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 directory-based group.
050: * @author Jesse Glick
051: */
052: public class DirectoryGroupEditPanel extends GroupEditPanel {
053:
054: private final DirectoryGroup g;
055:
056: public DirectoryGroupEditPanel(DirectoryGroup g) {
057: this .g = g;
058: initComponents();
059: nameField.setText(g.getName());
060: FileObject dir = g.getDirectory();
061: if (dir != null) {
062: File d = FileUtil.toFile(dir);
063: if (d != null) {
064: folderField.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: folderLabel = new javax.swing.JLabel();
084: folderField = new javax.swing.JTextField();
085:
086: org.openide.awt.Mnemonics.setLocalizedText(nameLabel,
087: org.openide.util.NbBundle.getMessage(
088: DirectoryGroupEditPanel.class,
089: "DirectoryGroupEditPanel.nameLabel.text")); // NOI18N
090:
091: org.openide.awt.Mnemonics.setLocalizedText(folderLabel,
092: org.openide.util.NbBundle.getMessage(
093: DirectoryGroupEditPanel.class,
094: "DirectoryGroupEditPanel.folderLabel.text")); // NOI18N
095:
096: folderField.setEditable(false);
097:
098: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
099: this );
100: this .setLayout(layout);
101: layout
102: .setHorizontalGroup(layout
103: .createParallelGroup(
104: org.jdesktop.layout.GroupLayout.LEADING)
105: .add(
106: layout
107: .createSequentialGroup()
108: .addContainerGap()
109: .add(
110: layout
111: .createParallelGroup(
112: org.jdesktop.layout.GroupLayout.LEADING)
113: .add(nameLabel)
114: .add(
115: folderLabel))
116: .addPreferredGap(
117: org.jdesktop.layout.LayoutStyle.RELATED)
118: .add(
119: layout
120: .createParallelGroup(
121: org.jdesktop.layout.GroupLayout.LEADING)
122: .add(
123: folderField,
124: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
125: 327,
126: Short.MAX_VALUE)
127: .add(
128: nameField,
129: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
130: 327,
131: Short.MAX_VALUE))
132: .addContainerGap()));
133: layout
134: .setVerticalGroup(layout
135: .createParallelGroup(
136: org.jdesktop.layout.GroupLayout.LEADING)
137: .add(
138: layout
139: .createSequentialGroup()
140: .addContainerGap()
141: .add(
142: layout
143: .createParallelGroup(
144: org.jdesktop.layout.GroupLayout.BASELINE)
145: .add(nameLabel)
146: .add(
147: nameField,
148: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
149: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
150: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
151: .addPreferredGap(
152: org.jdesktop.layout.LayoutStyle.RELATED)
153: .add(
154: layout
155: .createParallelGroup(
156: org.jdesktop.layout.GroupLayout.BASELINE)
157: .add(
158: folderLabel)
159: .add(
160: folderField,
161: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
162: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
163: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
164: .addContainerGap(
165: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
166: Short.MAX_VALUE)));
167: }// </editor-fold>//GEN-END:initComponents
168:
169: // Variables declaration - do not modify//GEN-BEGIN:variables
170: private javax.swing.JTextField folderField;
171: private javax.swing.JLabel folderLabel;
172: private javax.swing.JTextField nameField;
173: private javax.swing.JLabel nameLabel;
174: // End of variables declaration//GEN-END:variables
175:
176: }
|