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

The following examples show how to use org.eclipse.ui.IWorkbenchWindow#addPageListener() . 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: OpenDocumentTracker.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Inject(optional=true)
protected void initialize(final IWorkbench workbench) {
	Assert.isNotNull(Display.getCurrent());
	partListener = new PartListener();
	pageListener = new PageListener();
	for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) {
		window.addPageListener(pageListener);
		for (IWorkbenchPage page : window.getPages()) {
			page.addPartListener(partListener);
			for (IEditorReference editorRef : page.getEditorReferences()) {
				Pair<URI, IXtextDocument> entry = getEntry(editorRef);
				if (entry != null) {
					resourceUri2document.put(entry.getFirst(), entry.getSecond());
				}
			}
		}
	}
}
 
Example 2
Source File: ActiveEditorTracker.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected void initialize(IWorkbenchWindow window) {
	if (workbenchWindow != null && !workbenchWindow.equals(window)) {
		/*
		 * TODO: implement logic for keeping track of editors in multiple
		 * workbench windows!
		 */
	}
	this.workbenchWindow = window;
	if (window == null)
		return;
	this.activePage = window.getActivePage();
	final IEditorPart editor = this.activePage.getActiveEditor();
	if (editor != null) {
		lastActiveEditorId = checkEditorAndGetId(editor);
		activeEditors.put(lastActiveEditorId, editor);
	}
	window.addPageListener(this);
	window.getPartService().addPartListener(this);
}
 
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: JSDTEditorTracker.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void windowOpened(IWorkbenchWindow window) {
	if (window.getShell() != null) {
		IWorkbenchPage[] pages = window.getPages();
		for (IWorkbenchPage page : pages) {
			pageOpened(page);
		}
		window.addPageListener(this);
	}
}
 
Example 5
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 6
Source File: EditorTracker.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void windowOpened(IWorkbenchWindow window) {
	window.addPageListener(this);
}