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: /*
043: * Created on Jun 12, 2003
044: *
045: */
046: package org.netbeans.modules.uml.ui.swing.treetable;
047:
048: import java.awt.BorderLayout;
049: import java.awt.Color;
050: import java.awt.Font;
051: import java.awt.GridBagConstraints;
052: import java.awt.event.ActionEvent;
053: import java.awt.event.ActionListener;
054:
055: import javax.swing.BorderFactory;
056: import javax.swing.Box;
057: import javax.swing.JButton;
058: import javax.swing.JPanel;
059: import javax.swing.JTextField;
060: import javax.swing.SwingConstants;
061:
062: import org.netbeans.modules.uml.core.support.umlutils.IPropertyElement;
063: import org.netbeans.modules.uml.ui.swing.preferencedialog.PreferenceDialogUI;
064:
065: /**
066: * @author sumitabhk
067: *
068: */
069: public class JDescribeDotButton extends JPanel implements
070: ActionListener {
071: private JButton m_Button = null;
072: private JTextField m_TextField = null;
073: private String m_Text = "";
074: private int m_Row = 0;
075: private Object m_Object = null;
076: private Font m_Font = null;
077: private Color m_Color = null;
078:
079: public JDescribeDotButton(int row, Object obj) {
080: super ();
081: m_Row = row;
082: m_Object = obj;
083: initialize();
084: }
085:
086: public JDescribeDotButton(int row, Object obj, String text) {
087: super ();
088: m_Row = row;
089: m_Object = obj;
090: m_Text = text;
091: initialize();
092: }
093:
094: public JDescribeDotButton(int row, Object obj, String text, Font f,
095: Color c) {
096: super ();
097: m_Row = row;
098: m_Object = obj;
099: m_Text = text;
100: if (f != null) {
101: m_Font = f;
102: }
103: if (c != null) {
104: m_Color = c;
105: }
106: initialize();
107: }
108:
109: /* (non-Javadoc)
110: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
111: */
112: public void actionPerformed(ActionEvent e) {
113: Object obj = e.getSource();
114: if (m_Object != null) {
115: if (m_Object instanceof PreferenceDialogUI) {
116: PreferenceDialogUI ui = (PreferenceDialogUI) m_Object;
117: IPropertyElement pEle = ui.getElementAtGridRow(m_Row);
118: if (pEle != null) {
119: ui.onCellButtonClicked(m_Row, pEle);
120: //ui.refreshFontElement(pEle);
121: }
122: }
123: }
124: }
125:
126: private void initialize() {
127: m_TextField = new javax.swing.JTextField(m_Text);
128: m_TextField.setEditable(false);
129: m_TextField.setBorder(null);
130: if (m_Font != null) {
131: m_TextField.setFont(m_Font);
132: } else {
133: m_TextField.setFont(new java.awt.Font("Dialog", 0, 11));
134: }
135: if (m_Color != null) {
136: m_TextField.setText("");
137: m_TextField.setBackground(m_Color);
138: }
139:
140: m_Button = new javax.swing.JButton("...");
141: m_Button.setIcon(null);
142: m_Button.setPreferredSize(new java.awt.Dimension(25, 15));
143: m_Button.setBorder(BorderFactory.createEtchedBorder());
144: setLayout(new BorderLayout());
145: m_Button.addActionListener(this );
146: Box pane = Box.createHorizontalBox();
147: pane.add(Box.createHorizontalGlue());
148: pane.add(m_TextField);
149: pane.add(m_Button);
150: add(pane, BorderLayout.CENTER);
151: }
152: }
|