コード例 #1
0
 public boolean performFinish() {
   try {
     String perspId = selection.getAttribute("perspectiveId"); // $NON-NLS-1$
     IWorkbenchPage page = PDEPlugin.getActivePage();
     if (perspId != null && switchPerspective) {
       PlatformUI.getWorkbench().showPerspective(perspId, page.getWorkbenchWindow());
     }
     SampleOperation op =
         new SampleOperation(selection, namesPage.getProjectNames(), new ImportOverwriteQuery());
     getContainer().run(true, true, op);
     IFile sampleManifest = op.getSampleManifest();
     if (selectRevealEnabled) {
       selectReveal(getShell());
     }
     if (activitiesEnabled) enableActivities();
     if (sampleEditorNeeded && sampleManifest != null) IDE.openEditor(page, sampleManifest, true);
   } catch (InvocationTargetException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (InterruptedException e) {
     // PDEPlugin.logException(e);
     return false;
   } catch (CoreException e) {
     PDEPlugin.logException(e);
     return false;
   } catch (OperationCanceledException e) {
     return false;
   }
   return true;
 }
コード例 #2
0
 public void run() {
   try {
     IViewPart view = PDEPlugin.getActivePage().showView(IPDEUIConstants.DEPENDENCIES_VIEW_ID);
     ((DependenciesView) view).openCallersFor(fModel);
   } catch (PartInitException e) {
     PDEPlugin.logException(e);
   }
 }
コード例 #3
0
 /**
  * Returns an IPluginModelBase from the active ManifestEditor or null if no manifest editor is
  * open.
  *
  * @return the active IPluginModelBase
  */
 public static IPluginModelBase getActivePluginModel() {
   IEditorPart editor = PDEPlugin.getActivePage().getActiveEditor();
   if (editor instanceof ManifestEditor) {
     IBaseModel model = ((ManifestEditor) editor).getAggregateModel();
     if (model instanceof IPluginModelBase) return (IPluginModelBase) model;
   }
   return null;
 }
コード例 #4
0
  public boolean openHyperLink() {
    String localiz = getLocalization();
    if (localiz == null) {
      return false;
    } else if (fBase.getUnderlyingResource() == null) {
      return false;
    } else if (fElement.length() == 0 || fElement.charAt(0) != '%') {
      return false;
    }

    IProject proj = fBase.getUnderlyingResource().getProject();
    IFile file = proj.getFile(localiz + ".properties"); // $NON-NLS-1$
    if (!file.exists()) return false;

    try {
      IEditorPart editor = IDE.openEditor(PDEPlugin.getActivePage(), file);
      if (!(editor instanceof TextEditor)) return false;
      TextEditor tEditor = (TextEditor) editor;
      IDocument doc = tEditor.getDocumentProvider().getDocument(tEditor.getEditorInput());
      if (doc == null) return false;

      try {
        String key = fElement.substring(1);
        int keyLen = key.length();
        int length = doc.getLength();
        int start = 0;
        IRegion region = null;
        FindReplaceDocumentAdapter docSearch = new FindReplaceDocumentAdapter(doc);
        while ((region = docSearch.find(start, key, true, false, false, false)) != null) {
          int offset = region.getOffset();
          if (offset > 0) {
            // check for newline before
            char c = doc.getChar(offset - 1);
            if (c != '\n' && c != '\r') {
              start += keyLen;
              continue;
            }
          }
          if (offset + keyLen < length) {
            // check for whitespace / assign symbol after
            char c = doc.getChar(offset + keyLen);
            if (!Character.isWhitespace(c) && c != '=' && c != ':') {
              start += keyLen;
              continue;
            }
          }
          tEditor.selectAndReveal(offset, keyLen);
          break;
        }
      } catch (BadLocationException e) {
        PDEPlugin.log(e);
      }

    } catch (PartInitException e) {
      return false;
    }
    return true;
  }
コード例 #5
0
 private void handleGoToPackage(ISelection selection) {
   IPackageFragment frag = getPackageFragment(selection);
   if (frag != null)
     try {
       IViewPart part = PDEPlugin.getActivePage().showView(JavaUI.ID_PACKAGES);
       ShowInPackageViewAction action = new ShowInPackageViewAction(part.getSite());
       action.run(frag);
     } catch (PartInitException e) {
     }
 }