001: /*
002: * Sun Public License Notice
003: *
004: * The contents of this file are subject to the Sun Public License
005: * Version 1.0 (the "License"). You may not use this file except in
006: * compliance with the License. A copy of the License is available at
007: * http://www.sun.com/
008: *
009: * The Original Code is NetBeans. The Initial Developer of the Original
010: * Code is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
011: * Microsystems, Inc. All Rights Reserved.
012: If you wish your version of this file to be governed by only the CDDL
013: or only the GPL Version 2, indicate your decision by adding
014: "[Contributor] elects to include this software in this distribution
015: under the [CDDL or GPL Version 2] license." If you do not indicate a
016: single choice of license, a recipient has the option to distribute
017: your version of this file under either the CDDL, the GPL Version 2 or
018: to extend the choice of license to its licensees as provided above.
019: However, if you add GPL Version 2 code and therefore, elected the GPL
020: Version 2 license, then the option applies only if the new code is
021: made subject to such option by the copyright holder.
022: If you wish your version of this file to be governed by only the CDDL
023: or only the GPL Version 2, indicate your decision by adding
024: "[Contributor] elects to include this software in this distribution
025: under the [CDDL or GPL Version 2] license." If you do not indicate a
026: single choice of license, a recipient has the option to distribute
027: your version of this file under either the CDDL, the GPL Version 2 or
028: to extend the choice of license to its licensees as provided above.
029: However, if you add GPL Version 2 code and therefore, elected the GPL
030: Version 2 license, then the option applies only if the new code is
031: made subject to such option by the copyright holder.
032: */
033: package org.netbeans.modules.etl.ui;
034:
035: import java.awt.Image;
036:
037: import java.beans.PropertyChangeEvent;
038: import java.beans.PropertyChangeListener;
039: import net.java.hulp.i18n.Logger;
040: import org.netbeans.modules.etl.logger.Localizer;
041: import org.netbeans.modules.etl.logger.LogUtil;
042: import org.netbeans.modules.etl.ui.view.cookies.ExecuteTestCookie;
043: import org.netbeans.modules.etl.ui.view.cookies.SelectTablesCookie;
044: import org.openide.ErrorManager;
045: import org.openide.loaders.DataNode;
046: import org.openide.loaders.DataObject;
047: import org.openide.nodes.Children;
048: import org.openide.nodes.CookieSet;
049: import org.openide.nodes.PropertySupport;
050: import org.openide.nodes.Sheet;
051: import org.openide.util.Utilities;
052:
053: /** A node to represent this object. */
054: public class ETLNode extends DataNode implements PropertyChangeListener {
055:
056: public static final int VALID = 1;
057: public static final int ERROR = 0;
058: public static final int WARNING = 2;
059: static Image eTLImg = Utilities
060: .loadImage("org/netbeans/modules/etl/ui/resources/images/ETLDefinition.png");
061: static Image errorImg = Utilities
062: .loadImage("org/netbeans/modules/etl/ui/resources/images/ETLDefinitionError.png");
063: static Image warningImg = Utilities
064: .loadImage("org/netbeans/modules/etl/ui/resources/images/ETLDefinitionWarning.png");
065: private ETLDataObject dObj;
066: private int state = VALID;
067: private static transient final Logger mLogger = LogUtil
068: .getLogger(ETLNode.class.getName());
069: private static transient final Localizer mLoc = Localizer.get();
070:
071: public ETLNode(ETLDataObject obj) {
072: this (obj, Children.LEAF);
073: this .dObj = obj;
074: }
075:
076: private ETLNode(DataObject obj, Children ch) {
077: super (obj, ch);
078: obj.addPropertyChangeListener(this );
079: setIconBaseWithExtension("org/netbeans/modules/etl/ui/resources/images/ETLDefinition.png");
080: init();
081: }
082:
083: private void init() {
084: CookieSet cs = getCookieSet();
085: cs.add(new ExecuteTestCookie());
086: cs.add(new SelectTablesCookie());
087: }
088:
089: public void setCollabState(int state) {
090: this .state = state;
091: }
092:
093: @Override
094: protected Sheet createSheet() {
095: Sheet sheet = Sheet.createDefault();
096: Sheet.Set set = Sheet.createPropertiesSet();
097: try {
098: Property nameProp = new PropertySupport.Reflection(
099: this .dObj, String.class, "getName", null);
100: Property execProp = new PropertySupport.Reflection(
101: this .dObj.getETLDefinition().getSQLDefinition(),
102: String.class, "getExecutionStrategyStr", null);
103: String nbBundle1 = mLoc.t("PRSR001: Collaboration Name");
104: String nbBundle2 = mLoc.t("PRSR001: Execution Strategy");
105: nameProp.setName(Localizer.parse(nbBundle1));
106: execProp.setName(Localizer.parse(nbBundle2));
107: set.put(nameProp);
108: set.put(execProp);
109: } catch (Exception ex) {
110: ErrorManager.getDefault().notify(ex);
111: }
112: sheet.put(set);
113: return sheet;
114: }
115:
116: @Override
117: public Image getIcon(int type) {
118: Image img = eTLImg;
119: try {
120: if (state == ERROR) {
121: img = Utilities.mergeImages(eTLImg, errorImg, 1, 0);
122: } else if (state == WARNING) {
123: img = Utilities.mergeImages(eTLImg, warningImg, 1, 0);
124: }
125: } catch (Exception ex) {
126: ErrorManager.getDefault().notify(ex);
127: }
128: return img;
129: }
130:
131: public void propertyChange(PropertyChangeEvent evt) {
132: fireIconChange();
133: }
134: }
|