Java Code Examples for org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart#resolveSemanticElement()

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart#resolveSemanticElement() . 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: ValidationMarkerProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
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 2
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 3
Source File: TestPatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void checkGroovyExpressionModel() {
    final DiagramEditPart diagramEp = (DiagramEditPart) bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart()
            .part();
    final MainProcess diagram = (MainProcess) diagramEp.resolveSemanticElement();
    final List<Connector> connectors = ModelHelper.getAllItemsOfType(diagram, ProcessPackage.Literals.CONNECTOR);
    boolean found = false;
    for (final Connector c : connectors) {
        if (c.getName().equals("groovyDBConnector")) {
            final List<Expression> expressions = ModelHelper.getAllItemsOfType(c, ExpressionPackage.Literals.EXPRESSION);
            for (final Expression exp : expressions) {
                if (exp.getType().equals(ExpressionConstants.SCRIPT_TYPE)) {
                    found = true;
                    assertEquals("Invalid expression content", GROOVY_SQL_QUERY, exp.getContent());
                    assertEquals("Invalid expression return type", String.class.getName(), exp.getReturnType());
                    assertEquals("Invalid number of dependencies", 3, exp.getReferencedElements().size());
                    assertEquals("Invalid interpreter", ExpressionConstants.GROOVY, exp.getInterpreter());
                }
            }
        }
    }
    assertTrue("Groovy expression not found", found);
}
 
Example 4
Source File: SaveCommandHandler.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private MainProcess findProc(final IEditorPart editorPart) {
    MainProcess proc = null;
    if (editorPart instanceof ProcessDiagramEditor) {
        final DiagramEditPart diagram = ((ProcessDiagramEditor) editorPart).getDiagramEditPart();
        proc = (MainProcess) diagram.resolveSemanticElement();
    }
    return proc;
}
 
Example 5
Source File: TestPatternExpressionViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void checkPatternExpressionModel() {
    final DiagramEditPart diagramEp = (DiagramEditPart) bot.gefEditor(bot.activeEditor().getTitle()).mainEditPart()
            .part();
    final MainProcess diagram = (MainProcess) diagramEp.resolveSemanticElement();
    final List<Connector> connectors = ModelHelper.getAllItemsOfType(diagram, ProcessPackage.Literals.CONNECTOR);
    boolean found = false;
    for (final Connector c : connectors) {
        if (c.getName().equals("patternDBConnector")) {
            final List<Expression> expressions = ModelHelper.getAllItemsOfType(c, ExpressionPackage.Literals.EXPRESSION);
            for (final Expression exp : expressions) {
                if (exp.getType().equals(ExpressionConstants.PATTERN_TYPE)) {
                    found = true;
                    assertEquals("Invalid expression content", QUERY, exp.getContent());
                    assertEquals("Invalid expression return type", String.class.getName(), exp.getReturnType());
                    assertEquals("Invalid number of dependencies", 2, exp.getReferencedElements().size());
                    final org.bonitasoft.engine.expression.Expression engineExp = EngineExpressionUtil
                            .createExpression(exp);
                    assertEquals("Invalid expression convertion from studio to engine",
                            "SELECT ${" + DATA_NAME_1 + "} from MyTable WHERE ${" + DATA_NAME_2
                                    + "}='" + DATA_NAME_3 + "'",
                            engineExp.getContent());
                }
            }
        }
    }
    assertTrue("Pattern expression not found", found);
}