private void handleExistingUnshared() { ArrayList<Object> result = new ArrayList<>(); for (int i = 0; i < fModels.length; i++) { String id = fModels[i].getPluginBase().getId(); IProject project = (IProject) PDEPlugin.getWorkspace().getRoot().findMember(id); if (project != null && WorkspaceModelManager.isUnsharedProject(project) && WorkspaceModelManager.isPluginProject(project)) { result.add(fModels[i]); } } handleSetImportSelection(result); }
/* (non-Javadoc) * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; Iterator it = ssel.iterator(); final HashSet projects = new HashSet(); while (it.hasNext()) { Object element = it.next(); IProject proj = null; if (element instanceof IFile) proj = ((IFile) element).getProject(); if ((proj == null) && (element instanceof IProject)) proj = (IProject) element; if ((proj == null) && (element instanceof IAdaptable)) { IResource resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class); if (resource != null) { proj = resource.getProject(); } if (proj == null) { IWorkbenchAdapter workbenchAdapter = (IWorkbenchAdapter) ((IAdaptable) element).getAdapter(IWorkbenchAdapter.class); if (workbenchAdapter != null) { Object o = workbenchAdapter.getParent(element); if (o instanceof IAdaptable) { resource = (IResource) ((IAdaptable) o).getAdapter(IResource.class); if (resource != null) { proj = resource.getProject(); } } } } } if (proj != null && WorkspaceModelManager.isPluginProject(proj)) projects.add(proj); } if (projects.size() > 0) { BusyIndicator.showWhile( PDEPlugin.getActiveWorkbenchShell().getDisplay(), new Runnable() { public void run() { Iterator it = projects.iterator(); while (it.hasNext()) { IProject project = (IProject) it.next(); IFile file = PDEProject.getManifest(project); if (file == null || !file.exists()) file = PDEProject.getPluginXml(project); if (file == null || !file.exists()) file = PDEProject.getFragmentXml(project); if (file == null || !file.exists()) MessageDialog.openError( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, NLS.bind(PDEUIMessages.OpenManifestsAction_cannotFind, project.getName())); else try { IDE.openEditor( PDEPlugin.getActivePage(), file, IPDEUIConstants.MANIFEST_EDITOR_ID); } catch (PartInitException e) { MessageDialog.openError( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, NLS.bind( PDEUIMessages.OpenManifestsAction_cannotOpen, project.getName())); } } } }); } else MessageDialog.openInformation( PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, PDEUIMessages.OpenManifestAction_noManifest); } return null; }