diff options
Diffstat (limited to 'plugins')
1380 files changed, 62303 insertions, 16811 deletions
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java index 8e02014cde3..5670f3830dc 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java +++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/dialog/LocalPaletteContentPage.java @@ -71,7 +71,7 @@ import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.papyrus.customization.palette.proxies.XMLDefinitionPaletteProxyFactory;
+import org.eclipse.papyrus.customization.palette.proxies.XMLPaletteDefinitionProxyFactory;
import org.eclipse.papyrus.uml.diagram.common.Activator;
import org.eclipse.papyrus.uml.diagram.common.Messages;
import org.eclipse.papyrus.uml.diagram.common.part.PaletteUtil;
@@ -79,7 +79,7 @@ import org.eclipse.papyrus.uml.diagram.common.part.PapyrusPalettePreferences; import org.eclipse.papyrus.uml.diagram.common.service.AspectCreationEntry;
import org.eclipse.papyrus.uml.diagram.common.service.IPapyrusPaletteConstant;
import org.eclipse.papyrus.uml.diagram.common.service.PapyrusPaletteService;
-import org.eclipse.papyrus.uml.diagram.common.service.XMLDefinitionPaletteParser;
+import org.eclipse.papyrus.uml.diagram.common.service.XMLPaletteDefinitionWalker;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IAspectAction;
import org.eclipse.papyrus.uml.diagram.common.service.palette.StereotypeAspectActionProvider;
import org.eclipse.swt.SWT;
@@ -644,12 +644,14 @@ public class LocalPaletteContentPage extends WizardPage implements Listener { } else {
Document document = documentBuilder.parse(file);
Map<String, PaletteEntry> entries = PaletteUtil.getAvailableEntriesSet(editorPart, ProviderPriority.HIGHEST);
- XMLDefinitionPaletteProxyFactory factory = new XMLDefinitionPaletteProxyFactory(entries);
- XMLDefinitionPaletteParser parser = new XMLDefinitionPaletteParser(factory);
+
+ XMLPaletteDefinitionProxyFactory factory = new XMLPaletteDefinitionProxyFactory(entries);
+ XMLPaletteDefinitionWalker walker = new XMLPaletteDefinitionWalker(factory);
+
for(int i = 0; i < document.getChildNodes().getLength(); i++) {
Node node = document.getChildNodes().item(i);
if(IPapyrusPaletteConstant.PALETTE_DEFINITION.equals(node.getNodeName())) {
- parser.parsePaletteDefinition(node);
+ walker.walk(node);
}
}
contentNode = factory.getRootProxy();
diff --git a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/proxies/XMLDefinitionPaletteProxyFactory.java b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/proxies/XMLPaletteDefinitionProxyFactory.java index d06ea75e339..ac6c4819534 100644 --- a/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/proxies/XMLDefinitionPaletteProxyFactory.java +++ b/plugins/customization/org.eclipse.papyrus.customization.palette/src/org/eclipse/papyrus/customization/palette/proxies/XMLPaletteDefinitionProxyFactory.java @@ -8,6 +8,7 @@ *
* Contributors:
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
+ * Laurent Wouters (CEA LIST) laurent.wouters@cea.fr - Refactoring
*
*****************************************************************************/
@@ -24,16 +25,16 @@ import org.eclipse.papyrus.customization.palette.dialog.PaletteLocalDrawerProxy; import org.eclipse.papyrus.customization.palette.dialog.PaletteLocalSeparatorProxy;
import org.eclipse.papyrus.customization.palette.dialog.PaletteLocalStackProxy;
import org.eclipse.papyrus.uml.diagram.common.Activator;
-import org.eclipse.papyrus.uml.diagram.common.service.AbstractXMLDefinitionPaletteFactory;
import org.eclipse.papyrus.uml.diagram.common.service.AspectCreationEntry;
import org.eclipse.papyrus.uml.diagram.common.service.IPapyrusPaletteConstant;
+import org.eclipse.papyrus.uml.diagram.common.service.XMLPaletteDefinitionVisitor;
import org.eclipse.papyrus.uml.diagram.common.service.palette.IPaletteEntryProxy;
import org.w3c.dom.Node;
/**
* Implementation that creates proxies used by the palette previewer in the customiza dialog
*/
-public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPaletteFactory implements IPapyrusPaletteConstant {
+public class XMLPaletteDefinitionProxyFactory implements XMLPaletteDefinitionVisitor, IPapyrusPaletteConstant {
/** map of predefined entries */
protected final Map<String, PaletteEntry> predefinedEntries;
@@ -52,16 +53,26 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet * @param predefinedEntries
* existing predefined entries
*/
- public XMLDefinitionPaletteProxyFactory(Map<String, PaletteEntry> predefinedEntries) {
+ public XMLPaletteDefinitionProxyFactory(Map<String, PaletteEntry> predefinedEntries) {
this.predefinedEntries = predefinedEntries;
registry = new HashMap<Node, IPaletteEntryProxy>();
}
+
+ /**
+ * Returns the parent proxy for the given node
+ *
+ * @param node
+ * the node for which the parent is searched
+ * @return the parent of this node
+ */
+ protected PaletteContainerProxy getParentProxy(Node node) {
+ return (PaletteContainerProxy)registry.get(node.getParentNode());
+ }
/**
* {@inheritDoc}
*/
- @Override
- public void traverseContentNode(Node node) {
+ public void onContent(Node node) {
containerProxy = new PaletteContainerProxy(null);
registry.put(node, containerProxy);
}
@@ -69,8 +80,7 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet /**
* {@inheritDoc}
*/
- @Override
- public void traverseDrawerNode(Node node) {
+ public void onDrawer(Node node) {
String id = node.getAttributes().getNamedItem(ID).getNodeValue();
PaletteEntry entry = predefinedEntries.get(id);
PaletteContainerProxy proxy;
@@ -80,23 +90,11 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet getParentProxy(node).addChild(proxy);
registry.put(node, proxy);
}
-
- /**
- * Returns the parent proxy for the given node
- *
- * @param node
- * the node for which the parent is searched
- * @return the parent of this node
- */
- protected PaletteContainerProxy getParentProxy(Node node) {
- return (PaletteContainerProxy)registry.get(node.getParentNode());
- }
-
+
/**
* {@inheritDoc}
*/
- @Override
- public void traverseSeparatorNode(Node node) {
+ public void onSeparator(Node node) {
String id = node.getAttributes().getNamedItem(ID).getNodeValue();
PaletteLocalSeparatorProxy proxy = new PaletteLocalSeparatorProxy(id);
getParentProxy(node).addChild(proxy);
@@ -107,8 +105,7 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet /**
* {@inheritDoc}
*/
- @Override
- public void traverseStackNode(Node node) {
+ public void onStack(Node node) {
String id = node.getAttributes().getNamedItem(ID).getNodeValue();
PaletteLocalStackProxy proxy = new PaletteLocalStackProxy(id);
getParentProxy(node).addChild(proxy);
@@ -118,8 +115,7 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet /**
* {@inheritDoc}
*/
- @Override
- public void traverseToolEntryNode(Node node) {
+ public void onToolEntry(Node node) {
String id = node.getAttributes().getNamedItem(ID).getNodeValue();
PaletteEntry entry = predefinedEntries.get(id);
PaletteEntryProxy proxy = new PaletteEntryProxy(entry);
@@ -130,8 +126,7 @@ public class XMLDefinitionPaletteProxyFactory extends AbstractXMLDefinitionPalet /**
* {@inheritDoc}
*/
- @Override
- public void traverseAspectToolEntryNode(Node node) {
+ public void onAspectToolEntry(Node node) {
String id = node.getAttributes().getNamedItem(ID).getNodeValue();
PaletteEntry entry = predefinedEntries.get(id);
diff --git a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt index 8182b8c5b9c..aa60a52deed 100644 --- a/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt +++ b/plugins/developer/org.eclipse.papyrus.def/dynamic-templates3.5/codegen/xpt/diagram/commands/CreateNodeCommand.xpt @@ -1,196 +1,208 @@ -/*
- * Copyright (c) 2007, 2009 Borland Software Corporation
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Alexander Shatalin (Borland) - initial API and implementation
- * modified by Patrick Tessier (CEA LIST)
- */
-
-«IMPORT 'http://www.eclipse.org/gmf/2009/GenModel'»
-«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
-«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
-«EXTENSION xpt::GenModelUtils»
-«EXTENSION xpt::diagram::Utils»
-«EXTENSION xpt::diagram::commands::file»
-«EXTENSION xpt::diagram::commands::NodeConstraintUtils»
-«EXTENSION xpt::OclMigrationProblems»
-
-«DEFINE CreateNodeCommand FOR gmfgen::GenNode-»
-«EXPAND xpt::Common::copyright FOR getDiagram().editorGen-»
-package «getDiagram().editCommandsPackageName»;
-«EXPAND xpt::Common::generatedClassComment»
-public class «createCommandClassName» extends org.eclipse.gmf.runtime.emf.type.core.commands.EditElementCommand {
- «REM» Mutating canvas auxiliary «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- private org.eclipse.emf.ecore.EClass eClass = null;
- «EXPAND xpt::Common::generatedMemberComment-»
- private org.eclipse.emf.ecore.EObject eObject = null;
- «REM» Mutating canvas auxiliary constructor «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject) {
- super(req.getLabel(), null, req);
- this.eObject = eObject;
- this.eClass = eObject != null ? eObject.eClass() : null;
- }
- «REM» Mutating canvas auxiliary builder «ENDREM»
- «EXPAND xpt::Common::generatedMemberComment-»
- public static «createCommandClassName» create(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req, org.eclipse.emf.ecore.EObject eObject) {
- return new «createCommandClassName»(req, eObject);
- }
- «EXPAND _constructor-»
- «EXPAND getElementToEdit-»
- «EXPAND canExecuteMethod-»
- «EXPAND doExecuteWithResultMethod»
- «EXPAND doConfigureMethod»
-}
-«ENDDEFINE»
-«DEFINE _constructor FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public «createCommandClassName»(org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest req) {
- super(req.getLabel(), null, req);
- }
-«ENDDEFINE»
-/*
- * TODO: either use setElementToEdit, or generate downcasted version (which may be troublesome if containment and child features point to a different parent)
- */
-«DEFINE getElementToEdit FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment('FIXME: replace with setElementToEdit()')»
-protected org.eclipse.emf.ecore.EObject getElementToEdit() {
-
- «REM» Mutating canvas helper «ENDREM»
- org.eclipse.emf.ecore.EObject container =
- ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer();
- if (container instanceof org.eclipse.gmf.runtime.notation.View) {
- container = ((org.eclipse.gmf.runtime.notation.View) container).getElement();
- }
- if (container != null) {
- return container;
- }
- return eObject;
-}
-«ENDDEFINE»
-
-«REM» [AbstractElement] Modified for Abstract domain element «ENDREM»
-«DEFINE doExecuteWithResultMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
-«REM» [AbstractElement] START «ENDREM»
-
-«IF modelFacet.metaClass.ecoreClass._abstract <> true-»
-«REM» [AbstractElement] END «ENDREM»
-«IF modelFacet.isPhantomElement()-»
- «EXPAND phantomElementCreation(self, 'newElement') FOR modelFacet»
-«ELSE-»
- «EXPAND normalElementCreation(self, 'newElement') FOR modelFacet»
-«ENDIF»
- «EXPAND initialize(self, 'newElement') FOR modelFacet-»
-«IF true/*FIXME boolean needsExternalConfiguration*/»
- doConfigure(newElement, monitor, info);
-«ENDIF»
- ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).setNewElement(«EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass»);
- return org.eclipse.gmf.runtime.common.core.command.CommandResult.newOKCommandResult(newElement);
- }
-«REM» [AbstractElement] START «ENDREM»
-«ELSE-»
- throw new UnsupportedOperationException("Unimplemented operation (abstract domain element).");
- }
-«ENDIF»
-«REM» [AbstractElement] END «ENDREM»
-«ENDDEFINE»
-/*
- * Unlike original CreateElementCommand, we don't keep track of IStatus from configureCommand.execute,
- * nor allow status setting from doDefaultCreation. The reason is ICommandProxy#execute implementation,
- * which ignores any status from wrapped ICommand. Besides, both CommandResult and IStatus seems too much to me.
- */
-«DEFINE doConfigureMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- protected void doConfigure(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.metaClass» newElement, org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
- org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getElementType();
- org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest configureRequest = new org.eclipse.gmf.runtime.emf.type.core.requests.ConfigureRequest(getEditingDomain(), «EXPAND MetaModel::DowncastToEObject('newElement') FOR modelFacet.metaClass», elementType);
- configureRequest.setClientContext(((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getClientContext());
- configureRequest.addParameters(getRequest().getParameters());
- org.eclipse.gmf.runtime.common.core.command.ICommand configureCommand = elementType.getEditCommand(configureRequest);
- if (configureCommand != null && configureCommand.canExecute()) {
- configureCommand.execute(monitor, info);
- }
- }
-«ENDDEFINE»
-«DEFINE canExecuteMethod FOR gmfgen::GenNode-»
- «EXPAND xpt::Common::generatedMemberComment»
- public boolean canExecute() {
-«IF modelFacet.isPhantomElement()-»
- return true;
-«ELSE-»
- «EXPAND canExecute_Normal FOR modelFacet»
-«ENDIF-»
- }
-«ENDDEFINE»
-«DEFINE canExecute_Normal FOR gmfgen::TypeModelFacet-»
-«IF not containmentMetaFeature.oclIsUndefined()-»
- «IF not containmentMetaFeature.ecoreFeature.oclIsUndefined()-»
- «IF not isUnbounded(containmentMetaFeature.ecoreFeature) or (childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature))-»
- «EXPAND MetaModel::DeclareAndAssign('container', 'getElementToEdit()') FOR containmentMetaFeature.genClass-»
- «IF not isUnbounded(containmentMetaFeature.ecoreFeature)-»
- «IF isSingleValued(containmentMetaFeature.ecoreFeature)»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature» != null) {
- «ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR containmentMetaFeature».size() >= «containmentMetaFeature.ecoreFeature.upperBound») {
- «ENDIF-»
- return false;
- }
- «ENDIF-»
- «IF childMetaFeature <> containmentMetaFeature and not isUnbounded(childMetaFeature.ecoreFeature)-»
- «IF isSingleValued(childMetaFeature.ecoreFeature)-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature» != null) {
- «ELSE-»
- if («EXPAND MetaModel::getFeatureValue('container', containmentMetaFeature.genClass) FOR childMetaFeature».size() >= «childMetaFeature.ecoreFeature.upperBound») {
- «ENDIF-»
- return false;
- }
- «ENDIF-»
- «ENDIF-»
- «ENDIF-»
-«ENDIF-»
-«REM» [NodeCreationConstraint] START «ENDREM»
-«IF getOwningGenNode().hasNodeCreationConstraint()-»
- «getOwningGenNode().getNodeCreationConstraintBody()-»
-«ELSE-»
-«REM» [NodeCreationConstraint] END «ENDREM»
-return true;
-«REM» [NodeCreationConstraint] START «ENDREM» -«ENDIF-»
-«REM» [NodeCreationConstraint] END «ENDREM»
-«ENDDEFINE»
-«DEFINE phantomElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
- // Uncomment to put "phantom" objects into the diagram file.
- // org.eclipse.emf.ecore.resource.Resource resource =
- // ((org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest) getRequest()).getContainer().eResource();
- // if (resource == null) {
- // return null;
- // }
- org.eclipse.emf.ecore.resource.Resource resource = getElementToEdit().eResource();
- «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
- resource.getContents().add(«EXPAND MetaModel::DowncastToEObject(varName) FOR metaClass»);
-«ENDDEFINE»
-«DEFINE normalElementCreation(node : gmfgen::GenNode, varName : String) FOR gmfgen::TypeModelFacet-»
- «EXPAND MetaModel::NewInstance(varName) FOR metaClass»
-«IF not containmentMetaFeature.oclIsUndefined()-»
- «EXPAND MetaModel::DeclareAndAssign('owner', 'getElementToEdit()') FOR containmentMetaFeature.genClass»
- «EXPAND MetaModel::modifyFeature('owner', containmentMetaFeature.genClass, varName) FOR containmentMetaFeature-»
-«ELSE-»
- //
- // FIXME no containme |