2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
package org.netbeans.modules.debugger.jpda.ui.views;
44
import java.beans.PropertyChangeEvent;
45
import java.util.ArrayList;
46
import java.util.HashSet;
47
import java.util.Iterator;
48
import java.util.List;
50
import javax.swing.JComponent;
52
import org.netbeans.api.debugger.DebuggerEngine;
53
import org.netbeans.api.debugger.DebuggerManager;
54
import org.netbeans.api.debugger.DebuggerManagerAdapter;
55
import org.netbeans.spi.viewmodel.Model;
56
import org.netbeans.spi.viewmodel.Models;
57
import org.netbeans.spi.viewmodel.ColumnModel;
58
import org.netbeans.spi.viewmodel.TableModelFilter;
59
import org.netbeans.spi.viewmodel.NodeActionsProvider;
60
import org.netbeans.spi.viewmodel.NodeActionsProviderFilter;
61
import org.netbeans.spi.viewmodel.NodeModel;
62
import org.netbeans.spi.viewmodel.NodeModelFilter;
63
import org.netbeans.spi.viewmodel.TableModel;
64
import org.netbeans.spi.viewmodel.TreeExpansionModel;
65
import org.netbeans.spi.viewmodel.TreeModel;
66
import org.netbeans.spi.viewmodel.TreeModelFilter;
67
import org.netbeans.spi.viewmodel.ModelListener;
68
import org.netbeans.spi.viewmodel.UnknownTypeException;
72
* This delegating CompoundModelImpl loads all models from DebuggerManager.
73
* getDefault ().getCurrentEngine ().lookup (viewType, ..) lookup.
76
* This class is identical to org.netbeans.modules.debugger.ui.views.ViewModelListener.
80
class ViewModelListener extends DebuggerManagerAdapter {
82
private static boolean verbose =
83
System.getProperty ("netbeans.debugger.models") != null;
85
private String viewType;
86
private JComponent view;
87
private List models = new ArrayList(11);
94
this.viewType = viewType;
100
DebuggerManager.getDebuggerManager ().addDebuggerListener (
101
DebuggerManager.PROP_CURRENT_ENGINE,
108
DebuggerManager.getDebuggerManager ().removeDebuggerListener (
109
DebuggerManager.PROP_CURRENT_ENGINE,
112
Models.setModelsToView (
118
public void propertyChange (PropertyChangeEvent e) {
122
private List joinLookups(DebuggerEngine e, DebuggerManager dm, Class service) {
123
List es = e.lookup (viewType, service);
124
List ms = dm.lookup(viewType, service);
130
private synchronized void updateModel () {
131
DebuggerManager dm = DebuggerManager.getDebuggerManager ();
132
DebuggerEngine e = dm.getCurrentEngine ();
135
List treeModelFilters;
136
List treeExpansionModels;
138
List nodeModelFilters;
140
List tableModelFilters;
141
List nodeActionsProviders;
142
List nodeActionsProviderFilters;
146
treeModels = joinLookups(e, dm, TreeModel.class);
147
treeModelFilters = joinLookups(e, dm, TreeModelFilter.class);
148
treeExpansionModels = joinLookups(e, dm, TreeExpansionModel.class);
149
nodeModels = joinLookups(e, dm, NodeModel.class);
150
nodeModelFilters = joinLookups(e, dm, NodeModelFilter.class);
151
tableModels = joinLookups(e, dm, TableModel.class);
152
tableModelFilters = joinLookups(e, dm, TableModelFilter.class);
153
nodeActionsProviders = joinLookups(e, dm, NodeActionsProvider.class);
154
nodeActionsProviderFilters = joinLookups(e, dm, NodeActionsProviderFilter.class);
155
columnModels = joinLookups(e, dm, ColumnModel.class);
156
mm = joinLookups(e, dm, Model.class);
158
treeModels = dm.lookup (viewType, TreeModel.class);
159
treeModelFilters = dm.lookup (viewType, TreeModelFilter.class);
160
treeExpansionModels = dm.lookup (viewType, TreeExpansionModel.class);
161
nodeModels = dm.lookup (viewType, NodeModel.class);
162
nodeModelFilters = dm.lookup (viewType, NodeModelFilter.class);
163
tableModels = dm.lookup (viewType, TableModel.class);
164
tableModelFilters = dm.lookup (viewType, TableModelFilter.class);
165
nodeActionsProviders = dm.lookup (viewType, NodeActionsProvider.class);
166
nodeActionsProviderFilters = dm.lookup (viewType, NodeActionsProviderFilter.class);
167
columnModels = dm.lookup (viewType, ColumnModel.class);
168
mm = dm.lookup (viewType, Model.class);
172
models.add(treeModels);
173
models.add(treeModelFilters);
174
models.add(treeExpansionModels);
175
models.add(nodeModels);
176
models.add(nodeModelFilters);
177
models.add(tableModels);
178
models.add(tableModelFilters);
179
models.add(nodeActionsProviders);
180
models.add(nodeActionsProviderFilters);
181
models.add(columnModels);
184
Models.setModelsToView (
186
Models.createCompoundModel (models)
191
// innerclasses ............................................................
193
private static class EmptyModel implements NodeModel {
195
public String getDisplayName (Object node) throws UnknownTypeException {
196
if (node == TreeModel.ROOT) {
197
return "Name"; // TODO: Localized ???
199
throw new UnknownTypeException (node);
202
public String getIconBase (Object node) throws UnknownTypeException {
203
if (node == TreeModel.ROOT) {
204
return "org/netbeans/modules/debugger/resources/DebuggerTab";
206
throw new UnknownTypeException (node);
209
public String getShortDescription (Object node)
210
throws UnknownTypeException {
211
throw new UnknownTypeException (node);
214
public void addModelListener (ModelListener l) {}
215
public void removeModelListener (ModelListener l) {}