package com.jbase.jbuilder5vcs;
// jBuilder import
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.XYConstraints;
// java import
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.SwingConstants;
import java.awt.event.ActionEvent;
/**
* Title: jBuilder/Perforce<br>
* Description: The panel will be integrate on jBuilder,<br>
* This is the swing panel with the basic configuration for <br>
* communicate with P4 (on local computer).<p>
* <DL><DT><b>Company:</b></DT><DD>jBase.</DD></DL>
* @author <a href="mailto:nicolasj@jbase.com">Nicolas Jorand</a>
* @version 1.0
* @since JDK 1.3
*/
public class ConfigPanel extends JPanel {
XYLayout xYLayout1 = new XYLayout();
JTextField txtClient = new JTextField();
JLabel lblClient = new JLabel();
JTextField txtUser = new JTextField();
JLabel lblUser = new JLabel();
JLabel lblPass = new JLabel();
JPasswordField txtPass = new JPasswordField();
JLabel lblPort = new JLabel();
JTextField txtPort = new JTextField();
JLabel lblHost = new JLabel();
JTextField txtHost = new JTextField();
JCheckBox chkDefaultHost = new JCheckBox();
public ConfigPanel() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
/**
* CLIENT Property
*/
public String getClient() {
return( txtClient.getText() );
}
public void setClient(String sClient) {
txtClient.setText(sClient);
}
/**
* USER Property
*/
public String getUser() {
return( txtUser.getText() );
}
public void setUser(String sUser) {
txtUser.setText(sUser);
}
/**
* PASSWORD Property
*/
public String getPassword() {
return(String.valueOf(txtPass.getPassword()));
}
public void setPassword(String sPass) {
txtPass.setText(sPass);
}
/**
* HOST Property
*/
public String getHost() {
return( txtHost.getText() );
}
public void setHost(String sHost) {
txtHost.setText(sHost);
}
/**
* PORT Property
*/
public String getPort() {
return( txtPort.getText() );
}
public void setPort(String sPort) {
txtPort.setText(sPort);
}
/**
* PORT DEFAULT Property
*/
public boolean getDefaultPort() {
return chkDefaultHost.isSelected();
}
public void setDefaultPort(boolean bDefault) {
chkDefaultHost.setSelected(bDefault);
txtHost.setEnabled(!bDefault);
txtPort.setEnabled(!bDefault);
}
/**
* Init of the class.<p>
* Place all component on the panel
*/
private void jbInit() throws Exception {
txtClient.setText("");
this.setLayout(xYLayout1);
lblClient.setHorizontalAlignment(SwingConstants.RIGHT);
lblClient.setHorizontalTextPosition(SwingConstants.LEADING);
lblClient.setText("Client :");
txtUser.setText("");
lblUser.setHorizontalAlignment(SwingConstants.RIGHT);
lblUser.setHorizontalTextPosition(SwingConstants.LEADING);
lblUser.setText("User :");
lblPass.setHorizontalAlignment(SwingConstants.RIGHT);
lblPass.setText("Password :");
txtPass.setText("");
txtPass.setColumns(15);
lblPort.setHorizontalAlignment(SwingConstants.CENTER);
lblPort.setText(":");
txtPort.setText("");
lblHost.setHorizontalAlignment(SwingConstants.RIGHT);
lblHost.setHorizontalTextPosition(SwingConstants.RIGHT);
lblHost.setText("Host :");
chkDefaultHost.setText("Default");
chkDefaultHost.setToolTipText("");
chkDefaultHost.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
chkDefaultHost_actionPerformed(e);
}
});
this.add(lblHost, new XYConstraints(41, 50, 37, 21));
this.add(txtHost, new XYConstraints(84, 50, 168, 21));
this.add(lblPort, new XYConstraints(253, 50, 10, 21));
this.add(txtPort, new XYConstraints(264, 50, 60, 21));
this.add(lblClient, new XYConstraints(40, 78, -1, 21));
this.add(txtClient, new XYConstraints(84, 78, 168, -1));
this.add(txtUser, new XYConstraints(84, 106, 168, -1));
this.add(lblUser, new XYConstraints(45, 106, -1, 21));
this.add(lblPass, new XYConstraints(14, 135, -1, 21));
this.add(txtPass, new XYConstraints(84, 135, 168, -1));
this.add(chkDefaultHost, new XYConstraints(328, 51, 68, 18));
this.setVisible(true);
}
void chkDefaultHost_actionPerformed(ActionEvent e) {
txtHost.setEnabled(!chkDefaultHost.isSelected());
txtPort.setEnabled(!chkDefaultHost.isSelected());
}
}