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.graph.view.impl;
042:
043: import java.awt.BorderLayout;
044: import java.awt.Component;
045: import java.awt.Dimension;
046: import java.awt.Frame;
047: import java.awt.event.ActionListener;
048:
049: import javax.swing.JButton;
050: import javax.swing.JCheckBox;
051: import javax.swing.JDialog;
052: import javax.swing.JPanel;
053:
054: import net.java.hulp.i18n.Logger;
055: import org.netbeans.modules.etl.logger.Localizer;
056: import org.netbeans.modules.etl.logger.LogUtil;
057:
058: /**
059: * Displays the palette of available operators for the Collaboration Definition Editor.
060: *
061: * @author Jonathan Giron
062: * @version $Revision$
063: */
064: public class OperatorPaletteDialog extends JDialog implements
065: ActionListener {
066:
067: /* flag on whether to show palette item names */
068: private static boolean showName = true;
069: private static transient final Logger mLogger = LogUtil
070: .getLogger(OperatorPaletteDialog.class.getName());
071: private static transient final Localizer mLoc = Localizer.get();
072: private static Dimension minSize = null;
073:
074: /* cancel button */
075: String nbBundle = mLoc.t("PRSR001: Close");
076: private JButton mBtnCancel = new JButton(Localizer.parse(nbBundle));
077:
078: /* "Show name" check box */
079: String nbBundle1 = mLoc.t("PRSR001: Show Names");
080: private JCheckBox mCheckName = new JCheckBox(Localizer
081: .parse(nbBundle1), showName);
082:
083: /* selection (tabbed) panel */
084: private OperatorSelectionPanel mPanel = null;
085:
086: /**
087: * Constructs a new instance of OperatorPaletteDialog with the given Frame as parent
088: * and the given panel as internal content.
089: *
090: * @param aFrame parent Frame to block
091: * @param sp OperatorSelectionPanel instance with operator selection controls
092: */
093: public OperatorPaletteDialog(Frame aFrame, OperatorSelectionPanel sp) {
094: super (aFrame, true);
095:
096: mPanel = sp;
097:
098: String nbBundle2 = mLoc.t("PRSR001: Operator Palette");
099: setTitle(Localizer.parse(nbBundle2));
100:
101: JPanel pane = new JPanel();
102:
103: pane.setLayout(new BorderLayout(10, 10));
104: pane.add(sp, BorderLayout.CENTER);
105:
106: JPanel bp = new JPanel();
107: bp.setLayout(new BorderLayout(10, 10));
108:
109: JPanel bp2 = new JPanel();
110: mCheckName.addActionListener(this );
111: mBtnCancel.addActionListener(this );
112: mBtnCancel.getAccessibleContext().setAccessibleName(
113: Localizer.parse(nbBundle));
114: bp2.add(mBtnCancel);
115: bp.add(bp2, BorderLayout.EAST);
116: bp.add(mCheckName, BorderLayout.WEST);
117:
118: pane.add(bp, BorderLayout.SOUTH);
119:
120: setContentPane(pane);
121: setDefaultCloseOperation(DISPOSE_ON_CLOSE);
122: setResizable(true);
123: }
124:
125: /**
126: * Process the specified UI item action event.
127: *
128: * @param e the action event
129: */
130: public void actionPerformed(java.awt.event.ActionEvent e) {
131: Object src = e.getSource();
132:
133: if (src == mCheckName) {
134: showName = mCheckName.isSelected();
135: mPanel.updateShowNames(showName);
136: this .repaint();
137: return;
138: }
139:
140: this .setVisible(false);
141: }
142:
143: /**
144: * Show this dialog.
145: */
146: public void showDialog() {
147: mPanel.updateShowNames(showName);
148: if (minSize == null) {
149: pack();
150: minSize = getSize();
151: } else {
152: setSize(minSize);
153: }
154: setVisible(true);
155: }
156:
157: /**
158: * Show dialog in an appropriate position relative to the given component.
159: *
160: * @param p component relative to which we will display dialog in an appropriate
161: * position (e.g., centered)
162: */
163: public void showDialog(Component p) {
164: setLocationRelativeTo(p);
165: showDialog();
166: }
167: }
|