KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > propertypages > JavaExceptionBreakpointPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.jdt.internal.debug.ui.propertypages;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.jdt.debug.core.IJavaExceptionBreakpoint;
15 import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
16 import org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint;
17 import org.eclipse.jdt.internal.debug.ui.IJavaDebugHelpContextIds;
18 import org.eclipse.swt.events.SelectionAdapter;
19 import org.eclipse.swt.events.SelectionEvent;
20 import org.eclipse.swt.widgets.Button;
21 import org.eclipse.swt.widgets.Composite;
22 import org.eclipse.ui.PlatformUI;
23
24 /**
25  * Implements the property page for a Java exception breakpoint
26  */

27 public class JavaExceptionBreakpointPage extends JavaBreakpointPage {
28
29     //widgets
30
private Button fCaughtButton;
31     private Button fUncaughtButton;
32     private Button fSuspendOnSubclasses;
33     
34     private static final String JavaDoc fgExceptionBreakpointError= PropertyPageMessages.JavaExceptionBreakpointPage_2;
35     /**
36      * @see org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#doStore()
37      */

38     protected void doStore() throws CoreException {
39         super.doStore();
40         IJavaExceptionBreakpoint breakpoint= (IJavaExceptionBreakpoint) getBreakpoint();
41         boolean caught= fCaughtButton.getSelection();
42         if (caught != breakpoint.isCaught()) {
43             breakpoint.setCaught(caught);
44         }
45         boolean uncaught= fUncaughtButton.getSelection();
46         if (uncaught != breakpoint.isUncaught()) {
47             breakpoint.setUncaught(uncaught);
48         }
49         // TODO remove cast once the API freeze is over and the method has been added to IJavaExceptionBreakpoint
50
boolean suspend = fSuspendOnSubclasses.getSelection();
51         if(suspend != ((JavaExceptionBreakpoint)breakpoint).isSuspendOnSubclasses()) {
52             ((JavaExceptionBreakpoint)breakpoint).setSuspendOnSubclasses(suspend);
53         }
54     }
55
56     /**
57      * @see org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#createTypeSpecificEditors(org.eclipse.swt.widgets.Composite)
58      */

59     protected void createTypeSpecificEditors(Composite parent) {
60         setTitle(PropertyPageMessages.JavaExceptionBreakpointPage_5);
61         IJavaExceptionBreakpoint breakpoint= (IJavaExceptionBreakpoint) getBreakpoint();
62         SelectionAdapter exceptionBreakpointValidator= new SelectionAdapter() {
63             public void widgetSelected(SelectionEvent e) {
64                 validateExceptionBreakpoint();
65             }
66         };
67         createLabel(parent, PropertyPageMessages.JavaExceptionBreakpointPage_3);
68         fEnabledButton.addSelectionListener(exceptionBreakpointValidator);
69         fCaughtButton= createCheckButton(parent, PropertyPageMessages.JavaExceptionBreakpointPage_0);
70         try {
71             fCaughtButton.setSelection(breakpoint.isCaught());
72         } catch (CoreException e) {
73             JDIDebugPlugin.log(e);
74         }
75         fCaughtButton.addSelectionListener(exceptionBreakpointValidator);
76         fUncaughtButton= createCheckButton(parent, PropertyPageMessages.JavaExceptionBreakpointPage_1);
77         try {
78             fUncaughtButton.setSelection(breakpoint.isUncaught());
79         } catch (CoreException e) {
80             JDIDebugPlugin.log(e);
81         }
82         fUncaughtButton.addSelectionListener(exceptionBreakpointValidator);
83         fSuspendOnSubclasses = createCheckButton(parent, PropertyPageMessages.JavaExceptionBreakpointPage_4);
84         try {
85             // TODO add back the API for isSuspendOnSubclasses and setSuspendOnSubclasses in IJavaExceptionBreakpoint, and remove the cast below
86
fSuspendOnSubclasses.setSelection(((JavaExceptionBreakpoint)breakpoint).isSuspendOnSubclasses());
87         }
88         catch (CoreException ce) {JDIDebugPlugin.log(ce);}
89     }
90
91     /**
92      * validates the exception breakpoint
93      */

94     private void validateExceptionBreakpoint() {
95         if (fEnabledButton.getSelection() && !(fCaughtButton.getSelection() || fUncaughtButton.getSelection())) {
96             addErrorMessage(fgExceptionBreakpointError);
97         } else {
98             removeErrorMessage(fgExceptionBreakpointError);
99         }
100     }
101     
102     /* (non-Javadoc)
103      * @see org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#createControl(org.eclipse.swt.widgets.Composite)
104      */

105     public void createControl(Composite parent) {
106         super.createControl(parent);
107         PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), IJavaDebugHelpContextIds.JAVA_EXCEPTION_BREAKPOINT_PROPERTY_PAGE);
108     }
109 }
110
Popular Tags