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-2006 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.project.ui.groups;
043:
044: import java.io.File;
045: import org.openide.filesystems.FileObject;
046: import org.openide.filesystems.FileUtil;
047:
048: /**
049: * Panel to configure state of an existing subproject-based group.
050: * @author Jesse Glick
051: */
052: public class SubprojectsGroupEditPanel extends GroupEditPanel {
053:
054: private final SubprojectsGroup g;
055:
056: public SubprojectsGroupEditPanel(SubprojectsGroup g) {
057: this .g = g;
058: initComponents();
059: nameField.setText(g.getName());
060: FileObject dir = g.getMasterProjectDirectory();
061: if (dir != null) {
062: File d = FileUtil.toFile(dir);
063: if (d != null) {
064: masterProjectField.setText(d.getAbsolutePath());
065: }
066: }
067: }
068:
069: public void applyChanges() {
070: g.setName(nameField.getText().trim());
071: }
072:
073: /** This method is called from within the constructor to
074: * initialize the form.
075: * WARNING: Do NOT modify this code. The content of this method is
076: * always regenerated by the Form Editor.
077: */
078: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
079: private void initComponents() {
080:
081: nameLabel = new javax.swing.JLabel();
082: nameField = new javax.swing.JTextField();
083: masterProjectLabel = new javax.swing.JLabel();
084: masterProjectField = new javax.swing.JTextField();
085:
086: org.openide.awt.Mnemonics.setLocalizedText(nameLabel,
087: org.openide.util.NbBundle.getMessage(
088: SubprojectsGroupEditPanel.class,
089: "SubprojectsGroupEditPanel.nameLabel.text")); // NOI18N
090:
091: masterProjectLabel.setLabelFor(masterProjectField);
092: org.openide.awt.Mnemonics
093: .setLocalizedText(
094: masterProjectLabel,
095: org.openide.util.NbBundle
096: .getMessage(
097: SubprojectsGroupEditPanel.class,
098: "SubprojectsGroupEditPanel.masterProjectLabel.text")); // NOI18N
099:
100: masterProjectField.setEditable(false);
101:
102: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
103: this );
104: this .setLayout(layout);
105: layout
106: .setHorizontalGroup(layout
107: .createParallelGroup(
108: org.jdesktop.layout.GroupLayout.LEADING)
109: .add(
110: layout
111: .createSequentialGroup()
112: .addContainerGap()
113: .add(
114: layout
115: .createParallelGroup(
116: org.jdesktop.layout.GroupLayout.LEADING)
117: .add(nameLabel)
118: .add(
119: masterProjectLabel))
120: .addPreferredGap(
121: org.jdesktop.layout.LayoutStyle.RELATED)
122: .add(
123: layout
124: .createParallelGroup(
125: org.jdesktop.layout.GroupLayout.LEADING)
126: .add(
127: masterProjectField,
128: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
129: 294,
130: Short.MAX_VALUE)
131: .add(
132: nameField,
133: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
134: 294,
135: Short.MAX_VALUE))
136: .addContainerGap()));
137: layout
138: .setVerticalGroup(layout
139: .createParallelGroup(
140: org.jdesktop.layout.GroupLayout.LEADING)
141: .add(
142: layout
143: .createSequentialGroup()
144: .addContainerGap()
145: .add(
146: layout
147: .createParallelGroup(
148: org.jdesktop.layout.GroupLayout.BASELINE)
149: .add(nameLabel)
150: .add(
151: nameField,
152: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
153: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
154: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
155: .addPreferredGap(
156: org.jdesktop.layout.LayoutStyle.RELATED)
157: .add(
158: layout
159: .createParallelGroup(
160: org.jdesktop.layout.GroupLayout.BASELINE)
161: .add(
162: masterProjectLabel)
163: .add(
164: masterProjectField,
165: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
166: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
167: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
168: .addContainerGap(
169: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
170: Short.MAX_VALUE)));
171: }// </editor-fold>//GEN-END:initComponents
172:
173: // Variables declaration - do not modify//GEN-BEGIN:variables
174: private javax.swing.JTextField masterProjectField;
175: private javax.swing.JLabel masterProjectLabel;
176: private javax.swing.JTextField nameField;
177: private javax.swing.JLabel nameLabel;
178: // End of variables declaration//GEN-END:variables
179:
180: }
|