Java 类org.eclipse.ui.navigator.CommonNavigator 实例源码
项目:OpenSPIFe
文件:EditorPartUtils.java
/** 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;
}
项目:idecore
文件:UpgradeNotifier.java
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);
}
}
});
}
项目:n4js
文件:SelectAllProjectExplorerHandler.java
@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;
}
项目:Hydrograph
文件:DeleteHandler.java
@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;
}
项目:Hydrograph
文件:PasteHandler.java
@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;
}
项目:Hydrograph
文件:CopyHandler.java
@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;
}
项目:tlaplus
文件:ToolboxExplorer.java
/**
* 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;
}
项目:tlaplus
文件:ToolboxExplorer.java
/**
* 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;
}
项目:hssd
文件:Helper.java
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;
}
项目:translationstudio8
文件:ApplicationWorkbenchWindowAdvisor.java
/**
* 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 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);
}
}
项目:translationstudio8
文件:TabbedPropertySheetAdapterFactory.java
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof ProjectExplorer) {
if (IPropertySheetPage.class == adapterType)
return new TabbedPropertySheetPage(
new TabbedPropertySheetProjectExplorerContributor(
(CommonNavigator) adaptableObject));
}
return null;
}
项目:idecore
文件:UpgradeNotifier.java
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");
}
}
}
项目:SPLevo
文件:VPExplorerContent.java
/**
* 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;
}
项目:tmxeditor8
文件:ApplicationWorkbenchWindowAdvisor.java
/**
* 当程序第一次运行时(或是重新换了命名空间),设置项目视图的 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);
}
}
项目:tmxeditor8
文件:TabbedPropertySheetAdapterFactory.java
public Object getAdapter(Object adaptableObject, Class adapterType) {
if (adaptableObject instanceof ProjectExplorer) {
if (IPropertySheetPage.class == adapterType)
return new TabbedPropertySheetPage(
new TabbedPropertySheetProjectExplorerContributor(
(CommonNavigator) adaptableObject));
}
return null;
}
项目:Pydev
文件:PyFocusExplorerAction.java
@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;
}
项目:NIEM-Modeling-Tool
文件:NIEMpim2psmTest.java
@Test
public void can_generate_a_psm_from_a_pim() throws CoreException {
final IFile theFile = projectProvider.get().getFile("PetAdoption/PetAdoption.uml");
UIUtils.<CommonNavigator> activate_the_view(IPageLayout.ID_PROJECT_EXPLORER).selectReveal(
new StructuredSelection(theFile));
run_the_command(NIEM_PIM_2_PSM_ID);
final Package thePSM = get_the_root_model(theFile).getNestedPackage("PSM").getNestedPackage("example");
assertThat(thePSM, has_applied_profile(NIEM_Common_Profile));
assertThat(thePSM, has_applied_profile(NIEM_PSM_Profile));
assertThat(thePSM, has_applied_profile(Model_Package_Description_Profile));
}
项目:NIEM-Modeling-Tool
文件:NIEMpsm2xsdTest.java
@Test
public void can_generate_artifacts_from_a_model() throws CoreException {
final IProject theProject = projectProvider.get();
UIUtils.<CommonNavigator> activate_the_view(IPageLayout.ID_PROJECT_EXPLORER).selectReveal(
new StructuredSelection(theProject.getFile("PetAdoption/PetAdoption.uml")));
for (final String transform : transforms()) {
run_the_command(transform);
}
for (final String file : expectedArtifacts()) {
assertThat(theProject.getFile(file), exists());
}
}
项目:eclipse-tapestry5-plugin
文件:Eclipse4Utils.java
/**
* IWorkbenchPart activePart = window.getPartService().getActivePart();
*
* Tree tree = Eclipse4Utils.getTreeFromPart(activePart);
*
* if (tree != null)
* {
* // We're in navigator tree.
* // Try determining selected items from this tree to position editor list right near it.
*
* @param activePart
* @return
*/
public static Tree getTreeFromPart(IWorkbenchPart activePart)
{
Tree tree = null;
if (activePart instanceof CommonNavigator)
{
tree = ((CommonNavigator) activePart).getCommonViewer().getTree();
}
else if (activePart instanceof IPackagesViewPart)
{
TreeViewer treeViewer = ((IPackagesViewPart) activePart).getTreeViewer();
tree = treeViewer.getTree();
}
return tree;
}
项目:OpenSPIFe
文件:EnsembleOpenResourceHandler.java
@Override
@SuppressWarnings("unchecked")
public final Object execute(final ExecutionEvent event)
throws ExecutionException {
final List files = new ArrayList();
if (event.getParameter(PARAM_ID_FILE_PATH) == null) {
// Prompt the user for the resource to open.
Object[] result = queryFileResource();
if (result != null) {
for (int i = 0; i < result.length; i++) {
if (result[i] instanceof IFile) {
files.add(result[i]);
}
}
}
} else {
// Use the given parameter.
final IResource resource = (IResource) event
.getObjectParameterForExecution(PARAM_ID_FILE_PATH);
if (!(resource instanceof IFile)) {
throw new ExecutionException(
"filePath parameter must identify a file"); //$NON-NLS-1$
}
files.add(resource);
}
if (files.size() > 0) {
final IWorkbenchWindow window = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow();
if (window == null) {
throw new ExecutionException("no active workbench window"); //$NON-NLS-1$
}
final IWorkbenchPage page = window.getActivePage();
if (page == null) {
throw new ExecutionException("no active workbench page"); //$NON-NLS-1$
}
try {
for (Iterator it = files.iterator(); it.hasNext();) {
IFile next = (IFile) it.next();
// if the file exits, open it, otherwise check with the resource manager
if(next.exists()) {
IDE.openEditor(page, next, true);
}
else if (artificialResourceManager.canOpen(next)) {
artificialResourceManager.open(next);
TreePath treePath = artificialResourceManager.getTreePath(next);
ISelection selection = new StructuredSelection(treePath);
// select the node in the appropriate navigator
List<EnsembleCommonNavigator> commonNavigators = getEnsembleCommonNavigators();
for (CommonNavigator commonNavigator : commonNavigators) {
commonNavigator.selectReveal(selection);
}
}
}
} catch (final PartInitException e) {
throw new ExecutionException("error opening file in editor", e); //$NON-NLS-1$
}
}
return null;
}
项目:translationstudio8
文件:TabbedPropertySheetProjectExplorerContributor.java
protected TabbedPropertySheetProjectExplorerContributor(CommonNavigator aCommonNavigator) {
contributorId = aCommonNavigator.getViewSite().getId();
}
项目:FindBug-for-Domino-Designer
文件:FilterPatternAction.java
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
if (targetPart instanceof CommonNavigator) {
navigator = (CommonNavigator) targetPart;
useSpecificPattern = action.getId().startsWith("de.tobject.findbugs.filterSpecificPattern");
}
}
项目:FindBug-for-Domino-Designer
文件:OpenGroupDialogAction.java
public void init(IViewPart view) {
if (view instanceof CommonNavigator) {
navigator = (CommonNavigator) view;
}
}
项目:FindBug-for-Domino-Designer
文件:FilterBugsDialogAction.java
public void init(IViewPart view) {
if (view instanceof CommonNavigator) {
navigator = (CommonNavigator) view;
}
}
项目:FindBug-for-Domino-Designer
文件:RefreshAction.java
public void init(IViewPart view) {
if (view instanceof CommonNavigator) {
navigator = (CommonNavigator) view;
}
}
项目:FindBug-for-Domino-Designer
文件:GroupByAction.java
public void init(IViewPart view) {
if (view instanceof CommonNavigator) {
navigator = (CommonNavigator) view;
}
}
项目:FindBug-for-Domino-Designer
文件:ExpandAllAction.java
public void init(IViewPart view) {
if (view instanceof CommonNavigator) {
navigator = (CommonNavigator) view;
}
}
项目:tmxeditor8
文件:TabbedPropertySheetProjectExplorerContributor.java
protected TabbedPropertySheetProjectExplorerContributor(CommonNavigator aCommonNavigator) {
contributorId = aCommonNavigator.getViewSite().getId();
}
项目:maru
文件:ContentProvider.java
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
if (!(part instanceof CommonNavigator)) {
// we are currently only listening to selections
// inside the ScenarioExplorer
return;
}
ITreeSelection treeSelection = (ITreeSelection)selection;
Iterator<?> iterator = treeSelection.iterator();
if (!iterator.hasNext()) {
return;
}
Object object = iterator.next();
if (object instanceof IProject)
{
IProject project = (IProject) object;
CoreModel coreModel = CoreModel.getDefault();
IScenarioProject scenarioProject = coreModel.getScenarioProject(project);
UiModel uiModel = UiModel.getDefault();
UiProject activeUiProject = uiModel.getUiProject(scenarioProject);
if (activeUiProject == currentProject) {
// we reselected the current project - no update needed
return;
}
currentProject = activeUiProject;
notifyProjectSelectionChanged(activeUiProject, activeUiProject);
}
else if (object instanceof UiElement)
{
UiElement element = (UiElement) object;
if (element.getUiProject() == currentProject)
{
// an element in the current project was selected
notifyElementSelectionChanged(element);
}
else
{
// we selected an element in another project
currentProject = element.getUiProject();
notifyProjectSelectionChanged(element.getUiProject(), element);
}
}
}