### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/editor/LaunchShortcutOverviewPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/LaunchShortcutOverviewPage.java,v retrieving revision 1.2 diff -u -r1.2 LaunchShortcutOverviewPage.java --- src/org/eclipse/pde/internal/ui/editor/LaunchShortcutOverviewPage.java 10 Apr 2007 20:11:01 -0000 1.2 +++ src/org/eclipse/pde/internal/ui/editor/LaunchShortcutOverviewPage.java 15 Aug 2007 15:12:24 -0000 @@ -10,22 +10,11 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.editor; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; - -import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionRegistry; -import org.eclipse.core.runtime.Platform; -import org.eclipse.debug.core.ILaunchManager; -import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWTException; import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.events.IHyperlinkListener; import org.eclipse.ui.forms.widgets.ExpandableComposite; @@ -36,7 +25,7 @@ public abstract class LaunchShortcutOverviewPage extends PDEFormPage implements IHyperlinkListener { - public LaunchShortcutOverviewPage(FormEditor editor, String id, String title) { + public LaunchShortcutOverviewPage(PDELauncherFormEditor editor, String id, String title) { super(editor, id, title); } @@ -68,35 +57,9 @@ */ public void linkActivated(HyperlinkEvent e) { String href = (String) e.getHref(); - if (href.startsWith("launchShortcut.")) { //$NON-NLS-1$ - href = href.substring(15); - int index = href.indexOf('.'); - if (index < 0) - return; // error. Format of href should be launchShortcut.. - String mode = href.substring(0, index); - String id = href.substring(index + 1); - getEditor().doSave(null); - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.debug.ui.launchShortcuts"); //$NON-NLS-1$ - for (int i = 0; i < elements.length; i++) { - if (id.equals(elements[i].getAttribute("id"))) //$NON-NLS-1$ - try { - ILaunchShortcut shortcut = (ILaunchShortcut)elements[i].createExecutableExtension("class"); //$NON-NLS-1$ - preLaunch(); - shortcut.launch(new StructuredSelection(getLaunchObject()), mode); - } catch (CoreException e1) { - } - } - } + getPDELauncherEditor().launch(href, getPDELauncherEditor().getPreLaunchRunnable(), getPDELauncherEditor().getLauncherHelper().getLaunchObject()); } - - // returns the object which will be passed to the launch shortcut in a StructuredSelection - protected abstract Object getLaunchObject(); - // allows subclasses to do setup before launching the shortcut - protected void preLaunch() { - } - // returns the indent for each launcher protected abstract short getIndent(); @@ -123,63 +86,29 @@ } protected final String getLauncherText(boolean osgi, String message) { - IConfigurationElement[] elements = getLaunchers(osgi); + IConfigurationElement[][] elements = getPDELauncherEditor().getLaunchers(osgi); StringBuffer buffer = new StringBuffer(); String indent = Short.toString(getIndent()); for (int i = 0; i < elements.length; i++) { - String mode = elements[i].getAttribute("mode"); //$NON-NLS-1$ - buffer.append("
  • "); //$NON-NLS-1$ - buffer.append(elements[i].getAttribute("label")); //$NON-NLS-1$ - buffer.append("
  • "); //$NON-NLS-1$ + for (int j = 0; j < elements[i].length; j++) { + String mode = elements[i][j].getAttribute("mode"); //$NON-NLS-1$ + buffer.append("
  • "); //$NON-NLS-1$ + buffer.append(elements[i][j].getAttribute("label")); //$NON-NLS-1$ + buffer.append("
  • "); //$NON-NLS-1$ + } } return NLS.bind(message, buffer.toString()); } - private IConfigurationElement[] getLaunchers(boolean osgi) { - IExtensionRegistry registry = Platform.getExtensionRegistry(); - IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.launchShortcuts"); //$NON-NLS-1$ - // validate elements - ArrayList list = new ArrayList(); - for (int i = 0; i < elements.length; i++) { - String mode = elements[i].getAttribute("mode"); //$NON-NLS-1$ - if (mode != null && (mode.equals(ILaunchManager.RUN_MODE) || mode.equals(ILaunchManager.DEBUG_MODE) || mode.equals(ILaunchManager.PROFILE_MODE)) - && elements[i].getAttribute("label") != null && elements[i].getAttribute("id") != null && //$NON-NLS-1$ //$NON-NLS-2$ - osgi == "true".equals(elements[i].getAttribute("osgi"))) //$NON-NLS-1$ //$NON-NLS-2$ - list.add(elements[i]); - } - - // sort elements based on criteria specified in bug 172703 - elements = (IConfigurationElement[])list.toArray(new IConfigurationElement[list.size()]); - Arrays.sort(elements, new Comparator() { - - public int compare(Object arg0, Object arg1) { - int mode1 = getModeValue(((IConfigurationElement)arg0).getAttribute("mode")); //$NON-NLS-1$ - int mode2 = getModeValue(((IConfigurationElement)arg1).getAttribute("mode")); //$NON-NLS-1$ - if (mode1 != mode2) - return mode1 - mode2; - String label1 = ((IConfigurationElement)arg0).getAttribute("label"); //$NON-NLS-1$ - String label2 = ((IConfigurationElement)arg1).getAttribute("label"); //$NON-NLS-1$ - return label1.compareTo(label2); - } - - private int getModeValue(String value) { - if (value.equals(ILaunchManager.RUN_MODE)) - return 0; - else if (value.equals(ILaunchManager.DEBUG_MODE)) - return 1; - return 2; // has to be ILaunchManager.PROFILE_MODE - } - - }); - return elements; + protected PDELauncherFormEditor getPDELauncherEditor() { + return (PDELauncherFormEditor)getPDEEditor(); } - } Index: src/org/eclipse/pde/internal/ui/editor/PDEFormPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/PDEFormPage.java,v retrieving revision 1.42 diff -u -r1.42 PDEFormPage.java --- src/org/eclipse/pde/internal/ui/editor/PDEFormPage.java 13 Aug 2007 13:35:35 -0000 1.42 +++ src/org/eclipse/pde/internal/ui/editor/PDEFormPage.java 15 Aug 2007 15:12:24 -0000 @@ -140,9 +140,13 @@ //createNewStyleHeader(form, colors); toolkit.decorateFormHeading(form.getForm()); } + + IToolBarManager manager = form.getToolBarManager(); + + getPDEEditor().contributeToToolbar(manager); + final String href = getHelpResource(); if (href != null) { - IToolBarManager manager = form.getToolBarManager(); Action helpAction = new Action("help") { //$NON-NLS-1$ public void run() { BusyIndicator.showWhile(form.getDisplay(), new Runnable() { Index: src/org/eclipse/pde/internal/ui/editor/PDEFormEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/PDEFormEditor.java,v retrieving revision 1.60 diff -u -r1.60 PDEFormEditor.java --- src/org/eclipse/pde/internal/ui/editor/PDEFormEditor.java 27 Jul 2007 19:24:29 -0000 1.60 +++ src/org/eclipse/pde/internal/ui/editor/PDEFormEditor.java 15 Aug 2007 15:12:24 -0000 @@ -28,6 +28,7 @@ import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.text.IDocument; @@ -1010,6 +1011,9 @@ */ protected IStatusLineManager getStatusLineManager() { return getEditorSite().getActionBars().getStatusLineManager(); + } + + public void contributeToToolbar(IToolBarManager manager) { } } Index: src/org/eclipse/pde/internal/ui/editor/feature/FeatureEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureEditor.java,v retrieving revision 1.46 diff -u -r1.46 FeatureEditor.java --- src/org/eclipse/pde/internal/ui/editor/feature/FeatureEditor.java 8 Jun 2007 16:47:58 -0000 1.46 +++ src/org/eclipse/pde/internal/ui/editor/feature/FeatureEditor.java 15 Aug 2007 15:12:24 -0000 @@ -16,6 +16,8 @@ import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.core.IIdentifiable; @@ -27,6 +29,7 @@ import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEPluginImages; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage; import org.eclipse.pde.internal.ui.editor.MultiSourceEditor; @@ -57,6 +60,7 @@ public class FeatureEditor extends MultiSourceEditor implements IShowEditorInput { + private Action fExportAction; /* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID() */ @@ -364,4 +368,22 @@ setActivePage(getPageCount() - 3); } } + + protected Action getFeatureExportAction() { + if (fExportAction == null) + fExportAction = new Action() { + public void run() { + doSave(null); + FeatureEditorContributor contributor = (FeatureEditorContributor) getContributor(); + contributor.getBuildAction().run(); + } + }; + return fExportAction; + } + public void contributeToToolbar(IToolBarManager manager) { + Action exportAction = getFeatureExportAction(); + exportAction.setToolTipText(PDEUIMessages.FeatureEditor_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_FEATURE_TOOL); + manager.add(exportAction); + } } Index: src/org/eclipse/pde/internal/ui/editor/feature/FeatureFormPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/feature/FeatureFormPage.java,v retrieving revision 1.17 diff -u -r1.17 FeatureFormPage.java --- src/org/eclipse/pde/internal/ui/editor/feature/FeatureFormPage.java 8 Jun 2007 16:47:58 -0000 1.17 +++ src/org/eclipse/pde/internal/ui/editor/feature/FeatureFormPage.java 15 Aug 2007 15:12:24 -0000 @@ -220,14 +220,7 @@ } }); } else if (href.equals("export")) { //$NON-NLS-1$ - getEditor().doSave(null); - final FeatureEditorContributor contributor = (FeatureEditorContributor) getPDEEditor() - .getContributor(); - BusyIndicator.showWhile(e.display, new Runnable() { - public void run() { - contributor.getBuildAction().run(); - } - }); + ((FeatureEditor)getPDEEditor()).getFeatureExportAction().run(); } else if (href.equals("siteProject")) { //$NON-NLS-1$ getEditor().doSave(null); final FeatureEditorContributor contributor = (FeatureEditorContributor) getPDEEditor() Index: src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java,v retrieving revision 1.49 diff -u -r1.49 OverviewPage.java --- src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java 29 Mar 2007 20:08:22 -0000 1.49 +++ src/org/eclipse/pde/internal/ui/editor/plugin/OverviewPage.java 15 Aug 2007 15:12:24 -0000 @@ -30,8 +30,10 @@ import org.eclipse.pde.internal.ui.PDEPluginImages; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; import org.eclipse.pde.internal.ui.editor.LaunchShortcutOverviewPage; import org.eclipse.pde.internal.ui.editor.PDEFormEditor; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; import org.eclipse.pde.internal.ui.editor.build.BuildInputContext; import org.eclipse.pde.internal.ui.editor.build.BuildPage; import org.eclipse.pde.internal.ui.editor.context.InputContext; @@ -43,7 +45,6 @@ import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.FormText; import org.eclipse.ui.forms.widgets.FormToolkit; @@ -60,8 +61,9 @@ private PluginExportAction fExportAction; private GeneralInfoSection fInfoSection; private boolean fDisposed = false; + private ILauncherFormPageHelper fLauncherHelper; - public OverviewPage(FormEditor editor) { + public OverviewPage(PDELauncherFormEditor editor) { super(editor, PAGE_ID, PDEUIMessages.OverviewPage_tabName); } @@ -171,7 +173,7 @@ String prefixText = (!((ManifestEditor)getEditor()).showExtensionTabs()) ? PDEUIMessages.OverviewPage_OSGiTesting : isFragment() ? PDEUIMessages.OverviewPage_fTesting : PDEUIMessages.OverviewPage_testing; - FormText text = createClient(container, getLauncherText(!((ManifestEditor)getEditor()).showExtensionTabs(), prefixText), toolkit); + FormText text = createClient(container, getLauncherText(getLauncherHelper().isOSGi(), prefixText), toolkit); text.setImage("run", lp.get(PDEPluginImages.DESC_RUN_EXC)); //$NON-NLS-1$ text.setImage("debug", lp.get(PDEPluginImages.DESC_DEBUG_EXC)); //$NON-NLS-1$ text.setImage("profile", lp.get(PDEPluginImages.DESC_PROFILE_EXC)); //$NON-NLS-1$ @@ -254,12 +256,7 @@ organizeAction.run(null); } else super.linkActivated(e); - } - - protected Object getLaunchObject() { - return getPDEEditor().getCommonProject(); - } - + } private PluginExportAction getExportAction() { if (fExportAction == null) fExportAction = new PluginExportAction((PDEFormEditor) getEditor()); @@ -335,4 +332,10 @@ protected short getIndent() { return 5; } + + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new PluginLauncherFormPageHelper(getPDELauncherEditor()); + return fLauncherHelper; + } } Index: src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java,v retrieving revision 1.71 diff -u -r1.71 ManifestEditor.java --- src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java 8 Jun 2007 16:47:58 -0000 1.71 +++ src/org/eclipse/pde/internal/ui/editor/plugin/ManifestEditor.java 15 Aug 2007 15:12:24 -0000 @@ -24,6 +24,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.IEclipsePreferences; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.core.IIdentifiable; @@ -50,11 +52,14 @@ import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage; import org.eclipse.pde.internal.ui.editor.JarEntryEditorInput; import org.eclipse.pde.internal.ui.editor.JarEntryFile; -import org.eclipse.pde.internal.ui.editor.MultiSourceEditor; import org.eclipse.pde.internal.ui.editor.PDEFormEditor; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; import org.eclipse.pde.internal.ui.editor.PDESourcePage; import org.eclipse.pde.internal.ui.editor.SystemFileEditorInput; import org.eclipse.pde.internal.ui.editor.build.BuildInputContext; @@ -73,13 +78,15 @@ import org.eclipse.ui.views.properties.IPropertySheetPage; import org.osgi.service.prefs.BackingStoreException; -public class ManifestEditor extends MultiSourceEditor implements IShowEditorInput { +public class ManifestEditor extends PDELauncherFormEditor implements IShowEditorInput { private static int BUILD_INDEX = 5; private static boolean SHOW_SOURCE; private boolean fEquinox = true; private boolean fShowExtensions = true; private IEclipsePreferences fPrefs; + private PluginExportAction fExportAction; + private ILauncherFormPageHelper fLauncherHelper; /* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.PDEFormEditor#getEditorID() @@ -700,4 +707,22 @@ } fShowExtensions = show; } + public void contributeToToolbar(IToolBarManager manager) { + contributeLaunchersToToolbar(manager); + + Action exportAction = getExportAction(); + exportAction.setToolTipText(PDEUIMessages.PluginEditor_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_PLUGIN_TOOL); + manager.add(exportAction); + } + private PluginExportAction getExportAction() { + if (fExportAction == null) + fExportAction = new PluginExportAction(this); + return fExportAction; + } + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new PluginLauncherFormPageHelper(this); + return fLauncherHelper; + } } Index: src/org/eclipse/pde/internal/ui/editor/product/OverviewPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/OverviewPage.java,v retrieving revision 1.33 diff -u -r1.33 OverviewPage.java --- src/org/eclipse/pde/internal/ui/editor/product/OverviewPage.java 8 Jun 2007 16:48:00 -0000 1.33 +++ src/org/eclipse/pde/internal/ui/editor/product/OverviewPage.java 15 Aug 2007 15:12:24 -0000 @@ -10,14 +10,6 @@ *******************************************************************************/ package org.eclipse.pde.internal.ui.editor.product; -import java.lang.reflect.InvocationTargetException; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.pde.core.IBaseModel; -import org.eclipse.pde.internal.core.iproduct.IProduct; -import org.eclipse.pde.internal.core.iproduct.IProductModel; import org.eclipse.pde.internal.ui.IHelpContextIds; import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.PDELabelProvider; @@ -25,25 +17,25 @@ import org.eclipse.pde.internal.ui.PDEPluginImages; import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; import org.eclipse.pde.internal.ui.editor.LaunchShortcutOverviewPage; -import org.eclipse.pde.internal.ui.wizards.product.SynchronizationOperation; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; -import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.events.HyperlinkEvent; import org.eclipse.ui.forms.widgets.FormText; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.progress.IProgressService; public class OverviewPage extends LaunchShortcutOverviewPage { public static final String PAGE_ID = "overview"; //$NON-NLS-1$ + private ProductLauncherFormPageHelper fLauncherHelper; - public OverviewPage(FormEditor editor) { + public OverviewPage(PDELauncherFormEditor editor) { super(editor, PAGE_ID, PDEUIMessages.OverviewPage_title); } @@ -82,7 +74,7 @@ private void createTestingSection(Composite parent, FormToolkit toolkit) { Section section = createStaticSection(toolkit, parent, PDEUIMessages.Product_OverviewPage_testing); - FormText text = createClient(section, getLauncherText(false, PDEUIMessages.Product_overview_testing), toolkit); + FormText text = createClient(section, getLauncherText(getLauncherHelper().isOSGi(), PDEUIMessages.Product_overview_testing), toolkit); PDELabelProvider lp = PDEPlugin.getDefault().getLabelProvider(); text.setImage("run", lp.get(PDEPluginImages.DESC_RUN_EXC)); //$NON-NLS-1$ text.setImage("debug", lp.get(PDEPluginImages.DESC_DEBUG_EXC)); //$NON-NLS-1$ @@ -98,44 +90,22 @@ public void linkActivated(HyperlinkEvent e) { String href = (String) e.getHref(); if (href.equals("action.synchronize")) { //$NON-NLS-1$ - handleSynchronize(true); + ((ProductLauncherFormPageHelper)getLauncherHelper()).handleSynchronize(true); } else if (href.equals("action.export")) { //$NON-NLS-1$ if (getPDEEditor().isDirty()) getPDEEditor().doSave(null); new ProductExportAction(getPDEEditor()).run(); } else if (href.equals("configuration")) { //$NON-NLS-1$ - String pageId = getProduct().useFeatures() ? ConfigurationPage.FEATURE_ID : ConfigurationPage.PLUGIN_ID; + String pageId = ((ProductLauncherFormPageHelper)getLauncherHelper()).getProduct().useFeatures() ? ConfigurationPage.FEATURE_ID : ConfigurationPage.PLUGIN_ID; getEditor().setActivePage(pageId); } else super.linkActivated(e); } - - protected Object getLaunchObject() { - Object file = getEditorInput().getAdapter(IFile.class); - if (file != null) - return file; - return ((IProductModel)getPDEEditor().getAggregateModel()).getUnderlyingResource(); - } - - protected void preLaunch() { - handleSynchronize(false); - } - - private void handleSynchronize(boolean alert) { - try { - IProgressService service = PlatformUI.getWorkbench().getProgressService(); - IProject project = getPDEEditor().getCommonProject(); - SynchronizationOperation op = new SynchronizationOperation(getProduct(), getSite().getShell(), project); - service.runInUI(service, op, PDEPlugin.getWorkspace().getRoot()); - } catch (InterruptedException e) { - } catch (InvocationTargetException e) { - if (alert) MessageDialog.openError(getSite().getShell(), "Synchronize", e.getTargetException().getMessage()); //$NON-NLS-1$ - } - } - - private IProduct getProduct() { - IBaseModel model = getPDEEditor().getAggregateModel(); - return ((IProductModel)model).getProduct(); + + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new ProductLauncherFormPageHelper(getPDELauncherEditor()); + return fLauncherHelper; } protected short getIndent() { Index: src/org/eclipse/pde/internal/ui/editor/product/ProductEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ProductEditor.java,v retrieving revision 1.24 diff -u -r1.24 ProductEditor.java --- src/org/eclipse/pde/internal/ui/editor/product/ProductEditor.java 8 Jun 2007 16:48:00 -0000 1.24 +++ src/org/eclipse/pde/internal/ui/editor/product/ProductEditor.java 15 Aug 2007 15:12:24 -0000 @@ -13,12 +13,17 @@ import java.io.File; import org.eclipse.core.resources.IFile; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.pde.core.IBaseModel; import org.eclipse.pde.internal.core.iproduct.IProductModel; import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage; -import org.eclipse.pde.internal.ui.editor.PDEFormEditor; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; import org.eclipse.pde.internal.ui.editor.SystemFileEditorInput; import org.eclipse.pde.internal.ui.editor.context.InputContext; import org.eclipse.pde.internal.ui.editor.context.InputContextManager; @@ -28,8 +33,10 @@ import org.eclipse.ui.PartInitException; -public class ProductEditor extends PDEFormEditor { +public class ProductEditor extends PDELauncherFormEditor { + private ProductExportAction fExportAction; + private ILauncherFormPageHelper fLauncherHelper; /** * */ @@ -165,5 +172,22 @@ public boolean monitoredFileRemoved(IFile monitoredFile) { return true; } - + public void contributeToToolbar(IToolBarManager manager) { + contributeLaunchersToToolbar(manager); + + Action exportAction = getExportAction(); + exportAction.setToolTipText(PDEUIMessages.ProductEditor_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_PRODUCT_TOOL); + manager.add(exportAction); + } + private ProductExportAction getExportAction() { + if (fExportAction == null) + fExportAction = new ProductExportAction(this); + return fExportAction; + } + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new ProductLauncherFormPageHelper(this); + return fLauncherHelper; + } } Index: src/org/eclipse/pde/internal/ui/pderesources.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties,v retrieving revision 1.906 diff -u -r1.906 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 14 Aug 2007 22:12:09 -0000 1.906 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 15 Aug 2007 15:12:24 -0000 @@ -216,6 +216,7 @@ FeatureEditor_URLSection_desc = Add URLs of other update sites to visit while looking for new features. FeatureEditor_URLSection_new = Add +FeatureEditor_exportTooltip=Export a deployable feature FeatureEditor_URLSection_newDiscoverySite = New discovery site FeatureEditor_URLSection_newURL = http://newsite FeatureEditor_URLDetailsSection_desc = Specify a meaningful site name and the site URL. @@ -1340,6 +1341,7 @@ PluginGeneralInfoSection_singleton=This plug-in is a singleton PluginWorkingSet_deselectAll_toolTip=Unselect all of these plug-ins for this working set. PluginListPage_initializeFromPlugins=&Initialize from the plug-ins list: +PluginEditor_exportTooltip=Export deployable plug-ins and fragments PluginWorkingSet_noPluginsChecked=At least one plug-in must be checked PluginStatusDialog_pluginValidation=Validation PluginsView_openWith=Open &With @@ -1840,6 +1842,7 @@ ProductExportWizardPage_wrongExtension=A product configuration file name must have a '.product' extension ProductExportWizardPage_fileSelection=File Selection ProductIntroWizardPage_invalidIntroId=Invalid Intro ID. Legal characters are: a-z A-Z 0-9 . +ProductEditor_exportTooltip=Export an Eclipse product ProvisionerListSelectionPage_pageName=Provisioners ProductExportWizardPage_productSelection=Select a product configuration ProvisionerListSelectionPage_description=Select a target provisioner below to add plugins to your target platform Index: src/org/eclipse/pde/internal/ui/PDEUIMessages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java,v retrieving revision 1.311 diff -u -r1.311 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 14 Aug 2007 22:12:10 -0000 1.311 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 15 Aug 2007 15:12:24 -0000 @@ -81,6 +81,8 @@ public static String ExternalizeStringsProcessor_errorMessage; + public static String FeatureEditor_exportTooltip; + public static String JavaArgumentsTab_appendLauncherIni; public static String JavaSearchOperation_createProjectTaskName; @@ -285,6 +287,8 @@ public static String PluginExportJob_name; + public static String PluginEditor_exportTooltip; + public static String PluginListPage_initializeFromLaunch; public static String PluginListPage_initializeFromPlugins; @@ -309,6 +313,8 @@ public static String ProductExportJob_name; + public static String ProductEditor_exportTooltip; + public static String RemoveSplashHandlerBindingAction_msgProgressRemoveProductBindings; public static String RenamePluginAction_label; Index: src/org/eclipse/pde/internal/ui/PDEPluginImages.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEPluginImages.java,v retrieving revision 1.99 diff -u -r1.99 PDEPluginImages.java --- src/org/eclipse/pde/internal/ui/PDEPluginImages.java 31 Jul 2007 18:22:34 -0000 1.99 +++ src/org/eclipse/pde/internal/ui/PDEPluginImages.java 15 Aug 2007 15:12:24 -0000 @@ -185,7 +185,10 @@ public static final ImageDescriptor DESC_NEWEXP_WIZ_TOOL = create(PATH_TOOL, "newexp_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_DEPLOYCS_TOOL = create(PATH_TOOL, "new_cheatsheet_wiz.gif"); //$NON-NLS-1$ public static final ImageDescriptor DESC_VALIDATE_TOOL = create(PATH_TOOL, "validate.gif"); //$NON-NLS-1$ - + public static final ImageDescriptor DESC_EXPORT_PLUGIN_TOOL = create(PATH_TOOL, "exp_deployplug.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXPORT_PRODUCT_TOOL = create(PATH_TOOL, "exp_product.gif"); //$NON-NLS-1$ + public static final ImageDescriptor DESC_EXPORT_FEATURE_TOOL = create(PATH_TOOL, "exp_deployfeat.gif"); //$NON-NLS-1$ + /** * LCL */ Index: src/org/eclipse/pde/internal/ui/editor/build/BuildEditor.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/build/BuildEditor.java,v retrieving revision 1.19 diff -u -r1.19 BuildEditor.java --- src/org/eclipse/pde/internal/ui/editor/build/BuildEditor.java 8 Jun 2007 16:47:59 -0000 1.19 +++ src/org/eclipse/pde/internal/ui/editor/build/BuildEditor.java 15 Aug 2007 15:12:24 -0000 @@ -11,10 +11,14 @@ package org.eclipse.pde.internal.ui.editor.build; import org.eclipse.core.resources.IFile; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; import org.eclipse.pde.core.build.IBuildModel; import org.eclipse.pde.internal.core.build.IBuildObject; import org.eclipse.pde.internal.ui.IPDEUIConstants; import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.PDEUIMessages; import org.eclipse.pde.internal.ui.editor.ISortableContentOutlinePage; import org.eclipse.pde.internal.ui.editor.MultiSourceEditor; import org.eclipse.pde.internal.ui.editor.PDEFormEditor; @@ -23,6 +27,7 @@ import org.eclipse.pde.internal.ui.editor.SystemFileEditorInput; import org.eclipse.pde.internal.ui.editor.context.InputContext; import org.eclipse.pde.internal.ui.editor.context.InputContextManager; +import org.eclipse.pde.internal.ui.editor.plugin.PluginExportAction; import org.eclipse.swt.SWTError; import org.eclipse.swt.dnd.RTFTransfer; import org.eclipse.swt.dnd.TextTransfer; @@ -37,6 +42,7 @@ public class BuildEditor extends MultiSourceEditor { + private PluginExportAction fExportAction; public BuildEditor() { } @@ -174,5 +180,15 @@ } return context; } - + public void contributeToToolbar(IToolBarManager manager) { + Action exportAction = getExportAction(); + exportAction.setToolTipText(PDEUIMessages.PluginEditor_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_PLUGIN_TOOL); + manager.add(exportAction); + } + private PluginExportAction getExportAction() { + if (fExportAction == null) + fExportAction = new PluginExportAction(this); + return fExportAction; + } } Index: src/org/eclipse/pde/internal/ui/editor/PDELauncherFormEditor.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/PDELauncherFormEditor.java diff -N src/org/eclipse/pde/internal/ui/editor/PDELauncherFormEditor.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/PDELauncherFormEditor.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,179 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.editor; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.editor.actions.ActionMenu; + +public abstract class PDELauncherFormEditor extends MultiSourceEditor { + + Action[][] fActions = null; + + protected abstract ILauncherFormPageHelper getLauncherHelper(); + + protected void contributeLaunchersToToolbar(IToolBarManager manager) { + + // this should never be null (no point in using this class if you don't provide an ILauncherFormPageHelper) + // but we'll guard against it anyway + if (getLauncherHelper() != null) { + + Action[][] actions = getActions(); + if (actions[RUN_LAUNCHER_INDEX].length > 0) { + Action runAction = new ActionMenu(actions[RUN_LAUNCHER_INDEX]); + manager.add(runAction); + } + + if (actions[DEBUG_LAUNCHER_INDEX].length > 0) { + Action runAction = new ActionMenu(actions[DEBUG_LAUNCHER_INDEX]); + manager.add(runAction); + } + + if (actions[PROFILE_LAUNCHER_INDEX].length > 0) { + Action runAction = new ActionMenu(actions[PROFILE_LAUNCHER_INDEX]); + manager.add(runAction); + } + } + } + + private Action[][] getActions() { + if (fActions == null) { + fActions = new Action[3][]; + IConfigurationElement[][] elements = getLaunchers(getLauncherHelper().isOSGi()); + fActions[RUN_LAUNCHER_INDEX] = getLauncherActions(elements[RUN_LAUNCHER_INDEX]); + fActions[DEBUG_LAUNCHER_INDEX] = getLauncherActions(elements[DEBUG_LAUNCHER_INDEX]); + fActions[PROFILE_LAUNCHER_INDEX] = getLauncherActions(elements[PROFILE_LAUNCHER_INDEX]); + } + return fActions; + } + + private Action[] getLauncherActions(IConfigurationElement[] elements) { + Action[] result = new Action[elements.length]; + for (int i = 0; i < elements.length; i++) { + String label = elements[i].getAttribute("label"); //$NON-NLS-1$ + final String thisLaunchShortcut = getLaunchString(elements[i]); + Action thisAction = new Action(label) { //$NON-NLS-1$ + public void run() { + doSave(null); + launch(thisLaunchShortcut, getPreLaunchRunnable(), getLauncherHelper().getLaunchObject()); + } + }; + thisAction.setToolTipText(label); + thisAction.setImageDescriptor(getImageDescriptor(elements[i])); + result[i] = thisAction; + } + return result; + } + + protected Runnable getPreLaunchRunnable() { + return new Runnable() { + public void run() { + getLauncherHelper().preLaunch(); + } + }; + } + + public String getLaunchString(IConfigurationElement e) { + StringBuffer sb = new StringBuffer("launchShortcut."); //$NON-NLS-1$ + sb.append(e.getAttribute("mode")); //$NON-NLS-1$ + sb.append("."); //$NON-NLS-1$ + sb.append(e.getAttribute("id")); //$NON-NLS-1$ + return sb.toString(); + } + + private ImageDescriptor getImageDescriptor(IConfigurationElement element) { + String mode = element.getAttribute("mode"); //$NON-NLS-1$ + if (mode == null) + return null; + else if (mode.equals(ILaunchManager.RUN_MODE)) + return PDEPluginImages.DESC_RUN_EXC; + else if (mode.equals(ILaunchManager.DEBUG_MODE)) + return PDEPluginImages.DESC_DEBUG_EXC; + else if (mode.equals(ILaunchManager.PROFILE_MODE)) + return PDEPluginImages.DESC_PROFILE_EXC; + return null; + } + + public void launch(String launchShortcut, Runnable preLaunch, Object launchObject) { + if (launchShortcut.startsWith("launchShortcut.")) { //$NON-NLS-1$ + launchShortcut = launchShortcut.substring(15); + int index = launchShortcut.indexOf('.'); + if (index < 0) + return; // error. Format of launchShortcut should be launchShortcut.. + String mode = launchShortcut.substring(0, index); + String id = launchShortcut.substring(index + 1); + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.debug.ui.launchShortcuts"); //$NON-NLS-1$ + for (int i = 0; i < elements.length; i++) { + if (id.equals(elements[i].getAttribute("id"))) //$NON-NLS-1$ + try { + ILaunchShortcut shortcut = (ILaunchShortcut)elements[i].createExecutableExtension("class"); //$NON-NLS-1$ + preLaunch.run(); + shortcut.launch(new StructuredSelection(launchObject), mode); + } catch (CoreException e1) { + } + } + } + } + + protected static final int RUN_LAUNCHER_INDEX = 0; + protected static final int DEBUG_LAUNCHER_INDEX = 1; + protected static final int PROFILE_LAUNCHER_INDEX = 2; + protected IConfigurationElement[][] getLaunchers(boolean osgi) { + IExtensionRegistry registry = Platform.getExtensionRegistry(); + IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.pde.ui.launchShortcuts"); //$NON-NLS-1$ + // validate elements + ArrayList runList = new ArrayList(); + ArrayList debugList = new ArrayList(); + ArrayList profileList = new ArrayList(); + for (int i = 0; i < elements.length; i++) { + String mode = elements[i].getAttribute("mode"); //$NON-NLS-1$ + if (mode != null && elements[i].getAttribute("label") != null && elements[i].getAttribute("id") != null && //$NON-NLS-1$ //$NON-NLS-2$ + osgi == "true".equals(elements[i].getAttribute("osgi"))) { //$NON-NLS-1$ //$NON-NLS-2$ + if (mode.equals(ILaunchManager.RUN_MODE)) + runList.add(elements[i]); + else if (mode.equals(ILaunchManager.DEBUG_MODE)) + debugList.add(elements[i]); + else if (mode.equals(ILaunchManager.PROFILE_MODE)) + profileList.add(elements[i]); + } + } + + // sort elements based on criteria specified in bug 172703 + IConfigurationElement[] runElements = (IConfigurationElement[])runList.toArray(new IConfigurationElement[runList.size()]); + IConfigurationElement[] debugElements = (IConfigurationElement[])debugList.toArray(new IConfigurationElement[debugList.size()]); + IConfigurationElement[] profileElements = (IConfigurationElement[])profileList.toArray(new IConfigurationElement[profileList.size()]); + Comparator comparator = new Comparator() { + public int compare(Object arg0, Object arg1) { + String label1 = ((IConfigurationElement)arg0).getAttribute("label"); //$NON-NLS-1$ + String label2 = ((IConfigurationElement)arg1).getAttribute("label"); //$NON-NLS-1$ + return label1.compareTo(label2); + } + }; + Arrays.sort(runElements, comparator); + Arrays.sort(debugElements, comparator); + Arrays.sort(profileElements, comparator); + return new IConfigurationElement[][] {runElements,debugElements,profileElements}; + } +} Index: src/org/eclipse/pde/internal/ui/editor/ILauncherFormPageHelper.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/ILauncherFormPageHelper.java diff -N src/org/eclipse/pde/internal/ui/editor/ILauncherFormPageHelper.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/ILauncherFormPageHelper.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,24 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.editor; + + +/** + * This is an interface used only by subclasses of PDELauncherFormPage. + * It's purpose is to allow code reuse between direct subclasses of + * PDELauncherFormPage and subclasses of LaunchShortcutOverviewPage. + */ + +public interface ILauncherFormPageHelper { + public void preLaunch(); + public Object getLaunchObject(); + public boolean isOSGi(); +} Index: src/org/eclipse/pde/internal/ui/editor/actions/ActionMenu.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/actions/ActionMenu.java diff -N src/org/eclipse/pde/internal/ui/editor/actions/ActionMenu.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/actions/ActionMenu.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.editor.actions; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; + +public class ActionMenu extends Action implements IMenuCreator { + + Action[] fActions; + Menu fMenu; + + public ActionMenu(Action[] actions) { + fActions = actions; + if (fActions.length > 0) { + setToolTipText(fActions[0].getToolTipText()); + setImageDescriptor(fActions[0].getImageDescriptor()); + if (fActions.length > 1) + setMenuCreator(this); + } + } + + public void run() { + if (fActions.length > 0) + fActions[0].run(); + } + + public void dispose() { + if (fMenu != null) { + fMenu.dispose(); + fMenu = null; + } + } + + public Menu getMenu(Control parent) { + if (fMenu != null) + fMenu.dispose(); + fMenu = new Menu(parent); + + for (int i = 0; i < fActions.length; i++) { + addActionToMenu(fMenu, fActions[i]); + } + return fMenu; + } + + public Menu getMenu(Menu parent) { + return null; + } + + + protected void addActionToMenu(Menu parent, Action action) { + ActionContributionItem item = new ActionContributionItem(action); + item.fill(parent, -1); + } +} Index: src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPageHelper.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPageHelper.java diff -N src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPageHelper.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPageHelper.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.editor.product; + +import java.lang.reflect.InvocationTargetException; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.pde.core.IBaseModel; +import org.eclipse.pde.internal.core.iproduct.IProduct; +import org.eclipse.pde.internal.core.iproduct.IProductModel; +import org.eclipse.pde.internal.ui.PDEPlugin; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; +import org.eclipse.pde.internal.ui.wizards.product.SynchronizationOperation; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.IProgressService; + +public class ProductLauncherFormPageHelper implements ILauncherFormPageHelper { + PDELauncherFormEditor fEditor; + public ProductLauncherFormPageHelper(PDELauncherFormEditor editor) { + fEditor = editor; + } + public Object getLaunchObject() { + Object file = fEditor.getEditorInput().getAdapter(IFile.class); + if (file != null) + return file; + return ((IProductModel)fEditor.getAggregateModel()).getUnderlyingResource(); + } + public boolean isOSGi() { + return false; + } + public void preLaunch() { + handleSynchronize(false); + } + public void handleSynchronize(boolean alert) { + try { + IProgressService service = PlatformUI.getWorkbench().getProgressService(); + IProject project = fEditor.getCommonProject(); + SynchronizationOperation op = new SynchronizationOperation(getProduct(), fEditor.getSite().getShell(), project); + service.runInUI(service, op, PDEPlugin.getWorkspace().getRoot()); + } catch (InterruptedException e) { + } catch (InvocationTargetException e) { + if (alert) MessageDialog.openError(fEditor.getSite().getShell(), "Synchronize", e.getTargetException().getMessage()); //$NON-NLS-1$ + } + } + public IProduct getProduct() { + IBaseModel model = fEditor.getAggregateModel(); + return ((IProductModel)model).getProduct(); + } +} Index: src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPageHelper.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPageHelper.java diff -N src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPageHelper.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPageHelper.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2007 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.pde.internal.ui.editor.plugin; + +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormEditor; + +public class PluginLauncherFormPageHelper implements ILauncherFormPageHelper { + PDELauncherFormEditor fEditor; + public PluginLauncherFormPageHelper(PDELauncherFormEditor editor) { + fEditor = editor; + } + public Object getLaunchObject() { + return fEditor.getCommonProject(); + } + public boolean isOSGi() { + return !((ManifestEditor)fEditor).showExtensionTabs(); + } + public void preLaunch() { + } +}