### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.ui Index: src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionPointsPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionPointsPage.java,v retrieving revision 1.17 diff -u -r1.17 ExtensionPointsPage.java --- src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionPointsPage.java 8 Jun 2007 16:47:58 -0000 1.17 +++ src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionPointsPage.java 10 Aug 2007 15:22:15 -0000 @@ -19,7 +19,6 @@ 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.PDEFormPage; import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; import org.eclipse.pde.internal.ui.editor.PDESection; import org.eclipse.swt.custom.StyledText; @@ -33,7 +32,7 @@ import org.eclipse.ui.forms.editor.IFormPage; import org.eclipse.ui.forms.widgets.ScrolledForm; -public class ExtensionPointsPage extends PDEFormPage { +public class ExtensionPointsPage extends PluginLauncherFormPage { public static final String PAGE_ID = "ex-points"; //$NON-NLS-1$ 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 10 Aug 2007 15:22:15 -0000 @@ -30,6 +30,7 @@ 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.build.BuildInputContext; @@ -60,6 +61,7 @@ private PluginExportAction fExportAction; private GeneralInfoSection fInfoSection; private boolean fDisposed = false; + private ILauncherFormPageHelper fLauncherHelper; public OverviewPage(FormEditor 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(this); + return fLauncherHelper; + } } Index: src/org/eclipse/pde/internal/ui/editor/plugin/DependenciesPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/DependenciesPage.java,v retrieving revision 1.27 diff -u -r1.27 DependenciesPage.java --- src/org/eclipse/pde/internal/ui/editor/plugin/DependenciesPage.java 8 Jun 2007 16:47:58 -0000 1.27 +++ src/org/eclipse/pde/internal/ui/editor/plugin/DependenciesPage.java 10 Aug 2007 15:22:15 -0000 @@ -17,7 +17,6 @@ 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.PDEFormPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -28,7 +27,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; -public class DependenciesPage extends PDEFormPage { +public class DependenciesPage extends PluginLauncherFormPage { public static final String PAGE_ID = "dependencies"; //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsPage.java,v retrieving revision 1.22 diff -u -r1.22 ExtensionsPage.java --- src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsPage.java 8 Jun 2007 16:47:58 -0000 1.22 +++ src/org/eclipse/pde/internal/ui/editor/plugin/ExtensionsPage.java 10 Aug 2007 15:22:15 -0000 @@ -24,7 +24,6 @@ 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.PDEFormPage; import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock; import org.eclipse.pde.internal.ui.editor.PDESection; import org.eclipse.swt.custom.StyledText; @@ -38,7 +37,7 @@ import org.eclipse.ui.forms.editor.IFormPage; import org.eclipse.ui.forms.widgets.ScrolledForm; -public class ExtensionsPage extends PDEFormPage { +public class ExtensionsPage extends PluginLauncherFormPage { public static final String PAGE_ID = "extensions"; //$NON-NLS-1$ private ExtensionsSection fSection; Index: src/org/eclipse/pde/internal/ui/editor/plugin/RuntimePage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/plugin/RuntimePage.java,v retrieving revision 1.24 diff -u -r1.24 RuntimePage.java --- src/org/eclipse/pde/internal/ui/editor/plugin/RuntimePage.java 8 Jun 2007 16:47:58 -0000 1.24 +++ src/org/eclipse/pde/internal/ui/editor/plugin/RuntimePage.java 10 Aug 2007 15:22:15 -0000 @@ -17,13 +17,12 @@ 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.PDEFormPage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.editor.FormEditor; import org.eclipse.ui.forms.widgets.ScrolledForm; -public class RuntimePage extends PDEFormPage { +public class RuntimePage extends PluginLauncherFormPage { public static final String PAGE_ID="runtime"; //$NON-NLS-1$ public RuntimePage(FormEditor editor) { 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 10 Aug 2007 15:22:15 -0000 @@ -10,19 +10,10 @@ *******************************************************************************/ 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.pde.internal.ui.launcher.LauncherUtils; import org.eclipse.swt.SWTException; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.forms.editor.FormEditor; @@ -34,7 +25,7 @@ import org.eclipse.ui.forms.widgets.Section; import org.eclipse.ui.forms.widgets.TableWrapData; -public abstract class LaunchShortcutOverviewPage extends PDEFormPage implements IHyperlinkListener { +public abstract class LaunchShortcutOverviewPage extends PDELauncherFormPage implements IHyperlinkListener { public LaunchShortcutOverviewPage(FormEditor editor, String id, String title) { super(editor, id, title); @@ -68,35 +59,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) { - } - } - } + LauncherUtils.launch(href, getPDEEditor(), getPreLaunchRunnable(), 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 +88,25 @@ } protected final String getLauncherText(boolean osgi, String message) { - IConfigurationElement[] elements = getLaunchers(osgi); + IConfigurationElement[][] elements = LauncherUtils.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; - } - } Index: src/org/eclipse/pde/internal/ui/editor/product/SplashPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/SplashPage.java,v retrieving revision 1.4 diff -u -r1.4 SplashPage.java --- src/org/eclipse/pde/internal/ui/editor/product/SplashPage.java 12 May 2007 06:17:46 -0000 1.4 +++ src/org/eclipse/pde/internal/ui/editor/product/SplashPage.java 10 Aug 2007 15:22:15 -0000 @@ -17,7 +17,6 @@ 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.PDEFormPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; @@ -29,7 +28,7 @@ * SplashPage * */ -public class SplashPage extends PDEFormPage { +public class SplashPage extends ProductLauncherFormPage { public static final String PAGE_ID = "splash"; //$NON-NLS-1$ 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 10 Aug 2007 15:22:15 -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,8 +17,8 @@ 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.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; @@ -36,12 +28,12 @@ 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) { 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(this); + return fLauncherHelper; } protected short getIndent() { Index: src/org/eclipse/pde/internal/ui/editor/product/LaunchingPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/LaunchingPage.java,v retrieving revision 1.7 diff -u -r1.7 LaunchingPage.java --- src/org/eclipse/pde/internal/ui/editor/product/LaunchingPage.java 8 Jun 2007 16:48:00 -0000 1.7 +++ src/org/eclipse/pde/internal/ui/editor/product/LaunchingPage.java 10 Aug 2007 15:22:15 -0000 @@ -16,7 +16,6 @@ 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.PDEFormPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; @@ -25,7 +24,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; -public class LaunchingPage extends PDEFormPage { +public class LaunchingPage extends ProductLauncherFormPage { public static final String PAGE_ID = "launcher"; //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/ui/editor/product/ConfigurationPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/ConfigurationPage.java,v retrieving revision 1.21 diff -u -r1.21 ConfigurationPage.java --- src/org/eclipse/pde/internal/ui/editor/product/ConfigurationPage.java 26 Mar 2007 22:26:14 -0000 1.21 +++ src/org/eclipse/pde/internal/ui/editor/product/ConfigurationPage.java 10 Aug 2007 15:22:15 -0000 @@ -16,7 +16,6 @@ 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.PDEFormPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; @@ -25,7 +24,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; -public class ConfigurationPage extends PDEFormPage { +public class ConfigurationPage extends ProductLauncherFormPage { public static final String PLUGIN_ID = "plugin-configuration"; //$NON-NLS-1$ public static final String FEATURE_ID = "feature-configuration"; //$NON-NLS-1$ Index: src/org/eclipse/pde/internal/ui/editor/product/BrandingPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/product/BrandingPage.java,v retrieving revision 1.23 diff -u -r1.23 BrandingPage.java --- src/org/eclipse/pde/internal/ui/editor/product/BrandingPage.java 8 Jun 2007 16:48:00 -0000 1.23 +++ src/org/eclipse/pde/internal/ui/editor/product/BrandingPage.java 10 Aug 2007 15:22:15 -0000 @@ -16,7 +16,6 @@ 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.PDEFormPage; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.forms.IManagedForm; @@ -25,7 +24,7 @@ import org.eclipse.ui.forms.widgets.ScrolledForm; -public class BrandingPage extends PDEFormPage { +public class BrandingPage extends ProductLauncherFormPage { public static final String PAGE_ID = "branding"; //$NON-NLS-1$ 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.905 diff -u -r1.905 pderesources.properties --- src/org/eclipse/pde/internal/ui/pderesources.properties 8 Aug 2007 23:37:56 -0000 1.905 +++ src/org/eclipse/pde/internal/ui/pderesources.properties 10 Aug 2007 15:22:15 -0000 @@ -1340,6 +1340,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: +PluginLauncherFormPage_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 +1841,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 . +ProductLauncherFormPage_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.310 diff -u -r1.310 PDEUIMessages.java --- src/org/eclipse/pde/internal/ui/PDEUIMessages.java 8 Aug 2007 23:37:56 -0000 1.310 +++ src/org/eclipse/pde/internal/ui/PDEUIMessages.java 10 Aug 2007 15:22:15 -0000 @@ -285,6 +285,8 @@ public static String PluginExportJob_name; + public static String PluginLauncherFormPage_exportTooltip; + public static String PluginListPage_initializeFromLaunch; public static String PluginListPage_initializeFromPlugins; @@ -309,6 +311,8 @@ public static String ProductExportJob_name; + public static String ProductLauncherFormPage_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 10 Aug 2007 15:22:15 -0000 @@ -185,7 +185,9 @@ 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$ + /** * LCL */ Index: src/org/eclipse/pde/internal/ui/editor/build/BuildPage.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/build/BuildPage.java,v retrieving revision 1.24 diff -u -r1.24 BuildPage.java --- src/org/eclipse/pde/internal/ui/editor/build/BuildPage.java 8 Jun 2007 16:47:59 -0000 1.24 +++ src/org/eclipse/pde/internal/ui/editor/build/BuildPage.java 10 Aug 2007 15:22:15 -0000 @@ -21,8 +21,8 @@ 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.PDEFormPage; import org.eclipse.pde.internal.ui.editor.context.InputContext; +import org.eclipse.pde.internal.ui.editor.plugin.PluginLauncherFormPage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -35,7 +35,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.ScrolledForm; -public class BuildPage extends PDEFormPage { +public class BuildPage extends PluginLauncherFormPage { public static final String PAGE_ID = "build"; //$NON-NLS-1$ private BuildClasspathSection fClasspathSection; private BuildContentsSection fSrcSection; Index: src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java,v retrieving revision 1.104 diff -u -r1.104 LauncherUtils.java --- src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java 27 Jul 2007 19:24:29 -0000 1.104 +++ src/org/eclipse/pde/internal/ui/launcher/LauncherUtils.java 10 Aug 2007 15:22:15 -0000 @@ -15,6 +15,8 @@ import java.io.FileOutputStream; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; import java.util.HashSet; import java.util.Iterator; import java.util.Properties; @@ -26,14 +28,19 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.ILaunchShortcut; import org.eclipse.jdt.core.IClasspathEntry; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.JavaCore; @@ -42,6 +49,7 @@ import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.osgi.util.NLS; import org.eclipse.pde.core.plugin.IPluginModelBase; @@ -54,6 +62,7 @@ import org.eclipse.pde.internal.ui.IPreferenceConstants; import org.eclipse.pde.internal.ui.PDEPlugin; import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.editor.PDEFormEditor; import org.eclipse.pde.internal.ui.wizards.tools.OrganizeManifestsProcessor; import org.eclipse.pde.ui.launcher.IPDELauncherConstants; import org.eclipse.swt.widgets.Display; @@ -407,5 +416,75 @@ message, null); } + + public static final int RUN_LAUNCHER_INDEX = 0; + public static final int DEBUG_LAUNCHER_INDEX = 1; + public static final int PROFILE_LAUNCHER_INDEX = 2; + public static 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}; + } + + public static void launch(String launchShortcut, PDEFormEditor editor, 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); + editor.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.run(); + shortcut.launch(new StructuredSelection(launchObject), mode); + } catch (CoreException e1) { + } + } + } + } + public static 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(); + } } Index: src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPage.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPage.java diff -N src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/product/ProductLauncherFormPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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 org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormPage; +import org.eclipse.ui.forms.editor.FormEditor; + +public class ProductLauncherFormPage extends PDELauncherFormPage { + private ILauncherFormPageHelper fLauncherHelper; + public ProductLauncherFormPage(FormEditor editor, String id, String title) { + super(editor, id, title); + } + public ProductLauncherFormPage(FormEditor editor, String id, String title, boolean newStyleHeader) { + super(editor, id, title, newStyleHeader); + } + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new ProductLauncherFormPageHelper(this); + return fLauncherHelper; + } +} Index: src/org/eclipse/pde/internal/ui/editor/PDELauncherFormPage.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/PDELauncherFormPage.java diff -N src/org/eclipse/pde/internal/ui/editor/PDELauncherFormPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/PDELauncherFormPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,68 @@ +/******************************************************************************* + * 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 org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.pde.internal.ui.launcher.LauncherAction; +import org.eclipse.pde.internal.ui.launcher.LauncherUtils; +import org.eclipse.ui.forms.IManagedForm; +import org.eclipse.ui.forms.editor.FormEditor; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +public abstract class PDELauncherFormPage extends PDEFormPage { + public PDELauncherFormPage(FormEditor editor, String id, String title) { + super(editor, id, title); + } + public PDELauncherFormPage(FormEditor editor, String id, String title, boolean newStyleHeader) { + super(editor, id, title, newStyleHeader); + } + + protected abstract ILauncherFormPageHelper getLauncherHelper(); + + protected void createFormContent(IManagedForm managedForm) { + final ScrolledForm form = managedForm.getForm(); + IConfigurationElement[][] elements = LauncherUtils.getLaunchers(getLauncherHelper().isOSGi()); + + IToolBarManager manager = form.getToolBarManager(); + + if (elements[LauncherUtils.RUN_LAUNCHER_INDEX].length > 0) { + Action runAction = new LauncherAction(elements[LauncherUtils.RUN_LAUNCHER_INDEX], form, + getPDEEditor(), getPreLaunchRunnable(), getLauncherHelper().getLaunchObject()); + manager.add(runAction); + } + + if (elements[LauncherUtils.DEBUG_LAUNCHER_INDEX].length > 0) { + Action debugAction = new LauncherAction(elements[LauncherUtils.DEBUG_LAUNCHER_INDEX], form, + getPDEEditor(), getPreLaunchRunnable(), getLauncherHelper().getLaunchObject()); + manager.add(debugAction); + } + + if (elements[LauncherUtils.PROFILE_LAUNCHER_INDEX].length > 0) { + Action profileAction = new LauncherAction(elements[LauncherUtils.PROFILE_LAUNCHER_INDEX], form, + getPDEEditor(), getPreLaunchRunnable(), getLauncherHelper().getLaunchObject()); + manager.add(profileAction); + } + + getLauncherHelper().createAdditionalButtons(manager); + + super.createFormContent(managedForm); + } + + protected Runnable getPreLaunchRunnable() { + return new Runnable() { + public void run() { + getLauncherHelper().preLaunch(); + } + }; + } +} 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,26 @@ +/******************************************************************************* + * 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 org.eclipse.jface.action.IToolBarManager; + +/** + * 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(); + public void createAdditionalButtons(IToolBarManager manager); +} Index: src/org/eclipse/pde/internal/ui/launcher/LauncherAction.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/launcher/LauncherAction.java diff -N src/org/eclipse/pde/internal/ui/launcher/LauncherAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/launcher/LauncherAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,108 @@ +/******************************************************************************* + * 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.launcher; + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IMenuCreator; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.editor.PDEFormEditor; +import org.eclipse.swt.custom.BusyIndicator; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.ui.forms.widgets.ScrolledForm; + +public class LauncherAction extends Action implements IMenuCreator { + + Action[] fActions; + Menu fMenu; + + public LauncherAction(IConfigurationElement[] elements, ScrolledForm form, + PDEFormEditor editor, Runnable preLaunch, Object launchObject) { + createActions(elements, form, editor, preLaunch, launchObject); + if (fActions.length > 0) { + setToolTipText(fActions[0].getToolTipText()); + setImageDescriptor(fActions[0].getImageDescriptor()); + if (fActions.length > 1) + setMenuCreator(this); + } + } + + private void createActions(IConfigurationElement[] elements, final ScrolledForm form, + final PDEFormEditor editor, final Runnable preLaunch, final Object launchObject) { + fActions = new Action[elements.length]; + for (int i = 0; i < elements.length; i++) { + final IConfigurationElement thisElement = elements[i]; + String label = thisElement.getAttribute("label"); //$NON-NLS-1$ + Action thisAction = new Action(label) { //$NON-NLS-1$ + public void run() { + BusyIndicator.showWhile(form.getDisplay(), new Runnable() { + public void run() { + LauncherUtils.launch(LauncherUtils.getLaunchString(thisElement), editor, preLaunch, launchObject); + } + }); + } + }; + thisAction.setToolTipText(label); + thisAction.setImageDescriptor(getImageDescriptor(thisElement)); + fActions[i] = thisAction; + } + } + + 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); + } + + private ImageDescriptor getImageDescriptor(IConfigurationElement e) { + String mode = e.getAttribute("mode"); //$NON-NLS-1$ + if (mode == null) + return null; + if (mode.equals(ILaunchManager.RUN_MODE)) + return PDEPluginImages.DESC_RUN_EXC; + if (mode.equals(ILaunchManager.DEBUG_MODE)) + return PDEPluginImages.DESC_DEBUG_EXC; + if (mode.equals(ILaunchManager.PROFILE_MODE)) + return PDEPluginImages.DESC_PROFILE_EXC; + return null; + } +} Index: src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPage.java =================================================================== RCS file: src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPage.java diff -N src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/pde/internal/ui/editor/plugin/PluginLauncherFormPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,30 @@ +/******************************************************************************* + * 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.PDELauncherFormPage; +import org.eclipse.ui.forms.editor.FormEditor; + +public class PluginLauncherFormPage extends PDELauncherFormPage { + private ILauncherFormPageHelper fLauncherHelper; + public PluginLauncherFormPage(FormEditor editor, String id, String title) { + super(editor, id, title); + } + public PluginLauncherFormPage(FormEditor editor, String id, String title, boolean newStyleHeader) { + super(editor, id, title, newStyleHeader); + } + protected ILauncherFormPageHelper getLauncherHelper() { + if (fLauncherHelper == null) + fLauncherHelper = new PluginLauncherFormPageHelper(this); + return fLauncherHelper; + } +} 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,70 @@ +/******************************************************************************* + * 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.action.Action; +import org.eclipse.jface.action.IToolBarManager; +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.PDEPluginImages; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.editor.ILauncherFormPageHelper; +import org.eclipse.pde.internal.ui.editor.PDELauncherFormPage; +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 { + PDELauncherFormPage fFormPage; + public ProductLauncherFormPageHelper(PDELauncherFormPage formPage) { + fFormPage = formPage; + } + public Object getLaunchObject() { + Object file = fFormPage.getEditorInput().getAdapter(IFile.class); + if (file != null) + return file; + return ((IProductModel)fFormPage.getPDEEditor().getAggregateModel()).getUnderlyingResource(); + } + public boolean isOSGi() { + return false; + } + public void createAdditionalButtons(IToolBarManager manager) { + Action exportAction = new ProductExportAction(fFormPage.getPDEEditor()); + exportAction.setToolTipText(PDEUIMessages.ProductLauncherFormPage_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_PLUGIN_TOOL); + manager.add(exportAction); + } + public void preLaunch() { + handleSynchronize(false); + } + public void handleSynchronize(boolean alert) { + try { + IProgressService service = PlatformUI.getWorkbench().getProgressService(); + IProject project = fFormPage.getPDEEditor().getCommonProject(); + SynchronizationOperation op = new SynchronizationOperation(getProduct(), fFormPage.getSite().getShell(), project); + service.runInUI(service, op, PDEPlugin.getWorkspace().getRoot()); + } catch (InterruptedException e) { + } catch (InvocationTargetException e) { + if (alert) MessageDialog.openError(fFormPage.getSite().getShell(), "Synchronize", e.getTargetException().getMessage()); //$NON-NLS-1$ + } + } + public IProduct getProduct() { + IBaseModel model = fFormPage.getPDEEditor().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,39 @@ +/******************************************************************************* + * 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.jface.action.Action; +import org.eclipse.jface.action.IToolBarManager; +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.PDELauncherFormPage; + +public class PluginLauncherFormPageHelper implements ILauncherFormPageHelper { + PDELauncherFormPage fFormPage; + public PluginLauncherFormPageHelper(PDELauncherFormPage formPage) { + fFormPage = formPage; + } + public Object getLaunchObject() { + return fFormPage.getPDEEditor().getCommonProject(); + } + public boolean isOSGi() { + return !((ManifestEditor)fFormPage.getEditor()).showExtensionTabs(); + } + public void createAdditionalButtons(IToolBarManager manager) { + Action exportAction = new PluginExportAction(fFormPage.getPDEEditor()); + exportAction.setToolTipText(PDEUIMessages.PluginLauncherFormPage_exportTooltip); + exportAction.setImageDescriptor(PDEPluginImages.DESC_EXPORT_PLUGIN_TOOL); + manager.add(exportAction); + } + public void preLaunch() { + } +}