Exemple #1
0
 protected void openExtern(final IFileStore fileStore) {
   final IWorkbenchPage page = UIAccess.getActiveWorkbenchPage(true);
   try {
     IDE.openEditorOnFileStore(page, fileStore);
   } catch (final PartInitException e) {
     //			final String fileName = FileUtil.toString(fileStore);
     //			Program.launch(fileName);
   }
 }
 @Override
 public Object execute(final ExecutionEvent event) throws ExecutionException {
   ToolProcess process = fProcess;
   if (process == null) {
     final IWorkbenchPage page = UIAccess.getActiveWorkbenchPage(false);
     process = NicoUI.getToolRegistry().getActiveToolSession(page).getProcess();
   }
   if (!NicoUITools.isToolReady(RTool.TYPE, RTool.R_DATA_FEATURESET_ID, process)) {
     return null;
   }
   process.getQueue().add(new REnvIndexAutoUpdater.UpdateRunnable(fCompletely));
   return null;
 }
    @Override
    public void widgetSelected(final SelectionEvent event) {
      final TexCommand command = (TexCommand) event.widget.getData();

      final IEditorPart editor = UIAccess.getActiveWorkbenchPage(true).getActiveEditor();
      if (editor instanceof ILtxEditor) {
        final ILtxEditor texEditor = (ILtxEditor) editor;
        if (!texEditor.isEditable(true)) {
          return;
        }
        final SourceViewer viewer = ((ILtxEditor) editor).getViewer();
        Point selection = viewer.getSelectedRange();
        if (selection == null || selection.x < 0) {
          return;
        }
        try {
          final String contentType =
              TextUtils.getContentType(
                  viewer.getDocument(),
                  texEditor.getDocumentContentInfo(),
                  selection.x,
                  selection.y == 0);

          final LtxAssistInvocationContext context =
              new LtxAssistInvocationContext(
                  texEditor, selection.x, contentType, true, new NullProgressMonitor());
          final LtxCommandCompletionProposal proposal =
              new LtxCommandCompletionProposal(context, context.getInvocationOffset(), command);
          proposal.apply(viewer, (char) 0, 1, context.getInvocationOffset());
          selection = proposal.getSelection(viewer.getDocument());
          if (selection != null) {
            viewer.setSelectedRange(selection.x, selection.y);
            viewer.revealRange(selection.x, selection.y);
          } else {
            viewer.revealRange(context.getInvocationOffset(), 0);
          }
        } catch (final Exception e) {
          StatusManager.getManager()
              .handle(
                  new Status(
                      IStatus.ERROR,
                      TexUI.PLUGIN_ID,
                      0,
                      "An error occurred when inserting LaTeX symbol.",
                      e));
        }
      }
    }