001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.bpel.debugger.ui.watch;
020:
021: import org.netbeans.modules.bpel.debugger.api.BpelDebugger;
022: import org.netbeans.modules.bpel.debugger.api.variables.NamedValueHost;
023: import org.netbeans.modules.bpel.debugger.ui.util.VariablesUtil;
024: import org.netbeans.spi.debugger.ContextProvider;
025: import org.netbeans.spi.debugger.ui.Constants;
026: import org.netbeans.spi.viewmodel.ModelListener;
027: import org.netbeans.spi.viewmodel.NodeModel;
028: import org.netbeans.spi.viewmodel.TreeModel;
029: import org.netbeans.spi.viewmodel.UnknownTypeException;
030: import org.openide.util.NbBundle;
031: import org.w3c.dom.Node;
032:
033: /**
034: *
035: * @author Vladimir Yaroslavskiy
036: * @author Kirill Sorokin
037: */
038: public class WatchesNodeModel implements NodeModel, Constants {
039: public static final String WATCH_ICON = "org/netbeans/modules/debugger/resources/watchesView/Watch";
040:
041: final ContextProvider myContextProvider;
042: final BpelDebugger myDebugger;
043: final VariablesUtil myHelper;
044:
045: /**{@inheritDoc}*/
046: public WatchesNodeModel(final ContextProvider contextProvider) {
047:
048: myContextProvider = contextProvider;
049: myDebugger = contextProvider.lookupFirst(null,
050: BpelDebugger.class);
051: myHelper = new VariablesUtil(myDebugger);
052: }
053:
054: /**{@inheritDoc}*/
055: public String getDisplayName(final Object object)
056: throws UnknownTypeException {
057:
058: if (object == TreeModel.ROOT) {
059: return NbBundle.getBundle(WatchesNodeModel.class)
060: .getString("CTL_Watch_Column_Name_Name"); // NOI18N
061: }
062:
063: if (object instanceof BpelWatch) {
064: return ((BpelWatch) object).getExpression();
065: }
066:
067: if (object instanceof NamedValueHost) {
068: return myHelper.getDisplayName(object);
069: }
070:
071: if (object instanceof Node) {
072: return myHelper.getDisplayName(object);
073: }
074:
075: throw new UnknownTypeException(object);
076: }
077:
078: /**{@inheritDoc}*/
079: public String getShortDescription(final Object object)
080: throws UnknownTypeException {
081:
082: return getDisplayName(object);
083: }
084:
085: /**{@inheritDoc}*/
086: public String getIconBase(final Object object)
087: throws UnknownTypeException {
088:
089: if (object == TreeModel.ROOT) {
090: return WATCH_ICON;
091: }
092:
093: if (object instanceof BpelWatch) {
094: return WATCH_ICON;
095: }
096:
097: if (object instanceof NamedValueHost) {
098: return myHelper.getIconBase(object);
099: }
100:
101: if (object instanceof Node) {
102: return myHelper.getIconBase(object);
103: }
104:
105: throw new UnknownTypeException(object);
106: }
107:
108: /**{@inheritDoc}*/
109: public void addModelListener(final ModelListener listener) {
110: // does nothing
111: }
112:
113: /**{@inheritDoc}*/
114: public void removeModelListener(final ModelListener listener) {
115: // does nothing
116: }
117: }
|