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


Java IWorkbenchPage.getActivePart方法代碼示例

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


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

示例1: getEditor

import org.eclipse.ui.IWorkbenchPage; //導入方法依賴的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

示例2: execute

import org.eclipse.ui.IWorkbenchPage; //導入方法依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
	if (null == activeWorkbenchWindow) {
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (null == activePage) {
		return null;
	}
	IWorkbenchPart activePart = activePage.getActivePart();
	if (!(activePart instanceof CommonNavigator)) {
		return null;
	}

	CommonNavigator navigator = (CommonNavigator) activePart;
	CommonViewer commonViewer = navigator.getCommonViewer();

	Tree navigatorTree = commonViewer.getTree();
	List<TreeItem> visibleItems = new ArrayList<>();
	collectChildren(navigatorTree.getItems(), visibleItems);

	List<Object> visibleData = visibleItems.stream().map(i -> i.getData()).collect(Collectors.toList());

	commonViewer.setSelection(new StructuredSelection(visibleData), false);

	return null;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:29,代碼來源:SelectAllProjectExplorerHandler.java

示例3: test

import org.eclipse.ui.IWorkbenchPage; //導入方法依賴的package包/類
@Override
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    if ("gluonMobileFound".equals(property)) {
        try {
            IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
            if (activeWorkbenchWindow == null) {
                return false;
            }
            IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
            if (activePage == null) {
                return false;
            }
            IWorkbenchPart activePart = activePage.getActivePart();
            if (activePart == null || ! (activePart instanceof CompilationUnitEditor)) {
                return false;
            }
            IEditorPart editor = activePage.getActiveEditor();
            if (editor == null) {
                return false;
            }
            IEditorInput input = editor.getEditorInput();
            if (input == null || ! (input instanceof FileEditorInput)) {
                return false;
            }
            IFile file = ((FileEditorInput) input).getFile();
            if (file != null && file.getType() == IResource.FILE && file.getFileExtension().equals("java")) {
                ProjectUtils utils = new ProjectUtils(file.getProject());
            return utils.isGluonMobileProject();
            }
        } catch (Exception e) { }
    }
    return false;
}
 
開發者ID:gluonhq,項目名稱:ide-plugins,代碼行數:34,代碼來源:InsertFunctionTester.java

示例4: getActivePart

import org.eclipse.ui.IWorkbenchPage; //導入方法依賴的package包/類
private IWorkbenchPart getActivePart()
{
	IWorkbenchWindow activeWindow = getWorkbench().getActiveWorkbenchWindow();
	if( activeWindow != null )
	{
		IWorkbenchPage activePage = activeWindow.getActivePage();
		if( activePage != null )
		{
			return activePage.getActivePart();
		}
	}
	return null;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:NewPluginWizard.java


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