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;
021:
022: import java.awt.Component;
023: import java.beans.PropertyChangeListener;
024: import java.util.List;
025: import java.util.Vector;
026:
027: import org.netbeans.modules.soa.mapper.basicmapper.util.MapperUtilities;
028: import org.netbeans.modules.soa.mapper.common.basicmapper.IBasicMapperView;
029: import org.netbeans.modules.soa.mapper.common.basicmapper.IBasicViewManager;
030: import org.netbeans.modules.soa.mapper.common.IMapperAutoLayout;
031: import org.netbeans.modules.soa.mapper.common.IMapperListener;
032: import org.netbeans.modules.soa.mapper.common.IMapperViewModel;
033:
034: /**
035: * <p>
036: *
037: * Title: </p> BasicMapperView<p>
038: *
039: * Description: </p> BasicMapperView provides basic setter and getter for
040: * IBasicMapperView interface.<p>
041: *
042: * @author Un Seng Leong
043: * @created December 23, 2002
044: */
045:
046: public class BasicMapperView implements IBasicMapperView {
047:
048: /**
049: * the view manager handles this view
050: */
051: private IBasicViewManager mViewManager;
052:
053: /**
054: * the view model to be display in this view.
055: */
056: private IMapperViewModel mViewModel;
057:
058: /**
059: * the java component repersenting this view
060: */
061: private Component mComp;
062:
063: /**
064: * the object handles autolayout
065: */
066: private IMapperAutoLayout mAutoLayout;
067:
068: /**
069: * the name of this mapper view
070: */
071: private String mViewName;
072:
073: /**
074: * the property listeners list
075: */
076: private List mPropertyListeners;
077:
078: /**
079: * flag indicates if this mapper tree is mapping enable.
080: */
081: private boolean mIsMapable = true;
082:
083: /**
084: * Constructor for the BasicMapperView object
085: */
086: public BasicMapperView() {
087: mPropertyListeners = new Vector();
088: }
089:
090: /**
091: * Sets the viewManager attribute of the BasicMapperView object
092: *
093: * @param viewManager The new viewManager value
094: */
095: public void setViewManager(IBasicViewManager viewManager) {
096: mViewManager = viewManager;
097: }
098:
099: /**
100: * Return the view manager handles this view.
101: *
102: * @return the view manager handles this view.
103: */
104: public IBasicViewManager getViewManager() {
105: return mViewManager;
106: }
107:
108: /**
109: * Return a java visual object repersents this view.
110: *
111: * @return a java visual object repersents this view.
112: */
113: public Component getViewComponent() {
114: return mComp;
115: }
116:
117: /**
118: * Sets the viewComponent attribute of the BasicMapperView object
119: *
120: * @param comp The new viewComponent value
121: */
122: public void setViewComponent(Component comp) {
123: mComp = comp;
124: }
125:
126: /**
127: * Set the view model of this view should display.
128: *
129: * @param model the link mode to display
130: */
131: public void setViewModel(IMapperViewModel model) {
132: IMapperViewModel oldModel = mViewModel;
133: mViewModel = model;
134: firePropertyChange(IBasicMapperView.MODEL_CHANGE, model,
135: oldModel);
136: }
137:
138: /**
139: * Return the current mapper view model of this view.
140: *
141: * @return the mapper view model of this view.
142: */
143: public IMapperViewModel getViewModel() {
144: return mViewModel;
145: }
146:
147: /**
148: * Return a name of this view.
149: *
150: * @return a String repersentation of this view name.
151: */
152: public String getViewName() {
153: return mViewName;
154: }
155:
156: /**
157: * Set a name of this view.
158: *
159: * @param name a String repersentation of this view name.
160: */
161: public void setViewName(String name) {
162: String oldName = mViewName;
163: mViewName = name;
164: firePropertyChange(IBasicMapperView.NAME_CHANGE, name, oldName);
165: }
166:
167: /**
168: * Return true if this view is mapping enable, false otherwise.
169: *
170: * @return The droppable value
171: */
172: public boolean isMapable() {
173: return mIsMapable;
174: }
175:
176: /**
177: * Set if this view is mapping enable.
178: *
179: * @param droppable the flag indicates if this view is mapping enable.
180: */
181: public void setIsMapable(boolean mapable) {
182: mIsMapable = mapable;
183: }
184:
185: /**
186: * Set the auto layout object of this view.
187: *
188: * @param autoLayout the auto layout of this view.
189: */
190: public void setAutoLayout(IMapperAutoLayout autoLayout) {
191: mAutoLayout = autoLayout;
192: }
193:
194: /**
195: * Return the auto layout object of this view.
196: *
197: * @return the auto layout object of this view.
198: */
199: public IMapperAutoLayout getAutoLayout() {
200: return mAutoLayout;
201: }
202:
203: /**
204: * Adds a PropertyChangeListener to the listener list.
205: *
206: * @param listener the PropertyChangeListener to be added
207: */
208: public void addPropertyChangeListener(
209: PropertyChangeListener listener) {
210: mPropertyListeners.add(listener);
211: }
212:
213: /**
214: * Removes a PropertyChangeListener from the listener list.
215: *
216: * @param listener the PropertyChangeListener to be added
217: */
218: public void removePropertyChangeListener(
219: PropertyChangeListener listener) {
220: mPropertyListeners.remove(listener);
221: }
222:
223: /**
224: * Throws UnsupportedOperationException, use IBasicMapper.addMapperListener
225: * instead.
226: *
227: * @param listener the IMapperListener to be added
228: */
229: public void addMapperListener(IMapperListener listener) {
230: throw new UnsupportedOperationException(
231: "Use IBasicMapper.addMapperListener instead");
232: }
233:
234: /**
235: * Throws UnsupportedOperationException, use
236: * IBasicMapper.removeMapperListener instead.
237: *
238: * @param listener the IMapperListener to be added
239: */
240: public void removeMapperListener(IMapperListener listener) {
241: throw new UnsupportedOperationException(
242: "Use IBasicMapper.removeMapperListener instead");
243: }
244:
245: /**
246: * Fire a specified property change event of this node.
247: *
248: * @param propertyName the name of this property has changed
249: * @param newValue the new value of the property
250: * @param oldValue the old value of the property
251: */
252: protected void firePropertyChange(String propertyName,
253: Object newValue, Object oldValue) {
254:
255: if (mPropertyListeners.size() > 0) {
256: MapperUtilities
257: .firePropertyChanged(
258: (PropertyChangeListener[]) mPropertyListeners
259: .toArray(new PropertyChangeListener[mPropertyListeners
260: .size()]), this,
261: propertyName, newValue, oldValue);
262: }
263: }
264: }
|