KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > actions > breakpoints > DeleteWorkingsetsMessageDialog


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.actions.breakpoints;
12
13 import org.eclipse.debug.internal.ui.DebugUIPlugin;
14 import org.eclipse.debug.internal.ui.actions.ActionMessages;
15 import org.eclipse.jface.dialogs.IDialogSettings;
16 import org.eclipse.jface.dialogs.MessageDialog;
17 import org.eclipse.swt.SWT;
18 import org.eclipse.swt.events.SelectionEvent;
19 import org.eclipse.swt.events.SelectionListener;
20 import org.eclipse.swt.graphics.Font;
21 import org.eclipse.swt.graphics.Image;
22 import org.eclipse.swt.layout.GridLayout;
23 import org.eclipse.swt.widgets.Button;
24 import org.eclipse.swt.widgets.Composite;
25 import org.eclipse.swt.widgets.Control;
26 import org.eclipse.swt.widgets.Shell;
27
28 /**
29  * Allows the user to specify if they want to delete the working set, all the breakpoints in the working
30  * set or both
31  * @since 3.2
32  */

33 public class DeleteWorkingsetsMessageDialog extends MessageDialog {
34
35     /**
36      * to determine if we should delete the working set as well
37      */

38     private boolean fDeleteWorkingsets = false;
39     
40     /**
41      * to determine if we should delete all the breakpoints in the set.
42      * to maintain backward compatibility this is by default true
43      */

44     private boolean fDeleteBreakpoints = true;
45     
46     //widgets
47
private Button fDeleteWS;
48     private Button fDeleteBPS;
49     
50     // dialog settings
51
private final static String JavaDoc DIALOG_SETTINGS = "DeleteBreakpointsDialogSettings"; //$NON-NLS-1$
52
private static final String JavaDoc DELETE_BREAKPOINTS = "DeleteBreakpoints"; //$NON-NLS-1$
53
private static final String JavaDoc DELETE_WORKINGSETS = "DeleteWorkingSets"; //$NON-NLS-1$
54

55     public DeleteWorkingsetsMessageDialog(Shell parentShell, String JavaDoc dialogTitle, Image dialogTitleImage, String JavaDoc dialogMessage, int dialogImageType, String JavaDoc[] dialogButtonLabels, int defaultIndex) {
56         super(parentShell, dialogTitle, dialogTitleImage, dialogMessage, dialogImageType, dialogButtonLabels, defaultIndex);
57         IDialogSettings section = getDialogSettings();
58         fDeleteBreakpoints = section.getBoolean(DELETE_BREAKPOINTS);
59         fDeleteWorkingsets = section.getBoolean(DELETE_WORKINGSETS);
60     }
61     
62     /* (non-Javadoc)
63      * @see org.eclipse.jface.dialogs.MessageDialog#createCustomArea(org.eclipse.swt.widgets.Composite)
64      */

65     protected Control createCustomArea(Composite parent) {
66         Composite comp = new Composite(parent, SWT.NONE);
67         comp.setLayout(new GridLayout());
68         Font font = parent.getFont();
69         fDeleteWS = new Button(comp, SWT.CHECK);
70         fDeleteWS.setText(ActionMessages.DeleteWorkingsetsMessageDialog_0);
71         fDeleteWS.setFont(font);
72         fDeleteWS.addSelectionListener(new SelectionListener() {
73             public void widgetDefaultSelected(SelectionEvent e) {}
74             public void widgetSelected(SelectionEvent e) {
75                 getButton(0).setEnabled(fDeleteWS.getSelection() || fDeleteBPS.getSelection());
76             }
77         });
78         
79         fDeleteBPS = new Button(comp, SWT.CHECK);
80         fDeleteBPS.setText(ActionMessages.DeleteWorkingsetsMessageDialog_1);
81         fDeleteBPS.setFont(font);
82         fDeleteBPS.addSelectionListener(new SelectionListener() {
83             public void widgetDefaultSelected(SelectionEvent e) {}
84             public void widgetSelected(SelectionEvent e) {
85                 getButton(0).setEnabled(fDeleteWS.getSelection() || fDeleteBPS.getSelection());
86             }
87         });
88         
89         fDeleteWS.setSelection(fDeleteWorkingsets);
90         fDeleteBPS.setSelection(fDeleteBreakpoints);
91         return comp;
92     }
93     
94     /* (non-Javadoc)
95      * @see org.eclipse.jface.dialogs.MessageDialog#buttonPressed(int)
96      */

97     protected void buttonPressed(int buttonId) {
98         if(buttonId == OK) {
99             fDeleteBreakpoints = fDeleteBPS.getSelection();
100             fDeleteWorkingsets = fDeleteWS.getSelection();
101             IDialogSettings dialogSettings = getDialogSettings();
102             dialogSettings.put(DELETE_BREAKPOINTS, fDeleteBreakpoints);
103             dialogSettings.put(DELETE_WORKINGSETS, fDeleteWorkingsets);
104         }
105         super.buttonPressed(buttonId);
106     }
107
108     /**
109      * return the checked value of the delete working set check box
110      * @return the checked state of the delete working set check box
111      */

112     public boolean deleteWorkingset() {
113         return fDeleteWorkingsets;
114     }
115     
116     /**
117      * returns the checked state of the delete all breakpoints in working set check box
118      * @return the checked state of the delete all breakpoints... check box
119      */

120     public boolean deleteAllBreakpoints() {
121         return fDeleteBreakpoints;
122     }
123
124     /**
125      * Returns the dialog settings for this dialog.
126      *
127      * @return dialog settings
128      */

129     protected IDialogSettings getDialogSettings() {
130         DebugUIPlugin plugin = DebugUIPlugin.getDefault();
131         IDialogSettings workbenchSettings = plugin.getDialogSettings();
132         IDialogSettings section = workbenchSettings.getSection(DIALOG_SETTINGS);
133         if (section == null) {
134             section = workbenchSettings.addNewSection(DIALOG_SETTINGS);
135             section.put(DELETE_BREAKPOINTS, true);
136             section.put(DELETE_WORKINGSETS, false);
137         }
138         return section;
139     }
140     
141     
142     
143 }
144
Popular Tags