Пример #1
0
    @Override
    public IStatus runInUIThread(IProgressMonitor monitor) {
      // BPMNDefineModel define = new BPMNDefineModel();
      // define.setCurrent_version_flag("Y");
      // define.setDescription("XX");
      // define.setName("Hello");
      // define.setProcess_code("007");
      // define.setProcess_version("001");
      define.setDefine(InputStreamUtil.stream2String(TestBPMN.getStream()));

      BPMService service = new BPMService(model);
      service.setServiceType(Endpoints.T_CREATE_BPM);
      // service.setBPMNDefineModel(define);
      service.setParas(makeParas(define));
      BPMServiceRunner runner = new BPMServiceRunner(service);
      BPMServiceResponse list = runner.saveBPM();
      int status = list.getStatus();
      if (BPMServiceResponse.sucess == status && list.getDefines().size() > 0) {
        List<BPMNDefineModel> defines = list.getDefines();
        BPMNDefineModel repDefine = defines.get(0);
        if (repDefine != null) {

          BPMNDefineCategory bpmnDefineCategory =
              model.getBPMNDefineCategory(repDefine.getCategory_id());
          if (bpmnDefineCategory != null) {
            bpmnDefineCategory.addDefine(repDefine);
            viewer.getTreeViewer().refresh(bpmnDefineCategory);
            viewer.getTreeViewer().expandToLevel(bpmnDefineCategory, 1);
          } else {
            model.addDefine(repDefine);
            viewer.getTreeViewer().refresh(model);
            viewer.getTreeViewer().expandToLevel(model, 1);
          }
          try {
            ByteArrayInputStream is =
                new ByteArrayInputStream(repDefine.getDefines().getBytes("UTF-8"));
            IEditorPart openEditor =
                viewer
                    .getSite()
                    .getPage()
                    .openEditor(
                        new BPMServiceInputStreamEditorInput(is), AuroraBpmnEditor.ID, true);
            if (openEditor instanceof AuroraBpmnEditor) {
              ((AuroraBpmnEditor) openEditor).setDefine(repDefine);
            }
          } catch (PartInitException e) {
            e.printStackTrace();
          } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
          }
        }

      } else {
        String serviceL = Endpoints.getSaveService(model.getHost(), "").getUrl();
        MessageDialog.openError(
            this.getDisplay().getActiveShell(), "Error", "服务" + serviceL + "未响应");
        return Status.CANCEL_STATUS;
      }
      return Status.OK_STATUS;
    }
 private static void openXmlEditor(final IFileStore fileStore, int line, int column, String name) {
   assert fileStore != null;
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   if (window != null) {
     IWorkbenchPage page = window.getActivePage();
     if (page != null) {
       try {
         if (!fileStore.getName().endsWith(".pom")) { // .pom means stuff from local repository?
           IEditorPart part = IDE.openEditorOnFileStore(page, fileStore);
           reveal(selectEditorPage(part), line, column);
         } else {
           // we need special EditorInput for stuff from repository
           name = name + ".pom"; // $NON-NLS-1$
           File file = new File(fileStore.toURI());
           try {
             IEditorInput input =
                 new MavenPathStorageEditorInput(
                     name, name, file.getAbsolutePath(), readStream(new FileInputStream(file)));
             IEditorPart part = OpenPomAction.openEditor(input, name);
             reveal(selectEditorPage(part), line, column);
           } catch (IOException e) {
             log.error("failed opening editor", e);
           }
         }
       } catch (PartInitException e) {
         MessageDialog.openInformation(
             Display.getDefault().getActiveShell(), //
             Messages.PomHyperlinkDetector_error_title,
             NLS.bind(Messages.PomHyperlinkDetector_error_message, fileStore, e.toString()));
       }
     }
   }
 }
Пример #3
0
 void createPage0() {
   try {
     xmlEditor = new XMLEditor();
     int index = addPage(xmlEditor, getEditorInput());
     setPageText(index, xmlEditor.getTitle() + " (Xml View)");
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     if (documentContent.isEmpty()) {
       documentContent = "";
       Bundle bundle = Platform.getBundle("reprotool.ide.txtspec");
       URL url = bundle.getResource("schema/default.txtspec.xml");
       try {
         InputStream ir = url.openStream();
         InputStreamReader isr = new InputStreamReader(ir);
         BufferedReader br = new BufferedReader(isr);
         String append;
         if ((documentContent = (br.readLine())) != null) ;
         while ((append = (br.readLine())) != null) documentContent += ("\n" + append);
         br.close();
       } catch (Exception e) {
         System.err.println(e.getMessage() + " " + e.getCause().toString());
       }
       documentContent = documentContent.trim();
       xmlEditor.setDocument(documentContent);
     }
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating xml text editor", null, e.getStatus());
   }
 }
Пример #4
0
 public void run() {
   try {
     if (element.getResource() instanceof IFile) {
       IFile file = (IFile) element.getResource();
       IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
       IDE.openEditor(page, file);
     } else {
       // 2012-04-13 sundl 添加处理引用包里的资源
       IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
       if (element instanceof ArchiveARESResource) {
         ArchiveARESResource aresfile = (ArchiveARESResource) element;
         ARESResourceEditorInput input = new ARESResourceEditorInput(aresfile);
         boolean active = OpenStrategy.activateOnOpen();
         try {
           IEditorDescriptor editor = IDE.getEditorDescriptor(aresfile.getElementName());
           if (editor != null) {
             IDE.openEditor(page, input, editor.getId(), active);
           }
         } catch (PartInitException e) {
           e.printStackTrace();
         }
       }
     }
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
  /**
   * @see
   *     org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   * @param event
   * @return null
   * @throws ExecutionException
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    EObject selectedObject = getSelectedElement();

    // test if this is a constraint
    if (selectedObject instanceof Constraint) {
      Constraint constraint = (Constraint) selectedObject;

      // test if this is an opaqueExpression
      if (constraint.getSpecification() instanceof OpaqueExpression) {
        OpaqueExpression opaqueExpression = ((OpaqueExpression) constraint.getSpecification());

        // look for the good body named OCL
        int indexOfOCLBody = -1;
        for (int i = 0; i < opaqueExpression.getLanguages().size() && indexOfOCLBody == -1; i++) {
          if (opaqueExpression.getLanguages().get(i).equals("OCL")) {
            indexOfOCLBody = i;
          }
        }
        if (indexOfOCLBody != -1) {
          try {
            OCLEvaluationView view =
                (OCLEvaluationView)
                    HandlerUtil.getActiveWorkbenchWindow(event)
                        .getActivePage()
                        .showView(OCLEvaluationView.ID);
            view.compute(constraint.getContext(), opaqueExpression.getBodies().get(indexOfOCLBody));
          } catch (PartInitException e) {
            e.printStackTrace();
          }
        }
      }
    }

    return null;
  }
 /** @generated */
 private static boolean openEditor(IWorkbench workbench, URI fileURI) {
   IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = workbenchWindow.getActivePage();
   IEditorDescriptor editorDescriptor =
       workbench.getEditorRegistry().getDefaultEditor(fileURI.toFileString());
   if (editorDescriptor == null) {
     MessageDialog.openError(
         workbenchWindow.getShell(),
         Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorTitle,
         NLS.bind(
             Messages.DiagramEditorActionBarAdvisor_DefaultFileEditorMessage,
             fileURI.toFileString()));
     return false;
   } else {
     try {
       page.openEditor(new URIEditorInput(fileURI), editorDescriptor.getId());
     } catch (PartInitException exception) {
       MessageDialog.openError(
           workbenchWindow.getShell(),
           Messages.DiagramEditorActionBarAdvisor_DefaultEditorOpenErrorTitle,
           exception.getMessage());
       return false;
     }
   }
   return true;
 }
  /** Creates the pages of the multi-page editor. */
  protected void createPages() {
    // Here we will create the form according to
    // ContentTypeDefinition
    InfoglueEditorInput input = getInfoglueEditorInput();

    /*
     * Create the textarea editors
     */
    EditableInfoglueContent content = input.getContent();
    for (Iterator i = content.getAttributes().iterator(); i.hasNext(); ) {
      ContentTypeAttribute attribute = (ContentTypeAttribute) i.next();
      if (attribute.getInputType().equalsIgnoreCase(ContentTypeAttribute.TEXTAREA)) {
        // Here we should wait for the file to load.
        // or dump the attribute here instead of in filehelper
        createStructuredEditor(attribute);
      }
    }

    /*
     * Create the form editor
     */
    formEditor = new InfoglueFormEditor();
    try {
      int index = addPage(formEditor, input);
      setPageText(index, "Properties");

    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    // setTitle(content.getName());
    setPartName(content.getName());
  }
Пример #8
0
  private void openSelectedMarker() {
    ISelection sel = tableViewer.getSelection();

    if (sel instanceof IStructuredSelection) {
      Object element = ((IStructuredSelection) sel).getFirstElement();

      if (element instanceof IMarker) {
        IMarker marker = (IMarker) element;

        if (marker.getResource() instanceof IFile) {
          try {
            IDE.openEditor(getViewSite().getPage(), marker);
          } catch (PartInitException e) {
            ErrorDialog.openError(
                getSite().getShell(),
                "Error Opening Marker",
                "Unable to open an editor for the given marker: " + e.getClass().getSimpleName(),
                new Status(IStatus.ERROR, DartToolsPlugin.PLUGIN_ID, e.toString(), e));

            DartToolsPlugin.log(e);
          }
        }
      }
    }
  }
 private void setSelectedEditor(String fileName) {
   outer:
   for (IWorkbenchWindow w : PlatformUI.getWorkbench().getWorkbenchWindows()) {
     for (IWorkbenchPage p : w.getPages()) {
       for (IEditorReference e : p.getEditorReferences()) {
         try {
           if (e.getEditorInput() instanceof IFileEditorInput) {
             IFileEditorInput editorInput = (IFileEditorInput) e.getEditorInput();
             if (editorInput.getFile().getParent().findMember("opaeum.properties") != null) {
               for (IResource r : editorInput.getFile().getParent().members()) {
                 if (r.getName().equals(fileName)) {
                   selectedEditor = e.getEditor(true);
                   break outer;
                 }
               }
             }
           }
         } catch (PartInitException e1) {
           e1.printStackTrace();
         } catch (CoreException e2) {
           e2.printStackTrace();
         }
       }
     }
   }
 }
  @Override
  public void run(IAction action) {
    UserDBDAO userDB = (UserDBDAO) sel.getFirstElement();

    if (DBDefine.getDBDefine(userDB) == DBDefine.MYSQL_DEFAULT
        || DBDefine.getDBDefine(userDB) == DBDefine.MARIADB_DEFAULT
        || DBDefine.getDBDefine(userDB) == DBDefine.ORACLE_DEFAULT
        || DBDefine.getDBDefine(userDB) == DBDefine.MSSQL_DEFAULT) {

      try {
        SessionListEditorInput sleInput = new SessionListEditorInput(userDB);
        PlatformUI.getWorkbench()
            .getActiveWorkbenchWindow()
            .getActivePage()
            .openEditor(sleInput, SessionListEditor.ID);
      } catch (PartInitException e) {
        logger.error("open session list", e); // $NON-NLS-1$

        Status errStatus =
            new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e); // $NON-NLS-1$
        ExceptionDetailsErrorDialog.openError(
            null, "Error", Messages.AbstractQueryAction_1, errStatus); // $NON-NLS-1$
      }
    } else {
      MessageDialog.openWarning(null, "Information", "Not support database.");
    }
  }
  @Override
  public boolean matches(IEditorReference editorRef, IEditorInput input) {
    IQ7Element inputElement = getElement(input);
    if (inputElement != null && editorRef.getId().startsWith("org.eclipse.rcptt.ui.editors")) {
      IWorkbenchPart part = editorRef.getPart(false);
      if (part instanceof EclEditor) {
        IQ7NamedElement model = ((EclEditor) part).getModel();
        if (model != null) {
          return inputElement.equals(model);
        }
      } else if (part instanceof NamedElementEditor) {
        IQ7NamedElement model = ((NamedElementEditor) part).getModel();
        if (model != null) {
          return inputElement.equals(model);
        }
      }

      // try figure out using ref editor input
      IEditorInput editRefInput;
      try {
        editRefInput = editorRef.getEditorInput();
        if (editRefInput != null) {
          IQ7Element refElement = getElement(editRefInput);
          return inputElement.equals(refElement);
        }
      } catch (PartInitException e) {
        RcpttPlugin.log(e.getMessage(), e);
      }
    }
    return false;
  }
  private static void getOpenTabs(IWorkbenchWindow window) {
    openTabs.clear();
    WorkbenchPage activePage = (WorkbenchPage) window.getActivePage();
    IEditorReference[] editorRefs = ((WorkbenchPage) activePage).getSortedEditors();

    // WorkbenchPage.getSortedEditors() returns the editors in activation order (oldest
    // first). We want most recently activated to be first, so reverse the list.
    List<IEditorReference> editorRefsAsList = Arrays.asList(editorRefs);
    Collections.reverse(editorRefsAsList);

    try {
      for (IEditorReference ref : editorRefsAsList) {
        if (ref.getEditorInput() instanceof FileEditorInput) {
          IFile file = ((FileEditorInput) ref.getEditorInput()).getFile();
          IJavaElement editorElt = JavaCore.create(file);
          if (editorElt instanceof ICompilationUnit) {
            openTabs.addAll(Arrays.asList(((ICompilationUnit) editorElt).getAllTypes()));
          }
        }
      }
    } catch (PartInitException e) {
      System.out.print("Exception while getting all open tabs. " + e.getMessage());
      e.printStackTrace();
    } catch (JavaModelException e) {
      System.out.print("Exception while getting all open tabs. " + e.getMessage());
      e.printStackTrace();
    }
  }
Пример #13
0
 private void openFile(File file, DotGraphView view) {
   if (view.currentFile == null) { // no workspace file for cur. graph
     IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path("")); // $NON-NLS-1$
     fileStore = fileStore.getChild(file.getAbsolutePath());
     if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
       IWorkbenchPage page = view.getSite().getPage();
       try {
         IDE.openEditorOnFileStore(page, fileStore);
       } catch (PartInitException e) {
         e.printStackTrace();
       }
     }
   } else {
     IWorkspace workspace = ResourcesPlugin.getWorkspace();
     IPath location = Path.fromOSString(file.getAbsolutePath());
     IFile copy = workspace.getRoot().getFileForLocation(location);
     IEditorRegistry registry = PlatformUI.getWorkbench().getEditorRegistry();
     if (registry.isSystemExternalEditorAvailable(copy.getName())) {
       try {
         view.getViewSite()
             .getPage()
             .openEditor(new FileEditorInput(copy), IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
       } catch (PartInitException e) {
         e.printStackTrace();
       }
     }
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
   */
  public Object execute(ExecutionEvent event) throws ExecutionException {
    Project p = MovieUtil.getActiveProject();
    if (p != null) {
      EList<Movie> movies =
          p.getAllModelElementsbyClass(MoviesPackage.eINSTANCE.getMovie(), new BasicEList<Movie>());
      for (Iterator<Movie> iter = movies.iterator(); iter.hasNext(); ) {
        if (iter.next().getOverallRating() == "ZERO"
            || iter.next().getOverallRating() == "ONE"
            || iter.next().getOverallRating() == "TWO") {
          iter.remove();
        }
      }

      // Open Movies View and set input
      try {
        IViewPart view =
            PlatformUI.getWorkbench()
                .getActiveWorkbenchWindow()
                .getActivePage()
                .showView(MoviesView.ID);
        if (view instanceof MoviesView) {
          MoviesView moviesView = (MoviesView) view;
          moviesView.setInput(movies);
        }
      } catch (PartInitException e) {
        // showView() can throw an exception if view cannot be shown
        e.printStackTrace();
      }
    }
    return null;
  }
Пример #15
0
 /**
  * Open commit in editor
  *
  * @param commit
  * @param activateOnOpen <code>true</code> if the newly opened editor should be activated
  * @return opened editor part or null if opening fails
  * @since 2.1
  */
 public static final IEditorPart openQuiet(RepositoryCommit commit, boolean activateOnOpen) {
   try {
     return open(commit, activateOnOpen);
   } catch (PartInitException e) {
     Activator.logError(e.getMessage(), e);
     return null;
   }
 }
 void createPage(IEditorPart editor, IEditorInput input) {
   try {
     int index = addPage(editor, input);
     setPageText(index, editor.getTitle());
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
   }
 }
Пример #17
0
 public static void openEditor(IFile file, int offset, int length) {
   IEditorPart ep = null;
   try {
     ep = EditorUtility.openInEditor(file);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   if (ep != null) EditorUtility.revealInEditor(ep, offset, length);
 }
Пример #18
0
 public void run(IAction action) {
   try {
     view.getViewSite().getWorkbenchWindow().getActivePage().showView(DatabaseBrowserView.ID);
   } catch (PartInitException e) {
     e.printStackTrace();
     String message = Messages.OpenInBrowserViewAction__errmsg_open_dbview;
     ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, DatabasePlugin.PLUGIN_ID, e);
   }
 }
Пример #19
0
 @Override
 protected void addPages() {
   try {
     addPage(dpage);
     addPage(epage);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
 /**
  * Creates page 1 of the multi-page editor, which allows you to change the font used in page 2.
  */
 void createPage1() {
   try {
     m_editor = new TextEditor();
     int index = addPage(m_editor, getEditorInput());
     setPageText(index, m_editor.getTitle());
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
Пример #21
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   try {
     PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FigureView.ID);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return null;
 }
Пример #22
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
  */
 @Override
 public void run(IAction action) {
   // TODO Auto-generated method stub
   try {
     window.getActivePage().showView("oraclePlugin.PaneView");
   } catch (PartInitException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
 }
Пример #23
0
 void createPage1() {
   try {
     TSEditor = new TxtSpecEditor(xmlEditor.getDocument());
     int index = addPage(TSEditor, getEditorInput());
     setPageText(index, TSEditor.getTitle() + " (TextSpec View)");
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating TextSpec Editor", null, e.getStatus());
   }
 }
 private void openFile() {
   final IFile resource = BPELResourceAdapterFactory.getFileForObject(_implementation, _project);
   if (resource != null) {
     try {
       IDE.openEditor(getPart().getSite().getPage(), resource);
     } catch (PartInitException e) {
       Activator.getDefault().getLog().log(e.getStatus());
     }
   }
 }
Пример #25
0
 public void run() {
   if (window != null) {
     try {
       window
           .getActivePage()
           .showView(viewId, Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE);
     } catch (PartInitException e) {
       MessageDialog.openError(window.getShell(), "Error", "Error opening view:" + e.getMessage());
     }
   }
 }
Пример #26
0
 public static void show() {
   IWorkbench wb = PlatformUI.getWorkbench();
   IWorkbenchPage wbPage = wb.getActiveWorkbenchWindow().getActivePage();
   if (wbPage != null) {
     try {
       IConsoleView conView = (IConsoleView) wbPage.showView(IConsoleConstants.ID_CONSOLE_VIEW);
       conView.display(getRhinoConsole());
     } catch (PartInitException e) {
       PluginLogger.log("Console.show() - PartInitException: " + e.getMessage());
     }
   }
 }
Пример #27
0
  private void showConsole(MessageConsole myConsole) {
    try {
      IConsoleView view;
      IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();

      String id = IConsoleConstants.ID_CONSOLE_VIEW;
      view = (IConsoleView) win.getActivePage().showView(id);
      view.display(myConsole);
    } catch (PartInitException e) {
      e.printStackTrace();
    }
  }
Пример #28
0
 public static void openARESConsole() {
   IConsole myConsole = getConsole();
   IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
   String id = IConsoleConstants.ID_CONSOLE_VIEW;
   IConsoleView view;
   try {
     view = (IConsoleView) page.showView(id, null, IWorkbenchPage.VIEW_CREATE);
     view.display(myConsole);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
Пример #29
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   IWorkbench workbench = PlatformUI.getWorkbench();
   IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
   IWorkbenchPage page = window.getActivePage();
   try {
     page.showView(PvSearchView.VIEW_ID);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return null;
 }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   try {
     PlatformUI.getWorkbench()
         .getActiveWorkbenchWindow()
         .getActivePage()
         .showView("com.sap.dirigible.ide.publish.ui.view.RuntimeViewerView"); // $NON-NLS-1$
   } catch (PartInitException e) {
     logger.error(e.getMessage(), e);
   }
   return null;
 }