类org.eclipse.ui.IWorkbenchPartReference源码实例Demo

下面列出了怎么用org.eclipse.ui.IWorkbenchPartReference的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ice   文件: MeshElementTreeView.java
/**
 * This function is called whenever a Workbench part gains focus. Here, we
 * are only interested if the part is an ICEFormEditor. A call to this
 * function will occur prior to a part being closed, so just keep track of
 * that form's id.
 * 
 * @param partRef
 *            The workbench part calling this function.
 * 
 * @see IPartListener2#partActivated(IWorkbenchPartReference)
 */
@Override
public void partActivated(IWorkbenchPartReference partRef) {

	logger.info("MeshElementTreeView Message: Called partActivated("
			+ partRef.getId() + ")");

	if (partRef.getId().equals(ICEFormEditor.ID)) {
		// Get the activated editor
		ICEFormEditor activeEditor = (ICEFormEditor) partRef.getPart(false);
		// Pull the form from the editor
		Form activeForm = ((ICEFormInput) activeEditor.getEditorInput())
				.getForm();
		// Record the ID of this form
		lastFormItemID = activeForm.getItemID();
	}

	return;
}
 
源代码2 项目: CogniCrypt   文件: CrySLProjectTransformer.java
@Override
public void partOpened(IWorkbenchPartReference partRef) {

	if (Constants.cryslEditorID.equals(partRef.getId())) {
		IResource file = partRef.getPage().getActiveEditor().getEditorInput().getAdapter(IResource.class);
		if (Constants.cryslFileEnding.substring(1).equals(file.getFileExtension())) {
			IProject projectOfOpenedFile = file.getProject();
			try {
				if (!CrySLBuilderUtils.hasCrySLBuilder(projectOfOpenedFile)) {
					CrySLBuilderUtils.addCrySLBuilderToProject(projectOfOpenedFile);
				}
			}
			catch (CoreException e) {
				Activator.getDefault().logError(e);
			}
		}
	}
}
 
源代码3 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
public void partActivated(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IViewReference)
	{
		IViewReference viewRef = (IViewReference) partRef;
		String id = viewRef.getId();
		if ("org.eclipse.ui.console.ConsoleView".equals(id) || "org.eclipse.jdt.ui.TypeHierarchy".equals(id) //$NON-NLS-1$ //$NON-NLS-2$
				|| "org.eclipse.jdt.callhierarchy.view".equals(id)) //$NON-NLS-1$
		{
			final IViewPart part = viewRef.getView(false);
			Display.getCurrent().asyncExec(new Runnable()
			{
				public void run()
				{
					hijackView(part, false);
				}
			});
			return;
		}
	}
	if (partRef instanceof IEditorReference)
	{
		hijackOutline();
	}
}
 
源代码4 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
public void partClosed(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IEditorReference)
	{
		IEditorPart part = (IEditorPart) partRef.getPart(false);
		if (part instanceof MultiPageEditorPart)
		{
			MultiPageEditorPart multi = (MultiPageEditorPart) part;
			if (pageListener != null)
			{
				multi.getSite().getSelectionProvider().removeSelectionChangedListener(pageListener);
			}
		}
	}
	// If it's a search view, remove any query listeners for it!
	else if (partRef instanceof IViewReference)
	{
		IViewPart view = (IViewPart) partRef.getPart(false);
		if (queryListeners.containsKey(view))
		{
			NewSearchUI.removeQueryListener(queryListeners.remove(view));
		}
	}
}
 
源代码5 项目: ice   文件: ICEResourceView.java
/**
 * This function is called whenever a Workbench part is closed. If the
 * current {@link #editor} is closed, then we need to clear the view's
 * contents.
 */
@Override
public void partClosed(IWorkbenchPartReference partRef) {

	// If the closed editor is the known active ICEFormEditor, call the
	// method to clear the currently active editor and related UI pieces.
	IWorkbenchPart part = partRef.getPart(false);
	if (part != null && part instanceof ICEFormEditor) {
		ICEFormEditor activeEditor = (ICEFormEditor) partRef.getPart(false);
		if (activeEditor == editor) {
			setActiveEditor(null);
		}
	}

	return;
}
 
源代码6 项目: saros   文件: SafePartListener2.java
@Override
public void partDeactivated(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partDeactivated(partRef);
        }
      });
}
 
源代码7 项目: tracecompass   文件: SWTBotUtils.java
/**
 * Maximize a workbench part and wait for one of its controls to be resized.
 * Calling this a second time will "un-maximize" the part.
 *
 * @param partReference
 *            the {@link IWorkbenchPartReference} which contains the control
 * @param controlBot
 *            a control that should be resized
 */
public static void maximize(IWorkbenchPartReference partReference, AbstractSWTBotControl<?> controlBot) {
    final AtomicBoolean controlResized = new AtomicBoolean();
    Control control = controlBot.widget;
    assertNotNull(control);
    UIThreadRunnable.syncExec(new VoidResult() {
        @Override
        public void run() {
            control.addControlListener(new ControlAdapter() {
                @Override
                public void controlResized(ControlEvent e) {
                    control.removeControlListener(this);
                    controlResized.set(true);
                }
            });
        }
    });
    IWorkbenchPart part = partReference.getPart(false);
    assertNotNull(part);
    maximize(part);
    new SWTBot().waitUntil(new DefaultCondition() {
        @Override
        public boolean test() throws Exception {
            return controlResized.get();
        }

        @Override
        public String getFailureMessage() {
            return "Control was not resized";
        }
    });
}
 
源代码8 项目: tlaplus   文件: ModelEditorPartListener.java
/**
    * This updates the error view. If the error view is not open,
    * then the user may have closed it, so nothing is done.
    * If the error view is open but the model editor being switched
    * to has no errors, then the error view is cleared but not closed.
    * If the model editor made visible does have errors, then the error
    * view is updated with these errors.
    */
public void partVisible(final IWorkbenchPartReference partRef) {
       final IWorkbenchPart part = partRef.getPart(false);
       
	if ((part != null) && (part instanceof ModelEditor)) {
		final ModelEditor editor = (ModelEditor) part;
		final TLCModelLaunchDataProvider provider;

		final Model model = editor.getModel();
		if (model.isOriginalTraceShown()) {
			provider = TLCOutputSourceRegistry.getModelCheckSourceRegistry().getProvider(model);
		} else {
			provider = TLCOutputSourceRegistry.getTraceExploreSourceRegistry().getProvider(model);
		}

		final TLCErrorView errorView = (TLCErrorView) UIHelper.findView(TLCErrorView.ID);
		if ((errorView != null) && (provider != null)) {
			if (provider.getErrors().size() > 0) {
				// Tell the TLCErrorView update function to not open the
				// TLCErrorView iff the ModelEditor and the TLCErrorView
				// would open in the same part stack (on top of each other).
				// This prevents a stackoverflow that results from cyclic
				// focus activation when the ModelEditor triggers the
				// TLCErrorView to be opened while ModelEditor itself
				// becomes visible (see partVisible()).
				//
				// The steps to reproduce were:
		    	// 0) Open model with errors trace
		    	// 1) Drag the model editor on top of the TLC error view
		    	// 2) Change focus from model editor, to TLC error and spec editor a couple of times
		    	// 3) Run the model
		    	// 4) Cycle focus
				// 5) Bam!
				TLCErrorView.updateErrorView(editor, !UIHelper.isInSameStack(editor, TLCErrorView.ID));
			} else {
				errorView.clear();
			}
		}
	}
   }
 
源代码9 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
public void partDeactivated(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IEditorReference)
	{
		hijackOutline();
	}
}
 
源代码10 项目: translationstudio8   文件: MatchViewPart.java
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);
	site.getPage().addPostSelectionListener(this);
	site.getPage().addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				getSite().getPage().removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = getSite().getPage().getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						synchronized (matchDataContainer) {
							matchDataContainer.clear();
							if (matcherThread != null) {
								matcherThread.interrupt();
							}
						}
						manualTranslationThread.interruptCurrentTask();

						tmMatcher.clearDbResources();
						copyEnable.resetSelection();
						gridTable.removeAll();
						sourceText.setText("");
						setMatchMessage(null, "", "");
						setProcessMessage(null, "", "");
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager().setMessage(Messages.getString("view.MatchViewPart.statusLine"));
}
 
源代码11 项目: saros   文件: SafePartListener2.java
@Override
public void partClosed(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partClosed(partRef);
        }
      });
}
 
源代码12 项目: saros   文件: SafePartListener2.java
@Override
public void partActivated(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partActivated(partRef);
        }
      });
}
 
源代码13 项目: typescript.java   文件: RenameInformationPopup.java
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
	IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
	if (fPopup != null && ! fPopup.isDisposed() && partRef.getPart(false) == fPart) {
		fPopup.setVisible(false);
	}
}
 
源代码14 项目: xtext-eclipse   文件: AbstractSourceView.java
@Override
public void partInputChanged(IWorkbenchPartReference ref) {
	if (!ref.getId().equals(getSite().getId())) {
		IWorkbenchPart workbenchPart = ref.getPart(false);
		ISelectionProvider provider = workbenchPart.getSite().getSelectionProvider();
		if (provider == null) {
			return;
		}
		ISelection selection = provider.getSelection();
		if (selection == null || selection.isEmpty()) {
			return;
		}
		computeAndSetInput(new DefaultWorkbenchPartSelection(ref.getPart(false), selection));
	}
}
 
源代码15 项目: ice   文件: EMFTreeCompositeViewer.java
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {

	if (partRef.getId().equals(ICEFormEditor.ID)) {
		logger.info("EMFTreeCompositeViewer message: "
				+ "EMFFormEditor part deactivated.");

		// If the active editor closed, reset the active editor reference.
		if (partRef == activeEditorRef) {
			activeEditorRef = null;
		}
	}

	return;
}
 
源代码16 项目: tracecompass   文件: AbstractTimeGraphView.java
@Override
public void partHidden(IWorkbenchPartReference partRef) {
    IWorkbenchPart part = partRef.getPart(false);
    if (part != null && part == AbstractTimeGraphView.this) {
        Display.getDefault().asyncExec(() -> {
            if (fTimeEventFilterDialog != null) {
                fTimeEventFilterDialog.close();
            }
        });
    }
}
 
源代码17 项目: xtext-eclipse   文件: RenameRefactoringPopup.java
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
	IWorkbenchPart fPart = editor.getEditorSite().getPart();
	if (popup != null && !popup.isDisposed() && partRef.getPart(false) == fPart) {
		popup.setVisible(false);
	}
}
 
源代码18 项目: tmxeditor8   文件: TerminologyViewPart.java
@Override
public void init(IViewSite site, IMemento memento) throws PartInitException {
	init(site);

	final IWorkbenchPage page = site.getPage();
	page.addPostSelectionListener(this);
	page.addPartListener(new PartAdapter2() {
		@Override
		public void partClosed(IWorkbenchPartReference partRef) {
			if (gridTable == null || gridTable.isDisposed()) {
				page.removePartListener(this); // 关闭视图后,移除此监听
			} else {
				if ("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor".equals(partRef.getId())) {
					IEditorReference[] editorReferences = page.getEditorReferences();
					if (editorReferences.length == 0) { // 所有编辑器全部关闭的情况下。
						matcher.clearResources();
						firstAction.setEnabled(false);
						copyEnable.resetSelection();
						gridTable.removeAll();
					}
				}
			}
		}
	});
	site.getActionBars().getStatusLineManager()
			.setMessage(Messages.getString("view.TerminologyViewPart.statusLine"));
}
 
源代码19 项目: xds-ide   文件: ModulaOutlinePage.java
@Override
public void partHidden(IWorkbenchPartReference partRef) {
    IWorkbenchPart part= partRef.getPart(false);
    if (part instanceof ContentOutline) {
        isViewVisible= false;
    }
}
 
public void partOpened(IWorkbenchPartReference ref) {
}
 
public void partClosed(IWorkbenchPartReference partRef) {
	// nothing to do
}
 
源代码22 项目: eclipse-cs   文件: CheckFileOnOpenPartListener.java
/**
 * {@inheritDoc}
 */
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
  // NOOP
}
 
源代码23 项目: IndentGuide   文件: Starter.java
public void partHidden(IWorkbenchPartReference partRef) {
}
 
源代码24 项目: typescript.java   文件: RenameInformationPopup.java
@Override
public void partOpened(IWorkbenchPartReference partRef) {
	// nothing to do
}
 
源代码25 项目: eclipse-cs   文件: CheckFileOnOpenPartListener.java
/**
 * {@inheritDoc}
 */
@Override
public void partVisible(IWorkbenchPartReference partRef) {
  // NOOP
}
 
public void windowActivated(IWorkbenchWindow window) {
	IWorkbenchPartReference ref= window.getPartService().getActivePartReference();
	if (isJavaEditor(ref) && !isActiveEditor(ref))
		activeJavaEditorChanged(ref.getPart(true));
}
 
源代码27 项目: n4js   文件: PartListener2Adapter.java
@Override
public void partActivated(final IWorkbenchPartReference partRef) {
	// Does nothing by default.
}
 
源代码28 项目: eclipsegraphviz   文件: GraphicalView.java
public void partClosed(IWorkbenchPartReference partRef) {
    //
}
 
源代码29 项目: n4js   文件: PartListener2Adapter.java
@Override
public void partClosed(final IWorkbenchPartReference partRef) {
	// Does nothing by default.
}
 
源代码30 项目: tlaplus   文件: ModelEditorPartListener.java
public void partClosed(IWorkbenchPartReference partRef) {
	// ignored
}
 
 类所在包
 同包方法