diff options
author | Darin Wright | 2003-09-22 15:57:37 +0000 |
---|---|---|
committer | Darin Wright | 2003-09-22 15:57:37 +0000 |
commit | 0efc4227d6a4f3bacf9f45c220c2b3b4546613e8 (patch) | |
tree | c983b7f4e6827af56d25af23298923ccb972de90 /org.eclipse.debug.ui | |
parent | 79ddd516af0fcadfc2d477a6a5e36ced734b6146 (diff) | |
download | eclipse.platform.debug-0efc4227d6a4f3bacf9f45c220c2b3b4546613e8.tar.gz eclipse.platform.debug-0efc4227d6a4f3bacf9f45c220c2b3b4546613e8.tar.xz eclipse.platform.debug-0efc4227d6a4f3bacf9f45c220c2b3b4546613e8.zip |
bug 43332 - Re-work launch variable API
Diffstat (limited to 'org.eclipse.debug.ui')
6 files changed, 187 insertions, 11 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/IArgumentSelector.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/IArgumentSelector.java index 5831b5590..e584f7a81 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/IArgumentSelector.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/IArgumentSelector.java @@ -11,6 +11,7 @@ package org.eclipse.debug.internal.ui.stringsubstitution; import org.eclipse.debug.internal.core.stringsubstitution.IStringVariable; +import org.eclipse.swt.widgets.Shell; /** @@ -26,8 +27,10 @@ public interface IArgumentSelector { * Selects and returns an argument for the given variable, * or <code>null</code> if none. * + * @param variable the variable an arugment is being seleted for + * @param the shell to create any dialogs on, or <code>null</code> if none * @return argument for the given variable or <code>null</code> * if none */ - public String selectArgument(IStringVariable variable); + public String selectArgument(IStringVariable variable, Shell shell); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ResourceSelector.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ResourceSelector.java new file mode 100644 index 000000000..3d3c723da --- /dev/null +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/ResourceSelector.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * Copyright (c) 2000, 2003 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.internal.ui.stringsubstitution; + +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.debug.internal.core.stringsubstitution.IStringVariable; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.dialogs.ResourceListSelectionDialog; + +/** + * Selects a resource argument for a string substitution variable + */ +public class ResourceSelector implements IArgumentSelector { + + /* (non-Javadoc) + * @see org.eclipse.debug.internal.ui.stringsubstitution.IArgumentSelector#selectArgument(org.eclipse.debug.internal.core.stringsubstitution.IStringVariable) + */ + public String selectArgument(IStringVariable variable, Shell shell) { + ResourceListSelectionDialog dialog = new ResourceListSelectionDialog(shell, ResourcesPlugin.getWorkspace().getRoot(), IResource.FILE | IResource.FOLDER | IResource.PROJECT); + dialog.setTitle(StringSubstitutionMessages.getString("ResourceSelector.0")); //$NON-NLS-1$ + if (dialog.open() == Window.OK) { + Object[] objects = dialog.getResult(); + if (objects.length == 1) { + return ((IResource)objects[0]).getFullPath().toString(); + } + } + return null; + } + +} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties index 02d3877a1..4669ee01f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringSubstitutionMessages.properties @@ -16,6 +16,12 @@ ResourceResolver.6=Variable references non-existant resource : {0} ResourceResolver.7=Variable references empty selection: {0} ResourceResolver.8=Variable not recognized: {0} +ResourceSelector.0=Select Resource + StringPromptExpander.0=Variable input + StringVariableSelectionDialog.2=Select Variable StringVariableSelectionDialog.3=&Choose a variable (? = any character, * = any string): +StringVariableSelectionDialog.6=&Argument: +StringVariableSelectionDialog.7=C&onfigure... +StringVariableSelectionDialog.8=Variable Description: diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java index 6793f1d0f..54cf4443f 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableLabelProvider.java @@ -22,14 +22,7 @@ class StringVariableLabelProvider extends LabelProvider { public String getText(Object element) { if (element instanceof IStringVariable) { IStringVariable variable = (IStringVariable)element; - StringBuffer buffer = new StringBuffer(); - buffer.append(variable.getName()); - String desc = variable.getDescription(); - if (desc != null) { - buffer.append(" - "); //$NON-NLS-1$ - buffer.append(desc); - } - return buffer.toString(); + return variable.getName(); } return super.getText(element); } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java index 998a27bc5..126b603ba 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariablePresentationManager.java @@ -33,7 +33,7 @@ public class StringVariablePresentationManager { * * @since 3.0 */ - public static final String EXTENSION_POINT_STRING_VARIABLE_PRESENTATIONS = DebugUIPlugin.getUniqueIdentifier() + ".stringVariablePresentations"; //$NON-NLS-1$ + public static final String EXTENSION_POINT_STRING_VARIABLE_PRESENTATIONS = "stringVariablePresentations"; //$NON-NLS-1$ // default manager private static StringVariablePresentationManager fgManager; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableSelectionDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableSelectionDialog.java index ab53efb6f..e463e89eb 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableSelectionDialog.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/stringsubstitution/StringVariableSelectionDialog.java @@ -12,8 +12,18 @@ package org.eclipse.debug.internal.ui.stringsubstitution; import org.eclipse.debug.internal.core.stringsubstitution.IStringVariable; import org.eclipse.debug.internal.core.stringsubstitution.StringVariableManager; +import org.eclipse.debug.internal.ui.SWTUtil; 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.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.ElementListSelectionDialog; /** @@ -23,6 +33,14 @@ import org.eclipse.ui.dialogs.ElementListSelectionDialog; * @since 3,0 */ public class StringVariableSelectionDialog extends ElementListSelectionDialog { + + // button to configure variable's argument + private Button fArgumentButton; + // variable description + private Text fDescriptionText; + // the argument value + private Text fArgumentText; + private String fArgumentValue; /** * Constructs a new string substitution variable selection dialog. @@ -46,17 +64,133 @@ public class StringVariableSelectionDialog extends ElementListSelectionDialog { * dialog, or <code>null</code> if none */ public String getVariableExpression() { - // TODO: allow user to configure argument Object[] selected = getResult(); if (selected != null && selected.length == 1) { IStringVariable variable = (IStringVariable)selected[0]; StringBuffer buffer = new StringBuffer(); buffer.append("${"); //$NON-NLS-1$ buffer.append(variable.getName()); + if (fArgumentValue != null && fArgumentValue.length() > 0) { + buffer.append(":"); //$NON-NLS-1$ + buffer.append(fArgumentValue); + } buffer.append("}"); //$NON-NLS-1$ return buffer.toString(); } return null; } + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + Control control = super.createDialogArea(parent); + createArgumentArea((Composite)control); + return control; + } + + /** + * Creates an area to display a description of the selected variable + * and a button to configure the variable's argument. + * + * @param parent parnet widget + */ + private void createArgumentArea(Composite parent) { + Composite container = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + layout.marginHeight = 0; + layout.marginWidth = 0; + container.setLayout(layout); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + container.setLayoutData(gd); + container.setFont(parent.getFont()); + + Label desc = new Label(container, SWT.NONE); + desc.setFont(parent.getFont()); + desc.setText(StringSubstitutionMessages.getString("StringVariableSelectionDialog.6")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + desc.setLayoutData(gd); + + fArgumentText = new Text(container, SWT.BORDER); + fArgumentText.setFont(container.getFont()); + gd = new GridData(GridData.FILL_HORIZONTAL); + fArgumentText.setLayoutData(gd); + + fArgumentButton = new Button(container, SWT.PUSH); + fArgumentButton.setFont(parent.getFont()); + fArgumentButton.setText(StringSubstitutionMessages.getString("StringVariableSelectionDialog.7")); //$NON-NLS-1$ + gd = new GridData(GridData.HORIZONTAL_ALIGN_END); + gd.widthHint = SWTUtil.getButtonWidthHint(fArgumentButton); + fArgumentButton.setLayoutData(gd); + fArgumentButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + configureArgument(); + } + }); + + + desc = new Label(container, SWT.NONE); + desc.setFont(parent.getFont()); + desc.setText(StringSubstitutionMessages.getString("StringVariableSelectionDialog.8")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + desc.setLayoutData(gd); + + fDescriptionText = new Text(container, SWT.BORDER | SWT.WRAP); + fDescriptionText.setFont(container.getFont()); + fDescriptionText.setEditable(false); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + gd.heightHint = 50; + fDescriptionText.setLayoutData(gd); + + } + + /** + * Configures the argument for the selected variable. + */ + protected void configureArgument() { + Object[] objects = getSelectedElements(); + IStringVariable variable = (IStringVariable)objects[0]; + IArgumentSelector selector = StringVariablePresentationManager.getDefault().getArgumentSelector(variable); + String value = selector.selectArgument(variable, getShell()); + if (value != null) { + fArgumentText.setText(value); + } + } + + /** + * Update variable description and argument button enablement. + * + * @see org.eclipse.ui.dialogs.AbstractElementListSelectionDialog#handleSelectionChanged() + */ + protected void handleSelectionChanged() { + super.handleSelectionChanged(); + Object[] objects = getSelectedElements(); + boolean enabled = false; + String text = null; + if (objects.length == 1) { + IStringVariable variable = (IStringVariable)objects[0]; + IArgumentSelector selector = StringVariablePresentationManager.getDefault().getArgumentSelector(variable); + enabled = selector != null; + text = variable.getDescription(); + } + if (text == null) { + text = ""; //$NON-NLS-1$ + } + fArgumentButton.setEnabled(enabled); + fDescriptionText.setText(text); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#okPressed() + */ + protected void okPressed() { + fArgumentValue = fArgumentText.getText().trim(); + super.okPressed(); + } + } |