1 11 package org.eclipse.debug.internal.ui.launchConfigurations; 12 13 14 import java.util.Set ; 15 16 import org.eclipse.core.runtime.CoreException; 17 import org.eclipse.core.runtime.IStatus; 18 import org.eclipse.debug.core.DebugPlugin; 19 import org.eclipse.debug.core.ILaunchConfiguration; 20 import org.eclipse.debug.core.ILaunchConfigurationListener; 21 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; 22 import org.eclipse.debug.core.ILaunchManager; 23 import org.eclipse.debug.internal.ui.DebugUIPlugin; 24 import org.eclipse.debug.internal.ui.IDebugHelpContextIds; 25 import org.eclipse.debug.ui.IDebugUIConstants; 26 import org.eclipse.debug.ui.ILaunchConfigurationDialog; 27 import org.eclipse.debug.ui.ILaunchConfigurationTab; 28 import org.eclipse.debug.ui.ILaunchConfigurationTabGroup; 29 import org.eclipse.jface.dialogs.IDialogConstants; 30 import org.eclipse.swt.SWT; 31 import org.eclipse.swt.layout.GridData; 32 import org.eclipse.swt.layout.GridLayout; 33 import org.eclipse.swt.widgets.Composite; 34 import org.eclipse.swt.widgets.Shell; 35 36 import com.ibm.icu.text.MessageFormat; 37 38 39 42 public class LaunchConfigurationPropertiesDialog extends LaunchConfigurationsDialog implements ILaunchConfigurationListener { 43 44 47 private ILaunchConfiguration fLaunchConfiguration; 48 49 53 private boolean fSetDefaultOnOpen = false; 54 55 64 public LaunchConfigurationPropertiesDialog(Shell shell, ILaunchConfiguration launchConfiguration, LaunchGroupExtension group) { 65 super(shell, group); 66 fLaunchConfiguration = launchConfiguration; 67 DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this); 68 } 69 70 81 public LaunchConfigurationPropertiesDialog(Shell shell, ILaunchConfiguration launchConfiguration, LaunchGroupExtension group, Set reservednames) { 82 super(shell, group); 83 fLaunchConfiguration = launchConfiguration; 84 DebugPlugin.getDefault().getLaunchManager().addLaunchConfigurationListener(this); 85 fReservedNames = reservednames; 86 } 87 88 93 protected ILaunchConfiguration getLaunchConfiguration() { 94 return fLaunchConfiguration; 95 } 96 97 100 protected void initializeBounds() { 101 super.initializeBounds(); 102 resize(); 103 } 104 105 108 protected void initializeContent() { 109 ILaunchConfiguration launchConfiguration = getLaunchConfiguration(); 110 if (fSetDefaultOnOpen && launchConfiguration instanceof ILaunchConfigurationWorkingCopy) { 111 ILaunchConfigurationWorkingCopy wc = (ILaunchConfigurationWorkingCopy) launchConfiguration; 112 try { 113 ILaunchConfigurationTabGroup tabGroup = LaunchConfigurationPresentationManager.getDefault().getTabGroup(wc, getMode()); 114 ILaunchConfigurationDialog dialog = LaunchConfigurationsDialog.getCurrentlyVisibleLaunchConfigurationDialog(); 116 tabGroup.createTabs(dialog, dialog.getMode()); 117 ILaunchConfigurationTab[] tabs = tabGroup.getTabs(); 118 for (int i = 0; i < tabs.length; i++) { 119 tabs[i].setLaunchConfigurationDialog(dialog); 120 } 121 tabGroup.setDefaults(wc); 122 tabGroup.dispose(); 123 } catch (CoreException e) { 124 DebugUIPlugin.log(e.getStatus()); 125 } 126 } 127 getTabViewer().setInput(launchConfiguration); 128 IStatus status = getInitialStatus(); 129 if (status != null) { 130 handleStatus(status); 131 } 132 } 133 134 137 public boolean close() { 138 if (!isSafeToClose()) { 139 return false; 140 } 141 getBannerImage().dispose(); 142 getTabViewer().dispose(); 143 DebugPlugin.getDefault().getLaunchManager().removeLaunchConfigurationListener(this); 144 return super.close(); 145 } 146 147 150 protected void addContent(Composite dialogComp) { 151 GridData gd; 152 Composite topComp = new Composite(dialogComp, SWT.NONE); 153 gd = new GridData(GridData.FILL_BOTH); 154 topComp.setLayoutData(gd); 155 GridLayout topLayout = new GridLayout(); 156 topLayout.numColumns = 1; 157 topLayout.marginHeight = 5; 158 topLayout.marginWidth = 5; 159 topComp.setLayout(topLayout); 160 topComp.setFont(dialogComp.getFont()); 161 162 setTitle(getTitleAreaTitle()); 164 setMessage(""); setModeLabelState(); 166 167 Composite editAreaComp = createLaunchConfigurationEditArea(topComp); 169 gd = new GridData(GridData.FILL_BOTH); 170 editAreaComp.setLayoutData(gd); 171 editAreaComp.setFont(dialogComp.getFont()); 172 173 dialogComp.layout(true); 174 applyDialogFont(dialogComp); 175 } 176 177 181 protected String getTitleAreaTitle() { 182 return LaunchConfigurationsMessages.LaunchConfigurationPropertiesDialog_Edit_launch_configuration_properties_1; 183 } 184 185 188 protected void createButtonsForButtonBar(Composite parent) { 189 createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); 191 createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); 192 } 193 194 197 protected String getShellTitle() { 198 return MessageFormat.format(LaunchConfigurationsMessages.LaunchConfigurationPropertiesDialog_Properties_for__0__2, new String []{getLaunchConfiguration().getName()}); 199 } 200 201 204 protected String getHelpContextId() { 205 return IDebugHelpContextIds.LAUNCH_CONFIGURATION_PROPERTIES_DIALOG; 206 } 207 208 211 public void updateButtons() { 212 getTabViewer().refresh(); 213 getButton(IDialogConstants.OK_ID).setEnabled(getTabViewer().canSave()); 214 215 } 216 217 220 protected void okPressed() { 221 getTabViewer().handleApplyPressed(); 222 super.okPressed(); 223 } 224 225 228 public int open() { 229 setOpenMode(-1); 230 return super.open(); 231 } 232 233 236 protected String getDialogSettingsSectionName() { 237 return IDebugUIConstants.PLUGIN_ID + ".LAUNCH_CONFIGURATION_PROPERTIES_DIALOG_SECTION"; } 239 240 243 public void launchConfigurationAdded(ILaunchConfiguration configuration) { 244 ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); 245 if (getLaunchConfiguration().equals(manager.getMovedFrom(configuration))) { 246 fLaunchConfiguration = configuration; 248 getTabViewer().setInput(getLaunchConfiguration()); 249 } 250 } 251 252 255 public void launchConfigurationChanged(ILaunchConfiguration configuration) {} 256 257 260 public void launchConfigurationRemoved(ILaunchConfiguration configuration) {} 261 262 269 public void setDefaultsOnOpen(boolean setDefaults) { 270 fSetDefaultOnOpen = setDefaults; 271 } 272 273 } 274 | Popular Tags |