aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2013-07-22 06:34:03 (EDT)
committerGerrit Code Review @ Eclipse.org2013-08-13 13:08:02 (EDT)
commit363bf2ff71b457f076f3744b0a0eca27936ba50e (patch)
treef7696ee880d28ee3d72f627288ed63064aced71a
parent74f064e095b6118334f3be864b4827d4bc97ed6a (diff)
downloadeclipse.platform.ui-363bf2ff71b457f076f3744b0a0eca27936ba50e.zip
eclipse.platform.ui-363bf2ff71b457f076f3744b0a0eca27936ba50e.tar.gz
eclipse.platform.ui-363bf2ff71b457f076f3744b0a0eca27936ba50e.tar.bz2
Bug 413431 - Uses injection to access the MApplication objectI20130813-1330refs/changes/40/14740/5
Bug: https://bugs.eclipse.org/413431 Change-Id: I335822fd13bff0da562fb92697e4ff40e3f3f457 Signed-off-by: Lars Vogel <Lars.Vogel@gmail.com>
-rw-r--r--examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/AbstractThemeProcessor.java12
-rw-r--r--examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/MenuThemeProcessor.java27
-rw-r--r--examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/ToolbarThemeProcessor.java24
3 files changed, 27 insertions, 36 deletions
diff --git a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/AbstractThemeProcessor.java b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/AbstractThemeProcessor.java
index 89811fe..d5fc7db 100644
--- a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/AbstractThemeProcessor.java
+++ b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/AbstractThemeProcessor.java
@@ -9,6 +9,7 @@
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
* Kai Tödter - Adoption to contacts demo
+ * Lars Vogel <lars.vogel@gmail.com> - Bug https://bugs.eclipse.org/413431
******************************************************************************/
package org.eclipse.e4.demo.contacts.processors;
@@ -34,10 +35,10 @@ import org.osgi.framework.ServiceReference;
public abstract class AbstractThemeProcessor {
- @Execute
- public void process() {
- if (!check())
+ public void process(MApplication app) {
+ if (!check()) {
return;
+ }
// FIXME Remove once bug 314091 is resolved
Bundle bundle = FrameworkUtil.getBundle(getClass());
@@ -50,10 +51,9 @@ public abstract class AbstractThemeProcessor {
List<ITheme> themes = engine.getThemes();
if (themes.size() > 0) {
- MApplication application = getApplication();
MCommand switchThemeCommand = null;
- for (MCommand cmd : application.getCommands()) {
+ for (MCommand cmd : app.getCommands()) {
if ("contacts.switchTheme".equals(cmd.getElementId())) { //$NON-NLS-1$
switchThemeCommand = cmd;
break;
@@ -91,8 +91,6 @@ public abstract class AbstractThemeProcessor {
abstract protected void postprocess();
- abstract protected MApplication getApplication();
-
private String getCSSUri(String themeId) {
IExtensionRegistry registry = RegistryFactory.getRegistry();
IExtensionPoint extPoint = registry
diff --git a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/MenuThemeProcessor.java b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/MenuThemeProcessor.java
index e973031..58508d4 100644
--- a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/MenuThemeProcessor.java
+++ b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/MenuThemeProcessor.java
@@ -9,26 +9,22 @@
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
* Kai Tödter - Adoption to contacts demo
+ * Lars Vogel <lars.vogel@gmail.com> - Bug https://bugs.eclipse.org/413431
******************************************************************************/
package org.eclipse.e4.demo.contacts.processors;
import java.util.List;
-import org.eclipse.e4.core.di.annotations.Execute;
-
import javax.inject.Inject;
import javax.inject.Named;
+import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
-import org.eclipse.emf.ecore.EObject;
public class MenuThemeProcessor extends AbstractThemeProcessor {
- // should be bundleclass, see bug 374961
- // private static final String BUNDLE_ID =
- // "bundleclass://org.eclipse.e4.demo.contacts/org.eclipse.e4.demo.contacts.processors.MenuThemeProcessor
private static final String BUNDLE_ID = "platform:/plugin/org.eclipse.e4.demo.contacts"; //$NON-NLS-1$
@Inject
@@ -39,20 +35,23 @@ public class MenuThemeProcessor extends AbstractThemeProcessor {
private final static String PROCESSOR_ID = "org.eclipse.e4.demo.contacts.processor.menu";
@Execute
- public void process() {
- if (menu == null)
+ public void execute(MApplication app) {
+ if (menu == null) {
return;
+ }
- MApplication theApp = getApplication();
- List<String> tags = theApp.getTags();
+ List<String> tags = app.getTags();
for(String tag : tags) {
if (PROCESSOR_ID.equals(tag))
+ {
return; // already processed
+ }
}
- if (!check())
+ if (!check()) {
return;
+ }
tags.add(PROCESSOR_ID);
- super.process();
+ super.process(app);
}
@Override
@@ -88,8 +87,4 @@ public class MenuThemeProcessor extends AbstractThemeProcessor {
menu.getChildren().add(themesMenu);
}
- @Override
- protected MApplication getApplication() {
- return (MApplication) (((EObject) menu).eContainer()).eContainer();
- }
}
diff --git a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/ToolbarThemeProcessor.java b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/ToolbarThemeProcessor.java
index 679a4c1..491a99d 100644
--- a/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/ToolbarThemeProcessor.java
+++ b/examples/org.eclipse.e4.demo.contacts/src/org/eclipse/e4/demo/contacts/processors/ToolbarThemeProcessor.java
@@ -8,22 +8,21 @@
*
* Contributors:
* Kai Tödter - initial implementation
+ * Lars Vogel <lars.vogel@gmail.com> - Bug https://bugs.eclipse.org/413431
******************************************************************************/
package org.eclipse.e4.demo.contacts.processors;
import java.util.List;
-import org.eclipse.e4.core.di.annotations.Execute;
-
import javax.inject.Inject;
import javax.inject.Named;
+import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.ui.menu.MHandledToolItem;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
import org.eclipse.e4.ui.model.application.ui.menu.MToolBar;
-import org.eclipse.emf.ecore.EObject;
public class ToolbarThemeProcessor extends AbstractThemeProcessor {
@@ -34,20 +33,23 @@ public class ToolbarThemeProcessor extends AbstractThemeProcessor {
private final static String PROCESSOR_ID = "org.eclipse.e4.demo.contacts.processor.toolbar";
@Execute
- public void process() {
- if (toolbar == null)
+ public void execute(MApplication app) {
+ if (toolbar == null) {
return;
+ }
- MApplication theApp = getApplication();
- List<String> tags = theApp.getTags();
+ List<String> tags = app.getTags();
for(String tag : tags) {
if (PROCESSOR_ID.equals(tag))
+ {
return; // already processed
+ }
}
- if (!check())
+ if (!check()) {
return;
+ }
tags.add(PROCESSOR_ID);
- super.process();
+ super.process(app);
}
@Override
@@ -79,8 +81,4 @@ public class ToolbarThemeProcessor extends AbstractThemeProcessor {
protected void postprocess() {
}
- @Override
- protected MApplication getApplication() {
- return (MApplication) (((EObject) toolbar).eContainer()).eContainer().eContainer();
- }
}