wizardpane2.java
来自「开源的axis2框架的源码。用于开发WEBSERVER」· Java 代码 · 共 542 行 · 第 1/2 页
JAVA
542 行
if (loadVals) {
this.classFileNameTextBox.setText(
myBean.getAutomaticClassName());
this.providerClassNameTextBox.setText(
myBean.getProviderClassName());
}
}
private void init() {
this.setLayout(null);
this.setSize(width, 100);
this.classFileListLable = new JLabel("Class Name");
this.add(this.classFileListLable);
this.classFileListLable.setBounds(hgap,
vgap,
Constants.UIConstants.LABEL_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.classFileNameTextBox = new JTextField();
this.add(this.classFileNameTextBox);
this.classFileNameTextBox.setBounds(
Constants.UIConstants.LABEL_WIDTH + 2 * hgap,
vgap,
Constants.UIConstants.TEXT_BOX_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.classFileNameTextBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setClassName();
}
});
this.classFileNameTextBox.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
setClassName();
}
});
this.providerClassLable = new JLabel("Provider Class Name");
this.add(this.providerClassLable);
this.providerClassLable.setBounds(hgap,
(Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap),
Constants.UIConstants.LABEL_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.providerClassNameTextBox = new JTextField();
this.add(this.providerClassNameTextBox);
this.providerClassNameTextBox.setBounds(
Constants.UIConstants.LABEL_WIDTH + 2 * hgap,
(Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap * 2),
Constants.UIConstants.TEXT_BOX_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.providerClassNameTextBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setProviderClassName();
}
});
this.providerClassNameTextBox.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
}
public void keyReleased(KeyEvent e) {
setProviderClassName();
}
});
this.loadButton = new JButton("Load");
this.add(this.loadButton);
this.loadButton.setBounds(hgap, (Constants.UIConstants.GENERAL_COMP_HEIGHT +
vgap) *
2 +
vgap,
Constants.UIConstants.GENERAL_BUTTON_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.loadButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadAllMethods();
}
});
loadButton.setEnabled(false);
this.advancedButton = new JButton("Advanced");
this.add(this.advancedButton);
this.advancedButton.setBounds(
2 * hgap + Constants.UIConstants.GENERAL_BUTTON_WIDTH
, (Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap) * 2 +
vgap,
Constants.UIConstants.GENERAL_BUTTON_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.advancedButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
openDialog();
}
});
this.advancedButton.setEnabled(false);
}
private void loadAllMethods() {
try {
ArrayList methodList = new Controller().getMethodList(
parentBean);
myBean.setSelectedMethodNames(methodList);
loadButton.setEnabled(false);
advancedButton.setEnabled(true);
} catch (ProcessException e) {
showErrorMessage(e.getMessage());
}
}
private void openDialog() {
try {
new AdvancedSelectionDialog().show();
} catch (ProcessException e) {
showErrorMessage(e.getMessage());
}
}
private void setClassName() {
loadButton.setEnabled(true);
advancedButton.setEnabled(false);
myBean.setAutomaticClassName(classFileNameTextBox.getText());
}
private void setProviderClassName() {
//loadButton.setEnabled(true);
//advancedButton.setEnabled(false);
myBean.setProviderClassName(providerClassNameTextBox.getText());
}
}
private class AdvancedSelectionDialog extends JDialog {
private JPanel lablePanel;
private JButton okButton;
private JButton cancelButton;
private boolean[] selectedValues;
private ArrayList completeMethodList;
public AdvancedSelectionDialog() throws HeadlessException,
ProcessException {
super();
super.setModal(true);
super.setTitle("Select Methods");
this.getContentPane().setLayout(null);
init();
}
private void init() throws ProcessException {
//load the class file list
this.completeMethodList =
new Controller().getMethodList(parentBean);
int methodCount = this.completeMethodList.size();
int panelHeight = methodCount *
(Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap);
this.lablePanel = new JPanel();
this.lablePanel.setLayout(null);
this.lablePanel.setBounds(0, 0, width, panelHeight);
this.getContentPane().add(this.lablePanel);
ArrayList currentSelectedList = myBean.getSelectedMethodNames();
//create check boxes for all the methods and add them to the panel
JCheckBox tempCheckBox;
boolean currentSelection;
this.selectedValues = new boolean[methodCount];
for (int i = 0; i < methodCount; i++) {
tempCheckBox =
new JCheckBox(
this.completeMethodList.get(i).toString());
currentSelection =
currentSelectedList.contains(
this.completeMethodList.get(i));
tempCheckBox.setSelected(currentSelection);
selectedValues[i] = currentSelection;
tempCheckBox.setBounds(hgap, vgap +
(Constants.UIConstants.GENERAL_COMP_HEIGHT + vgap) * i,
Constants.UIConstants.LABEL_WIDTH * 3,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
tempCheckBox.addActionListener(
new CheckBoxActionListner(tempCheckBox, i));
this.lablePanel.add(tempCheckBox);
}
okButton = new JButton("OK");
this.getContentPane().add(this.okButton);
this.okButton.setBounds(hgap, panelHeight + vgap,
Constants.UIConstants.GENERAL_BUTTON_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
loadValuesToBean();
closeMe();
}
});
cancelButton = new JButton("Cancel");
this.getContentPane().add(this.cancelButton);
this.cancelButton.setBounds(
hgap * 2 + Constants.UIConstants.GENERAL_BUTTON_WIDTH, panelHeight +
vgap,
Constants.UIConstants.GENERAL_BUTTON_WIDTH,
Constants.UIConstants.GENERAL_COMP_HEIGHT);
this.cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
closeMe();
}
});
this.setSize(width,
panelHeight +
2 * Constants.UIConstants.GENERAL_COMP_HEIGHT +
30);
this.setResizable(false);
}
private void updateSelection(JCheckBox checkBox, int index) {
if (checkBox.isSelected()) {
selectedValues[index] = true;
} else {
selectedValues[index] = false;
}
}
private void loadValuesToBean() {
ArrayList modifiedMethodList = new ArrayList();
for (int i = 0; i < selectedValues.length; i++) {
if (selectedValues[i])
modifiedMethodList.add(completeMethodList.get(i));
}
myBean.setSelectedMethodNames(modifiedMethodList);
}
private void closeMe() {
this.dispose();
}
private class CheckBoxActionListner implements ActionListener {
private JCheckBox checkBox;
private int index;
public CheckBoxActionListner(JCheckBox checkBox, int index) {
this.index = index;
this.checkBox = checkBox;
}
public void actionPerformed(ActionEvent e) {
updateSelection(checkBox, index);
}
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?