Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java')
-rw-r--r--extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java328
1 files changed, 164 insertions, 164 deletions
diff --git a/extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java b/extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java
index 7c911454ea3..3593bdb87b4 100644
--- a/extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java
+++ b/extraplugins/diagramtemplate/org.eclipse.papyrus.diagramtemplate.editor/src/org/eclipse/papyrus/diagramtemplate/launcher/DiagramTemplateLauncher.java
@@ -1,7 +1,7 @@
/*****************************************************************************
* Copyright (c) 2010 CEA LIST.
*
- *
+ *
* 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
@@ -79,7 +79,7 @@ import org.eclipse.uml2.uml.NamedElement;
/**
* The template launcher class
- *
+ *
*/
public class DiagramTemplateLauncher {
@@ -90,7 +90,7 @@ public class DiagramTemplateLauncher {
/**
* Enum used to report on diagram creation
- *
+ *
*/
public enum CreationReportKind {
SUCCESS, FAIL
@@ -125,12 +125,12 @@ public class DiagramTemplateLauncher {
/**
* Get the singleton
- *
+ *
* @return
* the DiagramTemplateLauncher singleton
*/
public final synchronized static DiagramTemplateLauncher getInstance() {
- if(instance == null) {
+ if (instance == null) {
instance = new DiagramTemplateLauncher();
}
return instance;
@@ -143,16 +143,16 @@ public class DiagramTemplateLauncher {
protected void initializeDiagramCategories() {
diagramCategories = new ArrayList<String>();
- for(DiagramCategoryDescriptor diagramCategoryDescriptor : DiagramCategoryRegistry.getInstance().getDiagramCategories()) {
+ for (DiagramCategoryDescriptor diagramCategoryDescriptor : DiagramCategoryRegistry.getInstance().getDiagramCategories()) {
diagramCategories.add(diagramCategoryDescriptor.getLabel());
}
}
/**
* Util method to get the CreationCommandDescriptor corresponding to a commandID
- *
+ *
* @param commandID
- * the commandID to find
+ * the commandID to find
* @return
* the corresponding CreationCommandDescriptor
*/
@@ -160,10 +160,10 @@ public class DiagramTemplateLauncher {
DiagramKindContentProvider provider = new DiagramKindContentProvider();
List<Object> diagramsKindlist = Arrays.asList(provider.getElements(diagramCategories));
- for(Object object : diagramsKindlist) {
- CreationCommandDescriptor command = (CreationCommandDescriptor)object;
+ for (Object object : diagramsKindlist) {
+ CreationCommandDescriptor command = (CreationCommandDescriptor) object;
- if(command.getCommandId().compareTo(commandID) == 0) {
+ if (command.getCommandId().compareTo(commandID) == 0) {
return command;
}
}
@@ -173,50 +173,50 @@ public class DiagramTemplateLauncher {
/**
* Used to recursively process the template definition. It identifies the newly create editpart and recurses on it
- *
+ *
* @param actualEditPart
- * the editpart elements was added to. It is used to find the newly create editpart
+ * the editpart elements was added to. It is used to find the newly create editpart
* @param elementToShow
- * the semantic element added
+ * the semantic element added
* @param selectionRef
- * the corresponding selectionRed
+ * the corresponding selectionRed
* @param activeEditor
- * the editor used
+ * the editor used
*/
protected void processRecursively(EditPart actualEditPart, EObject elementToShow, SelectionRef selectionRef, DiagramEditor activeEditor) {
- //Guess which of the View is the new one
+ // Guess which of the View is the new one
EditPartViewer viewer = actualEditPart.getViewer();
Map<?, ?> map = viewer.getEditPartRegistry();
- //We must have a copy since map may change during the loop
+ // We must have a copy since map may change during the loop
Map<?, ?> mapCopy = new HashMap<Object, Object>(map);
Iterator<?> it = mapCopy.keySet().iterator();
boolean found = false;
- while(it.hasNext() && !found) {
+ while (it.hasNext() && !found) {
Object view = it.next();
Object value = mapCopy.get(view);
- if(value instanceof GraphicalEditPart) {
+ if (value instanceof GraphicalEditPart) {
- GraphicalEditPart editPart = (GraphicalEditPart)value;
+ GraphicalEditPart editPart = (GraphicalEditPart) value;
// The element of the editPart and the element we just added must match
String editPartSemanticElementID = editPart.resolveSemanticElement().eResource().getURIFragment(editPart.resolveSemanticElement());
String elementToShowID = elementToShow.eResource().getURIFragment(elementToShow);
- if(editPartSemanticElementID.equals(elementToShowID)) {
+ if (editPartSemanticElementID.equals(elementToShowID)) {
- //The view should be the editpart whose parent's element is not the elementToShow
+ // The view should be the editpart whose parent's element is not the elementToShow
boolean foundParentWithElementToShowAsElement = false;
EditPart elementToProcess = editPart.getParent();
- while(elementToProcess != null && !foundParentWithElementToShowAsElement) {
+ while (elementToProcess != null && !foundParentWithElementToShowAsElement) {
- if(elementToProcess instanceof GraphicalEditPart) {
- String elementToProcessSemanticElementID = ((GraphicalEditPart)elementToProcess).resolveSemanticElement().eResource().getURIFragment(((GraphicalEditPart)elementToProcess).resolveSemanticElement());
- if(elementToProcessSemanticElementID.equals(elementToShowID)) {
+ if (elementToProcess instanceof GraphicalEditPart) {
+ String elementToProcessSemanticElementID = ((GraphicalEditPart) elementToProcess).resolveSemanticElement().eResource().getURIFragment(((GraphicalEditPart) elementToProcess).resolveSemanticElement());
+ if (elementToProcessSemanticElementID.equals(elementToShowID)) {
foundParentWithElementToShowAsElement = true;
}
}
@@ -224,15 +224,15 @@ public class DiagramTemplateLauncher {
elementToProcess = elementToProcess.getParent();
}
- if(!foundParentWithElementToShowAsElement) {
- //Last we must be sure that it is really new one
- if(!elementProcessed.contains(view)) {
- //We can process it
+ if (!foundParentWithElementToShowAsElement) {
+ // Last we must be sure that it is really new one
+ if (!elementProcessed.contains(view)) {
+ // We can process it
addElementsFor(selectionRef.getSelectionRef(), elementToShow, activeEditor, editPart);
// FIXME we may need to add all new elements as processed
- //Record that it is processed
- elementProcessed.add((View)view);
+ // Record that it is processed
+ elementProcessed.add((View) view);
found = true;
}
@@ -244,47 +244,47 @@ public class DiagramTemplateLauncher {
/**
* Find the element to show depending on a list and try to add them to a specific editPart
- *
+ *
* @param selectionList
- * The selection list of elements to add to the editPart
+ * The selection list of elements to add to the editPart
* @param root
- * The root to search the elements from
+ * The root to search the elements from
* @param activeEditor
- * the editor corresponding to the editPart
+ * the editor corresponding to the editPart
* @param editPartToShowIn
- * the editPart to show elements in
+ * the editPart to show elements in
*/
protected void addElementsFor(List<?> selectionList, EObject root, DiagramEditor activeEditor, EditPart editPartToShowIn) {
// Go through the SelectionRef
- for(Object object : selectionList) {
- if(object instanceof SelectionRef) {
- SelectionRef selectionRef = (SelectionRef)object;
+ for (Object object : selectionList) {
+ if (object instanceof SelectionRef) {
+ SelectionRef selectionRef = (SelectionRef) object;
// Retrieve the values
- Object result = root.eGet((EStructuralFeature)selectionRef.getEReference());
+ Object result = root.eGet((EStructuralFeature) selectionRef.getEReference());
List<EObject> resultsToProcess = new ArrayList<EObject>();
- if(result instanceof List) {
- resultsToProcess.addAll((Collection<? extends EObject>)result);
+ if (result instanceof List) {
+ resultsToProcess.addAll((Collection<? extends EObject>) result);
} else {
- resultsToProcess.add((EObject)result);
+ resultsToProcess.add((EObject) result);
}
- if(selectionRef.getKind() == SelectionKind.FOR_ALL) {
+ if (selectionRef.getKind() == SelectionKind.FOR_ALL) {
List<EObject> resultsToShow = new ArrayList<EObject>();
- //Try to match constraints
- for(EObject elementToMatch : resultsToProcess) {
- if(matchStereotypedBy(elementToMatch, selectionRef.getStereotypedBy())) {
- if(selectionRef.isSubTypes()) {
- //Consider all subtypes
- if(elementToMatch.eClass().getEAllSuperTypes().contains(selectionRef.getElement()) || elementToMatch.eClass() == selectionRef.getElement()) {
+ // Try to match constraints
+ for (EObject elementToMatch : resultsToProcess) {
+ if (matchStereotypedBy(elementToMatch, selectionRef.getStereotypedBy())) {
+ if (selectionRef.isSubTypes()) {
+ // Consider all subtypes
+ if (elementToMatch.eClass().getEAllSuperTypes().contains(selectionRef.getElement()) || elementToMatch.eClass() == selectionRef.getElement()) {
// It matches
resultsToShow.add(elementToMatch);
}
} else {
- if(elementToMatch.eClass() == selectionRef.getElement()) {
+ if (elementToMatch.eClass() == selectionRef.getElement()) {
// It matches
resultsToShow.add(elementToMatch);
}
@@ -294,7 +294,7 @@ public class DiagramTemplateLauncher {
// Process them all
int i = 0;
- for(EObject elementToShow : resultsToShow) {
+ for (EObject elementToShow : resultsToShow) {
EditPart actualEditPart = showElementIn(elementToShow, activeEditor, editPartToShowIn, i);
processRecursively(actualEditPart, elementToShow, selectionRef, activeEditor);
@@ -303,11 +303,11 @@ public class DiagramTemplateLauncher {
} else {
// FIXME Kind of very dirty
- for(EObject eObject : resultsToProcess) {
+ for (EObject eObject : resultsToProcess) {
String eObjectID = eObject.eResource().getURIFragment(eObject);
String elementID = selectionRef.getElement().eResource().getURIFragment(selectionRef.getElement());
- if(eObjectID.equals(elementID)) {
- // if(eObject == selectionRef.getElement()) {
+ if (eObjectID.equals(elementID)) {
+ // if(eObject == selectionRef.getElement()) {
EditPart actualEditPart = showElementIn(eObject, activeEditor, editPartToShowIn, 0);
processRecursively(actualEditPart, eObject, selectionRef, activeEditor);
}
@@ -319,32 +319,32 @@ public class DiagramTemplateLauncher {
/**
* Util method used to find all the children of a certain editpart
- *
+ *
* @param list
- * the children found recursively
+ * the children found recursively
* @param root
- * the root editpart to start the search from
+ * the root editpart to start the search from
*/
protected void findAllChildren(List<EditPart> list, EditPart root) {
list.addAll(root.getChildren());
- for(Object editPart : root.getChildren()) {
- if(editPart instanceof EditPart) {
- findAllChildren(list, (EditPart)editPart);
+ for (Object editPart : root.getChildren()) {
+ if (editPart instanceof EditPart) {
+ findAllChildren(list, (EditPart) editPart);
}
}
}
/**
* Try to show an element in an editPart (or its children)
- *
+ *
* @param elementToShow
- * the element to show
+ * the element to show
* @param activeEditor
- * the editor corresponding to the editPart
+ * the editor corresponding to the editPart
* @param editPart
- * the editPart to show the element in
+ * the editPart to show the element in
* @param position
- * position is used to try to distribute the drop
+ * position is used to try to distribute the drop
* @return
* the editPart in which the element has been actually added
*/
@@ -353,20 +353,20 @@ public class DiagramTemplateLauncher {
EditPart returnEditPart = null;
- if(elementToShow instanceof Element) {
+ if (elementToShow instanceof Element) {
DropObjectsRequest dropObjectsRequest = new DropObjectsRequest();
ArrayList<Element> list = new ArrayList<Element>();
- list.add((Element)elementToShow);
+ list.add((Element) elementToShow);
dropObjectsRequest.setObjects(list);
dropObjectsRequest.setLocation(new Point(20, 100 * position));
Command commandDrop = editPart.getCommand(dropObjectsRequest);
boolean processChildren = false;
- if(commandDrop == null) {
+ if (commandDrop == null) {
processChildren = true;
} else {
- if(commandDrop.canExecute()) {
+ if (commandDrop.canExecute()) {
activeEditor.getDiagramEditDomain().getDiagramCommandStack().execute(commandDrop);
returnEditPart = editPart;
creationReport.put(elementToShow, CreationReportKind.SUCCESS);
@@ -375,27 +375,27 @@ public class DiagramTemplateLauncher {
}
}
- if(processChildren) {
- //try to add to one of its children
+ if (processChildren) {
+ // try to add to one of its children
boolean found = false;
ArrayList<EditPart> childrenList = new ArrayList<EditPart>();
findAllChildren(childrenList, editPart);
- for(Object child : childrenList) {
- if(child instanceof EditPart) {
- Command commandDropChild = ((EditPart)child).getCommand(dropObjectsRequest);
- if(commandDropChild != null) {
- if(commandDropChild.canExecute()) {
+ for (Object child : childrenList) {
+ if (child instanceof EditPart) {
+ Command commandDropChild = ((EditPart) child).getCommand(dropObjectsRequest);
+ if (commandDropChild != null) {
+ if (commandDropChild.canExecute()) {
activeEditor.getDiagramEditDomain().getDiagramCommandStack().execute(commandDropChild);
found = true;
- returnEditPart = (EditPart)child;
+ returnEditPart = (EditPart) child;
creationReport.put(elementToShow, CreationReportKind.SUCCESS);
break;
}
}
}
}
- if(!found) {
+ if (!found) {
creationReport.put(elementToShow, CreationReportKind.FAIL);
returnEditPart = editPart;
}
@@ -407,24 +407,24 @@ public class DiagramTemplateLauncher {
/**
* Utils method that determine whether an element is stereotypedBy a certain stereotype qualiedName
- *
+ *
* @param element
- * the element to test
+ * the element to test
* @param stereotypedBy
- * the qulifiedName of the stereotype to match
+ * the qulifiedName of the stereotype to match
* @return
* true if matches false else.
*/
protected boolean matchStereotypedBy(EObject element, String stereotypedBy) {
- if(element instanceof Element) {
- //Read stereotypedBy
+ if (element instanceof Element) {
+ // Read stereotypedBy
stereotypedBy = stereotypedBy.replaceAll(" ", ""); //$NON-NLS-1$ //$NON-NLS-2$
String[] stereotypes = stereotypedBy.split(","); //$NON-NLS-1$
boolean matchStereotypes = true;
- for(String stereo : stereotypes) {
- if(stereo != null && stereo.length() > 0) {
- if(((Element)element).getAppliedStereotype(stereo) != null) {
+ for (String stereo : stereotypes) {
+ if (stereo != null && stereo.length() > 0) {
+ if (((Element) element).getAppliedStereotype(stereo) != null) {
matchStereotypes = true;
} else {
matchStereotypes = false;
@@ -441,43 +441,43 @@ public class DiagramTemplateLauncher {
/**
* Creates the diagrams in a specified Papyrus resource
- *
+ *
* @param selectionList
- * The selection for which we must create diagrams corresponding to the diagram definition
+ * The selection for which we must create diagrams corresponding to the diagram definition
* @param diagramDefinition
- * The diagram definition to create
+ * The diagram definition to create
* @param diResourceSet
- * The Papyrus resource to create the diagrams in
+ * The Papyrus resource to create the diagrams in
*/
protected void createDiagramFor(List<?> selectionList, DiagramDefinition diagramDefinition, ModelSet modelSet) {
- //Go through the selection and try to find elements in the target model that match
- for(Object object : selectionList) {
+ // Go through the selection and try to find elements in the target model that match
+ for (Object object : selectionList) {
- if(object instanceof AbstractSelection) {
- AbstractSelection selection = (AbstractSelection)object;
+ if (object instanceof AbstractSelection) {
+ AbstractSelection selection = (AbstractSelection) object;
CreationCommandDescriptor creationCommandDescriptor = getCreation(diagramDefinition.getDiagramKind());
- if(creationCommandDescriptor != null) {
+ if (creationCommandDescriptor != null) {
EObject root;
- //If the template is under specified, try to guess
- if(diagramDefinition.getFromRoot() == null) {
- root = ((Template)diagramDefinition.eContainer()).getTargetRoot();
+ // If the template is under specified, try to guess
+ if (diagramDefinition.getFromRoot() == null) {
+ root = ((Template) diagramDefinition.eContainer()).getTargetRoot();
} else {
root = diagramDefinition.getFromRoot();
}
- if(root != null) {
- if(selection.getKind() == SelectionKind.FOR_ALL) {
+ if (root != null) {
+ if (selection.getKind() == SelectionKind.FOR_ALL) {
// Find elements that match
List<EObject> content = new ArrayList<EObject>();
- if(selection instanceof Selection) {
- if(((Selection)selection).isRecursively()) {
- //Go through all recursively
+ if (selection instanceof Selection) {
+ if (((Selection) selection).isRecursively()) {
+ // Go through all recursively
TreeIterator<EObject> it = root.eAllContents();
- while(it.hasNext()) {
+ while (it.hasNext()) {
EObject eObject = it.next();
content.add(eObject);
}
@@ -490,30 +490,30 @@ public class DiagramTemplateLauncher {
}
- for(EObject eObject : content) {
- if(matchStereotypedBy(eObject, selection.getStereotypedBy())) {
+ for (EObject eObject : content) {
+ if (matchStereotypedBy(eObject, selection.getStereotypedBy())) {
String name = diagramDefinition.getPrefix();
- if(eObject instanceof NamedElement) {
- name += ((NamedElement)eObject).getName();
+ if (eObject instanceof NamedElement) {
+ name += ((NamedElement) eObject).getName();
} else {
name += eObject.toString();
}
- if(selection.isSubTypes()) {
- //Consider all subtypes
- if(eObject.eClass().getEAllSuperTypes().contains(selection.getElement()) || eObject.eClass() == selection.getElement()) {
+ if (selection.isSubTypes()) {
+ // Consider all subtypes
+ if (eObject.eClass().getEAllSuperTypes().contains(selection.getElement()) || eObject.eClass() == selection.getElement()) {
// System.err.println("FoundForAll Sub: " + diagramDefinition.getName());
// It matches: create a diagram
try {
creationCommandDescriptor.getCommand().createDiagram(modelSet, eObject, name);
- //Identify the new diagram
+ // Identify the new diagram
TreeIterator<EObject> it = NotationUtils.getNotationResource(modelSet).getAllContents();
- while(it.hasNext()) {
+ while (it.hasNext()) {
EObject diagram = it.next();
- if(diagram instanceof Diagram) {
- if(!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
+ if (diagram instanceof Diagram) {
+ if (!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
diagramsCreated.put(diagram.eResource().getURIFragment(diagram), selection);
diagramsInResource.add(diagram.eResource().getURIFragment(diagram));
@@ -528,19 +528,19 @@ public class DiagramTemplateLauncher {
}
}
} else {
- if(eObject.eClass() == selection.getElement()) {
+ if (eObject.eClass() == selection.getElement()) {
// System.err.println("FoundForAll Strict: " + diagramDefinition.getName());
// It matches: create a diagram
try {
creationCommandDescriptor.getCommand().createDiagram(modelSet, eObject, name);
- //Identify the new diagram
+ // Identify the new diagram
TreeIterator<EObject> it = NotationUtils.getNotationResource(modelSet).getAllContents();
- while(it.hasNext()) {
+ while (it.hasNext()) {
EObject diagram = it.next();
- if(diagram instanceof Diagram) {
- if(!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
+ if (diagram instanceof Diagram) {
+ if (!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
diagramsCreated.put(diagram.eResource().getURIFragment(diagram), selection);
diagramsInResource.add(diagram.eResource().getURIFragment(diagram));
@@ -557,12 +557,12 @@ public class DiagramTemplateLauncher {
}
}
}
- } else if(selection.getKind() == SelectionKind.SPECIFIC) {
+ } else if (selection.getKind() == SelectionKind.SPECIFIC) {
// System.err.println("FoundSpecific");
String name = diagramDefinition.getPrefix();
- if(selection.getElement() instanceof NamedElement) {
- name += ((NamedElement)selection.getElement()).getName();
+ if (selection.getElement() instanceof NamedElement) {
+ name += ((NamedElement) selection.getElement()).getName();
} else {
name += selection.getElement().toString();
}
@@ -570,12 +570,12 @@ public class DiagramTemplateLauncher {
try {
creationCommandDescriptor.getCommand().createDiagram(modelSet, selection.getElement(), name);
- //Identify the new diagram
+ // Identify the new diagram
TreeIterator<EObject> it = NotationUtils.getNotationResource(modelSet).getAllContents();
- while(it.hasNext()) {
+ while (it.hasNext()) {
EObject diagram = it.next();
- if(diagram instanceof Diagram) {
- if(!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
+ if (diagram instanceof Diagram) {
+ if (!diagramsInResource.contains(diagram.eResource().getURIFragment(diagram))) {
diagramsCreated.put(diagram.eResource().getURIFragment(diagram), selection);
diagramsInResource.add(diagram.eResource().getURIFragment(diagram));
@@ -596,20 +596,20 @@ public class DiagramTemplateLauncher {
/**
* Helper method used to arrange recursively editparts
- *
+ *
* @param editpart
- * the editpart to process
+ * the editpart to process
*/
protected void arrangeRecursively(EditPart editpart) {
- //ArrangeRequest request = new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL, LayoutType.DEFAULT);
+ // ArrangeRequest request = new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL, LayoutType.DEFAULT);
ArrangeRequest request = new ArrangeRequest(RequestConstants.REQ_ARRANGE_DEFERRED);
List<EditPart> listToArrange = new ArrayList<EditPart>();
listToArrange.addAll(editpart.getChildren());
- if(!listToArrange.isEmpty()) {
- for(Object element : editpart.getChildren()) {
- if(element instanceof EditPart) {
- arrangeRecursively((EditPart)element);
+ if (!listToArrange.isEmpty()) {
+ for (Object element : editpart.getChildren()) {
+ if (element instanceof EditPart) {
+ arrangeRecursively((EditPart) element);
}
}
@@ -622,9 +622,9 @@ public class DiagramTemplateLauncher {
/**
* This is the main method for the template launcher. Executes the template
- *
+ *
* @param template
- * The template to execute
+ * The template to execute
*/
public void execute(Template template) {
initializeDiagramCategories();
@@ -632,16 +632,16 @@ public class DiagramTemplateLauncher {
diagramsCreated = new HashMap<String, AbstractSelection>();
creationReport = new HashMap<EObject, CreationReportKind>();
- if(template != null) {
+ if (template != null) {
ModelSet modelSet = new DiResourceSet();
- if(template.getTargetRoot().eResource() != null) {
+ if (template.getTargetRoot().eResource() != null) {
String targetModelLocation = template.getTargetRoot().eResource().getURI().toPlatformString(false);
IFile targetModelfile = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(targetModelLocation));
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(targetModelfile.getFullPath().removeFileExtension().toString() + ".di")); //$NON-NLS-1$
- if(file.exists()) {
+ if (file.exists()) {
try {
modelSet.loadModels(file);
@@ -655,26 +655,26 @@ public class DiagramTemplateLauncher {
try {
registry.startRegistry();
} catch (ServiceException ex) {
- //Ignore
+ // Ignore
}
- //Identify already available diagrams
+ // Identify already available diagrams
TreeIterator<EObject> it = NotationUtils.getNotationResource(modelSet).getAllContents();
- while(it.hasNext()) {
+ while (it.hasNext()) {
EObject diagram = it.next();
- if(diagram instanceof Diagram) {
+ if (diagram instanceof Diagram) {
diagramsInResource.add(diagram.eResource().getURIFragment(diagram));
}
}
// Create diagrams
- if(!template.getDiagramDefinitions().isEmpty()) {
- for(DiagramDefinition diagramDefinition : template.getDiagramDefinitions()) {
+ if (!template.getDiagramDefinitions().isEmpty()) {
+ for (DiagramDefinition diagramDefinition : template.getDiagramDefinitions()) {
createDiagramFor(diagramDefinition.getSelection(), diagramDefinition, modelSet);
}
} else {
// Create empty diagrams
- //EditorUtils.getTransactionalIPageMngr(DiModelUtils.getDiResource(modelSet), modelSet.getTransactionalEditingDomain());
+ // EditorUtils.getTransactionalIPageMngr(DiModelUtils.getDiResource(modelSet), modelSet.getTransactionalEditingDomain());
}
// Save the resource
@@ -688,7 +688,7 @@ public class DiagramTemplateLauncher {
try {
registry.disposeRegistry();
} catch (ServiceException ex) {
- //Ignore
+ // Ignore
}
} catch (ServiceException ex) {
@@ -698,12 +698,12 @@ public class DiagramTemplateLauncher {
// Open the editor
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- if(page != null) {
+ if (page != null) {
try {
final IEditorPart editor = IDE.openEditor(page, file, true);
- if(editor instanceof IMultiDiagramEditor) {
- final ServicesRegistry services = ((IMultiDiagramEditor)editor).getServicesRegistry();
+ if (editor instanceof IMultiDiagramEditor) {
+ final ServicesRegistry services = ((IMultiDiagramEditor) editor).getServicesRegistry();
TransactionalEditingDomain editingDomain = services.getService(TransactionalEditingDomain.class);
org.eclipse.emf.common.command.Command openPagesCommand = new RecordingCommand(editingDomain, "Open created pages") {
@@ -717,27 +717,27 @@ public class DiagramTemplateLauncher {
pageManager.closeAllOpenedPages();
// Go through the diagrams available in the resource
- for(Object pageDiagram : pageManager.allPages()) {
+ for (Object pageDiagram : pageManager.allPages()) {
- if(pageDiagram instanceof Diagram) {
- String pageID = ((Diagram)pageDiagram).eResource().getURIFragment((Diagram)pageDiagram);
+ if (pageDiagram instanceof Diagram) {
+ String pageID = ((Diagram) pageDiagram).eResource().getURIFragment((Diagram) pageDiagram);
- if(diagramsCreated.containsKey(pageID)) {
+ if (diagramsCreated.containsKey(pageID)) {
System.out.println("Open page");
pageManager.openPage(pageDiagram);
- IEditorPart activeEditor = ((PapyrusMultiDiagramEditor)editor).getActiveEditor();
+ IEditorPart activeEditor = ((PapyrusMultiDiagramEditor) editor).getActiveEditor();
- if(activeEditor instanceof DiagramEditor) {
+ if (activeEditor instanceof DiagramEditor) {
// Get the GraphicalViewer for this diagram
Object result = activeEditor.getAdapter(GraphicalViewer.class);
- if(result != null && result instanceof GraphicalViewer) {
- DiagramEditPart diagramEditPart = (DiagramEditPart)((GraphicalViewer)result).getEditPartRegistry().get(pageDiagram);
+ if (result != null && result instanceof GraphicalViewer) {
+ DiagramEditPart diagramEditPart = (DiagramEditPart) ((GraphicalViewer) result).getEditPartRegistry().get(pageDiagram);
// Retrieve the selection to show for this diagram
AbstractSelection selection = diagramsCreated.get(pageID);
- addElementsFor(selection.getSelectionRef(), ((Diagram)pageDiagram).getElement(), (DiagramEditor)activeEditor, diagramEditPart);
+ addElementsFor(selection.getSelectionRef(), ((Diagram) pageDiagram).getElement(), (DiagramEditor) activeEditor, diagramEditPart);
- //Arrange all recursively
+ // Arrange all recursively
arrangeRecursively(diagramEditPart);
}
@@ -756,7 +756,7 @@ public class DiagramTemplateLauncher {
editingDomain.getCommandStack().execute(openPagesCommand);
}
- //Report
+ // Report
DiagramTemplateLauncherReport.getInstance().showReport(creationReport);
} catch (PartInitException e) {

Back to the top