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.event.ActionEvent;
050: import java.awt.event.ActionListener;
051:
052: import javax.swing.BorderFactory;
053: import javax.swing.Box;
054: import javax.swing.JButton;
055: import javax.swing.JPanel;
056: import javax.swing.JTextField;
057:
058: import org.netbeans.modules.uml.core.support.umlutils.IPropertyDefinition;
059: import org.netbeans.modules.uml.core.support.umlutils.IPropertyElement; //This has to be uncommnted after resolving cyclic dependency issues
060: //import org.netbeans.modules.uml.ui.products.ad.addesigncentergui.designpatternaddin.WizardRoles;
061: import org.netbeans.modules.uml.ui.swing.propertyeditor.PropertyEditor;
062:
063: /**
064: * @author sumitabhk
065: *
066: */
067: public class JDescribeButton extends JPanel implements ActionListener {
068: private JButton m_Button = null;
069: private JTextField m_Text = null;
070: private int m_Row = 0;
071: private PropertyEditor m_editor = null;
072:
073: //This has to be uncommnted after resolving cyclic dependency issues
074: //private WizardRoles m_RolesClazz = null;
075:
076: /**
077: *
078: */
079: public JDescribeButton(PropertyEditor editor) {
080: super ();
081: m_editor = editor;
082: // GridBagLayout gbl = new GridBagLayout();
083: // double[] vals = {1.0, 0.0};
084: // gbl.columnWeights = vals;
085: // GridBagConstraints textConstraints = new GridBagConstraints();
086: // GridBagConstraints buttonConstraints = new GridBagConstraints();
087: // textConstraints.fill = GridBagConstraints.BOTH;
088: // buttonConstraints.gridx = GridBagConstraints.CENTER;
089: // buttonConstraints.gridy = GridBagConstraints.CENTER;
090: // this.setLayout(gbl);
091: // gbl.invalidateLayout(this);
092: // this.doLayout();
093: //
094: // m_Text = new JTextField();
095: // m_Text.setEditable(false);
096: // m_Text.setEnabled(false);
097: // gbl.setConstraints(m_Text, textConstraints);
098: // m_Button = new JButton("+");
099: // m_Button.setPreferredSize(new Dimension(10,10));
100: // gbl.setConstraints(m_Button, buttonConstraints);
101: // add(m_Text);
102: // add(m_Button);
103: initialize();
104: }
105:
106: public JDescribeButton(int row) {
107: super ();
108: initialize();
109: m_Row = row;
110: }
111:
112: public JDescribeButton(int row, PropertyEditor editor) {
113: super ();
114: initialize();
115: m_Row = row;
116: m_editor = editor;
117: }
118:
119: //This has to be uncommnted after resolving cyclic dependency issues
120: // public JDescribeButton(int row, WizardRoles rolesClazz)
121: // {
122: // super();
123: // initialize();
124: // //m_RolesClazz = rolesClazz;
125: // m_Row = row;
126: // }
127: /* (non-Javadoc)
128: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
129: */
130: public void actionPerformed(ActionEvent e) {
131: if (m_editor != null) {
132: IPropertyElement pEle = m_editor.getElementAtGridRow(m_Row);
133: IPropertyDefinition def = pEle.getPropertyDefinition();
134: m_editor.onPopupCreate(m_Row, pEle);
135: }
136: //else if (m_RolesClazz != null)
137: //{
138: // m_RolesClazz.onCellButtonClickGrid(m_Row, 0);
139: //}
140: }
141:
142: private void initialize() {
143: // java.awt.GridBagConstraints gridBagConstraints;
144: //
145: // m_Text = new javax.swing.JTextField();
146: m_Button = new javax.swing.JButton("+");
147: m_Button.setFocusable(false);
148: //
149: // setLayout(new java.awt.GridBagLayout());
150: //
151: // //setMaximumSize(new java.awt.Dimension(100, 15));
152: // m_Text.setEditable(false);
153: // //m_Text.setMinimumSize(new java.awt.Dimension(40, 10));
154: // m_Text.setEnabled(false);
155: // m_Text.setBorder(null);
156: //
157: // gridBagConstraints = new java.awt.GridBagConstraints();
158: // gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
159: // gridBagConstraints.weightx = 1.0;
160: // gridBagConstraints.gridx = 0;
161: // gridBagConstraints.gridy = 0;
162: // add(m_Text, gridBagConstraints);
163: //
164: // //m_Button.setText("+");
165: m_Button.setIcon(null);
166: m_Button.setPreferredSize(new java.awt.Dimension(25, 15));
167: // m_Button.setVerticalTextPosition(SwingConstants.TOP);
168: // m_Button.setHorizontalTextPosition(SwingConstants.RIGHT);
169: // m_Button.setBorderPainted(false);
170: // m_Button.setContentAreaFilled(false);
171: // java.awt.GridBagConstraints constraints = new java.awt.GridBagConstraints();
172: // constraints.gridx = 1;
173: // constraints.gridy = 0;
174: // constraints.anchor = GridBagConstraints.EAST;
175: // add(m_Button, constraints);
176:
177: m_Button.setBorder(BorderFactory.createEtchedBorder());
178: setLayout(new BorderLayout());
179: m_Button.addActionListener(this );
180: Box pane = Box.createHorizontalBox();
181: pane.add(Box.createHorizontalGlue());
182: pane.add(m_Button);
183: add(pane, BorderLayout.CENTER);
184: }
185: }
|