Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 219889 Details for
Bug 387251
OpenManifestHandler should open manifest for current editor if the active part
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to OpenManifestHandler
387251.patch (text/plain), 6.35 KB, created by
Brian de Alwis
on 2012-08-14 18:59:29 EDT
(
hide
)
Description:
Patch to OpenManifestHandler
Filename:
MIME Type:
Creator:
Brian de Alwis
Created:
2012-08-14 18:59:29 EDT
Size:
6.35 KB
patch
obsolete
>commit 51626a184f04493c132c53185a339e935ed6d1d0 >Author: Brian de Alwis <bsd@mt.ca> >Date: Tue Aug 14 18:57:28 2012 -0400 > > Bug 387251 OpenManifestHandler should open manifest for current editor if the active part > >diff --git a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/OpenManifestHandler.java b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/OpenManifestHandler.java >index a45391c..088a5a1 100644 >--- a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/OpenManifestHandler.java >+++ b/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/OpenManifestHandler.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2011 IBM Corporation and others. >+ * Copyright (c) 2006, 2011, 2012 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -10,6 +10,7 @@ > * Alex Blewitt (alex_blewitt@yahoo.com) - contributed a patch for: > * o Add an 'Open Manifest' to projects to open the manifest editor > * (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=133692) >+ * Brian de Alwis - open manifest for the currently active editor > *******************************************************************************/ > package org.eclipse.pde.internal.ui.editor; > >@@ -17,7 +18,7 @@ import java.util.HashSet; > import java.util.Iterator; > import org.eclipse.core.commands.*; > import org.eclipse.core.resources.*; >-import org.eclipse.core.runtime.IAdaptable; >+import org.eclipse.core.runtime.*; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -26,7 +27,7 @@ import org.eclipse.pde.internal.core.WorkspaceModelManager; > import org.eclipse.pde.internal.core.project.PDEProject; > import org.eclipse.pde.internal.ui.*; > import org.eclipse.swt.custom.BusyIndicator; >-import org.eclipse.ui.PartInitException; >+import org.eclipse.ui.*; > import org.eclipse.ui.handlers.HandlerUtil; > import org.eclipse.ui.ide.IDE; > import org.eclipse.ui.model.IWorkbenchAdapter; >@@ -41,11 +42,18 @@ public class OpenManifestHandler extends AbstractHandler { > * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) > */ > public Object execute(ExecutionEvent event) throws ExecutionException { >+ final HashSet projects = new HashSet(); >+ if (HandlerUtil.getActivePart(event) instanceof IEditorPart) { >+ IEditorInput input = ((IEditorPart) HandlerUtil.getActivePart(event)).getEditorInput(); >+ IProject proj = getProject(input); >+ if (proj != null && WorkspaceModelManager.isPluginProject(proj)) { >+ projects.add(proj); >+ } >+ } > 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; >@@ -75,30 +83,42 @@ public class OpenManifestHandler extends AbstractHandler { > 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())); >- } >- } >+ } >+ 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); >+ } >+ }); >+ } else >+ MessageDialog.openInformation(PDEPlugin.getActiveWorkbenchShell(), PDEUIMessages.OpenManifestsAction_title, PDEUIMessages.OpenManifestAction_noManifest); >+ return null; >+ } >+ >+ private IProject getProject(IEditorInput input) { >+ IAdapterManager adapterManager = Platform.getAdapterManager(); >+ Object o; >+ if ((o = input.getAdapter(IResource.class)) != null || (o = adapterManager.getAdapter(input, IResource.class)) != null) { >+ return ((IFile) o).getProject(); >+ } >+ if ((o = input.getAdapter(IProject.class)) != null || (o = adapterManager.getAdapter(input, IProject.class)) != null) { >+ return (IProject) o; > } > return null; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
curtis.windatt.public
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 387251
: 219889