From 21865ed3ef58dfc479b831009f3a00fb72e25c89 Mon Sep 17 00:00:00 2001 From: Sarika Sinha Date: Mon, 30 Jul 2018 01:35:33 +0530 Subject: Bug 312397 - Run Configuration Command Line to Clipboard Change-Id: I19d054bed10f834c52bc00f0397255f870b4d6c8 --- .../LaunchConfigurationTabGroupViewer.java | 7 +-- .../LaunchConfigurationsMessages.java | 1 + .../LaunchConfigurationsMessages.properties | 1 + .../ShowCommandLineDialog.java | 61 +++++++++++++++++----- 4 files changed, 50 insertions(+), 20 deletions(-) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java index 45a43f20a..30764a43b 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabGroupViewer.java @@ -1553,12 +1553,7 @@ public class LaunchConfigurationTabGroupViewer { * Dialog to Show the Command line */ protected void handleShowCommandLinePressed() { - ShowCommandLineDialog dialog = new ShowCommandLineDialog(getShell(), - LaunchConfigurationsMessages.LaunchConfigurationDialog_ShowCommandLine_Title, null, null, 0, - new String[] { LaunchConfigurationsMessages.LaunchConfigurationDialog_ShowCommandLine_Copy, - IDialogConstants.CANCEL_LABEL }, - 0, - fOriginal); + ShowCommandLineDialog dialog = new ShowCommandLineDialog(getShell(), fOriginal); dialog.open(); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java index 3414bbbbc..edaf3c963 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.java @@ -107,6 +107,7 @@ public class LaunchConfigurationsMessages extends NLS { public static String LaunchConfigurationDialog_ShowCommandLine; public static String LaunchConfigurationDialog_ShowCommandLine_Title; public static String LaunchConfigurationDialog_ShowCommandLine_Copy; + public static String LaunchConfigurationDialog_ShowCommandLine_Default; public static String LaunchConfigurationSelectionDialog_0; public static String LaunchConfigurationSelectionDialog_1; public static String LaunchConfigurationSelectionDialog_deleteButtonLabel; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties index b48e01d71..de89a84d9 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationsMessages.properties @@ -118,6 +118,7 @@ LaunchConfigurationsDialog_Information_3=Information LaunchConfigurationDialog_ShowCommandLine=Sho&w Command Line LaunchConfigurationDialog_ShowCommandLine_Title=Command Line LaunchConfigurationDialog_ShowCommandLine_Copy=C&opy +LaunchConfigurationDialog_ShowCommandLine_Default=Command Line could not be retrieved. LaunchConfigurationsDialog_0=New launch configuration LaunchConfigurationsDialog_1=Delete selected launch configuration(s) LaunchConfigurationsDialog_2=New launch configuration prototype diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ShowCommandLineDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ShowCommandLineDialog.java index fc3a3b462..f11ab8a3a 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ShowCommandLineDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/ShowCommandLineDialog.java @@ -24,13 +24,15 @@ import org.eclipse.debug.core.Launch; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate2; import org.eclipse.debug.internal.core.DebugCoreMessages; -import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.debug.internal.ui.DebugUIPlugin; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.swt.SWT; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; @@ -44,23 +46,37 @@ import com.ibm.icu.text.MessageFormat; /** * Allows the user to specify to see and copy the command line to be executed * for the launch. - * + * * @since 3.13 */ -public class ShowCommandLineDialog extends MessageDialog { +public class ShowCommandLineDialog extends Dialog { Text fModuleArgumentsText; ILaunchConfiguration flaunchConfiguration; - public ShowCommandLineDialog(Shell parentShell, String dialogTitle, Image dialogTitleImage, String dialogMessage, int dialogImageType, String[] dialogButtonLabels, int defaultIndex, ILaunchConfiguration config) { - super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex); + public ShowCommandLineDialog(Shell parentShell, ILaunchConfiguration config) { + super(parentShell); + setShellStyle(SWT.RESIZE | getShellStyle()); flaunchConfiguration = config; } + + @Override + protected void configureShell(Shell newShell) { + super.configureShell(newShell); + newShell.setText(LaunchConfigurationsMessages.LaunchConfigurationDialog_ShowCommandLine_Title); + } + + @Override + protected void createButtonsForButtonBar(Composite parent) { + createButton(parent, IDialogConstants.OK_ID, + LaunchConfigurationsMessages.LaunchConfigurationDialog_ShowCommandLine_Copy, true); + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + @Override - protected Control createCustomArea(Composite parent) { - Composite comp = new Composite(parent, SWT.NONE); - comp.setLayout(new GridLayout()); + protected Control createDialogArea(Composite parent) { + Composite comp = (Composite) super.createDialogArea(parent); Font font = parent.getFont(); Group group = new Group(comp, SWT.NONE); @@ -72,16 +88,13 @@ public class ShowCommandLineDialog extends MessageDialog { group.setLayoutData(gd); group.setFont(font); - - // Label description = new Label(group, SWT.WRAP); - // description.setText(ActionMessages.Override_Dependencies_label1); fModuleArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL); gd = new GridData(GridData.FILL_BOTH); gd.heightHint = convertHeightInCharsToPixels(10); gd.widthHint = convertWidthInCharsToPixels(60); fModuleArgumentsText.setLayoutData(gd); - String command = "Could not retrieve the command"; //$NON-NLS-1$ + String command = ""; //$NON-NLS-1$ try { Set modes = flaunchConfiguration.getModes(); modes.add(ILaunchManager.RUN_MODE); @@ -108,11 +121,16 @@ public class ShowCommandLineDialog extends MessageDialog { } } } - command = delegate.showCommandLine(flaunchConfiguration, ILaunchManager.RUN_MODE, launch, null); + command = delegate.showCommandLine(flaunchConfiguration, ILaunchManager.RUN_MODE, launch, + null); + } } catch (CoreException e) { e.printStackTrace(); } + if (command == null || (command != null && command.length() == 0)) { + command = LaunchConfigurationsMessages.LaunchConfigurationDialog_ShowCommandLine_Default; + } fModuleArgumentsText.setText(command); fModuleArgumentsText.setEditable(false); @@ -135,6 +153,21 @@ public class ShowCommandLineDialog extends MessageDialog { super.buttonPressed(buttonId); } + @Override + protected IDialogSettings getDialogBoundsSettings() { + IDialogSettings settings = DebugUIPlugin.getDefault().getDialogSettings(); + IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); + if (section == null) { + section = settings.addNewSection(getDialogSettingsSectionName()); + } + return section; + } + /** + * @return the name to use to save the dialog settings + */ + protected String getDialogSettingsSectionName() { + return "SHOW_COMMAND_LINE_DIALOG"; //$NON-NLS-1$ + } } -- cgit v1.2.3