diff options
author | Camille Letavernier | 2014-08-21 11:37:18 +0000 |
---|---|---|
committer | Camille Letavernier | 2014-08-21 11:37:18 +0000 |
commit | ea48a20561464c3cbb7895d430583669a9f82fcc (patch) | |
tree | 0fdf9eebacbbb301b13bafce3ca4a6952ff6e91c /extraplugins/layers | |
parent | f91b71175fd97557cf378cdcad845a44a6274b16 (diff) | |
download | org.eclipse.papyrus-ea48a20561464c3cbb7895d430583669a9f82fcc.tar.gz org.eclipse.papyrus-ea48a20561464c3cbb7895d430583669a9f82fcc.tar.xz org.eclipse.papyrus-ea48a20561464c3cbb7895d430583669a9f82fcc.zip |
[Code style] Apply clean-up and formatter on Extra plug-ins
Diffstat (limited to 'extraplugins/layers')
531 files changed, 20719 insertions, 13500 deletions
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.dev.ui/src/org/eclipse/papyrus/layers/dev/ui/Activator.java b/extraplugins/layers/org.eclipse.papyrus.layers.dev.ui/src/org/eclipse/papyrus/layers/dev/ui/Activator.java index 94137e7ab64..43061b56daf 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.dev.ui/src/org/eclipse/papyrus/layers/dev/ui/Activator.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.dev.ui/src/org/eclipse/papyrus/layers/dev/ui/Activator.java @@ -4,7 +4,7 @@ * 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:
* Cedric Dumoulin - cedric.dumoulin@lifl.fr
******************************************************************************/
@@ -23,16 +23,20 @@ public class Activator implements BundleActivator { /*
* (non-Javadoc)
+ *
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
+ @Override
public void start(BundleContext bundleContext) throws Exception {
Activator.context = bundleContext;
}
/*
* (non-Javadoc)
+ *
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
+ @Override
public void stop(BundleContext bundleContext) throws Exception {
Activator.context = null;
}
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.integrationtests/test/org/eclipse/papyrus/layers/integrationtests/LayersStateAfterReloadTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.integrationtests/test/org/eclipse/papyrus/layers/integrationtests/LayersStateAfterReloadTest.java index 3f7512616af..c74a72541c1 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.integrationtests/test/org/eclipse/papyrus/layers/integrationtests/LayersStateAfterReloadTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.integrationtests/test/org/eclipse/papyrus/layers/integrationtests/LayersStateAfterReloadTest.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2014 Cedric Dumoulin.
*
- *
+ *
* 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
@@ -30,10 +30,6 @@ import org.eclipse.papyrus.infra.core.resource.NotFoundException; import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel;
import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationUtils;
-import org.eclipse.papyrus.integrationtests.editor.DiagramCreator;
-import org.eclipse.papyrus.integrationtests.editor.EclipseProject;
-import org.eclipse.papyrus.integrationtests.editor.ExecutionException;
-import org.eclipse.papyrus.integrationtests.editor.ProgramaticPapyrusEditor;
import org.eclipse.papyrus.layers.runtime.model.LayersModel;
import org.eclipse.papyrus.layers.stackmodel.LayersException;
import org.eclipse.papyrus.layers.stackmodel.layers.AbstractLayerOperator;
@@ -59,7 +55,7 @@ import org.junit.Test; /**
* Tests checking the states of the layers after a reload of the model.
* The state should normally be "ATTACHED".
- *
+ *
* @author cedric dumoulin
*
*/
@@ -91,12 +87,15 @@ public class LayersStateAfterReloadTest { }
/**
- * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createLayer(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}.
- * @throws LayersException
- * @throws ServiceException
- * @throws BadArgumentExcetion
- * @throws NotFoundException
- * @throws ExecutionException
+ * Test method for
+ * {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createLayer(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}
+ * .
+ *
+ * @throws LayersException
+ * @throws ServiceException
+ * @throws BadArgumentExcetion
+ * @throws NotFoundException
+ * @throws ExecutionException
*/
@Test
public void testReloadLayer() throws LayersException, ServiceException, NotFoundException, BadArgumentExcetion, ExecutionException {
@@ -104,48 +103,51 @@ public class LayersStateAfterReloadTest { // Create Editor
String modelName = "models/modeltestReload";
String diagramName = "diagram1";
-
-
+
+
EclipseProject eclipseProject = new EclipseProject(PLUGIN_PROJECT_NAME);
- eclipseProject.copyResources(BUNDLE_NAME, modelName+".di", modelName+".notation", modelName+".uml" );
+ eclipseProject.copyResources(BUNDLE_NAME, modelName + ".di", modelName + ".notation", modelName + ".uml");
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor(eclipseProject, modelName);
DiagramCreator diagramCreator = new DiagramCreator(editorHandler);
-
+
// Get the diagram:
// First the ModelSet, then the NotationModel, then the diagram by its name
ModelSet modelSet = editorHandler.getServiceRegistry().getService(ModelSet.class);
NotationModel notationModel = NotationUtils.getNotationModel(modelSet);
- Diagram diagram = notationModel.getDiagram(diagramName );
-
+ Diagram diagram = notationModel.getDiagram(diagramName);
+
// Get the LayerStack for the Layer
- LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID);
+ LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID);
LayersStackApplication application = layersModel.getLayerStackApplication();
LayersStack owningStack = application.lookupLayersStackFor(diagram);
-
+
// Recover tree
- TopLayerOperator rootLayer = (TopLayerOperator)owningStack.getLayers();
- Layer layer1 = (Layer)rootLayer.getLayers().get(0);
-
+ TopLayerOperator rootLayer = (TopLayerOperator) owningStack.getLayers();
+ Layer layer1 = (Layer) rootLayer.getLayers().get(0);
+
// Assert
assertNotNull("stack found in diagram", owningStack);
- assertSame("state attached", LayerState.ATTACHED, owningStack.getState() );
-
+ assertSame("state attached", LayerState.ATTACHED, owningStack.getState());
+
assertNotNull("Layer created", layer1);
- assertSame("state attached", LayerState.ATTACHED, layer1.getState() );
- assertSame("application set", application, layer1.getApplication() );
- assertSame("owningStack set", owningStack, layer1.getOwningLayersStack() );
- assertSame("parent set", rootLayer, layer1.eContainer() );
+ assertSame("state attached", LayerState.ATTACHED, layer1.getState());
+ assertSame("application set", application, layer1.getApplication());
+ assertSame("owningStack set", owningStack, layer1.getOwningLayersStack());
+ assertSame("parent set", rootLayer, layer1.eContainer());
}
/**
- * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createRegExpLayer(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}.
- * @throws LayersException
- * @throws ExecutionException
- * @throws ServiceException
- * @throws BadArgumentExcetion
- * @throws NotFoundException
+ * Test method for
+ * {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createRegExpLayer(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}
+ * .
+ *
+ * @throws LayersException
+ * @throws ExecutionException
+ * @throws ServiceException
+ * @throws BadArgumentExcetion
+ * @throws NotFoundException
*/
@Test
public void testReloadRegExpLayer() throws LayersException, ExecutionException, ServiceException, NotFoundException, BadArgumentExcetion {
@@ -153,43 +155,46 @@ public class LayersStateAfterReloadTest { // Create Editor
String modelName = "models/modeltestReload";
String diagramName = "diagram2";
-
-
+
+
EclipseProject eclipseProject = new EclipseProject(PLUGIN_PROJECT_NAME);
- eclipseProject.copyResources(BUNDLE_NAME, modelName+".di", modelName+".notation", modelName+".uml" );
+ eclipseProject.copyResources(BUNDLE_NAME, modelName + ".di", modelName + ".notation", modelName + ".uml");
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor(eclipseProject, modelName);
-
+
// Get the diagram:
// First the ModelSet, then the NotationModel, then the diagram by its name
ModelSet modelSet = editorHandler.getServiceRegistry().getService(ModelSet.class);
NotationModel notationModel = NotationUtils.getNotationModel(modelSet);
- Diagram diagram = notationModel.getDiagram(diagramName );
-
+ Diagram diagram = notationModel.getDiagram(diagramName);
+
// Get the LayerStack for the Layer
- LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID);
+ LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID);
LayersStackApplication application = layersModel.getLayerStackApplication();
LayersStack owningStack = application.lookupLayersStackFor(diagram);
-
+
// Recover tree
- TopLayerOperator rootLayer = (TopLayerOperator)owningStack.getLayers();
- RegExpLayer layer1 = (RegExpLayer)rootLayer.getLayers().get(0);
-
+ TopLayerOperator rootLayer = (TopLayerOperator) owningStack.getLayers();
+ RegExpLayer layer1 = (RegExpLayer) rootLayer.getLayers().get(0);
+
// asserts
assertNotNull("Layer created", layer1);
- assertSame("state attached", LayerState.ATTACHED, layer1.getState() );
- assertSame("application set", application, layer1.getApplication() );
- assertSame("owningStack set", owningStack, layer1.getOwningLayersStack() );
- assertSame("parent set", rootLayer, layer1.eContainer() );
+ assertSame("state attached", LayerState.ATTACHED, layer1.getState());
+ assertSame("application set", application, layer1.getApplication());
+ assertSame("owningStack set", owningStack, layer1.getOwningLayersStack());
+ assertSame("parent set", rootLayer, layer1.eContainer());
}
/**
- * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createTopLayerOperator(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}.
- * @throws LayersException
- * @throws ServiceException
- * @throws ExecutionException
- * @throws BadArgumentExcetion
- * @throws NotFoundException
+ * Test method for
+ * {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createTopLayerOperator(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}
+ * .
+ *
+ * @throws LayersException
+ * @throws ServiceException
+ * @throws ExecutionException
+ * @throws BadArgumentExcetion
+ * @throws NotFoundException
*/
@Test
public void testReloadTopLayerOperator() throws LayersException, ServiceException, ExecutionException, NotFoundException, BadArgumentExcetion {
@@ -197,43 +202,46 @@ public class LayersStateAfterReloadTest { // Create Editor
String modelName = "models/modeltestReload";
String diagramName = "diagram3";
-
-
+
+
EclipseProject eclipseProject = new EclipseProject(PLUGIN_PROJECT_NAME);
- eclipseProject.copyResources(BUNDLE_NAME, modelName+".di", modelName+".notation", modelName+".uml" );
+ eclipseProject.copyResources(BUNDLE_NAME, modelName + ".di", modelName + ".notation", modelName + ".uml");
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor(eclipseProject, modelName);
-
+
// Get the diagram:
// First the ModelSet, then the NotationModel, then the diagram by its name
ModelSet modelSet = editorHandler.getServiceRegistry().getService(ModelSet.class);
NotationModel notationModel = NotationUtils.getNotationModel(modelSet);
- Diagram diagram = notationModel.getDiagram(diagramName );
-
+ Diagram diagram = notationModel.getDiagram(diagramName);
+
// Get the LayerStack for the Layer
- LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID);
+ LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID);
LayersStackApplication application = layersModel.getLayerStackApplication();
LayersStack owningStack = application.lookupLayersStackFor(diagram);
-
+
// Recover tree
- TopLayerOperator rootLayer = (TopLayerOperator)owningStack.getLayers();
- TopLayerOperator layer1 = (TopLayerOperator)rootLayer.getLayers().get(0);
-
+ TopLayerOperator rootLayer = (TopLayerOperator) owningStack.getLayers();
+ TopLayerOperator layer1 = (TopLayerOperator) rootLayer.getLayers().get(0);
+
// asserts
assertNotNull("Layer created", layer1);
- assertSame("state attached", LayerState.ATTACHED, layer1.getState() );
- assertSame("application set", application, layer1.getApplication() );
- assertSame("owningStack set", owningStack, layer1.getOwningLayersStack() );
- assertSame("parent set", rootLayer, layer1.eContainer() );
+ assertSame("state attached", LayerState.ATTACHED, layer1.getState());
+ assertSame("application set", application, layer1.getApplication());
+ assertSame("owningStack set", owningStack, layer1.getOwningLayersStack());
+ assertSame("parent set", rootLayer, layer1.eContainer());
}
/**
- * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createStackedLayerOperator(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}.
- * @throws LayersException
- * @throws ExecutionException
- * @throws ServiceException
- * @throws BadArgumentExcetion
- * @throws NotFoundException
+ * Test method for
+ * {@link org.eclipse.papyrus.layers.stackmodel.layers.impl.LayersFactoryForStackImpl#createStackedLayerOperator(org.eclipse.papyrus.layers.stackmodel.layers.LayersContainer, org.eclipse.papyrus.layers.stackmodel.layers.LayersStack, org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication)}
+ * .
+ *
+ * @throws LayersException
+ * @throws ExecutionException
+ * @throws ServiceException
+ * @throws BadArgumentExcetion
+ * @throws NotFoundException
*/
@Test
public void testCreateStackedLayerOperator() throws LayersException, ExecutionException, ServiceException, NotFoundException, BadArgumentExcetion {
@@ -241,34 +249,34 @@ public class LayersStateAfterReloadTest { // Create Editor
String modelName = "models/modeltestReload";
String diagramName = "diagram4";
-
-
+
+
EclipseProject eclipseProject = new EclipseProject(PLUGIN_PROJECT_NAME);
- eclipseProject.copyResources(BUNDLE_NAME, modelName+".di", modelName+".notation", modelName+".uml" );
+ eclipseProject.copyResources(BUNDLE_NAME, modelName + ".di", modelName + ".notation", modelName + ".uml");
ProgramaticPapyrusEditor editorHandler = new ProgramaticPapyrusEditor(eclipseProject, modelName);
-
+
// Get the diagram:
// First the ModelSet, then the NotationModel, then the diagram by its name
ModelSet modelSet = editorHandler.getServiceRegistry().getService(ModelSet.class);
NotationModel notationModel = NotationUtils.getNotationModel(modelSet);
- Diagram diagram = notationModel.getDiagram(diagramName );
-
+ Diagram diagram = notationModel.getDiagram(diagramName);
+
// Get the LayerStack for the Layer
- LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID);
+ LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID);
LayersStackApplication application = layersModel.getLayerStackApplication();
LayersStack owningStack = application.lookupLayersStackFor(diagram);
-
+
// Recover tree
- TopLayerOperator rootLayer = (TopLayerOperator)owningStack.getLayers();
- StackedLayerOperator layer1 = (StackedLayerOperator)rootLayer.getLayers().get(0);
-
+ TopLayerOperator rootLayer = (TopLayerOperator) owningStack.getLayers();
+ StackedLayerOperator layer1 = (StackedLayerOperator) rootLayer.getLayers().get(0);
+
// asserts
assertNotNull("Layer created", layer1);
- assertSame("state attached", LayerState.ATTACHED, layer1.getState() );
- assertSame("application set", application, layer1.getApplication() );
- assertSame("owningStack set", owningStack, layer1.getOwningLayersStack() );
- assertSame("parent set", rootLayer, layer1.eContainer() );
+ assertSame("state attached", LayerState.ATTACHED, layer1.getState());
+ assertSame("application set", application, layer1.getApplication());
+ assertSame("owningStack set", owningStack, layer1.getOwningLayersStack());
+ assertSame("parent set", rootLayer, layer1.eContainer());
}
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/Activator.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/Activator.java index 71f339fab33..5bafa2b2058 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/Activator.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/Activator.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -23,7 +23,7 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - + /** * The constructor */ @@ -32,8 +32,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) + * * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -41,8 +43,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) + * * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ConnectorItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ConnectorItemProvider.java index 35ed7558ec6..19ea1a285a7 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ConnectorItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ConnectorItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -13,7 +13,6 @@ package org.eclipse.papyrus.layers.notationmodel.edit; import org.eclipse.emf.common.notify.AdapterFactory; import org.eclipse.emf.edit.provider.IItemLabelProvider; import org.eclipse.gmf.runtime.notation.Connector; -import org.eclipse.gmf.runtime.notation.Shape; @@ -24,7 +23,7 @@ import org.eclipse.gmf.runtime.notation.Shape; public class ConnectorItemProvider extends org.eclipse.gmf.runtime.notation.provider.ConnectorItemProvider { protected AdapterFactory domainAdapterFactory; - + /** * Constructor. * @@ -38,6 +37,7 @@ public class ConnectorItemProvider extends org.eclipse.gmf.runtime.notation.prov /** * Return the text of the underlying UML element if any. + * * @see org.eclipse.gmf.runtime.notation.provider.ShapeItemProvider#getText(java.lang.Object) * * @param object @@ -45,24 +45,24 @@ public class ConnectorItemProvider extends org.eclipse.gmf.runtime.notation.prov */ @Override public String getText(Object object) { - -// System.err.println("getText()"); - Connector shape = (Connector)object; - + + // System.err.println("getText()"); + Connector shape = (Connector) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getText(domainObject); } } return super.getText(object); } - + /** * Return the image of the underlying UML element if any. - * + * * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getImage(java.lang.String) * * @param key @@ -70,13 +70,13 @@ public class ConnectorItemProvider extends org.eclipse.gmf.runtime.notation.prov */ @Override public Object getImage(Object object) { -// System.err.println("getImage()"); - Connector shape = (Connector)object; - + // System.err.println("getImage()"); + Connector shape = (Connector) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getImage(domainObject); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/DiagramItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/DiagramItemProvider.java index 32843fa7f8b..25d9d3a3937 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/DiagramItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/DiagramItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -24,7 +24,7 @@ import org.eclipse.gmf.runtime.notation.View; /** * Custom Diagram Item provider - * + * * @author cedric dumoulin * */ @@ -32,12 +32,12 @@ public class DiagramItemProvider extends org.eclipse.gmf.runtime.notation.provid protected AdapterFactory domainAdapterFactory; - + /** * Constructor. * * @param adapterFactory - * @param domainAdapterFactory + * @param domainAdapterFactory */ public DiagramItemProvider(AdapterFactory adapterFactory, AdapterFactory domainAdapterFactory) { super(adapterFactory); @@ -48,33 +48,32 @@ public class DiagramItemProvider extends org.eclipse.gmf.runtime.notation.provid public Collection<?> getChildren(Object object) { return getChildren(object); } - + @Override public Collection<?> getElements(Object object) { - - Diagram diagram = (Diagram)object; - if(diagram.getChildren().size() == 0) { + + Diagram diagram = (Diagram) object; + if (diagram.getChildren().size() == 0) { return Collections.emptyList(); } - + // TODO: improve the implementation by using a view list or // by having an internal shadow list List<View> children = diagram.getChildren(); - List<View> res = new ArrayList<View>() - ; - for( View v : children) { - if( v instanceof Shape || v instanceof Connector) { + List<View> res = new ArrayList<View>(); + for (View v : children) { + if (v instanceof Shape || v instanceof Connector) { res.add(v); } - + } - + List<View> edges = diagram.getEdges(); - for( View v : edges) { - if( v instanceof Shape || v instanceof Connector) { + for (View v : edges) { + if (v instanceof Shape || v instanceof Connector) { res.add(v); } - + } return res; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NodeItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NodeItemProvider.java index 5862a30c970..963516f01a6 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NodeItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NodeItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -23,7 +23,7 @@ import org.eclipse.gmf.runtime.notation.Node; public class NodeItemProvider extends org.eclipse.gmf.runtime.notation.provider.NodeItemProvider { protected AdapterFactory domainAdapterFactory; - + /** * Constructor. * @@ -37,6 +37,7 @@ public class NodeItemProvider extends org.eclipse.gmf.runtime.notation.provider. /** * Return the text of the underlying UML element if any. + * * @see org.eclipse.gmf.runtime.notation.provider.ShapeItemProvider#getText(java.lang.Object) * * @param object @@ -44,24 +45,24 @@ public class NodeItemProvider extends org.eclipse.gmf.runtime.notation.provider. */ @Override public String getText(Object object) { - -// System.err.println("getText()"); - Node shape = (Node)object; - + + // System.err.println("getText()"); + Node shape = (Node) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getText(domainObject); } } return super.getText(object); } - + /** * Return the image of the underlying UML element if any. - * + * * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getImage(java.lang.String) * * @param key @@ -69,13 +70,13 @@ public class NodeItemProvider extends org.eclipse.gmf.runtime.notation.provider. */ @Override public Object getImage(Object object) { -// System.err.println("getImage()"); - Node shape = (Node)object; - + // System.err.println("getImage()"); + Node shape = (Node) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getImage(domainObject); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NotationItemProviderAdapterFactory.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NotationItemProviderAdapterFactory.java index 01d689fd569..aeba5db7c3c 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NotationItemProviderAdapterFactory.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/NotationItemProviderAdapterFactory.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -16,8 +16,8 @@ import org.eclipse.emf.common.notify.AdapterFactory; /** * A ProviderAdapterFactory for notations elements in Layers. * The associated providers allows to render notation elements as UML elements. - * - * + * + * * @author cedric dumoulin * */ @@ -29,7 +29,7 @@ public class NotationItemProviderAdapterFactory extends org.eclipse.gmf.runtime. * models. */ protected AdapterFactory domainAdapterFactory; - + /** * Constructor. * @@ -38,8 +38,10 @@ public class NotationItemProviderAdapterFactory extends org.eclipse.gmf.runtime. public NotationItemProviderAdapterFactory(AdapterFactory domainAdapterFactory) { this.domainAdapterFactory = domainAdapterFactory; } + /** * Use our DiagramAdapter. + * * @see org.eclipse.gmf.runtime.notation.provider.NotationItemProviderAdapterFactory#createDiagramAdapter() * * @return @@ -52,7 +54,7 @@ public class NotationItemProviderAdapterFactory extends org.eclipse.gmf.runtime. return diagramItemProvider; } - + @Override public Adapter createShapeAdapter() { if (shapeItemProvider == null) { @@ -61,7 +63,7 @@ public class NotationItemProviderAdapterFactory extends org.eclipse.gmf.runtime. return shapeItemProvider; } - + @Override public Adapter createConnectorAdapter() { if (connectorItemProvider == null) { @@ -70,7 +72,7 @@ public class NotationItemProviderAdapterFactory extends org.eclipse.gmf.runtime. return connectorItemProvider; } - + @Override public Adapter createNodeAdapter() { if (nodeItemProvider == null) { diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ShapeItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ShapeItemProvider.java index 24105e7e045..5798e8fa5a6 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ShapeItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.notationmodel.edit/src/org/eclipse/papyrus/layers/notationmodel/edit/ShapeItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -23,7 +23,7 @@ import org.eclipse.gmf.runtime.notation.Shape; public class ShapeItemProvider extends org.eclipse.gmf.runtime.notation.provider.ShapeItemProvider { protected AdapterFactory domainAdapterFactory; - + /** * Constructor. * @@ -37,6 +37,7 @@ public class ShapeItemProvider extends org.eclipse.gmf.runtime.notation.provider /** * Return the text of the underlying UML element if any. + * * @see org.eclipse.gmf.runtime.notation.provider.ShapeItemProvider#getText(java.lang.Object) * * @param object @@ -44,24 +45,24 @@ public class ShapeItemProvider extends org.eclipse.gmf.runtime.notation.provider */ @Override public String getText(Object object) { - -// System.err.println("getText()"); - Shape shape = (Shape)object; - + + // System.err.println("getText()"); + Shape shape = (Shape) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getText(domainObject); } } return super.getText(object); } - + /** * Return the image of the underlying UML element if any. - * + * * @see org.eclipse.emf.edit.provider.ItemProviderAdapter#getImage(java.lang.String) * * @param key @@ -69,13 +70,13 @@ public class ShapeItemProvider extends org.eclipse.gmf.runtime.notation.provider */ @Override public Object getImage(Object object) { -// System.err.println("getImage()"); - Shape shape = (Shape)object; - + // System.err.println("getImage()"); + Shape shape = (Shape) object; + Object domainObject = shape.getElement(); - if( domainObject != null) { - IItemLabelProvider nestedProvider = (IItemLabelProvider)domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); - if(nestedProvider != null) { + if (domainObject != null) { + IItemLabelProvider nestedProvider = (IItemLabelProvider) domainAdapterFactory.adapt(domainObject, IItemLabelProvider.class); + if (nestedProvider != null) { return nestedProvider.getImage(domainObject); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/Activator.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/Activator.java index 592e759c30c..8c54322e8d0 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/Activator.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/Activator.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -14,31 +14,35 @@ import org.eclipse.core.runtime.Plugin; import org.eclipse.papyrus.infra.core.log.LogHelper; import org.osgi.framework.BundleContext; -public class Activator extends Plugin { +public class Activator extends Plugin { private static BundleContext context; - /** Logging helper */ - public static LogHelper log; - + /** Logging helper */ + public static LogHelper log; + static BundleContext getContext() { return context; } /* * (non-Javadoc) + * * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext bundleContext) throws Exception { Activator.context = bundleContext; // register the login helper - log = new LogHelper(this); + log = new LogHelper(this); } /* * (non-Javadoc) + * * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext bundleContext) throws Exception { Activator.context = null; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersModelEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersModelEventListener.java index 3abf07c96d5..e05324614f2 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersModelEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersModelEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -16,7 +16,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack; /** * Class implementing this interface can listen to event from a {@link LayersStack}. - * + * * @author cedric dumoulin * */ @@ -25,41 +25,50 @@ public interface ILayersModelEventListener { /** * Method called when a value is added to one layer. * The vent contains: the layer, the property name, the new value. - * + * * @param notification */ - public void propertyValueAdded( Notification notification ); - public void propertyValueRemoved( Notification notification ); - public void propertyValueChanged( Notification notification ); - + public void propertyValueAdded(Notification notification); + + public void propertyValueRemoved(Notification notification); + + public void propertyValueChanged(Notification notification); + /** * Method called when a layer is added to one layer. * The event contains: the layer. - * + * * @param notification */ - public void layerAdded( Notification notification ); - public void layerRemoved( Notification notification ); - public void layerMoved( Notification notification ); - public void layerSet( Notification notification ); + public void layerAdded(Notification notification); + + public void layerRemoved(Notification notification); + + public void layerMoved(Notification notification); + + public void layerSet(Notification notification); /** * Method called when a view is added to one layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void viewAddedToLayer( Notification notification ); - public void viewRemovedFromLayer( Notification notification ); + public void viewAddedToLayer(Notification notification); + + public void viewRemovedFromLayer(Notification notification); + public void multiViewsRemovedFromLayer(Notification notification); + public void multiViewsAddedToLayer(Notification notification); /** * Method called when a view is moved from one layer to another. * The event contains: the layer, the view. * Warning : this handler is never called in the current implementation. + * * @param notification */ - public void viewMovedBetweenLayer( Notification notification ); + public void viewMovedBetweenLayer(Notification notification); } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersStackApplicationEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersStackApplicationEventListener.java index a4fa5d014c7..e272b244772 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersStackApplicationEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/ILayersStackApplicationEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,7 +17,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; /** * Class implementing this interface can listen to event from a {@link LayersStackApplication}. - * + * * @author cedric dumoulin * */ @@ -25,15 +25,17 @@ public interface ILayersStackApplicationEventListener { /** * Called by events when a {@link LayersStack} is added to the {@link LayersStackApplication} + * * @param msg */ - public void layerStackAdded(Notification msg) ; - + public void layerStackAdded(Notification msg); + /** * Called by events when a {@link LayersStack} is removed from the {@link LayersStackApplication} + * * @param msg */ - public void layerStackRemoved(Notification msg) ; - + public void layerStackRemoved(Notification msg); + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/INotationDiagramRemovedEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/INotationDiagramRemovedEventListener.java index e402f975038..8aa333c8ab9 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/INotationDiagramRemovedEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/INotationDiagramRemovedEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -18,7 +18,7 @@ import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; /** * Class implementing this interface can listen to diagram removed event from a {@link Resource}. - * + * * @author cedric dumoulin * */ @@ -26,9 +26,10 @@ public interface INotationDiagramRemovedEventListener { /** * Called by events when a {@link Diagram} is removed from the {@link NotationModel} + * * @param msg */ - public void diagramRemoved(Notification msg) ; - + public void diagramRemoved(Notification msg); + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizer.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizer.java index 356f6c78253..e74b27467f0 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizer.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizer.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -25,52 +25,53 @@ import static org.eclipse.papyrus.layers.runtime.Activator.log; /** - * + * * Listen to: - * - LayerStack added - * - application added/removed in LayerModel - * - * <br> - * The class has an internal state machine with two states: ApplicationExist and NoApplication. - * <br> - * In the ApplicationExist state, the class listen to {@link LayersStack} added/removed and to the Diagrams deletion. + * - LayerStack added + * - application added/removed in LayerModel + * * <br> - * In the NoApplication state, the class listen on the LayerModel to be informed when the application is created. + * The class has an internal state machine with two states: ApplicationExist and NoApplication. <br> + * In the ApplicationExist state, the class listen to {@link LayersStack} added/removed and to the Diagrams deletion. <br> + * In the NoApplication state, the class listen on the LayerModel to be informed when the application is created. * When application is created, we change the state to ApplicationExist. - * + * * There is an UML sm diagram of this in architecture.di. - * - * - * + * + * + * * @author cedric dumoulin * */ -public class LayerStackApplicationSynchronizer implements ILayersModelRootEventListener, ILayersStackApplicationEventListener, INotationDiagramRemovedEventListener{ +public class LayerStackApplicationSynchronizer implements ILayersModelRootEventListener, ILayersStackApplicationEventListener, INotationDiagramRemovedEventListener { /** * States used in the state machine. */ - protected enum State {NoApplication, ApplicationCreated, disposed}; + protected enum State { + NoApplication, ApplicationCreated, disposed + }; + protected State state; - + protected LayersModel layersModel; protected NotationModel notationModel; - + /** * All registered synchronizers. */ protected Map<Diagram, LayerStackSynchronizer> synchronizers = new HashMap<Diagram, LayerStackSynchronizer>(); - + /** * Notifier on Diagram removed event. */ protected NotationDiagramRemovedFromResourceEventNotifier notationDiagramRemovedNotifier; - + /** * Notifier on LayerSTackApplication events */ protected LayersStackApplicationEventNotifier layersStackApplicationEventNotifier; - + /** * Notifier on {@link LayersModel} events. */ @@ -81,10 +82,10 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL * */ public LayerStackApplicationSynchronizer(LayersModel layersModel, NotationModel notationModel) { - + this.layersModel = layersModel; this.notationModel = notationModel; - + initState(); } @@ -92,15 +93,15 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL * Init the state of the object */ private void initState() { - - if( layersModel.lookupLayerStackApplication() != null) { + + if (layersModel.lookupLayerStackApplication() != null) { transitionInitToApplicationCreatedState(); } else { transitionInitToNoApplicationState(); } } - + /** * Initialize the class for the NoApplication state: * - listen on LayersModel notifiers for application creation @@ -149,17 +150,17 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL private void createSynchronizerForExistingStacks() { LayersStackApplication application = layersModel.lookupLayerStackApplication(); - if(application == null) { + if (application == null) { // Application is not set, skip. return; } - - for( LayersStack stack : application.getLayersStacks()) { - if( stack.getDiagram() != null) { - addLayerStackSynchronizer(stack); + + for (LayersStack stack : application.getLayersStacks()) { + if (stack.getDiagram() != null) { + addLayerStackSynchronizer(stack); } } - + } @@ -179,7 +180,7 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL return layersModel; } - + /** * @return the notationModel */ @@ -189,73 +190,73 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL /** * Activate the listeners. - * + * */ protected void activate() { - initState(); + initState(); } /** * Activate the listeners. - * + * */ private void activateLayersModelRootNotifier() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ - + layersModelEventRootNotifier = new LayersModelEventRootNotifier(layersModel); - layersModelEventRootNotifier.addEventListener(this); + layersModelEventRootNotifier.addEventListener(this); } /** * Activate the listeners. - * + * */ private void deactivateLayersModelRootNotifier() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ - if( layersModelEventRootNotifier != null ) { + if (layersModelEventRootNotifier != null) { layersModelEventRootNotifier.removeEventListener(this); - layersModelEventRootNotifier = null; + layersModelEventRootNotifier = null; } } /** * Deactivate the listeners. - * + * */ private void activateLayersModelAndDiagramDeletionNotifiers() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ notationDiagramRemovedNotifier = new NotationDiagramRemovedFromResourceEventNotifier(notationModel); notationDiagramRemovedNotifier.addLayersModelEventListener(this); - + layersStackApplicationEventNotifier = new LayersStackApplicationEventNotifier(layersModel); - layersStackApplicationEventNotifier.addLayersModelEventListener(this); + layersStackApplicationEventNotifier.addLayersModelEventListener(this); } /** * Deactivate listeners */ protected void deactivateLayersModelAndDiagramDeletionNotifiers() { - if( notationDiagramRemovedNotifier != null) { + if (notationDiagramRemovedNotifier != null) { notationDiagramRemovedNotifier.removeLayersModelEventListener(this); notationDiagramRemovedNotifier = null; } - if(layersStackApplicationEventNotifier!=null) { + if (layersStackApplicationEventNotifier != null) { layersStackApplicationEventNotifier.removeLayersModelEventListener(this); layersStackApplicationEventNotifier = null; } } - + /** * Deactivate listeners */ @@ -263,7 +264,7 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL deactivateLayersModelAndDiagramDeletionNotifiers(); deactivateLayersModelRootNotifier(); } - + /** * Dispose the synchronizer */ @@ -274,28 +275,31 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL notationModel = null; state = State.disposed; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return state == State.disposed; } - + /** * Called by events when a {@link LayersStack} is added to the {@link LayersStackApplication} + * * @param msg */ + @Override public void layerStackAdded(Notification msg) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug("LayerStackApplicationSynchronizer.layerStackAdded : " + msg.getNewValue()); } - + // Find the LayerStack LayersStack stack = LayersStackApplicationEventNotifier.getAddedLayerStack(msg); - + addLayerStackSynchronizer(stack); } @@ -303,22 +307,23 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL /** * Create and add a {@link LayerStackSynchronizer} for the stack. * Do nothing if the stack has already a synchronizer. - * + * * @param stack */ private void addLayerStackSynchronizer(LayersStack stack) { // Check if already exist - if( lookupLayersStackSynchronizer(stack.getDiagram()) != null) { + if (lookupLayersStackSynchronizer(stack.getDiagram()) != null) { return; } - + // Create a new synchronizer LayerStackSynchronizer layerStackSynchronizer = new LayerStackSynchronizer(stack); putLayersStackSynchronizer(layerStackSynchronizer); } - + /** * Lookup a {@link LayerStackSynchronizer} by its diagram. + * * @param diagram * @return */ @@ -328,48 +333,53 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL /** * Lookup a {@link LayerStackSynchronizer} by its diagram. + * * @param diagram * @return */ - protected void putLayersStackSynchronizer(LayerStackSynchronizer layerStackSynchronizer) { - + protected void putLayersStackSynchronizer(LayerStackSynchronizer layerStackSynchronizer) { + synchronizers.put(layerStackSynchronizer.getDiagram(), layerStackSynchronizer); } /** * Called by events when a {@link LayersStack} is removed from the {@link LayersStackApplication} + * * @param msg */ + @Override public void layerStackRemoved(Notification msg) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug("LayerStack is removed" + msg.getOldValue()); } - + // Find the LayerStack LayersStack stack = LayersStackApplicationEventNotifier.getRemovedLayerStack(msg); - + LayerStackSynchronizer synchronizer = synchronizers.remove(stack.getDiagram()); synchronizer.dispose(); - + // Also remove from application - + } - + /** * Called by events when a {@link Diagram} is removed from the {@link NotationModel} + * * @param msg */ + @Override public void diagramRemoved(Notification msg) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".diagramRemoved() - " + msg.getOldValue()); } - - if( state != State.ApplicationCreated) { + + if (state != State.ApplicationCreated) { return; } - + // Find the diagram Diagram diagram = NotationDiagramRemovedFromResourceEventNotifier.getRemovedDiagram(msg); @@ -380,7 +390,7 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL // check if really removed from this object LayerStackSynchronizer synchronizer = synchronizers.remove(diagram); - if( synchronizer != null ) { + if (synchronizer != null) { // Should not happen log.info(this.getClass().getSimpleName() + ".diagramRemoved() - synchronizer not completly cleaned. Finish the job."); synchronizer.dispose(); @@ -390,16 +400,16 @@ public class LayerStackApplicationSynchronizer implements ILayersModelRootEventL @Override public void layersModelRootAdded(Notification msg) { - if( state == State.NoApplication) { + if (state == State.NoApplication) { transitionNoApplicationToApplicationCreatedState(); } - + } @Override public void layersModelRootRemoved(Notification msg) { - if( state == State.ApplicationCreated) { + if (state == State.ApplicationCreated) { transitionApplicationCreatedToNoApplicationState(); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizer.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizer.java index ef59e705a97..dc1359d3d4c 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizer.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizer.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -34,7 +34,7 @@ import static org.eclipse.papyrus.layers.runtime.Activator.log; * This class is used to synchronize the diagram's properties when something * change in the LayerStack. * It listen on events from {@link LayersStack} and {@link Diagram}. - * + * * @author cedric dumoulin * */ @@ -44,52 +44,52 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer * The observed diagram. */ protected Diagram diagram; - + /** * The observed LayerStack. */ protected LayersStack layersStack; - + /** - * The application object. Required by some methods. - * <br> - * Method requiring this object must check it before any use, + * The application object. Required by some methods. <br> + * Method requiring this object must check it before any use, * as this object can be null. - * + * */ protected LayersStackApplication application; - + /** * The notifier of layer model events. */ protected LayersModelEventNotifier layersModelEventNotifier; - + /** * The notifier of layer model events. */ protected DiagramViewEventNotifier diagramViewEventNotifier; - + /** * Constructor. * - * @param layersStack The layerStack to listen to. It should have an associated diagram. - * + * @param layersStack + * The layerStack to listen to. It should have an associated diagram. + * */ public LayerStackSynchronizer(LayersStack layersStack) { this.diagram = layersStack.getDiagram(); this.layersStack = layersStack; - + // try to get the application object // it is the container of the layerStack - application = (LayersStackApplication)layersStack.eContainer(); - - + application = (LayersStackApplication) layersStack.eContainer(); + + activate(); -// System.err.println("LayerStackSynchronizer( " +diagram.getName()+ " ) started"); + // System.err.println("LayerStackSynchronizer( " +diagram.getName()+ " ) started"); } - + /** * @return the diagram */ @@ -98,7 +98,7 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer } - + /** * @return the layersStack */ @@ -110,16 +110,16 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** * Activate the listeners. - * + * */ protected void activate() { - + diagramViewEventNotifier = new DiagramViewEventNotifier(diagram); diagramViewEventNotifier.addEventListener(this); - + layersModelEventNotifier = new LayersModelEventNotifier(layersStack); layersModelEventNotifier.addLayersModelEventListener(this); - + } /** @@ -128,11 +128,11 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer protected void deactivate() { diagramViewEventNotifier.removeEventListener(this); diagramViewEventNotifier = null; - + layersModelEventNotifier.removeLayersModelEventListener(this); layersModelEventNotifier = null; } - + /** * Dispose the synchronizer */ @@ -142,39 +142,40 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer diagramViewEventNotifier = null; layersModelEventNotifier = null; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return diagramViewEventNotifier == null; } - + /** * Check if the application object is not null. - * Throw an exception if the application object is null. - * <br> + * Throw an exception if the application object is null. <br> * In normal use, the Application is the container of the LayerStack. * It is set in the constructor of this class. - * + * * @throws BadStateException */ protected void checkApplication() throws BadStateException { - if( application == null) { + if (application == null) { throw new BadStateException("Attempt to call a method requireing the 'application object, but the Application object is not set. You must provide a LayerStack contained in its Application."); } } + /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#propertyValueAdded(org.eclipse.emf.common.notify.Notification) * * @param notification */ @Override public void propertyValueAdded(Notification notification) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".propertyValueAdded " + notification.getNewValue()); } @@ -186,44 +187,44 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer // Need to recompute the associated views AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); List<View> views = layer.getViews(); - if( views.size() == 0) { + if (views.size() == 0) { return; } - + checkApplication(); - Property property = application.getPropertyRegistry().getProperty(propertyName); - + Property property = application.getPropertyRegistry().getProperty(propertyName); + List<ComputePropertyValueCommand> commands = layersStack.getViewsComputePropertyValueCommand(views, property); - + setter = application.getPropertySetterRegistry().getPropertySetter(property); - + // Walk each view and set the property - for( int i=0; i<views.size(); i++) { - + for (int i = 0; i < views.size(); i++) { + // set the value from the provided cmds. // Do it if the cmd is not null - if( commands != null && commands.get(i) != null ) { - setter.setValue(views.get(i), commands.get(i).getCmdValue() ); - } + if (commands != null && commands.get(i) != null) { + setter.setValue(views.get(i), commands.get(i).getCmdValue()); + } else { log.info(this.getClass().getSimpleName() + "ERROR - a cmd is null " + commands); } } } catch (NotFoundException e) { log.error(e); - } catch (LayersException e) { + } catch (LayersException e) { log.error(e); - } catch (UnsupportedOperationException e) { + } catch (UnsupportedOperationException e) { // A setter or getter is not implemented - throw new UnsupportedOperationException("setter='" + setter.getClass().getName()+"'", e); - } + throw new UnsupportedOperationException("setter='" + setter.getClass().getName() + "'", e); + } } @Override public void propertyValueRemoved(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".propertyValueRemoved " + notification.getOldValue()); } @@ -234,15 +235,15 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer // Need to recompute the associated views AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); List<View> views = layer.getViews(); - if( views.size() == 0) { + if (views.size() == 0) { return; } checkApplication(); - Property property = application.getPropertyRegistry().getProperty(propertyName); + Property property = application.getPropertyRegistry().getProperty(propertyName); List<ComputePropertyValueCommand> commands = layersStack.getViewsComputePropertyValueCommand(views, property); - if( commands == null) { + if (commands == null) { // no command return; } @@ -250,11 +251,11 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer PropertySetter setter = application.getPropertySetterRegistry().getPropertySetter(property); // Walk each view and set the property - for( int i=0; i<views.size(); i++) { + for (int i = 0; i < views.size(); i++) { // A command can be null ComputePropertyValueCommand cmd = commands.get(i).getCmdValue(); - if( cmd != null ) { - setter.setValue(views.get(i), cmd.getCmdValue() ); + if (cmd != null) { + setter.setValue(views.get(i), cmd.getCmdValue()); } } @@ -262,23 +263,23 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer log.error(e); } catch (LayersException e) { log.error(e); - } + } } @Override public void propertyValueChanged(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".propertyValueChanged " + notification.getNewValue()); } // If LayerExpression::IsLayerEnabled() is changed, treat it separately. - if(notification.getFeature() == LayersPackage.eINSTANCE.getLayerExpression_IsLayerEnabled()) { + if (notification.getFeature() == LayersPackage.eINSTANCE.getLayerExpression_IsLayerEnabled()) { propertyValueChangedIsLayerEnabled(notification); return; } - + // Here, this should be a regular property that is modified try { // Name of the property @@ -287,25 +288,25 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer // Need to recompute the associated views AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); List<View> views = layer.getViews(); - if( views.size() == 0) { + if (views.size() == 0) { return; } - + checkApplication(); - Property property = application.getPropertyRegistry().getProperty(propertyName); - + Property property = application.getPropertyRegistry().getProperty(propertyName); + List<ComputePropertyValueCommand> commands = layersStack.getViewsComputePropertyValueCommand(views, property); - if(commands == null) { + if (commands == null) { return; } - + PropertySetter setter = application.getPropertySetterRegistry().getPropertySetter(property); - + // Walk each view and set the property - for( int i=0; i<views.size(); i++) { + for (int i = 0; i < views.size(); i++) { ComputePropertyValueCommand getValueCmd = commands.get(i); - if(getValueCmd != null) { - setter.setValue(views.get(i), getValueCmd.getCmdValue() ); + if (getValueCmd != null) { + setter.setValue(views.get(i), getValueCmd.getCmdValue()); } } } catch (NotFoundException e) { @@ -319,25 +320,25 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** * The LayerExpression::IsLayerEnabled() is changed. Refresh views and properties of the layer. - * - * + * + * * @param notification */ private void propertyValueChangedIsLayerEnabled(Notification notification) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".propertyValueChangedIsLayerEnabled " + notification.getNewValue()); - + } try { - + checkApplication(); - + // Extract the affected layer -// AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); - AbstractLayer layer = (AbstractLayer)notification.getNotifier(); - + // AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); + AbstractLayer layer = (AbstractLayer) notification.getNotifier(); + recomputePropertiesForAllViewsOf(layer); } catch (NotFoundException e) { log.error(e); @@ -350,47 +351,47 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** * Recompute the specified properties for the specified views. - * + * * @param views * @param properties - * @throws LayersException + * @throws LayersException */ private void recompute(List<View> views, List<Property> properties) throws LayersException { // Iterate on views - for( View view : views) { - recompute( view, properties); + for (View view : views) { + recompute(view, properties); } - + } /** * Recompute the specified properties for the specified view. - * + * * @param view * @param properties - * @throws LayersException + * @throws LayersException */ private void recompute(View view, List<Property> properties) throws LayersException { List<ComputePropertyValueCommand> commands = layersStack.getPropertiesComputePropertyValueCommand(view, properties); - if(commands == null) { + if (commands == null) { // No property to set return; } PropertySetter setter; // Walk each cmd and set the property - for( int i=0; i<commands.size(); i++) { + for (int i = 0; i < commands.size(); i++) { try { Property property = properties.get(i); setter = application.getPropertySetterRegistry().getPropertySetter(property); // Set the value only if we have a getter command. ComputePropertyValueCommand getterCmd = commands.get(i); - if(getterCmd != null) { - setter.setValue(view, getterCmd.getCmdValue() ); + if (getterCmd != null) { + setter.setValue(view, getterCmd.getCmdValue()); } } catch (NotFoundException e) { @@ -400,24 +401,25 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer // A command is null } } - + } @Override public void layerAdded(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".layerAdded() " + notification.getNewValue()); } - if( ! (notification.getNewValue() instanceof AbstractLayer) ) { - log.info( "TODO: " + this.getClass().getSimpleName() + ".layerAdded() " + notification.getOldValue() + " - recompute for LayerOperator not implemented yet.");; - return; + if (!(notification.getNewValue() instanceof AbstractLayer)) { + log.info("TODO: " + this.getClass().getSimpleName() + ".layerAdded() " + notification.getOldValue() + " - recompute for LayerOperator not implemented yet."); + ; + return; } // Extract the affected layer - AbstractLayer layer = (AbstractLayer)notification.getNewValue(); + AbstractLayer layer = (AbstractLayer) notification.getNewValue(); try { checkApplication(); @@ -432,16 +434,17 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer @Override public void layerRemoved(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + " layerRemoved() " + notification.getOldValue()); } - if( ! (notification.getOldValue() instanceof AbstractLayer) ) { - log.info( "TODO: " + this.getClass().getSimpleName() + ".layerRemoved() " + notification.getOldValue() + " - recompute() after removing layerOperator not implemented yet.");; - return; + if (!(notification.getOldValue() instanceof AbstractLayer)) { + log.info("TODO: " + this.getClass().getSimpleName() + ".layerRemoved() " + notification.getOldValue() + " - recompute() after removing layerOperator not implemented yet."); + ; + return; } // Extract the affected layer - AbstractLayer layer = (AbstractLayer)notification.getOldValue(); + AbstractLayer layer = (AbstractLayer) notification.getOldValue(); try { checkApplication(); @@ -456,40 +459,40 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** * Recompute the properties of the views attached to the specified layers. - * + * * @param layer * @throws LayersException */ private void recomputePropertiesForAllViewsOf(AbstractLayer layer) throws LayersException { // We need the list of affected properties - List<Property> properties = layer.getAttachedProperties(); + List<Property> properties = layer.getAttachedProperties(); // We need the list of affected Views. List<View> views = layer.getViews(); - if( views.size() == 0) { + if (views.size() == 0) { return; } - + // For each view, recompute the Properties - recompute( views, properties ); + recompute(views, properties); } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#layerMoved(org.eclipse.emf.common.notify.Notification) * * @param notification */ @Override public void layerMoved(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + " layerMoved(not tested) " + notification.getNewValue()); } // Extract the affected layer - AbstractLayer layer = (AbstractLayer)notification.getNewValue(); + AbstractLayer layer = (AbstractLayer) notification.getNewValue(); try { checkApplication(); @@ -501,7 +504,7 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#layerSet(org.eclipse.emf.common.notify.Notification) * * @param notification @@ -515,42 +518,42 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#viewAddedToLayer(org.eclipse.emf.common.notify.Notification) * * @param notification */ @Override public void viewAddedToLayer(Notification notification) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + " viewAddedToLayer( " + notification.getNewValue() + " )"); } // We need to find the view, the layer in which it is added, // and the properties attached to this layer. // Then, we compute this property and set it to the view. - try { + try { AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); View view = LayersModelEventUtils.ViewEvents.getViewAdded(notification); - - + + checkApplication(); - List<Property> properties = layer.getAttachedProperties(); - + List<Property> properties = layer.getAttachedProperties(); + List<ComputePropertyValueCommand> commands = layersStack.getPropertiesComputePropertyValueCommand(view, properties); - if(commands == null) { + if (commands == null) { // No property to set return; } - + PropertySetter setter; // Walk each cmd and set the property - for( int i=0; i<commands.size(); i++) { + for (int i = 0; i < commands.size(); i++) { try { Property property = properties.get(i); setter = application.getPropertySetterRegistry().getPropertySetter(property); - setter.setValue(view, commands.get(i).getCmdValue() ); + setter.setValue(view, commands.get(i).getCmdValue()); } catch (NotFoundException e) { // No setter found log.error("No setter found", e); @@ -566,8 +569,8 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer @Override public void multiViewsAddedToLayer(Notification notification) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + ".multiViewsAddedToLayer( " + notification.getNewValue() + " )"); } @@ -577,54 +580,54 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer try { AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); List<View> views = LayersModelEventUtils.ViewEvents.getViewsAdded(notification); - + checkApplication(); - List<Property> properties = layer.getAttachedProperties(); + List<Property> properties = layer.getAttachedProperties(); recompute(views, properties); - + } catch (LayersException e) { log.error(e); } - + } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#viewRemovedFromLayer(org.eclipse.emf.common.notify.Notification) * * @param notification */ @Override public void viewRemovedFromLayer(Notification notification) { - if(log.isDebugEnabled()) { + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + " viewRemovedFromLayer( " + notification.getOldValue() + " )"); } - + // We need to find the view, the layer in which it is added, // and the properties attached to this layer. // Then, we compute this property and set it to the view. try { AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); View view = LayersModelEventUtils.ViewEvents.getViewRemoved(notification); - + checkApplication(); - List<Property> properties = layer.getAttachedProperties(); - + List<Property> properties = layer.getAttachedProperties(); + List<ComputePropertyValueCommand> commands = layersStack.getPropertiesComputePropertyValueCommand(view, properties); - if(commands == null) { + if (commands == null) { // No property to set return; } - + PropertySetter setter; // Walk each cmd and set the property - for( int i=0; i<commands.size(); i++) { + for (int i = 0; i < commands.size(); i++) { try { Property property = properties.get(i); setter = application.getPropertySetterRegistry().getPropertySetter(property); - setter.setValue(view, commands.get(i).getCmdValue() ); + setter.setValue(view, commands.get(i).getCmdValue()); } catch (NotFoundException e) { // No setter found log.error("No setter found", e); @@ -640,33 +643,33 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer @Override public void multiViewsRemovedFromLayer(Notification notification) { - - if(log.isDebugEnabled()) { + + if (log.isDebugEnabled()) { log.debug(this.getClass().getSimpleName() + " multiViewsRemovedFromLayer( " + notification.getOldValue() + " )"); } - + // We need to find the view, the layer in which it is added, // and the properties attached to this layer. // Then, we compute this property and set it to the view. try { AbstractLayer layer = LayersModelEventUtils.PropertyEvents.getAbstractLayer(notification); List<View> views = LayersModelEventUtils.ViewEvents.getViewsRemoved(notification); - + checkApplication(); - List<Property> properties = layer.getAttachedProperties(); + List<Property> properties = layer.getAttachedProperties(); recompute(views, properties); - + } catch (LayersException e) { log.error(e); } - + } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#viewMovedBetweenLayer(org.eclipse.emf.common.notify.Notification) * * @param notification @@ -680,7 +683,7 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer /** - * + * * @see org.eclipse.papyrus.layers.stackmodel.notifier.IDiagramViewEventListener#diagramViewAdded(org.eclipse.emf.common.notify.Notification) * * @param msg @@ -690,17 +693,17 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer log.info(this.getClass().getSimpleName() + " diagramViewAdded(not implemented) " + msg.getNewValue()); // WARNING !!! - // Some filtering should be done on the event. + // Some filtering should be done on the event. // When a View is removed, the event is sent for each of its parts. This // result in multiple events receiving. - // Only events on Shape and Links are useful. So, we need to + // Only events on Shape and Links are useful. So, we need to // do some filtering (in the DiagramViewEventNotifier ?). } /** - * + * * @see org.eclipse.papyrus.layers.stackmodel.notifier.IDiagramViewEventListener#diagramViewRemoved(org.eclipse.emf.common.notify.Notification) * * @param msg @@ -710,10 +713,10 @@ public class LayerStackSynchronizer implements IDiagramViewEventListener, ILayer log.info(this.getClass().getSimpleName() + " diagramViewRemoved(not implemented) " + msg.getOldValue()); // WARNING !!! - // Some filtering should be done on the event. + // Some filtering should be done on the event. // When a View is removed, the event is sent for each of its parts. This // result in multiple events receiving. - // Only events on Shape and Links are useful. So, we need to + // Only events on Shape and Links are useful. So, we need to // do some filtering (in the DiagramViewEventNotifier ?). } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifier.java index 4c15cb07aab..c329e5e321d 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifier.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -28,7 +28,7 @@ import static org.eclipse.papyrus.layers.runtime.Activator.log; /** * This class listen to a {@link LayersStack} and send event to listeners. - * + * * @author cedric dumoulin * */ @@ -38,36 +38,36 @@ public class LayersModelEventNotifier { * The observed {@link LayersStack}. */ protected LayersStack layersStack; - + /** * List of listener to notify. */ protected List<ILayersModelEventListener> listeners = new ArrayList<ILayersModelEventListener>(); - + /** * listener on layers changes. - * + * */ protected Adapter layersListener = new EContentAdapter() { - + @Override public void notifyChanged(Notification notification) { - if(log.isDebugEnabled() ) { - log.debug( this.getClass().getSimpleName() + ".event received " + notification.getFeature()); - } - + if (log.isDebugEnabled()) { + log.debug(this.getClass().getSimpleName() + ".event received " + notification.getFeature()); + } + // Self atttach super.notifyChanged(notification); - + // Check layers modification // There is two sources: LayerOperator::layers and LayersStack::layers - if( notification.getFeature() == LayersPackage.eINSTANCE.getLayerOperator_Layers() - || notification.getFeature() == LayersPackage.eINSTANCE.getLayersStack_Layers() ) { + if (notification.getFeature() == LayersPackage.eINSTANCE.getLayerOperator_Layers() + || notification.getFeature() == LayersPackage.eINSTANCE.getLayersStack_Layers()) { // LayerOperator::layers || LayersStack::layers // check the event type. - switch(notification.getEventType()) { + switch (notification.getEventType()) { case Notification.SET: - fireLayerSet(notification); + fireLayerSet(notification); break; case Notification.ADD: // A layer is added @@ -82,114 +82,114 @@ public class LayersModelEventNotifier { fireLayerMoved(notification); break; } - } + } // Check view event - // View event can by fired by: AbstractLayer::views - else if (notification.getFeature() == LayersPackage.eINSTANCE.getAbstractLayer_Views() ) { + // View event can by fired by: AbstractLayer::views + else if (notification.getFeature() == LayersPackage.eINSTANCE.getAbstractLayer_Views()) { // check the event type. - switch(notification.getEventType()) { + switch (notification.getEventType()) { case Notification.ADD: // A layer is added // the concerned view -// View view = (View)notification.getNewValue(); -// AbstractLayer layer = (AbstractLayer)notification.getNotifier() - + // View view = (View)notification.getNewValue(); + // AbstractLayer layer = (AbstractLayer)notification.getNotifier() + fireViewAddedToLayer(notification); break; case Notification.ADD_MANY: // A layer is added // the concerned view -// View view = (View)notification.getNewValue(); -// AbstractLayer layer = (AbstractLayer)notification.getNotifier() - + // View view = (View)notification.getNewValue(); + // AbstractLayer layer = (AbstractLayer)notification.getNotifier() + fireMultiViewsAddedToLayer(notification); break; case Notification.REMOVE: // A layer is removed // the concerned view -// View view = (View)notification.getOldValue(); -// AbstractLayer layer = (AbstractLayer)notification.getNotifier() + // View view = (View)notification.getOldValue(); + // AbstractLayer layer = (AbstractLayer)notification.getNotifier() fireViewRemovedFromLayer(notification); break; case Notification.REMOVE_MANY: // A layer is removed // the concerned view -// View view = (View)notification.getOldValue(); -// AbstractLayer layer = (AbstractLayer)notification.getNotifier() + // View view = (View)notification.getOldValue(); + // AbstractLayer layer = (AbstractLayer)notification.getNotifier() fireMultiViewsRemovedFromLayer(notification); break; } - + } // Check instance addition/deletion - // instance event can by fired by: AbstractLayer::propertyValuesMap - else if (notification.getFeature() == LayersPackage.eINSTANCE.getAbstractLayer_PropertyValueMap() ) { + // instance event can by fired by: AbstractLayer::propertyValuesMap + else if (notification.getFeature() == LayersPackage.eINSTANCE.getAbstractLayer_PropertyValueMap()) { // check the event type. - switch(notification.getEventType()) { -// case Notification.SET: -// { -// // A key is added -// break; -// } -// case Notification.UNSET: -// // A key is added -// break; - case Notification.ADD: + switch (notification.getEventType()) { + // case Notification.SET: + // { + // // A key is added + // break; + // } + // case Notification.UNSET: + // // A key is added + // break; + case Notification.ADD: { // An entry is added - StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)notification.getNewValue(); -// System.out.println("ADD" + entry.getValue() -// + ", key=" + entry.getKey()); + StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl) notification.getNewValue(); + // System.out.println("ADD" + entry.getValue() + // + ", key=" + entry.getKey()); // Add the corresponding instance to propertyValues - //Layer layer = (Layer)notification.getNotifier(); - //String propertyName = entry.getKey(); - //TypeInstance propertyValue = (TypeInstance)entry.getValue(); + // Layer layer = (Layer)notification.getNotifier(); + // String propertyName = entry.getKey(); + // TypeInstance propertyValue = (TypeInstance)entry.getValue(); firePropertyValueAddedEvent(notification); break; } - case Notification.REMOVE: + case Notification.REMOVE: { // An entry is removed - StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)notification.getOldValue(); -// System.out.println("REMOVE" + entry.getValue() -// + ", key=" + entry.getKey()); + StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl) notification.getOldValue(); + // System.out.println("REMOVE" + entry.getValue() + // + ", key=" + entry.getKey()); // Add the corresponding instance to propertyValues - //Layer layer = (Layer)notification.getNotifier(); - //String propertyName = entry.getKey(); - //TypeInstance propertyValue = (TypeInstance)entry.getValue(); + // Layer layer = (Layer)notification.getNotifier(); + // String propertyName = entry.getKey(); + // TypeInstance propertyValue = (TypeInstance)entry.getValue(); firePropertyValueRemoved(notification); break; } default: break; } - + } // Check if the isLayerEnabled is modified // sources: LayerExpression::IsLayerEnabled - else if(notification.getFeature() == LayersPackage.eINSTANCE.getLayerExpression_IsLayerEnabled() ) { + else if (notification.getFeature() == LayersPackage.eINSTANCE.getLayerExpression_IsLayerEnabled()) { firePropertyValueChanged(notification); } - + // Check property instance modification event - // instance change event can by fired by: any modification in a subclass of TypeInstance + // instance change event can by fired by: any modification in a subclass of TypeInstance else { try { // Lookup if the event comes from a type instance - TypeInstance ancestor = (TypeInstance)ECoreUtils.lookupAncestorOfType((EObject)notification.getNotifier(), LayersPackage.eINSTANCE.getTypeInstance()); + TypeInstance ancestor = (TypeInstance) ECoreUtils.lookupAncestorOfType((EObject) notification.getNotifier(), LayersPackage.eINSTANCE.getTypeInstance()); // originating layer - AbstractLayer layer = (AbstractLayer)ECoreUtils.lookupAncestorOfType((EObject)notification.getNotifier(), LayersPackage.eINSTANCE.getAbstractLayer()); + AbstractLayer layer = (AbstractLayer) ECoreUtils.lookupAncestorOfType((EObject) notification.getNotifier(), LayersPackage.eINSTANCE.getAbstractLayer()); // or: layer = (AbstractLayer)ancestor.eContainer().eContainer().eContainer(); // StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)ancestor.eContainer(); - //String propertyName = entry.getKey(); - //TypeInstance propertyValue = (TypeInstance)entry.getValue(); - // -// String propertyName + // String propertyName = entry.getKey(); + // TypeInstance propertyValue = (TypeInstance)entry.getValue(); + // + // String propertyName // check the event type. - switch(notification.getEventType()) { + switch (notification.getEventType()) { case Notification.SET: // An instance value is set firePropertyValueChanged(notification); @@ -207,18 +207,19 @@ public class LayersModelEventNotifier { // lookupAncestorOfType() found nothing // silently fail } - - + + } - + } }; - + /** * Constructor. * - * @param layersStack The observed {@link LayersStack}. + * @param layersStack + * The observed {@link LayersStack}. */ public LayersModelEventNotifier(LayersStack layersStack) { this.layersStack = layersStack; @@ -230,7 +231,7 @@ public class LayersModelEventNotifier { */ protected void activate() { layersStack.eAdapters().add(layersListener); - + } /** @@ -238,208 +239,211 @@ public class LayersModelEventNotifier { */ protected void deactivate() { layersStack.eAdapters().remove(layersListener); - + } /** * Dispose this object. */ public void dispose() { - + deactivate(); listeners.clear(); layersListener = null; } - + /** * Return true if the object is disposed. + * * @return */ public boolean isDisposed() { - return layersListener==null; + return layersListener == null; } /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addLayersModelEventListener(ILayersModelEventListener listener) { - - if(listener == null ) { + + if (listener == null) { return; } - + // Check if exist - if( listeners.contains(listener)) { + if (listeners.contains(listener)) { return; } - + listeners.add(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeLayersModelEventListener(ILayersModelEventListener listener) { listeners.remove(listener); } + /** * Method called when a value is added to one layer. * The vent contains: the layer, the property name, the new value. - * + * * @param notification */ - public void firePropertyValueAddedEvent( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void firePropertyValueAddedEvent(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.propertyValueAdded(notification); } } - + /** * Method called when a value is removed from one layer. * The vent contains: the layer, the property name, the new value. - * + * * @param notification */ - public void firePropertyValueRemoved( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void firePropertyValueRemoved(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.propertyValueRemoved(notification); } } - + /** * Method called when a value is changed in one layer. * The vent contains: the layer, the property name, the new value. - * + * * @param notification */ - public void firePropertyValueChanged( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void firePropertyValueChanged(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.propertyValueChanged(notification); } } - + /** * Method called when a layer is added to one layer. * The event contains: the layer. - * + * * @param notification */ - public void fireLayerSet( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireLayerSet(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.layerSet(notification); } } - + /** * Method called when a layer is added to one layer. * The event contains: the layer. - * + * * @param notification */ - public void fireLayerAdded( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireLayerAdded(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.layerAdded(notification); } } - + /** * Method called when a layer is removed from one layer. * The event contains: the layer. - * + * * @param notification */ - public void fireLayerRemoved( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireLayerRemoved(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.layerRemoved(notification); } } - + /** * Method called when a layer is moved in LayerStack. * The event contains: the layer. - * + * * @param notification */ - public void fireLayerMoved( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireLayerMoved(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.layerMoved(notification); } } - + /** * Method called when a view is added to one layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void fireViewAddedToLayer( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireViewAddedToLayer(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.viewAddedToLayer(notification); } } - + /** * Method called when a view is added to one layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void fireMultiViewsAddedToLayer( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireMultiViewsAddedToLayer(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.multiViewsAddedToLayer(notification); } } - + /** * Method called when a view is removed from one layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void fireViewRemovedFromLayer( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireViewRemovedFromLayer(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.viewRemovedFromLayer(notification); } } - + /** * Method called when a view is removed from one layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void fireMultiViewsRemovedFromLayer( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireMultiViewsRemovedFromLayer(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.multiViewsRemovedFromLayer(notification); } } - + /** * Method called when a view is moved from one layer to another layer. * The event contains: the layer, the view. - * + * * @param notification */ - public void fireViewMovedBetweenLayer( Notification notification ) { - - for(ILayersModelEventListener listener : listeners) { + public void fireViewMovedBetweenLayer(Notification notification) { + + for (ILayersModelEventListener listener : listeners) { listener.viewMovedBetweenLayer(notification); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventUtils.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventUtils.java index e58b3bfe2ac..91fe3ac8094 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventUtils.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersModelEventUtils.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -23,7 +23,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.util.ECoreUtils; /** - * + * * @author cedric dumoulin * */ @@ -31,101 +31,106 @@ public class LayersModelEventUtils { static public class PropertyEvents { - + /** * Get the abstract layer containing the notifier. - * + * * @param notification * @return * @throws NotFoundException */ static public AbstractLayer getAbstractLayer(Notification notification) throws NotFoundException { - return (AbstractLayer)ECoreUtils.lookupAncestorOfType((EObject)notification.getNotifier(), LayersPackage.eINSTANCE.getAbstractLayer()); + return (AbstractLayer) ECoreUtils.lookupAncestorOfType((EObject) notification.getNotifier(), LayersPackage.eINSTANCE.getAbstractLayer()); } - + /** * Get the name of the property concerned by the event. + * * @return */ static public String getPropertyNameFromValueAdd(Notification notification) { - - StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)notification.getNewValue(); + + StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl) notification.getNewValue(); return entry.getKey(); } + /** * Get the name of the property concerned by the event. + * * @return */ static public String getPropertyNameFromValueRemove(Notification notification) { - - StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)notification.getOldValue(); + + StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl) notification.getOldValue(); return entry.getKey(); } + /** * Get the name of the property concerned by the event. + * * @return - * @throws NotFoundException + * @throws NotFoundException */ static public String getPropertyNameFromValueSet(Notification notification) throws NotFoundException { - - StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl)ECoreUtils.lookupAncestorOfType((EObject)notification.getNotifier(), LayersPackage.eINSTANCE.getStringToTypeInstanceMap()); + + StringToTypeInstanceMapImpl entry = (StringToTypeInstanceMapImpl) ECoreUtils.lookupAncestorOfType((EObject) notification.getNotifier(), LayersPackage.eINSTANCE.getStringToTypeInstanceMap()); return entry.getKey(); } } - + /** - * + * * */ static public class ViewEvents { - + /** * Get the abstract layer containing the notifier. - * + * * @param notification * @return * @throws NotFoundException */ static public AbstractLayer getAbstractLayer(Notification notification) throws NotFoundException { - return (AbstractLayer)notification.getNotifier(); + return (AbstractLayer) notification.getNotifier(); } /** * Get the view added to layer - * + * * @param notification * @return * @throws NotFoundException */ static public View getViewAdded(Notification notification) throws NotFoundException { - return (View)notification.getNewValue(); + return (View) notification.getNewValue(); } - + /** * Get the view removed from layer - * + * * @param notification * @return * @throws NotFoundException */ static public View getViewRemoved(Notification notification) throws NotFoundException { - return (View)notification.getOldValue(); + return (View) notification.getOldValue(); } /** * Get the views[*] that have been removed from the layer. - * + * * @param notification * @return */ public static List<View> getViewsRemoved(Notification notification) { - return (List<View>)notification.getOldValue(); + return (List<View>) notification.getOldValue(); } public static List<View> getViewsAdded(Notification notification) { - return (List<View>)notification.getNewValue(); + return (List<View>) notification.getNewValue(); } - + } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifier.java index db8768dd68e..e8b942e7f8c 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifier.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -24,13 +24,13 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; * The class take care to check if the {@link LayersStackApplication} exist or not. * So, it can be used in all cases, even if the {@link LayersStackApplication} is not * created. - * + * * The following events are fired: * <ul> - * <li>LayerStack added</li> - * <li>LayerStack removed</li> + * <li>LayerStack added</li> + * <li>LayerStack removed</li> * </ul> - * + * * @author cedric dumoulin * */ @@ -39,16 +39,19 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { /** * States used in the state machine. */ - protected enum State {NoApplication, ApplicationCreated, disposed}; + protected enum State { + NoApplication, ApplicationCreated, disposed + }; + protected State state; - + protected LayersModel layersModel; /** * Notifier on {@link LayersStack} life cycle events */ protected LayersStackApplicationEventNotifier layersStackApplicationEventNotifier; - + /** * Notifier on {@link LayersStackApplication} life cycle events. */ @@ -58,22 +61,22 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { * Listener on {@link LayersStackApplication} life cycle events */ protected ILayersModelRootEventListener layersStackApplicationLifeCycleEventListener = new ILayersModelRootEventListener() { - + @Override public void layersModelRootRemoved(Notification msg) { - if( state == State.ApplicationCreated) { + if (state == State.ApplicationCreated) { transitionApplicationCreatedToNoApplicationState(); } } - + @Override public void layersModelRootAdded(Notification msg) { - if( state == State.NoApplication) { + if (state == State.NoApplication) { transitionNoApplicationToApplicationCreatedState(); } } }; - + /** * Constructor. * @@ -89,15 +92,15 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { * Init the state of the object */ private void initState() { - - if( layersModel.lookupLayerStackApplication() != null) { + + if (layersModel.lookupLayerStackApplication() != null) { transitionInitToApplicationCreatedState(); } else { transitionInitToNoApplicationState(); } } - + /** * Initialize the class for the NoApplication state: * - listen on LayersModel notifiers for application creation @@ -138,10 +141,10 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { /** * Activate the notifier. - * + * */ protected void activate() { - createListeners(); + createListeners(); } /** @@ -150,7 +153,7 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { protected void deactivate() { deleteListeners(); } - + /** * Dispose the synchronizer */ @@ -160,21 +163,22 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { layersModel = null; state = State.disposed; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return state == State.disposed; } - + /** * Activate the notifier. */ private void activateLayersStackLifeCycleEventNotifier() { layersStackApplicationEventNotifier.activate(); - + } /** @@ -182,7 +186,7 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { */ private void deactivateLayersStackLifeCycleEventNotifier() { layersStackApplicationEventNotifier.deactivate(); - + } @@ -201,102 +205,104 @@ public class LayersStackAndApplicationLifeCycleEventNotifier { deleteLayersModelAndDiagramDeletionNotifiers(); deleteLayersModelRootNotifier(); } - + /** * Activate the listeners. - * + * */ private void createLayersModelRootNotifier() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ - + layersModelEventRootNotifier = new LayersModelEventRootNotifier(layersModel); - layersModelEventRootNotifier.addEventListener(layersStackApplicationLifeCycleEventListener); + layersModelEventRootNotifier.addEventListener(layersStackApplicationLifeCycleEventListener); } /** * Deactivate the listeners. - * + * */ private void deleteLayersModelRootNotifier() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ - if( layersModelEventRootNotifier != null ) { + if (layersModelEventRootNotifier != null) { layersModelEventRootNotifier.removeEventListener(layersStackApplicationLifeCycleEventListener); layersModelEventRootNotifier.dispose(); - layersModelEventRootNotifier = null; + layersModelEventRootNotifier = null; } } /** * Activate the listeners. - * + * */ private void createLayersModelAndDiagramDeletionNotifiers() { - /** + /** * Listen on layersModel to be inform when the application object is created. * When it is created, we can listen on it. */ layersStackApplicationEventNotifier = new LayersStackApplicationEventNotifier(layersModel, false); -// layersStackApplicationEventNotifier.addLayersModelEventListener(layersStackLifeCycleEventListener); + // layersStackApplicationEventNotifier.addLayersModelEventListener(layersStackLifeCycleEventListener); } /** * Deactivate listeners */ protected void deleteLayersModelAndDiagramDeletionNotifiers() { - if(layersStackApplicationEventNotifier!=null) { -// layersStackApplicationEventNotifier.removeLayersModelEventListener(layersStackLifeCycleEventListener); + if (layersStackApplicationEventNotifier != null) { + // layersStackApplicationEventNotifier.removeLayersModelEventListener(layersStackLifeCycleEventListener); layersStackApplicationEventNotifier.dispose(); layersStackApplicationEventNotifier = null; } } - + /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addLayersModelEventListener(ILayersStackApplicationEventListener listener) { // Add to the inner notifier layersStackApplicationEventNotifier.addLayersModelEventListener(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeLayersModelEventListener(ILayersStackApplicationEventListener listener) { layersStackApplicationEventNotifier.removeLayersModelEventListener(listener); } - + /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addLayersStackApplicationLifeCycleEventListener(ILayersModelRootEventListener listener) { // Add to the inner notifier layersModelEventRootNotifier.addEventListener(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeLayersStackApplicationLifeCycleEventListener(ILayersModelRootEventListener listener) { layersModelEventRootNotifier.removeEventListener(listener); } - + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifier.java index faa10ed9415..e1aa035c91e 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifier.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -25,10 +25,10 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; /** * This class listen to a {@link LayersStackApplication} and send following to listeners: * <ul> - * <li>LayerStack added</li> - * <li>LayerStack removed</li> + * <li>LayerStack added</li> + * <li>LayerStack removed</li> * </ul> - * + * * @author cedric dumoulin * */ @@ -40,36 +40,38 @@ public class LayersStackApplicationEventNotifier { * List of listener to notify. */ protected List<ILayersStackApplicationEventListener> listeners = new ArrayList<ILayersStackApplicationEventListener>(); - + /** * listener on LayerStack events */ protected Adapter layerStackListener = new AdapterImpl() { + @Override public void notifyChanged(Notification msg) { - - switch(msg.getFeatureID(LayersStackApplication.class)) { - case LayersPackage.LAYERS_STACK_APPLICATION__LAYERS_STACKS : - switch(msg.getEventType()) { - case Notification.ADD: - // a layerStack is added to application - // layerStack = msg.getNewValue() - layerStackAdded(msg); - break; - - case Notification.REMOVE: - // a layerStack is removed from application - // layerStack = msg.getOldValue() - layerStackRemoved(msg); - break; - - default: - break; - } - break; - }; + + switch (msg.getFeatureID(LayersStackApplication.class)) { + case LayersPackage.LAYERS_STACK_APPLICATION__LAYERS_STACKS: + switch (msg.getEventType()) { + case Notification.ADD: + // a layerStack is added to application + // layerStack = msg.getNewValue() + layerStackAdded(msg); + break; + + case Notification.REMOVE: + // a layerStack is removed from application + // layerStack = msg.getOldValue() + layerStackRemoved(msg); + break; + + default: + break; + } + break; + } + ; }; }; - + /** * Constructor. * @@ -84,27 +86,28 @@ public class LayersStackApplicationEventNotifier { * Constructor. * * @param layersModel - * @param activate True if the notifier should be activated immediately. False otherwise. + * @param activate + * True if the notifier should be activated immediately. False otherwise. */ public LayersStackApplicationEventNotifier(LayersModel layersModel, boolean activate) { this.layersModel = layersModel; - if( activate) { - activate(); + if (activate) { + activate(); } } /** * Activate the listeners. - * + * */ protected void activate() { // Listen on LayerStackApplication for LayerStack creation // TODO Avoid to create the application here. Listen on its creation // and listen on it when created. - + LayersStackApplication application = layersModel.getLayerStackApplication(); - - application.eAdapters().add( layerStackListener ); + + application.eAdapters().add(layerStackListener); } /** @@ -114,11 +117,11 @@ public class LayersStackApplicationEventNotifier { // The application can be already deactivated (because we are in dispose() // See bug 431121 LayersStackApplication application = layersModel.lookupLayerStackApplication(); - if( application != null) { - application.eAdapters().remove( layerStackListener ); + if (application != null) { + application.eAdapters().remove(layerStackListener); } } - + /** * Dispose the synchronizer */ @@ -127,81 +130,87 @@ public class LayersStackApplicationEventNotifier { deactivate(); layersModel = null; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return layersModel == null; } - + /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addLayersModelEventListener(ILayersStackApplicationEventListener listener) { - - if(listener == null ) { + + if (listener == null) { return; } - + // Check if exist - if( listeners.contains(listener)) { + if (listeners.contains(listener)) { return; } - + listeners.add(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeLayersModelEventListener(ILayersStackApplicationEventListener listener) { listeners.remove(listener); } - + /** * Called by events when a {@link LayersStack} is added to the {@link LayersStackApplication} + * * @param msg */ protected void layerStackAdded(Notification msg) { - for(ILayersStackApplicationEventListener listener : listeners) { + for (ILayersStackApplicationEventListener listener : listeners) { listener.layerStackAdded(msg); } } - + /** * Called by events when a {@link LayersStack} is removed from the {@link LayersStackApplication} + * * @param msg */ protected void layerStackRemoved(Notification msg) { - for(ILayersStackApplicationEventListener listener : listeners) { + for (ILayersStackApplicationEventListener listener : listeners) { listener.layerStackRemoved(msg); } } /** * Utility method returning the layer stack in case of addedLayer event. + * * @param msg * @return */ public static LayersStack getAddedLayerStack(Notification msg) { - return (LayersStack)msg.getNewValue(); + return (LayersStack) msg.getNewValue(); } - + /** * Utility method returning the layer stack in case of removeLayer event. + * * @param msg * @return */ public static LayersStack getRemovedLayerStack(Notification msg) { - return (LayersStack)msg.getOldValue(); + return (LayersStack) msg.getOldValue(); } - + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramHelper.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramHelper.java index 6dc42162150..4a9305bad63 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramHelper.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramHelper.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -22,9 +22,9 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; * <li>Add or remove a LayersStack</li> * <li>get the LayersStackMngr if a LayersStack exist.</li> * </ul> - * + * * @author Cedric dumoulin - * + * */ public class NotationDiagramHelper { @@ -32,77 +32,78 @@ public class NotationDiagramHelper { * Associated Diagram. */ protected Diagram diagram; - + /** * Layers model. */ protected LayersModel layersModel; - + protected LayersStackApplication layersApplication; -// /** -// * The associated {@link LayersStackMngr}. Maybe null if no LayersStack is associated. -// */ -// protected LayersStackMngr layerStackMngr; -// -// /** -// * Notifier sending event when the layerStack is added or removed. -// */ -// private LayersStackAttachedNotifier layerStackAttachedNotifier; - -// /** -// * Listen on events from the layerStackAttachedNotifier. -// */ -// private LayersStackAttachedListener layerStackAttachedListener = new LayersStackAttachedListener() { -// -// public void layerStackRemoved(LayersStackAttachedEvent event) { -// layerStackMngr.dispose(); -// layerStackMngr = null; -// } -// -// public void layerStackAttached(LayersStackAttachedEvent event) { -// -// if(layerStackMngr != null) -// { -// layerStackMngr.dispose(); -// layerStackMngr = null; -// } -// -// layerStackMngr = new LayersStackMngr(event.getLayersStack()); -// } -// -// public void diagramChanged(LayersStackAttachedEvent event) { -// // Not used because diagram is never set. -// if(layerStackMngr != null) -// { -// layerStackMngr.dispose(); -// layerStackMngr = null; -// } -// -// layerStackMngr = new LayersStackMngr(event.getLayersStack()); -// -// } -// }; + // /** + // * The associated {@link LayersStackMngr}. Maybe null if no LayersStack is associated. + // */ + // protected LayersStackMngr layerStackMngr; + // + // /** + // * Notifier sending event when the layerStack is added or removed. + // */ + // private LayersStackAttachedNotifier layerStackAttachedNotifier; + + // /** + // * Listen on events from the layerStackAttachedNotifier. + // */ + // private LayersStackAttachedListener layerStackAttachedListener = new LayersStackAttachedListener() { + // + // public void layerStackRemoved(LayersStackAttachedEvent event) { + // layerStackMngr.dispose(); + // layerStackMngr = null; + // } + // + // public void layerStackAttached(LayersStackAttachedEvent event) { + // + // if(layerStackMngr != null) + // { + // layerStackMngr.dispose(); + // layerStackMngr = null; + // } + // + // layerStackMngr = new LayersStackMngr(event.getLayersStack()); + // } + // + // public void diagramChanged(LayersStackAttachedEvent event) { + // // Not used because diagram is never set. + // if(layerStackMngr != null) + // { + // layerStackMngr.dispose(); + // layerStackMngr = null; + // } + // + // layerStackMngr = new LayersStackMngr(event.getLayersStack()); + // + // } + // }; /** * Constructor. * Construct the manager and initialize it. - * @param layersModel * + * @param layersModel + * */ public NotationDiagramHelper(LayersModel layersModel, Diagram diagram) { this.diagram = diagram; this.layersModel = layersModel; -// // Set the layerStackMngr if necessary -// LayersStack layerStack = LayersStackUtil.getInstance().lookupLayersStack(diagram); -// if(layerStack != null) { -// layerStackMngr = new LayersStackMngr(layerStack); -// } -// -// // Set the listeners on changes -// layerStackAttachedNotifier = new LayersStackAttachedNotifier(diagram); -// layerStackAttachedNotifier.addLayersStackAttachedEventListener(layerStackAttachedListener); + // // Set the layerStackMngr if necessary + // LayersStack layerStack = LayersStackUtil.getInstance().lookupLayersStack(diagram); + // if(layerStack != null) { + // layerStackMngr = new LayersStackMngr(layerStack); + // } + // + // // Set the listeners on changes + // layerStackAttachedNotifier = new LayersStackAttachedNotifier(diagram); + // layerStackAttachedNotifier.addLayersStackAttachedEventListener(layerStackAttachedListener); activate(); } @@ -111,26 +112,26 @@ public class NotationDiagramHelper { * Activate the manager. */ public void activate() { -// layerStackAttachedNotifier.activate(); + // layerStackAttachedNotifier.activate(); } /** * Deactivate the manager. */ public void deactivate() { -// layerStackAttachedNotifier.deactivate(); + // layerStackAttachedNotifier.deactivate(); } /** * Dispose all resources. */ public void dispose() { -// layerStackAttachedNotifier.deactivate(); + // layerStackAttachedNotifier.deactivate(); diagram = null; } - + /** * @return the diagram */ @@ -138,19 +139,19 @@ public class NotationDiagramHelper { return diagram; } - -// /** -// * Return the {@link LayersStackMngr} if any. Throw an -// * @return the layerStackMngr -// * @throws NotSetException If the layerStackMngr is not set. -// */ -// public LayersStackMngr getLayersStackMngr() throws NotSetException { -// -// if(layerStackMngr == null) -// throw new NotSetException(this.getClass().getSimpleName() + ".getLayersStackMngr(): layerStackMngr is not set."); -// -// return layerStackMngr; -// } + + // /** + // * Return the {@link LayersStackMngr} if any. Throw an + // * @return the layerStackMngr + // * @throws NotSetException If the layerStackMngr is not set. + // */ + // public LayersStackMngr getLayersStackMngr() throws NotSetException { + // + // if(layerStackMngr == null) + // throw new NotSetException(this.getClass().getSimpleName() + ".getLayersStackMngr(): layerStackMngr is not set."); + // + // return layerStackMngr; + // } /** * Attach the {@link LayersStack} to the diagram. @@ -173,34 +174,34 @@ public class NotationDiagramHelper { /** * Return True if a {@link LayersStack} is attached to the diagram. - * + * * @return True if a {@link LayersStack} is attached to the diagram. */ public boolean isLayersStackAttached() { LayersStackApplication application = layersModel.lookupLayerStackApplication(); - if(application == null ) { + if (application == null) { return false; } return application.isLayersStackAttachedFor(diagram); } -// /** -// * Add a listener for the {@link LayersStackActivatedEvent}. -// * -// * @param listener -// */ -// public void addLayersStackAttachedEventListener(LayersStackAttachedListener listener) { -// layerStackAttachedNotifier.addLayersStackAttachedEventListener(listener); -// } -// -// /** -// * Remove a listener for the {@link LayersStackActivatedEvent}. -// * -// * @param listener -// */ -// public void removeLayersStackAttachedEventListener(LayersStackAttachedListener listener) { -// layerStackAttachedNotifier.removeLayersStackAttachedEventListener(listener); -// } + // /** + // * Add a listener for the {@link LayersStackActivatedEvent}. + // * + // * @param listener + // */ + // public void addLayersStackAttachedEventListener(LayersStackAttachedListener listener) { + // layerStackAttachedNotifier.addLayersStackAttachedEventListener(listener); + // } + // + // /** + // * Remove a listener for the {@link LayersStackActivatedEvent}. + // * + // * @param listener + // */ + // public void removeLayersStackAttachedEventListener(LayersStackAttachedListener listener) { + // layerStackAttachedNotifier.removeLayersStackAttachedEventListener(listener); + // } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifier.java index 35f22c18782..aea47aa9863 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifier.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -26,9 +26,9 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; /** * This class listen to a {@link Resource} and send following events to listeners: * <ul> - * <li>diagram removed</li> + * <li>diagram removed</li> * </ul> - * + * * @author cedric dumoulin * */ @@ -40,32 +40,33 @@ public class NotationDiagramRemovedFromResourceEventNotifier { * List of listener to notify. */ protected List<INotationDiagramRemovedEventListener> listeners = new ArrayList<INotationDiagramRemovedEventListener>(); - + protected Adapter notationDiagramRemovedListener = new AdapterImpl() { + @Override public void notifyChanged(Notification msg) { - + // TODO When a Resource is unloaded, each diagram is removed and a corresponding event is fired. - // We need to separate event from a regular removal (user choose to remove a diagram) from events - // event fired by 'resource.unload()' (to be done). - if( msg.getEventType() == Notification.REMOVE + // We need to separate event from a regular removal (user choose to remove a diagram) from events + // event fired by 'resource.unload()' (to be done). + if (msg.getEventType() == Notification.REMOVE && msg.getNotifier() instanceof Resource - && msg.getOldValue() instanceof Diagram ) { + && msg.getOldValue() instanceof Diagram) { // A diagram is removed from its resource -// System.err.println("Resource notified. Feature=" + msg.getFeature() -// + ", type="+ msg.getEventType() -// + ", newValue=" + msg.getNewValue() -// + ", oldValue=" + msg.getOldValue()); - Resource resource = (Resource)msg.getNotifier(); + // System.err.println("Resource notified. Feature=" + msg.getFeature() + // + ", type="+ msg.getEventType() + // + ", newValue=" + msg.getNewValue() + // + ", oldValue=" + msg.getOldValue()); + Resource resource = (Resource) msg.getNotifier(); // Fire event only if resource is loaded. This should avoid firing event when the // diagram is removed because the resource is unloading. - if( resource.isLoaded() ) { - fireDiagramRemovedEvent(msg); + if (resource.isLoaded()) { + fireDiagramRemovedEvent(msg); } } }; - + }; - + /** * Constructor. * @@ -78,7 +79,7 @@ public class NotationDiagramRemovedFromResourceEventNotifier { /** * Activate the listeners. - * + * */ protected void activate() { // Listen on diagram removed events @@ -92,7 +93,7 @@ public class NotationDiagramRemovedFromResourceEventNotifier { // Listen on diagram removed events notationModel.getResource().eAdapters().remove(notationDiagramRemovedListener); } - + /** * Dispose the synchronizer */ @@ -101,62 +102,66 @@ public class NotationDiagramRemovedFromResourceEventNotifier { deactivate(); notationModel = null; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return notationModel == null; } - + /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addLayersModelEventListener(INotationDiagramRemovedEventListener listener) { - - if(listener == null ) { + + if (listener == null) { return; } - + // Check if exist - if( listeners.contains(listener)) { + if (listeners.contains(listener)) { return; } - + listeners.add(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeLayersModelEventListener(INotationDiagramRemovedEventListener listener) { listeners.remove(listener); } - + /** * Called by events when a {@link LayersStack} is added to the {@link LayersStackApplication} + * * @param msg */ protected void fireDiagramRemovedEvent(Notification msg) { - for(INotationDiagramRemovedEventListener listener : listeners) { + for (INotationDiagramRemovedEventListener listener : listeners) { listener.diagramRemoved(msg); } } /** * Get the removed diagram in case of diagramRemoved event + * * @param msg * @return */ public static Diagram getRemovedDiagram(Notification msg) { - return (Diagram)msg.getOldValue(); + return (Diagram) msg.getOldValue(); } - + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/ILayersModelRootEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/ILayersModelRootEventListener.java index 828388d7910..9f1d0dfbe96 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/ILayersModelRootEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/ILayersModelRootEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -12,31 +12,31 @@ package org.eclipse.papyrus.layers.runtime.model; import org.eclipse.emf.common.notify.Notification; import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; /** * Class implementing this interface can listen to event from a {@link LayersStackApplication}. - * + * * @author cedric dumoulin * */ public interface ILayersModelRootEventListener { /** - * Called by events when a root of type {@link LayersStackApplication} is added to the {@link LayersModel} - * elements. + * Called by events when a root of type {@link LayersStackApplication} is added to the {@link LayersModel} elements. + * * @param msg */ - public void layersModelRootAdded(Notification msg) ; - + public void layersModelRootAdded(Notification msg); + /** * Called by events when a root of type {@link LayersStackApplication} is removed from the {@link Diagram} or one of its contained * elements. + * * @param msg */ - public void layersModelRootRemoved(Notification msg) ; - + public void layersModelRootRemoved(Notification msg); + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModel.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModel.java index 085fc88afff..aac8b7c3667 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModel.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModel.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -21,11 +21,11 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; * This class declare the model used by the layer. * This model is registered to Papyrus core ModelSet which take care to load the * corresponding EMF resource. - * + * * @author cedric dumoulin * */ -public class LayersModel extends AbstractModelWithSharedResource<LayersStackApplication>{ +public class LayersModel extends AbstractModelWithSharedResource<LayersStackApplication> { /** * File extension used for notation. @@ -39,9 +39,9 @@ public class LayersModel extends AbstractModelWithSharedResource<LayersStackAppl /** * Identifier used to retrieve the model from the ModelManager - * + * * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getIdentifier() - * + * * @return */ @Override @@ -51,9 +51,9 @@ public class LayersModel extends AbstractModelWithSharedResource<LayersStackAppl /** * Get the extension used for TraceModel resources - * + * * @see org.eclipse.papyrus.infra.core.resource.AbstractBaseModel#getModelFileExtension() - * + * * @return */ @Override @@ -64,7 +64,7 @@ public class LayersModel extends AbstractModelWithSharedResource<LayersStackAppl /** * Return true if the provided object is a root of the model, false otherwise. * This method should be implemented by subclasses. - * + * * @param object * @return */ @@ -74,21 +74,23 @@ public class LayersModel extends AbstractModelWithSharedResource<LayersStackAppl } /** - * Lookup for the {@link LayersStackApplication} instance + * Lookup for the {@link LayersStackApplication} instance + * * @return the {@link LayersStackApplication} or null if not found. */ public LayersStackApplication lookupLayerStackApplication() { - + return getModelRoot(); } /** * Get the {@link LayersStackApplication} object. Create it if not found. + * * @return */ public LayersStackApplication getLayerStackApplication() { LayersStackApplication application = getModelRoot(); - if( application != null) { + if (application != null) { return application; } // Not found, create it @@ -100,28 +102,31 @@ public class LayersModel extends AbstractModelWithSharedResource<LayersStackAppl /** * Remove the specified application from the model. + * * @param application */ public void removeRoot(LayersStackApplication application) { getResource().getContents().remove(application); - + } private LayersStackAndApplicationLifeCycleEventNotifier layersStackAndApplicationLifeCycleEventNotifier = null; + /** * Get the associated {@link LayersStackAndApplicationLifeCycleEventNotifier}. * There is only one such notifier associated to the model. + * * @return */ public LayersStackAndApplicationLifeCycleEventNotifier getLayersStackLifeCycleEventNotifier() { // TODO Use an adapter to share a single instance in the model itself. - if( layersStackAndApplicationLifeCycleEventNotifier == null) { + if (layersStackAndApplicationLifeCycleEventNotifier == null) { // Create it layersStackAndApplicationLifeCycleEventNotifier = new LayersStackAndApplicationLifeCycleEventNotifier(this); } - + return layersStackAndApplicationLifeCycleEventNotifier; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModelEventRootNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModelEventRootNotifier.java index 5399e17ef71..74e496bf5cb 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModelEventRootNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/model/LayersModelEventRootNotifier.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -23,61 +23,63 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStackApplication; /** * This class listen to a {@link LayersModel} and send following events to listeners: * <ul> - * <li>root of type {@link LayersStackApplication} added</li> - * <li>root of type {@link LayersStackApplication} removed</li> + * <li>root of type {@link LayersStackApplication} added</li> + * <li>root of type {@link LayersStackApplication} removed</li> * </ul> - * + * * @author cedric dumoulin - * TODO Rename to LayersStackApplicationLifeCycleEventNotifier + * TODO Rename to LayersStackApplicationLifeCycleEventNotifier */ public class LayersModelEventRootNotifier { - protected LayersModel layersModel; + protected LayersModel layersModel; /** * List of listener to notify. */ protected List<ILayersModelRootEventListener> listeners = new ArrayList<ILayersModelRootEventListener>(); - + protected Adapter modelListener = new AdapterImpl() { - + /** * Something happen on the tree of object + * * @see org.eclipse.emf.ecore.util.EContentAdapter#notifyChanged(org.eclipse.emf.common.notify.Notification) * * @param msg */ + @Override public void notifyChanged(Notification notification) { - - + + // Check Resource modification - // There is 1 sources: + // There is 1 sources: // LayersModel::Resource::contents - if( notification.getFeatureID(Resource.class) == Resource.RESOURCE__CONTENTS) { + if (notification.getFeatureID(Resource.class) == Resource.RESOURCE__CONTENTS) { // LayerOperator::layers || LayersStack::layers // check the event type. - switch(notification.getEventType()) { + switch (notification.getEventType()) { case Notification.SET: - + break; case Notification.ADD: // A root is added - if( notification.getNewValue() instanceof LayersStackApplication ) { + if (notification.getNewValue() instanceof LayersStackApplication) { fireLayersModelRootAddedEvent(notification); } break; case Notification.REMOVE: // A root is removed - if( notification.getOldValue() instanceof LayersStackApplication ) { + if (notification.getOldValue() instanceof LayersStackApplication) { fireLayersModelRootRemovedEvent(notification); } break; } } } - + }; - + /** * Constructor. * @@ -90,7 +92,7 @@ public class LayersModelEventRootNotifier { /** * Activate the listeners. - * + * */ protected void activate() { // Listen on diagram removed events @@ -104,7 +106,7 @@ public class LayersModelEventRootNotifier { // Listen on diagram removed events layersModel.getResource().eAdapters().remove(modelListener); } - + /** * Dispose the synchronizer */ @@ -113,62 +115,66 @@ public class LayersModelEventRootNotifier { deactivate(); layersModel = null; } - + /** * Return true if the object is disposed. + * * @return */ protected boolean isDisposed() { return layersModel == null; } - + /** * Add the specified listener to the list of listener. * Do not add it if the listener is already in the list. - * + * * @param listener */ public void addEventListener(ILayersModelRootEventListener listener) { - - if(listener == null ) { + + if (listener == null) { return; } - + // Check if exist - if( listeners.contains(listener)) { + if (listeners.contains(listener)) { return; } - + listeners.add(listener); } - - /** + + /** * Remove the specified listener from the list of listeners. + * * @param listener */ public void removeEventListener(ILayersModelRootEventListener listener) { listeners.remove(listener); } - + /** * Called by events when a root is added to the {@link LayersModel} + * * @param msg */ protected void fireLayersModelRootAddedEvent(Notification msg) { - for(ILayersModelRootEventListener listener : listeners) { + for (ILayersModelRootEventListener listener : listeners) { listener.layersModelRootAdded(msg); } } /** * Called by events when a root is added to the {@link LayersModel} + * * @param msg */ protected void fireLayersModelRootRemovedEvent(Notification msg) { - for(ILayersModelRootEventListener listener : listeners) { + for (ILayersModelRootEventListener listener : listeners) { listener.layersModelRootRemoved(msg); } } - + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/AbstractDerivedViewLayerNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/AbstractDerivedViewLayerNotifier.java index a71a7afb2c0..726fe72fbb5 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/AbstractDerivedViewLayerNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/AbstractDerivedViewLayerNotifier.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 Cedric Dumoulin.
*
- *
+ *
* 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
@@ -24,7 +24,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.RegExpLayer; * This class maintains a list of listeners. It allows to add and remove listeners.
* If there is no more listener, stop listening on external events.
* Start listening on external events as soon as there is a listener.
- *
+ *
* @author cedric dumoulin
*
*/
@@ -34,38 +34,38 @@ public abstract class AbstractDerivedViewLayerNotifier { * List of listeners that should be notified.
*/
protected List<RegExpLayer> listeners = new ArrayList<RegExpLayer>();
-
+
/**
* Indicate if this Notifier is listening on externals events
*/
private boolean isListening = false;
-
+
/**
* Attach the listener to this notifier.
- *
+ *
* @param layer
*/
public void addListener(RegExpLayer listener) {
- if(!listeners.contains(listener)) {
+ if (!listeners.contains(listener)) {
listeners.add(listener);
checkStartListening();
}
}
-
+
/**
* Attach the listener to this notifier.
- *
+ *
* @param layer
*/
public void removeListener(RegExpLayer listener) {
- listeners.remove(listener);
- checkStopListening();
-
+ listeners.remove(listener);
+ checkStopListening();
+
}
-
+
/**
* Attach the listener to this notifier.
- *
+ *
* @param layer
*/
public void removeAllListeners() {
@@ -73,26 +73,26 @@ public abstract class AbstractDerivedViewLayerNotifier { listeners.clear();
stopListening();
}
-
+
/**
- * Check if we should start listening.
- * If the class is not listening on externals events, and there is some listeners, then
+ * Check if we should start listening.
+ * If the class is not listening on externals events, and there is some listeners, then
* start listening (call {@link #startListening()} and set {@link #isListening()} to true.
*/
private void checkStartListening() {
- if( !isListening() && listeners.size() > 0) {
- isListening=true;
+ if (!isListening() && listeners.size() > 0) {
+ isListening = true;
startListening();
}
}
/**
* Check if we should stop listening.
- * If the class is listening on externals events, and there is no more listeners, then
+ * If the class is listening on externals events, and there is no more listeners, then
* stop listening (call {@link #stopListening()} and set {@link #isListening()} to false.
*/
private void checkStopListening() {
- if(isListening() && listeners.size() == 0) {
+ if (isListening() && listeners.size() == 0) {
isListening = false;
stopListening();
}
@@ -101,18 +101,18 @@ public abstract class AbstractDerivedViewLayerNotifier { /**
* fire the event to all registered listeners.
*/
- public void fireEvent( ) {
- for( RegExpLayer listener : listeners) {
-// listener.evaluateExpr();
+ public void fireEvent() {
+ for (RegExpLayer listener : listeners) {
+ // listener.evaluateExpr();
}
}
-
+
/**
* Start listening on external events.
* Should be implemented by subclass
*/
abstract protected void startListening();
-
+
/**
* Stop listening on external events.
* Should be implemented by subclass
@@ -121,6 +121,7 @@ public abstract class AbstractDerivedViewLayerNotifier { /**
* Return true if this Notifier is listening on externals events.
+ *
* @return
*/
public boolean isListening() {
@@ -128,6 +129,6 @@ public abstract class AbstractDerivedViewLayerNotifier { return isListening;
}
-
+
}
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DiagramChangedEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DiagramChangedEventNotifier.java index 30eea472991..5be908164d8 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DiagramChangedEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DiagramChangedEventNotifier.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 Cedric Dumoulin.
*
- *
+ *
* 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
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack; /**
* Notify listeners when a change occurs on an domain element associated to an element of the LayerStack's diagram.
- *
+ *
* @author cedric dumoulin
*
*/
@@ -29,9 +29,9 @@ public class DiagramChangedEventNotifier extends AbstractDerivedViewLayerNotifie * {@link LayersStack} containing the {@link Diagram} on which this notifier is listening changes.
*/
protected LayersStack layersStack;
-
+
/**
- *
+ *
* Constructor.
*
* @param layersStack
@@ -39,9 +39,10 @@ public class DiagramChangedEventNotifier extends AbstractDerivedViewLayerNotifie public DiagramChangedEventNotifier(LayersStack layersStack) {
this.layersStack = layersStack;
}
-
+
/**
* Start listening on externals events that should be relayed by this Notifier.
+ *
* @see org.eclipse.papyrus.layers.runtime.notifier.AbstractDerivedViewLayerNotifier#startListening()
*
*/
@@ -53,6 +54,7 @@ public class DiagramChangedEventNotifier extends AbstractDerivedViewLayerNotifie /**
* Start listening on externals events that should be relayed by this Notifier.
+ *
* @see org.eclipse.papyrus.layers.runtime.notifier.AbstractDerivedViewLayerNotifier#stopListening()
*
*/
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DomainChangedEventNotifier.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DomainChangedEventNotifier.java index c79e825a870..7107653e873 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DomainChangedEventNotifier.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/notifier/DomainChangedEventNotifier.java @@ -1,7 +1,7 @@ /*****************************************************************************
* Copyright (c) 2013 Cedric Dumoulin.
*
- *
+ *
* 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
@@ -19,7 +19,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack; /**
* Notify listeners when a change occurs on an domain element associated to an element of the LayerStack's diagram.
- *
+ *
* @author cedric dumoulin
*
*/
@@ -29,9 +29,9 @@ public class DomainChangedEventNotifier extends AbstractDerivedViewLayerNotifier * {@link LayersStack} containing the {@link Diagram} on which this notifier is listening changes.
*/
protected LayersStack layersStack;
-
+
/**
- *
+ *
* Constructor.
*
* @param layersStack
@@ -39,9 +39,10 @@ public class DomainChangedEventNotifier extends AbstractDerivedViewLayerNotifier public DomainChangedEventNotifier(LayersStack layersStack) {
this.layersStack = layersStack;
}
-
+
/**
* Start listening on externals events that should be relayed by this Notifier.
+ *
* @see org.eclipse.papyrus.layers.runtime.notifier.AbstractDerivedViewLayerNotifier#startListening()
*
*/
@@ -53,6 +54,7 @@ public class DomainChangedEventNotifier extends AbstractDerivedViewLayerNotifier /**
* Start listening on externals events that should be relayed by this Notifier.
+ *
* @see org.eclipse.papyrus.layers.runtime.notifier.AbstractDerivedViewLayerNotifier#stopListening()
*
*/
diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/service/LayersApplicationService.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/service/LayersApplicationService.java index c134f35ac93..50bcb3156ec 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/service/LayersApplicationService.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/service/LayersApplicationService.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -33,7 +33,7 @@ public class LayersApplicationService implements IService { * ModelSet to retrieve models */ protected ModelSet modelSet; - + /** * The synchronizer used to listen on events and to synchronize layers and notation. */ @@ -42,11 +42,12 @@ public class LayersApplicationService implements IService { * associated layerModel. */ private LayersModel layersModel; - + /** * The {@link NotationModel} */ private NotationModel notationModel; + /** * Constructor. * @@ -65,7 +66,7 @@ public class LayersApplicationService implements IService { public void init(ServicesRegistry servicesRegistry) throws ServiceException { // Retrieve required services. modelSet = servicesRegistry.getService(ModelSet.class); -// multiDiagramEditor = servicesRegistry.getService(IMultiDiagramEditor.class); + // multiDiagramEditor = servicesRegistry.getService(IMultiDiagramEditor.class); } /** @@ -75,32 +76,32 @@ public class LayersApplicationService implements IService { */ @Override public void startService() throws ServiceException { - + // Try to get the associated model try { - layersModel = (LayersModel)modelSet.getModelChecked(LayersModel.MODEL_ID); - notationModel = (NotationModel)modelSet.getModelChecked(NotationModel.MODEL_ID); + layersModel = (LayersModel) modelSet.getModelChecked(LayersModel.MODEL_ID); + notationModel = (NotationModel) modelSet.getModelChecked(NotationModel.MODEL_ID); } catch (NotFoundException e) { throw new ServiceException("Can't get layer model", e); } catch (ClassCastException e) { throw new ServiceException("layersModel should be of type LayersModel", e); } - + // Check model LayersStackApplication application = layersModel.getModelRoot(); - boolean isAlreadyExist = (application !=null); - if( log.isDebugEnabled() ) { - if( isAlreadyExist) { + boolean isAlreadyExist = (application != null); + if (log.isDebugEnabled()) { + if (isAlreadyExist) { log.debug("LayerApplication already exist in modelSet"); } else { - log.debug("LayerApplication do not exist in modelSet"); + log.debug("LayerApplication do not exist in modelSet"); } } - + // Start synchronizer layersSynchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); - + } /** @@ -110,12 +111,12 @@ public class LayersApplicationService implements IService { */ @Override public void disposeService() throws ServiceException { - + layersSynchronizer.dispose(); layersSynchronizer = null; layersModel = null; modelSet = null; -// multiDiagramEditor = null; + // multiDiagramEditor = null; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/utils/package-info.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/utils/package-info.java index 40041bddeac..9b7102fea15 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/utils/package-info.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/src/org/eclipse/papyrus/layers/runtime/utils/package-info.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -13,3 +13,4 @@ * */ package org.eclipse.papyrus.layers.runtime.utils; + diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/DiagramViewEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/DiagramViewEventNotifierTest.java index d0fc400f054..17cbb6f87fe 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/DiagramViewEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/DiagramViewEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -49,19 +49,19 @@ public class DiagramViewEventNotifierTest { */ @Before public void setUp() throws Exception { -// // Create ModelSet and Model -// ModelSet mngr = new ModelSet(); -// // LayersModel -// LayersModel layersModel = new LayersModel(); -// mngr.registerModel(layersModel); -// // Notation model -// NotationModel notationModel = new NotationModel(); -// mngr.registerModel(notationModel); -// // Do create resources -// URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); -// mngr.createModels(uri); -// -// modelSet = mngr; + // // Create ModelSet and Model + // ModelSet mngr = new ModelSet(); + // // LayersModel + // LayersModel layersModel = new LayersModel(); + // mngr.registerModel(layersModel); + // // Notation model + // NotationModel notationModel = new NotationModel(); + // mngr.registerModel(notationModel); + // // Do create resources + // URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); + // mngr.createModels(uri); + // + // modelSet = mngr; } /** @@ -69,7 +69,7 @@ public class DiagramViewEventNotifierTest { */ @After public void tearDown() throws Exception { -// modelSet.unload(); + // modelSet.unload(); } /** @@ -78,7 +78,7 @@ public class DiagramViewEventNotifierTest { @Test public void testDiagramViewEventNotifier() { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - + DiagramViewEventNotifier notifier = new DiagramViewEventNotifier(diagram); assertNotNull("notifier created", notifier); @@ -92,7 +92,7 @@ public class DiagramViewEventNotifierTest { @Test public void testDispose() { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - + DiagramViewEventNotifier notifier = new DiagramViewEventNotifier(diagram); assertNotNull("notifier created", notifier); @@ -126,24 +126,24 @@ public class DiagramViewEventNotifierTest { @Test public void testFireDiagramViewAddedEvent() { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - + DiagramViewEventNotifier notifier = new DiagramViewEventNotifier(diagram); - + TraceDiagramViewEventListener listener = new TraceDiagramViewEventListener(); notifier.addEventListener(listener); - + // Add view - Node node1 = diagram.createChild( NotationPackage.eINSTANCE.getShape() ); - + Node node1 = diagram.createChild(NotationPackage.eINSTANCE.getShape()); + // Check for event assertEquals("event found", "diagramViewAdded", listener.traces.get(0).name); - + // Check inner creation listener.traces.clear(); - node1.createChild( NotationPackage.eINSTANCE.getShape() ); + node1.createChild(NotationPackage.eINSTANCE.getShape()); assertEquals("event found", "diagramViewAdded", listener.traces.get(0).name); - + } /** @@ -152,18 +152,18 @@ public class DiagramViewEventNotifierTest { @Test public void testFireDiagramViewRemovedEvent() { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); - + DiagramViewEventNotifier notifier = new DiagramViewEventNotifier(diagram); - + TraceDiagramViewEventListener listener = new TraceDiagramViewEventListener(); notifier.addEventListener(listener); - + // Add view - Node node1 = diagram.createChild( NotationPackage.eINSTANCE.getShape() ); - + Node node1 = diagram.createChild(NotationPackage.eINSTANCE.getShape()); + // Check inner creation listener.traces.clear(); - node1.createChild( NotationPackage.eINSTANCE.getShape() ); + node1.createChild(NotationPackage.eINSTANCE.getShape()); // Check if the node is a children of the diagram assertTrue("event found", diagram.getChildren().contains(node1)); @@ -172,9 +172,9 @@ public class DiagramViewEventNotifierTest { listener.traces.clear(); diagram.removeChild(node1); assertFalse("event found", diagram.getChildren().contains(node1)); - + assertTrue("event found", listener.traces.contains("diagramViewRemoved")); -// assertEquals("event found", "diagramViewRemoved", listener.traces.get(0).name); + // assertEquals("event found", "diagramViewRemoved", listener.traces.get(0).name); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerEventTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerEventTest.java index 215ac77ce36..8069ca8e612 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerEventTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerEventTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -39,6 +39,7 @@ public class LayerStackApplicationSynchronizerEventTest { * ModelSet created for each test */ protected ModelSet modelSet; + /** * @throws java.lang.Exception */ @@ -55,7 +56,7 @@ public class LayerStackApplicationSynchronizerEventTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -65,7 +66,7 @@ public class LayerStackApplicationSynchronizerEventTest { @After public void tearDown() throws Exception { modelSet.unload(); - + } /** @@ -74,20 +75,20 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testModelSetCreation() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - + } /** @@ -96,8 +97,8 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testLayerStackApplicationSynchronizer() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); @@ -112,12 +113,12 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testDispose() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer.getLayersModel()); - + // Try to dispose synchronizer.dispose(); assertNull("object is disposed", synchronizer.getLayersModel()); @@ -129,25 +130,25 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testLayerAddedEventListener() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the synchronizer TriggeredEventTraces traces = new TriggeredEventTraces(); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizerSubclass(layersModel, notationModel, traces); - // Add a layer Stack to the diagram + // Add a layer Stack to the diagram helper.attachLayersStack(); - + // Check if the appropriate method is called assertEquals("event catched", "layerStackAdded", traces.get(0).name); assertTrue("event catched", traces.contains("layerStackAdded")); - + // dispose synchronizer.dispose(); } @@ -158,24 +159,24 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testLayerRemovedEventListener() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the synchronizer TriggeredEventTraces traces = new TriggeredEventTraces(); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizerSubclass(layersModel, notationModel, traces); - // Add a layer Stack to the diagram + // Add a layer Stack to the diagram helper.attachLayersStack(); - + traces.clear(); helper.removeLayersStack(); - + // Check if the appropriate method is called assertTrue("event catched", traces.contains("layerStackRemoved")); @@ -189,38 +190,38 @@ public class LayerStackApplicationSynchronizerEventTest { @Test public void testDiagramRemovedEventListener() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create a diagram Diagram diagram1 = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram1); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helperForDiag1 = new NotationDiagramHelper(layersModel, diagram1); - + // Create a diagram Diagram diagram2 = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram2); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helperForDiag2 = new NotationDiagramHelper(layersModel, diagram2); - + // Create the synchronizer TriggeredEventTraces traces = new TriggeredEventTraces(); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizerSubclass(layersModel, notationModel, traces); - // Add a layer Stack to the diagram + // Add a layer Stack to the diagram helperForDiag1.attachLayersStack(); helperForDiag2.attachLayersStack(); - + // Try to remove a diagram traces.clear(); notationModel.getResource().getContents().remove(diagram2); - - + + // Check if the appropriate method is called assertTrue("event catched", traces.contains("diagramRemoved")); -// assertEquals("number of events", 1, traces.traces.size()); -// assertEquals("diagram found in notification", diagram2, traces.traces.get(0).notifier.getOldValue()); + // assertEquals("number of events", 1, traces.traces.size()); + // assertEquals("diagram found in notification", diagram2, traces.traces.get(0).notifier.getOldValue()); assertEquals("diagram found in notification", diagram2, traces.getFirstEvent("diagramRemoved").notifier.getOldValue()); // dispose diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerSubclass.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerSubclass.java index a4953b2dddd..72d4912f464 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerSubclass.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerSubclass.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -19,7 +19,7 @@ import org.eclipse.papyrus.layers.runtime.utils.TriggeredEventTraces; /** * This class subclass the {@link LayerStackApplicationSynchronizer} in order to record * the calls to the method catching the events from the superclass. - * + * * @author cedric dumoulin * */ @@ -28,8 +28,8 @@ public class LayerStackApplicationSynchronizerSubclass extends LayerStackApplica /** * List of recorded events. */ - public TriggeredEventTraces traces ; - + public TriggeredEventTraces traces; + /** * Constructor. * @@ -41,7 +41,7 @@ public class LayerStackApplicationSynchronizerSubclass extends LayerStackApplica traces = new TriggeredEventTraces(); } - + /** * Constructor. * @@ -56,19 +56,19 @@ public class LayerStackApplicationSynchronizerSubclass extends LayerStackApplica /** - * + * * @see org.eclipse.papyrus.layers.runtime.LayerStackApplicationSynchronizer#layerStackAdded(org.eclipse.emf.common.notify.Notification) * * @param msg */ @Override public void layerStackAdded(Notification msg) { - traces.addTrace( "layerStackAdded", msg); + traces.addTrace("layerStackAdded", msg); super.layerStackAdded(msg); } - + /** - * + * * @see org.eclipse.papyrus.layers.runtime.LayerStackApplicationSynchronizer#layerStackRemoved(org.eclipse.emf.common.notify.Notification) * * @param msg @@ -80,7 +80,7 @@ public class LayerStackApplicationSynchronizerSubclass extends LayerStackApplica } /** - * + * * @see org.eclipse.papyrus.layers.runtime.LayerStackApplicationSynchronizer#diagramRemoved(org.eclipse.emf.common.notify.Notification) * * @param msg diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerTest.java index 85e0c4164c3..b1ef9feb3de 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackApplicationSynchronizerTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -27,7 +27,7 @@ import org.junit.Test; * Tests for the {@link LayerStackApplicationSynchronizer} class. * This tests do not tests event received when models are modified. * This tests tests method behavior when they are called directly. - * + * * @author cedric dumoulin * */ @@ -42,6 +42,7 @@ public class LayerStackApplicationSynchronizerTest { * ModelSet created for each test */ protected ModelSet modelSet; + /** * @throws java.lang.Exception */ @@ -58,7 +59,7 @@ public class LayerStackApplicationSynchronizerTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -68,7 +69,7 @@ public class LayerStackApplicationSynchronizerTest { @After public void tearDown() throws Exception { modelSet.unload(); - + } /** @@ -77,28 +78,29 @@ public class LayerStackApplicationSynchronizerTest { @Test public void testModelSetCreation() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - + } + /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackApplicationSynchronizer#LayerStackApplicationSynchronizer(org.eclipse.papyrus.layers.runtime.model.LayersModel, org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel)}. */ @Test public void testLayerStackApplicationSynchronizer() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); @@ -112,8 +114,8 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testGetLayersModel() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("layers model exist", synchronizer.getLayersModel()); @@ -128,8 +130,8 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testGetNotationModel() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("layers model exist", synchronizer.getNotationModel()); @@ -144,12 +146,12 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testDispose() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer.getLayersModel()); - + // Try to dispose assertFalse("object is disposed", synchronizer.isDisposed()); synchronizer.dispose(); @@ -161,8 +163,8 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testLayerStackAdded() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Init models Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); @@ -170,17 +172,17 @@ public class LayerStackApplicationSynchronizerTest { // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); // add a LayerStack to models // in result, the method should be called helper.attachLayersStack(); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); - + assertNotNull("LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); + synchronizer.dispose(); } @@ -189,8 +191,8 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testLayerStackRemoved() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Init models Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); @@ -198,22 +200,22 @@ public class LayerStackApplicationSynchronizerTest { // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); // add a LayerStack to models // in result, the method should be called helper.attachLayersStack(); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); - + assertNotNull("LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); + // Remove layer helper.removeLayersStack(); - - assertNull( "LayerStackSynchronizer removed", synchronizer.getSynchronizers().get(diagram)); - + + assertNull("LayerStackSynchronizer removed", synchronizer.getSynchronizers().get(diagram)); + synchronizer.dispose(); } @@ -222,8 +224,8 @@ public class LayerStackApplicationSynchronizerTest { */ @Test public void testDiagramRemoved() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Init models Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); @@ -231,22 +233,22 @@ public class LayerStackApplicationSynchronizerTest { // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); // add a LayerStack to models // in result, the method should be called helper.attachLayersStack(); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); - + assertNotNull("LayerStackSynchronizer added", synchronizer.getSynchronizers().get(diagram)); + // Remove diagram notationModel.getResource().getContents().remove(diagram); - - assertNull( "LayerStackSynchronizer removed", synchronizer.getSynchronizers().get(diagram)); - + + assertNull("LayerStackSynchronizer removed", synchronizer.getSynchronizers().get(diagram)); + synchronizer.dispose(); } @@ -254,41 +256,41 @@ public class LayerStackApplicationSynchronizerTest { * Test {@link LayerStackApplicationSynchronizer} start when an application object * with LayerStack already exist in the LayerModel. * Test if synchronizer are restarted for already existing Stacks. - * + * */ @Test public void testLayerStackApplicationSynchronizerRestartSynchronizer() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); - + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); + // Init models Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - - + + // create a stack: this also create the application object in model. helper.attachLayersStack(); - + // create synchronizer LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram)); - + assertNotNull("LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram)); + // Check if we can add new LayerStack Diagram diagram2 = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram2); NotationDiagramHelper helper2 = new NotationDiagramHelper(layersModel, diagram2); helper2.attachLayersStack(); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram2)); - - + assertNotNull("LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram2)); + + synchronizer.dispose(); } @@ -296,33 +298,33 @@ public class LayerStackApplicationSynchronizerTest { * Test {@link LayerStackApplicationSynchronizer} start when NO application object * exist in the LayerModel. * Test if synchronizer is correctly started and accept new stack attachment. - * + * */ @Test public void testLayerStackApplicationSynchronizerStartWithNoApplicationInModel() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); - + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); + // create synchronizer LayerStackApplicationSynchronizer synchronizer = new LayerStackApplicationSynchronizer(layersModel, notationModel); assertNotNull("application created", synchronizer); // Here, the synchronizer should have not create an application ! - assertNull( "Application is not created in model", layersModel.lookupLayerStackApplication() ); - + assertNull("Application is not created in model", layersModel.lookupLayerStackApplication()); + // Create a stack: first the diagram, then an helper, then the stack Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. - NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); + NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); // create a stack: this also create the application object in model. helper.attachLayersStack(); - + // Check if the appropriate LayerStackSynchronizer is created - assertNotNull( "LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram)); + assertNotNull("LayerStackSynchronizer created", synchronizer.getSynchronizers().get(diagram)); // Here, the application should be created (by the stack creation) - assertNotNull( "Application is created in model", layersModel.lookupLayerStackApplication() ); - - + assertNotNull("Application is created in model", layersModel.lookupLayerStackApplication()); + + synchronizer.dispose(); } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerSubclass.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerSubclass.java index 3f68b7e1aff..de8834fb610 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerSubclass.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerSubclass.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -18,6 +18,7 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack; /** * A subclass registering events * For tests purpose. + * * @author cedric dumoulin * */ @@ -26,8 +27,8 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { /** * List of recorded events. */ - public TriggeredEventTraces traces ; - + public TriggeredEventTraces traces; + /** * Constructor. * @@ -45,7 +46,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void propertyValueAdded(Notification notification) { - traces.addTrace( "propertyValueAdded", notification); + traces.addTrace("propertyValueAdded", notification); super.propertyValueAdded(notification); } @@ -56,7 +57,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void propertyValueRemoved(Notification notification) { - traces.addTrace( "propertyValueRemoved", notification); + traces.addTrace("propertyValueRemoved", notification); super.propertyValueRemoved(notification); } @@ -67,7 +68,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void propertyValueChanged(Notification notification) { - traces.addTrace( "propertyValueChanged", notification); + traces.addTrace("propertyValueChanged", notification); super.propertyValueChanged(notification); } @@ -78,7 +79,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void layerAdded(Notification notification) { - traces.addTrace( "layerAdded", notification); + traces.addTrace("layerAdded", notification); super.layerAdded(notification); } @@ -89,7 +90,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void layerRemoved(Notification notification) { - traces.addTrace( "layerRemoved", notification); + traces.addTrace("layerRemoved", notification); super.layerRemoved(notification); } @@ -100,7 +101,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void layerMoved(Notification notification) { - traces.addTrace( "layerMoved", notification); + traces.addTrace("layerMoved", notification); super.layerMoved(notification); } @@ -111,7 +112,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void layerSet(Notification notification) { - traces.addTrace( "layerSet", notification); + traces.addTrace("layerSet", notification); super.layerSet(notification); } @@ -122,7 +123,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void viewAddedToLayer(Notification notification) { - traces.addTrace( "viewAddedToLayer", notification); + traces.addTrace("viewAddedToLayer", notification); super.viewAddedToLayer(notification); } @@ -133,7 +134,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void viewRemovedFromLayer(Notification notification) { - traces.addTrace( "viewRemovedFromLayer", notification); + traces.addTrace("viewRemovedFromLayer", notification); super.viewRemovedFromLayer(notification); } @@ -144,7 +145,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void viewMovedBetweenLayer(Notification notification) { - traces.addTrace( "viewMovedBetweenLayer", notification); + traces.addTrace("viewMovedBetweenLayer", notification); super.viewMovedBetweenLayer(notification); } @@ -155,7 +156,7 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void diagramViewAdded(Notification msg) { - traces.addTrace( "diagramViewAdded", msg); + traces.addTrace("diagramViewAdded", msg); super.diagramViewAdded(msg); } @@ -166,19 +167,19 @@ public class LayerStackSynchronizerSubclass extends LayerStackSynchronizer { */ @Override public void diagramViewRemoved(Notification msg) { - traces.addTrace( "diagramViewRemoved", msg); + traces.addTrace("diagramViewRemoved", msg); super.diagramViewRemoved(msg); } @Override public void multiViewsAddedToLayer(Notification notification) { - traces.addTrace( "multiViewsAddedToLayer", notification); + traces.addTrace("multiViewsAddedToLayer", notification); super.multiViewsAddedToLayer(notification); } - + @Override public void multiViewsRemovedFromLayer(Notification notification) { - traces.addTrace( "multiViewsRemovedFromLayer", notification); + traces.addTrace("multiViewsRemovedFromLayer", notification); super.multiViewsRemovedFromLayer(notification); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerTest.java index 32e6c09cf29..c0e9f9b19fe 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -40,24 +40,25 @@ public class LayerStackSynchronizerTest { * ModelSet created for each test */ protected ModelSet modelSet; + /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { -// // Create ModelSet and Model -// ModelSet mngr = new ModelSet(); -// // LayersModel -// LayersModel layersModel = new LayersModel(); -// mngr.registerModel(layersModel); -// // Notation model -// NotationModel notationModel = new NotationModel(); -// mngr.registerModel(notationModel); -// // Do create resources -// URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); -// mngr.createModels(uri); -// -// modelSet = mngr; + // // Create ModelSet and Model + // ModelSet mngr = new ModelSet(); + // // LayersModel + // LayersModel layersModel = new LayersModel(); + // mngr.registerModel(layersModel); + // // Notation model + // NotationModel notationModel = new NotationModel(); + // mngr.registerModel(notationModel); + // // Do create resources + // URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); + // mngr.createModels(uri); + // + // modelSet = mngr; } /** @@ -65,8 +66,8 @@ public class LayerStackSynchronizerTest { */ @After public void tearDown() throws Exception { -// modelSet.unload(); - + // modelSet.unload(); + } /** @@ -78,11 +79,11 @@ public class LayerStackSynchronizerTest { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); LayersStack stack = LayersFactory.eINSTANCE.createLayersStack(); stack.setDiagram(diagram); - + // Create the stack LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - + // Check creation assertNotNull("object created", synchronizer); } @@ -96,11 +97,11 @@ public class LayerStackSynchronizerTest { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); LayersStack stack = LayersFactory.eINSTANCE.createLayersStack(); stack.setDiagram(diagram); - + // Create the stack LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - + // Check creation assertNotNull("getDiagram", synchronizer.getDiagram()); assertSame("getDiagram", diagram, synchronizer.getDiagram()); @@ -115,11 +116,11 @@ public class LayerStackSynchronizerTest { Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); LayersStack stack = LayersFactory.eINSTANCE.createLayersStack(); stack.setDiagram(diagram); - + // Create the stack LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - + // Check creation assertNotNull("getLayersStack", synchronizer.getLayersStack()); assertSame("getLayersStack", stack, synchronizer.getLayersStack()); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerWithApplicationTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerWithApplicationTest.java index cd1e9519fcb..5d2c35ff9f6 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerWithApplicationTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayerStackSynchronizerWithApplicationTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -45,10 +45,9 @@ import org.junit.Test; /** - * Test the {@link LayerStackSynchronizer} by initializing it from the {@link LayersStackApplication} - * class. - * - * + * Test the {@link LayerStackSynchronizer} by initializing it from the {@link LayersStackApplication} class. + * + * * @author cedric dumoulin * */ @@ -63,24 +62,25 @@ public class LayerStackSynchronizerWithApplicationTest { * ModelSet created for each test */ protected ModelSet modelSet; + /** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { -// // Create ModelSet and Model -// ModelSet mngr = new ModelSet(); -// // LayersModel -// LayersModel layersModel = new LayersModel(); -// mngr.registerModel(layersModel); -// // Notation model -// NotationModel notationModel = new NotationModel(); -// mngr.registerModel(notationModel); -// // Do create resources -// URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); -// mngr.createModels(uri); -// -// modelSet = mngr; + // // Create ModelSet and Model + // ModelSet mngr = new ModelSet(); + // // LayersModel + // LayersModel layersModel = new LayersModel(); + // mngr.registerModel(layersModel); + // // Notation model + // NotationModel notationModel = new NotationModel(); + // mngr.registerModel(notationModel); + // // Do create resources + // URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); + // mngr.createModels(uri); + // + // modelSet = mngr; } /** @@ -88,13 +88,14 @@ public class LayerStackSynchronizerWithApplicationTest { */ @After public void tearDown() throws Exception { -// modelSet.unload(); - + // modelSet.unload(); + } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#LayerStackSynchronizer(org.eclipse.papyrus.layers.stackmodel.layers.LayersStack)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testLayerStackSynchronizer() throws LayersException { @@ -105,42 +106,42 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create synchronizer LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - + // Check creation assertNotNull("object created", synchronizer); // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); View view3 = NotationFactory.eINSTANCE.createShape(); View view4 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); Property property2 = propertyRegistry.getProperties().get(index++); Property property3 = propertyRegistry.getProperties().get(index++); Property property4 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1), Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1), Arrays.asList(property1)); + // Create layer2: views ={} propInstances={} - Layer layer2 = createLayer( layer, Arrays.asList(view1, view2), Arrays.asList(property1, property2)); - + Layer layer2 = createLayer(layer, Arrays.asList(view1, view2), Arrays.asList(property1, property2)); + // Create layer3: views ={} propInstances={} - Layer layer3 = createLayer( layer, Arrays.asList(view3), Arrays.asList(property3)); - - + Layer layer3 = createLayer(layer, Arrays.asList(view3), Arrays.asList(property3)); + + + - } /** @@ -155,11 +156,11 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create synchronizer LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - - + + // Check creation assertNotNull("getDiagram", synchronizer.getDiagram()); assertSame("getDiagram", diagram, synchronizer.getDiagram()); @@ -177,11 +178,11 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create synchronizer LayerStackSynchronizer synchronizer = new LayerStackSynchronizer(stack); - - + + // Check creation assertNotNull("getLayersStack", synchronizer.getLayersStack()); assertSame("getLayersStack", stack, synchronizer.getLayersStack()); @@ -207,7 +208,8 @@ public class LayerStackSynchronizerWithApplicationTest { /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#propertyValueAdded(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testPropertyValueAdded() throws LayersException { @@ -218,7 +220,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -227,31 +229,32 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); Property property2 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1), Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1), Arrays.asList(property1)); + // Checks traces.clear(); // add a property layer1.addPropertyInstance(property2); - - assertTrue("event sent", traces.size()>0); + + assertTrue("event sent", traces.size() > 0); assertSame("event sent", "propertyValueAdded", traces.get(0).name); - + } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#propertyValueRemoved(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testPropertyValueRemoved() throws LayersException { @@ -262,7 +265,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -271,30 +274,31 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); Property property2 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1), Arrays.asList(property1, property2)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1), Arrays.asList(property1, property2)); + // Checks traces.clear(); // remove a property layer1.removePropertyInstance(property2); - - assertTrue("event sent", traces.size()>0); + + assertTrue("event sent", traces.size() > 0); assertSame("event sent", "propertyValueRemoved", traces.get(0).name); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#propertyValueChanged(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testPropertyValueChanged() throws LayersException { @@ -305,7 +309,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -314,38 +318,38 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); Property property2 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1), Arrays.asList(property1, property2)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1), Arrays.asList(property1, property2)); + // Checks traces.clear(); // change a property value TypeInstance value = layer1.getPropertyInstance(property1); // Check the type of the instance // We don't know the type as it is set externally in the Property registry. - if( value instanceof StringInstance) { + if (value instanceof StringInstance) { assertTrue("value is instance of String", value instanceof StringInstance); - StringInstance stringValue = (StringInstance)value; + StringInstance stringValue = (StringInstance) value; stringValue.setValue("newValue"); } - else if( value instanceof BooleanInstance) { - BooleanInstance realValue = (BooleanInstance)value; + else if (value instanceof BooleanInstance) { + BooleanInstance realValue = (BooleanInstance) value; realValue.setValue(true); } - + // What for ? layer1.removePropertyInstance(property2); - - assertTrue("event sent", traces.size()>0); + + assertTrue("event sent", traces.size() > 0); assertSame("event sent", "propertyValueChanged", traces.get(0).name); } @@ -387,7 +391,8 @@ public class LayerStackSynchronizerWithApplicationTest { /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#viewAddedToLayer(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testViewAddedToLayer() throws LayersException { @@ -398,7 +403,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -407,32 +412,33 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1), Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1), Arrays.asList(property1)); + // action traces.clear(); // remove a view layer1.getViews().add(view2); - + // assert - assertTrue("event sent", traces.size()>0); + assertTrue("event sent", traces.size() > 0); TriggeredEvent event = traces.get(0); assertSame("event sent", "viewAddedToLayer", event.name); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#viewAddedToLayer(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testNViewAddedToLayer() throws LayersException { @@ -443,7 +449,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -452,44 +458,45 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); View view3 = NotationFactory.eINSTANCE.createShape(); - + List<View> viewsToAttach = Arrays.asList(view1); List<View> viewsToAdd = Arrays.asList(view2, view3); // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, viewsToAttach, Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, viewsToAttach, Arrays.asList(property1)); + // action traces.clear(); // remove a view - layer1.getViews().addAll(viewsToAdd ); - + layer1.getViews().addAll(viewsToAdd); + // assert - assertTrue("event sent", traces.size()>0); + assertTrue("event sent", traces.size() > 0); TriggeredEvent event = traces.get(0); assertSame("event sent", "multiViewsAddedToLayer", event.name); - + // Check the collection Notification notification = event.notifier; assertNotNull("notification is set", notification); - + List<View> addedViews = LayersModelEventUtils.ViewEvents.getViewsAdded(notification); - assertEquals( "both removed list have the same size", viewsToAdd.size(), addedViews.size()); - assertTrue( "notification contains removed views", addedViews.containsAll(viewsToAdd)); + assertEquals("both removed list have the same size", viewsToAdd.size(), addedViews.size()); + assertTrue("notification contains removed views", addedViews.containsAll(viewsToAdd)); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#viewRemovedFromLayer(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testViewRemovedFromLayer() throws LayersException { @@ -500,7 +507,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -509,32 +516,33 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, Arrays.asList(view1, view2), Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, Arrays.asList(view1, view2), Arrays.asList(property1)); + // action traces.clear(); // remove a view layer1.getViews().remove(view2); - + // assert - assertTrue("event sent", traces.size()>0); + assertTrue("event sent", traces.size() > 0); TriggeredEvent event = traces.get(0); assertSame("event sent", "viewRemovedFromLayer", event.name); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayerStackSynchronizer#viewRemovedFromLayer(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testNViewRemovedFromLayer() throws LayersException { @@ -545,7 +553,7 @@ public class LayerStackSynchronizerWithApplicationTest { // Create stack LayersStack stack = application.getLayersStackFor(diagram); - + // Create a TopLayer TopLayerOperator layer = LayersFactory.eINSTANCE.createTopLayerOperator(); layer.setApplication(application); @@ -554,39 +562,39 @@ public class LayerStackSynchronizerWithApplicationTest { // Create synchronizer LayerStackSynchronizerSubclass synchronizer = new LayerStackSynchronizerSubclass(stack); TriggeredEventTraces traces = synchronizer.traces; - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); View view3 = NotationFactory.eINSTANCE.createShape(); - + List<View> viewsToAttach = Arrays.asList(view1, view2, view3); List<View> viewsToRemove = Arrays.asList(view2, view3); - - + + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer1 = createLayer( layer, viewsToAttach, Arrays.asList(property1)); - + Layer layer1 = createLayer(layer, viewsToAttach, Arrays.asList(property1)); + // action traces.clear(); // remove a view layer1.getViews().removeAll(viewsToRemove); - + // assert - assertTrue("event sent", traces.size()>0); + assertTrue("event sent", traces.size() > 0); TriggeredEvent event = traces.get(0); assertSame("event sent", "multiViewsRemovedFromLayer", event.name); // Check the collection Notification notification = event.notifier; assertNotNull("notification is set", notification); - + List<View> removedViews = LayersModelEventUtils.ViewEvents.getViewsRemoved(notification); - assertEquals( "both removed list have the same size", removedViews.size(), viewsToRemove.size()); - assertTrue( "notification contains removed views", removedViews.containsAll(viewsToRemove)); + assertEquals("both removed list have the same size", removedViews.size(), viewsToRemove.size()); + assertTrue("notification contains removed views", removedViews.containsAll(viewsToRemove)); } /** @@ -618,29 +626,29 @@ public class LayerStackSynchronizerWithApplicationTest { /** * Create a layer with the specified view and property set - * + * * @param asList * @param asList2 * @return - * @throws LayersException + * @throws LayersException */ protected Layer createLayer(LayerOperator parent, List<View> views, List<Property> properties) throws LayersException { - + // Create the layer Layer layer = LayersFactory.eINSTANCE.createLayer(); // Set the application (needed ?) layer.setApplication(parent.getApplication()); // Attach it to its parent parent.getLayers().add(layer); - - + + // Add views - for( View view : views) { + for (View view : views) { layer.getViews().add(view); } - + // Add property instances - for(Property property : properties) { + for (Property property : properties) { layer.addPropertyInstance(property); } return layer; @@ -648,35 +656,36 @@ public class LayerStackSynchronizerWithApplicationTest { /** * Test method for {@link #createLayer(List, List)} - * @throws LayersException + * + * @throws LayersException */ @Test public void testCreateLayer() throws LayersException { - + // Create requested objects TopLayerOperator layerParent = LayersFactory.eINSTANCE.createTopLayerOperator(); LayersStackApplication application = LayersFactory.eINSTANCE.createLayersStackApplication(); layerParent.setApplication(application); PropertyRegistry propertyRegistry = application.getPropertyRegistry(); - + // Create Views View view1 = NotationFactory.eINSTANCE.createShape(); View view2 = NotationFactory.eINSTANCE.createShape(); View view3 = NotationFactory.eINSTANCE.createShape(); - + // Create Properties int index = 0; Property property1 = propertyRegistry.getProperties().get(index++); Property property2 = propertyRegistry.getProperties().get(index++); Property property3 = propertyRegistry.getProperties().get(index++); - + // Create layer1: views ={} propInstances={} - Layer layer = createLayer( layerParent, Arrays.asList(view1, view2), Arrays.asList(property1, property2)); - + Layer layer = createLayer(layerParent, Arrays.asList(view1, view2), Arrays.asList(property1, property2)); + // Checks assertNotNull("layer created", layer); assertSame("views added", 2, layer.getViews().size()); - + assertSame("property instance added", 2, layer.getPropertyValueMap().values().size()); assertSame("property instance is correctly set", layer.getPropertyValueMap().get(property1.getName()), layer.getPropertyInstance(property1)); assertSame("property instance is correctly set", layer.getPropertyValueMap().get(property2.getName()), layer.getPropertyInstance(property2)); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifierTest.java index ef34d3970b5..46afa023b23 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersModelEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -12,7 +12,6 @@ package org.eclipse.papyrus.layers.runtime; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.junit.Assert.assertEquals; @@ -30,7 +29,6 @@ import org.eclipse.papyrus.layers.stackmodel.layers.LayersFactory; import org.eclipse.papyrus.layers.stackmodel.layers.LayersPackage; import org.eclipse.papyrus.layers.stackmodel.layers.LayersStack; import org.eclipse.papyrus.layers.stackmodel.layers.Property; -import org.eclipse.papyrus.layers.stackmodel.layers.TypeInstance; import org.eclipse.papyrus.layers.stackmodel.layers.util.PropertyUtils; import org.junit.After; import org.junit.Before; @@ -63,15 +61,15 @@ public class LayersModelEventNotifierTest { */ @Test public void testLayersModelEventNotifier() { - + // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - -// // Add a trace listener -// ILayersModelEventListener listener = new TraceLayersModelEventListener(); -// notifier.addLayersModelEventListener(listener); - + + // // Add a trace listener + // ILayersModelEventListener listener = new TraceLayersModelEventListener(); + // notifier.addLayersModelEventListener(listener); + // Check creation assertNotNull("notifier created", notifier); } @@ -102,16 +100,16 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // dispose notifier assertFalse("notifier disposed", notifier.isDisposed()); notifier.dispose(); @@ -126,14 +124,14 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener ILayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + // Check creation assertNotNull("notifier created", notifier); - assertTrue( "listener added to internal list", notifier.listeners.contains(listener) ); + assertTrue("listener added to internal list", notifier.listeners.contains(listener)); } /** @@ -144,33 +142,34 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener ILayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - assertTrue( "listener added to internal list", notifier.listeners.contains(listener) ); - + assertTrue("listener added to internal list", notifier.listeners.contains(listener)); + // Remove the listener notifier.removeLayersModelEventListener(listener); - assertFalse( "listener removed from internal list", notifier.listeners.contains(listener) ); - - + assertFalse("listener removed from internal list", notifier.listeners.contains(listener)); + + } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayersModelEventNotifier#firePropertyValueAddedEvent(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testFirePropertyValueAddedEvent() throws LayersException { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); @@ -178,38 +177,39 @@ public class LayersModelEventNotifierTest { layersStack.setLayers(layerOp1); // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); - + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); System.err.println("layerOp1.getLayers().add(layer1)"); layerOp1.getLayers().add(layer1); - + // Add an instance to layer1 traces.traces.clear(); Property isSunday = PropertyUtils.getInstance().createProperty("isSunday", LayersPackage.eINSTANCE.getBooleanType()); layer1.addPropertyInstance(isSunday); // Check events - assertEquals("one event recorded", "propertyValueAdded", traces.traces.get(0).name ); + assertEquals("one event recorded", "propertyValueAdded", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("propertyValueAdded")); - assertEquals("one event recorded", 1, traces.traces.size() ); + assertEquals("one event recorded", 1, traces.traces.size()); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayersModelEventNotifier#firePropertyValueRemoved(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testFirePropertyValueRemoved() throws LayersException { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); @@ -217,65 +217,66 @@ public class LayersModelEventNotifierTest { layersStack.setLayers(layerOp1); // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); - + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); System.err.println("layerOp1.getLayers().add(layer1)"); layerOp1.getLayers().add(layer1); - + // Add an instance to layer1 String propertyName = "isSunday"; Property isSunday = PropertyUtils.getInstance().createProperty(propertyName, LayersPackage.eINSTANCE.getBooleanType()); layer1.addPropertyInstance(isSunday); - + // Remove the instance traces.traces.clear(); layer1.removePropertyInstance(isSunday); - + // Check events - assertEquals("one event recorded", "propertyValueRemoved", traces.traces.get(0).name ); + assertEquals("one event recorded", "propertyValueRemoved", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("propertyValueRemoved")); - assertEquals("one event recorded", 1, traces.traces.size() ); + assertEquals("one event recorded", 1, traces.traces.size()); } /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayersModelEventNotifier#firePropertyValueChanged(org.eclipse.emf.common.notify.Notification)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testFirePropertyValueChanged() throws LayersException { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // create layer op LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Add an instance to layer1 String propertyName = "isSunday"; Property isSunday = PropertyUtils.getInstance().createProperty(propertyName, LayersPackage.eINSTANCE.getBooleanType()); - BooleanInstance isSundayInstance = (BooleanInstance)layer1.addPropertyInstance(isSunday); - + BooleanInstance isSundayInstance = (BooleanInstance) layer1.addPropertyInstance(isSunday); + // Change the value of the instance traces.traces.clear(); isSundayInstance.setValue(true); - + // Check events - assertEquals("one event recorded", "propertyValueChanged", traces.traces.get(0).name ); + assertEquals("one event recorded", "propertyValueChanged", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("propertyValueChanged")); - assertEquals("one event recorded", 1, traces.traces.size() ); + assertEquals("one event recorded", 1, traces.traces.size()); } /** @@ -286,11 +287,11 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); @@ -298,18 +299,18 @@ public class LayersModelEventNotifierTest { layersStack.setLayers(layerOp1); // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); - + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); System.err.println("layerOp1.getLayers().add(layer1)"); layerOp1.getLayers().add(layer1); - + // Check events assertTrue("event recorded", traces.contains("layerAdded")); - assertEquals("one event recorded", 2, traces.traces.size() ); - assertEquals("one event recorded", "layerAdded", traces.traces.get(1).name ); + assertEquals("one event recorded", 2, traces.traces.size()); + assertEquals("one event recorded", "layerAdded", traces.traces.get(1).name); } /** @@ -320,28 +321,28 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Remove layer traces.clear(); layerOp1.getLayers().remove(layer1); - + // Check events assertTrue("event recorded", traces.contains("layerRemoved")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerRemoved", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerRemoved", traces.traces.get(0).name); } /** @@ -352,28 +353,28 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer as root LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Remove root layer traces.clear(); layersStack.setLayers(null); - + // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); // Note that no event is sent for the nested layer } @@ -385,29 +386,29 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer as root LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // replace root layer traces.clear(); Layer layer2 = LayersFactory.eINSTANCE.createLayer(); layersStack.setLayers(layer2); - + // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); } /** @@ -418,29 +419,29 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer as root LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // replace root layer traces.clear(); Layer layer2 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().set(0, layer2); - + // Check events assertTrue("event recorded", traces.contains("layerSet")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerSet", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerSet", traces.traces.get(0).name); } /** @@ -451,34 +452,34 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Add a layer Layer layer2 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer2); - + // move layer // EMF list are EList, which contains a move operation traces.clear(); - EList<LayerExpression> list = (EList<LayerExpression>)layerOp1.getLayers(); + EList<LayerExpression> list = layerOp1.getLayers(); list.move(0, layer2); - + // Check events assertTrue("event recorded", traces.contains("layerMoved")); - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "layerMoved", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "layerMoved", traces.traces.get(0).name); } /** @@ -489,50 +490,50 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Add a layer Layer layer2 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer2); - + // add a view to layer1 traces.clear(); View view1 = NotationFactory.eINSTANCE.createShape(); layer1.getViews().add(view1); - + // Check events - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("viewAddedToLayer")); - + // add a view to layer2 traces.clear(); View view2 = NotationFactory.eINSTANCE.createShape(); layer2.getViews().add(view2); - + // Check events - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("viewAddedToLayer")); - + // Use the same view 2 times traces.clear(); layer2.getViews().add(view1); // Check events - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "viewAddedToLayer", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("viewAddedToLayer")); } @@ -544,37 +545,37 @@ public class LayersModelEventNotifierTest { // Create a notifier LayersStack layersStack = LayersFactory.eINSTANCE.createLayersStack(); LayersModelEventNotifier notifier = new LayersModelEventNotifier(layersStack); - + // Add a trace listener TraceLayersModelEventListener listener = new TraceLayersModelEventListener(); notifier.addLayersModelEventListener(listener); - + TriggeredEventTraces traces = listener.traces; // Add a layer LayerOperator layerOp1 = LayersFactory.eINSTANCE.createStackedLayerOperator(); layersStack.setLayers(layerOp1); - + // Add a layer Layer layer1 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer1); - + // Add a layer Layer layer2 = LayersFactory.eINSTANCE.createLayer(); layerOp1.getLayers().add(layer2); - + // add a view to layer1 View view1 = NotationFactory.eINSTANCE.createShape(); layer1.getViews().add(view1); - + // Remove the view traces.clear(); layer1.getViews().remove(view1); - + // Check events - assertEquals("one event recorded", 1, traces.traces.size() ); - assertEquals("one event recorded", "viewRemovedFromLayer", traces.traces.get(0).name ); + assertEquals("one event recorded", 1, traces.traces.size()); + assertEquals("one event recorded", "viewRemovedFromLayer", traces.traces.get(0).name); assertTrue("event recorded", traces.contains("viewRemovedFromLayer")); - + } /** diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifierTest.java index 83a69002141..95e3bb8a3fc 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackAndApplicationLifeCycleEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -55,7 +55,7 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -72,7 +72,7 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testLayersStackAndApplicationLifeCycleEventNotifier() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersStackAndApplicationLifeCycleEventNotifier notifier = new LayersStackAndApplicationLifeCycleEventNotifier(layersModel); assertNotNull("application created", notifier); @@ -86,11 +86,11 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testDispose() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersStackAndApplicationLifeCycleEventNotifier synchronizer = new LayersStackAndApplicationLifeCycleEventNotifier(layersModel); assertFalse("application created", synchronizer.isDisposed()); - + // Try to dispose synchronizer.dispose(); assertTrue("object is disposed", synchronizer.isDisposed()); @@ -101,11 +101,11 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testIsDisposed() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersStackAndApplicationLifeCycleEventNotifier synchronizer = new LayersStackAndApplicationLifeCycleEventNotifier(layersModel); assertFalse("application created", synchronizer.isDisposed()); - + // Try to dispose synchronizer.dispose(); assertTrue("object is disposed", synchronizer.isDisposed()); @@ -152,21 +152,21 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testModelSetCreation() { - - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - - + + } /** @@ -175,25 +175,25 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testLayerStackAdded() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); - + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); + Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the notifier TraceLayersStackApplicationEventListener traces = new TraceLayersStackApplicationEventListener(); LayersStackAndApplicationLifeCycleEventNotifier notifier = new LayersStackAndApplicationLifeCycleEventNotifier(layersModel); notifier.addLayersModelEventListener(traces); - - // Add a layer Stack to the diagram + + // Add a layer Stack to the diagram helper.attachLayersStack(); - + // Check if the appropriate method is called assertTrue("event catched", traces.traces.contains("layerStackAdded")); - + // dispose notifier.dispose(); } @@ -203,28 +203,28 @@ public class LayersStackAndApplicationLifeCycleEventNotifierTest { */ @Test public void testLayerStackRemoved() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); - + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); + Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the notifier TraceLayersStackApplicationEventListener traces = new TraceLayersStackApplicationEventListener(); LayersStackAndApplicationLifeCycleEventNotifier notifier = new LayersStackAndApplicationLifeCycleEventNotifier(layersModel); notifier.addLayersModelEventListener(traces); - - // Add a layer Stack to the diagram + + // Add a layer Stack to the diagram helper.attachLayersStack(); - + traces.traces.clear(); helper.removeLayersStack(); - + // Check if the appropriate method is called assertTrue("event catched", traces.traces.contains("layerStackRemoved")); - + // dispose notifier.dispose(); } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifierTest.java index a78aa430286..625a246c238 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/LayersStackApplicationEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -57,7 +57,7 @@ public class LayersStackApplicationEventNotifierTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -75,20 +75,20 @@ public class LayersStackApplicationEventNotifierTest { @Test public void testModelSetCreation() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - + } /** @@ -96,7 +96,7 @@ public class LayersStackApplicationEventNotifierTest { */ @Test public void testLayersStackApplicationEventNotifier() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersStackApplicationEventNotifier notifier = new LayersStackApplicationEventNotifier(layersModel); assertNotNull("application created", notifier); @@ -110,11 +110,11 @@ public class LayersStackApplicationEventNotifierTest { */ @Test public void testDispose() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersStackApplicationEventNotifier synchronizer = new LayersStackApplicationEventNotifier(layersModel); assertFalse("application created", synchronizer.isDisposed()); - + // Try to dispose synchronizer.dispose(); assertTrue("object is disposed", synchronizer.isDisposed()); @@ -126,25 +126,25 @@ public class LayersStackApplicationEventNotifierTest { */ @Test public void testLayerStackAdded() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the notifier TraceLayersStackApplicationEventListener traces = new TraceLayersStackApplicationEventListener(); LayersStackApplicationEventNotifier notifier = new LayersStackApplicationEventNotifier(layersModel); notifier.addLayersModelEventListener(traces); - - // Add a layer Stack to the diagram + + // Add a layer Stack to the diagram helper.attachLayersStack(); - + // Check if the appropriate method is called assertTrue("event catched", traces.traces.contains("layerStackAdded")); - + // dispose notifier.dispose(); } @@ -154,25 +154,25 @@ public class LayersStackApplicationEventNotifierTest { */ @Test public void testLayerStackRemoved() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helper = new NotationDiagramHelper(layersModel, diagram); - + // Create the notifier TraceLayersStackApplicationEventListener traces = new TraceLayersStackApplicationEventListener(); LayersStackApplicationEventNotifier notifier = new LayersStackApplicationEventNotifier(layersModel); notifier.addLayersModelEventListener(traces); - - // Add a layer Stack to the diagram + + // Add a layer Stack to the diagram helper.attachLayersStack(); - + traces.traces.clear(); helper.removeLayersStack(); - + // Check if the appropriate method is called assertTrue("event catched", traces.traces.contains("layerStackRemoved")); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramMngrTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramMngrTest.java index a26f8e36d0e..be96d8cbec0 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramMngrTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramMngrTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -41,6 +41,7 @@ public class NotationDiagramMngrTest { * ModelSet created for each test */ protected ModelSet modelSet; + /** * @throws java.lang.Exception */ @@ -53,7 +54,7 @@ public class NotationDiagramMngrTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -63,10 +64,10 @@ public class NotationDiagramMngrTest { @After public void tearDown() throws Exception { modelSet.unload(); - + } - + /** * Test method for {@link org.eclipse.papyrus.layers.runtime.NotationDiagramHelper#NotationDiagramMngr(org.eclipse.gmf.runtime.notation.Diagram)}. */ @@ -76,7 +77,7 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Check creation NotationDiagramHelper diagramHelper = new NotationDiagramHelper(layersModel, diagram); @@ -91,7 +92,7 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create mngr @@ -100,8 +101,8 @@ public class NotationDiagramMngrTest { // Do dispose diagramHelper.dispose(); // Check disposal - assertNull( "disposed", diagramHelper.getDiagram()); - + assertNull("disposed", diagramHelper.getDiagram()); + } /** @@ -112,15 +113,15 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create mngr NotationDiagramHelper diagramHelper = new NotationDiagramHelper(layersModel, diagram); // check - assertNotNull("getDiagram", diagramHelper.getDiagram()); - assertSame("getDiagram", diagram, diagramHelper.getDiagram()); + assertNotNull("getDiagram", diagramHelper.getDiagram()); + assertSame("getDiagram", diagram, diagramHelper.getDiagram()); } /** @@ -131,15 +132,15 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create mngr NotationDiagramHelper diagramHelper = new NotationDiagramHelper(layersModel, diagram); - + diagramHelper.attachLayersStack(); - - assertTrue("LayerStack is attached to diagram", diagramHelper.isLayersStackAttached() ); + + assertTrue("LayerStack is attached to diagram", diagramHelper.isLayersStackAttached()); } /** @@ -150,20 +151,20 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create mngr NotationDiagramHelper diagramHelper = new NotationDiagramHelper(layersModel, diagram); - + diagramHelper.attachLayersStack(); - assertTrue("LayerStack is attached to diagram", diagramHelper.isLayersStackAttached() ); + assertTrue("LayerStack is attached to diagram", diagramHelper.isLayersStackAttached()); // Try to remove LayerStack - diagramHelper.removeLayersStack(); - assertFalse("LayerStack is detached from diagram", diagramHelper.isLayersStackAttached() ); - - + diagramHelper.removeLayersStack(); + assertFalse("LayerStack is detached from diagram", diagramHelper.isLayersStackAttached()); + + } /** @@ -174,7 +175,7 @@ public class NotationDiagramMngrTest { // Create a Diagram Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); // Get LayersModel - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create mngr diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifierTest.java index a3a51ee62ff..b1dedace1ab 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/NotationDiagramRemovedFromResourceEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -60,7 +60,7 @@ public class NotationDiagramRemovedFromResourceEventNotifierTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -77,7 +77,7 @@ public class NotationDiagramRemovedFromResourceEventNotifierTest { */ @Test public void testNotationDiagramRemovedFromResourceEventNotifier() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); NotationDiagramRemovedFromResourceEventNotifier notifier = new NotationDiagramRemovedFromResourceEventNotifier(notationModel); assertNotNull("application created", notifier); @@ -92,20 +92,20 @@ public class NotationDiagramRemovedFromResourceEventNotifierTest { @Test public void testModelSetCreation() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - + } /** @@ -113,11 +113,11 @@ public class NotationDiagramRemovedFromResourceEventNotifierTest { */ @Test public void testDispose() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); NotationDiagramRemovedFromResourceEventNotifier notifier = new NotationDiagramRemovedFromResourceEventNotifier(notationModel); assertFalse("application created", notifier.isDisposed()); - + // Try to dispose notifier.dispose(); assertTrue("object is disposed", notifier.isDisposed()); @@ -146,35 +146,35 @@ public class NotationDiagramRemovedFromResourceEventNotifierTest { */ @Test public void testFireDiagramRemovedEvent() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); // Create a diagram Diagram diagram1 = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram1); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helperForDiag1 = new NotationDiagramHelper(layersModel, diagram1); - + // Create a diagram Diagram diagram2 = NotationFactory.eINSTANCE.createDiagram(); notationModel.addDiagram(diagram2); // Create a helper used to attach a LayerStack to diagram. NotationDiagramHelper helperForDiag2 = new NotationDiagramHelper(layersModel, diagram2); - + // Create the synchronizer NotationDiagramRemovedFromResourceEventNotifier notifier = new NotationDiagramRemovedFromResourceEventNotifier(notationModel); TraceNotationDiagramRemovedFromResourceEventListener traces = new TraceNotationDiagramRemovedFromResourceEventListener(); notifier.addLayersModelEventListener(traces); - - // Add a layer Stack to the diagram + + // Add a layer Stack to the diagram helperForDiag1.attachLayersStack(); helperForDiag2.attachLayersStack(); - + // Try to remove a diagram traces.traces.clear(); notationModel.getResource().getContents().remove(diagram2); - - + + // Check if the appropriate method is called assertTrue("event catched", traces.traces.contains("diagramRemoved")); assertEquals("number of events", 1, traces.traces.size()); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceDiagramViewEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceDiagramViewEventListener.java index ba03465eb7c..50efb216caa 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceDiagramViewEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceDiagramViewEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -18,25 +18,25 @@ import org.eclipse.papyrus.layers.stackmodel.notifier.IDiagramViewEventListener; /** * A listener on {@link LayersStackApplicationEventNotifier}. This listener trace events from * the notifier. - * + * * @author cedric dumoulin * */ public class TraceDiagramViewEventListener implements IDiagramViewEventListener { public TriggeredEventTraces traces = new TriggeredEventTraces(); - + @Override public void diagramViewAdded(Notification msg) { traces.addTrace("diagramViewAdded", msg); - + } @Override public void diagramViewRemoved(Notification msg) { traces.addTrace("diagramViewRemoved", msg); - + } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersModelEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersModelEventListener.java index f5d6a2b61c2..dbcd6508c4d 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersModelEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersModelEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,14 +17,14 @@ import org.eclipse.papyrus.layers.runtime.utils.TriggeredEventTraces; /** * A listener on {@link LayersModelEventNotifier}. This listener trace events from * the notifier. - * + * * @author cedric dumoulin * */ public class TraceLayersModelEventListener implements ILayersModelEventListener { public TriggeredEventTraces traces = new TriggeredEventTraces(); - + /** * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#propertyValueAdded(org.eclipse.emf.common.notify.Notification) * @@ -56,7 +56,7 @@ public class TraceLayersModelEventListener implements ILayersModelEventListener traces.addTrace("propertyValueChanged", notification); } - + /** * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#layerAdded(org.eclipse.emf.common.notify.Notification) * @@ -65,9 +65,9 @@ public class TraceLayersModelEventListener implements ILayersModelEventListener @Override public void layerSet(Notification notification) { traces.addTrace("layerSet", notification); - + } - + /** * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#layerAdded(org.eclipse.emf.common.notify.Notification) * @@ -129,7 +129,7 @@ public class TraceLayersModelEventListener implements ILayersModelEventListener } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#multiViewsRemovedFromLayer(org.eclipse.emf.common.notify.Notification) * * @param notification @@ -140,7 +140,7 @@ public class TraceLayersModelEventListener implements ILayersModelEventListener } /** - * + * * @see org.eclipse.papyrus.layers.runtime.ILayersModelEventListener#multiViewsAddedToLayer(org.eclipse.emf.common.notify.Notification) * * @param notification diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersStackApplicationEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersStackApplicationEventListener.java index 352528f20ca..0ac0a184287 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersStackApplicationEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceLayersStackApplicationEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,14 +17,14 @@ import org.eclipse.papyrus.layers.runtime.utils.TriggeredEventTraces; /** * A listener on {@link LayersStackApplicationEventNotifier}. This listener trace events from * the notifier. - * + * * @author cedric dumoulin * */ public class TraceLayersStackApplicationEventListener implements ILayersStackApplicationEventListener { public TriggeredEventTraces traces = new TriggeredEventTraces(); - + /** * @see org.eclipse.papyrus.layers.runtime.ILayersStackApplicationEventListener#layerStackAdded(org.eclipse.emf.common.notify.Notification) * diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceNotationDiagramRemovedFromResourceEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceNotationDiagramRemovedFromResourceEventListener.java index af6d42d90c5..16bcea19cf1 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceNotationDiagramRemovedFromResourceEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/TraceNotationDiagramRemovedFromResourceEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,19 +17,19 @@ import org.eclipse.papyrus.layers.runtime.utils.TriggeredEventTraces; /** * A listener on {@link NotationDiagramRemovedFromResourceEventNotifier}. This listener trace events from * the notifier. - * + * * @author cedric dumoulin * */ public class TraceNotationDiagramRemovedFromResourceEventListener implements INotationDiagramRemovedEventListener { public TriggeredEventTraces traces = new TriggeredEventTraces(); - + @Override public void diagramRemoved(Notification msg) { traces.addTrace("diagramRemoved", msg); - + } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelRootEventNotifierTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelRootEventNotifierTest.java index 3ce4280ff9f..54bd2753ba7 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelRootEventNotifierTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelRootEventNotifierTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -59,7 +59,7 @@ public class LayersModelRootEventNotifierTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + modelSet = mngr; } @@ -77,30 +77,31 @@ public class LayersModelRootEventNotifierTest { @Test public void testModelSetCreation() { - NotationModel notationModel = (NotationModel)modelSet.getModel(NotationModel.MODEL_ID); + NotationModel notationModel = (NotationModel) modelSet.getModel(NotationModel.MODEL_ID); assertNotNull("NotationModel is created", notationModel); // Try to create a Diagram notationModel.addDiagram(NotationFactory.eINSTANCE.createDiagram()); - // + // assertNotNull("Diagram is in the roots", notationModel.getResource().getContents().get(0)); - - - - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + + + + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); assertNotNull("LayerModel is created", layersModel); assertNotNull("LayerStackApplication is created", layersModel.getLayerStackApplication()); - + } + /** * Test method for {@link org.eclipse.papyrus.layers.runtime.LayersModelEventRootNotifier#LayersModelEventRootNotifier(org.eclipse.gmf.runtime.notation.Diagram)}. */ @Test public void testLayersModelEventRootNotifier() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersModelEventRootNotifier notifier = new LayersModelEventRootNotifier(layersModel); - - + + assertNotNull("notifier created", notifier); // dispose @@ -112,7 +113,7 @@ public class LayersModelRootEventNotifierTest { */ @Test public void testDispose() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersModelEventRootNotifier notifier = new LayersModelEventRootNotifier(layersModel); assertNotNull("notifier created", notifier); @@ -146,21 +147,21 @@ public class LayersModelRootEventNotifierTest { */ @Test public void testFireLayersModelRootAddedEvent() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersModelEventRootNotifier notifier = new LayersModelEventRootNotifier(layersModel); - + TraceLayersModelRootEventListener listener = new TraceLayersModelRootEventListener(); notifier.addEventListener(listener); - + // Add root @SuppressWarnings("unused") LayersStackApplication application = layersModel.getLayerStackApplication(); - + // Check for event assertTrue("event sent", listener.traces.size() > 0); assertEquals("event found", "layersModelRootAdded", listener.traces.get(0).name); - - + + } /** @@ -168,15 +169,15 @@ public class LayersModelRootEventNotifierTest { */ @Test public void testFireLayersModelRootRemovedEvent() { - LayersModel layersModel = (LayersModel)modelSet.getModel(LayersModel.MODEL_ID); + LayersModel layersModel = (LayersModel) modelSet.getModel(LayersModel.MODEL_ID); LayersModelEventRootNotifier notifier = new LayersModelEventRootNotifier(layersModel); - + TraceLayersModelRootEventListener listener = new TraceLayersModelRootEventListener(); notifier.addEventListener(listener); - + // Add root LayersStackApplication application = layersModel.getLayerStackApplication(); - + // Check remove listener.traces.clear(); layersModel.removeRoot(application); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelTest.java index 6661752f8ca..52a0d8c15e4 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/LayersModelTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -52,8 +52,9 @@ public class LayersModelTest { /** * Test method for {@link org.eclipse.papyrus.layers.runtime.model.LayersModel#LayersModel()}. - * @throws CoreException - * @throws IOException + * + * @throws CoreException + * @throws IOException */ @Test public void testLayersModel() throws CoreException, IOException { @@ -64,7 +65,7 @@ public class LayersModelTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + // Check if root exist assertNotNull("layer model root created", layersModel.getLayerStackApplication()); } @@ -81,10 +82,10 @@ public class LayersModelTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + // Check if application lookup assertNull("lookup application return null", layersModel.lookupLayerStackApplication()); - + // Get the application, this create it assertNotNull("layer model root created", layersModel.getLayerStackApplication()); // lookup again, this found the application @@ -103,10 +104,10 @@ public class LayersModelTest { // Do create resources URI uri = URI.createPlatformResourceURI(PROJECT_MODEL_URI, true); mngr.createModels(uri); - + // Check if root exist assertNotNull("layer model root created", layersModel.getLayerStackApplication()); - assertTrue("LayerStackApplication is found", layersModel.getLayerStackApplication() instanceof LayersStackApplication); + assertTrue("LayerStackApplication is found", layersModel.getLayerStackApplication() instanceof LayersStackApplication); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/TraceLayersModelRootEventListener.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/TraceLayersModelRootEventListener.java index b23f60f209e..78dd1f56610 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/TraceLayersModelRootEventListener.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/model/TraceLayersModelRootEventListener.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,14 +17,14 @@ import org.eclipse.papyrus.layers.runtime.utils.TriggeredEventTraces; /** * A listener on {@link NotationDiagramRemovedFromResourceEventNotifier}. This listener trace events from * the notifier. - * + * * @author cedric dumoulin * */ public class TraceLayersModelRootEventListener implements ILayersModelRootEventListener { public TriggeredEventTraces traces = new TriggeredEventTraces(); - + @Override public void layersModelRootAdded(Notification msg) { diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/ECoreUtilsTest.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/ECoreUtilsTest.java index a3014cad9e5..664279789ae 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/ECoreUtilsTest.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/ECoreUtilsTest.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -59,7 +59,7 @@ public class ECoreUtilsTest { TypeInstance instance2 = LayersFactory.eINSTANCE.createBooleanInstance(); layer.getPropertyValueMap().put("prop1", instance2); - + // Check ancestor assertTrue("ancestor found", ECoreUtils.isAncestorInstanceOf(instance2, LayersPackage.eINSTANCE.getTypeInstance())); assertTrue("ancestor found", ECoreUtils.isAncestorInstanceOf(instance2, LayersPackage.eINSTANCE.getLayer())); @@ -71,7 +71,8 @@ public class ECoreUtilsTest { /** * Test method for {@link org.eclipse.papyrus.layers.stackmodel.layers.util.ECoreUtils#lookupAncestorOfType(org.eclipse.emf.ecore.EObject, org.eclipse.emf.ecore.EClass)}. - * @throws LayersException + * + * @throws LayersException */ @Test public void testLookupAncestorOfType() throws LayersException { @@ -82,14 +83,14 @@ public class ECoreUtilsTest { TypeInstance instance2 = LayersFactory.eINSTANCE.createBooleanInstance(); layer.getPropertyValueMap().put("prop1", instance2); - + // Check ancestor assertEquals("ancestor found", instance2, ECoreUtils.lookupAncestorOfType(instance2, LayersPackage.eINSTANCE.getTypeInstance())); assertEquals("ancestor found", layer, ECoreUtils.lookupAncestorOfType(instance2, LayersPackage.eINSTANCE.getLayer())); assertEquals("ancestor found", layerOperator, ECoreUtils.lookupAncestorOfType(instance2, LayersPackage.eINSTANCE.getTopLayerOperator())); assertEquals("ancestor found", layerOperator, ECoreUtils.lookupAncestorOfType(instance2, LayersPackage.eINSTANCE.getLayerOperator())); - try { + try { ECoreUtils.lookupAncestorOfType(instance2, LayersPackage.eINSTANCE.getLayersStack()); fail("Exception is thrown"); } catch (LayersException e) { diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/NotationDiagramTestUtils.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/NotationDiagramTestUtils.java index 39b9469d024..683ddc262b5 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/NotationDiagramTestUtils.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/NotationDiagramTestUtils.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -16,7 +16,7 @@ import org.eclipse.gmf.runtime.notation.NotationFactory; /** * Set of utilities on Notation for testing purposes - * + * * @author cedric dumoulin * */ @@ -30,7 +30,7 @@ public class NotationDiagramTestUtils { } public Diagram newDiagram() { - + Diagram diagram = NotationFactory.eINSTANCE.createDiagram(); return diagram; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/TriggeredEventTraces.java b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/TriggeredEventTraces.java index 3309d5702e1..b94add9139d 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/TriggeredEventTraces.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.runtime/tests/org/eclipse/papyrus/layers/runtime/utils/TriggeredEventTraces.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -20,11 +20,11 @@ import org.eclipse.emf.common.notify.Notification; * This class is used to record a list of traces. * Traces are for event triggered by a method. * This class is for tests purpose. - * + * * @author cedric dumoulin * */ -public class TriggeredEventTraces { +public class TriggeredEventTraces { /** @@ -38,9 +38,10 @@ public class TriggeredEventTraces { public void clear() { traces.clear(); } - + /** * Add a trace to the list of traces + * * @param name * @param notification */ @@ -50,32 +51,39 @@ public class TriggeredEventTraces { /** * Return true if one of the trace has the specified name. + * * @param name * @return */ public boolean contains(String name) { - if( name == null) + if (name == null) { return false; - - for(TriggeredEvent event : traces) { - if(name.equals(event.name)) + } + + for (TriggeredEvent event : traces) { + if (name.equals(event.name)) { return true; + } } return false; } /** * Return true if one of the trace has the specified name. - * @param name Name of the event to found + * + * @param name + * Name of the event to found * @return the first event with the specified name, or null if nothing is found. */ public TriggeredEvent getFirstEvent(String name) { - if( name == null) + if (name == null) { return null; - - for(TriggeredEvent event : traces) { - if(name.equals(event.name)) + } + + for (TriggeredEvent event : traces) { + if (name.equals(event.name)) { return event; + } } return null; } @@ -89,6 +97,7 @@ public class TriggeredEventTraces { public String name; public Notification notifier; public Object object; + /** * Constructor. * @@ -99,6 +108,7 @@ public class TriggeredEventTraces { this.name = name; this.notifier = notifier; } + /** * Constructor. * @@ -109,12 +119,13 @@ public class TriggeredEventTraces { this.name = name; this.object = object; } - + } /** * Return the number of traces + * * @return */ public int size() { @@ -123,6 +134,7 @@ public class TriggeredEventTraces { /** * Get the specified trace. + * * @param i * @return */ diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/Activator.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/Activator.java index ac18f998112..a1dc0a53743 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/Activator.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/Activator.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -24,7 +24,7 @@ public class Activator extends AbstractUIPlugin { // The shared instance private static Activator plugin; - + public static LogHelper log; /** @@ -35,8 +35,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) + * * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -45,8 +47,10 @@ public class Activator extends AbstractUIPlugin { /* * (non-Javadoc) + * * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/CreateLayersTreeDiagramHandler.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/CreateLayersTreeDiagramHandler.java index ab88a4ae7da..cb1fa40fdb0 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/CreateLayersTreeDiagramHandler.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/CreateLayersTreeDiagramHandler.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/DynamicContextMenu.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/DynamicContextMenu.java index 6956df0c05d..04778c17ba6 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/DynamicContextMenu.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/DynamicContextMenu.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -52,22 +52,23 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; /** - * + * * This class manage the dynamic menu for Layer diagram. - * It is a modification of the original {@link LayersActionBarContributor}. - * <br> + * It is a modification of the original {@link LayersActionBarContributor}. <br> * Code is copied from the generated {@link LayersActionBarContributor}. * Changes are made in order to work with Papyrus. - * + * * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ -public class DynamicContextMenu implements ISelectionChangedListener { +public class DynamicContextMenu implements ISelectionChangedListener { /** * This keeps track of the active editor. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IEditorPart activeEditorPart; @@ -76,64 +77,68 @@ public class DynamicContextMenu implements ISelectionChangedListener { * This keeps track of the current selection provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected ISelectionProvider selectionProvider; - /** - * The workbench page; <code>null</code> until <code>init</code> is called. - */ - private IWorkbenchPage page; + /** + * The workbench page; <code>null</code> until <code>init</code> is called. + */ + private IWorkbenchPage page; /** * This action opens the Properties view. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IAction showPropertiesViewAction = - new Action(LayersEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - LayersEditorPlugin.INSTANCE.log(exception); + new Action(LayersEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { + @Override + public void run() { + try { + getPage().showView("org.eclipse.ui.views.PropertySheet"); + } + catch (PartInitException exception) { + LayersEditorPlugin.INSTANCE.log(exception); + } } - } - }; + }; /** * This action refreshes the viewer of the current editor if the editor * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IAction refreshViewerAction = - new Action(LayersEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } + new Action(LayersEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { + @Override + public boolean isEnabled() { + return activeEditorPart instanceof IViewerProvider; + } - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); + @Override + public void run() { + if (activeEditorPart instanceof IViewerProvider) { + Viewer viewer = ((IViewerProvider) activeEditorPart).getViewer(); + if (viewer != null) { + viewer.refresh(); + } } } - } - }; + }; /** * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor * generated for the current selection by the item provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> createChildActions; @@ -142,6 +147,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * This is the menu manager into which menu contribution items should be added for CreateChild actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IMenuManager createChildMenuManager; @@ -151,6 +157,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * generated for the current selection by the item provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> createSiblingActions; @@ -159,70 +166,72 @@ public class DynamicContextMenu implements ISelectionChangedListener { * This is the menu manager into which menu contribution items should be added for CreateSibling actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IMenuManager createSiblingMenuManager; - /** - * This is the action used to implement delete. - */ - protected DeleteAction deleteAction; - - /** - * This is the action used to implement cut. - */ - protected CutAction cutAction; - - /** - * This is the action used to implement copy. - */ - protected CopyAction copyAction; - - /** - * This is the action used to implement paste. - */ - protected PasteAction pasteAction; - - /** - * This is the action used to implement undo. - */ - protected UndoAction undoAction; - - /** - * This is the action used to implement redo. - */ - protected RedoAction redoAction; - - /** - * This is the action used to load a resource. - */ - protected LoadResourceAction loadResourceAction; - - /** - * This is the action used to control or uncontrol a contained object. - */ - protected ControlAction controlAction; - - /** - * This is the action used to perform validation. - */ - protected ValidateAction validateAction; + /** + * This is the action used to implement delete. + */ + protected DeleteAction deleteAction; + + /** + * This is the action used to implement cut. + */ + protected CutAction cutAction; + + /** + * This is the action used to implement copy. + */ + protected CopyAction copyAction; + + /** + * This is the action used to implement paste. + */ + protected PasteAction pasteAction; + + /** + * This is the action used to implement undo. + */ + protected UndoAction undoAction; + + /** + * This is the action used to implement redo. + */ + protected RedoAction redoAction; + + /** + * This is the action used to load a resource. + */ + protected LoadResourceAction loadResourceAction; + + /** + * This is the action used to control or uncontrol a contained object. + */ + protected ControlAction controlAction; + + /** + * This is the action used to perform validation. + */ + protected ValidateAction validateAction; /** * This creates an instance of the contributor. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public DynamicContextMenu(IEditorPart part) { loadResourceAction = new LoadResourceAction(); validateAction = new ValidateAction(); controlAction = new ControlAction(); - + // Added init this.page = part.getEditorSite().getPage(); setActiveEditor(part); - + MenuManager menuManager = new MenuManager(); menuManager.add(new Separator("additions")); menuManager.add(new Separator("edit")); @@ -234,12 +243,13 @@ public class DynamicContextMenu implements ISelectionChangedListener { * as well as the sub-menus for object creation items. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public void contributeToMenu(IMenuManager menuManager) { IMenuManager submenuManager = new MenuManager(LayersEditorPlugin.INSTANCE.getString("_UI_LayersEditor_menu"), "org.eclipse.papyrus.layers.stackmodel.layersMenuID"); -// menuManager.insertAfter("additions", submenuManager); + // menuManager.insertAfter("additions", submenuManager); menuManager.add(submenuManager); submenuManager.add(new Separator("settings")); submenuManager.add(new Separator("actions")); @@ -259,11 +269,12 @@ public class DynamicContextMenu implements ISelectionChangedListener { // Force an update because Eclipse hides empty menus now. // submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); + (new IMenuListener() { + @Override + public void menuAboutToShow(IMenuManager menuManager) { + menuManager.updateAll(true); + } + }); addGlobalActions(submenuManager); } @@ -272,6 +283,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * When the active editor changes, this remembers the change and registers with it as a selection provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public void setActiveEditor(IEditorPart part) { @@ -303,8 +315,10 @@ public class DynamicContextMenu implements ISelectionChangedListener { * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ + @Override public void selectionChanged(SelectionChangedEvent event) { // Remove any menu items for old selection. // @@ -321,10 +335,10 @@ public class DynamicContextMenu implements ISelectionChangedListener { Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); + if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) { + Object object = ((IStructuredSelection) selection).getFirstElement(); - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); + EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain(); newChildDescriptors = domain.getNewChildDescriptors(object, null); newSiblingDescriptors = domain.getNewChildDescriptors(null, object); @@ -350,6 +364,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { @@ -367,6 +382,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { @@ -386,6 +402,7 @@ public class DynamicContextMenu implements ISelectionChangedListener { * If <code>contributionID</code> is <code>null</code>, they are simply added. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { @@ -400,12 +417,13 @@ public class DynamicContextMenu implements ISelectionChangedListener { } } } - + /** * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { @@ -416,13 +434,13 @@ public class DynamicContextMenu implements ISelectionChangedListener { // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); + contributionItem = ((SubContributionItem) contributionItem).getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); + IAction action = ((ActionContributionItem) contributionItem).getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } @@ -435,21 +453,22 @@ public class DynamicContextMenu implements ISelectionChangedListener { * This populates the pop-up menu before it appears. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public void menuAboutToShow(IMenuManager menuManager) { - -// System.err.println("menuAboutToShow("+ menuManager.getId()+ ")"); + + // System.err.println("menuAboutToShow("+ menuManager.getId()+ ")"); MenuManager submenuManager = null; submenuManager = new MenuManager(LayersEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); populateManager(submenuManager, createChildActions, null); -// menuManager.insertBefore("edit", submenuManager); + // menuManager.insertBefore("edit", submenuManager); menuManager.add(submenuManager); submenuManager = new MenuManager(LayersEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); populateManager(submenuManager, createSiblingActions, null); -// menuManager.insertBefore("edit", submenuManager); + // menuManager.insertBefore("edit", submenuManager); menuManager.add(submenuManager); } @@ -457,25 +476,26 @@ public class DynamicContextMenu implements ISelectionChangedListener { * This inserts global actions before the "additions-end" separator. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addGlobalActions(IMenuManager menuManager) { menuManager.insertAfter("additions-end", new Separator("ui-actions")); menuManager.insertAfter("ui-actions", showPropertiesViewAction); - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); + refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); menuManager.insertAfter("ui-actions", refreshViewerAction); } - /** - * Returns this contributor's workbench page. - * - * @return the workbench page - */ - public IWorkbenchPage getPage() { - return page; - } + /** + * Returns this contributor's workbench page. + * + * @return the workbench page + */ + public IWorkbenchPage getPage() { + return page; + } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersDiagramActionBarContributor.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersDiagramActionBarContributor.java index fb46d80ad52..c38f19035de 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersDiagramActionBarContributor.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersDiagramActionBarContributor.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -47,23 +47,24 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.PartInitException; /** - * - * This is the action bar contributor for the Layers model diagram editor. - * <br> + * + * This is the action bar contributor for the Layers model diagram editor. <br> * Code is copied from the generated {@link LayersActionBarContributor}. * Changes are made in order to work with Papyrus. - * + * * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class LayersDiagramActionBarContributor - extends EditingDomainActionBarContributor - implements ISelectionChangedListener { + extends EditingDomainActionBarContributor + implements ISelectionChangedListener { /** * This keeps track of the active editor. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IEditorPart activeEditorPart; @@ -72,6 +73,7 @@ public class LayersDiagramActionBarContributor * This keeps track of the current selection provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected ISelectionProvider selectionProvider; @@ -80,51 +82,54 @@ public class LayersDiagramActionBarContributor * This action opens the Properties view. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IAction showPropertiesViewAction = - new Action(LayersEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { - @Override - public void run() { - try { - getPage().showView("org.eclipse.ui.views.PropertySheet"); - } - catch (PartInitException exception) { - LayersEditorPlugin.INSTANCE.log(exception); + new Action(LayersEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { + @Override + public void run() { + try { + getPage().showView("org.eclipse.ui.views.PropertySheet"); + } + catch (PartInitException exception) { + LayersEditorPlugin.INSTANCE.log(exception); + } } - } - }; + }; /** * This action refreshes the viewer of the current editor if the editor * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IAction refreshViewerAction = - new Action(LayersEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { - @Override - public boolean isEnabled() { - return activeEditorPart instanceof IViewerProvider; - } + new Action(LayersEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { + @Override + public boolean isEnabled() { + return activeEditorPart instanceof IViewerProvider; + } - @Override - public void run() { - if (activeEditorPart instanceof IViewerProvider) { - Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); - if (viewer != null) { - viewer.refresh(); + @Override + public void run() { + if (activeEditorPart instanceof IViewerProvider) { + Viewer viewer = ((IViewerProvider) activeEditorPart).getViewer(); + if (viewer != null) { + viewer.refresh(); + } } } - } - }; + }; /** * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor * generated for the current selection by the item provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> createChildActions; @@ -133,6 +138,7 @@ public class LayersDiagramActionBarContributor * This is the menu manager into which menu contribution items should be added for CreateChild actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IMenuManager createChildMenuManager; @@ -142,6 +148,7 @@ public class LayersDiagramActionBarContributor * generated for the current selection by the item provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> createSiblingActions; @@ -150,6 +157,7 @@ public class LayersDiagramActionBarContributor * This is the menu manager into which menu contribution items should be added for CreateSibling actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected IMenuManager createSiblingMenuManager; @@ -158,6 +166,7 @@ public class LayersDiagramActionBarContributor * This creates an instance of the contributor. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public LayersDiagramActionBarContributor() { @@ -171,6 +180,7 @@ public class LayersDiagramActionBarContributor * This adds Separators for editor additions to the tool bar. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -184,6 +194,7 @@ public class LayersDiagramActionBarContributor * as well as the sub-menus for object creation items. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -210,11 +221,12 @@ public class LayersDiagramActionBarContributor // Force an update because Eclipse hides empty menus now. // submenuManager.addMenuListener - (new IMenuListener() { - public void menuAboutToShow(IMenuManager menuManager) { - menuManager.updateAll(true); - } - }); + (new IMenuListener() { + @Override + public void menuAboutToShow(IMenuManager menuManager) { + menuManager.updateAll(true); + } + }); addGlobalActions(submenuManager); } @@ -223,6 +235,7 @@ public class LayersDiagramActionBarContributor * When the active editor changes, this remembers the change and registers with it as a selection provider. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -256,8 +269,10 @@ public class LayersDiagramActionBarContributor * that can be added to the selected object and updating the menus accordingly. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ + @Override public void selectionChanged(SelectionChangedEvent event) { // Remove any menu items for old selection. // @@ -274,10 +289,10 @@ public class LayersDiagramActionBarContributor Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { - Object object = ((IStructuredSelection)selection).getFirstElement(); + if (selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1) { + Object object = ((IStructuredSelection) selection).getFirstElement(); - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); + EditingDomain domain = ((IEditingDomainProvider) activeEditorPart).getEditingDomain(); newChildDescriptors = domain.getNewChildDescriptors(object, null); newSiblingDescriptors = domain.getNewChildDescriptors(null, object); @@ -303,6 +318,7 @@ public class LayersDiagramActionBarContributor * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> generateCreateChildActions(Collection<?> descriptors, ISelection selection) { @@ -320,6 +336,7 @@ public class LayersDiagramActionBarContributor * and returns the collection of these actions. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected Collection<IAction> generateCreateSiblingActions(Collection<?> descriptors, ISelection selection) { @@ -339,6 +356,7 @@ public class LayersDiagramActionBarContributor * If <code>contributionID</code> is <code>null</code>, they are simply added. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void populateManager(IContributionManager manager, Collection<? extends IAction> actions, String contributionID) { @@ -353,12 +371,13 @@ public class LayersDiagramActionBarContributor } } } - + /** * This removes from the specified <code>manager</code> all {@link org.eclipse.jface.action.ActionContributionItem}s * based on the {@link org.eclipse.jface.action.IAction}s contained in the <code>actions</code> collection. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void depopulateManager(IContributionManager manager, Collection<? extends IAction> actions) { @@ -369,13 +388,13 @@ public class LayersDiagramActionBarContributor // IContributionItem contributionItem = items[i]; while (contributionItem instanceof SubContributionItem) { - contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); + contributionItem = ((SubContributionItem) contributionItem).getInnerItem(); } // Delete the ActionContributionItems with matching action. // if (contributionItem instanceof ActionContributionItem) { - IAction action = ((ActionContributionItem)contributionItem).getAction(); + IAction action = ((ActionContributionItem) contributionItem).getAction(); if (actions.contains(action)) { manager.remove(contributionItem); } @@ -388,6 +407,7 @@ public class LayersDiagramActionBarContributor * This populates the pop-up menu before it appears. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -408,6 +428,7 @@ public class LayersDiagramActionBarContributor * This inserts global actions before the "additions-end" separator. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -415,7 +436,7 @@ public class LayersDiagramActionBarContributor menuManager.insertAfter("additions-end", new Separator("ui-actions")); menuManager.insertAfter("ui-actions", showPropertiesViewAction); - refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); + refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); menuManager.insertAfter("ui-actions", refreshViewerAction); super.addGlobalActions(menuManager); @@ -425,6 +446,7 @@ public class LayersDiagramActionBarContributor * This ensures that a delete action will clean up all references to deleted objects. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeDiagramEditorFactory.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeDiagramEditorFactory.java index 394758f2cb9..9e0c7d801f1 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeDiagramEditorFactory.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeDiagramEditorFactory.java @@ -4,11 +4,11 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr * Christian W. Damus (CEA) - bug 392301 - * + * ******************************************************************************/ package org.eclipse.papyrus.layers.stackmodel.diagram; @@ -53,11 +53,15 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { /** * Initialize the factory with useful Classes. - * @see IPluggableEditorFactory#init(ServicesRegistry, EditorDescriptor) * - * @param serviceRegistry Service registry that will be provided to created editor. - * @param editorDescriptor Descriptor containing data from the Eclipse Extension. + * @see IPluggableEditorFactory#init(ServicesRegistry, EditorDescriptor) + * + * @param serviceRegistry + * Service registry that will be provided to created editor. + * @param editorDescriptor + * Descriptor containing data from the Eclipse Extension. */ + @Override public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { this.editorDescriptor = editorDescriptor; this.serviceRegistry = serviceRegistry; @@ -66,28 +70,30 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { /** * TODO Implements next methods - * + * * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory#createIPageModel(java.lang.Object) * @param pageIdentifier * @return - * + * */ + @Override public IPageModel createIPageModel(Object pageIdentifier) { - return new EmfTreeEditorModel((Diagram)pageIdentifier, serviceRegistry); + return new EmfTreeEditorModel((Diagram) pageIdentifier, serviceRegistry); } /** - * + * * @see org.eclipse.papyrus.infra.core.extension.diagrameditor.IPluggableEditorFactory#isPageModelFactoryFor(java.lang.Object) * @param pageIdentifier * @return - * + * */ + @Override public boolean isPageModelFactoryFor(Object pageIdentifier) { - if(pageIdentifier instanceof Diagram) { - Diagram diagram = (Diagram)pageIdentifier; + if (pageIdentifier instanceof Diagram) { + Diagram diagram = (Diagram) pageIdentifier; - if(EMF_DIAGRAM_TYPE.equals(diagram.getType())) { + if (EMF_DIAGRAM_TYPE.equals(diagram.getType())) { return true; } } @@ -97,7 +103,7 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { /** * Model used to describe an instance of this editor in the SashSystem. - * + * */ public class EmfTreeEditorModel implements IEditorModel { @@ -107,13 +113,13 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { private Diagram pageIdentifier; private ServicesRegistry servicesRegistry; - + private Image tabIcon; /** - * + * * Constructor. - * + * * @param pageIdentifier * @param servicesRegistry */ @@ -124,12 +130,13 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { /** * Create the instance of the editor. - * + * * @see org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel#createIEditorPart() * @return * @throws PartInitException - * + * */ + @Override public IEditorPart createIEditorPart() throws PartInitException { try { return new LayersTreeEditorDiagram(servicesRegistry); @@ -140,12 +147,13 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { } } + @Override public EditorActionBarContributor getActionBarContributor() { String actionBarId = editorDescriptor.getActionBarContributorId(); // Do nothing if no EditorActionBarContributor is specify. - if(actionBarId == null || actionBarId.length() == 0) { + if (actionBarId == null || actionBarId.length() == 0) { return null; } @@ -155,7 +163,7 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { ActionBarContributorRegistry registry; try { registry = servicesRegistry - .getService(ActionBarContributorRegistry.class); + .getService(ActionBarContributorRegistry.class); } catch (ServiceException e) { // Service not found // TODO Log the error @@ -173,45 +181,48 @@ public class LayersTreeDiagramEditorFactory implements IPluggableEditorFactory { } /** - * + * * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getRawModel() * @return - * + * */ + @Override public Object getRawModel() { return pageIdentifier; } /** - * + * * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabIcon() * @return - * + * */ + @Override public Image getTabIcon() { - if(tabIcon == null) { + if (tabIcon == null) { ImageDescriptor imageDescriptor = editorDescriptor.getIcon(); - if(imageDescriptor != null) { + if (imageDescriptor != null) { tabIcon = imageDescriptor.createImage(); } } - + return tabIcon; } /** - * + * * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabTitle() * @return - * + * */ + @Override public String getTabTitle() { return "Layers Tree Editor"; } - + @Override public void dispose() { - if(tabIcon != null) { + if (tabIcon != null) { tabIcon.dispose(); tabIcon = null; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeEditorDiagram.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeEditorDiagram.java index 637bfbe775f..7b18b270122 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeEditorDiagram.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/LayersTreeEditorDiagram.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -41,7 +41,7 @@ import org.eclipse.ui.views.properties.PropertySheetPage; /** * This is an example of a EMF UML model editor. <!-- begin-user-doc --> <!-- end-user-doc --> - * + * * @generated */ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider, IGotoMarker { @@ -54,9 +54,9 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom protected CommandStackListener commandStackListener; /** - * + * * Constructor. Create an DiEditor using the {@link ServicesRegistry}. - * + * * @param servicesRegistry */ public LayersTreeEditorDiagram(ServicesRegistry servicesRegistry) throws ServiceException, BackboneException { @@ -67,7 +67,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * Init the editor from the specified context. * Set the editing domain used by the EMF editor. - * + * * @param editorContext * @throws ServiceException */ @@ -84,33 +84,36 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * called when command stack has changed + * * @see org.eclipse.emf.common.command.CommandStackListener#commandStackChanged(java.util.EventObject) * * @param event */ + @Override public void commandStackChanged(final EventObject event) { - if(getContainer().isDisposed()) { + if (getContainer().isDisposed()) { return; } getContainer().getDisplay().asyncExec(new Runnable() { + @Override public void run() { firePropertyChange(IEditorPart.PROP_DIRTY); // Try to select the affected objects. // - Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); - if(mostRecentCommand != null) { + Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand(); + if (mostRecentCommand != null) { setSelectionToViewer(mostRecentCommand.getAffectedObjects()); } - + for (Iterator<PropertySheetPage> i = propertySheetPages.iterator(); i.hasNext();) { PropertySheetPage propertySheetPage = i.next(); if ((propertySheetPage.getControl() == null) - || propertySheetPage.getControl().isDisposed()) { - + || propertySheetPage.getControl().isDisposed()) { + i.remove(); } else { propertySheetPage.refresh(); @@ -141,7 +144,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom * This is the method called to load a resource into the editing domain's resource set based on * the editor's input. Put the existing model into the editingDomain. <!-- begin-user-doc --> * <!-- end-user-doc --> - * + * * @generated */ @Override @@ -152,7 +155,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * This is for implementing {@link IEditorPart} and simply saves the model file. <!-- * begin-user-doc --> <!-- end-user-doc --> - * + * * @generated */ @Override @@ -161,7 +164,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * This also changes the editor's input. <!-- begin-user-doc --> <!-- end-user-doc --> - * + * * @generated */ @Override @@ -170,7 +173,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * <!-- begin-user-doc --> <!-- end-user-doc --> - * + * * @generated */ @Override @@ -185,7 +188,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom /** * <!-- begin-user-doc --> <!-- end-user-doc --> - * + * * @generated */ @Override @@ -200,7 +203,7 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom @Override public void dispose() { - //super.dispose(); //FIXME: Fails on a ClassCastException: The ActionBarContributor is not accessible + // super.dispose(); //FIXME: Fails on a ClassCastException: The ActionBarContributor is not accessible try { TransactionalEditingDomain papyrusEditingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); CommandStack commandStack = papyrusEditingDomain.getCommandStack(); @@ -224,15 +227,16 @@ public class LayersTreeEditorDiagram extends LayersEditor implements IEditingDom @Override public IPropertySheetPage getPropertySheetPage() { -// return null; + // return null; return super.getPropertySheetPage(); } - + protected DynamicContextMenu dynamicContextMenu; + @Override public void menuAboutToShow(IMenuManager menuManager) { - if( dynamicContextMenu == null) { + if (dynamicContextMenu == null) { dynamicContextMenu = new DynamicContextMenu(this); } dynamicContextMenu.menuAboutToShow(menuManager); diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/AbstractLayerCommand.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/AbstractLayerCommand.java index b194d1a027d..40ba476e1ce 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/AbstractLayerCommand.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/AbstractLayerCommand.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -31,6 +31,7 @@ import org.eclipse.ui.IEditorPart; /** * Base class for Commands on Layers. * This class provide utility methods to find the current Layer, LayerStack, ... + * * @author cedric dumoulin * */ @@ -49,8 +50,9 @@ public abstract class AbstractLayerCommand extends AbstractHandler { * @param event * @return * @throws ExecutionException - * + * */ + @Override public Object execute(ExecutionEvent event) throws ExecutionException { executeTransaction(event); @@ -59,7 +61,8 @@ public abstract class AbstractLayerCommand extends AbstractHandler { /** * Execute as transaction - * @param event + * + * @param event */ private void executeTransaction(ExecutionEvent event) { @@ -86,7 +89,7 @@ public abstract class AbstractLayerCommand extends AbstractHandler { AbstractLayerCommand.this.doExecute(notationDiagramHelper); } - + }; editingDomain.getCommandStack().execute(cmd); @@ -94,9 +97,9 @@ public abstract class AbstractLayerCommand extends AbstractHandler { } /** - * Get the name used in the {@link RecordingCommand}. This name will be visible in + * Get the name used in the {@link RecordingCommand}. This name will be visible in * undo/redo. - * + * * @return The command name to show. */ public abstract String getCommandName(); @@ -104,83 +107,87 @@ public abstract class AbstractLayerCommand extends AbstractHandler { /** * Do the execution of the command. * Subclass should implements this method. - * + * * @param notationDiagramHelper */ protected abstract void doExecute(NotationDiagramHelper notationDiagramHelper); -// /** -// * -// * @return -// * @throws NotFoundException -// */ -// protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { -// -// return lookupLayersViewChecked().getLayerStackMngrChecked(); -// -// } - - + // /** + // * + // * @return + // * @throws NotFoundException + // */ + // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { + // + // return lookupLayersViewChecked().getLayerStackMngrChecked(); + // + // } + + protected IEvaluationContext getIEvaluationContext(ExecutionEvent event) throws NotFoundException { try { - return (IEvaluationContext)event.getApplicationContext(); + return (IEvaluationContext) event.getApplicationContext(); } catch (ClassCastException e) { throw new NotFoundException("IEvaluationContext can't be found."); } - + } + /** * Try to lookup the TransactionalEditingDomain. + * * @return - * @throws ServiceException If the Editing domain can't be found. + * @throws ServiceException + * If the Editing domain can't be found. */ protected TransactionalEditingDomain lookupTransactionalEditingDomain(IEvaluationContext context) throws ServiceException { // Get page from the event ! -// IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); - - return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); + // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); + + return ServiceUtilsForIEvaluationContext.getInstance().getTransactionalEditingDomain(context); } /** * Called by framework. Need to set the enabled flag. - * + * * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object) * * @param evaluationContext */ @Override public void setEnabled(Object evaluationContext) { - - if( ! (evaluationContext instanceof IEvaluationContext)) { + + if (!(evaluationContext instanceof IEvaluationContext)) { setBaseEnabled(false); -// System.out.println(getCommandName() + ".setEnabled(" + isEnabled() + ") - no context"); + // System.out.println(getCommandName() + ".setEnabled(" + isEnabled() + ") - no context"); return; } - - IEvaluationContext context = (IEvaluationContext)evaluationContext; - + + IEvaluationContext context = (IEvaluationContext) evaluationContext; + try { NotationDiagramHelper diagramHelper = lookupNotationDiagramHelperChecked(context); // Ask the subclass setBaseEnabled(isEnabled(diagramHelper)); - + } catch (ServiceException e) { // Can't find ServiceRegistry: disable - setBaseEnabled( false); + setBaseEnabled(false); } catch (NotFoundException e) { // Can't find ServiceRegistry: disable - setBaseEnabled( false); + setBaseEnabled(false); } - - -// System.out.println(getCommandName() + ".setEnabled(" + isEnabled() + ")"); + + + // System.out.println(getCommandName() + ".setEnabled(" + isEnabled() + ")"); } - + /** * Return true if the action is enabled, false otherwise. * Subclasses should implements this method. The default implementation return true. + * * @param notationDiagramHelper * @return */ @@ -188,47 +195,47 @@ public abstract class AbstractLayerCommand extends AbstractHandler { return true; } - // /** - // * - // * @return - // * @throws NotFoundException - // */ - // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { - // - // return lookupLayersViewChecked().getLayerStackMngrChecked(); - // - // } - - /** - * Get the notation diagram helper. - * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. - * - * @return The - * @throws NotFoundException - * @throws ServiceException - */ - protected NotationDiagramHelper lookupNotationDiagramHelperChecked(IEvaluationContext context) throws NotFoundException, ServiceException { - - - // Get page from the event ! - // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); - - IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getNestedActiveIEditorPart(context); - - if( ! (editor instanceof DiagramDocumentEditor) ) { - throw new NotFoundException("Selected editor do not contains Diagram"); - } - DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor)editor; - - Diagram diagram = diagramEditor.getDiagram(); - if(diagram == null) { - throw new NotFoundException("Selected editor do not contains Diagram"); - } - - // Lookup the Layer model - LayersModel layersModel = (LayersModel)ServiceUtilsForIEvaluationContext.getInstance().getModelSet(context).getModel(LayersModel.MODEL_ID); - // Return a new instance of the Helper - return new NotationDiagramHelper(layersModel, diagram); + // /** + // * + // * @return + // * @throws NotFoundException + // */ + // protected LayerStackMngr lookupLayerStackMngrChecked() throws NotFoundException { + // + // return lookupLayersViewChecked().getLayerStackMngrChecked(); + // + // } + + /** + * Get the notation diagram helper. + * This method can be used from {@link #execute(ExecutionEvent)} or {@link #setEnabled(Object)}. + * + * @return The + * @throws NotFoundException + * @throws ServiceException + */ + protected NotationDiagramHelper lookupNotationDiagramHelperChecked(IEvaluationContext context) throws NotFoundException, ServiceException { + + + // Get page from the event ! + // IWorkbenchPage page = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(); + + IEditorPart editor = ServiceUtilsForIEvaluationContext.getInstance().getNestedActiveIEditorPart(context); + + if (!(editor instanceof DiagramDocumentEditor)) { + throw new NotFoundException("Selected editor do not contains Diagram"); + } + DiagramDocumentEditor diagramEditor = (DiagramDocumentEditor) editor; + + Diagram diagram = diagramEditor.getDiagram(); + if (diagram == null) { + throw new NotFoundException("Selected editor do not contains Diagram"); } + // Lookup the Layer model + LayersModel layersModel = (LayersModel) ServiceUtilsForIEvaluationContext.getInstance().getModelSet(context).getModel(LayersModel.MODEL_ID); + // Return a new instance of the Helper + return new NotationDiagramHelper(layersModel, diagram); + } + } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/DynamicCreateChildMenu.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/DynamicCreateChildMenu.java index 41dcf8a9997..66a010255b4 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/DynamicCreateChildMenu.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/DynamicCreateChildMenu.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -22,7 +22,7 @@ import org.eclipse.ui.menus.CommandContributionItem; /** * This class is responsible to create the dynamic menu allowing to create * child elements of a Layer Model. - * + * * @author cedric dumoulin * */ @@ -35,15 +35,15 @@ public class DynamicCreateChildMenu extends CompoundContributionItem { */ @Override protected IContributionItem[] getContributionItems() { -// System.err.println("getContributionItems()"); + // System.err.println("getContributionItems()"); IContributionItem[] items = new IContributionItem[1]; - - Map<String, String> parms = new HashMap<String, String>(); - parms.put("groupBy", "Severity"); - items[0] = new CommandContributionItem(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), null, - "org.eclipse.ui.views.problems.grouping", - parms, null, null, null, "Severity", null, - null, CommandContributionItem.STYLE_PUSH); + + Map<String, String> parms = new HashMap<String, String>(); + parms.put("groupBy", "Severity"); + items[0] = new CommandContributionItem(PlatformUI.getWorkbench().getActiveWorkbenchWindow(), null, + "org.eclipse.ui.views.problems.grouping", + parms, null, null, null, "Severity", null, + null, CommandContributionItem.STYLE_PUSH); return items; } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/ShowCreateChildCommand.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/ShowCreateChildCommand.java index d87e2d4cf44..0ab0ec678eb 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/ShowCreateChildCommand.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.diagram/src/org/eclipse/papyrus/layers/stackmodel/diagram/ui/handlers/ShowCreateChildCommand.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -17,9 +17,9 @@ import org.eclipse.papyrus.layers.runtime.NotationDiagramHelper; /** * Add a layer stack to a diagram. * This is performed on the current LayerStack Viewer. - * + * * @author cedric dumoulin - * + * */ public class ShowCreateChildCommand extends AbstractLayerCommand implements IHandler { @@ -33,7 +33,7 @@ public class ShowCreateChildCommand extends AbstractLayerCommand implements IHan public String getCommandName() { return "Attach Layer Stack"; } - + /** * @see org.eclipse.papyrus.layers2.ui.view.commands.AbstractLayerCommand#doExecute(org.eclipse.papyrus.layers.application.NotationDiagramMngr) * @@ -50,7 +50,7 @@ public class ShowCreateChildCommand extends AbstractLayerCommand implements IHan */ @Override public boolean isEnabled(NotationDiagramHelper notationDiagramHelper) { - return ! notationDiagramHelper.isLayersStackAttached(); + return !notationDiagramHelper.isLayersStackAttached(); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderElementItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderElementItemProvider.java index e7c4c7bbab5..014bd45975c 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderElementItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderElementItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -39,11 +39,12 @@ import org.eclipse.papyrus.layers.configmodel.layersconfig.LayersconfigPackage; * This is the item provider adapter for a {@link org.eclipse.papyrus.layers.configmodel.layersconfig.FolderElement} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class FolderElementItemProvider - extends ItemProviderAdapter - implements + extends ItemProviderAdapter + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, @@ -53,6 +54,7 @@ public class FolderElementItemProvider * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public FolderElementItemProvider(AdapterFactory adapterFactory) { @@ -63,6 +65,7 @@ public class FolderElementItemProvider * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -79,28 +82,30 @@ public class FolderElementItemProvider * This adds a property descriptor for the Name feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addNamePropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_FolderElement_name_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_FolderElement_name_feature", "_UI_FolderElement_type"), - LayersconfigPackage.Literals.FOLDER_ELEMENT__NAME, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_FolderElement_name_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_FolderElement_name_feature", "_UI_FolderElement_type"), + LayersconfigPackage.Literals.FOLDER_ELEMENT__NAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This returns FolderElement.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -112,14 +117,15 @@ public class FolderElementItemProvider * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override public String getText(Object object) { - String label = ((FolderElement)object).getName(); + String label = ((FolderElement) object).getName(); return label == null || label.length() == 0 ? - getString("_UI_FolderElement_type") : - getString("_UI_FolderElement_type") + " " + label; + getString("_UI_FolderElement_type") : + getString("_UI_FolderElement_type") + " " + label; } /** @@ -127,6 +133,7 @@ public class FolderElementItemProvider * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -134,9 +141,9 @@ public class FolderElementItemProvider updateChildren(notification); switch (notification.getFeatureID(FolderElement.class)) { - case LayersconfigPackage.FOLDER_ELEMENT__NAME: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); - return; + case LayersconfigPackage.FOLDER_ELEMENT__NAME: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; } super.notifyChanged(notification); } @@ -146,6 +153,7 @@ public class FolderElementItemProvider * that can be created under this object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -157,6 +165,7 @@ public class FolderElementItemProvider * Return the resource locator for this item provider's resources. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderItemProvider.java index e6451fde7d6..3a0233c6cc3 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/FolderItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -37,11 +37,12 @@ import org.eclipse.papyrus.layers.configmodel.layersconfig.LayersconfigPackage; * This is the item provider adapter for a {@link org.eclipse.papyrus.layers.configmodel.layersconfig.Folder} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class FolderItemProvider - extends FolderElementItemProvider - implements + extends FolderElementItemProvider + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, @@ -51,6 +52,7 @@ public class FolderItemProvider * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public FolderItemProvider(AdapterFactory adapterFactory) { @@ -61,6 +63,7 @@ public class FolderItemProvider * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -73,11 +76,11 @@ public class FolderItemProvider } /** - * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an - * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -92,6 +95,7 @@ public class FolderItemProvider /** * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -106,6 +110,7 @@ public class FolderItemProvider * This returns Folder.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -117,14 +122,15 @@ public class FolderItemProvider * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override public String getText(Object object) { - String label = ((Folder)object).getName(); + String label = ((Folder) object).getName(); return label == null || label.length() == 0 ? - getString("_UI_Folder_type") : - getString("_UI_Folder_type") + " " + label; + getString("_UI_Folder_type") : + getString("_UI_Folder_type") + " " + label; } /** @@ -132,6 +138,7 @@ public class FolderItemProvider * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -139,9 +146,9 @@ public class FolderItemProvider updateChildren(notification); switch (notification.getFeatureID(Folder.class)) { - case LayersconfigPackage.FOLDER__FOLDER_ELEMENTS: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); - return; + case LayersconfigPackage.FOLDER__FOLDER_ELEMENTS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; } super.notifyChanged(notification); } @@ -151,6 +158,7 @@ public class FolderItemProvider * that can be created under this object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -158,34 +166,34 @@ public class FolderItemProvider super.collectNewChildDescriptors(newChildDescriptors, object); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createFolder())); + LayersconfigFactory.eINSTANCE.createFolder())); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createLayerOperatorConfig())); + LayersconfigFactory.eINSTANCE.createLayerOperatorConfig())); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createOperatorConfig())); + LayersconfigFactory.eINSTANCE.createOperatorConfig())); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createPropertyId())); + LayersconfigFactory.eINSTANCE.createPropertyId())); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createTypeConfig())); + LayersconfigFactory.eINSTANCE.createTypeConfig())); newChildDescriptors.add - (createChildParameter + (createChildParameter (LayersconfigPackage.Literals.FOLDER__FOLDER_ELEMENTS, - LayersconfigFactory.eINSTANCE.createLayerOperatorMultipleBinding())); + LayersconfigFactory.eINSTANCE.createLayerOperatorMultipleBinding())); } } diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/InstanciableElementItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/InstanciableElementItemProvider.java index 713dcf91798..c95cefab568 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/InstanciableElementItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/InstanciableElementItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -36,11 +36,12 @@ import org.eclipse.papyrus.layers.configmodel.layersconfig.LayersconfigPackage; * This is the item provider adapter for a {@link org.eclipse.papyrus.layers.configmodel.layersconfig.InstanciableElement} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class InstanciableElementItemProvider - extends FolderElementItemProvider - implements + extends FolderElementItemProvider + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, @@ -50,6 +51,7 @@ public class InstanciableElementItemProvider * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public InstanciableElementItemProvider(AdapterFactory adapterFactory) { @@ -60,6 +62,7 @@ public class InstanciableElementItemProvider * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -80,116 +83,122 @@ public class InstanciableElementItemProvider * This adds a property descriptor for the Classname feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addClassnamePropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_InstanciableElement_classname_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_classname_feature", "_UI_InstanciableElement_type"), - LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__CLASSNAME, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_InstanciableElement_classname_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_classname_feature", "_UI_InstanciableElement_type"), + LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__CLASSNAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This adds a property descriptor for the Bundle ID feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addBundleIDPropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_InstanciableElement_bundleID_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_bundleID_feature", "_UI_InstanciableElement_type"), - LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__BUNDLE_ID, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_InstanciableElement_bundleID_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_bundleID_feature", "_UI_InstanciableElement_type"), + LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__BUNDLE_ID, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This adds a property descriptor for the Display Name feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addDisplayNamePropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_InstanciableElement_displayName_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_displayName_feature", "_UI_InstanciableElement_type"), - LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__DISPLAY_NAME, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_InstanciableElement_displayName_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_displayName_feature", "_UI_InstanciableElement_type"), + LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__DISPLAY_NAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This adds a property descriptor for the Icon Path feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addIconPathPropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_InstanciableElement_iconPath_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_iconPath_feature", "_UI_InstanciableElement_type"), - LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__ICON_PATH, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_InstanciableElement_iconPath_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_iconPath_feature", "_UI_InstanciableElement_type"), + LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__ICON_PATH, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This adds a property descriptor for the Classname Kind feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addClassnameKindPropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_InstanciableElement_classnameKind_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_classnameKind_feature", "_UI_InstanciableElement_type"), - LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__CLASSNAME_KIND, - true, - false, - false, - ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_InstanciableElement_classnameKind_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_InstanciableElement_classnameKind_feature", "_UI_InstanciableElement_type"), + LayersconfigPackage.Literals.INSTANCIABLE_ELEMENT__CLASSNAME_KIND, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); } /** * This returns InstanciableElement.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -201,14 +210,15 @@ public class InstanciableElementItemProvider * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override public String getText(Object object) { - String label = ((InstanciableElement)object).getName(); + String label = ((InstanciableElement) object).getName(); return label == null || label.length() == 0 ? - getString("_UI_InstanciableElement_type") : - getString("_UI_InstanciableElement_type") + " " + label; + getString("_UI_InstanciableElement_type") : + getString("_UI_InstanciableElement_type") + " " + label; } /** @@ -216,6 +226,7 @@ public class InstanciableElementItemProvider * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -223,13 +234,13 @@ public class InstanciableElementItemProvider updateChildren(notification); switch (notification.getFeatureID(InstanciableElement.class)) { - case LayersconfigPackage.INSTANCIABLE_ELEMENT__CLASSNAME: - case LayersconfigPackage.INSTANCIABLE_ELEMENT__BUNDLE_ID: - case LayersconfigPackage.INSTANCIABLE_ELEMENT__DISPLAY_NAME: - case LayersconfigPackage.INSTANCIABLE_ELEMENT__ICON_PATH: - case LayersconfigPackage.INSTANCIABLE_ELEMENT__CLASSNAME_KIND: - fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); - return; + case LayersconfigPackage.INSTANCIABLE_ELEMENT__CLASSNAME: + case LayersconfigPackage.INSTANCIABLE_ELEMENT__BUNDLE_ID: + case LayersconfigPackage.INSTANCIABLE_ELEMENT__DISPLAY_NAME: + case LayersconfigPackage.INSTANCIABLE_ELEMENT__ICON_PATH: + case LayersconfigPackage.INSTANCIABLE_ELEMENT__CLASSNAME_KIND: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; } super.notifyChanged(notification); } @@ -239,6 +250,7 @@ public class InstanciableElementItemProvider * that can be created under this object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorConfigItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorConfigItemProvider.java index ed1ea73cd3e..17d27f8d13b 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorConfigItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorConfigItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -32,11 +32,12 @@ import org.eclipse.papyrus.layers.configmodel.layersconfig.LayerOperatorConfig; * This is the item provider adapter for a {@link org.eclipse.papyrus.layers.configmodel.layersconfig.LayerOperatorConfig} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class LayerOperatorConfigItemProvider - extends InstanciableElementItemProvider - implements + extends InstanciableElementItemProvider + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, @@ -46,6 +47,7 @@ public class LayerOperatorConfigItemProvider * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public LayerOperatorConfigItemProvider(AdapterFactory adapterFactory) { @@ -56,6 +58,7 @@ public class LayerOperatorConfigItemProvider * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -71,6 +74,7 @@ public class LayerOperatorConfigItemProvider * This returns LayerOperatorConfig.gif. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -82,14 +86,15 @@ public class LayerOperatorConfigItemProvider * This returns the label text for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override public String getText(Object object) { - String label = ((LayerOperatorConfig)object).getName(); + String label = ((LayerOperatorConfig) object).getName(); return label == null || label.length() == 0 ? - getString("_UI_LayerOperatorConfig_type") : - getString("_UI_LayerOperatorConfig_type") + " " + label; + getString("_UI_LayerOperatorConfig_type") : + getString("_UI_LayerOperatorConfig_type") + " " + label; } /** @@ -97,6 +102,7 @@ public class LayerOperatorConfigItemProvider * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -110,6 +116,7 @@ public class LayerOperatorConfigItemProvider * that can be created under this object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override diff --git a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorMultipleBindingItemProvider.java b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorMultipleBindingItemProvider.java index 80fc363cb99..94b19110522 100644 --- a/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorMultipleBindingItemProvider.java +++ b/extraplugins/layers/org.eclipse.papyrus.layers.stackmodel.edit/src/org/eclipse/papyrus/layers/configmodel/layersconfig/provider/LayerOperatorMultipleBindingItemProvider.java @@ -4,7 +4,7 @@ * 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: * Cedric Dumoulin - cedric.dumoulin@lifl.fr ******************************************************************************/ @@ -38,11 +38,12 @@ import org.eclipse.papyrus.layers.configmodel.layersconfig.LayersconfigPackage; * This is the item provider adapter for a {@link org.eclipse.papyrus.layers.configmodel.layersconfig.LayerOperatorMultipleBinding} object. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public class LayerOperatorMultipleBindingItemProvider - extends FolderElementItemProvider - implements + extends FolderElementItemProvider + implements IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, @@ -52,6 +53,7 @@ public class LayerOperatorMultipleBindingItemProvider * This constructs an instance from a factory and a notifier. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ public LayerOperatorMultipleBindingItemProvider(AdapterFactory adapterFactory) { @@ -62,6 +64,7 @@ public class LayerOperatorMultipleBindingItemProvider * This returns the property descriptors for the adapted class. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ @Override @@ -78,30 +81,31 @@ public class LayerOperatorMultipleBindingItemProvider * This adds a property descriptor for the Layer Operator Config feature. * <!-- begin-user-doc --> * <!-- end-user-doc --> + * * @generated */ protected void addLayerOperatorConfigPropertyDescriptor(Object object) { itemPropertyDescriptors.add - (createItemPropertyDescriptor - (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), - getResourceLocator(), - getString("_UI_LayerOperatorMultipleBinding_layerOperatorConfig_feature"), - getString("_UI_PropertyDescriptor_description", "_UI_LayerOperatorMultipleBinding_layerOperatorConfig_feature", "_UI_LayerOperatorMultipleBinding_type"), - LayersconfigPackage.Literals.LAYER_OPERATOR_MULTIPLE_BINDING__LAYER_OPERATOR_CONFIG, - true, - false, - true, - null, - null, - null)); + (createItemPropertyDescriptor + (((ComposeableAdapterFactory) adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_LayerOperatorMultipleBinding_layerOperatorConfig_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_LayerOperatorMultipleBinding_layerOperatorConfig_feature", "_UI_LayerOperatorMultipleBinding_type"), + LayersconfigPackage.Literals.LAYER_OPERATOR_MULTIPLE_BINDING__LAYER_OPERATOR_CONFIG, + true, + false, + true, + null, + null, + null)); } /** - * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an - * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * This specifies |