Esempio n. 1
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();
   }
 }
Esempio n. 2
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();
       }
     }
   }
 }
  /**
   * @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;
  }
  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();
    }
  }
    @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;
    }
  /** 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());
  }
  /*
   * (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;
  }
 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();
         }
       }
     }
   }
 }
  /**
   * The action has been activated. The argument of the method represents the 'real' action sitting
   * in the workbench UI.
   *
   * @see IWorkbenchWindowActionDelegate#run
   */
  public void run(IAction action) {

    //
    //	<http://stackoverflow.com/questions/18151203/eclipse-plugin-how-to-open-standard-view-like-internalwebbrowser-with-java>
    //
    //			To open the `Internal Browser` you need this code:
    //
    //			    int style = IWorkbenchBrowserSupport.AS_EDITOR | IWorkbenchBrowserSupport.LOCATION_BAR
    // | IWorkbenchBrowserSupport.STATUS;
    //			    IWebBrowser browser = WorkbenchBrowserSupport.getInstance().createBrowser(style,
    // "MyBrowserID", "MyBrowserName", "MyBrowser Tooltip");
    //			    browser.openURL(new URL("http://www.google.de"));
    //
    //			Alternative:
    //
    //			    final IWebBrowser browser =
    // PlatformUI.getWorkbench().getBrowserSupport().createBrowser("abc");
    //			    browser.openURL(new URL("http://www.google.de"));

    int style =
        IWorkbenchBrowserSupport.AS_EDITOR
            | IWorkbenchBrowserSupport.LOCATION_BAR
            | IWorkbenchBrowserSupport.NAVIGATION_BAR
            | IWorkbenchBrowserSupport.STATUS;
    IWebBrowser browser;
    try {
      browser =
          WorkbenchBrowserSupport.getInstance()
              .createBrowser(
                  style,
                  Constants.LIST_BROWSER_ID,
                  Constants.LIST_BROWSER_NAME,
                  Constants.LIST_BROWSER_TOOLTIP);
    } catch (PartInitException e) {
      e.printStackTrace();
      MessageDialog.openError(
          window.getShell(),
          Constants.ERROR1_MESSAGE,
          Constants.ERROR1_MESSAGE + " to show " + Constants.LIST_BROWSER_NAME);
      return;
    }
    try {
      browser.openURL(Constants.listUrl);
    } catch (PartInitException e) {
      e.printStackTrace();
    }
  }
 @Override
 public void run() {
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   Assert.isNotNull(window);
   Shell shell = window.getShell();
   if (status.getSeverity() == IStatus.ERROR) {
     MessageDialog.openError(shell, "文件转换失败", status.getMessage());
   } else {
     // 转换完成后直接打开编辑器,不再进行弹框提示。
     // MessageDialog.openInformation(shell, "文件转换完成", status.getMessage());
     final String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor";
     String xliffFile = conversionResult.get(Converter.ATTR_XLIFF_FILE);
     IWorkbenchPage page = window.getActivePage();
     Assert.isNotNull(page, "当前的 Active Page 为 null。无法打开转换后的文件。");
     if (xliffFile != null) {
       IEditorDescriptor editorDescriptor =
           PlatformUI.getWorkbench().getEditorRegistry().findEditor(XLIFF_EDITOR_ID);
       if (editorDescriptor != null) {
         try {
           IDE.openEditor(page, new File(xliffFile).toURI(), XLIFF_EDITOR_ID, true);
         } catch (PartInitException e) {
           MessageDialog.openInformation(
               shell, "提示", "转换完成!但是在尝试打开该 XLIFF 文件时发生异常:\n" + e.getMessage());
           e.printStackTrace();
         }
       }
     } else {
       String targetFile = conversionResult.get(Converter.ATTR_TARGET_FILE);
       if (targetFile == null) {
         MessageDialog.openError(shell, "错误", "为找到已转换文件的路径!");
       } else {
         IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
         IFile input = root.getFileForLocation(new Path(targetFile));
         try {
           // 使用外部编辑器(系统默认编辑器)打开文件。
           IDE.openEditor(page, input, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
         } catch (PartInitException e) {
           MessageDialog.openInformation(
               shell, "提示", "转换完成!但是在尝试使用系统默认程序打开该文件时发生异常:\n" + e.getMessage());
           e.printStackTrace();
         }
       }
     }
   }
 }
 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);
   }
 }
 /**
  * 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();
   }
 }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   try {
     PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(FigureView.ID);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 14
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);
 }
Esempio n. 15
0
 @Override
 protected void addPages() {
   try {
     addPage(dpage);
     addPage(epage);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
Esempio n. 16
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();
   }
 }
Esempio n. 17
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();
   }
 }
Esempio n. 18
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();
    }
  }
Esempio n. 19
0
 @Override
 public void run(IAction action) {
   try {
     PlatformUI.getWorkbench()
         .getActiveWorkbenchWindow()
         .getActivePage()
         .showView(FeedbackView.ID);
   } catch (PartInitException e) {
     // Not much to do here as its not that important.
     e.printStackTrace();
   }
 }
Esempio n. 20
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;
 }
Esempio n. 21
0
  /**
   * Shows the warning view.
   *
   * @return view which is shown
   */
  public static IViewPart showWarningView() {
    final IWorkbench workbench = PlatformUI.getWorkbench();

    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    try {
      final IViewPart theView = window.getActivePage().showView(warningViewID);
      return theView;
    } catch (final PartInitException e) {
      e.printStackTrace();
    }
    return null;
  }
Esempio n. 22
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    final IWorkbench workbench = PlatformUI.getWorkbench();
    final IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
    final IWorkbenchPage page = window.getActivePage();
    try {
      page.showView(ChangelogViewPart.ID);
    } catch (final PartInitException e) {
      e.printStackTrace();
    }
    return null;
  }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
   IWorkbenchPage page = window.getActivePage();
   try {
     page.openEditor(
         new DefaultEditorInput(Messages.getString("EXECUTED_POLICY")),
         LiderConstants.EDITORS.EXECUTED_POLICY_EDITOR);
   } catch (PartInitException e) {
     e.printStackTrace();
   }
   return null;
 }
 public static IEditorPart openEditor(IProject project, IFile file) {
   try {
     IEditorDescriptor toolEditor =
         PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
     return PlatformUI.getWorkbench()
         .getActiveWorkbenchWindow()
         .getActivePage()
         .openEditor(new FileEditorInput(file), toolEditor.getId());
   } catch (PartInitException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
     return null;
   }
 }
Esempio n. 25
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    try {
      HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(GLPathway.VIEW_TYPE);

      // WE DO NOT ALLOW MULTIPLE PATHWAY VIEWS UNTIL WE HAVE A WORKFLOW FOR IT
      // , Integer.toString(SECONDARY_ID++),
      // IWorkbenchPage.VIEW_ACTIVATE);
    } catch (PartInitException e) {
      e.printStackTrace();
    }

    return null;
  }
Esempio n. 26
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   try {
     IWorkbenchBrowserSupport browserSupport = PlatformUI.getWorkbench().getBrowserSupport();
     browserSupport
         .createBrowser(IWorkbenchBrowserSupport.AS_EDITOR, "prob", "prob2", "prob3")
         .openURL(new URL("http://localhost:" + WebConsole.getPort() + "/"));
   } catch (PartInitException e) {
     e.printStackTrace();
   } catch (MalformedURLException e) {
     e.printStackTrace();
   }
   return null;
 }
Esempio n. 27
0
  public static IViewPart openView(String ViewId) {
    // Locals
    IViewPart view = null;

    if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
      try {
        view =
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(ViewId);
      } catch (PartInitException e) {
        e.printStackTrace();
      }
    }
    return view;
  }
Esempio n. 28
0
  @Override
  public void run() {

    // hide all views
    IViewReference[] views = window.getActivePage().getViewReferences();
    for (IViewReference view : views) {
      window.getActivePage().hideView(view);
    }
    try {
      window.getActivePage().showView(viewId);
    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 29
0
  @Override
  public Object execute(ExecutionEvent event) throws ExecutionException {

    ViewData.instance().setModel(null);

    IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
    activePage.hideView(activePage.findView(MainView.ID));
    try {
      activePage.showView(MainView.ID);
    } catch (PartInitException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return null;
  }
  /* (non-Javadoc)
   * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
   */
  @Override
  protected void addPages() {
    interfacePage = new LogicFunctionInterfacePage(null, this, "interface", "½Ó¿Ú");
    try {
      //			addPage(new LogicFunctionBaseInfoPage(this, "baseinfo", "»ù±¾ÐÅÏ¢"));
      addPage(interfacePage);
      //			addPage(new LogicServiceIntenalVarPage(this, "internalvar", "ÄÚ²¿±äÁ¿"));

      // α´úÂëÒ³Ãæ
      final LogicFunction func = (LogicFunction) getInfo();
      sourcePage = new LogicTextEditor(getARESResource());
      TextBasedEditorInput input =
          new TextBasedEditorInput(
              new ITextBased() {
                @Override
                public void setText(String text) {
                  Command command =
                      SetCommand.create(
                          getEditingDomain(),
                          func,
                          AtomPackage.Literals.ATOM_FUNCTION__PSEUDO_CODE,
                          text);
                  getEditingDomain().getCommandStack().execute(command);
                }

                @Override
                public String getText() {
                  return func.getPseudoCode();
                }
              },
              getARESResource());
      index = addPage(sourcePage, input);
      sourcePage.setEditor(this);
      setPageText(index, "ʵÏÖ-α´úÂë");

      // Ô¤ÀÀÒ³Ãæ
      addPage(preViewPage = new LogicPreViewPage(this, "preview", "Ô¤ÀÀ"), new TextEditorInput());
      addPage(new RevisionHistoryListPage(this, "revisionHistory", "ÐÞ¶©ÐÅÏ¢"));

      addPageChangedListener(
          new PreviewUpdater(ILogicSkeletonFactoryConstant.SKELETONTYPE_LOGIC_FUNCTION));

    } catch (PartInitException e) {
      e.printStackTrace();
    }
  }