1 20 21 package net.java.dev.cvsrootselector; 22 23 import java.awt.event.ActionEvent ; 24 import java.awt.event.ActionListener ; 25 import java.io.File ; 26 import java.io.IOException ; 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 { 32 private final File file; 33 private final String originalRoot; 34 private boolean ok; 35 36 public CvsRootSelectorPanel(File file) throws IOException { 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 52 private void initComponents() { 54 java.awt.GridBagConstraints gridBagConstraints; 55 56 workDirLabel = new javax.swing.JLabel (); 57 workDir = new javax.swing.JLabel (); 58 rootLabel = new javax.swing.JLabel (); 59 root = new javax.swing.JTextField (); 60 61 setLayout(new java.awt.GridBagLayout ()); 62 63 setBorder(javax.swing.BorderFactory.createEmptyBorder(12, 12, 0, 12)); 64 workDirLabel.setText("Working Directory:"); 65 gridBagConstraints = new java.awt.GridBagConstraints (); 66 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; 67 gridBagConstraints.gridheight = java.awt.GridBagConstraints.RELATIVE; 68 gridBagConstraints.insets = new java.awt.Insets (0, 0, 3, 3); 69 add(workDirLabel, gridBagConstraints); 70 71 workDir.setText("aDir"); 72 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (0, 3, 3, 0); 77 add(workDir, gridBagConstraints); 78 79 rootLabel.setText("CVS/Root:"); 80 gridBagConstraints = new java.awt.GridBagConstraints (); 81 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 82 gridBagConstraints.insets = new java.awt.Insets (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 (); 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 (3, 3, 0, 0); 92 add(root, gridBagConstraints); 93 94 } 96 public javax.swing.JTextField root; 98 public javax.swing.JLabel rootLabel; 99 public javax.swing.JLabel workDir; 100 public javax.swing.JLabel workDirLabel; 101 103 public void display() { 104 DialogDescriptor descriptor = new DialogDescriptor( 105 this, "Change CVS Root"); 106 descriptor.setButtonListener(new ActionListener () { 107 public void actionPerformed(ActionEvent 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 () { 118 public void run() { 119 new CvsRootRewriter(file, root.getText().trim()).rewrite(); 120 } 121 }); 122 } 123 } | Popular Tags |