Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2017-02-20 13:57:07 +0000
committerJoao Barata2017-08-02 13:38:42 +0000
commita434a1609dc9cba43003d99aac1ab6dbace62759 (patch)
tree3f20e37c5a8e8452809904f270b5e7e6db1e2238
parent12501a5eb458d34b7f2a7a1f9755eb9d6cd46709 (diff)
downloadorg.eclipse.amalgam-a434a1609dc9cba43003d99aac1ab6dbace62759.tar.gz
org.eclipse.amalgam-a434a1609dc9cba43003d99aac1ab6dbace62759.tar.xz
org.eclipse.amalgam-a434a1609dc9cba43003d99aac1ab6dbace62759.zip
[509735] Extract CommonActivityExplorerPage configuration into separate class
Bug: 509735 Change-Id: I13ce8d730bbe2720a2e3ea894f6cdabbbe88d812 Signed-off-by: Pierre-Charles David <pierre-charles.david@obeo.fr>
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/configuration/CommonActivityExplorerPageConfiguration.java107
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java2
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java306
-rw-r--r--plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java10
4 files changed, 244 insertions, 181 deletions
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/configuration/CommonActivityExplorerPageConfiguration.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/configuration/CommonActivityExplorerPageConfiguration.java
new file mode 100644
index 00000000..4cd022aa
--- /dev/null
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/configuration/CommonActivityExplorerPageConfiguration.java
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * Copyright (c) 2017 THALES GLOBAL SERVICES.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Thales - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.amalgam.explorer.activity.ui.api.configuration;
+
+import org.eclipse.amalgam.explorer.activity.ui.api.editor.pages.CommonActivityExplorerPage;
+import org.eclipse.amalgam.explorer.activity.ui.api.editor.predicates.IPredicate;
+
+/**
+ * Encapsutates the configuration data for a
+ * {@link CommonActivityExplorerPage}.
+ *
+ * @author pcdavid
+ */
+public class CommonActivityExplorerPageConfiguration {
+ private int index;
+
+ private String title;
+
+ private String tabName;
+
+ public String pluginId;
+
+ private boolean overview;
+
+ private String overviewText;
+
+ private String overviewImageOnPath;
+
+ private String overviewImageOffPath;
+
+ private IPredicate predicate;
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public String getTabName() {
+ return tabName;
+ }
+
+ public void setTabName(String tabName) {
+ this.tabName = tabName;
+ }
+
+ public boolean isOverview() {
+ return overview;
+ }
+
+ public void setOverview(boolean overview) {
+ this.overview = overview;
+ }
+
+ public String getOverviewText() {
+ return overviewText;
+ }
+
+ public void setOverviewText(String overviewText) {
+ this.overviewText = overviewText;
+ }
+
+ public String getOverviewImageOnPath() {
+ return overviewImageOnPath;
+ }
+
+ public void setOverviewImageOnPath(String overviewImageOnPath) {
+ this.overviewImageOnPath = overviewImageOnPath;
+ }
+
+ public String getOverviewImageOffPath() {
+ return overviewImageOffPath;
+ }
+
+ public void setOverviewImageOffPath(String overviewImageOffPath) {
+ this.overviewImageOffPath = overviewImageOffPath;
+ }
+
+ public IPredicate getPredicate() {
+ return predicate;
+ }
+
+ public void setPredicate(IPredicate predicate) {
+ this.predicate = predicate;
+ }
+
+
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
index 2641721a..0a7be78e 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/ActivityExplorerPage.java
@@ -531,7 +531,7 @@ public class ActivityExplorerPage extends CommonActivityExplorerPage implements
* @return {@link IPredicate}
*/
public IPredicate getPredicate() {
- return predicate;
+ return config.getPredicate();
}
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
index 4f178ae7..121d9168 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/CommonActivityExplorerPage.java
@@ -14,8 +14,8 @@ import java.text.MessageFormat;
import org.eclipse.amalgam.explorer.activity.ui.ActivityExplorerActivator;
import org.eclipse.amalgam.explorer.activity.ui.IImageKeys;
+import org.eclipse.amalgam.explorer.activity.ui.api.configuration.CommonActivityExplorerPageConfiguration;
import org.eclipse.amalgam.explorer.activity.ui.api.editor.ActivityExplorerEditor;
-import org.eclipse.amalgam.explorer.activity.ui.api.editor.predicates.IPredicate;
import org.eclipse.amalgam.explorer.activity.ui.internal.extension.point.manager.ActivityExplorerExtensionManager;
import org.eclipse.amalgam.explorer.activity.ui.internal.intf.IOrdered;
import org.eclipse.amalgam.explorer.activity.ui.internal.intf.IVisibility;
@@ -31,218 +31,178 @@ import org.eclipse.ui.forms.editor.SharedHeaderFormEditor;
import org.eclipse.ui.forms.widgets.FormToolkit;
/**
- * Base class to implement ActivityExplorer pages in an {@link ActivityExplorerEditor}.
+ * Base class to implement ActivityExplorer pages in an
+ * {@link ActivityExplorerEditor}.
*/
public class CommonActivityExplorerPage extends FormPage implements IExecutableExtension, IOrdered, IVisibility, IPropertyListener {
- private boolean overview;
- private Image overviewImageOff;
- private String overviewText;
- private Image overviewImageOn;
- private String overviewImageOnPath;
- private String overviewImageOffPath;
- protected IPredicate predicate;
+ public static final int PROP_ACTIVE = 0x185;
- public static final int PROP_ACTIVE = 0x185;
+ private static String ids;
- private int index;
-
- private static String ids;
-
- public static void setID(String id) {
- ids = id;
- }
-
- public CommonActivityExplorerPage() {
- this(null, ids, ""); //$NON-NLS-1$
- }
-
- public CommonActivityExplorerPage(FormEditor editor, String id, String title) {
- super(editor, id, title);
-
- }
-
- /**
- * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
- */
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- FormToolkit toolkit = managedForm.getToolkit();
- toolkit.decorateFormHeading(managedForm.getForm().getForm());
- // For performance optimization.
- // managedForm.getForm().setDelayedReflow(true);
-
- getEditor().addPropertyListener(this);
-
- }
-
- /**
- * @see org.eclipse.ui.forms.editor.FormPage#getEditor()
- */
- @Override
- public SharedHeaderFormEditor getEditor() {
- return (SharedHeaderFormEditor) super.getEditor();
- }
-
- @Override
- public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
-
- super.setInitializationData(cfig, propertyName, data);
-
- String title = ActivityExplorerExtensionManager.getTitle(cfig);
- String tabName = ActivityExplorerExtensionManager.getTabName(cfig);
-
- if (tabName == null) {
- tabName = title;
+ public static void setID(String id) {
+ ids = id;
}
- setPartName(tabName);
-
- overview = ActivityExplorerExtensionManager.getOverviewElement(cfig) != null;
- if (overview) {
-
- overviewImageOffPath = ActivityExplorerExtensionManager.getOverviewImageOff(cfig);
- overviewImageOnPath = ActivityExplorerExtensionManager.getOverviewImageOn(cfig);
-
- String plugin_id = ActivityExplorerExtensionManager.getPluginId(cfig);
- if ((overviewImageOffPath.equals(IImageKeys.IMAGE_DEFAULT_OVERVIEW_OFF))) {
- plugin_id = ActivityExplorerActivator.ID;
- }
+ protected final CommonActivityExplorerPageConfiguration config = new CommonActivityExplorerPageConfiguration();
- setOverviewImageOff(ActivityExplorerActivator.getDefault().getImage(plugin_id, overviewImageOffPath));
+ private Image overviewImageOff;
- if ((overviewImageOnPath.equals(IImageKeys.IMAGE_DEFAULT_OVERVIEW_ON))) {
- plugin_id = ActivityExplorerActivator.ID;
- }
+ private Image overviewImageOn;
- setOverviewImageOn(ActivityExplorerActivator.getDefault().getImage(plugin_id, overviewImageOnPath));
-
- setOverViewText(ActivityExplorerExtensionManager.getOverviewDescription(cfig));
+ public CommonActivityExplorerPage() {
+ this(null, ids, ""); //$NON-NLS-1$
}
- predicate = ActivityExplorerExtensionManager.getPredicate(cfig);
-
- String indice = ActivityExplorerExtensionManager.getIndex(cfig);
- try {
- setIndex(Integer.parseInt(indice));
- } catch (NumberFormatException e) {
- throw new IllegalArgumentException(MessageFormat.format("Attribute ''{0}'' of page {1} must be an int, but was ''{2}''", ActivityExplorerExtensionManager.ATT_INDEX, ActivityExplorerExtensionManager.getId(cfig), indice));
+ public CommonActivityExplorerPage(FormEditor editor, String id, String title) {
+ super(editor, id, title);
}
- }
-
- private void setOverviewImageOn(Image image) {
- overviewImageOn = image;
-
- }
-
- public String getOverViewImageOnPath() {
- return overviewImageOnPath;
- }
-
- public String getOverViewImageOffPath() {
- return overviewImageOffPath;
-
- }
-
- public Image getOverViewImageOn() {
- return overviewImageOn;
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ FormToolkit toolkit = managedForm.getToolkit();
+ toolkit.decorateFormHeading(managedForm.getForm().getForm());
+ // For performance optimization.
+ // managedForm.getForm().setDelayedReflow(true);
+ getEditor().addPropertyListener(this);
+ }
- }
+ @Override
+ public SharedHeaderFormEditor getEditor() {
+ return (SharedHeaderFormEditor) super.getEditor();
+ }
- private void setOverViewText(String text) {
- overviewText = text;
+ @Override
+ public void setInitializationData(IConfigurationElement cfg, String propertyName, Object data) {
+ super.setInitializationData(cfg, propertyName, data);
- }
+ parseConfiguration(cfg);
+ setPartName(config.getTabName());
- public String getOverViewText() {
- return overviewText;
+ String plugin_id = config.pluginId;
+ if (config.getOverviewImageOffPath().equals(IImageKeys.IMAGE_DEFAULT_OVERVIEW_OFF)) {
+ plugin_id = ActivityExplorerActivator.ID;
+ }
+ overviewImageOff = ActivityExplorerActivator.getDefault().getImage(plugin_id, config.getOverviewImageOffPath());
+ if (config.getOverviewImageOnPath().equals(IImageKeys.IMAGE_DEFAULT_OVERVIEW_ON)) {
+ plugin_id = ActivityExplorerActivator.ID;
+ }
+ overviewImageOn = ActivityExplorerActivator.getDefault().getImage(plugin_id, config.getOverviewImageOnPath());
- }
+ setIndex(config.getIndex());
+ }
- private void setOverviewImageOff(Image image) {
- overviewImageOff = image;
- }
+ private void parseConfiguration(IConfigurationElement cfig) {
+ config.setTitle(ActivityExplorerExtensionManager.getTitle(cfig));
+ config.setTabName(ActivityExplorerExtensionManager.getTabName(cfig));
+ if (config.getTabName() == null) {
+ config.setTabName(config.getTitle());
+ }
+ config.setOverview(ActivityExplorerExtensionManager.getOverviewElement(cfig) != null);
+ config.pluginId = ActivityExplorerExtensionManager.getPluginId(cfig);
+ if (config.isOverview()) {
+ config.setOverviewImageOffPath(ActivityExplorerExtensionManager.getOverviewImageOff(cfig));
+ config.setOverviewImageOnPath(ActivityExplorerExtensionManager.getOverviewImageOn(cfig));
+ config.setOverviewText(ActivityExplorerExtensionManager.getOverviewDescription(cfig));
+ }
+ config.setPredicate(ActivityExplorerExtensionManager.getPredicate(cfig));
+
+ String indice = ActivityExplorerExtensionManager.getIndex(cfig);
+ try {
+ this.config.setIndex(Integer.parseInt(indice));
+ } catch (NumberFormatException e) {
+ throw new IllegalArgumentException(MessageFormat.format("Attribute ''{0}'' of page {1} must be an int, but was ''{2}''", ActivityExplorerExtensionManager.ATT_INDEX,
+ ActivityExplorerExtensionManager.getId(cfig), indice));
+ }
+ }
- public Image getOverviewImageOff() {
- return overviewImageOff;
- }
+ public String getOverViewImageOnPath() {
+ return config.getOverviewImageOnPath();
+ }
- public boolean contributeToOverview() {
- return overview;
- }
+ public String getOverViewImageOffPath() {
+ return config.getOverviewImageOffPath();
+ }
- public void contributeToOverview(boolean contribute) {
- overview = contribute;
- }
+ public Image getOverViewImageOn() {
+ return overviewImageOn;
+ }
- /**
- * Return true this page is visible.
- */
- @Override
- public boolean isVisible() {
- boolean result = ActivityExplorerActivator.getDefault().getPreferenceStore().getBoolean(getId());
+ public String getOverViewText() {
+ return config.getOverviewText();
+ }
- if (predicate != null) {
- result &= predicate.isOk();
+ public Image getOverviewImageOff() {
+ return overviewImageOff;
}
- return result;
- }
- public int getPosition() {
- return index;
- }
+ public boolean contributeToOverview() {
+ return config.isOverview();
+ }
- public void setPosition(int index) {
- this.index = index;
+ public void contributeToOverview(boolean contribute) {
+ config.setOverview(contribute);
+ }
- }
+ /**
+ * Return true this page is visible.
+ */
+ @Override
+ public boolean isVisible() {
+ boolean result = ActivityExplorerActivator.getDefault().getPreferenceStore().getBoolean(getId());
+ if (config.getPredicate() != null) {
+ result &= config.getPredicate().isOk();
+ }
+ return result;
+ }
- @Override
- public int getIndex() {
- return index;
- }
+ public int getPosition() {
+ return config.getIndex();
+ }
- @Override
- public void setIndex(int index) {
- this.index = index;
+ public void setPosition(int index) {
+ this.config.setIndex(index);
+ }
- }
+ @Override
+ public int getIndex() {
+ return config.getIndex();
+ }
- public int compareTo(IOrdered arg0) {
- int result = 1;
- if (null != arg0) {
- result = new Integer(getPosition()).compareTo(new Integer(arg0.getPosition()));
+ @Override
+ public void setIndex(int index) {
+ this.config.setIndex(index);
}
- return result;
- }
+ public int compareTo(IOrdered other) {
+ int result = 1;
+ if (null != other) {
+ result = Integer.valueOf(getPosition()).compareTo(Integer.valueOf(other.getPosition()));
+ }
+ return result;
+ }
- @Override
- public void setActive(boolean active) {
- super.setActive(active);
- if (active) {
- markAsActive();
+ @Override
+ public void setActive(boolean active) {
+ super.setActive(active);
+ if (active) {
+ markAsActive();
+ }
}
- }
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, int)
- */
- @Override
- public void propertyChanged(Object source, int propId) {
- if (IEditorPart.PROP_DIRTY == propId) {
- markAsDirty();
+ @Override
+ public void propertyChanged(Object source, int propId) {
+ if (IEditorPart.PROP_DIRTY == propId) {
+ markAsDirty();
+ }
}
- }
- public void markAsDirty() {
- firePropertyChange(IEditorPart.PROP_DIRTY);
- }
+ public void markAsDirty() {
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ }
- public void markAsActive() {
- firePropertyChange(PROP_ACTIVE);
- }
+ public void markAsActive() {
+ firePropertyChange(PROP_ACTIVE);
+ }
}
diff --git a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
index 30a98e25..f1b85d9e 100644
--- a/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
+++ b/plugins/org.eclipse.amalgam.explorer.activity.ui/src/org/eclipse/amalgam/explorer/activity/ui/api/editor/pages/OverviewActivityExplorerPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2016 THALES GLOBAL SERVICES.
+ * Copyright (c) 2006, 2017 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -253,16 +253,12 @@ public class OverviewActivityExplorerPage extends CommonActivityExplorerPage {
return composite;
}
- // public Composite getSubFormComposite(final String id) {
- // return contents.get(id);
- // }
-
@Override
public boolean isVisible() {
// By default all Overview page are visible (cf. bug 485652)
boolean result = true;
- if (predicate != null) {
- result &= predicate.isOk();
+ if (config.getPredicate() != null) {
+ result &= config.getPredicate().isOk();
}
return result;
}

Back to the top