org.eclipse.ui.IWorkbenchPartReference Java Examples

The following examples show how to use org.eclipse.ui.IWorkbenchPartReference. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
	}
}
 
Example #2
Source File: MeshElementTreeView.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #3
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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));
		}
	}
}
 
Example #4
Source File: CrySLProjectTransformer.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@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);
			}
		}
	}
}
 
Example #5
Source File: ICEResourceView.java    From ice with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: TerminologyViewPart.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
@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"));
}
 
Example #7
Source File: EMFTreeCompositeViewer.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
@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;
}
 
Example #8
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void partDeactivated(IWorkbenchPartReference partRef)
{
	if (partRef instanceof IEditorReference)
	{
		hijackOutline();
	}
}
 
Example #9
Source File: MatchViewPart.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
@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"));
}
 
Example #10
Source File: AbstractTimeGraphView.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@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();
            }
        });
    }
}
 
Example #11
Source File: RenameRefactoringPopup.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
	IWorkbenchPart fPart = editor.getEditorSite().getPart();
	if (popup != null && !popup.isDisposed() && partRef.getPart(false) == fPart) {
		popup.setVisible(false);
	}
}
 
Example #12
Source File: AbstractSourceView.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@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));
	}
}
 
Example #13
Source File: RenameInformationPopup.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void partDeactivated(IWorkbenchPartReference partRef) {
	IWorkbenchPart fPart= fEditor.getEditorSite().getPart();
	if (fPopup != null && ! fPopup.isDisposed() && partRef.getPart(false) == fPart) {
		fPopup.setVisible(false);
	}
}
 
Example #14
Source File: SafePartListener2.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void partClosed(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partClosed(partRef);
        }
      });
}
 
Example #15
Source File: SafePartListener2.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void partActivated(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partActivated(partRef);
        }
      });
}
 
Example #16
Source File: ModulaOutlinePage.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void partHidden(IWorkbenchPartReference partRef) {
    IWorkbenchPart part= partRef.getPart(false);
    if (part instanceof ContentOutline) {
        isViewVisible= false;
    }
}
 
Example #17
Source File: ModelEditorPartListener.java    From tlaplus with MIT License 5 votes vote down vote up
/**
    * 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();
			}
		}
	}
   }
 
Example #18
Source File: SWTBotUtils.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * 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";
        }
    });
}
 
Example #19
Source File: SafePartListener2.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void partDeactivated(final IWorkbenchPartReference partRef) {
  ThreadUtils.runSafeSync(
      log,
      new Runnable() {
        @Override
        public void run() {
          toForwardTo.partDeactivated(partRef);
        }
      });
}
 
Example #20
Source File: RefreshingPartListener.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void partDeactivated(IWorkbenchPartReference partRef){
	// TODO Auto-generated method stub
	
}
 
Example #21
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void partActivated(IWorkbenchPartReference ref) {
}
 
Example #22
Source File: RenameInformationPopup.java    From typescript.java with MIT License 4 votes vote down vote up
@Override
public void partBroughtToTop(IWorkbenchPartReference partRef) {
	// nothing to do
}
 
Example #23
Source File: SyncGraphvizExportHandler.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void partOpened(IWorkbenchPartReference partRef) {
}
 
Example #24
Source File: CustomEditorListener.java    From eclipse-wakatime with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void partInputChanged(IWorkbenchPartReference partRef) {
    // TODO Auto-generated method stub

}
 
Example #25
Source File: JavaBrowsingPart.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void partClosed(IWorkbenchPartReference ref) {
}
 
Example #26
Source File: RefreshingPartListener.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void partOpened(IWorkbenchPartReference partRef){
	// TODO Auto-generated method stub
	
}
 
Example #27
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public void partVisible(IWorkbenchPartReference partRef)
{
	partActivated(partRef);
}
 
Example #28
Source File: AbstractSourceView.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void partActivated(IWorkbenchPartReference ref) {
}
 
Example #29
Source File: MOOSETreeCompositeView.java    From ice with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void partOpened(IWorkbenchPartReference partRef) {
	// Nothing to do.
}
 
Example #30
Source File: OccurrencesSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void partOpened(IWorkbenchPartReference partRef) {
}