1 23 package org.enhydra.kelp.common.deployer; 24 25 import org.enhydra.tool.common.ButtonPanel; 27 28 import java.awt.*; 30 import java.awt.event.ActionEvent ; 31 import java.awt.event.ActionListener ; 32 import java.beans.*; 33 import javax.swing.*; 34 35 public class DeployButtonPanel extends ButtonPanel { 37 private GridBagLayout layoutMain = null; 39 private JButton buttonBack = null; 40 private JButton buttonNext = null; 41 private JButton buttonDeploy = null; 42 private JButton buttonClose = null; 43 private JButton buttonHelp = null; 44 private JButton buttonAbout = null; 45 private LocalButtonListener buttonListener = null; 46 private JPanel panelFiller; 47 48 public static final String [] getOptions() { 49 final String [] options = {ButtonPanel.COMMAND_BACK, 50 ButtonPanel.COMMAND_NEXT, ButtonPanel.COMMAND_DEPLOY, 51 ButtonPanel.COMMAND_CLOSE, ButtonPanel.COMMAND_HELP, 52 ButtonPanel.COMMAND_ABOUT}; 53 return options; 54 } 55 56 public DeployButtonPanel() { 57 try { 58 jbInit(); 59 pmInit(); 60 } catch (Exception e) { 61 e.printStackTrace(); 62 } 63 } 64 65 public void removeHelp() { 67 remove(buttonHelp); 68 invalidate(); 69 doLayout(); 70 } 71 72 private void pmInit() { 75 buttonListener = new LocalButtonListener(); 76 buttonBack.addActionListener(buttonListener); 77 buttonNext.addActionListener(buttonListener); 78 buttonDeploy.addActionListener(buttonListener); 79 buttonClose.addActionListener(buttonListener); 80 buttonAbout.addActionListener(buttonListener); 81 buttonHelp.addActionListener(buttonListener); 82 83 buttonBack.setText(ButtonPanel.COMMAND_BACK); 84 buttonNext.setText(ButtonPanel.COMMAND_NEXT); 85 buttonDeploy.setText(ButtonPanel.COMMAND_DEPLOY); 86 buttonClose.setText(ButtonPanel.COMMAND_CLOSE); 87 buttonAbout.setText(ButtonPanel.COMMAND_ABOUT); 88 buttonHelp.setText(ButtonPanel.COMMAND_HELP); 89 buttonBack.setActionCommand(buttonBack.getText()); 91 buttonNext.setActionCommand(buttonNext.getText()); 92 buttonDeploy.setActionCommand(buttonDeploy.getText()); 93 buttonClose.setActionCommand(buttonClose.getText()); 94 buttonAbout.setActionCommand(buttonAbout.getText()); 95 buttonHelp.setActionCommand(buttonHelp.getText()); 96 buttonClose.requestFocus(); 98 } 99 100 private void jbInit() throws Exception { 101 layoutMain = 102 (GridBagLayout) Beans.instantiate(getClass().getClassLoader(), 103 GridBagLayout.class.getName()); 104 buttonBack = (JButton) Beans.instantiate(getClass().getClassLoader(), 105 JButton.class.getName()); 106 buttonNext = (JButton) Beans.instantiate(getClass().getClassLoader(), 107 JButton.class.getName()); 108 buttonDeploy = 109 (JButton) Beans.instantiate(getClass().getClassLoader(), 110 JButton.class.getName()); 111 buttonClose = 112 (JButton) Beans.instantiate(getClass().getClassLoader(), 113 JButton.class.getName()); 114 buttonAbout = (JButton) Beans.instantiate(getClass().getClassLoader(), 115 JButton.class.getName()); 116 buttonHelp = (JButton) Beans.instantiate(getClass().getClassLoader(), 117 JButton.class.getName()); 118 panelFiller = (JPanel) Beans.instantiate(getClass().getClassLoader(), 119 JPanel.class.getName()); 120 buttonBack.setText("BACK"); 121 buttonNext.setText("NEXT"); 122 buttonDeploy.setText("DEPLOY"); 123 buttonClose.setText("CLOSE"); 124 buttonAbout.setText("ABOUT"); 125 buttonHelp.setText("HELP"); 126 this.setLayout(layoutMain); 127 this.add(buttonBack, new GridBagConstraints(1, 0, 1, 1, 0.1, 0.0 128 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 20, 5, 2), 0, 0)); 129 this.add(buttonNext, new GridBagConstraints(2, 0, 1, 1, 0.1, 0.0 130 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0)); 131 this.add(buttonDeploy, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.0 132 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0)); 133 this.add(buttonClose, new GridBagConstraints(4, 0, 1, 1, 0.1, 0.0 134 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0)); 135 this.add(buttonAbout, new GridBagConstraints(6, 0, 1, 1, 0.1, 0.0 136 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 10), 0, 0)); 137 this.add(buttonHelp, new GridBagConstraints(5, 0, 1, 1, 0.1, 0.0 138 ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0)); 139 this.add(panelFiller, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0 140 ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 50, 0)); 141 } 142 143 private class LocalButtonListener implements ActionListener { 144 145 152 public void actionPerformed(ActionEvent e) { 153 Object source = null; 154 ActionEvent event = null; 155 156 source = e.getSource(); 157 if (source == buttonBack) { 158 event = new ActionEvent (buttonBack, ButtonPanel.BACK, 159 buttonBack.getActionCommand()); 160 } else if (source == buttonNext) { 161 event = new ActionEvent (buttonNext, ButtonPanel.NEXT, 162 buttonNext.getActionCommand()); 163 } else if (source == buttonDeploy) { 164 event = new ActionEvent (buttonDeploy, 165 ButtonPanel.DEPLOY, 166 buttonDeploy.getActionCommand()); 167 } else if (source == buttonClose) { 168 event = new ActionEvent (buttonClose, 169 ButtonPanel.CLOSE, 170 buttonClose.getActionCommand()); 171 } else if (source == buttonHelp) { 172 event = new ActionEvent (buttonHelp, ButtonPanel.HELP, 173 buttonHelp.getActionCommand()); 174 } else if (source == buttonAbout) { 175 event = new ActionEvent (buttonAbout, ButtonPanel.ABOUT, 176 buttonAbout.getActionCommand()); 177 } 178 if (event != null) { 179 notifyActionListeners(event); 180 } 181 } 182 183 } 184 } 185 | Popular Tags |