KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > ui > AbstractBreakpointOrganizerDelegate


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.ui;
12
13 import org.eclipse.core.runtime.IAdaptable;
14 import org.eclipse.core.runtime.ISafeRunnable;
15 import org.eclipse.core.runtime.ListenerList;
16 import org.eclipse.core.runtime.SafeRunner;
17 import org.eclipse.debug.core.model.IBreakpoint;
18 import org.eclipse.debug.internal.ui.DebugUIPlugin;
19 import org.eclipse.debug.internal.ui.views.breakpoints.OtherBreakpointCategory;
20 import org.eclipse.jface.util.IPropertyChangeListener;
21 import org.eclipse.jface.util.PropertyChangeEvent;
22
23 /**
24  * Common function for breakpoint organizer delegates.
25  * <p>
26  * Clients implementing <code>IBreakpointOrganizerDelegate</code> must subclass this class.
27  * </p>
28  * @since 3.1
29  */

30 public abstract class AbstractBreakpointOrganizerDelegate implements IBreakpointOrganizerDelegate {
31     
32     // property change listeners
33
private ListenerList fListeners = new ListenerList();
34
35     /* (non-Javadoc)
36      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#addBreakpoint(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
37      */

38     public void addBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
39         // do noting, not supported by default
40
}
41     
42     /* (non-Javadoc)
43      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
44      */

45     public void addPropertyChangeListener(IPropertyChangeListener listener) {
46         fListeners.add(listener);
47     }
48     
49     /* (non-Javadoc)
50      *
51      * Subclasses that override should return super.canAdd(...) when they are not able to add
52      * the breakpoint.
53      *
54      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canAdd(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
55      */

56     public boolean canAdd(IBreakpoint breakpoint, IAdaptable category) {
57         return category instanceof OtherBreakpointCategory;
58     }
59     
60     /* (non-Javadoc)
61      *
62      * Subclasses that override should return super.canRemove(...) when they are not able to remove
63      * the breakpoint.
64      *
65      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#canRemove(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
66      */

67     public boolean canRemove(IBreakpoint breakpoint, IAdaptable category) {
68         return category instanceof OtherBreakpointCategory;
69     }
70     
71     /* (non-Javadoc)
72      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#dispose()
73      */

74     public void dispose() {
75         fListeners = new ListenerList();
76     }
77     
78     /* (non-Javadoc)
79      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#removeBreakpoint(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.runtime.IAdaptable)
80      */

81     public void removeBreakpoint(IBreakpoint breakpoint, IAdaptable category) {
82         // do nothing, not supported by default
83
}
84     
85     /* (non-Javadoc)
86      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
87      */

88     public void removePropertyChangeListener(IPropertyChangeListener listener) {
89         fListeners.remove(listener);
90     }
91     
92     /**
93      * Fires a property change notification for the given category.
94      *
95      * @param category category that has changed
96      */

97     protected void fireCategoryChanged(IAdaptable category) {
98         if (fListeners.isEmpty()) {
99             return;
100         }
101         final PropertyChangeEvent event = new PropertyChangeEvent(this, P_CATEGORY_CHANGED, category, null);
102         Object JavaDoc[] listeners = fListeners.getListeners();
103         for (int i = 0; i < listeners.length; i++) {
104             final IPropertyChangeListener listener = (IPropertyChangeListener) listeners[i];
105             ISafeRunnable runnable = new ISafeRunnable() {
106                 public void handleException(Throwable JavaDoc exception) {
107                     DebugUIPlugin.log(exception);
108                 }
109                 public void run() throws Exception JavaDoc {
110                     listener.propertyChange(event);
111                 }
112             };
113             SafeRunner.run(runnable);
114         }
115     }
116     
117     /* (non-Javadoc)
118      * @see org.eclipse.debug.ui.IBreakpointOrganizerDelegate#getCategories()
119      */

120     public IAdaptable[] getCategories() {
121         return null;
122     }
123 }
124
Popular Tags