From: Christian Femers Date: Mon, 29 Apr 2019 10:57:37 +0000 (+0200) Subject: Basic Test X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=6a05507878963e5724ba4e3f636901a6a029df98;p=Mograsim.git Basic Test --- 6a05507878963e5724ba4e3f636901a6a029df98 diff --git a/com.example.e4.rcp/.classpath b/com.example.e4.rcp/.classpath new file mode 100644 index 00000000..ca3785c4 --- /dev/null +++ b/com.example.e4.rcp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/com.example.e4.rcp/.gitignore b/com.example.e4.rcp/.gitignore new file mode 100644 index 00000000..ae3c1726 --- /dev/null +++ b/com.example.e4.rcp/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/com.example.e4.rcp/.project b/com.example.e4.rcp/.project new file mode 100644 index 00000000..780f001c --- /dev/null +++ b/com.example.e4.rcp/.project @@ -0,0 +1,28 @@ + + + com.example.e4.rcp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.example.e4.rcp/.settings/org.eclipse.jdt.core.prefs b/com.example.e4.rcp/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000..bd1095bb --- /dev/null +++ b/com.example.e4.rcp/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,9 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=11 +org.eclipse.jdt.core.compiler.compliance=11 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=11 diff --git a/com.example.e4.rcp/Application.e4xmi b/com.example.e4.rcp/Application.e4xmi new file mode 100644 index 00000000..f7b641e0 --- /dev/null +++ b/com.example.e4.rcp/Application.e4xmi @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.example.e4.rcp/META-INF/MANIFEST.MF b/com.example.e4.rcp/META-INF/MANIFEST.MF new file mode 100644 index 00000000..ae7ce585 --- /dev/null +++ b/com.example.e4.rcp/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Rcp +Bundle-SymbolicName: com.example.e4.rcp;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: EXAMPLE +Require-Bundle: javax.inject;bundle-version="0.0.0", + org.eclipse.core.runtime;bundle-version="0.0.0", + org.eclipse.swt;bundle-version="0.0.0", + org.eclipse.e4.ui.model.workbench;bundle-version="0.0.0", + org.eclipse.jface;bundle-version="0.0.0", + org.eclipse.e4.ui.services;bundle-version="0.0.0", + org.eclipse.e4.ui.workbench;bundle-version="0.0.0", + org.eclipse.e4.core.di;bundle-version="0.0.0", + org.eclipse.e4.ui.di;bundle-version="0.0.0", + org.eclipse.e4.core.contexts;bundle-version="0.0.0" +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Import-Package: javax.annotation;version="1.0.0";resolution:=optional, + javax.inject;version="1.0.0" +Automatic-Module-Name: com.example.e4.rcp diff --git a/com.example.e4.rcp/build.properties b/com.example.e4.rcp/build.properties new file mode 100644 index 00000000..163f78c0 --- /dev/null +++ b/com.example.e4.rcp/build.properties @@ -0,0 +1,8 @@ +source.. = src/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + css/default.css,\ + Application.e4xmi diff --git a/com.example.e4.rcp/com.example.e4.rcp.product b/com.example.e4.rcp/com.example.e4.rcp.product new file mode 100644 index 00000000..eaf91b83 --- /dev/null +++ b/com.example.e4.rcp/com.example.e4.rcp.product @@ -0,0 +1,102 @@ + + + + + + + + + + + -clearPersistedState + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/com.example.e4.rcp/css/default.css b/com.example.e4.rcp/css/default.css new file mode 100644 index 00000000..e69de29b diff --git a/com.example.e4.rcp/icons/debug_view.png b/com.example.e4.rcp/icons/debug_view.png new file mode 100644 index 00000000..97d5e2d7 Binary files /dev/null and b/com.example.e4.rcp/icons/debug_view.png differ diff --git a/com.example.e4.rcp/icons/home.png b/com.example.e4.rcp/icons/home.png new file mode 100644 index 00000000..e9ace41c Binary files /dev/null and b/com.example.e4.rcp/icons/home.png differ diff --git a/com.example.e4.rcp/icons/open_in_app.png b/com.example.e4.rcp/icons/open_in_app.png new file mode 100644 index 00000000..9df4eeb7 Binary files /dev/null and b/com.example.e4.rcp/icons/open_in_app.png differ diff --git a/com.example.e4.rcp/icons/save_edit.png b/com.example.e4.rcp/icons/save_edit.png new file mode 100644 index 00000000..b17caf5a Binary files /dev/null and b/com.example.e4.rcp/icons/save_edit.png differ diff --git a/com.example.e4.rcp/plugin.xml b/com.example.e4.rcp/plugin.xml new file mode 100644 index 00000000..1c02c2cf --- /dev/null +++ b/com.example.e4.rcp/plugin.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/handlers/AboutHandler.java b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/AboutHandler.java new file mode 100644 index 00000000..e1348aba --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/AboutHandler.java @@ -0,0 +1,12 @@ +package com.example.e4.rcp.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + +public class AboutHandler { + @Execute + public void execute(Shell shell) { + MessageDialog.openInformation(shell, "About", "Eclipse 4 RCP Application"); + } +} diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/handlers/OpenHandler.java b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/OpenHandler.java new file mode 100644 index 00000000..9f240d8c --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/OpenHandler.java @@ -0,0 +1,13 @@ +package com.example.e4.rcp.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +public class OpenHandler { + + @Execute + public void execute(Shell shell){ + FileDialog dialog = new FileDialog(shell); + dialog.open(); + } +} diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/handlers/QuitHandler.java b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/QuitHandler.java new file mode 100644 index 00000000..9fce036d --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/QuitHandler.java @@ -0,0 +1,17 @@ +package com.example.e4.rcp.handlers; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.workbench.IWorkbench; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Shell; + + +public class QuitHandler { + @Execute + public void execute(IWorkbench workbench, Shell shell){ + if (MessageDialog.openConfirm(shell, "Confirmation", + "Do you want to exit?")) { + workbench.close(); + } + } +} diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/handlers/SaveHandler.java b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/SaveHandler.java new file mode 100644 index 00000000..e15be940 --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/handlers/SaveHandler.java @@ -0,0 +1,21 @@ +package com.example.e4.rcp.handlers; + +import org.eclipse.e4.core.di.annotations.CanExecute; +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.ui.workbench.modeling.EPartService; + +public class SaveHandler { + + @CanExecute + public boolean canExecute(EPartService partService) { + if (partService != null) { + return !partService.getDirtyParts().isEmpty(); + } + return false; + } + + @Execute + public void execute(EPartService partService) { + partService.saveAll(false); + } +} \ No newline at end of file diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/parts/NPart.java b/com.example.e4.rcp/src/com/example/e4/rcp/parts/NPart.java new file mode 100644 index 00000000..520ed136 --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/parts/NPart.java @@ -0,0 +1,22 @@ + +package com.example.e4.rcp.parts; + +import javax.inject.Inject; +import javax.annotation.PostConstruct; +import org.eclipse.swt.widgets.Composite; + +public class NPart { + @Inject + public NPart() { + + } + + @PostConstruct + public void postConstruct(Composite parent) { + + } + + + + +} \ No newline at end of file diff --git a/com.example.e4.rcp/src/com/example/e4/rcp/parts/SamplePart.java b/com.example.e4.rcp/src/com/example/e4/rcp/parts/SamplePart.java new file mode 100644 index 00000000..160ba8ac --- /dev/null +++ b/com.example.e4.rcp/src/com/example/e4/rcp/parts/SamplePart.java @@ -0,0 +1,55 @@ +package com.example.e4.rcp.parts; + +import java.util.Arrays; +import java.util.List; +import javax.annotation.PostConstruct; +import javax.inject.Inject; + +import org.eclipse.e4.ui.di.Focus; +import org.eclipse.e4.ui.di.Persist; +import org.eclipse.e4.ui.model.application.ui.basic.MPart; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; + +public class SamplePart { + + private TableViewer tableViewer; + + @Inject + private MPart part; + + @PostConstruct + public void createComposite(Composite parent) { + parent.setLayout(new GridLayout(1, false)); + + Text txtInput = new Text(parent, SWT.BORDER); + txtInput.setMessage("Enter text to mark part as dirty"); + txtInput.addModifyListener(e -> part.setDirty(true)); + txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + tableViewer = new TableViewer(parent); + + tableViewer.setContentProvider(ArrayContentProvider.getInstance()); + tableViewer.setInput(createInitialDataModel()); + tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); + } + + @Focus + public void setFocus() { + tableViewer.getTable().setFocus(); + } + + @Persist + public void save() { + part.setDirty(false); + } + + private List createInitialDataModel() { + return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5"); + } +} \ No newline at end of file