1 11 package org.eclipse.jdt.internal.debug.ui.launcher; 12 13 14 import org.eclipse.core.runtime.CoreException; 15 import org.eclipse.debug.core.ILaunchConfiguration; 16 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 17 import org.eclipse.debug.ui.StringVariableSelectionDialog; 18 import org.eclipse.jdt.debug.ui.launchConfigurations.JavaLaunchTab; 19 import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin; 20 import org.eclipse.jdt.internal.debug.ui.actions.ControlAccessibleListener; 21 import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; 22 import org.eclipse.swt.SWT; 23 import org.eclipse.swt.events.ModifyEvent; 24 import org.eclipse.swt.events.ModifyListener; 25 import org.eclipse.swt.events.SelectionEvent; 26 import org.eclipse.swt.events.SelectionListener; 27 import org.eclipse.swt.graphics.Font; 28 import org.eclipse.swt.layout.GridData; 29 import org.eclipse.swt.layout.GridLayout; 30 import org.eclipse.swt.widgets.Button; 31 import org.eclipse.swt.widgets.Composite; 32 import org.eclipse.swt.widgets.Group; 33 import org.eclipse.swt.widgets.Text; 34 35 38 public class VMArgumentsBlock extends JavaLaunchTab { 39 40 protected Text fVMArgumentsText; 42 private Button fPgrmArgVariableButton; 43 44 47 public void createControl(Composite parent) { 48 Font font = parent.getFont(); 49 50 Group group = new Group(parent, SWT.NONE); 51 setControl(group); 52 GridLayout topLayout = new GridLayout(); 53 group.setLayout(topLayout); 54 GridData gd = new GridData(GridData.FILL_BOTH); 55 group.setLayoutData(gd); 56 group.setFont(font); 57 group.setText(LauncherMessages.JavaArgumentsTab_VM_ar_guments__6); 58 59 fVMArgumentsText = new Text(group, SWT.MULTI | SWT.WRAP| SWT.BORDER | SWT.V_SCROLL); 60 gd = new GridData(GridData.FILL_BOTH); 61 gd.heightHint = 40; 62 gd.widthHint = 100; 63 fVMArgumentsText.setLayoutData(gd); 64 fVMArgumentsText.setFont(font); 65 fVMArgumentsText.addModifyListener(new ModifyListener() { 66 public void modifyText(ModifyEvent evt) { 67 updateLaunchConfigurationDialog(); 68 } 69 }); 70 ControlAccessibleListener.addListener(fVMArgumentsText, group.getText()); 71 72 fPgrmArgVariableButton = createPushButton(group, LauncherMessages.VMArgumentsBlock_4, null); 73 fPgrmArgVariableButton.setFont(font); 74 fPgrmArgVariableButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); 75 fPgrmArgVariableButton.addSelectionListener(new SelectionListener() { 76 public void widgetSelected(SelectionEvent e) { 77 StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); 78 dialog.open(); 79 String variable = dialog.getVariableExpression(); 80 if (variable != null) { 81 fVMArgumentsText.insert(variable); 82 } 83 } 84 public void widgetDefaultSelected(SelectionEvent e) { 85 } 86 87 }); 88 } 89 90 93 public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { 94 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, (String )null); 95 } 96 97 100 public void initializeFrom(ILaunchConfiguration configuration) { 101 try { 102 fVMArgumentsText.setText(configuration.getAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, "")); } catch (CoreException e) { 104 setErrorMessage(LauncherMessages.JavaArgumentsTab_Exception_occurred_reading_configuration___15 + e.getStatus().getMessage()); 105 JDIDebugUIPlugin.log(e); 106 } 107 } 108 109 112 public void performApply(ILaunchConfigurationWorkingCopy configuration) { 113 configuration.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, getAttributeValueFrom(fVMArgumentsText)); 114 } 115 116 119 public String getName() { 120 return LauncherMessages.VMArgumentsBlock_VM_Arguments; 121 } 122 123 128 protected String getAttributeValueFrom(Text text) { 129 String content = text.getText().trim(); 130 if (content.length() > 0) { 131 return content; 132 } 133 return null; 134 } 135 136 public void setEnabled(boolean enabled) { 137 fVMArgumentsText.setEnabled(enabled); 138 fPgrmArgVariableButton.setEnabled(enabled); 139 } 140 } 141 | Popular Tags |