From: Christian Femers Date: Tue, 4 Jun 2019 01:52:04 +0000 (+0200) Subject: Eclipse e4 and translation experiments X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=b6807ba38574bccd122cd9414c883cd73ca61163;p=Mograsim.git Eclipse e4 and translation experiments --- diff --git a/net.mograsim.rcp/Application.e4xmi b/net.mograsim.rcp/Application.e4xmi index 3caa9c19..1aa84444 100644 --- a/net.mograsim.rcp/Application.e4xmi +++ b/net.mograsim.rcp/Application.e4xmi @@ -1,23 +1,31 @@ - + - - + + - + - - - - + + + + - - + + + + + + + + + + @@ -31,6 +39,7 @@ + @@ -41,10 +50,13 @@ - - - - + + + + + + + diff --git a/net.mograsim.rcp/META-INF/MANIFEST.MF b/net.mograsim.rcp/META-INF/MANIFEST.MF index 1c5e2a77..cf712fe5 100644 --- a/net.mograsim.rcp/META-INF/MANIFEST.MF +++ b/net.mograsim.rcp/META-INF/MANIFEST.MF @@ -4,6 +4,10 @@ Bundle-Name: %Bundle-Name Bundle-SymbolicName: net.mograsim.rcp;singleton:=true Bundle-Version: 1.0.0.qualifier Bundle-Vendor: %Bundle-Vendor +Bundle-Localization: OSGI-INF/l10n/bundle +Export-Package: net.mograsim.rcp.handlers;uses:="org.eclipse.swt.widgets,org.eclipse.e4.ui.workbench,org.eclipse.e4.ui.workbench.modeling", + net.mograsim.rcp.parts;uses:="org.eclipse.swt.widgets", + net.mograsim.rcp.splashhandlers Require-Bundle: org.eclipse.core.runtime;bundle-version="3.15.200", org.eclipse.e4.ui.model.workbench;bundle-version="2.1.300", org.eclipse.jface;bundle-version="3.15.100", @@ -12,9 +16,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="3.15.200", org.eclipse.e4.ui.di;bundle-version="1.2.500", org.eclipse.ui.workbench;bundle-version="3.113.0", javax.annotation;bundle-version="1.2.0", - net.mograsim.logic.ui + net.mograsim.logic.ui, + org.eclipse.osgi.services;bundle-version="3.8.0", + org.eclipse.e4.core.services;bundle-version="2.1.400" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Automatic-Module-Name: Sample -Export-Package: net.mograsim.rcp.handlers;uses:="org.eclipse.swt.widgets,org.eclipse.e4.ui.workbench,org.eclipse.e4.ui.workbench.modeling", - net.mograsim.rcp.parts;uses:="org.eclipse.swt.widgets", - net.mograsim.rcp.splashhandlers +Import-Package: javax.inject;version="1.0.0" diff --git a/net.mograsim.rcp/OSGI-INF/l10n/bundle.properties b/net.mograsim.rcp/OSGI-INF/l10n/bundle.properties index e07734a8..11c4aaf3 100644 --- a/net.mograsim.rcp/OSGI-INF/l10n/bundle.properties +++ b/net.mograsim.rcp/OSGI-INF/l10n/bundle.properties @@ -3,4 +3,20 @@ Bundle-Vendor = MYSELF Bundle-Name = Sample product.name = Sample extension-point.name = Splash Extensions -product.name.0 = Simulator WIP \ No newline at end of file +product.name = Simulator WIP +trimmedwindow.label.1 = Sample RCP4 +part.label.1 = Sample Part +part.label.2 = LogicUI part +part.label.3 = None +part.tooltip.1 = Something +menu.label.1 = File +handledmenuitem.label.1 = Open +handledmenuitem.label.2 = Save +handledmenuitem.label.3 = Quit +menu.label.2 = Help +handledmenuitem.label.4 = About +command.commandname.1 = quitCommand +command.commandname.2 = openCommand +command.commandname.3 = saveCommand +command.commandname.4 = aboutCommand +sample_part_input_hint = Enter text to mark part as dirty diff --git a/net.mograsim.rcp/OSGI-INF/l10n/bundle_de.properties b/net.mograsim.rcp/OSGI-INF/l10n/bundle_de.properties new file mode 100644 index 00000000..67bf1488 --- /dev/null +++ b/net.mograsim.rcp/OSGI-INF/l10n/bundle_de.properties @@ -0,0 +1,22 @@ +#Properties file for Sample +Bundle-Vendor = ICH +Bundle-Name = Beispiel +product.name = Beispiel +extension-point.name = Splash Extensions +product.name = Simulator WIP +trimmedwindow.label.1 = Beispiel RCP4 +part.label.1 = Sample Part +part.label.2 = LogicUI part +part.label.3 = Nix +part.tooltip.1 = Irgendwas +menu.label.1 = Datei +handledmenuitem.label.1 = Öffnen +handledmenuitem.label.2 = Speichern +handledmenuitem.label.3 = Schließen +menu.label.2 = Hilfe +handledmenuitem.label.4 = Über +command.commandname.1 = quitCommand +command.commandname.2 = openCommand +command.commandname.3 = saveCommand +command.commandname.4 = aboutCommand +sample_part_input_hint = ALKSKSKS diff --git a/net.mograsim.rcp/build.properties b/net.mograsim.rcp/build.properties index d1ae984b..7eb5b4a3 100644 --- a/net.mograsim.rcp/build.properties +++ b/net.mograsim.rcp/build.properties @@ -7,12 +7,11 @@ bin.includes = plugin.xml,\ css/,\ splash.bmp,\ schema/,\ - OSGI-INF/l10n/bundle.properties,\ OSGI-INF/ source.. = src/ src.includes = Application.e4xmi,\ - OSGI-INF/l10n/bundle.properties,\ css/,\ icons/,\ schema/,\ splash.bmp +javacProjectSettings = true diff --git a/net.mograsim.rcp/icons/af.png b/net.mograsim.rcp/icons/af.png deleted file mode 100644 index bcd0ce8a..00000000 Binary files a/net.mograsim.rcp/icons/af.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/embedded.png b/net.mograsim.rcp/icons/embedded.png deleted file mode 100644 index 57edc6a1..00000000 Binary files a/net.mograsim.rcp/icons/embedded.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/enterprise.png b/net.mograsim.rcp/icons/enterprise.png deleted file mode 100644 index 7fe2f5c8..00000000 Binary files a/net.mograsim.rcp/icons/enterprise.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/home.png b/net.mograsim.rcp/icons/home.png deleted file mode 100644 index e9ace41c..00000000 Binary files a/net.mograsim.rcp/icons/home.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/languages.png b/net.mograsim.rcp/icons/languages.png deleted file mode 100644 index 98af2daf..00000000 Binary files a/net.mograsim.rcp/icons/languages.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/open_in_app.png b/net.mograsim.rcp/icons/open_in_app.png deleted file mode 100644 index 9df4eeb7..00000000 Binary files a/net.mograsim.rcp/icons/open_in_app.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/rcp.png b/net.mograsim.rcp/icons/rcp.png deleted file mode 100644 index b248ca2b..00000000 Binary files a/net.mograsim.rcp/icons/rcp.png and /dev/null differ diff --git a/net.mograsim.rcp/icons/save_edit.png b/net.mograsim.rcp/icons/save_edit.png deleted file mode 100644 index b17caf5a..00000000 Binary files a/net.mograsim.rcp/icons/save_edit.png and /dev/null differ diff --git a/net.mograsim.rcp/plugin.xml b/net.mograsim.rcp/plugin.xml index a22663bd..7c2dac5f 100644 --- a/net.mograsim.rcp/plugin.xml +++ b/net.mograsim.rcp/plugin.xml @@ -8,14 +8,14 @@ point="org.eclipse.core.runtime.products"> + name="%product.name"> + value="%product.name"> - - - - - - - - - - - - diff --git a/net.mograsim.rcp/src/net/mograsim/rcp/handlers/LangHandler.java b/net.mograsim.rcp/src/net/mograsim/rcp/handlers/LangHandler.java new file mode 100644 index 00000000..f009a9bd --- /dev/null +++ b/net.mograsim.rcp/src/net/mograsim/rcp/handlers/LangHandler.java @@ -0,0 +1,22 @@ + +package net.mograsim.rcp.handlers; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.eclipse.e4.core.di.annotations.Execute; +import org.eclipse.e4.core.services.nls.ILocaleChangeService; + +public class LangHandler +{ + + @Inject + ILocaleChangeService lcs; + + @Execute + public void execute(@Named("change_lang_locale") String change_lang_locale) + { + lcs.changeApplicationLocale(change_lang_locale); + } + +} \ No newline at end of file diff --git a/net.mograsim.rcp/src/net/mograsim/rcp/i18n/Messages.java b/net.mograsim.rcp/src/net/mograsim/rcp/i18n/Messages.java new file mode 100644 index 00000000..fb9e5855 --- /dev/null +++ b/net.mograsim.rcp/src/net/mograsim/rcp/i18n/Messages.java @@ -0,0 +1,6 @@ +package net.mograsim.rcp.i18n; + +public class Messages +{ + public String sample_part_input_hint; +} diff --git a/net.mograsim.rcp/src/net/mograsim/rcp/parts/SamplePart.java b/net.mograsim.rcp/src/net/mograsim/rcp/parts/SamplePart.java index 0bbe8aac..fde7162c 100644 --- a/net.mograsim.rcp/src/net/mograsim/rcp/parts/SamplePart.java +++ b/net.mograsim.rcp/src/net/mograsim/rcp/parts/SamplePart.java @@ -6,6 +6,7 @@ import java.util.List; import javax.annotation.PostConstruct; import javax.inject.Inject; +import org.eclipse.e4.core.services.nls.Translation; import org.eclipse.e4.ui.di.Focus; import org.eclipse.e4.ui.di.Persist; import org.eclipse.e4.ui.model.application.ui.basic.MPart; @@ -17,10 +18,13 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Text; +import net.mograsim.rcp.i18n.Messages; + public class SamplePart { private TableViewer tableViewer; + private Text txtInput; @Inject private MPart part; @@ -30,7 +34,7 @@ public class SamplePart { parent.setLayout(new GridLayout(1, false)); - Text txtInput = new Text(parent, SWT.BORDER); + 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)); @@ -58,4 +62,11 @@ public class SamplePart { return Arrays.asList("Sample item 1", "Sample item 2", "Sample item 3", "Sample item 4", "Sample item 5"); } + + @Inject + public void translate(@Translation Messages m) + { + if (txtInput != null && !txtInput.isDisposed()) + txtInput.setMessage(m.sample_part_input_hint); + } } \ No newline at end of file