當前位置: 首頁>>代碼示例>>Java>>正文


Java IWorkbench.getActiveWorkbenchWindow方法代碼示例

本文整理匯總了Java中org.eclipse.ui.IWorkbench.getActiveWorkbenchWindow方法的典型用法代碼示例。如果您正苦於以下問題:Java IWorkbench.getActiveWorkbenchWindow方法的具體用法?Java IWorkbench.getActiveWorkbenchWindow怎麽用?Java IWorkbench.getActiveWorkbenchWindow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.ui.IWorkbench的用法示例。


在下文中一共展示了IWorkbench.getActiveWorkbenchWindow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BatchEditor){
		executeOnBatchEditor((BatchEditor) editor);
	}
	return null;
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:22,代碼來源:AbstractBatchEditorHandler.java

示例2: getEditor

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
protected AvroSchemaEditor getEditor() {
	
	IWorkbench workbench = PlatformUI.getWorkbench();
       IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

       if (window != null) {
           IWorkbenchPage workbenchPage = window.getActivePage();
           if (workbenchPage != null) {
           	IWorkbenchPart activePart = workbenchPage.getActivePart();                
               if (activePart instanceof IWithAvroSchemaEditor) {
               	return ((IWithAvroSchemaEditor) activePart).getEditor();
               }
           }
       }
       
       return null;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:18,代碼來源:SchemaEditorPropertyTester.java

示例3: execute

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BashEditor){
		executeOnBashEditor((BashEditor) editor);
	}
	return null;
}
 
開發者ID:de-jcup,項目名稱:eclipse-bash-editor,代碼行數:22,代碼來源:AbstractBashEditorHandler.java

示例4: search

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
protected void search(String pattern, SearchType type, boolean withRef) {    	    	
	IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
    IEditorPart editorPart = workbenchPage.getActiveEditor();
    if (editorPart instanceof IWithAvroSchemaEditor) {
    	AvroSchemaEditor schemaEditor = ((IWithAvroSchemaEditor) editorPart).getEditor();        	
    	AvroContext masterContext = schemaEditor.getContext().getMaster();
    	SearchNodeContext searchNodeContext = masterContext.getSearchNodeContext();
    	if (pattern == null || pattern.trim().isEmpty()) {
    		searchNodeContext.reset();
    	} else if (searchNodeContext.searchNodes(type, pattern, withRef)) {
    		AvroNode node = searchNodeContext.next();
    		schemaEditor.getContentPart()
    			.getSchemaViewer(AvroContext.Kind.MASTER)
    			.setSelection(new StructuredSelection(node), true);
    	}
    	refreshCommands(editorPart, SearchNodePropertyTester.PROPERTIES);
    }
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:21,代碼來源:SearchNodeControl.java

示例5: unsafeGetWorkbenchPage

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
static private final IWorkbenchPage unsafeGetWorkbenchPage() {
	IWorkbenchPage page = null;
	if (PlatformUI.isWorkbenchRunning()) {
		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
		page = win.getActivePage();
	}
	return page;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:10,代碼來源:EditorsUtil.java

示例6: getActivePage

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/***/
@SuppressWarnings("restriction")
protected IWorkbenchPage getActivePage() {
	IWorkbenchPage page = null;
	if (org.eclipse.ui.internal.Workbench.getInstance() != null) {
		IWorkbench wb = PlatformUI.getWorkbench();
		IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
		// Could be null if using Timeout test rule and does not run on main thread.
		if (null != window) {
			page = window.getActivePage();
		}
	}
	return page;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:AbstractBuilderTest.java

示例7: getActiveWorkbenchWindow

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/**
 * Returns the active workbench window.
 * @return the active workbench window
 */
public IWorkbenchWindow getActiveWorkbenchWindow() {
	IWorkbench iwb = this.getWorkbench();
	if (iwb!=null) {
		return iwb.getActiveWorkbenchWindow();
	}
	return null;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:12,代碼來源:UiBridge.java

示例8: getActiveWorkbenchShell

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/**
 * Returns active workbench shell - or <code>null</code>
 * 
 * @return active workbench shell - or <code>null</code>
 */
public static Shell getActiveWorkbenchShell() {
	IWorkbench workbench = getWorkbench();
	if (workbench == null) {
		return null;
	}
	IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
	if (window == null) {
		return null;
	}
	Shell shell = window.getShell();
	return shell;
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:18,代碼來源:EclipseUtil.java

示例9: getActiveWorkbenchWindow

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
public static IWorkbenchWindow getActiveWorkbenchWindow() {
	IWorkbench workbench = getWorkbench();
	if (workbench == null) {
		return null;
	}
	IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();

	if (workbenchWindow != null) {
		return workbenchWindow;
	}
	/* fall back - try to execute in UI */
	WorkbenchWindowRunnable wwr = new WorkbenchWindowRunnable();
	getSafeDisplay().syncExec(wwr);
	return wwr.workbenchWindowFromUI;
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:16,代碼來源:EclipseUtil.java

示例10: run

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
@Override
public void run() {
	IWorkbench workbench = getWorkbench();
	if (workbench == null) {
		return;
	}
	workbenchWindowFromUI = workbench.getActiveWorkbenchWindow();
}
 
開發者ID:de-jcup,項目名稱:eclipse-batch-editor,代碼行數:9,代碼來源:EclipseUtil.java

示例11: addListeners

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
public void addListeners() {
	try {
		IWorkbench workbench = PlatformUI.getWorkbench();
		
		// Add a WorkbenchListener
		workbenchListener = new ConvertigoWorkbenchListener();
		workbench.addWorkbenchListener(workbenchListener);
		
		// Add a WindowListener
		windowListener = new ConvertigoWindowListener();
		workbench.addWindowListener(windowListener);
		
		IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); 
		if (activeWorkbenchWindow != null) {
			// Add a PerspectiveListener
			if (perspectiveListener == null) {
				perspectiveListener = new ConvertigoPerspectiveListener();
				activeWorkbenchWindow.addPerspectiveListener(perspectiveListener);
			}
			// Add a PartListener
			if (partListener == null) {
				partListener = new ConvertigoPartListener();
				IPartService partService = activeWorkbenchWindow.getPartService(); 
				partService.addPartListener(partListener);
			}
		} 
		
	}
	catch (IllegalStateException e) {
		studioLog.error("Could not add listeners to plugin."+ e.getMessage());
	}
	
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:34,代碼來源:ConvertigoPlugin.java

示例12: clean

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/**
 * Clean plug-in
 * 
 * @param context
 * @throws Exception
 */
private void clean(BundleContext context) throws Exception {
	if (consolePipes != null)
		consolePipes.stopConsoleThreads();
	
	stderrConsoleStreamColor.dispose();
	
	disposeImages();
	
	cacheIProject.clear();
	
	// Removes listeners
	try {
		IWorkbench workbench = PlatformUI.getWorkbench();
		if (windowListener != null)
			workbench.removeWindowListener(windowListener);
		if (workbenchListener != null)
			workbench.removeWorkbenchListener(workbenchListener);
		
		IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow(); 
		if (activeWorkbenchWindow != null) {
			if (perspectiveListener != null)
				activeWorkbenchWindow.removePerspectiveListener(perspectiveListener);
			if (partListener != null)
				activeWorkbenchWindow.getPartService().removePartListener(partListener);
		}			
	}
	catch (IllegalStateException e) {}
	
	if (embeddedTomcat != null)
		embeddedTomcat.stop();
}
 
開發者ID:convertigo,項目名稱:convertigo-eclipse,代碼行數:38,代碼來源:ConvertigoPlugin.java

示例13: getActivePage

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/**
 * @return IWorkbenchPage
 */
public static IWorkbenchPage getActivePage() {
	try {
		if (!PlatformUI.isWorkbenchRunning()) return null;
	} catch (Exception | NoClassDefFoundError ne) {
		return null;
	}
	final IWorkbench bench = PlatformUI.getWorkbench();
	if (bench==null) return null;
	final IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
	if (window==null) return null;
	return window.getActivePage();
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:16,代碼來源:PageUtil.java

示例14: getActivePage

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
/**
 * @return IWorkbenchPage
 */
public static IWorkbenchPage getActivePage() {
	final IWorkbench bench = PlatformUI.getWorkbench();
	if (bench==null) return null;
	final IWorkbenchWindow window = bench.getActiveWorkbenchWindow();
	if (window==null) return null;
	return window.getActivePage();
}
 
開發者ID:eclipse,項目名稱:scanning,代碼行數:11,代碼來源:Util.java

示例15: resetWorkbench

import org.eclipse.ui.IWorkbench; //導入方法依賴的package包/類
private void resetWorkbench() {
	try {
		IViewReference[] views = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
		for (IViewReference iViewReference : views) {
			 if ( iViewReference.getTitle().equals( "Welcome" ) ) {
				 	iViewReference.getPage().hideView(iViewReference);
					break;
			}
		}
		
		IWorkbench workbench = PlatformUI.getWorkbench();
		IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
		IWorkbenchPage page = workbenchWindow.getActivePage();
		Shell activeShell = Display.getCurrent().getActiveShell();
		if ( activeShell != null && activeShell != workbenchWindow.getShell() ) {
			activeShell.close();
		}
		page.closeAllEditors( false );
		page.resetPerspective();
		String defaultPerspectiveId = workbench.getPerspectiveRegistry().getDefaultPerspective();
		workbench.showPerspective( defaultPerspectiveId, workbenchWindow );
		page.resetPerspective();
	}
	catch ( WorkbenchException e ) {
		throw new RuntimeException( e );
	}

}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:29,代碼來源:FilterTests.java


注:本文中的org.eclipse.ui.IWorkbench.getActiveWorkbenchWindow方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。