Source Code Cross Referenced for ClonePanel.java in  » IDE-Netbeans » mercurial » org » netbeans » modules » mercurial » ui » clone » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » mercurial » org.netbeans.modules.mercurial.ui.clone 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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:        package org.netbeans.modules.mercurial.ui.clone;
042:
043:        import java.io.File;
044:        import java.util.Set;
045:        import java.util.Vector;
046:        import java.util.LinkedHashSet;
047:        import javax.swing.SwingUtilities;
048:        import javax.swing.ComboBoxModel;
049:        import javax.swing.DefaultComboBoxModel;
050:        import java.awt.event.ActionEvent;
051:        import java.awt.event.ActionListener;
052:        import javax.swing.JFileChooser;
053:        import javax.swing.filechooser.FileFilter;
054:        import org.openide.util.NbBundle;
055:        import org.netbeans.modules.versioning.util.AccessibleJFileChooser;
056:        import org.netbeans.spi.project.ui.support.ProjectChooser;
057:        import org.netbeans.modules.mercurial.HgModuleConfig;
058:
059:        /**
060:         *
061:         * @author  Padraig O'Briain
062:         */
063:        public class ClonePanel extends javax.swing.JPanel implements 
064:                ActionListener {
065:
066:            private File repository;
067:
068:            /** Creates new form ClonePanel */
069:            public ClonePanel(File repo, File to) {
070:                repository = repo;
071:                initComponents();
072:                browseButton.addActionListener(this );
073:                setMainCheckBox.addActionListener(this );
074:                fromTextField.setText(repo.getAbsolutePath());
075:                toTextField.setText(to.getParent());
076:                toCloneField.setText(to.getName());
077:                setMainCheckBox.setSelected(HgModuleConfig.getDefault()
078:                        .getSetMainProject());
079:            }
080:
081:            public String getOutputFileName() {
082:                File target = new File(toTextField.getText(), toCloneField
083:                        .getText());
084:                return target.getAbsolutePath();
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:
095:                fromLabel = new javax.swing.JLabel();
096:                toLabel = new javax.swing.JLabel();
097:                browseButton = new javax.swing.JButton();
098:                fromTextField = new javax.swing.JTextField();
099:                toNameLabel = new javax.swing.JLabel();
100:                toCloneField = new javax.swing.JTextField();
101:                destinationLabel = new javax.swing.JLabel();
102:                setMainCheckBox = new javax.swing.JCheckBox();
103:
104:                fromLabel.setLabelFor(fromTextField);
105:                org.openide.awt.Mnemonics.setLocalizedText(fromLabel,
106:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
107:                                "ClonePanel.fromLabel.text")); // NOI18N
108:
109:                toLabel.setLabelFor(toTextField);
110:                org.openide.awt.Mnemonics.setLocalizedText(toLabel,
111:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
112:                                "ClonePanel.toLabel.text")); // NOI18N
113:
114:                org.openide.awt.Mnemonics.setLocalizedText(browseButton,
115:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
116:                                "ClonePanel.browseButton.text")); // NOI18N
117:
118:                fromTextField.setEditable(false);
119:
120:                toNameLabel.setLabelFor(toCloneField);
121:                org.openide.awt.Mnemonics.setLocalizedText(toNameLabel,
122:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
123:                                "ClonePanel.toName.text")); // NOI18N
124:
125:                org.openide.awt.Mnemonics.setLocalizedText(destinationLabel,
126:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
127:                                "destinationLabel.text")); // NOI18N
128:
129:                org.openide.awt.Mnemonics.setLocalizedText(setMainCheckBox,
130:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
131:                                "openCheckbox.text")); // NOI18N
132:
133:                org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
134:                        this );
135:                this .setLayout(layout);
136:                layout
137:                        .setHorizontalGroup(layout
138:                                .createParallelGroup(
139:                                        org.jdesktop.layout.GroupLayout.LEADING)
140:                                .add(
141:                                        layout
142:                                                .createSequentialGroup()
143:                                                .addContainerGap()
144:                                                .add(
145:                                                        layout
146:                                                                .createParallelGroup(
147:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
148:                                                                .add(
149:                                                                        destinationLabel)
150:                                                                .add(fromLabel)
151:                                                                .add(
152:                                                                        layout
153:                                                                                .createSequentialGroup()
154:                                                                                .add(
155:                                                                                        12,
156:                                                                                        12,
157:                                                                                        12)
158:                                                                                .add(
159:                                                                                        layout
160:                                                                                                .createParallelGroup(
161:                                                                                                        org.jdesktop.layout.GroupLayout.LEADING)
162:                                                                                                .add(
163:                                                                                                        toNameLabel)
164:                                                                                                .add(
165:                                                                                                        setMainCheckBox)))
166:                                                                .add(
167:                                                                        layout
168:                                                                                .createSequentialGroup()
169:                                                                                .add(
170:                                                                                        12,
171:                                                                                        12,
172:                                                                                        12)
173:                                                                                .add(
174:                                                                                        toLabel)))
175:                                                .addPreferredGap(
176:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
177:                                                .add(
178:                                                        layout
179:                                                                .createParallelGroup(
180:                                                                        org.jdesktop.layout.GroupLayout.LEADING)
181:                                                                .add(
182:                                                                        fromTextField,
183:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
184:                                                                        258,
185:                                                                        Short.MAX_VALUE)
186:                                                                .add(
187:                                                                        org.jdesktop.layout.GroupLayout.TRAILING,
188:                                                                        layout
189:                                                                                .createSequentialGroup()
190:                                                                                .add(
191:                                                                                        layout
192:                                                                                                .createParallelGroup(
193:                                                                                                        org.jdesktop.layout.GroupLayout.TRAILING)
194:                                                                                                .add(
195:                                                                                                        toCloneField,
196:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
197:                                                                                                        165,
198:                                                                                                        Short.MAX_VALUE)
199:                                                                                                .add(
200:                                                                                                        toTextField,
201:                                                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
202:                                                                                                        165,
203:                                                                                                        Short.MAX_VALUE))
204:                                                                                .addPreferredGap(
205:                                                                                        org.jdesktop.layout.LayoutStyle.RELATED)
206:                                                                                .add(
207:                                                                                        browseButton)))
208:                                                .addContainerGap()));
209:                layout
210:                        .setVerticalGroup(layout
211:                                .createParallelGroup(
212:                                        org.jdesktop.layout.GroupLayout.LEADING)
213:                                .add(
214:                                        layout
215:                                                .createSequentialGroup()
216:                                                .addContainerGap()
217:                                                .add(
218:                                                        layout
219:                                                                .createParallelGroup(
220:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
221:                                                                .add(fromLabel)
222:                                                                .add(
223:                                                                        fromTextField,
224:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
225:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
226:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
227:                                                .add(18, 18, 18)
228:                                                .add(destinationLabel)
229:                                                .addPreferredGap(
230:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
231:                                                .add(
232:                                                        layout
233:                                                                .createParallelGroup(
234:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
235:                                                                .add(
236:                                                                        browseButton)
237:                                                                .add(
238:                                                                        toTextField,
239:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
240:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
241:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
242:                                                                .add(toLabel))
243:                                                .addPreferredGap(
244:                                                        org.jdesktop.layout.LayoutStyle.RELATED,
245:                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
246:                                                        Short.MAX_VALUE)
247:                                                .add(
248:                                                        layout
249:                                                                .createParallelGroup(
250:                                                                        org.jdesktop.layout.GroupLayout.BASELINE)
251:                                                                .add(
252:                                                                        toCloneField,
253:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
254:                                                                        org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
255:                                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
256:                                                                .add(
257:                                                                        toNameLabel))
258:                                                .addPreferredGap(
259:                                                        org.jdesktop.layout.LayoutStyle.RELATED)
260:                                                .add(
261:                                                        setMainCheckBox,
262:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
263:                                                        21,
264:                                                        org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
265:                                                .addContainerGap()));
266:
267:                toTextField.getAccessibleContext().setAccessibleDescription(
268:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
269:                                "ACSD_toTextField")); // NOI18N
270:                browseButton.getAccessibleContext().setAccessibleDescription(
271:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
272:                                "ACSD_Browse")); // NOI18N
273:                fromTextField.getAccessibleContext().setAccessibleDescription(
274:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
275:                                "ACSD_fromTextField")); // NOI18N
276:                toCloneField.getAccessibleContext().setAccessibleDescription(
277:                        org.openide.util.NbBundle.getMessage(ClonePanel.class,
278:                                "ACSD_toCloneField")); // NOI18N
279:                setMainCheckBox.getAccessibleContext()
280:                        .setAccessibleDescription(
281:                                org.openide.util.NbBundle.getMessage(
282:                                        ClonePanel.class,
283:                                        "ACSD_setMainCheckBox")); // NOI18N
284:            }// </editor-fold>//GEN-END:initComponents
285:
286:            public void actionPerformed(ActionEvent evt) {
287:                if (evt.getSource() == browseButton) {
288:                    onBrowseClick();
289:                } else if (evt.getSource() == setMainCheckBox) {
290:                    HgModuleConfig.getDefault().setSetMainProject(
291:                            setMainCheckBox.isSelected());
292:                }
293:            }
294:
295:            private void onBrowseClick() {
296:                File oldFile = defaultWorkingDirectory();
297:                JFileChooser fileChooser = new AccessibleJFileChooser(NbBundle
298:                        .getMessage(ClonePanel.class, "ACSD_BrowseFolder"),
299:                        oldFile); // NO I18N
300:                fileChooser.setDialogTitle(NbBundle.getMessage(
301:                        ClonePanel.class, "Browse_title")); // NO I18N
302:                fileChooser.setMultiSelectionEnabled(false);
303:                FileFilter[] old = fileChooser.getChoosableFileFilters();
304:                for (int i = 0; i < old.length; i++) {
305:                    FileFilter fileFilter = old[i];
306:                    fileChooser.removeChoosableFileFilter(fileFilter);
307:
308:                }
309:                fileChooser.addChoosableFileFilter(new FileFilter() {
310:                    public boolean accept(File f) {
311:                        return f.isDirectory();
312:                    }
313:
314:                    public String getDescription() {
315:                        return NbBundle.getMessage(ClonePanel.class, "Folders");// NOI18N
316:                    }
317:                });
318:                fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
319:                fileChooser.showDialog(this , NbBundle.getMessage(
320:                        ClonePanel.class, "OK_Button")); // NO I18N
321:                File f = fileChooser.getSelectedFile();
322:                if (f != null) {
323:                    toTextField.setText(f.getAbsolutePath());
324:                }
325:            }
326:
327:            /**
328:             * Returns file to be initally used.
329:             * <ul>
330:             * <li>first is takes text in workTextField
331:             * <li>then recent project folder
332:             * <li>finally <tt>user.home</tt>
333:             * <ul>
334:             */
335:            private File defaultWorkingDirectory() {
336:                File defaultDir = null;
337:                String current = toTextField.getText();
338:                if (current != null && !(current.trim().equals(""))) { // NOI18N
339:                    File currentFile = new File(current);
340:                    while (currentFile != null && currentFile.exists() == false) {
341:                        currentFile = currentFile.getParentFile();
342:                    }
343:                    if (currentFile != null) {
344:                        if (currentFile.isFile()) {
345:                            defaultDir = currentFile.getParentFile();
346:                        } else {
347:                            defaultDir = currentFile;
348:                        }
349:                    }
350:                }
351:
352:                if (defaultDir == null) {
353:                    File projectFolder = ProjectChooser.getProjectsFolder();
354:                    if (projectFolder.exists() && projectFolder.isDirectory()) {
355:                        defaultDir = projectFolder;
356:                    }
357:
358:                }
359:
360:                if (defaultDir == null) {
361:                    defaultDir = new File(System.getProperty("user.home")); // NOI18N
362:                }
363:
364:                return defaultDir;
365:            }
366:
367:            // Variables declaration - do not modify//GEN-BEGIN:variables
368:            private javax.swing.JButton browseButton;
369:            private javax.swing.JLabel destinationLabel;
370:            private javax.swing.JLabel fromLabel;
371:            private javax.swing.JTextField fromTextField;
372:            private javax.swing.JCheckBox setMainCheckBox;
373:            private javax.swing.JTextField toCloneField;
374:            private javax.swing.JLabel toLabel;
375:            private javax.swing.JLabel toNameLabel;
376:            final javax.swing.JTextField toTextField = new javax.swing.JTextField();
377:            // End of variables declaration//GEN-END:variables
378:
379:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.