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: * @author Jonathan Giron
066: */
067: public class SQLRuntimeOutputArea extends SQLBasicTableArea {
068:
069: private static URL runtimeOutputImgUrl = SQLBasicTableArea.class
070: .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/RuntimeOutput.png");
071:
072: private static URL propertiesUrl = SQLBasicTableArea.class
073: .getResource("/org/netbeans/modules/sql/framework/ui/resources/images/properties.png");
074:
075: private static final Color DEFAULT_BG_COLOR = new Color(219, 207,
076: 219);//(204, 213, 241);
077:
078: private static final Color DEFAULT_BG_COLOR_DARK = new Color(221,
079: 235, 246);//(165, 193, 249);
080:
081: private static final JGoBrush DEFAULT_TITLE_BRUSH = new GradientBrush(
082: DEFAULT_BG_COLOR, DEFAULT_BG_COLOR_DARK);
083:
084: private JMenuItem editRuntimeItem;
085:
086: private static transient final Logger mLogger = LogUtil
087: .getLogger(SQLRuntimeOutputArea.class.getName());
088:
089: private static transient final Localizer mLoc = Localizer.get();
090:
091: /**
092: * Creates a new instance of SQLRuntimeOutputArea
093: */
094: public SQLRuntimeOutputArea() {
095: super ();
096: }
097:
098: /**
099: * Creates a new instance of SQLRuntimeOutputArea
100: *
101: * @param table the table to render
102: */
103: public SQLRuntimeOutputArea(SQLDBTable table) {
104: super (table);
105: }
106:
107: protected void initializePopUpMenu() {
108: ActionListener aListener = new TableActionListener();
109: // edit runtime
110: String nbBundle1 = mLoc.t("PRSR001: Edit");
111: String lbl = Localizer.parse(nbBundle1);
112: editRuntimeItem = new JMenuItem(lbl, new ImageIcon(
113: propertiesUrl));
114: editRuntimeItem.addActionListener(aListener);
115: popUpMenu.add(editRuntimeItem);
116:
117: addSelectVisibleColumnsPopUpMenu(aListener);
118: popUpMenu.addSeparator();
119: addRemovePopUpMenu(aListener);
120: }
121:
122: Icon createIcon() {
123: return new ImageIcon(runtimeOutputImgUrl);
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: DataObjectProvider.getProvider().getActiveDataObject()
148: .getETLEditorSupport().synchDocument();
149: }
150:
151: public void setConditionIcons() {
152: //do nothing
153: }
154:
155: /**
156: * @return
157: * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultTitleBrush()
158: */
159: protected JGoBrush getDefaultTitleBrush() {
160: return DEFAULT_TITLE_BRUSH;
161: }
162:
163: /**
164: * @return
165: * @see org.netbeans.modules.sql.framework.ui.view.graph.SQLBasicTableArea#getDefaultBackgroundColor()
166: */
167: protected Color getDefaultBackgroundColor() {
168: return DEFAULT_BG_COLOR;
169: }
170: }
|