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:
020: package org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo;
021:
022: import java.awt.Color;
023: import java.awt.Point;
024: import java.awt.Rectangle;
025:
026: import javax.swing.Icon;
027:
028: import com.nwoods.jgo.JGoBrush;
029: import org.netbeans.modules.soa.mapper.basicmapper.canvas.jgo.util.JGoLabel;
030: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasFieldNode;
031: import org.netbeans.modules.soa.mapper.common.basicmapper.canvas.gtk.ICanvasView;
032: import org.netbeans.modules.soa.mapper.common.basicmapper.methoid.IFieldNode;
033: import org.netbeans.modules.soa.mapper.common.gtk.ICanvas;
034: import org.netbeans.modules.soa.mapper.common.gtk.ICanvasAction;
035: import org.netbeans.modules.soa.mapper.common.gtk.ICanvasComponentNode;
036: import org.netbeans.modules.soa.mapper.common.gtk.ICanvasControlNode;
037: import org.netbeans.modules.soa.mapper.common.gtk.ICanvasGroupNode;
038: import org.netbeans.modules.soa.mapper.common.gtk.ICanvasNodePopupBox;
039:
040: /**
041: * <p>
042: *
043: * Title: </p> AbstractCanvasFieldNode <p>
044: *
045: * Description: </p> AbstractCanvasFieldNode provides the basic implemenation of
046: * a ICanvasFieldNode providing the basci view of a canvas field node. <p>
047: *
048: * Copyright: Copyright (c) 2002 </p> <p>
049: *
050: * Company: </p>
051: *
052: * @author Un Seng Leong
053: * @created December 4, 2002
054: * @version 1.0
055: */
056: public abstract class AbstractCanvasFieldNode extends JGoLabel
057: implements ICanvasFieldNode {
058:
059: /**
060: * the canvas that contains this node
061: */
062: private ICanvas mCanvas;
063:
064: /**
065: * the mapper field node that this field repersents.
066: */
067: protected IFieldNode mFieldNode;
068:
069: /**
070: * the group node that contains this node
071: */
072: private ICanvasGroupNode mGroup;
073:
074: /**
075: * the canvas that contains this node.
076: */
077: private ICanvasView mMapperCanvas;
078:
079: /**
080: * Creates a new AbstractCanvasFieldNode object.
081: *
082: * @param node the mapper field node of this canvas node.
083: */
084: public AbstractCanvasFieldNode(IFieldNode node) {
085: super ();
086: mFieldNode = node;
087:
088: this .setSelectable(true);
089: this .setDraggable(true);
090: this .setBrush(JGoBrush.makeStockBrush(Color.WHITE));
091:
092: setName(mFieldNode.getName());
093:
094: }
095:
096: /**
097: * Return the bounding rectangle of this node.
098: *
099: * @return the bounding rectangle of this node.
100: */
101: public Rectangle getBounding() {
102: return getBoundingRect();
103: }
104:
105: /**
106: * Retrieves the action, this method is not applicable, always returns null.
107: *
108: * @return always null
109: */
110: public ICanvasAction getAction() {
111: return null;
112: }
113:
114: /**
115: * Retrieves the aux popup, this method is not applicable, always returns
116: * null.
117: *
118: * @return the aux popup box
119: */
120: public ICanvasNodePopupBox getAuxPopup() {
121: return null;
122: }
123:
124: /**
125: * Retrieves the cavnas
126: *
127: * @return the canvas or null.
128: */
129: public ICanvas getCanvas() {
130: return mMapperCanvas;
131: }
132:
133: /**
134: * This method is not applicable, always returns null.
135: *
136: * @return always null
137: */
138: public ICanvasComponentNode getComponentNode() {
139: return null;
140: }
141:
142: /**
143: * Retrieves the container
144: *
145: * @return contain group of this node
146: */
147: public ICanvasGroupNode getContainer() {
148: return mGroup;
149: }
150:
151: /**
152: * Retrieves the control node associated with the canvas node. Return null
153: * is nothing associated, this method is not applicable, always returns
154: * null.
155: *
156: * @return always null
157: */
158: public ICanvasControlNode getControlNode() {
159: return null;
160: }
161:
162: /**
163: * Retrieves the data object, calls getFieldNode().
164: *
165: * @return - underlying data object represented by this node
166: */
167: public Object getDataObject() {
168: return getFieldNode();
169: }
170:
171: public IFieldNode getFieldNode() {
172: return mFieldNode;
173: }
174:
175: /**
176: * Gets the Icon which representing this node, , this method is not
177: * applicable, always returns null.
178: *
179: * @return always null.
180: */
181: public Icon getIcon() {
182: return null;
183: }
184:
185: /**
186: * Retrun the mapper canvas that displays this node.
187: *
188: * @return the canvas displays this node.
189: */
190: public ICanvasView getMapperCanvas() {
191: return mMapperCanvas;
192: }
193:
194: /**
195: * Retrieves the name of the node
196: *
197: * @return - name
198: */
199: public String getName() {
200: return mFieldNode.getName();
201: }
202:
203: /**
204: * Retrieves the location
205: *
206: * @return location
207: */
208: public Point getNodeLocation() {
209: return this .getLocation();
210: }
211:
212: /**
213: * Retrieves the popup, this method is not applicable, always returns null.
214: *
215: * @return always null
216: */
217: public ICanvasNodePopupBox getPopup() {
218: return null;
219: }
220:
221: /**
222: * Retrieves the underlying ui component
223: *
224: * @return this node
225: */
226: public Object getUIComponent() {
227: return this ;
228: }
229:
230: /**
231: * Sets the action
232: *
233: * @param action the action to be set
234: */
235: public void setAction(ICanvasAction action) {
236: }
237:
238: /**
239: * Sets the aux popup this node is associated with, this method is not
240: * applicable, always returns null.
241: *
242: * @param popup the aux popup box
243: */
244: public void setAuxPopup(ICanvasNodePopupBox popup) {
245: }
246:
247: /**
248: * Sets the canvas this node belongs to
249: *
250: * @param canvas the canvas that handles this cnode
251: */
252: public void setCanvas(ICanvas canvas) {
253: }
254:
255: /**
256: * Sets the component node associated with this canvas node
257: *
258: * @param node the component node of this node
259: */
260: public void setComponentNode(ICanvasComponentNode node) {
261: }
262:
263: /**
264: * Sets the container this node belongs to
265: *
266: * @param group the group that contains this node
267: */
268: public void setContainer(ICanvasGroupNode group) {
269: mGroup = group;
270: }
271:
272: /**
273: * Sets the control node associated with this canvas node
274: *
275: * @param node the control node of this node
276: */
277: public void setControlNode(ICanvasControlNode node) {
278: }
279:
280: /**
281: * sets the data object
282: *
283: * @param obj - then object to be represented by this node
284: */
285: public void setDataObject(Object obj) {
286: }
287:
288: /**
289: * Sets the icon associated with this node
290: *
291: * @param icon the icon
292: */
293: public void setIcon(Icon icon) {
294: }
295:
296: /**
297: * Set the mapper canvas that displays this node.
298: *
299: * @param canvas the canvas displays this node.
300: */
301: public void setMapperCanvas(ICanvasView canvas) {
302: mMapperCanvas = canvas;
303: }
304:
305: /**
306: * Sets the name of the name
307: *
308: * @param name - new name
309: */
310: public void setName(String name) {
311: updateLabel(name);
312: }
313:
314: /**
315: * Sets the location
316: *
317: * @param p - location
318: */
319: public void setNodeLocation(Point p) {
320: this .setLocation(p);
321: }
322:
323: /**
324: * Sets the abstract canvas node popup
325: *
326: * @param popup the popup box of this node
327: */
328: public void setPopup(ICanvasNodePopupBox popup) {
329: }
330:
331: /**
332: * Refresh the node image.
333: *
334: * @param icon the icon image of this node.
335: */
336: public void refreshNodeImage(javax.swing.Icon icon) {
337: }
338:
339: /**
340: * update the text of this node.
341: *
342: * @param text update the text of this node.
343: */
344: public void updateLabel(String text) {
345: setText(text);
346: }
347:
348: /**
349: * Return the toolTipText of this CanvasFieldNode, overrides JGoObject.getToolTipText.
350: *
351: * @return The toolTipText of this field node.
352: */
353: public String getToolTipText() {
354: return mFieldNode.getToolTipText();
355: }
356: }
|