Пример #1
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.console.IConsolePageParticipant#init(IPageBookViewPage,
   * IConsole)
   */
  public void init(final IPageBookViewPage page, final IConsole console) {
    fPage = page;
    fConsole = (ErlangConsole) console;

    fRemoveTerminated = new ConsoleRemoveLaunchAction(fConsole.getBackend());
    fRemoveAllTerminated = new ConsoleRemoveAllTerminatedAction();
    fTerminate = new ConsoleTerminateAction(fConsole);
    fStdOut = new ShowStandardOutAction();

    fView = (IConsoleView) fPage.getSite().getPage().findView(IConsoleConstants.ID_CONSOLE_VIEW);

    DebugPlugin.getDefault().addDebugEventListener(this);
    DebugUITools.getDebugContextManager()
        .getContextService(fPage.getSite().getWorkbenchWindow())
        .addDebugContextListener(this);

    // contribute to toolbar
    IActionBars actionBars = fPage.getSite().getActionBars();
    configureToolBar(actionBars.getToolBarManager());

    // create handler and submissions for EOF
    fEOFHandler = new EOFHandler();

    // set global ref, used by the SendToConsole action
    // FIXME global is bad, use project's page (keyed by backend?)
    ErlideUIPlugin.getDefault().setConsolePage((ErlangConsolePage) fPage);
  }
Пример #2
0
 @Override
 protected PageRec doCreatePage(IWorkbenchPart part) {
   IPageBookViewPage page = fPartsToPages.get(part);
   initPage(page);
   page.createControl(getPageBook());
   PageRec rec = new PageRec(part, page);
   return rec;
 }
Пример #3
0
 /* (non-Javadoc)
  * Method declared on PageBookView.
  * Returns the default property sheet page.
  */
 protected IPage createDefaultPage(PageBook book) {
   IPageBookViewPage page =
       (IPageBookViewPage) ViewsPlugin.getAdapter(this, IPropertySheetPage.class, false);
   if (page == null) {
     page = new PropertySheetPage();
   }
   initPage(page);
   page.createControl(book);
   return page;
 }
Пример #4
0
 @Override
 protected IPage createDefaultPage(PageBook book) {
   IPageBookViewPage page = new EmptySearchView();
   page.createControl(book);
   initPage(page);
   DummyPart part = new DummyPart();
   fPartsToPages.put(part, page);
   fPagesToParts.put(page, part);
   fDefaultPart = part;
   return page;
 }
Пример #5
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.console.IConsolePageParticipant#dispose()
  */
 public void dispose() {
   DebugUITools.getDebugContextManager()
       .getContextService(fPage.getSite().getWorkbenchWindow())
       .removeDebugContextListener(this);
   DebugPlugin.getDefault().removeDebugEventListener(this);
   if (fRemoveTerminated != null) {
     fRemoveTerminated.dispose();
     fRemoveTerminated = null;
   }
   if (fRemoveAllTerminated != null) {
     fRemoveAllTerminated.dispose();
     fRemoveAllTerminated = null;
   }
   if (fTerminate != null) {
     fTerminate.dispose();
     fTerminate = null;
   }
   if (fStdOut != null) {
     fStdOut.dispose();
     fStdOut = null;
   }
   fConsole = null;
   if (ErlideUIPlugin.getDefault().getConsolePage() == fPage) {
     ErlideUIPlugin.getDefault().setConsolePage(null);
   }
 }
Пример #6
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.console.IConsolePageParticipant#deactivated()
  */
 public void deactivated() {
   // remove EOF submissions
   IPageSite site = fPage.getSite();
   IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
   IContextService contextService = (IContextService) site.getService(IContextService.class);
   handlerService.deactivateHandler(fActivatedHandler);
   contextService.deactivateContext(fActivatedContext);
 }
Пример #7
0
 /*
  * (non-Javadoc)
  *
  * @see org.eclipse.ui.console.IConsolePageParticipant#activated()
  */
 public void activated() {
   // add EOF submissions
   IPageSite site = fPage.getSite();
   IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
   IContextService contextService = (IContextService) site.getService(IContextService.class);
   fActivatedContext = contextService.activateContext(fContextId);
   fActivatedHandler =
       handlerService.activateHandler(
           "org.eclipse.debug.ui.commands.eof", fEOFHandler); // $NON-NLS-1$
   ErlideUIPlugin.getDefault().setConsolePage((ErlangConsolePage) fPage);
 }
  @Override
  public void setInput(IWorkbenchPart part, ISelection selection) {
    if (part == getPart() && selection == getSelection()) {
      return;
    }
    super.setInput(part, selection);
    if (page != null) {
      page.getControl().removeControlListener(controlListener);
      aboutToBeHidden();
      page.dispose();
      page.getControl().dispose();
      page = null;
    }
    Object first = Selections.getFirstSelection(selection);
    if (first == null) {
      return;
    }
    page = createPage(first);
    if (page != null) {
      if (page instanceof IPageBookViewPage) {
        try {
          ((IPageBookViewPage) page).init(parentPage.getSite());
        } catch (PartInitException e) {
          Activator.getDefault().getLog().log(e.getStatus());
        }
      }
      page.createControl(container);
      FormData data = new FormData();
      data.left = new FormAttachment(0, 0);
      data.right = new FormAttachment(100, 0);
      data.top = new FormAttachment(0, 0);
      data.bottom = new FormAttachment(100, 0);
      page.getControl().setLayoutData(data);

      page.getControl().addControlListener(controlListener);
    }

    container.layout(true, true);
    parentPage.resizeScrolledComposite();
  }
Пример #9
0
  @Override
  protected void initPage(IPageBookViewPage page) {
    super.initPage(page);
    IActionBars actionBars = page.getSite().getActionBars();
    actionBars.setGlobalActionHandler(ActionFactory.REFRESH.getId(), fSearchAgainAction);
    actionBars.updateActionBars();

    fUndoRedoActionGroup.fillActionBars(actionBars);

    ISearchResultPage srPage = (ISearchResultPage) page;
    IMemento memento = null;
    if (fPageState != null) {
      IMemento[] mementos = fPageState.getChildren(MEMENTO_TYPE);
      for (int i = 0; i < mementos.length; i++) {
        if (mementos[i].getID().equals(srPage.getID())) {
          memento = mementos[i];
          break;
        }
      }
    }
    srPage.restoreState(memento);
  }
 private static void contributeToolAction(IPageBookViewPage page, String group, IAction action) {
   IActionBars actionBars = page.getSite().getActionBars();
   actionBars.getToolBarManager().appendToGroup(group, action);
 }
  public void init(IPageBookViewPage page, IConsole console) {
    closeAction = new CloseConsoleAction(console);

    IToolBarManager manager = page.getSite().getActionBars().getToolBarManager();
    manager.appendToGroup(IConsoleConstants.LAUNCH_GROUP, closeAction);
  }
  /** When a console page is initialized, */
  public void init(IPageBookViewPage page, final IConsole console) {
    if (!(console instanceof ProcessConsole)) {
      return;
    }
    ProcessConsole processConsole = (ProcessConsole) console;
    IProcess process = processConsole.getProcess();
    if (process == null) {
      return;
    }
    if (!PyCodeCompletionPreferencesPage.useCodeCompletion()
        || !PyCodeCompletionPreferencesPage.useCodeCompletionOnDebug()) {
      return;
    }
    String attribute = process.getAttribute(Constants.PYDEV_DEBUG_IPROCESS_ATTR);
    if (!Constants.PYDEV_DEBUG_IPROCESS_ATTR_TRUE.equals(attribute)) {
      // Only provide code-completion for pydev debug processes.
      return;
    }
    Control control = page.getControl();
    if (page instanceof IOConsolePage) {

      // Note that completions on "all letters and '_'" are already activated just by installing
      // the content assist, but the completions on the default keybinding is not, so, we have to
      // call it ourselves here.
      control.addKeyListener(
          new KeyListener() {
            public void keyPressed(KeyEvent e) {

              if (KeyBindingHelper.matchesContentAssistKeybinding(e)) {
                contentAssist.showPossibleCompletions();
              }
            }

            public void keyReleased(KeyEvent e) {}
          });

      IOConsolePage consolePage = (IOConsolePage) page;
      TextConsoleViewer viewer = consolePage.getViewer();

      contentAssist =
          new PyContentAssistant() {
            public String showPossibleCompletions() {
              // Only show completions if we're in a suspended console.
              if (getCurrentSuspendedPyStackFrame(console) == null) {
                return null;
              }
              return super.showPossibleCompletions();
            };
          };
      contentAssist.setInformationControlCreator(
          PyContentAssistant.createInformationControlCreator(viewer));
      ILaunch launch = process.getLaunch();
      IDebugTarget debugTarget = launch.getDebugTarget();
      IInterpreterInfo projectInterpreter = null;
      if (debugTarget instanceof PyDebugTarget) {
        PyDebugTarget pyDebugTarget = (PyDebugTarget) debugTarget;
        PythonNature nature = PythonNature.getPythonNature(pyDebugTarget.project);
        if (nature != null) {
          try {
            projectInterpreter = nature.getProjectInterpreter();
          } catch (Throwable e1) {
            Log.log(e1);
          }
        }
      }
      contentAssist.install(new ScriptConsoleViewerWrapper(viewer, projectInterpreter));

      PydevConsoleInterpreter interpreter = new PydevConsoleInterpreter();
      interpreter.setConsoleCommunication(new GetCompletionsInDebug());

      IContentAssistProcessor processor =
          new PydevConsoleCompletionProcessor(interpreter, contentAssist);
      contentAssist.setContentAssistProcessor(processor, IOConsolePartition.INPUT_PARTITION_TYPE);
      contentAssist.setContentAssistProcessor(processor, IOConsolePartition.OUTPUT_PARTITION_TYPE);

      contentAssist.enableAutoActivation(true);
      contentAssist.enableAutoInsert(false);
      contentAssist.setAutoActivationDelay(PyCodeCompletionPreferencesPage.getAutocompleteDelay());
    }
  }