1 24 25 26 package org.aspectj.ajde.ui.swing; 27 28 import java.awt.*; 29 import javax.swing.*; 30 import java.awt.event.*; 31 import java.util.Vector ; 32 import javax.swing.border.*; 33 import org.aspectj.ajde.Ajde; 34 import org.aspectj.ajde.internal.*; 35 36 42 public class UpdateConfigurationDialog extends JFrame { 43 private Vector buildConfigFiles; 44 private Vector filesToUpdate; 45 private boolean addToConfiguration; 46 47 private String message1 = " Project has been updated."; 48 private String message2 = " File list below."; 49 private Box box5; 50 private JButton cancel_button = new JButton(); 51 private JButton ok_button = new JButton(); 52 private FlowLayout flowLayout1 = new FlowLayout(); 53 private JPanel globalButton_panel = new JPanel(); 54 private JPanel jPanel1 = new JPanel(); 55 private JPanel jPanel2 = new JPanel(); 56 private TitledBorder titledBorder1; 57 private TitledBorder titledBorder2; 58 private BorderLayout borderLayout1 = new BorderLayout(); 59 private BorderLayout borderLayout2 = new BorderLayout(); 60 private BorderLayout borderLayout3 = new BorderLayout(); 61 private JPanel jPanel3 = new JPanel(); 62 private GridLayout gridLayout1 = new GridLayout(); 63 private JScrollPane jScrollPane1 = new JScrollPane(); 64 private JList updatedFilesList = new JList(); 65 private JScrollPane jScrollPane2 = new JScrollPane(); 66 private JList buildConfigList = new JList(); 67 private Box box2; 68 private JLabel messageLabel1 = new JLabel(); 69 private JLabel messageLabel2 = new JLabel(); 70 71 public UpdateConfigurationDialog(Vector filesToUpdate, Vector buildConfigFiles, boolean addToConfiguration, Component parentComponent) { 72 try { 73 this.buildConfigFiles = buildConfigFiles; 74 this.filesToUpdate = filesToUpdate; 75 this.addToConfiguration = addToConfiguration; 76 77 updatedFilesList.setListData(filesToUpdate); 78 String action = "removed from"; 79 if (addToConfiguration) action = "added to"; 80 message1 = " Files have been " + action + " the project, which will affect the build configurations\n"; 81 message2 = " listed below. These build configurations listed can be updated automatically."; 82 83 buildConfigList.setListData(buildConfigFiles); 86 87 jbInit(); 88 89 this.doLayout(); 90 this.setTitle("Build Configuration Update"); 91 this.setSize(500, 320); 92 93 int posX = parentComponent.getX() + 100; int posY = parentComponent.getY() + 100; this.setLocation(posX, posY); 97 } 98 catch(Exception e) { 99 Ajde.getDefault().getErrorHandler().handleError("Could not open configuration dialog", e); 100 } 101 } 102 103 void cancel_button_actionPerformed(ActionEvent e) { 104 this.dispose(); 105 } 106 void ok_button_actionPerformed(ActionEvent e) { 107 Object [] selected = buildConfigList.getSelectedValues(); 108 this.dispose(); 110 } 111 112 private void jbInit() throws Exception { 113 box5 = Box.createVerticalBox(); 114 titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)),"Project Files Added/Removed"); 115 titledBorder2 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)),"Build Configurations Affected"); 116 box2 = Box.createVerticalBox(); 117 this.getContentPane().setLayout(borderLayout1); 118 cancel_button.setText("Cancel"); 119 cancel_button.addActionListener(new java.awt.event.ActionListener () { 120 121 public void actionPerformed(ActionEvent e) { 122 cancel_button_actionPerformed(e); 123 } 124 }); 125 ok_button.setText("Update Selected Configurations"); 126 ok_button.addActionListener(new java.awt.event.ActionListener () { 127 128 public void actionPerformed(ActionEvent e) { 129 ok_button_actionPerformed(e); 130 } 131 }); 132 globalButton_panel.setLayout(flowLayout1); 133 jPanel1.setLayout(borderLayout3); 134 jPanel1.setBorder(titledBorder1); 135 jPanel1.setMinimumSize(new Dimension(154, 20)); 136 jPanel1.setPreferredSize(new Dimension(154, 50)); 137 jPanel2.setBorder(titledBorder2); 138 jPanel2.setMinimumSize(new Dimension(36, 50)); 139 jPanel2.setPreferredSize(new Dimension(272, 50)); 140 jPanel2.setLayout(borderLayout2); 141 globalButton_panel.setMinimumSize(new Dimension(297, 37)); 142 globalButton_panel.setPreferredSize(new Dimension(297, 37)); 143 jPanel3.setLayout(gridLayout1); 144 jPanel3.setMinimumSize(new Dimension(154, 20)); 145 jPanel3.setPreferredSize(new Dimension(154, 40)); 146 buildConfigList.setBorder(BorderFactory.createLoweredBevelBorder()); 147 messageLabel1.setText(message1); 148 messageLabel2.setText(message2); 149 updatedFilesList.setFont(new java.awt.Font ("Dialog", 0, 10)); 150 this.getContentPane().add(box5, BorderLayout.CENTER); 151 box5.add(jPanel3, null); 152 jPanel3.add(box2, null); 153 box2.add(messageLabel1, null); 154 box2.add(messageLabel2, null); 155 box5.add(jPanel1, null); 156 jPanel1.add(jScrollPane1, BorderLayout.CENTER); 157 jScrollPane1.getViewport().add(updatedFilesList, null); 158 box5.add(jPanel2, null); 159 jPanel2.add(jScrollPane2, BorderLayout.CENTER); 160 jScrollPane2.getViewport().add(buildConfigList, null); 161 box5.add(globalButton_panel, null); 162 globalButton_panel.add(ok_button, null); 163 globalButton_panel.add(cancel_button, null); 164 } 165 } 166 167 class CheckListCellRenderer extends JCheckBox implements ListCellRenderer { 168 public CheckListCellRenderer() { 169 super(); 170 setOpaque(true); 171 } 172 173 public Component getListCellRendererComponent(JList list, 174 Object value, 175 int index, 176 boolean isSelected, 177 boolean cellHasFocus) { 178 setText(value.toString()); 179 setFont(new java.awt.Font ("Dialog", 0, 10)); 180 setBackground(new Color(255, 255, 255)); 181 182 setBackground(isSelected ? list.getSelectionBackground() : list.getBackground()); 183 setForeground(isSelected ? list.getSelectionForeground() : list.getForeground()); 184 setSelected(isSelected); 185 186 return this; 187 } 188 } 189 190 class CheckListener implements MouseListener, KeyListener { 191 192 protected JList list; 193 194 public CheckListener(JList list) { 195 this.list = list; 196 } 197 198 public void mouseClicked(MouseEvent e) { 199 doCheck(); 200 } 201 202 public void keyPressed(KeyEvent e) { 203 if (e.getKeyChar() == ' ') doCheck(); 204 } 205 206 protected void doCheck() { 207 int index = list.getSelectedIndex(); 208 if (index < 0) { 209 return; 210 } 211 list.getModel().getElementAt(index); 212 list.repaint(); 213 } 214 215 public void mousePressed(MouseEvent e) {} 216 public void mouseReleased(MouseEvent e) {} 217 public void mouseEntered(MouseEvent e) {} 218 public void mouseExited(MouseEvent e) {} 219 public void keyTyped(KeyEvent e) {} 220 public void keyReleased(KeyEvent e) { } 221 } | Popular Tags |