Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Merks2015-06-09 05:04:05 +0000
committerEd Merks2015-06-09 05:04:05 +0000
commit415dd83aec8400aa72300f7e9caefe8db4576dfb (patch)
treeaa77ae8439df42a121fc2de72cc4d7edaf7baffc
parent97bd8cf11d4e76d956380b8da2726b5100afeb39 (diff)
downloadorg.eclipse.oomph-415dd83aec8400aa72300f7e9caefe8db4576dfb.tar.gz
org.eclipse.oomph-415dd83aec8400aa72300f7e9caefe8db4576dfb.tar.xz
org.eclipse.oomph-415dd83aec8400aa72300f7e9caefe8db4576dfb.zip
[459589] Windows: Add shortcuts for installed product to the menu and
desktop https://bugs.eclipse.org/bugs/show_bug.cgi?id=459589
-rw-r--r--plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/KeepInstallerUtil.java19
-rw-r--r--plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java89
-rw-r--r--plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProgressPage.java22
3 files changed, 116 insertions, 14 deletions
diff --git a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/KeepInstallerUtil.java b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/KeepInstallerUtil.java
index 359252bd8..10dd05038 100644
--- a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/KeepInstallerUtil.java
+++ b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/KeepInstallerUtil.java
@@ -36,14 +36,22 @@ public final class KeepInstallerUtil
public static void createShortCut(String specialFolder, String target)
{
+ createShortCut(specialFolder, target, "Eclipse Installer");
+
+ }
+
+ public static void createShortCut(String specialFolder, String target, String shortcutName)
+ {
try
{
String powerShell = KeepInstallerUtil.getPowerShell();
if (powerShell != null)
{
- Runtime.getRuntime()
- .exec(new String[] { powerShell, "-command",
- "& {$linkPath = Join-Path ([Environment]::GetFolderPath('" + specialFolder + "')) 'Eclipse Installer.lnk'; $targetPath = '" + target
+ Runtime.getRuntime().exec(
+ new String[] {
+ powerShell,
+ "-command",
+ "& {$linkPath = Join-Path ([Environment]::GetFolderPath('" + specialFolder + "')) '" + shortcutName + ".lnk'; $targetPath = '" + target
+ "'; $link = (New-Object -ComObject WScript.Shell).CreateShortcut( $linkpath ); $link.TargetPath = $targetPath; $link.Save()}" });
}
}
@@ -60,8 +68,9 @@ public final class KeepInstallerUtil
String powerShell = KeepInstallerUtil.getPowerShell();
if (powerShell != null)
{
- Runtime.getRuntime().exec(new String[] { powerShell, "-command",
- "& { (new-object -c shell.application).namespace('" + location + "').parsename('" + launcherName + "').invokeverb('taskbarpin') }" });
+ Runtime.getRuntime().exec(
+ new String[] { powerShell, "-command",
+ "& { (new-object -c shell.application).namespace('" + location + "').parsename('" + launcherName + "').invokeverb('taskbarpin') }" });
}
}
catch (IOException ex)
diff --git a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
index 55380bb61..98ea8fdb1 100644
--- a/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
+++ b/plugins/org.eclipse.oomph.setup.installer/src/org/eclipse/oomph/setup/internal/installer/SimpleVariablePage.java
@@ -28,6 +28,7 @@ import org.eclipse.oomph.setup.AttributeRule;
import org.eclipse.oomph.setup.Installation;
import org.eclipse.oomph.setup.LicenseInfo;
import org.eclipse.oomph.setup.Product;
+import org.eclipse.oomph.setup.ProductCatalog;
import org.eclipse.oomph.setup.ProductVersion;
import org.eclipse.oomph.setup.Scope;
import org.eclipse.oomph.setup.SetupFactory;
@@ -202,6 +203,10 @@ public class SimpleVariablePage extends SimpleInstallerPage
private Composite container;
+ private SimpleCheckbox createStartMenuEntryButton;
+
+ private SimpleCheckbox createDesktopShortcutButton;
+
public SimpleVariablePage(final Composite parent, final SimpleInstallerDialog dialog)
{
super(parent, dialog, true);
@@ -215,10 +220,12 @@ public class SimpleVariablePage extends SimpleInstallerPage
container.setBackgroundMode(SWT.INHERIT_FORCE);
container.setBackground(AbstractSimpleDialog.COLOR_WHITE);
+ String powerShell = KeepInstallerUtil.getPowerShell();
+
// Row 1
GridData browserLayoutData = GridDataFactory.fillDefaults().indent(0, 13).grab(true, false).create();
Point defaultSize = SimpleInstallerDialog.getDefaultSize(container);
- browserLayoutData.heightHint = defaultSize.y * 34 / 100;
+ browserLayoutData.heightHint = defaultSize.y * (powerShell != null ? 20 : 34) / 100;
Composite detailArea = new Composite(container, SWT.NONE);
detailArea.setLayoutData(browserLayoutData);
@@ -474,14 +481,40 @@ public class SimpleVariablePage extends SimpleInstallerPage
}
});
+ // Pin rows
+ if (powerShell != null)
+ {
+ {
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ }
+ {
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ createStartMenuEntryButton = createCheckbox(variablesComposite, "create start menu entry");
+ spacer(variablesComposite);
+ }
+ {
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ spacer(variablesComposite);
+ createDesktopShortcutButton = createCheckbox(variablesComposite, "create desktop shortcut");
+ spacer(variablesComposite);
+ }
+ }
+
spacer(variablesComposite);
spacer(variablesComposite);
spacer(variablesComposite);
installButton = new SimpleInstallLaunchButton(variablesComposite);
Point defaultInstallButtonSize = installButton.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- installButton
- .setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(SWT.DEFAULT, defaultInstallButtonSize.y + 3).indent(0, 32).create());
+ installButton.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).hint(SWT.DEFAULT, defaultInstallButtonSize.y + 3).indent(0, 32)
+ .create());
installButton.setCurrentState(SimpleInstallLaunchButton.State.INSTALL);
spacer(variablesComposite);
@@ -747,10 +780,15 @@ public class SimpleVariablePage extends SimpleInstallerPage
folderText.setEnabled(enabled);
folderButton.setEnabled(enabled);
+ createStartMenuEntryButton.setEnabled(enabled);
+ createDesktopShortcutButton.setEnabled(enabled);
+
boolean versionVisible = versionCombo.getItemCount() != 1;
setVisible(versionLabel, versionVisible);
setVisible(versionSpacer, versionVisible);
setVisible(versionCombo.getParent(), versionVisible);
+ setVisible(bitness32Button, versionVisible);
+ setVisible(bitness64Button, versionVisible);
if (JREManager.BITNESS_CHANGEABLE)
{
@@ -1103,6 +1141,40 @@ public class SimpleVariablePage extends SimpleInstallerPage
showReadmeButton.setVisible(readmePath != null);
+ if (createStartMenuEntryButton != null || createDesktopShortcutButton != null)
+ {
+ File executable = ProgressPage.getExecutable(performer);
+
+ ProductCatalog productCatalog = product.getProductCatalog();
+ String catalogName = "user.products".equals(productCatalog.getName()) ? "" : productCatalog.getLabel();
+ int firstDot = catalogName.indexOf('.');
+ if (firstDot != -1)
+ {
+ catalogName = catalogName.substring(0, firstDot);
+ }
+
+ String productName = product.getName();
+ if (productName.startsWith("epp.package."))
+ {
+ productName = productName.substring("epp.package.".length());
+ }
+ productName = productName.replace('.', ' ');
+
+ String qualifiedProductName = productName + " " + selectedProductVersion.getName().replace('.', ' ');
+
+ String shortCutName = StringUtil.capAll(StringUtil.isEmpty(catalogName) ? qualifiedProductName : catalogName + " " + qualifiedProductName);
+
+ if (createStartMenuEntryButton != null && createStartMenuEntryButton.isChecked())
+ {
+ KeepInstallerUtil.createShortCut("Programs", executable.getAbsolutePath(), shortCutName);
+ }
+
+ if (createDesktopShortcutButton != null && createDesktopShortcutButton.isChecked())
+ {
+ KeepInstallerUtil.createShortCut("Desktop", executable.getAbsolutePath(), shortCutName);
+ }
+ }
+
showSuccessMessage();
backButton.setEnabled(true);
@@ -1297,6 +1369,15 @@ public class SimpleVariablePage extends SimpleInstallerPage
return performer != null && getLogFile().exists();
}
+ private SimpleCheckbox createCheckbox(Composite parent, String text)
+ {
+ final SimpleCheckbox checkbox = new SimpleCheckbox(parent);
+ checkbox.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
+ checkbox.setText(text);
+ checkbox.setChecked(true);
+ return checkbox;
+ }
+
/**
* @author Eike Stepper
*/
@@ -1365,7 +1446,7 @@ public class SimpleVariablePage extends SimpleInstallerPage
/**
* @author Eike Stepper
*/
- private final class SimplePrompter extends HashMap<String, String>implements SetupPrompter
+ private final class SimplePrompter extends HashMap<String, String> implements SetupPrompter
{
private static final long serialVersionUID = 1L;
diff --git a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProgressPage.java b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProgressPage.java
index 860a1e04b..647435571 100644
--- a/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProgressPage.java
+++ b/plugins/org.eclipse.oomph.setup.ui/src/org/eclipse/oomph/setup/ui/wizards/ProgressPage.java
@@ -350,8 +350,8 @@ public class ProgressPage extends SetupWizardPage
}
else
{
- launchButton = addCheckButton("Restart automatically if needed", "Restart the current product if the installation has been changed by setup tasks", false,
- "restartIfNeeded");
+ launchButton = addCheckButton("Restart automatically if needed", "Restart the current product if the installation has been changed by setup tasks",
+ false, "restartIfNeeded");
}
launchAutomatically = launchButton.getSelection();
@@ -844,7 +844,8 @@ public class ProgressPage extends SetupWizardPage
{
if (restart)
{
- setMessage("Task execution has successfully completed but requires a restart. Press Finish to restart now or Cancel to restart later.",
+ setMessage(
+ "Task execution has successfully completed but requires a restart. Press Finish to restart now or Cancel to restart later.",
IMessageProvider.WARNING);
setButtonState(IDialogConstants.CANCEL_ID, true);
@@ -859,8 +860,8 @@ public class ProgressPage extends SetupWizardPage
setButtonState(IDialogConstants.CANCEL_ID, false);
}
- shell.setData(PROGRESS_STATUS,
- new Status(IStatus.OK, SetupEditPlugin.INSTANCE.getSymbolicName(), "Task execution has successfully completed"));
+ shell.setData(PROGRESS_STATUS, new Status(IStatus.OK, SetupEditPlugin.INSTANCE.getSymbolicName(),
+ "Task execution has successfully completed"));
}
}
else
@@ -919,6 +920,17 @@ public class ProgressPage extends SetupWizardPage
}
}
+ public static File getExecutable(SetupTaskPerformer performer)
+ {
+ OS os = performer.getOS();
+ String relativeProductFolder = performer.getRelativeProductFolder();
+ String relativeExecutableFolder = os.getRelativeExecutableFolder();
+ String executableName = os.getExecutableName(performer.getLauncherName());
+ File eclipseLocation = new File(performer.getInstallationLocation(), relativeProductFolder);
+ File executableFolder = new File(eclipseLocation, relativeExecutableFolder);
+ return new File(executableFolder, executableName);
+ }
+
public static boolean launchProduct(SetupTaskPerformer performer) throws Exception
{
OS os = performer.getOS();

Back to the top