org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/debug/ui/launchConfigurations/AppletParametersTab.java
Parent Directory
|
Revision Log
Revision 1.32 - (view) (download)
| 1 : | droberts | 1.8 | /******************************************************************************* |
| 2 : | darin | 1.32 | * Copyright (c) 2000, 2008 IBM Corporation and others. |
| 3 : | krbarnes | 1.17 | * All rights reserved. This program and the accompanying materials |
| 4 : | darins | 1.18 | * are made available under the terms of the Eclipse Public License v1.0 |
| 5 : | droberts | 1.8 | * which accompanies this distribution, and is available at |
| 6 : | darins | 1.18 | * http://www.eclipse.org/legal/epl-v10.html |
| 7 : | darin | 1.32 | * |
| 8 : | droberts | 1.8 | * Contributors: |
| 9 : | * IBM Corporation - initial API and implementation | ||
| 10 : | *******************************************************************************/ | ||
| 11 : | jszursze | 1.1 | package org.eclipse.jdt.debug.ui.launchConfigurations; |
| 12 : | |||
| 13 : | import java.util.HashMap; | ||
| 14 : | import java.util.Map; | ||
| 15 : | |||
| 16 : | import org.eclipse.core.runtime.CoreException; | ||
| 17 : | import org.eclipse.debug.core.ILaunchConfiguration; | ||
| 18 : | import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; | ||
| 19 : | mrennie | 1.24 | import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds; |
| 20 : | jszursze | 1.1 | import org.eclipse.jdt.internal.debug.ui.JavaDebugImages; |
| 21 : | import org.eclipse.jdt.internal.debug.ui.launcher.LauncherMessages; | ||
| 22 : | import org.eclipse.jdt.internal.debug.ui.launcher.NameValuePairDialog; | ||
| 23 : | import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; | ||
| 24 : | krbarnes | 1.23 | import org.eclipse.jface.dialogs.Dialog; |
| 25 : | jszursze | 1.1 | import org.eclipse.jface.viewers.ColumnWeightData; |
| 26 : | krbarnes | 1.23 | import org.eclipse.jface.viewers.ILabelProviderListener; |
| 27 : | import org.eclipse.jface.viewers.IStructuredContentProvider; | ||
| 28 : | import org.eclipse.jface.viewers.IStructuredSelection; | ||
| 29 : | import org.eclipse.jface.viewers.ITableLabelProvider; | ||
| 30 : | jszursze | 1.1 | import org.eclipse.jface.viewers.TableLayout; |
| 31 : | krbarnes | 1.23 | import org.eclipse.jface.viewers.TableViewer; |
| 32 : | import org.eclipse.jface.viewers.Viewer; | ||
| 33 : | darin | 1.27 | import org.eclipse.jface.viewers.ViewerComparator; |
| 34 : | jszursze | 1.1 | import org.eclipse.jface.window.Window; |
| 35 : | import org.eclipse.swt.SWT; | ||
| 36 : | import org.eclipse.swt.events.ModifyEvent; | ||
| 37 : | import org.eclipse.swt.events.ModifyListener; | ||
| 38 : | import org.eclipse.swt.events.MouseAdapter; | ||
| 39 : | import org.eclipse.swt.events.MouseEvent; | ||
| 40 : | import org.eclipse.swt.events.SelectionAdapter; | ||
| 41 : | import org.eclipse.swt.events.SelectionEvent; | ||
| 42 : | import org.eclipse.swt.graphics.Image; | ||
| 43 : | import org.eclipse.swt.layout.GridData; | ||
| 44 : | import org.eclipse.swt.layout.GridLayout; | ||
| 45 : | import org.eclipse.swt.widgets.Button; | ||
| 46 : | import org.eclipse.swt.widgets.Composite; | ||
| 47 : | import org.eclipse.swt.widgets.Label; | ||
| 48 : | import org.eclipse.swt.widgets.Table; | ||
| 49 : | import org.eclipse.swt.widgets.TableColumn; | ||
| 50 : | import org.eclipse.swt.widgets.Text; | ||
| 51 : | mrennie | 1.24 | import org.eclipse.ui.PlatformUI; |
| 52 : | jszursze | 1.1 | |
| 53 : | /** | ||
| 54 : | * This tab appears for java applet launch configurations and allows the user to edit | ||
| 55 : | * applet-specific attributes such as width, height, name & applet parameters. | ||
| 56 : | jszursze | 1.6 | * <p> |
| 57 : | mrennie | 1.31 | * This class may be instantiated. |
| 58 : | jszursze | 1.6 | * </p> |
| 59 : | jszursze | 1.1 | * @since 2.1 |
| 60 : | mrennie | 1.30 | * @noextend This class is not intended to be subclassed by clients. |
| 61 : | jszursze | 1.1 | */ |
| 62 : | darin | 1.22 | public class AppletParametersTab extends JavaLaunchTab { |
| 63 : | jszursze | 1.1 | |
| 64 : | private Label fWidthLabel; | ||
| 65 : | private Text fWidthText; | ||
| 66 : | private Label fHeightLabel; | ||
| 67 : | private Text fHeightText; | ||
| 68 : | private Label fNameLabel; | ||
| 69 : | private Text fNameText; | ||
| 70 : | private Button fParametersAddButton; | ||
| 71 : | private Button fParametersRemoveButton; | ||
| 72 : | private Button fParametersEditButton; | ||
| 73 : | jburns | 1.12 | |
| 74 : | private class AppletTabListener extends SelectionAdapter implements ModifyListener { | ||
| 75 : | |||
| 76 : | /* (non-Javadoc) | ||
| 77 : | * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent) | ||
| 78 : | */ | ||
| 79 : | public void modifyText(ModifyEvent e) { | ||
| 80 : | updateLaunchConfigurationDialog(); | ||
| 81 : | } | ||
| 82 : | |||
| 83 : | /* (non-Javadoc) | ||
| 84 : | * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) | ||
| 85 : | */ | ||
| 86 : | public void widgetSelected(SelectionEvent e) { | ||
| 87 : | Object source= e.getSource(); | ||
| 88 : | krbarnes | 1.23 | if (source == fViewer.getTable() || source == fViewer) { |
| 89 : | jburns | 1.12 | setParametersButtonsEnableState(); |
| 90 : | } else if (source == fParametersAddButton) { | ||
| 91 : | handleParametersAddButtonSelected(); | ||
| 92 : | } else if (source == fParametersEditButton) { | ||
| 93 : | handleParametersEditButtonSelected(); | ||
| 94 : | } else if (source == fParametersRemoveButton) { | ||
| 95 : | handleParametersRemoveButtonSelected(); | ||
| 96 : | } | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | } | ||
| 100 : | |||
| 101 : | private AppletTabListener fListener= new AppletTabListener(); | ||
| 102 : | jszursze | 1.1 | |
| 103 : | private static final String EMPTY_STRING = ""; //$NON-NLS-1$ | ||
| 104 : | |||
| 105 : | /** | ||
| 106 : | droberts | 1.8 | * The default value for the 'width' attribute. |
| 107 : | */ | ||
| 108 : | jszursze | 1.1 | public static final int DEFAULT_APPLET_WIDTH = 200; |
| 109 : | |||
| 110 : | /** | ||
| 111 : | * The default value for the 'height' attribute. | ||
| 112 : | */ | ||
| 113 : | public static final int DEFAULT_APPLET_HEIGHT = 200; | ||
| 114 : | krbarnes | 1.23 | |
| 115 : | /** | ||
| 116 : | * The parameters table viewer | ||
| 117 : | */ | ||
| 118 : | private TableViewer fViewer; | ||
| 119 : | jszursze | 1.1 | |
| 120 : | /** | ||
| 121 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(Composite) |
| 122 : | jszursze | 1.1 | */ |
| 123 : | mrennie | 1.24 | public void createControl(Composite parent) { |
| 124 : | jszursze | 1.1 | Composite comp = new Composite(parent, SWT.NONE); |
| 125 : | setControl(comp); | ||
| 126 : | mrennie | 1.24 | PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.LAUNCH_CONFIGURATION_DIALOG_APPLET_PARAMETERS_TAB); |
| 127 : | jszursze | 1.1 | GridLayout topLayout = new GridLayout(); |
| 128 : | comp.setLayout(topLayout); | ||
| 129 : | GridData gd; | ||
| 130 : | |||
| 131 : | Composite widthHeightNameComp = new Composite(comp, SWT.NONE); | ||
| 132 : | gd = new GridData(GridData.FILL_HORIZONTAL); | ||
| 133 : | widthHeightNameComp.setLayoutData(gd); | ||
| 134 : | GridLayout widthHeightNameLayout = new GridLayout(); | ||
| 135 : | widthHeightNameLayout.marginHeight = 0; | ||
| 136 : | widthHeightNameLayout.marginWidth = 0; | ||
| 137 : | darin | 1.2 | widthHeightNameLayout.numColumns = 4; |
| 138 : | jszursze | 1.1 | widthHeightNameComp.setLayout(widthHeightNameLayout); |
| 139 : | |||
| 140 : | fWidthLabel= new Label(widthHeightNameComp, SWT.NONE); | ||
| 141 : | darin | 1.21 | fWidthLabel.setText(LauncherMessages.appletlauncher_argumenttab_widthlabel_text); |
| 142 : | jszursze | 1.1 | |
| 143 : | fWidthText = new Text(widthHeightNameComp, SWT.SINGLE | SWT.BORDER); | ||
| 144 : | gd = new GridData(GridData.FILL_HORIZONTAL); | ||
| 145 : | fWidthText.setLayoutData(gd); | ||
| 146 : | jburns | 1.12 | fWidthText.addModifyListener(fListener); |
| 147 : | darin | 1.2 | |
| 148 : | fNameLabel = new Label(widthHeightNameComp, SWT.NONE); | ||
| 149 : | darin | 1.21 | fNameLabel.setText(LauncherMessages.appletlauncher_argumenttab_namelabel_text); |
| 150 : | jszursze | 1.1 | |
| 151 : | darin | 1.2 | fNameText = new Text(widthHeightNameComp, SWT.SINGLE | SWT.BORDER); |
| 152 : | gd = new GridData(GridData.FILL_HORIZONTAL); | ||
| 153 : | fNameText.setLayoutData(gd); | ||
| 154 : | jburns | 1.12 | fNameText.addModifyListener(fListener); |
| 155 : | darin | 1.2 | |
| 156 : | jszursze | 1.1 | fHeightLabel= new Label(widthHeightNameComp, SWT.NONE); |
| 157 : | darin | 1.21 | fHeightLabel.setText(LauncherMessages.appletlauncher_argumenttab_heightlabel_text); |
| 158 : | jszursze | 1.1 | |
| 159 : | fHeightText = new Text(widthHeightNameComp, SWT.SINGLE | SWT.BORDER); | ||
| 160 : | gd = new GridData(GridData.FILL_HORIZONTAL); | ||
| 161 : | fHeightText.setLayoutData(gd); | ||
| 162 : | jburns | 1.12 | fHeightText.addModifyListener(fListener); |
| 163 : | jszursze | 1.1 | |
| 164 : | darin | 1.2 | Label blank = new Label(widthHeightNameComp, SWT.NONE); |
| 165 : | blank.setText(EMPTY_STRING); | ||
| 166 : | Label hint = new Label(widthHeightNameComp, SWT.NONE); | ||
| 167 : | darin | 1.21 | hint.setText(LauncherMessages.AppletParametersTab__optional_applet_instance_name__1); |
| 168 : | darin | 1.2 | gd = new GridData(GridData.HORIZONTAL_ALIGN_CENTER); |
| 169 : | hint.setLayoutData(gd); | ||
| 170 : | |||
| 171 : | jszursze | 1.1 | createVerticalSpacer(comp); |
| 172 : | |||
| 173 : | Composite parametersComp = new Composite(comp, SWT.NONE); | ||
| 174 : | gd = new GridData(GridData.FILL_BOTH); | ||
| 175 : | parametersComp.setLayoutData(gd); | ||
| 176 : | GridLayout parametersLayout = new GridLayout(); | ||
| 177 : | parametersLayout.numColumns = 2; | ||
| 178 : | parametersLayout.marginHeight = 0; | ||
| 179 : | parametersLayout.marginWidth = 0; | ||
| 180 : | parametersComp.setLayout(parametersLayout); | ||
| 181 : | |||
| 182 : | Label parameterLabel = new Label(parametersComp, SWT.NONE); | ||
| 183 : | darin | 1.21 | parameterLabel.setText(LauncherMessages.appletlauncher_argumenttab_parameterslabel_text); |
| 184 : | jszursze | 1.1 | gd = new GridData(); |
| 185 : | gd.horizontalSpan = 2; | ||
| 186 : | parameterLabel.setLayoutData(gd); | ||
| 187 : | |||
| 188 : | krbarnes | 1.23 | |
| 189 : | fViewer = new TableViewer(parametersComp); | ||
| 190 : | Table parametersTable = fViewer.getTable(); | ||
| 191 : | gd = new GridData(GridData.FILL_BOTH); | ||
| 192 : | parametersTable.setLayoutData(gd); | ||
| 193 : | TableColumn column1 = new TableColumn(parametersTable, SWT.NONE); | ||
| 194 : | column1.setText(LauncherMessages.appletlauncher_argumenttab_parameterscolumn_name_text); | ||
| 195 : | TableColumn column2 = new TableColumn(parametersTable, SWT.NONE); | ||
| 196 : | column2.setText(LauncherMessages.appletlauncher_argumenttab_parameterscolumn_value_text); | ||
| 197 : | jszursze | 1.1 | TableLayout tableLayout = new TableLayout(); |
| 198 : | krbarnes | 1.23 | parametersTable.setLayout(tableLayout); |
| 199 : | jszursze | 1.1 | tableLayout.addColumnData(new ColumnWeightData(100)); |
| 200 : | tableLayout.addColumnData(new ColumnWeightData(100)); | ||
| 201 : | krbarnes | 1.23 | parametersTable.setHeaderVisible(true); |
| 202 : | parametersTable.setLinesVisible(true); | ||
| 203 : | parametersTable.addSelectionListener(fListener); | ||
| 204 : | parametersTable.addMouseListener(new MouseAdapter() { | ||
| 205 : | jszursze | 1.1 | public void mouseDoubleClick(MouseEvent e) { |
| 206 : | setParametersButtonsEnableState(); | ||
| 207 : | if (fParametersEditButton.isEnabled()) { | ||
| 208 : | handleParametersEditButtonSelected(); | ||
| 209 : | } | ||
| 210 : | } | ||
| 211 : | }); | ||
| 212 : | krbarnes | 1.23 | |
| 213 : | fViewer.setContentProvider(new IStructuredContentProvider() { | ||
| 214 : | public Object[] getElements(Object inputElement) { | ||
| 215 : | Map params = (Map) inputElement; | ||
| 216 : | return params.keySet().toArray(); | ||
| 217 : | } | ||
| 218 : | public void dispose() { | ||
| 219 : | } | ||
| 220 : | public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { | ||
| 221 : | } | ||
| 222 : | }); | ||
| 223 : | jszursze | 1.1 | |
| 224 : | krbarnes | 1.23 | fViewer.setLabelProvider(new ITableLabelProvider() { |
| 225 : | public Image getColumnImage(Object element, int columnIndex) { | ||
| 226 : | return null; | ||
| 227 : | } | ||
| 228 : | public String getColumnText(Object element, int columnIndex) { | ||
| 229 : | if (columnIndex == 0) { | ||
| 230 : | return element.toString(); | ||
| 231 : | } | ||
| 232 : | |||
| 233 : | String key = (String) element; | ||
| 234 : | Map params = (Map) fViewer.getInput(); | ||
| 235 : | Object object = params.get(key); | ||
| 236 : | if (object != null) | ||
| 237 : | return object.toString(); | ||
| 238 : | return null; | ||
| 239 : | } | ||
| 240 : | public void addListener(ILabelProviderListener listener) { | ||
| 241 : | } | ||
| 242 : | public void dispose() { | ||
| 243 : | } | ||
| 244 : | public boolean isLabelProperty(Object element, String property) { | ||
| 245 : | return false; | ||
| 246 : | } | ||
| 247 : | public void removeListener(ILabelProviderListener listener) { | ||
| 248 : | } | ||
| 249 : | }); | ||
| 250 : | |||
| 251 : | darin | 1.27 | fViewer.setComparator(new ViewerComparator()); |
| 252 : | krbarnes | 1.23 | |
| 253 : | jszursze | 1.1 | Composite envButtonComp = new Composite(parametersComp, SWT.NONE); |
| 254 : | GridLayout envButtonLayout = new GridLayout(); | ||
| 255 : | envButtonLayout.marginHeight = 0; | ||
| 256 : | envButtonLayout.marginWidth = 0; | ||
| 257 : | envButtonComp.setLayout(envButtonLayout); | ||
| 258 : | gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL); | ||
| 259 : | envButtonComp.setLayoutData(gd); | ||
| 260 : | |||
| 261 : | darin | 1.21 | fParametersAddButton = createPushButton(envButtonComp ,LauncherMessages.appletlauncher_argumenttab_parameters_button_add_text, null); |
| 262 : | jburns | 1.12 | fParametersAddButton.addSelectionListener(fListener); |
| 263 : | jszursze | 1.1 | |
| 264 : | darin | 1.21 | fParametersEditButton = createPushButton(envButtonComp, LauncherMessages.appletlauncher_argumenttab_parameters_button_edit_text, null); |
| 265 : | jburns | 1.12 | fParametersEditButton.addSelectionListener(fListener); |
| 266 : | jszursze | 1.1 | |
| 267 : | darin | 1.21 | fParametersRemoveButton = createPushButton(envButtonComp, LauncherMessages.appletlauncher_argumenttab_parameters_button_remove_text, null); |
| 268 : | jburns | 1.12 | fParametersRemoveButton.addSelectionListener(fListener); |
| 269 : | krbarnes | 1.23 | |
| 270 : | Dialog.applyDialogFont(parent); | ||
| 271 : | jszursze | 1.1 | } |
| 272 : | |||
| 273 : | |||
| 274 : | /** | ||
| 275 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(ILaunchConfiguration) |
| 276 : | jszursze | 1.1 | */ |
| 277 : | public boolean isValid(ILaunchConfiguration launchConfig) { | ||
| 278 : | setErrorMessage(null); | ||
| 279 : | try { | ||
| 280 : | jburns | 1.15 | Integer.parseInt(getWidthText()); |
| 281 : | jszursze | 1.3 | } catch(NumberFormatException nfe) { |
| 282 : | darin | 1.21 | setErrorMessage(LauncherMessages.appletlauncher_argumenttab_width_error_notaninteger); |
| 283 : | jszursze | 1.1 | return false; |
| 284 : | } | ||
| 285 : | try { | ||
| 286 : | jburns | 1.15 | Integer.parseInt(getHeightText()); |
| 287 : | jszursze | 1.3 | } catch(NumberFormatException nfe) { |
| 288 : | darin | 1.21 | setErrorMessage(LauncherMessages.appletlauncher_argumenttab_height_error_notaninteger); |
| 289 : | jszursze | 1.1 | return false; |
| 290 : | } | ||
| 291 : | return true; | ||
| 292 : | } | ||
| 293 : | |||
| 294 : | private void handleParametersAddButtonSelected() { | ||
| 295 : | NameValuePairDialog dialog = | ||
| 296 : | new NameValuePairDialog(getShell(), | ||
| 297 : | darin | 1.21 | LauncherMessages.appletlauncher_argumenttab_parameters_dialog_add_title, |
| 298 : | new String[] {LauncherMessages.appletlauncher_argumenttab_parameters_dialog_add_name_text, LauncherMessages.appletlauncher_argumenttab_parameters_dialog_add_value_text}, // | ||
| 299 : | jburns | 1.13 | new String[] {EMPTY_STRING, EMPTY_STRING}); |
| 300 : | jszursze | 1.1 | openNewParameterDialog(dialog, null); |
| 301 : | setParametersButtonsEnableState(); | ||
| 302 : | } | ||
| 303 : | |||
| 304 : | private void handleParametersEditButtonSelected() { | ||
| 305 : | krbarnes | 1.23 | IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection(); |
| 306 : | String key = (String) selection.getFirstElement(); | ||
| 307 : | Map params = (Map) fViewer.getInput(); | ||
| 308 : | String value = (String) params.get(key); | ||
| 309 : | |||
| 310 : | jszursze | 1.1 | NameValuePairDialog dialog = |
| 311 : | new NameValuePairDialog(getShell(), | ||
| 312 : | darin | 1.21 | LauncherMessages.appletlauncher_argumenttab_parameters_dialog_edit_title, |
| 313 : | new String[] {LauncherMessages.appletlauncher_argumenttab_parameters_dialog_edit_name_text, LauncherMessages.appletlauncher_argumenttab_parameters_dialog_edit_value_text}, // | ||
| 314 : | krbarnes | 1.23 | new String[] {key, value}); |
| 315 : | |||
| 316 : | openNewParameterDialog(dialog, key); | ||
| 317 : | jszursze | 1.1 | } |
| 318 : | |||
| 319 : | private void handleParametersRemoveButtonSelected() { | ||
| 320 : | krbarnes | 1.23 | IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection(); |
| 321 : | Object[] keys = selection.toArray(); | ||
| 322 : | for (int i = 0; i < keys.length; i++) { | ||
| 323 : | String key = (String) keys[i]; | ||
| 324 : | Map params = (Map) fViewer.getInput(); | ||
| 325 : | params.remove(key); | ||
| 326 : | } | ||
| 327 : | fViewer.refresh(); | ||
| 328 : | jszursze | 1.1 | setParametersButtonsEnableState(); |
| 329 : | jburns | 1.12 | updateLaunchConfigurationDialog(); |
| 330 : | jszursze | 1.1 | } |
| 331 : | |||
| 332 : | /** | ||
| 333 : | * Set the enabled state of the three environment variable-related buttons based on the | ||
| 334 : | * selection in the Table widget. | ||
| 335 : | */ | ||
| 336 : | private void setParametersButtonsEnableState() { | ||
| 337 : | krbarnes | 1.23 | IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection(); |
| 338 : | int selectCount = selection.size(); | ||
| 339 : | jszursze | 1.1 | if (selectCount < 1) { |
| 340 : | fParametersEditButton.setEnabled(false); | ||
| 341 : | fParametersRemoveButton.setEnabled(false); | ||
| 342 : | } else { | ||
| 343 : | fParametersRemoveButton.setEnabled(true); | ||
| 344 : | if (selectCount == 1) { | ||
| 345 : | fParametersEditButton.setEnabled(true); | ||
| 346 : | } else { | ||
| 347 : | fParametersEditButton.setEnabled(false); | ||
| 348 : | } | ||
| 349 : | } | ||
| 350 : | fParametersAddButton.setEnabled(true); | ||
| 351 : | } | ||
| 352 : | |||
| 353 : | /** | ||
| 354 : | * Show the specified dialog and update the parameter table based on its results. | ||
| 355 : | * | ||
| 356 : | * @param updateItem the item to update, or <code>null</code> if | ||
| 357 : | * adding a new item | ||
| 358 : | */ | ||
| 359 : | krbarnes | 1.23 | private void openNewParameterDialog(NameValuePairDialog dialog, String key) { |
| 360 : | jszursze | 1.1 | if (dialog.open() != Window.OK) { |
| 361 : | return; | ||
| 362 : | } | ||
| 363 : | String[] nameValuePair = dialog.getNameValuePair(); | ||
| 364 : | krbarnes | 1.23 | Map params = (Map) fViewer.getInput(); |
| 365 : | params.remove(key); | ||
| 366 : | params.put(nameValuePair[0], nameValuePair[1]); | ||
| 367 : | fViewer.refresh(); | ||
| 368 : | jszursze | 1.1 | updateLaunchConfigurationDialog(); |
| 369 : | } | ||
| 370 : | |||
| 371 : | /** | ||
| 372 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(ILaunchConfigurationWorkingCopy) |
| 373 : | jszursze | 1.1 | */ |
| 374 : | public void performApply(ILaunchConfigurationWorkingCopy configuration) { | ||
| 375 : | jburns | 1.15 | try { |
| 376 : | configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, Integer.parseInt(getWidthText())); | ||
| 377 : | } catch (NumberFormatException e) { | ||
| 378 : | } | ||
| 379 : | try { | ||
| 380 : | configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, Integer.parseInt(getHeightText())); | ||
| 381 : | } catch (NumberFormatException e) { | ||
| 382 : | } | ||
| 383 : | darins | 1.11 | configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, fNameText.getText()); |
| 384 : | krbarnes | 1.23 | configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_PARAMETERS, (Map) fViewer.getInput()); |
| 385 : | jburns | 1.15 | } |
| 386 : | krbarnes | 1.23 | |
| 387 : | jburns | 1.15 | /** |
| 388 : | * Returns the current width specified by the user | ||
| 389 : | * @return the width specified by the user | ||
| 390 : | */ | ||
| 391 : | private String getWidthText() { | ||
| 392 : | return fWidthText.getText().trim(); | ||
| 393 : | } | ||
| 394 : | |||
| 395 : | /** | ||
| 396 : | * Returns the current height specified by the user | ||
| 397 : | * @return the height specified by the user | ||
| 398 : | */ | ||
| 399 : | private String getHeightText() { | ||
| 400 : | return fHeightText.getText().trim(); | ||
| 401 : | jszursze | 1.1 | } |
| 402 : | |||
| 403 : | /** | ||
| 404 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(ILaunchConfigurationWorkingCopy) |
| 405 : | jszursze | 1.1 | */ |
| 406 : | public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { | ||
| 407 : | } | ||
| 408 : | |||
| 409 : | |||
| 410 : | /** | ||
| 411 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(ILaunchConfiguration) |
| 412 : | jszursze | 1.1 | */ |
| 413 : | public void initializeFrom(ILaunchConfiguration config) { | ||
| 414 : | try { | ||
| 415 : | darin | 1.21 | fWidthText.setText(Integer.toString(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_WIDTH, DEFAULT_APPLET_WIDTH))); |
| 416 : | jszursze | 1.1 | } catch(CoreException ce) { |
| 417 : | darin | 1.21 | fWidthText.setText(Integer.toString(DEFAULT_APPLET_WIDTH)); |
| 418 : | jszursze | 1.1 | } |
| 419 : | try { | ||
| 420 : | darin | 1.21 | fHeightText.setText(Integer.toString(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_HEIGHT, DEFAULT_APPLET_HEIGHT))); |
| 421 : | jszursze | 1.1 | } catch(CoreException ce) { |
| 422 : | darin | 1.21 | fHeightText.setText(Integer.toString(DEFAULT_APPLET_HEIGHT)); |
| 423 : | jszursze | 1.1 | } |
| 424 : | try { | ||
| 425 : | darin | 1.21 | fNameText.setText(config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_NAME, LauncherMessages.appletlauncher_argumenttab_name_defaultvalue)); |
| 426 : | jszursze | 1.1 | } catch(CoreException ce) { |
| 427 : | darin | 1.21 | fNameText.setText(LauncherMessages.appletlauncher_argumenttab_name_defaultvalue); |
| 428 : | jszursze | 1.1 | } |
| 429 : | krbarnes | 1.23 | |
| 430 : | Map input = new HashMap(); | ||
| 431 : | try { | ||
| 432 : | Map params = config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_APPLET_PARAMETERS, (Map) null); | ||
| 433 : | if (params != null) | ||
| 434 : | input.putAll(params); | ||
| 435 : | } catch (CoreException e) { | ||
| 436 : | } | ||
| 437 : | |||
| 438 : | fViewer.setInput(input); | ||
| 439 : | jszursze | 1.1 | } |
| 440 : | |||
| 441 : | /** | ||
| 442 : | * Create some empty space | ||
| 443 : | */ | ||
| 444 : | private void createVerticalSpacer(Composite comp) { | ||
| 445 : | new Label(comp, SWT.NONE); | ||
| 446 : | } | ||
| 447 : | |||
| 448 : | /** | ||
| 449 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() |
| 450 : | jszursze | 1.1 | */ |
| 451 : | public String getName() { | ||
| 452 : | darin | 1.21 | return LauncherMessages.appletlauncher_argumenttab_name; |
| 453 : | jszursze | 1.1 | } |
| 454 : | darins | 1.7 | |
| 455 : | jszursze | 1.1 | /** |
| 456 : | darins | 1.29 | * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#getId() |
| 457 : | mrennie | 1.26 | * |
| 458 : | * @since 3.3 | ||
| 459 : | mrennie | 1.25 | */ |
| 460 : | mrennie | 1.28 | public String getId() { |
| 461 : | mrennie | 1.25 | return "org.eclipse.jdt.debug.ui.appletParametersTab"; //$NON-NLS-1$ |
| 462 : | } | ||
| 463 : | |||
| 464 : | /** | ||
| 465 : | darin | 1.9 | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() |
| 466 : | jszursze | 1.1 | */ |
| 467 : | public Image getImage() { | ||
| 468 : | return JavaDebugImages.get(JavaDebugImages.IMG_VIEW_ARGUMENTS_TAB); | ||
| 469 : | } | ||
| 470 : | darin | 1.14 | |
| 471 : | /* (non-Javadoc) | ||
| 472 : | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) | ||
| 473 : | */ | ||
| 474 : | public void activated(ILaunchConfigurationWorkingCopy workingCopy) { | ||
| 475 : | // do nothing when activated | ||
| 476 : | } | ||
| 477 : | |||
| 478 : | /* (non-Javadoc) | ||
| 479 : | * @see org.eclipse.debug.ui.ILaunchConfigurationTab#deactivated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) | ||
| 480 : | */ | ||
| 481 : | public void deactivated(ILaunchConfigurationWorkingCopy workingCopy) { | ||
| 482 : | // do nothing when deactivated | ||
| 483 : | } | ||
| 484 : | jszursze | 1.1 | } |
| 485 : |
| help@eclipse.org | ViewVC Help |
| Powered by ViewVC 1.0.3 |
