org.eclipse.gmf.runtime.notation.Diagram Java Examples
The following examples show how to use
org.eclipse.gmf.runtime.notation.Diagram.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BonitaTreeOutlinePage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @return */ private EditPartFactory getOutlineViewEditPartFactory() { return new EditPartFactory() { @Override public EditPart createEditPart(final EditPart context, final Object model) { if (model instanceof Diagram) { return new TreeDiagramEditPart(model); } else if (model instanceof View && ViewType.GROUP.equals(((View) model).getType())) { return new TreeContainerEditPart(model); } else { return new TreeEditPart(model); } } }; }
Example #2
Source File: ProcessDiagramEditor.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { ProcessNavigatorItem item = new ProcessNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
Example #3
Source File: DiagramPartitioningUtil.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * Returns the {@link Diagram} that contains a given semantic element. */ public static Diagram getDiagramContaining(EObject element) { Assert.isNotNull(element); Resource eResource = element.eResource(); Collection<Diagram> objects = EcoreUtil.getObjectsByType(eResource.getContents(), NotationPackage.Literals.DIAGRAM); for (Diagram diagram : objects) { TreeIterator<EObject> eAllContents = diagram.eAllContents(); while (eAllContents.hasNext()) { EObject next = eAllContents.next(); if (next instanceof View) { if (EcoreUtil.equals(((View) next).getElement(), element)) { return ((View) next).getDiagram(); } } } } return null; }
Example #4
Source File: CrossflowDiagramEditor.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ private ISelection getNavigatorSelection() { IDiagramDocument document = getDiagramDocument(); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { CrossflowNavigatorItem item = new CrossflowNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
Example #5
Source File: CrossflowNavigatorActionProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ public final void selectionChanged(IStructuredSelection selection) { myDiagram = null; if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof CrossflowNavigatorItem) { selectedElement = ((CrossflowNavigatorItem) selectedElement).getView(); } else if (selectedElement instanceof IAdaptable) { selectedElement = ((IAdaptable) selectedElement).getAdapter(View.class); } if (selectedElement instanceof Diagram) { Diagram diagram = (Diagram) selectedElement; if (WorkflowEditPart.MODEL_ID.equals(CrossflowVisualIDRegistry.getModelID(diagram))) { myDiagram = diagram; } } } setEnabled(myDiagram != null); }
Example #6
Source File: CrossflowNavigatorLinkHelper.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ private static IEditorInput getEditorInput(Diagram diagram) { Resource diagramResource = diagram.eResource(); for (EObject nextEObject : diagramResource.getContents()) { if (nextEObject == diagram) { return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); } if (nextEObject instanceof Diagram) { break; } } URI uri = EcoreUtil.getURI(diagram); String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); IEditorInput editorInput = new URIEditorInput(uri, editorName); return editorInput; }
Example #7
Source File: CrossflowModelingAssistantProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ protected EObject selectExistingElement(IAdaptable host, Collection types) { if (types.isEmpty()) { return null; } IGraphicalEditPart editPart = (IGraphicalEditPart) host.getAdapter(IGraphicalEditPart.class); if (editPart == null) { return null; } Diagram diagram = (Diagram) editPart.getRoot().getContents().getModel(); HashSet<EObject> elements = new HashSet<EObject>(); for (Iterator<EObject> it = diagram.getElement().eAllContents(); it.hasNext();) { EObject element = it.next(); if (isApplicableElement(element, types)) { elements.add(element); } } if (elements.isEmpty()) { return null; } return selectElement((EObject[]) elements.toArray(new EObject[elements.size()])); }
Example #8
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public IStatus getResult() { final MultiStatus result = new MultiStatus(ValidationCommonPlugin.PLUGIN_ID, IStatus.OK, "", null); fileProcessed.clear(); for (final Diagram d : diagramsToDiagramEditPart.keySet()) { final EObject element = d.getElement(); if (element != null) { final IFile target = d.eResource() != null ? WorkspaceSynchronizer.getFile(d.eResource()) : null; if (target != null && !fileProcessed.contains(target)) { try { buildMultiStatus(target, result); } catch (final CoreException e) { BonitaStudioLog.error(e); } } } } return result; }
Example #9
Source File: CrossflowNavigatorActionProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ private static IEditorInput getEditorInput(Diagram diagram) { Resource diagramResource = diagram.eResource(); for (EObject nextEObject : diagramResource.getContents()) { if (nextEObject == diagram) { return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); } if (nextEObject instanceof Diagram) { break; } } URI uri = EcoreUtil.getURI(diagram); String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); IEditorInput editorInput = new URIEditorInput(uri, editorName); return editorInput; }
Example #10
Source File: CrossflowValidationDecoratorProvider.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ private static void refreshDecorators(String viewId, Diagram diagram) { final List decorators = viewId != null ? (List) allDecorators.get(viewId) : null; if (decorators == null || decorators.isEmpty() || diagram == null) { return; } final Diagram fdiagram = diagram; PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { try { TransactionUtil.getEditingDomain(fdiagram).runExclusive(new Runnable() { public void run() { for (Iterator it = decorators.iterator(); it.hasNext();) { IDecorator decorator = (IDecorator) it.next(); decorator.refresh(); } } }); } catch (Exception e) { CrossflowDiagramEditorPlugin.getInstance().logError("Decorator refresh failure", e); //$NON-NLS-1$ } } }); }
Example #11
Source File: DiagramPartitioningUtil.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * Opens a subdiagram for a given {@link Diagram} */ public static IEditorPart openEditor(Diagram diagramToOpen) { IFile file = WorkspaceSynchronizer.getFile(diagramToOpen.eResource()); try { IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName()); final IWorkbenchPage wbPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if (diagramToOpen.getElement() instanceof Statechart) { return wbPage.openEditor(new FileEditorInput(file), desc.getId()); } else if (diagramToOpen.getElement() instanceof State) { return wbPage.openEditor(new DiagramEditorInput(diagramToOpen), desc.getId()); } } catch (PartInitException e) { e.printStackTrace(); } return null; }
Example #12
Source File: DiagramPartitioningUtil.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public static View findNotationView(EObject semanticElement) { Collection<Diagram> objects = EcoreUtil.getObjectsByType(semanticElement.eResource().getContents(), NotationPackage.Literals.DIAGRAM); for (Diagram diagram : objects) { TreeIterator<EObject> eAllContents = diagram.eAllContents(); while (eAllContents.hasNext()) { EObject next = eAllContents.next(); if (next instanceof View) { if (((View) next).getElement() == semanticElement) { return ((View) next); } } } } return null; }
Example #13
Source File: ProcessNavigatorLinkHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ private static IEditorInput getEditorInput(Diagram diagram) { Resource diagramResource = diagram.eResource(); for (EObject nextEObject : diagramResource.getContents()) { if (nextEObject == diagram) { return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); } if (nextEObject instanceof Diagram) { break; } } URI uri = EcoreUtil.getURI(diagram); String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); IEditorInput editorInput = new URIEditorInput(uri, editorName); return editorInput; }
Example #14
Source File: DiagramFileStore.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IWorkbenchPart doOpen() { IEditorPart part = null; final Resource emfResource = getEMFResource(); final MainProcess content = getContent(); Assert.isLegal(content != null); Assert.isLegal(emfResource != null && emfResource.isLoaded()); final Diagram diagram = ModelHelper.getDiagramFor(content, emfResource); part = EditorService.getInstance().openEditor(new URIEditorInput(EcoreUtil.getURI(diagram).trimFragment())); if (part instanceof DiagramEditor) { final DiagramEditor editor = (DiagramEditor) part; final MainProcess mainProcess = (MainProcess) editor.getDiagramEditPart().resolveSemanticElement(); mainProcess.eAdapters().add(new PoolNotificationListener()); if (isReadOnly()) { setReadOnlyAndOpenWarningDialogAboutReadOnly(editor); } registerListeners(mainProcess, editor.getEditingDomain()); setDefaultSelection(editor); return editor; } return part; }
Example #15
Source File: ModelHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public static Diagram getDiagramFor(final EObject element, EditingDomain domain) { if (element == null) { return null; } Resource resource = element.eResource(); if (resource == null) { if (domain == null) { domain = TransactionUtil.getEditingDomain(element); if (domain != null) { resource = domain.getResourceSet().getResource(element.eResource().getURI(), true); } } else if (domain.getResourceSet() != null) { resource = domain.getResourceSet().getResource(element.eResource().getURI(), true); } } if (resource == null) { throw new IllegalStateException(String.format("No resource attached to EObject %s", element)); } return getDiagramFor(element, resource); }
Example #16
Source File: DiagramPartitioningDocumentProvider.java From statecharts with Eclipse Public License 1.0 | 6 votes |
@Override protected void disposeElementInfo(Object element, ElementInfo info) { Object content = info.fDocument.getContent(); info.fDocument.setContent(null); // Unset the content first to avoid call to DiagramIOUtil.unload super.disposeElementInfo(element, info); info.fDocument.setContent(content); if (content instanceof Diagram && info instanceof InputDiagramFileInfo) { // Unload non needed resources try { DiagramPartitioningUtil.getSharedDomain().runExclusive(new Runnable() { @Override public void run() { ResourceUnloadingTool.unloadEditorInput( DiagramPartitioningUtil.getSharedDomain().getResourceSet(), ((InputDiagramFileInfo) info).getEditorInput()); } }); } catch (InterruptedException e) { e.printStackTrace(); } } }
Example #17
Source File: CopyToImageUtilEx.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public byte [] copyToImageByteArray(final Diagram diagram,final Element elementToDraw, final int maxWidth, final int maxHeight, final ImageFileFormat format, final IProgressMonitor monitor, final PreferencesHint preferencesHint, final boolean useMargins) throws Exception { final Shell shell = new Shell(); DiagramEditPart diagramEditPart = null ; EditPart ep = null ; try { diagramEditPart = createDiagramEditPart(diagram, shell, preferencesHint); Assert.isNotNull(diagramEditPart); ep = GMFTools.findEditPart(diagramEditPart,elementToDraw) ; if(ep == null) { throw new Exception("Element to draw not found") ; } return copyToImageByteArray(diagramEditPart, Collections.singletonList(ep), maxWidth, maxHeight, format, monitor, useMargins); }catch(final Exception e){ e.printStackTrace(); throw e ; } finally { shell.dispose(); } }
Example #18
Source File: AbstractPapyrusModelManager.java From txtUML with Eclipse Public License 1.0 | 6 votes |
/** * Adds the elements to the diagrams * @param monitor */ protected void addElementsToDiagrams(IProgressMonitor monitor){ List<Diagram> diags = diagramManager.getDiagrams(); int diagNum = diags.size(); monitor.beginTask("Filling diagrams", diagNum*2); for(int i=0; i<diagNum*2; i=i+2){ Diagram diagram = diags.get(i/2); diagramManager.openDiagram(diagram); monitor.subTask("Filling diagrams "+(i+2)/2+"/"+diagNum); addElementsToDiagram(diagram, monitor); monitor.worked(1); try{ arrangeElementsOfDiagram(diagram, monitor); }catch(Throwable e){ Dialogs.errorMsgb("Arrange error", "Error occured during arrangement of diagram '" +diagram.getName()+"'.", e); } } }
Example #19
Source File: DiagramForElementRunnable.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public void run() { final TreeIterator<EObject> allContents = resource.getAllContents(); EObject elementToFind = null; final Set<Diagram> diagrams = new HashSet<Diagram>(); while (allContents.hasNext()) { final EObject eObject = allContents.next(); if (EcoreUtil.equals(eObject, element)) { elementToFind = eObject; } if (eObject instanceof Diagram) { diagrams.add((Diagram) eObject); } } if (elementToFind == null) { return; } for (final Diagram diagram : diagrams) { final EObject diagramElement = diagram.getElement(); if (diagramElement != null && diagramElement.equals(elementToFind)) { result = diagram; break; } } }
Example #20
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException { Assert.isLegal(!diagramsToDiagramEditPart.isEmpty()); buildEditPart(); validationMarkerProvider.clearMarkers(diagramsToDiagramEditPart); for (final Entry<Diagram, DiagramEditPart> entry : diagramsToDiagramEditPart.entrySet()) { final DiagramEditPart diagramEp = entry.getValue(); final Diagram diagram = entry.getKey(); if (diagramEp != null && !monitor.isCanceled()) { monitor.setTaskName(Messages.bind( Messages.validatingProcess, ((MainProcess) diagramEp.resolveSemanticElement()).getName(), ((MainProcess) diagramEp.resolveSemanticElement()).getVersion())); final TransactionalEditingDomain txDomain = TransactionUtil.getEditingDomain(diagram); runWithConstraints(txDomain, () -> validate(diagramEp, diagram, monitor)); monitor.worked(1); } } offscreenEditPartFactory.dispose(); }
Example #21
Source File: SubdiagramAwareCopyCommand.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected Collection<? extends Diagram> getAllSubDiagrams(State semanticState) { List<Diagram> subDiagrams = new ArrayList<>(); addSubDiagram(semanticState, subDiagrams); TreeIterator<EObject> iter = semanticState.eAllContents(); while (iter.hasNext()) { EObject next = iter.next(); if (next instanceof State) { State subState = (State) next; if (subState.isComposite()) { addSubDiagram(subState, subDiagrams); } else { iter.prune(); } } } return subDiagrams; }
Example #22
Source File: NotationClipboardOperationHelper.java From statecharts with Eclipse Public License 1.0 | 6 votes |
/** * By default, don't provide any child paste override behaviour. * * @return <code>null</code>, always */ public OverridePasteChildOperation getOverrideChildPasteOperation( PasteChildOperation overriddenChildPasteOperation) { if (shouldAllowPaste(overriddenChildPasteOperation)) { EObject eObject = overriddenChildPasteOperation.getEObject(); if (eObject instanceof org.eclipse.gmf.runtime.notation.Node) { org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) eObject; EObject element = node.getElement(); if ((element != null)) { return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, true); } else { return new PositionalGeneralViewPasteOperation(overriddenChildPasteOperation, false); } } else if (eObject instanceof Edge) { return new ConnectorViewPasteOperation(overriddenChildPasteOperation); } else if (eObject instanceof Diagram) { return new DiagramPasteOperation(overriddenChildPasteOperation); } } return null; }
Example #23
Source File: ValidationMarkerProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public void clearMarkers(final Map<Diagram, DiagramEditPart> diagramsToDiagramEditPart) { final Iterator<Entry<Diagram, DiagramEditPart>> iterator = diagramsToDiagramEditPart.entrySet().iterator(); while (iterator.hasNext()) { final Entry<Diagram, DiagramEditPart> entry = iterator.next(); final Diagram d = entry.getKey(); final DiagramEditPart de = entry.getValue(); if (de != null) { final EObject resolvedSemanticElement = de.resolveSemanticElement(); if (resolvedSemanticElement instanceof MainProcess) { final IFile target = d.eResource() != null ? WorkspaceSynchronizer.getFile(d.eResource()) : null; if (target != null) { org.bonitasoft.studio.model.process.diagram.providers.ProcessMarkerNavigationProvider.deleteMarkers(target); break; } } } } }
Example #24
Source File: ProcessNavigatorLinkHelper.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public IStructuredSelection findSelection(IEditorInput anInput) { IDiagramDocument document = ProcessDiagramEditorPlugin.getInstance().getDocumentProvider() .getDiagramDocument(anInput); if (document == null) { return StructuredSelection.EMPTY; } Diagram diagram = document.getDiagram(); if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); if (file != null) { ProcessNavigatorItem item = new ProcessNavigatorItem(diagram, file, false); return new StructuredSelection(item); } return StructuredSelection.EMPTY; }
Example #25
Source File: ProcessNavigatorActionProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ public final void selectionChanged(IStructuredSelection selection) { myDiagram = null; if (selection.size() == 1) { Object selectedElement = selection.getFirstElement(); if (selectedElement instanceof ProcessNavigatorItem) { selectedElement = ((ProcessNavigatorItem) selectedElement).getView(); } else if (selectedElement instanceof IAdaptable) { selectedElement = ((IAdaptable) selectedElement).getAdapter(View.class); } if (selectedElement instanceof Diagram) { Diagram diagram = (Diagram) selectedElement; if (MainProcessEditPart.MODEL_ID.equals(ProcessVisualIDRegistry.getModelID(diagram))) { myDiagram = diagram; } } } setEnabled(myDiagram != null); }
Example #26
Source File: ProcessNavigatorActionProvider.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
/** * @generated */ private static IEditorInput getEditorInput(Diagram diagram) { Resource diagramResource = diagram.eResource(); for (EObject nextEObject : diagramResource.getContents()) { if (nextEObject == diagram) { return new FileEditorInput(WorkspaceSynchronizer.getFile(diagramResource)); } if (nextEObject instanceof Diagram) { break; } } URI uri = EcoreUtil.getURI(diagram); String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); IEditorInput editorInput = new URIEditorInput(uri, editorName); return editorInput; }
Example #27
Source File: DefaultPapyrusModelManager.java From txtUML with Eclipse Public License 1.0 | 6 votes |
@Override protected void addElementsToDiagram(Diagram diagram, IProgressMonitor monitor) { Element container = diagramManager.getDiagramContainer(diagram); AbstractDiagramElementsManager diagramElementsManager; DiagramEditPart diagep = diagramManager.getActiveDiagramEditPart(); if(diagram.getType().equals("PapyrusUMLClassDiagram")){ diagramElementsManager = new ClassDiagramElementsManager(diagep); }else if(diagram.getType().equals("PapyrusUMLActivityDiagram")){ diagramElementsManager = new ActivityDiagramElementsManager(diagep); }else if(diagram.getType().equals("PapyrusUMLStateMachineDiagram")){ diagramElementsManager = new StateMachineDiagramElementsManager(diagep); }else{ return; } List<Element> baseElements = modelManager.getAllChildrenOfPackage(container); diagramElementsManager.addElementsToDiagram(baseElements); }
Example #28
Source File: SimulationView.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void openEditorForTarget(final IDebugTarget debugTarget) { if (this.debugTarget != null && debugTarget instanceof SCTDebugTarget && ((SCTDebugTarget) debugTarget).isPrimary()) { EObject adapter = debugTarget.getAdapter(EObject.class); if (adapter instanceof Statechart) { Statechart statechart = (Statechart) adapter; Diagram diagram = DiagramPartitioningUtil.getDiagramContaining(statechart); Display.getDefault().asyncExec(new Runnable() { @Override public void run() { DiagramPartitioningUtil.openEditor(diagram); } }); } } }
Example #29
Source File: OpenDiagramEditPolicy.java From scava with Eclipse Public License 2.0 | 6 votes |
/** * @generated */ protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException { try { Diagram diagram = getDiagramToOpen(); if (diagram == null) { diagram = intializeNewDiagram(); } URI uri = EcoreUtil.getURI(diagram); String editorName = uri.lastSegment() + '#' + diagram.eResource().getContents().indexOf(diagram); IEditorInput editorInput = new URIEditorInput(uri, editorName); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); page.openEditor(editorInput, getEditorID()); return CommandResult.newOKCommandResult(); } catch (Exception ex) { throw new ExecutionException("Can't open diagram", ex); } }
Example #30
Source File: SubdiagramAwareCopyCommand.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void collectSubdiagramsInRegion(List<Diagram> subDiagrams, Region region) { for (Vertex vertex : region.getVertices()) { if (vertex instanceof State) { collectSubdiagramsInState(subDiagrams, (State) vertex); } } }