KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > java > dev > cvsrootselector > CvsRootSelectorPanel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is the CVSROOT Selector (RFE #65366).
16  * The Initial Developer of the Original Software is Michael Nascimento Santos.
17  * Portions created by Michael Nascimento Santos are Copyright (C) 2005.
18  * All Rights Reserved.
19  */

20
21 package net.java.dev.cvsrootselector;
22
23 import java.awt.event.ActionEvent JavaDoc;
24 import java.awt.event.ActionListener JavaDoc;
25 import java.io.File JavaDoc;
26 import java.io.IOException JavaDoc;
27 import org.openide.DialogDescriptor;
28 import org.openide.DialogDisplayer;
29 import org.openide.util.RequestProcessor;
30
31 public class CvsRootSelectorPanel extends javax.swing.JPanel JavaDoc {
32     private final File JavaDoc file;
33     private final String JavaDoc originalRoot;
34     private boolean ok;
35
36     public CvsRootSelectorPanel(File JavaDoc file) throws IOException JavaDoc {
37         this.file = file;
38         
39         initComponents();
40         
41         workDir.setText(file.getAbsolutePath());
42         
43         originalRoot = CvsRootRewriter.getCvsRoot(file);
44         root.setText(originalRoot);
45     }
46     
47     /** This method is called from within the constructor to
48      * initialize the form.
49      * WARNING: Do NOT modify this code. The content of this method is
50      * always regenerated by the Form Editor.
51      */

52     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
53
private void initComponents() {
54         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
55
56         workDirLabel = new javax.swing.JLabel JavaDoc();
57         workDir = new javax.swing.JLabel JavaDoc();
58         rootLabel = new javax.swing.JLabel JavaDoc();
59         root = new javax.swing.JTextField JavaDoc();
60
61         setLayout(new java.awt.GridBagLayout JavaDoc());
62
63         setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 0, 12));
64         workDirLabel.setText("Working Directory:");
65         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
66         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE;
67         gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
68         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 3, 3);
69         add(workDirLabel, gridBagConstraints);
70
71         workDir.setText("aDir");
72         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
73         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
74         gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE;
75         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
76         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 3, 3, 0);
77         add(workDir, gridBagConstraints);
78
79         rootLabel.setText("CVS/Root:");
80         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
81         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
82         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 0, 0, 3);
83         add(rootLabel, gridBagConstraints);
84
85         root.setColumns(45);
86         root.setText(":pserver:user@server.com:/path");
87         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
88         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
89         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
90         gridBagConstraints.weightx = 1.0;
91         gridBagConstraints.insets = new java.awt.Insets JavaDoc(3, 3, 0, 0);
92         add(root, gridBagConstraints);
93
94     }// </editor-fold>//GEN-END:initComponents
95

96     // Variables declaration - do not modify//GEN-BEGIN:variables
97
public javax.swing.JTextField JavaDoc root;
98     public javax.swing.JLabel JavaDoc rootLabel;
99     public javax.swing.JLabel JavaDoc workDir;
100     public javax.swing.JLabel JavaDoc workDirLabel;
101     // End of variables declaration//GEN-END:variables
102

103     public void display() {
104         DialogDescriptor descriptor = new DialogDescriptor(
105                 this, "Change CVS Root");
106         descriptor.setButtonListener(new ActionListener JavaDoc() {
107             public void actionPerformed(ActionEvent JavaDoc e) {
108                 ok = e.getSource() == DialogDescriptor.OK_OPTION;
109             }
110         });
111         DialogDisplayer.getDefault().createDialog(descriptor).setVisible(true);
112         
113         if (!ok) {
114             return;
115         }
116         
117         RequestProcessor.getDefault().post(new Runnable JavaDoc() {
118             public void run() {
119                 new CvsRootRewriter(file, root.getText().trim()).rewrite();
120             }
121         });
122     }
123 }
Popular Tags