001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.debugger.ui.models;
043:
044: import java.awt.datatransfer.Transferable;
045: import java.io.IOException;
046: import java.util.Vector;
047:
048: import org.netbeans.api.debugger.Watch;
049: import org.netbeans.spi.viewmodel.ExtendedNodeModel;
050: import org.netbeans.spi.viewmodel.TreeModel;
051: import org.netbeans.spi.viewmodel.ModelListener;
052: import org.netbeans.spi.viewmodel.UnknownTypeException;
053:
054: import org.openide.util.NbBundle;
055: import org.openide.util.datatransfer.PasteType;
056:
057: /**
058: * @author Jan Jancura
059: */
060: public class WatchesNodeModel implements ExtendedNodeModel {
061:
062: public static final String WATCH = "org/netbeans/modules/debugger/resources/watchesView/watch_16.png";
063:
064: private Vector listeners = new Vector();
065:
066: public String getDisplayName(Object o) throws UnknownTypeException {
067: if (o == TreeModel.ROOT)
068: return NbBundle.getBundle(WatchesNodeModel.class)
069: .getString("CTL_WatchesModel_Column_Name_Name");
070: if (o instanceof Watch)
071: return ((Watch) o).getExpression();
072: throw new UnknownTypeException(o);
073: }
074:
075: public String getShortDescription(Object o)
076: throws UnknownTypeException {
077: if (o == TreeModel.ROOT)
078: return TreeModel.ROOT;
079: if (o instanceof Watch) {
080: Watch w = (Watch) o;
081: return w.getExpression()
082: + NbBundle
083: .getBundle(WatchesNodeModel.class)
084: .getString(
085: "CTL_WatchesModel_Column_NameNoContext_Desc");
086: }
087: throw new UnknownTypeException(o);
088: }
089:
090: public String getIconBase(Object o) throws UnknownTypeException {
091: throw new UnsupportedOperationException("Not supported.");
092: }
093:
094: public String getIconBaseWithExtension(Object node)
095: throws UnknownTypeException {
096: if (node == TreeModel.ROOT)
097: return WATCH;
098: if (node instanceof Watch)
099: return WATCH;
100: throw new UnknownTypeException(node);
101: }
102:
103: /**
104: *
105: * @param l the listener to add
106: */
107: public void addModelListener(ModelListener l) {
108: listeners.add(l);
109: }
110:
111: /**
112: *
113: * @param l the listener to remove
114: */
115: public void removeModelListener(ModelListener l) {
116: listeners.remove(l);
117: }
118:
119: public boolean canRename(Object node) throws UnknownTypeException {
120: return false;
121: }
122:
123: public boolean canCopy(Object node) throws UnknownTypeException {
124: return false;
125: }
126:
127: public boolean canCut(Object node) throws UnknownTypeException {
128: return false;
129: }
130:
131: public Transferable clipboardCopy(Object node) throws IOException,
132: UnknownTypeException {
133: throw new UnsupportedOperationException("Not supported yet.");
134: }
135:
136: public Transferable clipboardCut(Object node) throws IOException,
137: UnknownTypeException {
138: throw new UnsupportedOperationException("Not supported yet.");
139: }
140:
141: public PasteType[] getPasteTypes(Object node, Transferable t)
142: throws UnknownTypeException {
143: return null;
144: }
145:
146: public void setName(Object node, String name)
147: throws UnknownTypeException {
148: throw new UnsupportedOperationException("Not supported yet.");
149: }
150:
151: }
|