本文整理汇总了Java中org.eclipse.ui.navigator.CommonNavigator类的典型用法代码示例。如果您正苦于以下问题:Java CommonNavigator类的具体用法?Java CommonNavigator怎么用?Java CommonNavigator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommonNavigator类属于org.eclipse.ui.navigator包,在下文中一共展示了CommonNavigator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectedProject
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/** Tries to find the currently selected project in the currently selected editor or view,
* if the editor is some kind of file editor or the view is a navigator.
* @param window
* @return null if can't find a project, else a project.
*/
public static IProject getSelectedProject(IWorkbenchWindow window) {
ISelection selection = null;
IWorkbenchPart part = window.getPartService().getActivePart();
if (part instanceof CommonViewer) {
selection = ((CommonViewer) part).getSelection();
} else if (part instanceof CommonNavigator) {
selection = ((CommonNavigator) part).getCommonViewer().getSelection();
} else if (part instanceof IEditorPart) {
IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
if (editorInput instanceof FileEditorInput) return ((FileEditorInput) editorInput).getFile().getProject();
}
if(selection != null && selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection)selection;
Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof IProject) return ((IProject) firstElement);
if (firstElement instanceof IFile) return ((IFile) firstElement).getProject();
}
return null;
}
示例2: addViewListener
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
private static void addViewListener(final UpgradeNotifier upgradeNotifier, final IViewPart viewPart) {
// display alert
Display.getDefault().asyncExec(new Runnable() {
@Override
@SuppressWarnings("synthetic-access")
public void run() {
if (viewPart instanceof IPackagesViewPart && ((IPackagesViewPart) viewPart).getTreeViewer() != null) {
((IPackagesViewPart) viewPart).getTreeViewer().addSelectionChangedListener(upgradeNotifier);
((IPackagesViewPart) viewPart).getTreeViewer().addTreeListener(upgradeNotifier);
} else if (viewPart instanceof CommonNavigator
&& ((CommonNavigator) viewPart).getCommonViewer() != null) {
((CommonNavigator) viewPart).getCommonViewer().addSelectionChangedListener(upgradeNotifier);
((CommonNavigator) viewPart).getCommonViewer().addTreeListener(upgradeNotifier);
}
}
});
}
示例3: execute
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的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;
}
示例4: execute
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if(part instanceof CommonNavigator){
DeleteAction action=new DeleteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
action.run();
}
else if (part instanceof ELTGraphicalEditor) {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
((ELTGraphicalEditor) editor).deleteSelection();
((ELTGraphicalEditor) editor).hideToolTip();
}
return null;
}
示例5: execute
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
List<IFile> jobFiles = new ArrayList<>();
List<IFile> pastedFileList = new ArrayList<>();
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if(part instanceof CommonNavigator){
PasteAction action = new PasteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
action.run();
IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
IProject project = workSpaceRoot.getProject(JobCopyParticipant.getCopyToPath().split("/")[1]);
IFolder jobFolder = project.getFolder(
JobCopyParticipant.getCopyToPath().substring(JobCopyParticipant.getCopyToPath().indexOf('/', 2)));
IFolder paramFolder = project.getFolder(PARAMETER_FOLDER_NAME);
try {
createCurrentJobFileList(jobFolder, jobFiles);
pastedFileList=getPastedFileList(jobFiles);
generateUniqueJobIdForPastedFiles(pastedFileList);
createXmlFilesForPastedJobFiles(pastedFileList);
List<String> copiedPropertiesList = getCopiedPropertiesList();
createPropertiesFilesForPastedFiles(paramFolder, pastedFileList, copiedPropertiesList);
JobCopyParticipant.cleanUpStaticResourcesAfterPasteOperation();
} catch (CoreException coreException) {
logger.warn("Error while copy paste jobFiles",coreException.getMessage() );
}
}
else if(part instanceof ELTGraphicalEditor){
IEditorPart editor = HandlerUtil.getActiveEditor(event);
((ELTGraphicalEditor)editor).pasteSelection();
}
return null;
}
示例6: execute
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if(part instanceof CommonNavigator){
CopyToClipboardAction action=new CopyToClipboardAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
action.run();
}
else if(part instanceof ELTGraphicalEditor){
IEditorPart editor = HandlerUtil.getActiveEditor(event);
((ELTGraphicalEditor)editor).copySelection();
}
return null;
}
示例7: findCommonNavigator
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/**
* Finds the CommonNavigatorViewer by name
* @param navigatorViewId
* @return
*/
private static CommonNavigator findCommonNavigator(String navigatorViewId)
{
IWorkbenchPage page = UIHelper.getActivePage();
if (page != null)
{
IViewPart findView = UIHelper.getActivePage().findView(navigatorViewId);
if (findView != null && findView instanceof CommonNavigator)
{
return ((CommonNavigator) findView);
}
}
return null;
}
示例8: getViewer
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/**
* Retrieves the current viewer if any
* @return the instance of common viewer or <code>null</code>
*/
public static CommonViewer getViewer()
{
CommonNavigator navigator = findCommonNavigator(ToolboxExplorer.VIEW_ID);
if (navigator != null)
{
final CommonViewer commonViewer = navigator.getCommonViewer();
commonViewer.setAutoExpandLevel(DEFAULT_EXPAND_LEVEL);
return commonViewer;
}
return null;
}
示例9: findCommonNavigator
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
public static CommonNavigator findCommonNavigator(String navigatorViewId)
{
IWorkbenchPage page = getActiveWBPage();
if (page != null)
{
IViewPart view = page.findView(navigatorViewId);
if (view != null && view instanceof CommonNavigator)
return ((CommonNavigator) view);
}
return null;
}
示例10: setInitLinkEnable
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/**
* 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 link with editor 按钮处于选中状态
* robert 2013-01-04
*/
private void setInitLinkEnable(){
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
boolean isInitialRun = !store.getBoolean(IPreferenceConstants.INITIAL_RUN);
if (isInitialRun) {
IViewPart navigator = getWindowConfigurer().getWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
CommonNavigator commonNavigator = (CommonNavigator) navigator;
commonNavigator.setLinkingEnabled(true);
store.setValue(IPreferenceConstants.INITIAL_RUN, true);
}
}
示例11: getAdapter
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof ProjectExplorer) {
if (IPropertySheetPage.class == adapterType)
return new TabbedPropertySheetPage(
new TabbedPropertySheetProjectExplorerContributor(
(CommonNavigator) adaptableObject));
}
return null;
}
示例12: addProjectsViewListener
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
private void addProjectsViewListener() {
if (page != null && page.findView(Constants.PROJECT_EXPLORER_ID) != null) {
projectExplorer = (CommonNavigator) page.findView(Constants.PROJECT_EXPLORER_ID);
addViewListener(this, projectExplorer);
} else {
if (logger.isInfoEnabled()) {
logger.info("Unable to add upgrade notifier to project explorer - page and/or '"
+ Constants.PROJECT_EXPLORER_ID + "' view null or empty");
}
}
}
示例13: VPExplorerContent
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/**
* Constructor to bound the content wrapper to a specific explorer.
*
* @param navigator
* The explorer to notify about input changes.
*/
public VPExplorerContent(CommonNavigator navigator) {
if (navigator == null) {
logger.warn("Tried to register null as VPExplorer");
throw new IllegalArgumentException("Tried to register null as VPExplorer");
}
this.navigatorToRefresh = navigator;
}
示例14: setInitLinkEnable
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
/**
* 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 link with editor 按钮处于选中状态
* robert 2013-01-04
*/
private void setInitLinkEnable(){
IPreferenceStore store = Activator.getDefault().getPreferenceStore();
boolean isInitialRun = !store.getBoolean(IPreferenceConstants.INITIAL_RUN);
if (isInitialRun) {
IViewPart navigator = getWindowConfigurer().getWindow().getActivePage().findView("net.heartsome.cat.common.ui.navigator.view");
System.out.println("navigator.getViewSite() = " + navigator.getViewSite());
CommonNavigator commonNavigator = (CommonNavigator) navigator;
commonNavigator.setLinkingEnabled(true);
store.setValue(IPreferenceConstants.INITIAL_RUN, true);
}
}
示例15: getViewers
import org.eclipse.ui.navigator.CommonNavigator; //导入依赖的package包/类
@Override
public List<StructuredViewer> getViewers() {
List<StructuredViewer> viewers = new ArrayList<StructuredViewer>();
IViewPart view = super.getPartForAction();
if (view instanceof CommonNavigator) {
CommonNavigator navigator = (CommonNavigator) view;
viewers.add(navigator.getCommonViewer());
}
return viewers;
}