cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
iauser85
Level 2

CustomCodePanel

Hi,

I am trying to create a CustomCodePanel but I am having trouble with it appearing during the installation. Here is my code:

[CODE]package package3;

import java.awt.*;
import javax.swing.*;
import com.zerog.ia.api.pub.CustomCodePanel;
import com.zerog.ia.api.pub.CustomCodePanelProxy;
import javax.swing.JPasswordField;
import java.awt.Dimension;


public class ConfigurationPanel extends CustomCodePanel {

private static final long serialVersionUID = 1L;
private JLabel instructions = null;
private JLabel masterPWlabel = null;
private JPasswordField masterPWtxt = null;
private JLabel syscopyPortlabel = null;
private JTextField syscopyPorttxt = null;
private JLabel databaseTypelabel = null;
private Choice databaseTypeList = null;
private JLabel DBPortlabel = null;
private JTextField DBPorttxt = null;
private JLabel DBUsernamelabel = null;
private JTextField DBUsernametxt = null;
private JLabel DBPWlabel = null;
private JPasswordField DBPWtxt = null;
private boolean isSetup=false;

/**
* This is the default constructor
*/
public ConfigurationPanel() {
super();
//setupUI(customCodePanelProxy);
}


public boolean setupUI(CustomCodePanelProxy arg0) {

if (isSetup){
removeAll();
}
customCodePanelProxy = arg0;
initialize();
isSetup=true;
return true;
}

public void initialize(){
DBPWlabel = new JLabel();
DBPWlabel.setBounds(new Rectangle(15, 216, 170, 20));
DBPWlabel.setText("DB Password:");
DBUsernamelabel = new JLabel();
DBUsernamelabel.setBounds(new Rectangle(15, 184, 170, 20));
DBUsernamelabel.setText("DB Username:");
DBPortlabel = new JLabel();
DBPortlabel.setBounds(new Rectangle(15, 153, 170, 20));
DBPortlabel.setText("DB Port :");
databaseTypelabel = new JLabel();
databaseTypelabel.setBounds(new Rectangle(15, 125, 170, 20));
databaseTypelabel.setText("Database Type:");
syscopyPortlabel = new JLabel();
syscopyPortlabel.setBounds(new Rectangle(15, 95, 170, 20));
syscopyPortlabel.setText("Syscopy Port:");
masterPWlabel = new JLabel();
masterPWlabel.setBounds(new Rectangle(15, 65, 170, 20));
masterPWlabel.setText("Master Syscopy Password:");
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
instructions = new JLabel();
instructions.setText("Please specify configuration details for Syscopy.");
instructions.setBounds(new Rectangle(15, 14, 292, 31));
this.setSize(new Dimension(426, 310));
this.setLayout(null);
this.add(instructions);
this.add(masterPWlabel, null);
this.add(getMasterPWtxt(), null);
this.add(syscopyPortlabel, null);
this.add(getSyscopyPorttxt(), null);
this.add(databaseTypelabel, null);
this.add(getDatabaseTypeList(), null);
this.add(DBPortlabel, null);
this.add(getDBPorttxt(), null);
this.add(DBUsernamelabel, null);
this.add(getDBUsernametxt(), null);
this.add(DBPWlabel, null);
this.add(getDBPWtxt(),null);

}

public String getTitle(){
return "Configuration";// customCodePanelProxy.substitute("$PROGRAM_NAME$")+ " - Configuration";
}

public boolean okToContinue(){

/*customCodePanelProxy.setVariable("$USER_MASTER_PASSWORD$", masterPWtxt.getPassword());
customCodePanelProxy.setVariable("$USER_SYSCOPY_PORT_1$", syscopyPorttxt.getText());
customCodePanelProxy.setVariable("$USER_DB_Type$", databaseTypeList.getSelectedItem());
customCodePanelProxy.setVariable("$USER_DB_PORT$", DBPorttxt.getText());
customCodePanelProxy.setVariable("$USER_DB_USERNAME$", DBUsernametxt.getText());
customCodePanelProxy.setVariable("$USER_DB_PASSWORD$", DBPWtxt.getPassword());
*/
return true;
}

/**
* This method initializes masterPWtxt
*
* @return javax.swing.JTextField
*/
private JPasswordField getMasterPWtxt() {
if (masterPWtxt == null) {
masterPWtxt = new JPasswordField();
masterPWtxt.setBounds(new Rectangle(200, 66, 150, 20));
}
return masterPWtxt;
}

/**
* This method initializes syscopyPorttxt
*
* @return javax.swing.JTextField
*/
private JTextField getSyscopyPorttxt() {
if (syscopyPorttxt == null) {
syscopyPorttxt = new JTextField();
syscopyPorttxt.setBounds(new Rectangle(200, 96, 150, 20));
}
return syscopyPorttxt;
}

/**
* This method initializes databaseTypeList
*
* @return javax.swing.JList
*/
private Choice getDatabaseTypeList() {
if (databaseTypeList == null) {
databaseTypeList = new Choice();
databaseTypeList.setVisible(true);
databaseTypeList.setBounds(new Rectangle(200, 124, 150, 20));
databaseTypeList.add("MySQL");
databaseTypeList.add("MS SQL");
databaseTypeList.add("Oracle");
}
return databaseTypeList;
}

/**
* This method initializes DBPorttxt
*
* @return javax.swing.JTextField
*/
private JTextField getDBPorttxt() {
if (DBPorttxt == null) {
DBPorttxt = new JTextField(this.getClass().getName());
DBPorttxt.setBounds(new Rectangle(200, 154, 150, 20));
}
return DBPorttxt;
}

/**
* This method initializes DBUsernametxt
*
* @return javax.swing.JTextField
*/
private JTextField getDBUsernametxt() {
if (DBUsernametxt == null) {
DBUsernametxt = new JTextField();
DBUsernametxt.setBounds(new Rectangle(200, 185, 150, 20));
}
return DBUsernametxt;
}

/**
* This method initializes DBPWtxt
*
* @return javax.swing.JPasswordField
*/
private JPasswordField getDBPWtxt() {
if (DBPWtxt == null) {
DBPWtxt = new JPasswordField();
DBPWtxt.setBounds(new Rectangle(200, 217, 150, 20));
}
return DBPWtxt;
}


/*public void main(String[] args){
this.setupUI(customCodePanelProxy);
}
*/

}
[/CODE]

I created a jar file from eclipse and linked it in IA through Execute Custom Code. I stated that the full class name is package3.ConfigurationPanel. I followed the instructions displayed on: http://www.acresso.com/webdocuments/PDF/ia_create_cust_code_panel_eclipse.pdf.

I noticed that for some reason, all the CustomCodeAction classes are working, but when I want to create a panel, it doesnt show up.

Can anyone tell me what I'm doing wrong..

Thanks in advance.
Labels (1)
0 Kudos
(3) Replies
qqqqqq
Level 7

what is the exception coming.. ?
0 Kudos
MEinstaller
Level 7

CustomCodePanels in IA use a layout manager. Most of the examples I have seen and panels I have created have used the GridBag Layout, without a layout manager I was never able to get any panels to show up either.
0 Kudos
nosrednayduj
Level 7

I'm writing my first custom code panel, and wondering where you got all those numbers from to decide on sizes. I tried them (specifically the width of 426) and my text is truncated at the edge of the window, so it's obviously too wide. I changed a Jlabel to a JTextArea so it would word wrap and such. Experimentation reveals that 375 gives good results.

It would be nicer not to have explicit numbers, of course. Where might I find constants?
0 Kudos