KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > launchConfigurations > LaunchConfigurationEditDialog


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.ui.launchConfigurations;
12
13 import org.eclipse.debug.core.ILaunchConfiguration;
14 import org.eclipse.debug.ui.IDebugUIConstants;
15 import org.eclipse.jface.dialogs.IDialogConstants;
16 import org.eclipse.swt.widgets.Composite;
17 import org.eclipse.swt.widgets.Shell;
18
19 /**
20  * This class is used to construct a launch configuration dialog used to edit a launch configuration and continue or cancel (optional),
21  * not allowing a launch to occur.
22  *
23  * @since 3.3
24  */

25 public class LaunchConfigurationEditDialog extends LaunchConfigurationDialog {
26
27     private boolean fShowCancel = false;
28     
29     /**
30      * Constructor
31      * @param shell the shell to create this dialog on
32      * @param launchConfiguration the launch config that this dialog is allowing you to edit
33      * @param group the launch group associated with the showing tab group
34      * @param showcancel if the cancel button should be shown or not
35      */

36     public LaunchConfigurationEditDialog(Shell shell, ILaunchConfiguration launchConfiguration, LaunchGroupExtension group, boolean showcancel) {
37         super(shell, launchConfiguration, group);
38         fShowCancel = showcancel;
39     }
40
41     /* (non-Javadoc)
42      * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog#getTitleAreaTitle()
43      */

44     protected String JavaDoc getTitleAreaTitle() {
45         return LaunchConfigurationsMessages.LaunchConfigurationEditDialog_0;
46     }
47     
48     /* (non-Javadoc)
49      * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
50      */

51     protected void createButtonsForButtonBar(Composite parent) {
52         createButton(parent, ID_LAUNCH_BUTTON, LaunchConfigurationsMessages.LaunchConfigurationEditDialog_1, true);
53         if(fShowCancel) {
54             createButton(parent, ID_CANCEL_BUTTON, IDialogConstants.CANCEL_LABEL, false);
55         }
56     }
57     
58     /* (non-Javadoc)
59      * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog#updateButtons()
60      */

61     public void updateButtons() {
62         getTabViewer().refresh();
63         getButton(ID_LAUNCH_BUTTON).setEnabled(getTabViewer().canLaunch() & getTabViewer().canLaunchWithModes() & !getTabViewer().hasDuplicateDelegates());
64     }
65     
66     /* (non-Javadoc)
67      * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationPropertiesDialog#getDialogSettingsSectionName()
68      */

69     protected String JavaDoc getDialogSettingsSectionName() {
70         return IDebugUIConstants.PLUGIN_ID + ".LAUNCH_CONFIGURATION_EDIT_DIALOG_SECTION"; //$NON-NLS-1$
71
}
72
73     /**
74      * @see org.eclipse.debug.internal.ui.launchConfigurations.LaunchConfigurationsDialog#buttonPressed(int)
75      */

76     protected void buttonPressed(int buttonId) {
77         if(buttonId == ID_LAUNCH_BUTTON) {
78             setReturnCode(IDialogConstants.OK_ID);
79             int status = shouldSaveCurrentConfig();
80             if(status != IDialogConstants.CANCEL_ID) {
81                 if(status != ID_DISCARD_BUTTON) {
82                     if(status == IDialogConstants.YES_ID) {
83                         getTabViewer().handleApplyPressed();
84                     }
85                 }
86             }
87         }
88         else if(buttonId == ID_CANCEL_BUTTON) {
89             setReturnCode(IDialogConstants.CANCEL_ID);
90         }
91         close();
92     }
93 }
94
Popular Tags