public void run(IProgressMonitor progressMonitor)
      throws InvocationTargetException, InterruptedException {
    try {
      boolean isFixedForm = getFortranEditor().isFixedForm();

      IDocument doc = getFortranEditor().getIDocument();
      Reader in = new StringReader(doc.get());
      Reader cppIn = new CPreprocessingReader(getFortranEditor().getIFile(), null, in);
      try {
        File tempFile =
            File.createTempFile(
                "tmp", //$NON-NLS-1$
                isFixedForm ? ".f" : ".f90"); // $NON-NLS-1$ //$NON-NLS-2$
        tempFile.deleteOnExit();
        PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(tempFile)));
        try {
          for (int c = cppIn.read(); c != -1; c = cppIn.read()) out.print((char) c);
        } finally {
          out.close();
        }

        IDE.openEditor(
            Workbench.getInstance().getActiveWorkbenchWindow().getActivePage(),
            tempFile.toURI(),
            FortranEditor.EDITOR_ID,
            true);
      } finally {
        cppIn.close();
      }
    } catch (Exception e) {
      String message = e.getMessage();
      if (message == null) message = e.getClass().getName();
      MessageDialog.openError(getFortranEditor().getShell(), "Error", message); // $NON-NLS-1$
    }
  }
  /**
   * Given a <code>file</code> get an editor for it. If an editor has already been retrieved for the
   * given <code>file</code> then return the same already open editor.
   *
   * <p>When opening the editor it will also standardized the line endings to <code>\n</code>
   *
   * @param file open and return an editor for this
   * @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
   */
  public AbstractTextEditor getEditor(IFile file) {
    AbstractTextEditor editor = (AbstractTextEditor) fFileToEditorMap.get(file);

    if (editor == null) {
      try {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        IEditorPart editorPart = null;
        if (file.getFileExtension().equals("js")) {
          editorPart = IDE.openEditor(page, file, true, true);
        } else if (file.getFileExtension().equals("html")) {
          editorPart =
              IDE.openEditor(page, file, "org.eclipse.wst.html.core.htmlsource.source", true);
        }

        if (editorPart instanceof AbstractTextEditor) {
          editor = (AbstractTextEditor) editorPart;
        } else {
          Assert.fail("Unable to open structured text editor");
        }

        if (editor != null) {
          standardizeLineEndings(editor);
          fFileToEditorMap.put(file, editor);
        } else {
          Assert.fail("Could not open editor for " + file);
        }
      } catch (Exception e) {
        Assert.fail("Could not open editor for " + file + " exception: " + e.getMessage());
      }
    }

    return editor;
  }
Пример #3
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();
   }
 }
  /** Test that an editor notifies reconciling listeners when the editor gets focus. */
  public void testFocusedReconciling() throws Exception {
    IFile file = getOrCreateFile(PROJECT_NAME + "/" + "focustest.xml");
    IFile fileAlt = getOrCreateFile(PROJECT_NAME + "/" + "focustestAlt.xml");
    IWorkbenchPage activePage =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final int[] state = new int[2];
    Arrays.fill(state, -1);
    ISourceReconcilingListener listener =
        new ISourceReconcilingListener() {
          int mod = 0;

          public void reconciled(
              IDocument document,
              IAnnotationModel model,
              boolean forced,
              IProgressMonitor progressMonitor) {
            state[1] = mod++;
          }

          public void aboutToBeReconciled() {
            state[0] = mod++;
          }
        };
    IEditorPart editor =
        IDE.openEditor(activePage, file, "org.eclipse.wst.sse.ui.StructuredTextEditor.test");
    try {
      assertTrue("Not a StructuredTextEditor", editor instanceof StructuredTextEditor);
      addReconcilingListener((StructuredTextEditor) editor, listener);
      waitForReconcile(state);
      assertTrue(
          "Initial: Reconciling did not complete in a timely fashion",
          state[0] != -1 && state[1] != -1);
      assertTrue(
          "Initial: aboutToBeReconciled not invoked first (" + state[0] + ")", state[0] == 0);
      assertTrue(
          "Initial: reconciled not invoked after aboutToBeReconciled (" + state[1] + ")",
          state[1] == 1);
      IDE.openEditor(activePage, fileAlt, "org.eclipse.wst.sse.ui.StructuredTextEditor.test");
      Arrays.fill(state, -1);
      IEditorPart editorPart =
          IDE.openEditor(activePage, file, "org.eclipse.wst.sse.ui.StructuredTextEditor.test");
      assertEquals("Didn't get the original editor back.", editor, editorPart);
      waitForReconcile(state);
      assertTrue(
          "Modified: Reconciling did not complete in a timely fashion",
          state[0] != -1 && state[1] != -1);
      assertTrue(
          "Modified: aboutToBeReconciled not invoked first (" + state[0] + ")", state[0] == 2);
      assertTrue(
          "Modified: reconciled not invoked after aboutToBeReconciled (" + state[1] + ")",
          state[1] == 3);
    } finally {
      if (editor != null && activePage != null) {
        activePage.closeEditor(editor, false);
      }
    }
  }
Пример #5
0
  /** User clicks Finish */
  @Override
  public boolean performFinish() {
    try {
      // Create file object
      IFile file = doCreateNew(new NullProgressMonitor());
      if (file == null) {
        // that's ok, as it just didn't create a file (but maybe a folder)...
        return true;
      }

      // Scroll to file in package explorer
      BasicNewResourceWizard.selectAndReveal(file, workbench.getActiveWorkbenchWindow());

      // Open editor on new file.
      IWorkbenchWindow dw = workbench.getActiveWorkbenchWindow();
      try {
        if (dw != null) {
          IWorkbenchPage page = dw.getActivePage();
          if (page != null) {
            IEditorPart openEditor = IDE.openEditor(page, file, true);
            afterEditorCreated(openEditor);
          }
        }
      } catch (PartInitException e) {
        Log.log(e);
        return false;
      }
    } catch (Exception e) {
      Log.log(e);
      return false;
    }
    return true;
  }
Пример #6
0
 @Override
 public boolean close() {
   recordingSupport.setMode(RecordingMode.Stopped);
   if (isDirty()) {
     if (!openSaveDialog()) {
       return false;
     }
   }
   final boolean result = super.close();
   if (result && !parentShell.isDisposed()) {
     dbc.dispose();
     parentShell.removeShellListener(closeListener);
     parentShell.setMinimized(false);
     try {
       ShellUtilsProvider.getShellUtils().forceActive(parentShell);
     } catch (CoreException e) {
       throw new RuntimeException(e);
     }
     parentShell.setFocus();
     ITestCase model = getModel();
     if (model != null && model.exists()) {
       IFile location = (IFile) model.getResource();
       if (location != null) {
         try {
           IDE.openEditor(Q7UIPlugin.getActiveWindow().getActivePage(), location);
         } catch (PartInitException e) {
           Q7UIPlugin.log(e);
         }
       }
     }
   }
   RecordingContextManager.Instance.deactivateContext();
   return result;
 }
 @SuppressWarnings("unchecked")
 public IEditorPart openEditor(IStructuredSelection selection) {
   Object o = selection.getFirstElement();
   EObject obj = null;
   if (o instanceof EObject) {
     obj = (EObject) o;
   }
   if (o instanceof EObjectGroup) {
     EObjectGroup group = (EObjectGroup) o;
     if (!group.getEObjects().isEmpty()) {
       obj = group.getEObjects().getFirst();
     }
   }
   if (obj != null) {
     //			URI uri = obj.eResource().getURI();
     //			String fileString = URI.decode(uri.path());
     //			fileString = fileString.replaceFirst("/resource", "");
     //			IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(fileString));
     //			IWorkbench workbench = PlatformUI.getWorkbench();
     IFile file = ((LinkedList<ResultModel>) viewer.getInput()).get(0).getIFile();
     IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
     IWorkbenchPage page = workbenchWindow.getActivePage();
     try {
       if (file.exists()) {
         return IDE.openEditor(page, file);
       }
     } catch (PartInitException exception) {
       return null;
     }
   }
   return null;
 }
Пример #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);
          }
        }
      }
    }
  }
  @Override
  public boolean performFinish() {

    IPath locationPath = new Path(page.getLocationURI().getPath());

    DartToolsPlugin.getDefault()
        .getDialogSettingsSection(NewApplicationCreationPage.NEW_APPPLICATION_SETTINGS)
        .put(
            NewApplicationCreationPage.PARENT_DIR,
            locationPath.removeLastSegments(1).toPortableString());

    if (isNestedByAnExistingProject(locationPath)) {
      createFolder(locationPath);
    } else {
      createNewProject();
    }

    if (newProject == null) {
      return false;
    }

    if (createdFile != null) {
      selectAndReveal(createdFile);

      try {
        IDE.openEditor(getWorkbench().getActiveWorkbenchWindow().getActivePage(), createdFile);
      } catch (PartInitException e) {
        DartToolsPlugin.log(e);
      }
    } else {
      selectAndReveal(newProject);
    }

    return true;
  }
Пример #10
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;
 }
Пример #11
0
 public static void openFile(IWorkbenchPage page, IFile destinationFile, byte[] initialContent) {
   try {
     if (destinationFile != null) {
       // TODO: prompt to create the file ?  I say no, why would you try the shortcut if you didn't
       // want it created
       if (!destinationFile.exists()) {
         IPath fullPath = destinationFile.getLocation();
         if (fullPath.toFile().getParentFile().mkdirs()) {
           // create Eclipse resource so that the create file doesn't blow chunks
           destinationFile
               .getProject()
               .getFile(destinationFile.getParent().getProjectRelativePath())
               .refreshLocal(IFile.DEPTH_ZERO, null);
         }
         destinationFile.create(new ByteArrayInputStream(initialContent), false, null);
       }
       if (destinationFile.exists()) {
         IDE.openEditor(page, destinationFile);
       }
     }
   } catch (CoreException e) {
     String clazz = destinationFile.getName();
     System.err.println("OpenCakeFile can not open file: " + clazz);
     e.printStackTrace();
   }
 }
  /**
   * Given a <code>file</code> get an editor for it. If an editor has already been retrieved for the
   * given <code>file</code> then return the same already open editor.
   *
   * <p>When opening the editor it will also standardized the line endings to <code>\n</code>
   *
   * @param file open and return an editor for this
   * @return <code>StructuredTextEditor</code> opened from the given <code>file</code>
   */
  private static StructuredTextEditor getEditor(IFile file) {
    StructuredTextEditor editor = (StructuredTextEditor) fFileToEditorMap.get(file);

    if (editor == null) {
      try {
        IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        IWorkbenchPage page = workbenchWindow.getActivePage();
        IEditorPart editorPart = IDE.openEditor(page, file, true, true);
        if (editorPart instanceof StructuredTextEditor) {
          editor = ((StructuredTextEditor) editorPart);
        } else {
          fail("Unable to open structured text editor");
        }

        if (editor != null) {
          standardizeLineEndings(editor);
          fFileToEditorMap.put(file, editor);
        } else {
          fail("Could not open editor for " + file);
        }
      } catch (Exception e) {
        fail("Could not open editor for " + file + " exception: " + e.getMessage());
      }
    }

    return editor;
  }
  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;
  }
 @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();
         }
       }
     }
   }
 }
Пример #15
0
  @Override
  public boolean performFinish() {
    try {
      final IDocument doc =
          createDocument(typePage.getDocumentType(), typePage.getRootElementName());

      final Style style =
          VexPlugin.getDefault().getPreferences().getPreferredStyle(typePage.getDocumentType());
      if (style == null) {
        MessageDialog.openError(
            getShell(),
            Messages.getString("NewDocumentWizard.noStyles.title"),
            Messages.getString("NewDocumentWizard.noStyles.message")); // $NON-NLS-1$ //$NON-NLS-2$
        return false;
        // TODO: don't allow selection of types with no stylesheets
      }

      final ByteArrayOutputStream baos = new ByteArrayOutputStream();
      final DocumentWriter writer = new DocumentWriter();
      writer.setWhitespacePolicy(new CssWhitespacePolicy(style.getStyleSheet()));
      writer.write(doc, baos);
      baos.close();
      final ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

      filePage.setInitialContents(bais);
      final IFile file = filePage.createNewFile();
      IDE.setDefaultEditor(file, VexEditor.ID);
      this.selectAndReveal(file);

      registerEditorForFilename("*." + file.getFileExtension(), VexEditor.ID); // $NON-NLS-1$

      // Open editor on new file.
      final IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
      if (dw != null) {
        final IWorkbenchPage page = dw.getActivePage();
        if (page != null) {
          IDE.openEditor(page, file, true);
        }
      }

      typePage.saveSettings();

      return true;

    } catch (final Exception ex) {
      final String message =
          MessageFormat.format(
              Messages.getString("NewDocumentWizard.errorLoading.message"),
              new Object[] {filePage.getFileName(), ex.getMessage()});
      VexPlugin.getDefault().log(IStatus.ERROR, message, ex);
      MessageDialog.openError(
          getShell(),
          Messages.getString("NewDocumentWizard.errorLoading.title"),
          "Unable to create " + filePage.getFileName()); // $NON-NLS-1$ //$NON-NLS-2$
      return false;
    }
  }
Пример #16
0
 public void open() {
   try {
     IWorkbenchPage page =
         ShipyardPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
     IDE.openEditor(page, file);
   } catch (Exception e) {
     throw new RuntimeException(e);
   }
 }
Пример #17
0
 /**
  * Open commit in editor
  *
  * @param commit
  * @param activateOnOpen <code>true</code> if the newly opened editor should be activated
  * @return opened editor part
  * @throws PartInitException
  * @since 2.1
  */
 public static final IEditorPart open(RepositoryCommit commit, boolean activateOnOpen)
     throws PartInitException {
   CommitEditorInput input = new CommitEditorInput(commit);
   return IDE.openEditor(
       PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(),
       input,
       ID,
       activateOnOpen);
 }
Пример #18
0
 public static IEditorPart openFileInEditor(IFile input, String id) {
   if (input != null && input.exists()) {
     try {
       if (id == null) {
         IWorkbenchPage page =
             PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
         return IDE.openEditor(page, input, true);
       } else {
         IWorkbenchPage page =
             PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
         return IDE.openEditor(page, input, id, true);
       }
     } catch (PartInitException pie) {
       pie.printStackTrace();
       fail(pie.getMessage());
     }
   }
   return null;
 }
Пример #19
0
 public static ScriptEditor openDeeEditorForFile(IFile file) {
   IWorkbenchPage page = WorkbenchUtils.getActivePage();
   try {
     ScriptEditor editor = (ScriptEditor) IDE.openEditor(page, file, DeeEditor.EDITOR_ID);
     assertTrue(editor.getScriptSourceViewer() != null);
     return editor;
   } catch (PartInitException e) {
     throw melnorme.utilbox.core.ExceptionAdapter.unchecked(e);
   }
 }
 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());
     }
   }
 }
Пример #21
0
 /** Overridden to open the given files with the match provided by the platform. */
 @Override
 protected void openFiles(List<IFile> filesSelected) {
   for (IFile f : filesSelected) {
     try {
       IDE.openEditor(page, f, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
     } catch (PartInitException e) {
       Log.log(e);
     }
   }
 }
Пример #22
0
 private static IEditorPart openInEditor(final IFile file, final boolean activate)
     throws PartInitException {
   if (file != null) {
     final IWorkbenchPage p = ErlideUIPlugin.getActivePage();
     if (p != null) {
       final IEditorPart editorPart = IDE.openEditor(p, file, activate);
       return editorPart;
     }
   }
   return null;
 }
 // MyDefect : Refactored
 private void reOpenEditor(boolean wasOpen, String newName, IWorkbenchPage iwbp)
     throws PartInitException {
   // reopen if needed (if the rename failed, this will fail silently):
   if (wasOpen) {
     IContainer folder = resSelectedResource.getParent();
     IResource newResource = folder.findMember(newName);
     if (newResource != null) {
       IDE.openEditor(iwbp, (IFile) newResource);
     }
   }
 }
  protected IEditorPart openBeanEditor(String fileName) throws Exception {
    copyProjectCreateDocument(fileName);

    String baseLocation = model.getBaseLocation();
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
    IPath filePath = new Path(baseLocation);
    IFile beanFile = root.getFile(filePath);

    return IDE.openEditor(
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), beanFile);
  }
Пример #25
0
  public void openEditor(IFile file) {
    if (activePage == null) {
      return;
    }

    try {
      IDE.openEditor(activePage, file, true);
    } catch (PartInitException e) {
      logger.error("Could not open editor for " + file, e);
    }
  }
Пример #26
0
 void openFile(IFile file, IMarker marker) {
   try {
     IWorkbenchPage page = getViewSite().getWorkbenchWindow().getActivePage();
     if (page != null) {
       IDE.openEditor(page, marker);
       marker.delete();
     }
   } catch (CoreException e) {
     Status s = new Status(Status.ERROR, DdmsPlugin.PLUGIN_ID, e.getMessage(), e);
     DdmsPlugin.getDefault().getLog().log(s);
   }
 }
Пример #27
0
 @Override
 protected void openFiles(PythonpathZipChildTreeNode[] pythonPathFilesSelected) {
   for (PythonpathZipChildTreeNode n : pythonPathFilesSelected) {
     try {
       PydevZipFileStorage storage = new PydevZipFileStorage(n.zipStructure.file, n.zipPath);
       PydevZipFileEditorInput input = new PydevZipFileEditorInput(storage);
       IDE.openEditor(page, input, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
     } catch (PartInitException e) {
       Log.log(e);
     }
   }
 }
Пример #28
0
  /*
   * (non-Jsdoc)
   * @see com.ebmwebsourcing.petals.common.croquis.internal.provisional.ICroquisExtension
   * #performAfterFinish()
   */
  public void performAfterFinish() {

    IFile createdFile = getFile();
    try {
      IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
      IDE.openEditor(page, createdFile);

    } catch (PartInitException e) {
      PetalsEipPlugin.log(e, IStatus.ERROR);
    }

    ResourceUtils.selectResourceInPetalsExplorer(true, createdFile);
  }
Пример #29
0
 @Override
 protected void openFiles(PythonpathTreeNode[] pythonPathFilesSelected) {
   for (PythonpathTreeNode n : pythonPathFilesSelected) {
     try {
       IDE.openEditor(
           page,
           EditorInputFactory.create(n.file, false),
           IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);
     } catch (PartInitException e) {
       Log.log(e);
     }
   }
 }
Пример #30
0
 protected void openIndexFile(boolean activatateEditor) {
   IFile indexFile = newProject.getFile("index.html"); // $NON-NLS-1$
   if (indexFile.exists()) {
     IWorkbenchPage page = UIUtils.getActivePage();
     if (page != null) {
       try {
         IDE.openEditor(page, indexFile, activatateEditor);
       } catch (PartInitException e) {
         IdeLog.logError(
             ProjectsPlugin.getDefault(), Messages.NewProjectWizard_ERR_OpeningIndex, e);
       }
     }
   }
 }