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.sql.framework.ui.view.graph;
043:
044: import java.awt.Color;
045: import java.awt.event.ActionEvent;
046: import java.awt.event.ActionListener;
047: import java.net.URL;
048:
049: import javax.swing.Icon;
050: import javax.swing.ImageIcon;
051: import javax.swing.JMenuItem;
052:
053: import org.netbeans.modules.etl.ui.DataObjectProvider;
054: import org.netbeans.modules.sql.framework.model.SQLDBTable;
055: import org.netbeans.modules.sql.framework.ui.graph.ICommand;
056: import org.netbeans.modules.sql.framework.ui.graph.impl.GradientBrush;
057:
058: import com.nwoods.jgo.JGoBrush;
059: import net.java.hulp.i18n.Logger;
060: import org.netbeans.modules.etl.logger.Localizer;
061: import org.netbeans.modules.etl.logger.LogUtil;
062:
063: /**
064: * @author Ritesh Adval
065: */
066: public class SQLRuntimeInputArea extends SQLBasicTableArea {
067:
068: private static URL runtimeInputImgUrl = SQLBasicTableArea.class
069: .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/RuntimeInput.png");
070:
071: private static URL propertiesUrl = SQLBasicTableArea.class
072: .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/properties.png");
073:
074: private static final Color DEFAULT_BG_COLOR = new Color(204, 213,
075: 241);
076:
077: private static final Color DEFAULT_BG_COLOR_DARK = new Color(165,
078: 193, 249);
079:
080: private static final JGoBrush DEFAULT_TITLE_BRUSH = new GradientBrush(
081: DEFAULT_BG_COLOR_DARK, DEFAULT_BG_COLOR);
082:
083: private JMenuItem editRuntimeItem;
084:
085: private static transient final Logger mLogger = LogUtil
086: .getLogger(SQLRuntimeInputArea.class.getName());
087:
088: private static transient final Localizer mLoc = Localizer.get();
089:
090: /**
091: * Creates a new instance of SQLRuntimeInputArea
092: */
093: public SQLRuntimeInputArea() {
094: super ();
095: }
096:
097: /**
098: * Creates a new instance of SQLRuntimeInputArea
099: *
100: * @param table the table to render
101: */
102: public SQLRuntimeInputArea(SQLDBTable table) {
103: super (table);
104: }
105:
106: protected void initializePopUpMenu() {
107: ActionListener aListener = new TableActionListener();
108: // edit runtime
109: String nbBundle1 = mLoc.t("PRSR001: Edit");
110: String lbl = Localizer.parse(nbBundle1);
111: editRuntimeItem = new JMenuItem(lbl, new ImageIcon(
112: propertiesUrl));
113: editRuntimeItem.addActionListener(aListener);
114: popUpMenu.add(editRuntimeItem);
115:
116: addSelectVisibleColumnsPopUpMenu(aListener);
117: popUpMenu.addSeparator();
118: addRemovePopUpMenu(aListener);
119:
120: }
121:
122: Icon createIcon() {
123: return new ImageIcon(runtimeInputImgUrl);
124: }
125:
126: private class TableActionListener implements ActionListener {
127: /**
128: * Invoked when an action occurs.
129: *
130: * @param e ActionEvent to handle
131: */
132: public void actionPerformed(ActionEvent e) {
133: Object source = e.getSource();
134:
135: if (source == editRuntimeItem) {
136: EditRuntime_ActionPerformed(e);
137: } else {
138: handleCommonActions(e);
139: }
140: }
141: }
142:
143: private void EditRuntime_ActionPerformed(ActionEvent e) {
144: Object[] args = new Object[] { new Integer(table
145: .getObjectType()) };
146: this .getGraphView().execute(ICommand.ADD_RUNTIME_CMD, args);
147: if (DataObjectProvider.getProvider().getActiveDataObject()
148: .getModel().isDirty()) {
149: DataObjectProvider.getProvider().getActiveDataObject()
150: .getETLEditorSupport().synchDocument();
151: }
152: }
153:
154: public void setConditionIcons() {
155: //do nothing
156: }
157:
158: /**
159: * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultTitleBrush()
160: */
161: protected JGoBrush getDefaultTitleBrush() {
162: return DEFAULT_TITLE_BRUSH;
163: }
164:
165: /**
166: * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultBackgroundColor()
167: */
168: protected Color getDefaultBackgroundColor() {
169: return DEFAULT_BG_COLOR;
170: }
171: }
|