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: * ChooseLocationDialog.java
044: *
045: * Created on August 30, 2006, 5:20 PM
046: */
047:
048: package org.netbeans.modules.uml.integration.netbeans.actions.ui;
049:
050: import java.io.File;
051:
052: /**
053: *
054: * @author Craig Conover, craig.conover@sun.com
055: */
056: public class ChooseLocationDialog extends javax.swing.JDialog {
057: /**
058: * Creates new form ChooseLocationDialog
059: */
060: public ChooseLocationDialog(java.awt.Frame parent, boolean modal) {
061: this (parent, modal, null, null);
062: }
063:
064: public ChooseLocationDialog(java.awt.Frame parent, boolean modal,
065: File file, String title) {
066: super (parent, modal);
067: initComponents();
068:
069: setTitle(title);
070:
071: if (file != null && file.exists())
072: locationChooser.setCurrentDirectory(file);
073: }
074:
075: public File getFolderLocation() {
076: return locationChooser.getSelectedFile();
077: }
078:
079: public void setFolderLocation(String val) {
080: setFolderLocation(new File(val));
081: }
082:
083: public void setFolderLocation(File val) {
084: locationChooser.setSelectedFile(val);
085: }
086:
087: /** This method is called from within the constructor to
088: * initialize the form.
089: * WARNING: Do NOT modify this code. The content of this method is
090: * always regenerated by the Form Editor.
091: */
092: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
093: private void initComponents() {
094: locationChooser = new javax.swing.JFileChooser();
095:
096: setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
097: setTitle("Choose Folder Location to Export Code");
098: locationChooser.setAcceptAllFileFilterUsed(false);
099: locationChooser.setApproveButtonMnemonic(2);
100: locationChooser
101: .setApproveButtonText(java.util.ResourceBundle
102: .getBundle(
103: "org/netbeans/modules/uml/integration/netbeans/actions/ui/Bundle")
104: .getString("LBL_BrowseDialogApproveButton"));
105: locationChooser
106: .setApproveButtonToolTipText(java.util.ResourceBundle
107: .getBundle(
108: "org/netbeans/modules/uml/integration/netbeans/actions/ui/Bundle")
109: .getString("LBL_OpenButton_Tooltip"));
110: locationChooser
111: .setDialogTitle(java.util.ResourceBundle
112: .getBundle(
113: "org/netbeans/modules/uml/integration/netbeans/actions/ui/Bundle")
114: .getString("LBL_ChooseLocationDialog_Title"));
115: locationChooser.setFileHidingEnabled(true);
116: locationChooser
117: .setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
118: locationChooser.setBorder(null);
119: locationChooser
120: .addActionListener(new java.awt.event.ActionListener() {
121: public void actionPerformed(
122: java.awt.event.ActionEvent evt) {
123: locationChooserActionPerformed(evt);
124: }
125: });
126:
127: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
128: getContentPane());
129: getContentPane().setLayout(layout);
130: layout.setHorizontalGroup(layout.createParallelGroup(
131: org.jdesktop.layout.GroupLayout.LEADING).add(
132: layout.createSequentialGroup().addContainerGap().add(
133: locationChooser,
134: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
135: 501, Short.MAX_VALUE).addContainerGap()));
136: layout.setVerticalGroup(layout.createParallelGroup(
137: org.jdesktop.layout.GroupLayout.LEADING).add(
138: org.jdesktop.layout.GroupLayout.TRAILING,
139: layout.createSequentialGroup().addContainerGap().add(
140: locationChooser,
141: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
142: 363, Short.MAX_VALUE).addContainerGap()));
143: pack();
144: }// </editor-fold>//GEN-END:initComponents
145:
146: private void locationChooserActionPerformed(
147: java.awt.event.ActionEvent evt)//GEN-FIRST:event_locationChooserActionPerformed
148: {//GEN-HEADEREND:event_locationChooserActionPerformed
149: setVisible(false);
150: }//GEN-LAST:event_locationChooserActionPerformed
151:
152: /**
153: * @param args the command line arguments
154: */
155: public static void main(String args[]) {
156: java.awt.EventQueue.invokeLater(new Runnable() {
157: public void run() {
158: new ChooseLocationDialog(new javax.swing.JFrame(), true)
159: .setVisible(true);
160: }
161: });
162: }
163:
164: public javax.swing.JFileChooser getLocationChooser() {
165: return locationChooser;
166: }
167:
168: // Variables declaration - do not modify//GEN-BEGIN:variables
169: private javax.swing.JFileChooser locationChooser;
170: // End of variables declaration//GEN-END:variables
171:
172: }
|