package com.jbase.jbuilder5vcs; import javax.swing.*; import java.awt.Rectangle; import java.awt.Frame; import java.awt.Dimension; import java.awt.event.*; import java.awt.Component; /** * Title: JBuilder/Perforce * Description: Integration of Perforce on jBuilder, This is the dialog for enter * some information for the synchronize. * Copyright: Copyright (c) 2001 * Company: jBase * @author <a href="mailto:nicolasj@jbase.com">Nicolas Jorand</a> * @version beta 1 * @since JDK 1.3 */ public class P4SyncPanel extends JDialog { private static P4SyncPanel dialog; private static String value = ""; private static String OPT_REVISION_LABEL = "Revision number"; private static String OPT_OTHER_LABEL = "Other"; JRadioButton optRevision = new JRadioButton(); JRadioButton optOther = new JRadioButton(); JTextField txtRevisionNumber = new JTextField(); JTextField txtOther = new JTextField(); ButtonGroup grpOption = new ButtonGroup(); JLabel lblOtherComment = new JLabel(); final JButton btnOK = new JButton(); JButton btnCancel = new JButton(); public P4SyncPanel(Frame owner) { super(owner,"Title",true); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { P4SyncPanel.initialize(null); String selectedName = P4SyncPanel.showDialog(null); System.out.println(selectedName); System.exit(0); } public static void initialize(Component comp) { Frame frame = JOptionPane.getFrameForComponent(comp); dialog = new P4SyncPanel(frame); } public static String showDialog(Component comp) { if (dialog != null) { dialog.setValue(""); dialog.setLocationRelativeTo(comp); dialog.setVisible(true); } else { System.err.println("ListDialog requires you to call initialize " + "before calling showDialog."); } return value; } private void setValue(String newValue) { value = newValue; } private void jbInit() throws Exception { // Set the option for the revision number optRevision.setText(OPT_REVISION_LABEL); optRevision.setBounds(new Rectangle(38, 29, 121, 27)); optRevision.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { optRevision_actionPerformed(e); } }); // Set the option for the Other option optOther.setText(OPT_OTHER_LABEL); optOther.setBounds(new Rectangle(38, 53, 56, 25)); optOther.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { optOther_actionPerformed(e); } }); // Set the textbox txtRevisionNumber.setBounds(new Rectangle(165, 33, 63, 18)); txtOther.setBounds(new Rectangle(102, 56, 393, 18)); // Add the closing window this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); lblOtherComment.setText(""); lblOtherComment.setBounds(new Rectangle(100, 73, 409, 24)); btnOK.setSelected(true); btnOK.setText("OK"); btnOK.setBounds(new Rectangle(85, 128, 119, 25)); btnOK.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnOK_actionPerformed(e); } }); getRootPane().setDefaultButton(btnOK); btnCancel.setText("Cancel"); btnCancel.setBounds(new Rectangle(366, 128, 119, 25)); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnCancel_actionPerformed(e); } }); this.addWindowListener(new java.awt.event.WindowAdapter() { public void windowActivated(WindowEvent e) { this_windowActivated(e); } }); this.getContentPane().add(optRevision, null); this.getContentPane().add(optOther, null); this.getContentPane().add(txtRevisionNumber, null); this.getContentPane().add(txtOther, null); this.getContentPane().add(lblOtherComment, null); this.getContentPane().add(btnOK, null); this.getContentPane().add(btnCancel, null); this.getContentPane().setLayout(null); this.setSize(545,195); grpOption.add(optOther); grpOption.add(optRevision); optRevision.setSelected(true); txtOther.setEnabled(false); this.setResizable(false); } void optRevision_actionPerformed(ActionEvent e) { // Set the text box revision enable and disable the Other textbox txtRevisionNumber.setEnabled(true); txtRevisionNumber.requestFocus(); txtOther.setEnabled(false); } void optOther_actionPerformed(ActionEvent e) { // Set the text box revision enable and disable the Other textbox txtRevisionNumber.setEnabled(false); txtOther.setEnabled(true); txtOther.requestFocus(); } void btnOK_actionPerformed(ActionEvent e) { if (optRevision.isSelected() && !txtRevisionNumber.getText().equalsIgnoreCase("")){ P4SyncPanel.value = "#"+txtRevisionNumber.getText(); }else if (optOther.isSelected() && !txtOther.getText().equalsIgnoreCase("")){ P4SyncPanel.value = "@"+txtOther.getText(); }else{ P4SyncPanel.value = ""; } P4SyncPanel.dialog.setVisible(false); } void btnCancel_actionPerformed(ActionEvent e) { txtRevisionNumber.requestFocus(); P4SyncPanel.dialog.setVisible(false); } void this_windowActivated(WindowEvent e) { txtRevisionNumber.requestFocus(); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 1072 | rmg |
Integrate the "jBuilder5VCS" frmo Nicolas Jorand into //public; Plan is to add some top-level documentation before linking it into the "roadmap", or making any sort of general public announcement. |
||
//guest/nicolas_jorand/jBuilder5VCS/src/com/jbase/jbuilder5vcs/P4SyncPanel.java | |||||
#1 | 939 | nicolas_jorand | First input of perforce integration for jBuilder5 |