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: package org.netbeans.modules.sql.framework.ui.view.validation;
042:
043: import java.awt.BorderLayout;
044: import java.awt.CardLayout;
045: import java.awt.event.ActionEvent;
046: import java.awt.event.ActionListener;
047: import java.net.URL;
048: import java.util.List;
049: import javax.swing.ImageIcon;
050: import javax.swing.JButton;
051: import javax.swing.JPanel;
052: import javax.swing.JTextArea;
053: import net.java.hulp.i18n.Logger;
054: import org.netbeans.modules.etl.logger.Localizer;
055: import org.netbeans.modules.etl.logger.LogUtil;
056: import org.netbeans.modules.sql.framework.ui.graph.IGraphView;
057: import org.netbeans.modules.sql.framework.ui.output.ETLOutputPanel;
058:
059: /**
060: * @author Ritesh Adval
061: * @author Ahimanikya Satapathy
062: */
063: public class SQLValidationView extends JPanel implements ETLOutputPanel {
064:
065: private static final String TABLE_VIEW = "table_view";
066: private static final String TEXT_VIEW = "text_view";
067: private ValidationTableView vTableView;
068: private JTextArea textArea;
069: private JPanel cardPanel;
070: private IGraphView graphView;
071: private JButton refreshButton;
072: private ActionListener aListener;
073: private JButton[] btn = new JButton[1];
074: private static transient final Logger mLogger = LogUtil
075: .getLogger(SQLValidationView.class.getName());
076: private static transient final Localizer mLoc = Localizer.get();
077:
078: public SQLValidationView(IGraphView gView) {
079: this .graphView = gView;
080: initGui();
081: }
082:
083: private void initGui() {
084: this .setLayout(new BorderLayout());
085:
086: //add refresh button
087: URL url = getClass()
088: .getResource(
089: "/org/netbeans/modules/sql/framework/ui/resources/images/rerun.png");
090: refreshButton = new JButton(new ImageIcon(url));
091: String nbBundle30 = mLoc.t("PRSR001: Refresh");
092: refreshButton.setToolTipText(Localizer.parse(nbBundle30));
093: refreshButton
094: .setMnemonic(Localizer.parse(nbBundle30).charAt(0));
095: refreshButton.getAccessibleContext().setAccessibleName(
096: Localizer.parse(nbBundle30));
097: refreshButton.addActionListener(aListener);
098: btn[0] = refreshButton;
099: ActionListener aListener = new ActionListener() {
100:
101: public void actionPerformed(ActionEvent e) {
102: Object src = e.getSource();
103: if (src.equals(refreshButton)) {
104: validate();
105: }
106: }
107: };
108: cardPanel = new JPanel();
109: cardPanel.setLayout(new CardLayout());
110: this .add(cardPanel, BorderLayout.CENTER);
111:
112: //add table panel
113: vTableView = new ValidationTableView(this .graphView);
114: cardPanel.add(vTableView, TABLE_VIEW);
115:
116: //add text panel
117: textArea = new JTextArea();
118: cardPanel.add(textArea, TEXT_VIEW);
119: }
120:
121: public void setValidationInfos(List vInfos) {
122: this .graphView.clearSelection();
123: this .graphView.resetSelectionColors();
124: vTableView.setValidationInfos(vInfos);
125: CardLayout cl = (CardLayout) cardPanel.getLayout();
126: cl.show(cardPanel, TABLE_VIEW);
127: }
128:
129: public void clearView() {
130: vTableView.clearView();
131: textArea.setText("");
132: }
133:
134: public void appendToView(String msg) {
135: textArea.append(msg);
136: CardLayout cl = (CardLayout) cardPanel.getLayout();
137: cl.show(cardPanel, TEXT_VIEW);
138: }
139:
140: public JButton[] getVerticalToolBar() {
141: return btn;
142: }
143: }
|