コード例 #1
0
 private IProgressService getProgressService() {
   IEditorPart editor = getTextEditor();
   if (editor != null) {
     IWorkbenchPartSite site = editor.getSite();
     if (site != null)
       return (IWorkbenchSiteProgressService)
           editor.getSite().getAdapter(IWorkbenchSiteProgressService.class);
   }
   return PlatformUI.getWorkbench().getProgressService();
 }
コード例 #2
0
	private boolean openFileImpl(IProject project, IPath sourceLoc, int lineNumber) {
		if (sourceLoc == null || "??".equals(sourceLoc.toString())) return false;
		try {
			IEditorInput editorInput = getEditorInput(sourceLoc, project);
			IWorkbenchPage p= CUIPlugin.getActivePage();
			if (p != null) {
				if (editorInput == null) {
					p.openEditor(
							new STCSourceNotFoundEditorInput(project, sourceLoc, lineNumber),
							"org.eclipse.linuxtools.binutils.link2source.STCSourceNotFoundEditor",
							true);
				} else {
					IEditorPart editor = p.openEditor(editorInput, CUIPlugin.EDITOR_ID, true);
					if (lineNumber > 0 && editor instanceof ITextEditor){
						IDocumentProvider provider= ((ITextEditor)editor).getDocumentProvider();
						IDocument document= provider.getDocument(editor.getEditorInput());
						try {
							int start = document.getLineOffset(lineNumber-1);
							((ITextEditor)editor).selectAndReveal(start, 0);
							IWorkbenchPage page= editor.getSite().getPage();
							page.activate(editor);
							return true;
						} catch (BadLocationException x) {
							// ignore
						}
					}
				}
			}
		}
		catch (Exception _) {
		}
		return false;
	}
コード例 #3
0
 /**
  * Sets the active editor for the delegate.
  *
  * @param action the action proxy that handles presentation portion of the action
  * @param targetEditor the new editor target
  */
 @Override
 public void setActiveEditor(IAction action, IEditorPart targetEditor) {
   editor = targetEditor;
   if (editor != null) {
     page = editor.getSite().getPage();
   }
 }
  /**
   * DOC smallet Comment method "openRoutineEditor".
   *
   * @param item
   * @throws SystemException
   * @throws PartInitException
   */
  public IEditorPart openSQLPatternEditor(SQLPatternItem item, boolean readOnly)
      throws SystemException, PartInitException {
    if (item == null) {
      return null;
    }
    ICodeGeneratorService service =
        (ICodeGeneratorService)
            GlobalServiceRegister.getDefault().getService(ICodeGeneratorService.class);

    ECodeLanguage lang =
        ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY))
            .getProject()
            .getLanguage();
    ISQLPatternSynchronizer routineSynchronizer = service.getSQLPatternSynchronizer();

    // check if the related editor is open.
    IWorkbenchPage page = getActivePage();

    IEditorReference[] editorParts = page.getEditorReferences();
    String talendEditorID =
        "org.talend.designer.core.ui.editor.StandAloneTalend"
            + lang.getCaseName()
            + "Editor"; //$NON-NLS-1$ //$NON-NLS-2$
    boolean found = false;
    IEditorPart talendEditor = null;
    for (IEditorReference reference : editorParts) {
      IEditorPart editor = reference.getEditor(false);
      if (talendEditorID.equals(editor.getSite().getId())) {
        // TextEditor talendEditor = (TextEditor) editor;
        RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
        Item item2 = editorInput.getItem();
        if (item2 != null
            && item2 instanceof SQLPatternItem
            && item2.getProperty().getId().equals(item.getProperty().getId())) {
          if (item2.getProperty().getVersion().equals(item.getProperty().getVersion())) {
            page.bringToTop(editor);
            found = true;
            talendEditor = editor;
            break;
          } else {
            page.closeEditor(editor, false);
          }
        }
      }
    }

    if (!found) {
      routineSynchronizer.syncSQLPattern(item, true);
      IFile file = routineSynchronizer.getSQLPatternFile(item);

      RepositoryEditorInput input = new RepositoryEditorInput(file, item);
      input.setReadOnly(readOnly);
      talendEditor = page.openEditor(input, talendEditorID); // $NON-NLS-1$
    }

    return talendEditor;
  }
コード例 #5
0
  @Override
  public void execute(String newText) throws CoreException {

    if (newText.isEmpty()) {
      if (getModel().getText() != null) {
        EnquiryTranslationRemoveCommand removeCmd = new EnquiryTranslationRemoveCommand(getModel());
        removeCmd.execute(newText);
      }
      return;
    }
    if (newText.equals(getModel().getText())) {
      // do nothing if text is the same.
      return;
    }

    IEditorPart editorPart = getActiveEditorPart();
    if (editorPart != null) {

      // Extract useful parameters needed for the command
      IWorkbenchPartSite site = editorPart.getSite();

      // Invoke the command
      IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
      ICommandService commandService = (ICommandService) site.getService(ICommandService.class);

      CommandStack commandStack = (CommandStack) editorPart.getAdapter(CommandStack.class);

      try {

        // Get the command and assign values to parameters
        Command command = commandService.getCommand(EDIT_COMMAND_ID);
        Parameterization parameter = new Parameterization(command.getParameter("text"), newText);
        ParameterizedCommand parmCommand =
            new ParameterizedCommand(command, new Parameterization[] {parameter});

        // Prepare the evaluation context
        IEvaluationContext ctx = handlerService.getCurrentState();
        ctx.addVariable("model", getModel());
        ctx.addVariable("commandStack", commandStack);

        // Execute the command
        handlerService.executeCommandInContext(parmCommand, null, ctx);

      } catch (Exception ex) {
        IStatus status =
            new Status(
                IStatus.ERROR,
                Activator.PLUGIN_ID,
                "Error while executing command to update translation",
                ex);
        throw new CoreException(status);
      }
    } else {
      /** @TODO log warn no active editorPart, should never occur */
    }
  }
コード例 #6
0
  protected SVOutlinePage getOutlineView(IEditorPart editor) throws PartInitException {
    IViewPart outline_v =
        editor.getSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
    assertNotNull(outline_v);

    while (Display.getDefault().readAndDispatch()) {}

    Object ret = editor.getAdapter(IContentOutlinePage.class);

    assertTrue(ret instanceof SVOutlinePage);

    return (SVOutlinePage) ret;
  }
コード例 #7
0
  public void testSingleNonUIThreadUpdatesToEditorDocument() throws Exception {
    IFile file = getOrCreateFile(PROJECT_NAME + "/" + "testBackgroundChanges.xml");
    ITextFileBufferManager textFileBufferManager = FileBuffers.getTextFileBufferManager();
    textFileBufferManager.connect(
        file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());

    ITextFileBuffer textFileBuffer =
        textFileBufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
    final IDocument document = textFileBuffer.getDocument();
    document.replace(0, 0, "<?xml encoding=\"UTF-8\" version=\"1.0\"?>\n");
    textFileBuffer.commit(new NullProgressMonitor(), true);

    String testText = document.get() + "<c/><b/><a/>";
    final int end = document.getLength();
    IWorkbenchPage activePage =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IEditorPart openedEditor = IDE.openEditor(activePage, file);

    final boolean state[] = new boolean[] {false};
    Job changer =
        new Job("text changer") {
          protected IStatus run(IProgressMonitor monitor) {
            try {
              document.replace(end, 0, "<a/>");
              document.replace(end, 0, "<b/>");
              document.replace(end, 0, "<c/>");
            } catch (Exception e) {
              return new Status(IStatus.ERROR, SSEUIPlugin.ID, e.getMessage());
            } finally {
              state[0] = true;
            }
            return Status.OK_STATUS;
          }
        };
    changer.setUser(true);
    changer.setSystem(false);
    changer.schedule();

    while (!state[0]) {
      openedEditor.getSite().getShell().getDisplay().readAndDispatch();
    }

    String finalText = document.get();
    textFileBuffer.commit(new NullProgressMonitor(), true);
    textFileBufferManager.disconnect(
        file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());
    activePage.closeEditor(openedEditor, false);
    assertEquals("Non-UI changes did not apply", testText, finalText);
  }
コード例 #8
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.internal.e4.compatibility.WorkbenchPartReference#initialize
   * (org.eclipse.ui.IWorkbenchPart)
   */
  @Override
  public void initialize(IWorkbenchPart part) throws PartInitException {
    IConfigurationElement element = descriptor.getConfigurationElement();
    editorSite = new EditorSite(getModel(), part, this, element);
    if (element == null) {
      editorSite.setExtensionId(descriptor.getId());
    }
    editorSite.setActionBars(
        createEditorActionBars((WorkbenchPage) getPage(), descriptor, editorSite));
    IEditorPart editor = (IEditorPart) part;
    try {
      editor.init(editorSite, getEditorInput());
    } catch (PartInitException e) {
      if (editor instanceof ErrorEditorPart) {
        editor.init(editorSite, new NullEditorInput(this));
      } else {
        throw e;
      }
    }

    if (editor.getSite() != editorSite || editor.getEditorSite() != editorSite) {
      String id = descriptor == null ? getModel().getElementId() : descriptor.getId();
      throw new PartInitException(NLS.bind(WorkbenchMessages.EditorManager_siteIncorrect, id));
    }

    if (part instanceof IPersistableEditor) {
      if (editorState != null) {
        ((IPersistableEditor) part).restoreState(editorState);
      } else if (useIPersistableEditor()) {
        String mementoString = getModel().getPersistedState().get(MEMENTO_KEY);
        if (mementoString != null) {
          try {
            IMemento createReadRoot = XMLMemento.createReadRoot(new StringReader(mementoString));
            IMemento editorStateMemento =
                createReadRoot.getChild(IWorkbenchConstants.TAG_EDITOR_STATE);
            if (editorStateMemento != null) {
              ((IPersistableEditor) part).restoreState(editorStateMemento);
            }
          } catch (WorkbenchException e) {
            throw new PartInitException(e.getStatus());
          }
        }
      }
    }

    legacyPart = part;
    addPropertyListeners();
  }
コード例 #9
0
  @Override
  public void execute(String newText) throws CoreException {

    IEditorPart editorPart = getActiveEditorPart();
    if (editorPart != null) {

      // Extract useful parameters needed for the command
      IWorkbenchPartSite site = editorPart.getSite();

      // Invoke the command
      IHandlerService handlerService = (IHandlerService) site.getService(IHandlerService.class);
      ICommandService commandService = (ICommandService) site.getService(ICommandService.class);

      if (editorPart instanceof VersionMultiPageEditor) {
        VersionMultiPageEditor vEditor = (VersionMultiPageEditor) editorPart;
        EditingDomain editingDomain = vEditor.getVersionFormEditor().getEditingDomain();
        CommandStack commandStack = editingDomain.getCommandStack();

        try {

          // Get the command and assign values to parameters
          Command command = commandService.getCommand(getCommandId());
          ParameterizedCommand parmCommand =
              new ParameterizedCommand(command, new Parameterization[] {});

          // Prepare the evaluation context
          IEvaluationContext ctx = handlerService.getCurrentState();
          ctx.addVariable("model", getModel());
          ctx.addVariable("commandStack", commandStack);
          ctx.addVariable("editingDomain", editingDomain);

          // Execute the command
          handlerService.executeCommandInContext(parmCommand, null, ctx);

        } catch (Exception ex) {
          IStatus status =
              new Status(
                  IStatus.ERROR,
                  VersionEditorActivator.PLUGIN_ID,
                  "Error while executing command to remove translation",
                  ex);
          throw new CoreException(status);
        }
      }
    } else {
      /** @TODO log warn no active editorPart, should never occur */
    }
  }
コード例 #10
0
  public void start(ModelSet modelsManager) {
    try {
      IEditorPart editor =
          ServiceUtilsForResourceSet.getInstance()
              .getService(IMultiDiagramEditor.class, modelsManager);

      if (editor != null) {
        // this model is opened in an editor. That is the context in which we want to provide our
        // services
        presenter = new ZombieStereotypeDialogPresenter(editor.getSite().getShell(), modelsManager);
        adapter.adapt(modelsManager);
      }
    } catch (ServiceException e) {
      // OK, there is no editor, so we aren't needed
    }
  }
  private IProject getActiveProject() {
    IEditorPart editorPart = null;
    IProject activeProject = null;
    IEditorReference editorReferences[] =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
    for (int i = 0; i < editorReferences.length; i++) {
      IEditorPart editor = editorReferences[i].getEditor(false);

      if (editor != null) {
        editorPart = editor.getSite().getWorkbenchWindow().getActivePage().getActiveEditor();
      }

      if (editorPart != null) {
        EsbEditorInput input = (EsbEditorInput) editorPart.getEditorInput();
        IFile file = input.getXmlResource();
        activeProject = file.getProject();
      }
    }
    return activeProject;
  }
  /**
   * When the active editor changes, this remembers the change and registers with it as a selection
   * provider.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setActiveEditor(IEditorPart part) {
    super.setActiveEditor(part);
    activeEditorPart = part;

    // Switch to the new selection provider.
    //
    if (selectionProvider != null) {
      selectionProvider.removeSelectionChangedListener(this);
    }
    if (part == null) {
      selectionProvider = null;
    } else {
      selectionProvider = part.getSite().getSelectionProvider();
      selectionProvider.addSelectionChangedListener(this);

      // Fake a selection changed event to update the menus.
      //
      if (selectionProvider.getSelection() != null) {
        selectionChanged(
            new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
      }
    }
  }
コード例 #13
0
  public Object execute(ExecutionEvent event) throws ExecutionException {
    IEditorPart editor = HandlerUtil.getActiveEditor(event);
    if (editor instanceof IXliffEditor) {
      IXliffEditor xliffEditor = (IXliffEditor) editor;
      IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
      //			ProjectConfiger projectConfig =
      // ProjectConfigerFactory.getProjectConfiger(file.getProject());
      //			List<DatabaseModelBean> lstDatabase = projectConfig.getTermBaseDbs(true);
      TbImporter.getInstance().setProject(file.getProject());
      if (!TbImporter.getInstance().checkImporter()) {
        MessageDialog.openInformation(
            HandlerUtil.getActiveShell(event),
            Messages.getString("handler.AddTermToTBHandler.msgTitle"),
            Messages.getString("handler.AddTermToTBHandler.msg"));
        return null;
      }

      StringBuffer srcTerm = new StringBuffer();
      StringBuffer tgtTerm = new StringBuffer();
      String srcAllText =
          xliffEditor.getRowTransUnitBean(xliffEditor.getSelectedRows()[0]).getSrcText();
      xliffEditor.getSelectSrcOrTgtPureText(srcTerm, tgtTerm);

      AddTermToTBDialog dialog =
          AddTermToTBDialog.getInstance(
              editor.getSite().getShell(),
              srcTerm.toString().trim(),
              tgtTerm.toString().trim(),
              AddTermToTBDialog.ADD_TYPE);
      dialog.setProject(file.getProject());
      dialog.setSrcLang(xliffEditor.getSrcColumnName());
      dialog.setTgtLang(xliffEditor.getTgtColumnName());
      dialog.setSrcAllText(srcAllText);
      dialog.open();
    }
    return null;
  }
コード例 #14
0
 /**
  * Returns the name of the given editor
  *
  * @param editor
  * @return
  */
 public static String getName(IEditorPart editor) {
   IWorkbenchPage page = editor.getSite().getPage();
   IWorkbenchPartReference ref = page.getReference(editor);
   return ref.getPartName();
 }
コード例 #15
0
 public void tearDown() {
   if (editor != null) {
     editor.getSite().getPage().closeEditor(editor, false);
   }
 }
コード例 #16
0
  public void notifyChanged(Notification notification) {
    super.notifyChanged(notification);

    /*
     * We create partOpened / partClosed events based on both MPartWidget
     * events.
     *
     * The initial MPartVisible events are sent early and don't have the
     * actual implementation included. The MPartWidget events are sent as a
     * final step of "part is created" and therefore we use it to create
     * partOpened events. When the part is closed the widget is set to null.
     */
    if (MApplicationPackage.Literals.UI_ELEMENT__WIDGET.equals(notification.getFeature())) {
      if (notification.getEventType() != Notification.SET) return;
      if (notification.getOldValue() == notification.getNewValue())
        return; // avoid extra notifications
      Object part = notification.getNotifier();
      if (part instanceof MPart) {
        IWorkbenchPartReference ref = toPartRef((MPart) part);
        if (ref != null) {
          boolean isVisible = ((MPart) part).isVisible();
          if (isVisible) {
            if (notification.getNewValue() == null) {
              /*
               * not sure if this is the right place to fix bug
               * 283922 but if there is no widget and
               * isVisible==true, we must be shutting down, and we
               * should not send partOpened notifications.
               */
              return;
            }
            SaveablesList modelManager =
                (SaveablesList)
                    ref.getPart(true).getSite().getService(ISaveablesLifecycleListener.class);
            modelManager.postOpen(ref.getPart(true));
            partList.firePartOpened(ref);
          }
        }
      }
      return;
    }

    // Interpret E4 activation events:
    if (!MApplicationPackage.Literals.ELEMENT_CONTAINER__ACTIVE_CHILD.equals(
        notification.getFeature())) return;

    // at this time we only interpreting SET events
    if (notification.getEventType() != Notification.SET
        || notification.getEventType() != Notification.CREATE) return;

    // make sure something actually changed
    Object oldPart = notification.getOldValue();
    Object newPart = notification.getNewValue();

    // create 3.x visibility events
    if ((newPart != oldPart) && (oldPart instanceof MPart) && (newPart instanceof MPart))
      changeVisibility((MPart) oldPart, (MPart) newPart);

    // create 3.x activation events
    final Object object = e4Context.get(IServiceConstants.ACTIVE_PART);
    if ((newPart != oldPart) && newPart instanceof MPerspective) {
      // let legacy Workbench know about perspective activation
      IWorkbenchPage page = (IWorkbenchPage) e4Context.get(IWorkbenchPage.class.getName());
      if (page != null) {
        String id = ((MPerspective) newPart).getId();
        IPerspectiveDescriptor[] descriptors = page.getOpenPerspectives();
        for (IPerspectiveDescriptor desc : descriptors) {
          if (!id.equals(desc.getId())) continue;
          page.setPerspective(desc);
        }
      }
    }
    if (object instanceof MPart) {
      IWorkbenchPartReference ref = toPartRef((MPart) object);
      if (ref != null) {
        // set the Focus to the newly active part
        IWorkbenchPart part = ref.getPart(true);
        part.setFocus();
        // Update the action bars
        SubActionBars bars = (SubActionBars) ((PartSite) part.getSite()).getActionBars();
        bars.partChanged(part);
        partList.setActivePart(ref);
        if (ref instanceof IEditorReference) {
          IEditorReference editorReference = (IEditorReference) ref;
          partList.setActiveEditor(editorReference);
          final IEditorPart editor = editorReference.getEditor(true);
          e4Context.set(ISources.ACTIVE_EDITOR_NAME, editor);
          e4Context.set(ISources.ACTIVE_EDITOR_ID_NAME, editor.getSite().getId());
          e4Context.set(ISources.ACTIVE_EDITOR_INPUT_NAME, editor.getEditorInput());
        }
      }
    } else {
      partList.setActiveEditor(null);
      e4Context.set(ISources.ACTIVE_EDITOR_NAME, null);
      e4Context.set(ISources.ACTIVE_EDITOR_ID_NAME, null);
      e4Context.set(ISources.ACTIVE_EDITOR_INPUT_NAME, null);
      partList.setActivePart(null);
    }
  }
コード例 #17
0
  /**
   * Note: This test takes a while to run, but it's testing scalability after all.
   *
   * @throws Exception
   */
  public void testManyNonUIThreadsUpdatingEditorDocument() throws Exception {
    final int numberOfJobs = 30;
    /** 15 minute timeout before we stop waiting for the change jobs to complete */
    long timeout = 15 * 60 * 1000;

    long startTime = System.currentTimeMillis();
    IFile file = getOrCreateFile(PROJECT_NAME + "/" + "testManyBackgroundChanges.xml");
    ITextFileBufferManager textFileBufferManager = FileBuffers.getTextFileBufferManager();
    textFileBufferManager.connect(
        file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());

    ITextFileBuffer textFileBuffer =
        textFileBufferManager.getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
    final IDocument document = textFileBuffer.getDocument();
    document.replace(0, 0, "<?xml encoding=\"UTF-8\" version=\"1.0\"?>\n");
    textFileBuffer.commit(new NullProgressMonitor(), true);

    final int insertionPoint = document.getLength();
    final char names[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
    // numberOfJobs Jobs, inserting 26 tags, each 4 characters long
    int expectedLength = insertionPoint + numberOfJobs * 4 * names.length;
    IWorkbenchPage activePage =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    activePage.showView(IPageLayout.ID_PROGRESS_VIEW);
    IEditorPart openedEditor = IDE.openEditor(activePage, file);

    final int finished[] = new int[] {numberOfJobs};
    Job changers[] = new Job[numberOfJobs];
    for (int i = 0; i < changers.length; i++) {
      changers[i] =
          new Job("Text Changer " + Integer.toString(i)) {
            protected IStatus run(IProgressMonitor monitor) {
              try {
                for (int j = 0; j < names.length; j++) {
                  document.replace(insertionPoint + 4 * j, 0, "<" + names[j] + "/>");
                }
              } catch (Exception e) {
                return new Status(IStatus.ERROR, SSEUIPlugin.ID, e.getMessage());
              } finally {
                finished[0]--;
              }
              return Status.OK_STATUS;
            }
          };
      changers[i].setUser(true);
      changers[i].setSystem(false);
    }
    for (int i = 0; i < changers.length; i++) {
      changers[i].schedule();
    }

    long runtime = 0;
    while (finished[0] > 0 && (runtime = System.currentTimeMillis()) - startTime < timeout) {
      openedEditor.getSite().getShell().getDisplay().readAndDispatch();
    }
    assertTrue("Test timed out: (" + timeout + " was allowed)", runtime - startTime < timeout);

    int finalLength = document.getLength();
    textFileBuffer.commit(new NullProgressMonitor(), true);
    textFileBufferManager.disconnect(
        file.getFullPath(), LocationKind.IFILE, new NullProgressMonitor());
    activePage.closeEditor(openedEditor, false);
    assertEquals("Some non-UI changes did not apply", expectedLength, finalLength);
  }
コード例 #18
0
  /** Updates the outline page's context menu for the current input */
  private void updateContextMenuId() {
    String computedContextMenuId = null;
    // update outline view's context menu control and ID

    if (fEditor == null) {
      IWorkbenchPage page = getSite().getWorkbenchWindow().getActivePage();
      if (page != null) {
        fEditor = page.getActiveEditor();
      }
    }

    computedContextMenuId = computeContextMenuID();

    if (computedContextMenuId == null) {
      computedContextMenuId = OUTLINE_CONTEXT_MENU_ID;
    }

    /*
     * Update outline context menu id if updating to a new id or if
     * context menu is not already set up
     */
    if (!computedContextMenuId.equals(fContextMenuId) || (fContextMenu == null)) {
      fContextMenuId = computedContextMenuId;

      if (getControl() != null && !getControl().isDisposed()) {
        // dispose of previous context menu
        if (fContextMenu != null) {
          fContextMenu.dispose();
        }
        if (fContextMenuManager != null) {
          fContextMenuManager.removeMenuListener(fGroupAdder);
          fContextMenuManager.removeAll();
          fContextMenuManager.dispose();
        }

        fContextMenuManager = new MenuManager(fContextMenuId, fContextMenuId);
        fContextMenuManager.setRemoveAllWhenShown(true);

        fContextMenuManager.addMenuListener(fGroupAdder);

        fContextMenu = fContextMenuManager.createContextMenu(getControl());
        getControl().setMenu(fContextMenu);

        getSite().registerContextMenu(fContextMenuId, fContextMenuManager, this);

        /*
         * also register this menu for source page part and structured
         * text outline view ids
         */
        if (fEditor != null && fEditor.getSite() != null) {
          String partId = fEditor.getSite().getId();
          if (partId != null) {
            getSite()
                .registerContextMenu(
                    partId + OUTLINE_CONTEXT_MENU_SUFFIX, fContextMenuManager, this);
          }
        }
        getSite().registerContextMenu(OUTLINE_CONTEXT_MENU_ID, fContextMenuManager, this);
      }
    }
  }
コード例 #19
0
 public void setActiveEditor(IEditorPart targetEditor) {
   super.setActiveEditor(targetEditor);
   workbench = targetEditor.getSite().getWorkbenchWindow().getActivePage();
   workbench.addPartListener(this);
   targetEditor.addPropertyListener(this);
 }
コード例 #20
0
 public SynchronizationManager(
     IEditorPart editor, AspectEditModel editModel, SynchronizationHandler handler) {
   partListener = new ActivationListener(this, editor, handler, editModel);
   editor.getSite().getWorkbenchWindow().getPartService().addPartListener(partListener);
   PlatformUI.getWorkbench().addWindowListener(partListener);
 }
コード例 #21
0
 /* (non-Javadoc)
  * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
  */
 public void windowClosed(IWorkbenchWindow window) {
   if (editor.getSite().getWorkbenchWindow() == window) {
     manager.dispose();
   }
 }