diff --git a/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF index a872488..e1206d4 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui.controls/META-INF/MANIFEST.MF @@ -8,15 +8,17 @@ Bundle-Vendor: Eclipse CDT Require-Bundle: org.eclipse.osgi.services;bundle-version="3.5.0", org.eclipse.core.runtime, org.eclipse.ui, - org.eclipse.e4.core.di.annotations;bundle-version="1.5.0", - org.eclipse.e4.core.contexts;bundle-version="1.5.0", + org.eclipse.e4.core.di.annotations;bundle-version="1.4.0", + org.eclipse.e4.core.contexts;bundle-version="1.4.0", org.eclipse.e4.core.services;bundle-version="2.0.0", - org.eclipse.e4.ui.model.workbench;bundle-version="1.2.0", - org.eclipse.e4.ui.workbench;bundle-version="1.4.0", - org.eclipse.debug.ui;bundle-version="3.11.200", - org.eclipse.launchbar.core;bundle-version="2.0.0", - org.eclipse.launchbar.ui;bundle-version="2.0.0" + org.eclipse.e4.ui.model.workbench;bundle-version="1.1.0", + org.eclipse.e4.ui.workbench;bundle-version="1.3.0", + org.eclipse.debug.ui;bundle-version="3.11.101", + org.eclipse.jface, + org.eclipse.debug.core, + org.eclipse.launchbar.core;bundle-version="2.0.1", + org.eclipse.launchbar.ui;bundle-version="2.0.1" Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin -Export-Package: org.eclipse.launchbar.ui.controls.internal;x-internal:=true +Export-Package: org.eclipse.launchbar.ui.controls.internal diff --git a/bundles/org.eclipse.launchbar.ui.controls/icons/build.png b/bundles/org.eclipse.launchbar.ui.controls/icons/build.png old mode 100755 new mode 100644 index 110cb3a..db977ea Binary files a/bundles/org.eclipse.launchbar.ui.controls/icons/build.png and b/bundles/org.eclipse.launchbar.ui.controls/icons/build.png differ diff --git a/bundles/org.eclipse.launchbar.ui.controls/icons/deploy.png b/bundles/org.eclipse.launchbar.ui.controls/icons/deploy.png new file mode 100644 index 0000000..65c5aff Binary files /dev/null and b/bundles/org.eclipse.launchbar.ui.controls/icons/deploy.png differ diff --git a/bundles/org.eclipse.launchbar.ui.controls/icons/icons.idraw b/bundles/org.eclipse.launchbar.ui.controls/icons/icons.idraw new file mode 100644 index 0000000..4d8fddd Binary files /dev/null and b/bundles/org.eclipse.launchbar.ui.controls/icons/icons.idraw differ diff --git a/bundles/org.eclipse.launchbar.ui.controls/icons/launch.png b/bundles/org.eclipse.launchbar.ui.controls/icons/launch.png index d704b70..aaea70a 100644 Binary files a/bundles/org.eclipse.launchbar.ui.controls/icons/launch.png and b/bundles/org.eclipse.launchbar.ui.controls/icons/launch.png differ diff --git a/bundles/org.eclipse.launchbar.ui.controls/icons/stop.png b/bundles/org.eclipse.launchbar.ui.controls/icons/stop.png old mode 100755 new mode 100644 index b55b7c4..8d8fde4 Binary files a/bundles/org.eclipse.launchbar.ui.controls/icons/stop.png and b/bundles/org.eclipse.launchbar.ui.controls/icons/stop.png differ diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java index 363516a..c02c3c2 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Activator.java @@ -28,6 +28,7 @@ public class Activator extends AbstractUIPlugin { public static final String IMG_BUTTON_BUILD = "build"; //$NON-NLS-1$ public static final String IMG_BUTTON_LAUNCH = "launch"; //$NON-NLS-1$ public static final String IMG_BUTTON_STOP = "stop"; //$NON-NLS-1$ + public static final String IMG_BUTTON_DEPLOY = "deploy"; //$NON-NLS-1$ public static final String IMG_CONFIG_CONFIG = "config_config"; //$NON-NLS-1$ public static final String IMG_EDIT_COLD = "edit_cold"; //$NON-NLS-1$ @@ -50,6 +51,7 @@ public void start(BundleContext context) throws Exception { imageRegistry.put(IMG_BUTTON_BUILD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/build_16.png")); //$NON-NLS-1$ imageRegistry.put(IMG_BUTTON_LAUNCH, imageDescriptorFromPlugin(PLUGIN_ID, "icons/launch_16.png")); //$NON-NLS-1$ imageRegistry.put(IMG_BUTTON_STOP, imageDescriptorFromPlugin(PLUGIN_ID, "icons/stop_16.png")); //$NON-NLS-1$ + imageRegistry.put(IMG_BUTTON_DEPLOY, imageDescriptorFromPlugin(PLUGIN_ID, "icons/deploy.png")); //$NON-NLS-1$ imageRegistry.put(IMG_CONFIG_CONFIG, imageDescriptorFromPlugin(PLUGIN_ID, "icons/config_config.png")); //$NON-NLS-1$ imageRegistry.put(IMG_EDIT_COLD, imageDescriptorFromPlugin(PLUGIN_ID, "icons/edit_cold.png")); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java index d4ace4c..272e66c 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/LaunchBarControl.java @@ -7,7 +7,7 @@ * * Contributors: * Doug Schaefer - * Torkild U. Resheim - add preference to control target selector + * Torkild U. Resheim * Vincent Guignot - Ingenico - add preference to control Build button *******************************************************************************/ package org.eclipse.launchbar.ui.controls.internal; @@ -85,6 +85,8 @@ public void widgetDisposed(DisposeEvent e) { createButton(toolBar, Activator.IMG_BUTTON_LAUNCH, Messages.LaunchBarControl_Launch, ILaunchBarUIConstants.CMD_LAUNCH); + createButton(toolBar, Activator.IMG_BUTTON_DEPLOY, Messages.LaunchBarControl_Deploy, + ILaunchBarUIConstants.CMD_DEPLOY); createButton(toolBar, Activator.IMG_BUTTON_STOP, Messages.LaunchBarControl_Stop, ILaunchBarUIConstants.CMD_STOP); diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java index 9eac590..a1ebda8 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/Messages.java @@ -7,7 +7,7 @@ * * Contributors: * Doug Schaefer - * Torkild U. Resheim - add preference to control target selector + * Torkild U. Resheim * Vincent Guignot - Ingenico - add preference to control Build button *******************************************************************************/ package org.eclipse.launchbar.ui.controls.internal; @@ -29,6 +29,7 @@ public class Messages extends NLS { public static String LaunchBarControl_Build; public static String LaunchBarControl_Launch; public static String LaunchBarControl_Stop; + public static String LaunchBarControl_Deploy; public static String LaunchBarListViewer_0; public static String LaunchBarPreferencePage_0; public static String LaunchBarPreferencePage_1; diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties index 30e6ed1..5b27247 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/messages.properties @@ -18,6 +18,7 @@ LaunchBarControl_0=on LaunchBarControl_Build=Build LaunchBarControl_Launch=Launch LaunchBarControl_Stop=Stop +LaunchBarControl_Deploy=Deploy into running instance LaunchBarListViewer_0=Increase/Decrease size of recently used elements pane LaunchBarPreferencePage_0=Preferences for the Launch Bar LaunchBarPreferencePage_1=Enable the Launch Bar diff --git a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF index 3ad1121..6f4022e 100644 --- a/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF +++ b/bundles/org.eclipse.launchbar.ui/META-INF/MANIFEST.MF @@ -8,6 +8,19 @@ Bundle-Vendor: Eclipse CDT Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui, org.eclipse.ui.ide, + org.eclipse.swt, + org.eclipse.ui.navigator, + org.eclipse.remote.core;bundle-version="2.0.0", + org.eclipse.remote.ui;bundle-version="1.1.0", + org.eclipse.e4.core.contexts, + org.eclipse.pde.core, + org.eclipse.core.resources, + org.eclipse.pde.ui, + org.eclipse.core.jobs, + org.eclipse.pde.build, + org.eclipse.jface, + org.eclipse.pde.api.tools, + org.eclipse.debug.core, org.eclipse.debug.ui, org.eclipse.launchbar.core Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.eclipse.launchbar.ui/icons/publish.png b/bundles/org.eclipse.launchbar.ui/icons/publish.png new file mode 100644 index 0000000..8e8a6ad Binary files /dev/null and b/bundles/org.eclipse.launchbar.ui/icons/publish.png differ diff --git a/bundles/org.eclipse.launchbar.ui/plugin.xml b/bundles/org.eclipse.launchbar.ui/plugin.xml index da51d5e..750b1bd 100644 --- a/bundles/org.eclipse.launchbar.ui/plugin.xml +++ b/bundles/org.eclipse.launchbar.ui/plugin.xml @@ -15,6 +15,12 @@ id="org.eclipse.launchbar.ui.command.buildActive" name="Build Active Launch Configuration"> + + - @@ -57,7 +62,16 @@ name="Launch Target" project="false"> + + + + diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java index 8a204e1..2b0fe21 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/ILaunchBarUIConstants.java @@ -23,6 +23,7 @@ public interface ILaunchBarUIConstants { public static final String CMD_BUILD = Activator.PLUGIN_ID + ".command.buildActive"; //$NON-NLS-1$ public static final String CMD_LAUNCH = Activator.PLUGIN_ID + ".command.launchActive"; //$NON-NLS-1$ public static final String CMD_STOP = Activator.PLUGIN_ID + ".command.stop"; //$NON-NLS-1$ + public static final String CMD_DEPLOY = Activator.PLUGIN_ID + ".command.deploy"; //$NON-NLS-1$ public static final String CMD_CONFIG = Activator.PLUGIN_ID + ".command.configureActiveLaunch"; //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java index 85b8303..b8f9a9f 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/Activator.java @@ -7,8 +7,12 @@ * * Contributors: * Doug Schaefer +<<<<<<< HEAD * Torkild U. Resheim - add preference to control target selector * Vincent Guignot - Ingenico - add preference to control Build button +======= + * Torkild U. Resheim +>>>>>>> 7acff04... Add button to deploy all plug-in projects. Use styleguide palette. *******************************************************************************/ package org.eclipse.launchbar.ui.internal; diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/DeployCommandHandler.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/DeployCommandHandler.java new file mode 100644 index 0000000..97d8b2c --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/internal/commands/DeployCommandHandler.java @@ -0,0 +1,190 @@ +/******************************************************************************* + * Copyright (c) 2016 Diamond Light Source Ltd. + * 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: + * Torkild U. Resheim - initial API and implementation + *******************************************************************************/ +package org.eclipse.launchbar.ui.internal.commands; + +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.FileAttribute; +import java.util.ArrayList; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.jobs.IJobChangeEvent; +import org.eclipse.core.runtime.jobs.JobChangeAdapter; +import org.eclipse.debug.core.ILaunchMode; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.osgi.util.NLS; +import org.eclipse.pde.core.IModel; +import org.eclipse.pde.core.plugin.IPluginModelBase; +import org.eclipse.pde.core.plugin.PluginRegistry; +import org.eclipse.pde.internal.build.site.QualifierReplacer; +import org.eclipse.pde.internal.core.ICoreConstants; +import org.eclipse.pde.internal.core.PDECoreMessages; +import org.eclipse.pde.internal.core.WorkspaceModelManager; +import org.eclipse.pde.internal.core.exports.FeatureExportInfo; +import org.eclipse.pde.internal.core.exports.PluginExportOperation; +import org.eclipse.pde.internal.ui.PDEPluginImages; +import org.eclipse.pde.internal.ui.PDEUIMessages; +import org.eclipse.pde.internal.ui.build.RuntimeInstallJob; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.program.Program; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Link; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.progress.IProgressConstants; +import org.eclipse.ui.progress.UIJob; +import org.eclipse.launchbar.ui.internal.Activator; + +/** + * Command to build and install all open Eclipse plug-in projects into + * the running Eclipse instance. PDE build will be used for the operation. + * + * @author Torkild U. Resheim + */ +@SuppressWarnings("restriction") +public class DeployCommandHandler extends AbstractHandler { + + protected class AntErrorDialog extends MessageDialog { + private File fLogLocation; + + public AntErrorDialog(File logLocation) { + super(PlatformUI.getWorkbench().getDisplay().getActiveShell(), PDECoreMessages.FeatureBasedExportOperation_ProblemDuringExport, null, null, MessageDialog.ERROR, new String[] {IDialogConstants.OK_LABEL}, 0); + fLogLocation = logLocation; + } + + protected Control createMessageArea(Composite composite) { + Link link = new Link(composite, SWT.WRAP); + try { + link.setText(NLS.bind(PDEUIMessages.PluginExportWizard_Ant_errors_during_export_logs_generated, "" + fLogLocation.getCanonicalPath() + "")); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (IOException e) { + Activator.log(e); + } + GridData data = new GridData(); + data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); + link.setLayoutData(data); + link.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + try { + Program.launch(fLogLocation.getCanonicalPath()); + } catch (IOException ex) { + Activator.log(ex); + } + } + }); + return link; + } + } + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + new UIJob(Display.getDefault(), "Installing plug-ins into running Eclipse instance") { + public IStatus runInUIThread(IProgressMonitor monitor) { + try { + scheduleExportJob(); + } catch (IOException e) { + return new Status(IStatus.ERROR, "", "Could not install plug-in",e); + } + return Status.OK_STATUS; + }; + }.schedule(); + + return Status.OK_STATUS; + } + + protected String getMode(ILaunchMode launchMode) { + return launchMode.getIdentifier(); //$NON-NLS-1$ + } + + protected boolean isValidModel(IModel model) { + return model != null && model instanceof IPluginModelBase; + } + private boolean hasBuildProperties(IPluginModelBase model) { + File file = new File(model.getInstallLocation(), ICoreConstants.BUILD_FILENAME_DESCRIPTOR); + return file.exists(); + } + public Object[] getListElements() { + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + ArrayList result = new ArrayList(); + for (int i = 0; i < projects.length; i++) { + if (!WorkspaceModelManager.isBinaryProject(projects[i]) && WorkspaceModelManager.isPluginProject(projects[i])) { + IModel model = PluginRegistry.findModel(projects[i]); + if (model != null && isValidModel(model) && hasBuildProperties((IPluginModelBase) model)) { + result.add(model); + } + } + } + return result.toArray(); + } + + protected void scheduleExportJob() throws IOException { + + Path folder = Files.createTempDirectory("eclipse-export", new FileAttribute[0]); + final FeatureExportInfo info = new FeatureExportInfo(); + info.toDirectory = true; // in order to install from the repository + info.useJarFormat = true; + info.exportSource = false; + info.exportSourceBundle = false; + info.allowBinaryCycles = true; + info.useWorkspaceCompiledClasses = false; + info.destinationDirectory = folder.toString(); + info.zipFileName = "dawn-plugin-deployment.zip"; + info.items = getListElements(); // all open plug-in projects + info.signingInfo = null; // + info.qualifier = QualifierReplacer.getDateQualifier(); + + final boolean installAfterExport = true; + if (installAfterExport) { + RuntimeInstallJob.modifyInfoForInstall(info); + } + + final PluginExportOperation job = new PluginExportOperation(info, PDEUIMessages.PluginExportJob_name); + job.setUser(true); + job.setRule(ResourcesPlugin.getWorkspace().getRoot()); + job.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_PLUGIN_OBJ); + job.addJobChangeListener(new JobChangeAdapter() { + public void done(IJobChangeEvent event) { + if (job.hasAntErrors()) { + // If there were errors when running the ant scripts, inform the user where the logs can be found. + final File logLocation = new File(info.destinationDirectory, "logs.zip"); //$NON-NLS-1$ + if (logLocation.exists()) { + PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + public void run() { + AntErrorDialog dialog = new AntErrorDialog(logLocation); + dialog.open(); + } + }); + } + } else if (event.getResult().isOK() && installAfterExport) { + // install the export into the current running platform + RuntimeInstallJob installJob = new RuntimeInstallJob(PDEUIMessages.PluginExportWizard_InstallJobName, info); + installJob.setUser(true); + installJob.setProperty(IProgressConstants.ICON_PROPERTY, PDEPluginImages.DESC_FEATURE_OBJ); + installJob.schedule(); + } + } + }); + job.schedule(); + } +}