Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Monnier2017-11-15 15:56:42 +0000
committerMaxime Porhel2017-11-27 15:35:02 +0000
commitd750d44f9faa069731501400b52fe6d5d851d71b (patch)
tree0c393d6f487805ba0fb60b3c2d13d8eb9ff41e32
parent328db0024854f6a88e5a7873aec896096fd51e7b (diff)
downloadorg.eclipse.sirius-d750d44f9faa069731501400b52fe6d5d851d71b.tar.gz
org.eclipse.sirius-d750d44f9faa069731501400b52fe6d5d851d71b.tar.xz
org.eclipse.sirius-d750d44f9faa069731501400b52fe6d5d851d71b.zip
[527299] Fields and method visibility change to avoid code duplication
Sirius provides the extension point org.eclipse.sirius.ui.editor.sessionEditorPageProvider in order to extend the behavior of the Overview page of the Aird Editor. To redefine the "New..." and "Add..." button without code duplication a few fields and methods needs to be set as protected. Bug: 527299 Change-Id: I2482b61d88a22e5d99a069b3467e6d7c6b2dfab3 Signed-off-by: Steve Monnier <steve.monnier@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java16
-rw-r--r--plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/pages/DefaultSessionEditorPage.java51
2 files changed, 52 insertions, 15 deletions
diff --git a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java
index 2854f2286c..4ca9318601 100644
--- a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java
+++ b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/graphicalcomponents/GraphicalSemanticModelsHandler.java
@@ -156,7 +156,7 @@ public class GraphicalSemanticModelsHandler implements SessionListener, SessionM
/**
* Session from which semantic models are handled.
*/
- private Session session;
+ protected Session session;
/**
* The Form Toolkit to use to create & configure the controls.
@@ -314,8 +314,7 @@ public class GraphicalSemanticModelsHandler implements SessionListener, SessionM
});
newButton.setToolTipText(Messages.GraphicalSemanticModelsHandler_newModelButton_tooltip);
Button addButton = addButton(buttonsComposite, Messages.UI_SessionEditor_models_button_newSemanticModel, () -> {
- AddModelDependencyAction addModelDependencyAction = new AddModelDependencyAction(session, false);
- addModelDependencyAction.run();
+ addExistingSemanticModel();
});
addButton.setToolTipText(Messages.GraphicalSemanticModelsHandler_addModelButton_tooltip);
removeSemanticModelDependencyButton = addButton(buttonsComposite, Messages.UI_SessionEditor_models_button_removeSemanticModel, () -> {
@@ -340,7 +339,7 @@ public class GraphicalSemanticModelsHandler implements SessionListener, SessionM
* Use the generic model creation wizard to create a new resource, and if
* successful register it as a new semantic resource in the session.
*/
- private void createAndRegisterNewSemanticModel() {
+ protected void createAndRegisterNewSemanticModel() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IContainer context = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(session.getSessionResource().getURI().toPlatformString(true))).getParent();
CreateEMFModelWizard wizard = new CreateEMFModelWizard(EPackage.Registry.INSTANCE, new StructuredSelection(context));
@@ -364,6 +363,15 @@ public class GraphicalSemanticModelsHandler implements SessionListener, SessionM
}
/**
+ * Use the generic wizard to add a dependency to an already existing
+ * semantic model.
+ */
+ protected void addExistingSemanticModel() {
+ AddModelDependencyAction addModelDependencyAction = new AddModelDependencyAction(session, false);
+ addModelDependencyAction.run();
+ }
+
+ /**
* Create Model explorer navigator.
*
* @param parent
diff --git a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/pages/DefaultSessionEditorPage.java b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/pages/DefaultSessionEditorPage.java
index 1104444e90..5edf4c8f42 100644
--- a/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/pages/DefaultSessionEditorPage.java
+++ b/plugins/org.eclipse.sirius.ui.editor/src/org/eclipse/sirius/ui/editor/internal/pages/DefaultSessionEditorPage.java
@@ -81,14 +81,14 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
private static final String DELIMITER = "/"; //$NON-NLS-1$
/**
- * Session to describe and edit.
+ * Current editor.
*/
- private Session session;
+ protected SessionEditor editor;
/**
- * Label used to provides information regarding editor's context.
+ * Session to describe and edit.
*/
- private FormText informativeLabel;
+ protected Session session;
/**
* This graphical component provides a viewer showing all semantic models
@@ -97,6 +97,11 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
private GraphicalSemanticModelsHandler graphicalSemanticModelsHandler;
/**
+ * Label used to provides information regarding editor's context.
+ */
+ private FormText informativeLabel;
+
+ /**
* The graphical component providing a viewer showing all representations
* belonging to the given session under corresponding viewpoints objects
*/
@@ -112,8 +117,6 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
*/
private FilterActionGroup filterActionGroup;
- private SessionEditor editor;
-
/**
* Constructor.
*
@@ -121,9 +124,23 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
* the editor.
*/
public DefaultSessionEditorPage(SessionEditor theEditor) {
- super(theEditor, SessionEditorPlugin.DEFAULT_PAGE_ID, Messages.UI_SessionEditor_default_page_tab_label);
- this.session = theEditor.getSession();
- this.editor = theEditor;
+ this(theEditor, SessionEditorPlugin.DEFAULT_PAGE_ID, Messages.UI_SessionEditor_default_page_tab_label);
+ }
+
+ /**
+ * A constructor that creates the page and initializes it with the editor.
+ *
+ * @param editor
+ * the parent editor
+ * @param id
+ * the unique identifier
+ * @param title
+ * the page title
+ */
+ public DefaultSessionEditorPage(SessionEditor editor, String id, String title) {
+ super(editor, id, title);
+ this.session = editor.getSession();
+ this.editor = editor;
}
@Override
@@ -216,8 +233,7 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
modelSectionClient.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
modelSection.setClient(modelSectionClient);
- graphicalSemanticModelsHandler = new GraphicalSemanticModelsHandler(session, toolkit, ((IEditorSite) editor.getSite()).getActionBars(), ((IEditorSite) editor.getSite()).getSelectionProvider(),
- this.getSite());
+ graphicalSemanticModelsHandler = createGraphicalSemanticModelsHandler(toolkit);
graphicalSemanticModelsHandler.createControl(modelSectionClient);
getSite().setSelectionProvider(graphicalSemanticModelsHandler.getTreeViewer());
@@ -225,6 +241,19 @@ public class DefaultSessionEditorPage extends AbstractSessionEditorPage implemen
}
/**
+ * Initialize the {@link GraphicalSemanticModelsHandler} used for the aird
+ * editor.
+ *
+ * @param toolkit
+ * the tool allowing to create form UI component.
+ * @return the {@link GraphicalSemanticModelsHandler} used for the aird
+ * editor.
+ */
+ protected GraphicalSemanticModelsHandler createGraphicalSemanticModelsHandler(FormToolkit toolkit) {
+ return new GraphicalSemanticModelsHandler(session, toolkit, ((IEditorSite) editor.getSite()).getActionBars(), ((IEditorSite) editor.getSite()).getSelectionProvider(), this.getSite());
+ }
+
+ /**
* Init the collapse all and customize view(CNF filter and content provider)
* buttons in the section toolbar.
*

Back to the top