From 65fdbea4c0f867a80489f821b005ff9f52e24055 Mon Sep 17 00:00:00 2001 From: Doug Schaefer Date: Tue, 4 Jun 2019 10:46:06 -0400 Subject: [PATCH] Bug 547916 - Manage the size of the New Launch Config Wizard Dialog. Replicates the size management code of the regular launch config dialog and sets the default size to be 800x720. Change-Id: I00e5028383e3a04e8b81d3adfa8487f9fb7fbcaf --- .../ui/controls/internal/ConfigSelector.java | 3 +- .../launchbar/ui/NewLaunchConfigWizard.java | 2 +- .../ui/NewLaunchConfigWizardDialog.java | 66 +++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizardDialog.java diff --git a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java index cc22d905699..dd79efa4601 100644 --- a/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java +++ b/bundles/org.eclipse.launchbar.ui.controls/src/org/eclipse/launchbar/ui/controls/internal/ConfigSelector.java @@ -28,6 +28,7 @@ import org.eclipse.launchbar.core.ILaunchDescriptor; import org.eclipse.launchbar.ui.DefaultDescriptorLabelProvider; import org.eclipse.launchbar.ui.ILaunchBarUIManager; import org.eclipse.launchbar.ui.NewLaunchConfigWizard; +import org.eclipse.launchbar.ui.NewLaunchConfigWizardDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; @@ -174,7 +175,7 @@ public class ConfigSelector extends CSelector { @Override public void mouseUp(org.eclipse.swt.events.MouseEvent e) { final NewLaunchConfigWizard wizard = new NewLaunchConfigWizard(); - WizardDialog dialog = new WizardDialog(getShell(), wizard); + WizardDialog dialog = new NewLaunchConfigWizardDialog(getShell(), wizard); if (dialog.open() == Window.OK) { new Job(Messages.ConfigSelector_3) { @Override diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java index 66cac5a4b21..3445cbf9406 100644 --- a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizard.java @@ -50,7 +50,7 @@ public class NewLaunchConfigWizard extends Wizard implements ILaunchConfiguratio @Override public void setContainer(IWizardContainer wizardContainer) { super.setContainer(wizardContainer); - + if (wizardContainer != null) { // Edit page wants to know when it's about to change to itself ((WizardDialog) wizardContainer).addPageChangingListener(editPage); diff --git a/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizardDialog.java b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizardDialog.java new file mode 100644 index 00000000000..869bcef2d44 --- /dev/null +++ b/bundles/org.eclipse.launchbar.ui/src/org/eclipse/launchbar/ui/NewLaunchConfigWizardDialog.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2014, 2018 QNX Software Systems 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 + * + * SPDX-License-Identifier: EPL-2.0 + *******************************************************************************/ +package org.eclipse.launchbar.ui; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.wizard.IWizard; +import org.eclipse.jface.wizard.WizardDialog; +import org.eclipse.launchbar.ui.internal.Activator; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Shell; + +/** + * Wizard Dialog for Launch Bar's new Launch Configuration Wizard. + * + * @since 2.3 + */ +public class NewLaunchConfigWizardDialog extends WizardDialog { + + /** + * Size of this dialog if there is no preference specifying a size. + */ + protected static final Point DEFAULT_INITIAL_DIALOG_SIZE = new Point(800, 720); + + public NewLaunchConfigWizardDialog(Shell parentShell, IWizard newWizard) { + super(parentShell, newWizard); + } + + /** + * Returns the name of the section that this dialog stores its settings in + * + * @return String + */ + protected String getDialogSettingsSectionName() { + return Activator.PLUGIN_ID + ".LAUNCH_CONFIGURATIONS_DIALOG_SECTION"; //$NON-NLS-1$ + } + + @Override + protected IDialogSettings getDialogBoundsSettings() { + IDialogSettings settings = Activator.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); + if (section == null) { + section = settings.addNewSection(getDialogSettingsSectionName()); + } + return section; + } + + @Override + protected Point getInitialSize() { + try { + // Check if we've saved the height before + getDialogBoundsSettings().getInt("DIALOG_HEIGHT"); //$NON-NLS-1$ + return super.getInitialSize(); + } catch(NumberFormatException nfe) { + // Nope, return the default size + return DEFAULT_INITIAL_DIALOG_SIZE; + } + } + +}