类org.eclipse.ui.part.ISetSelectionTarget源码实例Demo

下面列出了怎么用org.eclipse.ui.part.ISetSelectionTarget的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: spotbugs   文件: ShowInPackageExplorerAction.java
@Override
public void run(IAction action) {
    if (data == null) {
        return;
    }
    IViewPart part = getView(JavaUI.ID_PACKAGES);
    if (part instanceof ISetSelectionTarget) {
        ISetSelectionTarget target = (ISetSelectionTarget) part;
        target.selectReveal(new StructuredSelection(data));
    }
}
 
源代码2 项目: typescript.java   文件: UIInterpreterHelper.java
/**
 * Select the given element in the view of the given id
 * 
 * @param element
 */
public static void selectReveal(Object element, String viewId) {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	// Select in the Project Explorer the generated files.
	IViewPart view = page.findView(viewId);
	if (view instanceof ISetSelectionTarget) {
		((ISetSelectionTarget) view).selectReveal(new StructuredSelection(element));
	}
}
 
public void run(IResource resource) {
	if (resource == null)
		return;
	try {
		IWorkbenchPage page= getSite().getWorkbenchWindow().getActivePage();
		IViewPart view= page.showView(JavaPlugin.ID_RES_NAV);
		if (view instanceof ISetSelectionTarget) {
			ISelection selection= new StructuredSelection(resource);
			((ISetSelectionTarget)view).selectReveal(selection);
		}
	} catch(PartInitException e) {
		ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.ShowInNavigatorView_error_activation_failed);
	}
}
 
private AddArchiveToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.ADD_LIB_TO_BP);

	fContext= context;

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddJarCP_label);
	setImageDescriptor(JavaPluginImages.DESC_OBJS_EXTJAR);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddJarCP_tooltip);
}
 
private ExcludeFromBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.EXCLUDE);

	fContext= context;

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_label);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_EXCLUDE_FROM_BUILDPATH);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Exclude_tooltip);
	setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_EXCLUDE_FROM_BUILDPATH);
}
 
private CreateLinkedSourceFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.CREATE_LINK);

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_label);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Link_tooltip);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_LINKED_SOURCE_TO_BUILDPATH);
	setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_createLinkedFolder);
}
 
private CreateSourceFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.CREATE_FOLDER);

	setText(ActionMessages.OpenNewSourceFolderWizardAction_text2);
	setDescription(ActionMessages.OpenNewSourceFolderWizardAction_description);
	setToolTipText(ActionMessages.OpenNewSourceFolderWizardAction_tooltip);
	setImageDescriptor(JavaPluginImages.DESC_TOOL_NEWPACKROOT);

	PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.OPEN_SOURCEFOLDER_WIZARD_ACTION);
}
 
public BuildpathModifierAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, int id, int style) {
super("", style); //$NON-NLS-1$

fSite= site;
fSelectionTarget= selectionTarget;
fSelectedElements= new ArrayList<Object>();
fListeners= new ArrayList<IBuildpathModifierListener>();

setId(Integer.toString(id));
  }
 
private EditFilterAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.EDIT_FILTERS);

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_label);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_BUILDPATH_FILTERS);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Edit_tooltip);
	setDescription(NewWizardMessages.PackageExplorerActionGroup_FormText_Edit);
	setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_BUILDPATH_FILTERS);
}
 
private AddSelectedLibraryToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.ADD_SEL_LIB_TO_BP);

fContext= context;

setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelLibToCP_label);
setImageDescriptor(JavaPluginImages.DESC_OBJS_EXTJAR);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelLibToCP_tooltip);
  }
 
private AddFolderToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.ADD_SEL_SF_TO_BP);

	fContext= context;

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_label);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_ADD_AS_SOURCE_FOLDER);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_AddSelSFToCP_tooltip);
}
 
private IncludeToBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.INCLUDE);

	fContext= context;

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_label);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_INCLUDE_ON_BUILDPATH);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Unexclude_tooltip);
	setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_INCLUDE_ON_BUILDPATH);
}
 
public ResetAllOutputFoldersAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context, IJavaProject javaProject) {
super(site, selectionTarget, BuildpathModifierAction.RESET_ALL_OUTPUT_FOLDERS);

fContext= context;
fJavaProject= javaProject;

setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
  }
 
public ResetAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.RESET);

fContext= context;

setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_Reset_tooltip);
  }
 
private EditOutputFolderAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
	super(site, selectionTarget, BuildpathModifierAction.EDIT_OUTPUT);

	fContext= context;
	fShowOutputFolders= false;

	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_EditOutput_label);
	setImageDescriptor(JavaPluginImages.DESC_ELCL_CONFIGURE_OUTPUT_FOLDER);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_EditOutput_tooltip);
	setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CONFIGURE_OUTPUT_FOLDER);
}
 
public ResetAllAction(HintTextGroup provider, IRunnableContext context, ISetSelectionTarget selectionTarget) {
	super(null, selectionTarget, BuildpathModifierAction.RESET_ALL);

	fProvider= provider;
	fContext= context;

	setImageDescriptor(JavaPluginImages.DESC_ELCL_CLEAR);
	setDisabledImageDescriptor(JavaPluginImages.DESC_DLCL_CLEAR);
	setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_label);
	setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_ClearAll_tooltip);
	setEnabled(false);
}
 
public RemoveFromBuildpathAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, IRunnableContext context) {
super(site, selectionTarget, BuildpathModifierAction.REMOVE_FROM_BP);

fContext= context;

setText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_label);
setToolTipText(NewWizardMessages.NewSourceContainerWorkbookPage_ToolBar_RemoveFromCP_tooltip);
  }
 
源代码18 项目: typescript.java   文件: RenameSelectionState.java
public void restore(Object newElement) {
	if (fDisplay == null)
		return;
	for (int i = 0; i < fParts.size(); i++) {
		IStructuredSelection currentSelection = (IStructuredSelection) fSelections.get(i);
		boolean changed = false;
		final ISetSelectionTarget target = (ISetSelectionTarget) fParts.get(i);
		final IStructuredSelection[] newSelection = new IStructuredSelection[1];
		newSelection[0] = currentSelection;
		if (currentSelection instanceof TreeSelection) {
			TreeSelection treeSelection = (TreeSelection) currentSelection;
			TreePath[] paths = treeSelection.getPaths();
			for (int p = 0; p < paths.length; p++) {
				TreePath path = paths[p];
				if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) {
					paths[p] = createTreePath(path, newElement);
					changed = true;
				}
			}
			if (changed) {
				newSelection[0] = new TreeSelection(paths, treeSelection.getElementComparer());
			}
		} else {
			Object[] elements = currentSelection.toArray();
			for (int e = 0; e < elements.length; e++) {
				if (elements[e].equals(fElement)) {
					elements[e] = newElement;
					changed = true;
				}
			}
			if (changed) {
				newSelection[0] = new StructuredSelection(elements);
			}
		}
		if (changed) {
			fDisplay.asyncExec(new Runnable() {
				public void run() {
					target.selectReveal(newSelection[0]);
				}
			});
		}
	}
}
 
public void restore(Object newElement) {
	if (fDisplay == null)
		return;
	for (int i= 0; i < fParts.size(); i++) {
		IStructuredSelection currentSelection= fSelections.get(i);
		boolean changed= false;
		final ISetSelectionTarget target= (ISetSelectionTarget)fParts.get(i);
		final IStructuredSelection[] newSelection= new IStructuredSelection[1];
		newSelection[0]= currentSelection;
		if (currentSelection instanceof TreeSelection) {
			TreeSelection treeSelection= (TreeSelection)currentSelection;
			TreePath[] paths= treeSelection.getPaths();
			for (int p= 0; p < paths.length; p++) {
				TreePath path= paths[p];
				if (path.getSegmentCount() > 0 && path.getLastSegment().equals(fElement)) {
					paths[p]= createTreePath(path, newElement);
					changed= true;
				}
			}
			if (changed) {
				newSelection[0]= new TreeSelection(paths, treeSelection.getElementComparer());
			}
		} else {
			Object[] elements= currentSelection.toArray();
			for (int e= 0; e < elements.length; e++) {
				if (elements[e].equals(fElement)) {
					elements[e]= newElement;
					changed= true;
				}
			}
			if (changed) {
				newSelection[0]= new StructuredSelection(elements);
			}
		}
		if (changed) {
			fDisplay.asyncExec(new Runnable() {
				public void run() {
					target.selectReveal(newSelection[0]);
				}
			});
		}
	}
}
 
public AddArchiveToBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public CreateSourceFolderAction2(HintTextGroup provider, IRunnableContext context, ISetSelectionTarget selectionTarget) {
super(context, selectionTarget);

fProvider= provider;
  }
 
public ExcludeFromBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public CreateLinkedSourceFolderAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public CreateSourceFolderAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public BuildpathModifierAction(IWorkbenchSite site, ISetSelectionTarget selectionTarget, int id) {
this(site, selectionTarget, id, IAction.AS_PUSH_BUTTON);
  }
 
public EditFilterAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public AddSelectedLibraryToBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public AddFolderToBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public IncludeToBuildpathAction(IRunnableContext context, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context);
  }
 
public ResetAllOutputFoldersAction(IRunnableContext context, IJavaProject project, ISetSelectionTarget selectionTarget) {
this(null, selectionTarget, context, project);
  }
 
 类所在包
 类方法
 同包方法