Exemplo n.º 1
0
    /** @generated */
    protected Diagram intializeNewDiagram() throws ExecutionException {
      Diagram d =
          ViewService.createDiagram(
              getDiagramDomainElement(), getDiagramKind(), getPreferencesHint());
      if (d == null) {
        throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind");
      }
      diagramFacet.setDiagramLink(d);
      assert diagramFacet.eResource() != null;
      diagramFacet.eResource().getContents().add(d);
      EObject container = diagramFacet.eContainer();
      while (container instanceof View) {
        ((View) container).persist();
        container = container.eContainer();
      }
      try {
        new WorkspaceModifyOperation() {

          protected void execute(IProgressMonitor monitor)
              throws CoreException, InvocationTargetException, InterruptedException {
            try {
              for (Iterator<?> it =
                      diagramFacet.eResource().getResourceSet().getResources().iterator();
                  it.hasNext(); ) {
                Resource nextResource = (Resource) it.next();
                if (nextResource.isLoaded() && !getEditingDomain().isReadOnly(nextResource)) {
                  nextResource.save(UMLDiagramEditorUtil.getSaveOptions());
                }
              }
            } catch (IOException ex) {
              throw new InvocationTargetException(ex, "Save operation failed");
            }
          }
        }.run(null);
      } catch (InvocationTargetException e) {
        throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
      } catch (InterruptedException e) {
        throw new ExecutionException("Can't create diagram of '" + getDiagramKind() + "' kind", e);
      }
      return d;
    }
Exemplo n.º 2
0
 /** @generated */
 protected EObject getDiagramDomainElement() {
   // use same element as associated with EP
   return ((View) diagramFacet.eContainer()).getElement();
 }
Exemplo n.º 3
0
 /** @generated */
 protected Diagram getDiagramToOpen() {
   return diagramFacet.getDiagramLink();
 }