org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor Java Examples

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor. 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: ProcessElementNameContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void editDiagramAndPoolNameAndVersion() {
    final MainProcess diagram = ModelHelper.getMainProcess(element);
    final DiagramRepositoryStore diagramStore = RepositoryManager.getInstance()
            .getRepositoryStore(DiagramRepositoryStore.class);
    final OpenNameAndVersionForDiagramDialog nameDialog = new OpenNameAndVersionForDiagramDialog(
            Display.getDefault().getActiveShell(), diagram,
            diagramStore);
    if (nameDialog.open() == Dialog.OK) {
        final DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                .getActiveEditor();
        final MainProcess newProcess = (MainProcess) editor.getDiagramEditPart().resolveSemanticElement();
        editingDomain.getCommandStack().execute(
                SetCommand.create(editingDomain, newProcess, ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR,
                        System.getProperty("user.name", "Unknown")));
        final String oldName = newProcess.getName();
        final String oldVersion = newProcess.getVersion();
        if (new Identifier(oldName, oldVersion).equals(nameDialog.getIdentifier())) {
            renamePoolsOnly(nameDialog, editor, newProcess);
        } else {
            editor.doSave(Repository.NULL_PROGRESS_MONITOR);
            renameDiagramAndPool(nameDialog, editor, newProcess);
        }
    }
}
 
Example #2
Source File: TimerEventConditionContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void refresh() {
Expression condition = eObject.getCondition();
if (condition != null) {
    String conditionLabel = groovyToLabel(condition);
    conditionViewer.setText(conditionLabel != null ? conditionLabel : "");

    DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
	    .getActiveEditor();
    if (editor != null) {
	EditPart ep = GMFTools.findEditPart(editor.getDiagramEditPart(), eObject);
	if (ep != null) {
	    if (!ep.getChildren().isEmpty()) {
		((LabelEditPart) ep.getChildren().get(0)).refresh();
	    }
	}
    }
}
   }
 
Example #3
Source File: DiagramFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Resource getEMFResource() {
    final DiagramEditor editor = getOpenedEditor();
    if (editor != null) {
        final DiagramEditPart diagramEditPart = editor.getDiagramEditPart();
        if (diagramEditPart != null) {
            final EObject resolveSemanticElement = diagramEditPart.resolveSemanticElement();
            if (resolveSemanticElement != null && resolveSemanticElement.eResource() != null) {
                return resolveSemanticElement.eResource();
            }
        }
    }
    final URI uri = getResourceURI();
    final EditingDomain editingDomain = getParentStore().getEditingDomain(uri);
    final ResourceSet resourceSet = editingDomain.getResourceSet();
    if (getResource().exists()) {
        Resource resource = resourceSet.getResource(uri, false);
        if (resource == null) {
            resource = resourceSet.createResource(uri);
        }
        return resource;
    }
    return super.getEMFResource();
}
 
Example #4
Source File: ProcessSelector.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public AbstractProcess getSelectedProcess() {
    Optional<AbstractProcess> processFromEvent = getProcessFromEvent();
    if (processFromEvent.isPresent()) {
        return processFromEvent.get();
    }
    final IEditorPart editor = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getActiveEditor();
    final boolean isADiagram = editor != null && editor instanceof DiagramEditor;
    if (isADiagram) {
        final List<?> selectedEditParts = ((DiagramEditor) editor).getDiagramGraphicalViewer()
                .getSelectedEditParts();
        if (selectedEditParts != null && !selectedEditParts.isEmpty()) {
            final Object selectedEp = selectedEditParts.iterator().next();
            if (selectedEp != null) {
                return ModelHelper.getParentProcess(((IGraphicalEditPart) selectedEp).resolveSemanticElement());
            }
        } else {
            final EObject element = ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement();
            return ModelHelper.getParentProcess(element);
        }
    }
    return null;
}
 
Example #5
Source File: DiagramFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@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 #6
Source File: NewDiagramCommandHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public DiagramFileStore execute(final ExecutionEvent event) throws ExecutionException {
    final DiagramFileStore diagramFileStore = newDiagram();
    Display.getDefault().asyncExec(() -> {
            final IEditorPart editor = (IEditorPart) diagramFileStore.open();
            if (editor instanceof DiagramEditor) {
                final String author = System.getProperty("user.name", "unknown");
                final TransactionalEditingDomain editingDomain = TransactionUtil
                        .getEditingDomain(diagramFileStore.getEMFResource());
                editingDomain.getCommandStack().execute(
                        SetCommand.create(editingDomain,
                                ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement(),
                                ProcessPackage.Literals.ABSTRACT_PROCESS__AUTHOR, author));
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().activate(editor);
            }
    });
    return diagramFileStore;
}
 
Example #7
Source File: ConfigureHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
private AbstractProcess getSelectedProcess() {
    if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
            && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
        final IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
        if (part != null && part instanceof DiagramEditor) {
            final DiagramEditPart diagramEditPart = ((DiagramEditor) part).getDiagramEditPart();
            if (diagramEditPart != null) {
                final List selection = ((DiagramEditor) part).getDiagramGraphicalViewer().getSelectedEditParts();
                if (!selection.isEmpty() && selection.get(0) instanceof IGraphicalEditPart) {
                    final IGraphicalEditPart selectedPart = (IGraphicalEditPart) selection.get(0);
                    return ModelHelper.getParentProcess(selectedPart.resolveSemanticElement());
                }
            }
        }
    }
    return null;
}
 
Example #8
Source File: ProcessElementNameContribution.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void renamePoolsOnly(final OpenNameAndVersionForDiagramDialog nameDialog, final DiagramEditor editor,
        final MainProcess newProcess) {
    editor.doSave(Repository.NULL_PROGRESS_MONITOR);
    final Identifier identifier = nameDialog.getIdentifier();
    processNamingTools.changeProcessNameAndVersion(newProcess, identifier.getName(), identifier.getVersion());
    for (final ProcessesNameVersion pnv : nameDialog.getPools()) {
        processNamingTools.changeProcessNameAndVersion(pnv.getAbstractProcess(), pnv.getNewName(), pnv.getNewVersion());
    }
    try {
        final ICommandService service = PlatformUI.getWorkbench().getService(ICommandService.class);
        final org.eclipse.core.commands.Command c = service.getCommand("org.eclipse.ui.file.save");
        if (c.isEnabled()) {
            c.executeWithChecks(new ExecutionEvent());
        }
    } catch (final Exception e) {
        BonitaStudioLog.error(e);
    }
}
 
Example #9
Source File: DiagramFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void setReadOnly(final boolean readOnly) {
    super.setReadOnly(readOnly);
    final DiagramEditor openedEditor = getOpenedEditor();
    if (openedEditor != null) {
        if (openedEditor.getDiagramEditPart() != null) {
            if (readOnly) {
                openedEditor.getDiagramEditPart().disableEditMode();
            } else {
                openedEditor.getDiagramEditPart().enableEditMode();
            }
        }
        if (openedEditor instanceof ProcessDiagramEditor) {
            ((ProcessDiagramEditor) openedEditor).setReadOnly(readOnly);
        }
    }
}
 
Example #10
Source File: ExtensibleGridPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void selectionChanged(final SelectionChangedEvent event) {
    if (part != null) {
	if (part instanceof DiagramEditor) {
	    /*
	     * in order to avoid to polute log on each diagram switch between process/form
	     * we need to not called setInput if getEditingDomain throws a NPE
	     */
	    // TODO : find a more elegant way to handle this (override ghetEditingDomain in
	    // ProcessDiagramEditor/FormDiagramEditor?) or far better solve the above todo
	    try {
		((DiagramEditor) part).getEditingDomain();
	    } catch (final NullPointerException e) {
		return;
	    }
	    setInput(part, event.getSelection());
	}
    }

}
 
Example #11
Source File: ProcessMarkerNavigationProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected void doGotoMarker(IMarker marker) {
	String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
	if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
		return;
	}
	DiagramEditor editor = (DiagramEditor) getEditor();
	Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
	EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
	if (targetView == null) {
		return;
	}
	EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
	if (targetEditPart != null) {
		ProcessDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
	}
}
 
Example #12
Source File: SaveAsImageHandler.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    //Remove Selection
    final DiagramEditor editor = (DiagramEditor) activePage.getActiveEditor();
    editor.getDiagramGraphicalViewer().setSelection(new StructuredSelection());
    final CopyToImageAction act = new CopyToImageAction(activePage) {

        @Override
        protected List createOperationSet() {
            if (getWorkbenchPart() instanceof DiagramEditor) {
                return Collections.singletonList(((DiagramEditor) getWorkbenchPart()).getDiagramEditPart());
            }
            return Collections.emptyList();
        }

        @Override
        protected void setWorkbenchPart(final IWorkbenchPart workbenchPart) {
            super.setWorkbenchPart(getWorkbenchPage().getActiveEditor());
        }

    };
    act.init();
    act.run();
    return null;
}
 
Example #13
Source File: ExtendendResourceLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void activateEditor(IWorkbenchPage aPage, IStructuredSelection aSelection) {
    if (aSelection == null || aSelection.isEmpty())
        return;
    if (aSelection.getFirstElement() instanceof IFile) {
        DiagramRepositoryStore store = RepositoryManager.getInstance().getCurrentRepository()
                .getRepositoryStore(DiagramRepositoryStore.class);
        IFile file = (IFile) aSelection.getFirstElement();
        DiagramFileStore fStore = store.getChild(file.getName(), true);
        if (fStore != null) {
            DiagramEditor openedEditor = fStore.getOpenedEditor();
            if (openedEditor != null) {
                aPage.bringToTop(openedEditor);
            }
        } else {
            super.activateEditor(aPage, aSelection);
        }
    } else {
        super.activateEditor(aPage, aSelection);
    }
}
 
Example #14
Source File: MigrationStatusView.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void createPartControl(final Composite parent) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().extendedMargins(0, 0, 0, 5).create());

    createTopComposite(mainComposite);
    createTableComposite(mainComposite);
    createBottomComposite(mainComposite);

    final ISelectionService ss = getSite().getWorkbenchWindow().getSelectionService();
    ss.addPostSelectionListener(this);
    final IEditorPart activeEditor = getSite().getPage().getActiveEditor();
    if (activeEditor instanceof DiagramEditor) {
        selectionProvider = activeEditor.getEditorSite().getSelectionProvider();
    }
    getSite().setSelectionProvider(this);
    createActions();
}
 
Example #15
Source File: AbstractLiveValidationMarkerConstraint.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private View getViewFor(final DiagramEditor editor, EObject validatedObject) {
    if (editor instanceof ProcessDiagramEditor) {
        if (!(validatedObject instanceof FlowElement
                || validatedObject instanceof BoundaryEvent
                || validatedObject instanceof Container
                || validatedObject instanceof Connection)) {
            validatedObject = ModelHelper.getParentFlowElement(validatedObject);
        }
    }
    for (final Object ep : editor.getDiagramGraphicalViewer().getEditPartRegistry().values()) {
        if (!(ep instanceof ITextAwareEditPart) && !(ep instanceof ShapeCompartmentEditPart) && ep instanceof IGraphicalEditPart
                && ((IGraphicalEditPart) ep).resolveSemanticElement() != null && ((IGraphicalEditPart) ep).resolveSemanticElement().equals(validatedObject)) {
            return ((IGraphicalEditPart) ep).getNotationView();
        }
    }
    return null;
}
 
Example #16
Source File: MigrationStatusView.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("rawtypes")
@Override
public Object getAdapter(final Class adapter) {
    if (adapter == IPropertySheetPage.class) {
        return getSite().getPage().getActiveEditor().getAdapter(adapter);
    } else if (adapter == IEditingDomainProvider.class) {
        return new IEditingDomainProvider() {

            @Override
            public EditingDomain getEditingDomain() {
                final IEditorPart part = getSite().getPage().getActiveEditor();
                if (part instanceof DiagramEditor) {
                    return ((DiagramEditor) part).getEditingDomain();
                }
                return null;
            }
        };
    }
    return super.getAdapter(adapter);
}
 
Example #17
Source File: CrossflowMarkerNavigationProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected void doGotoMarker(IMarker marker) {
	String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
	if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
		return;
	}
	DiagramEditor editor = (DiagramEditor) getEditor();
	Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
	EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
	if (targetView == null) {
		return;
	}
	EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
	if (targetEditPart != null) {
		CrossflowDiagramEditorUtil.selectElementsInDiagram(editor,
				Arrays.asList(new EditPart[] { targetEditPart }));
	}
}
 
Example #18
Source File: ExtensibleGridPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
   public void setInput(final IWorkbenchPart part, final ISelection selection) {
super.setInput(part, selection);
for (final IExtensibleGridPropertySectionContribution contrib : contributions) {
    if (contrib.isRelevantFor(getEObject())) {
	contrib.setSelection(selection);
    }
}
if (part instanceof DiagramEditor) {
    this.part = part;
    ((DiagramEditor) part).getDiagramGraphicalViewer().removeSelectionChangedListener(selectionListener);
    ((DiagramEditor) part).getDiagramGraphicalViewer().addSelectionChangedListener(selectionListener);
}
   }
 
Example #19
Source File: BonitaContentOutlineTreeView.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected PageRec doCreatePage(IWorkbenchPart part) {
    Object obj = Adapters.adapt(part, IContentOutlinePage.class, false);
    if (obj instanceof IContentOutlinePage && part instanceof DiagramEditor) {
        TreeViewer viewer = new TreeViewer();
        viewer.setRootEditPart(new DiagramRootTreeEditPart());
        IContentOutlinePage page = new BonitaTreeOutlinePage(viewer, (DiagramEditor) part);
        if (page instanceof IPageBookViewPage) {
            initPage((IPageBookViewPage) page);
        }
        page.createControl(getPageBook());
        return new PageRec(part, page);
    }
    return null;
}
 
Example #20
Source File: BonitaContentOutlineView.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected PageRec doCreatePage(IWorkbenchPart part) {
    Object obj = Adapters.adapt(part, IContentOutlinePage.class, false);
    if (obj instanceof IContentOutlinePage && part instanceof DiagramEditor) {
        return super.doCreatePage(part);
    }
    return null;
}
 
Example #21
Source File: PrintCommandHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
    final IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (activeEditor instanceof DiagramEditor) {
        ((DiagramEditor) activeEditor).getDiagramGraphicalViewer().deselectAll();
    }
    printAction.run();
    return Status.OK_STATUS;
}
 
Example #22
Source File: CustomEnhancedPrintActionHelper.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void doPrint(IWorkbenchPart workbenchPart) {
	if (workbenchPart instanceof DiagramEditor) {
		super.doPrint(workbenchPart);
	}
	else {
		workbenchPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
		super.doPrint(workbenchPart);
	}
	
}
 
Example #23
Source File: ProcessSelector.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public static MainProcess getProcessInEditor() {
    final IEditorPart editor = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage().getActiveEditor();
    final boolean isADiagram = editor != null && editor instanceof DiagramEditor;
    if (isADiagram) {
        final EObject root = ((DiagramEditor) editor).getDiagramEditPart().resolveSemanticElement();
        final MainProcess mainProc = ModelHelper.getMainProcess(root);
        return mainProc;
    }

    return null;
}
 
Example #24
Source File: UpdateMessageCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void editMessageFlow(Message message, DiagramEditor editor, AbstractCatchMessageEvent catchEvent) {
    if (isOnDiagram(catchEvent)) {
        MessageFlowFactory.editMessageFlowName(message, catchEvent, editor.getDiagramEditPart());
        SetCommand updateCatchMessageEventCommand = new SetCommand(domain, catchEvent,
                ProcessPackage.Literals.ABSTRACT_CATCH_MESSAGE_EVENT__EVENT, message.getName());
        domain.getCommandStack().execute(updateCatchMessageEventCommand);
    }
}
 
Example #25
Source File: UpdateMessageCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void updateMessageFlows(Message message, AbstractCatchMessageEvent oldCatchMessageEvent, DiagramEditor editor) {
    if (shouldReplaceMessageFlow(message, oldCatchMessageEvent)) {
        removeMessageFlow(editor, oldCatchMessageEvent);
        findCatchEvent(message)
                .ifPresent(newCatchEvent -> createMessageFlow(message, editor, newCatchEvent));
    } else {
        editMessageFlow(message, editor, oldCatchMessageEvent);
    }
}
 
Example #26
Source File: UpdateMessageCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    Optional<AbstractCatchMessageEvent> oldCatchMessageEvent = findCatchEvent(message);
    emfModelUpdater.update();
    DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActiveEditor();
    if (oldCatchMessageEvent.isPresent()) {
        updateMessageFlows(message, oldCatchMessageEvent.get(), editor);
    } else {
        findCatchEvent(message).ifPresent(newCatchEvent -> createMessageFlow(message, editor, newCatchEvent));
    }
}
 
Example #27
Source File: AddMessageCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    message.setName(messageWorkingCopy.getName());
    message.setDocumentation(messageWorkingCopy.getDocumentation());
    message.setThrowEvent(messageWorkingCopy.getThrowEvent());
    message.setTtl(messageWorkingCopy.getTtl());
    message.setTargetElementExpression(messageWorkingCopy.getTargetElementExpression());

    Expression targetProcessName = messageWorkingCopy.getTargetProcessExpression();
    if (targetProcessName != null && targetProcessName.getContent() != null
            && !targetProcessName.getContent().isEmpty()) {
        for (AbstractCatchMessageEvent ev : ModelHelper
                .getAllCatchEvent(ModelHelper.getMainProcess(throwMessageEvent))) {
            if (messageWorkingCopy.getTargetProcessExpression() != null && ModelHelper.getParentProcess(ev).getName()
                    .equals(messageWorkingCopy.getTargetProcessExpression().getContent())) {
                if (ev.getName().equals(message.getTargetElementExpression().getContent())) {
                    ev.setEvent(message.getName());
                }
            }
        }
    }
    message.setTargetProcessExpression(EcoreUtil.copy(targetProcessName));
    message.setCorrelation(messageWorkingCopy.getCorrelation());
    message.setMessageContent(messageWorkingCopy.getMessageContent());

    throwMessageEvent.getEvents().add(message);

    DiagramEditor editor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
            .getActiveEditor();
    findCatchEvent(message)
            .ifPresent(catchEvent -> createMessageFlow(messageWorkingCopy, editor, catchEvent));
}
 
Example #28
Source File: PoolGeneralPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void updateProcessName(String oldName, String newName) {
    Pool pool = (Pool) selectionProvider.getAdapter(EObject.class);
    processNamingTools.proceedForPools(pool, newName, oldName, pool.getVersion(), pool.getVersion());
    updateMessageEvents(pool);
    updatePropertyTabTitle(newName);
    Display.getDefault().asyncExec(() -> {
        DiagramEditor activeEditor = (DiagramEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                .getActivePage().getActiveEditor();
        activeEditor.getDiagramGraphicalViewer().getContents().refresh();
    });
}
 
Example #29
Source File: AbstractLiveValidationMarkerConstraint.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addMarker(final DiagramEditor editor, final EditPartViewer viewer, final IFile target,
        final String elementId, final String location, final String message,
        final int statusSeverity) {
    if (target == null) {
        return;
    }
    IMarker marker = null;
    try {
        marker = target.createMarker(getMarkerType(editor));
        marker.setAttribute(IMarker.MESSAGE, message);
        marker.setAttribute(IMarker.LOCATION, location);
        marker.setAttribute(
                org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID,
                elementId);
        marker.setAttribute(CONSTRAINT_ID, getConstraintId());
        int markerSeverity = IMarker.SEVERITY_INFO;
        if (statusSeverity == IStatus.WARNING) {
            markerSeverity = IMarker.SEVERITY_WARNING;
        } else if (statusSeverity == IStatus.ERROR
                || statusSeverity == IStatus.CANCEL) {
            markerSeverity = IMarker.SEVERITY_ERROR;
        }
        marker.setAttribute(IMarker.SEVERITY, markerSeverity);
    } catch (final CoreException e) {
        ProcessDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$
    }
}
 
Example #30
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void selectionChanged(final SelectionChangedEvent event) {
    if (event.getSelection() instanceof StructuredSelection
            && ((StructuredSelection) event.getSelection()).getFirstElement() instanceof Marker) {
        final Marker m = (Marker) ((StructuredSelection) event.getSelection())
                .getFirstElement();
        final String elementId = m.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
        if (elementId == null
                || !(getSite().getPage().getActiveEditor() instanceof DiagramEditor)) {
            return;
        }
        final DiagramEditor editor = (DiagramEditor) getSite().getPage()
                .getActiveEditor();
        final Map editPartRegistry = editor.getDiagramGraphicalViewer()
                .getEditPartRegistry();
        final EObject targetView = editor.getDiagram().eResource()
                .getEObject(elementId);
        if (targetView == null) {
            return;
        }
        final EditPart targetEditPart = (EditPart) editPartRegistry
                .get(targetView);
        if (targetEditPart != null) {
            ProcessDiagramEditorUtil.selectElementsInDiagram(editor,
                    Arrays.asList(new EditPart[] { targetEditPart }));
        }
    }

}