Java Code Examples for org.eclipse.ui.IWorkbenchWindow#addPerspectiveListener()

The following examples show how to use org.eclipse.ui.IWorkbenchWindow#addPerspectiveListener() . 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: GdtPlugin.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds the new wizards to the current perspective displayed in <code>activeWorkbenchWindow</code>, if they've not
 * been added already. Adds listeners on the window so that the same is done whenever the user switches perspectives
 * in the window.
 *
 * Note: This method can only be called once the workbench has been started.
 */
private void maybeAddNewWizardActionsToWindow(IWorkbenchWindow activeWorkbenchWindow) {
  if (activeWorkbenchWindow == null) {
    return;
  }

  activeWorkbenchWindow.addPerspectiveListener(perspectiveListener);

  WorkbenchPage activePage = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
  if (activePage == null) {
    return;
  }

  IPerspectiveDescriptor perspectiveDesc = activePage.getPerspective();
  maybeAddNewWizardActionsToPerspective(activePage, perspectiveDesc);
}
 
Example 2
Source File: UIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void addPerspectiveListener()
{
	try
	{
		IWorkbench workbench = PlatformUI.getWorkbench();
		if (workbench != null)
		{
			IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
			for (IWorkbenchWindow window : windows)
			{
				window.addPerspectiveListener(perspectiveListener);
			}
			// listens on any future windows
			PlatformUI.getWorkbench().addWindowListener(windowListener);
		}
	}
	catch (Exception e)
	{
		// ignore, may be running headless, like in tests
	}
}
 
Example 3
Source File: AllInOneWorkbenchListener.java    From typescript.java with MIT License 5 votes vote down vote up
private void hookListeners(IWorkbenchWindow window) {
	if (window == null)
		return;
	window.addPageListener(this);
	window.addPerspectiveListener(this);
	for (IWorkbenchPage page : window.getPages()) {
		hookListeners(page);
	}
}
 
Example 4
Source File: DropWorkbenchChangeListener.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected void hookWindow(IWorkbenchWindow window) {
	if (window == null) {
		return;
	}
	window.addPageListener(this);
	window.addPerspectiveListener(this);
	IPartService partService = (IPartService) window.getService(IPartService.class);
	partService.addPartListener(this);
	windowChanged(window);
}
 
Example 5
Source File: CleanupHelper.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static void run() {
	final RemoveUnwantedActionSets remove = new RemoveUnwantedActionSets();
	final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
	for (final IWorkbenchWindow window : windows) {
		final IWorkbenchPage page = window.getActivePage();
		if (page != null) {
			// Doing the initial cleanup on the default perspective
			// (modeling)
			remove.perspectiveActivated(page, null);
		}
		window.addPerspectiveListener(remove);
	}
}
 
Example 6
Source File: UIPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void windowOpened(IWorkbenchWindow window)
{
	window.addPerspectiveListener(perspectiveListener);
	if (!hasMainWindowActivated)
	{
		hasMainWindowActivated = true;
		IWorkbenchPage page = window.getActivePage();
		if (page != null)
		{
			perspectiveListener.perspectiveActivated(page, page.getPerspective());
		}
	}
}
 
Example 7
Source File: CommonEditorPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
public void windowOpened(IWorkbenchWindow window)
{
	IPartService partService = window.getPartService();
	if (partService != null)
	{
		partService.addPartListener(fPartListener);
	}
	window.addPerspectiveListener(fPerspectiveListener);
}
 
Example 8
Source File: CommonEditorPlugin.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private void addPartListener()
{
	try
	{
		IWorkbench workbench = PlatformUI.getWorkbench();
		if (workbench != null)
		{
			IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
			IPartService partService;
			for (IWorkbenchWindow window : windows)
			{
				partService = window.getPartService();
				if (partService != null)
				{
					partService.addPartListener(fPartListener);
				}
				window.addPerspectiveListener(fPerspectiveListener);
			}

			// Listen on any future windows
			PlatformUI.getWorkbench().addWindowListener(fWindowListener);
		}
	}
	catch (Exception e)
	{
		// ignore, may be running headless, like in tests
	}
}
 
Example 9
Source File: UIHelper.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * Attaches the perspective listener to active window
 * 
 * @param listener
 */
public static void addPerspectiveListener(IPerspectiveListener listener) {
	IWorkbench workbench = Activator.getDefault().getWorkbench();
	IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
	window.addPerspectiveListener(listener);
}
 
Example 10
Source File: StatechartDiagramActionbarContributor.java    From statecharts with Eclipse Public License 1.0 4 votes vote down vote up
private void showButtonsByPerspective(IActionBars bars) {
	IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	win.addPerspectiveListener(new DisableButtonsByPerspectiveListener(bars));
}