Changeset 23324 in osm
- Timestamp:
- 2010-09-23T23:14:10+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/smed/src/smed
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/smed/src/smed/menu/SmedMenuBar.java
r23315 r23324 12 12 import smed.menu.file.TabManager; 13 13 import smed.plug.ifc.SmedPluggable; 14 import smed.tabs.SmedTabbedPane; 14 15 15 16 public class SmedMenuBar extends JMenuBar { … … 23 24 JMenu menu, submenu; 24 25 JMenuItem menuItem; 25 public List<SmedPluggable> plugins = null; 26 TabManager hideAction = null; 26 private List<SmedPluggable> plugins = null; 27 27 28 28 public SmedMenuBar() { … … 38 38 39 39 menuItem.addActionListener(new java.awt.event.ActionListener() { 40 40 41 41 public void actionPerformed(java.awt.event.ActionEvent e) { 42 42 DefaultListModel myModel = new DefaultListModel(); 43 plugins = SmedTabbedPane.getPlugins(); 43 44 44 45 for(SmedPluggable p : plugins) myModel.addElement (p.getName()); 45 46 46 hideAction =new TabManager(myModel);47 new TabManager(myModel); 47 48 } 48 49 }); -
applications/editors/josm/plugins/smed/src/smed/menu/file/TabManager.java
r23315 r23324 8 8 import javax.swing.JPanel; 9 9 import java.awt.Dimension; 10 import javax.swing.JList;11 10 import java.awt.Rectangle; 12 11 import javax.swing.JButton; 13 12 import java.awt.Font; 13 import java.awt.event.ActionEvent; 14 import java.awt.event.ActionListener; 15 import java.util.List; 16 14 17 import javax.swing.JLabel; 15 18 import javax.swing.JTextField; 16 19 17 18 public class TabManager extends JDialog { 20 import smed.jide.swing.CheckBoxList; 21 import smed.jide.swing.CheckBoxListSelectionModel; 22 import smed.plug.ifc.SmedPluggable; 23 import smed.tabs.SmedTabbedPane; 24 25 26 public class TabManager extends JDialog implements ActionListener { 19 27 /** 20 28 * … … 22 30 private static final long serialVersionUID = 1L; 23 31 24 DefaultListModel model; 25 32 private DefaultListModel model; 33 private CheckBoxListSelectionModel selModel; 34 private List<SmedPluggable> plugins = null; 35 private int modelSize = 0; 26 36 27 37 private JDialog tabManagerDialog = null; // @jve:decl-index=0:visual-constraint="59,23" 28 29 38 private JPanel tabManagerPanel = null; 30 31 39 private JScrollPane tabScrollPane = null; 32 33 private JList tabList = null; 34 40 private CheckBoxList tabList = null; 35 41 private JButton tabButtonOk = null; 36 37 42 private JButton tabButtonCancel = null; 38 39 43 private JButton tabButtonUndo = null; 40 41 44 private JButton tabButtonLoad = null; 42 43 45 private JButton tabButtonSave = null; 44 45 46 private JButton tabButtonDelete = null; 46 47 47 private JButton tabButtonVisible = null; 48 49 48 private JButton tabButtonAll = null; 50 51 49 private JButton tabButtonNone = null; 52 53 50 private JLabel tabLabelSelect = null; 54 55 51 private JLabel tabLabelRename = null; 56 57 52 private JTextField tabTextFieldRename = null; 58 53 59 54 public TabManager(DefaultListModel model) { 60 55 this.model = model; 61 56 plugins = SmedTabbedPane.getPlugins(); 57 modelSize = model.getSize(); 62 58 getTabManagerDialog().setVisible(true); 63 59 } … … 136 132 * @return javax.swing.JList 137 133 */ 138 private JList getTabList() {134 private CheckBoxList getTabList() { 139 135 if (tabList == null) { 140 tabList = new JList(); 136 tabList = new CheckBoxList(model); 137 selModel = ((CheckBoxList) tabList).getCheckBoxListSelectionModel(); 141 138 } 142 139 return tabList; … … 154 151 tabButtonOk.setFont(new Font("Dialog", Font.BOLD, 12)); 155 152 tabButtonOk.setText("Ok"); 153 tabButtonOk.addActionListener(this); 154 tabButtonOk.setActionCommand("ok"); 156 155 } 157 156 return tabButtonOk; … … 169 168 tabButtonCancel.setFont(new Font("Dialog", Font.BOLD, 12)); 170 169 tabButtonCancel.setText("Cancel"); 170 tabButtonCancel.addActionListener(this); 171 tabButtonCancel.setActionCommand("cancel"); 171 172 } 172 173 return tabButtonCancel; … … 184 185 tabButtonUndo.setFont(new Font("Dialog", Font.BOLD, 12)); 185 186 tabButtonUndo.setText("Undo"); 187 tabButtonUndo.addActionListener(this); 188 tabButtonUndo.setActionCommand("undo"); 186 189 } 187 190 return tabButtonUndo; … … 199 202 tabButtonLoad.setFont(new Font("Dialog", Font.BOLD, 12)); 200 203 tabButtonLoad.setText("Load"); 204 tabButtonLoad.addActionListener(this); 205 tabButtonLoad.setActionCommand("load"); 201 206 } 202 207 return tabButtonLoad; … … 214 219 tabButtonSave.setFont(new Font("Dialog", Font.BOLD, 12)); 215 220 tabButtonSave.setText("Save"); 221 tabButtonSave.addActionListener(this); 222 tabButtonSave.setActionCommand("save"); 216 223 } 217 224 return tabButtonSave; … … 228 235 tabButtonDelete.setBounds(new Rectangle(186, 362, 104, 30)); 229 236 tabButtonDelete.setText("Delete"); 237 tabButtonDelete.addActionListener(this); 238 tabButtonDelete.setActionCommand("delete"); 230 239 } 231 240 return tabButtonDelete; … … 241 250 tabButtonVisible = new JButton(); 242 251 tabButtonVisible.setBounds(new Rectangle(293, 362, 104, 30)); 243 tabButtonVisible.setText("visible"); 252 tabButtonVisible.setText("invisible"); 253 tabButtonVisible.addActionListener(this); 254 tabButtonVisible.setActionCommand("invisible"); 244 255 } 245 256 return tabButtonVisible; … … 257 268 tabButtonAll.setFont(new Font("Dialog", Font.PLAIN, 12)); 258 269 tabButtonAll.setText("all"); 270 tabButtonAll.addActionListener(this); 271 tabButtonAll.setActionCommand("all"); 259 272 } 260 273 return tabButtonAll; … … 272 285 tabButtonNone.setFont(new Font("Dialog", Font.PLAIN, 12)); 273 286 tabButtonNone.setText("none"); 287 tabButtonNone.addActionListener(this); 288 tabButtonNone.setActionCommand("none"); 274 289 } 275 290 return tabButtonNone; … … 289 304 } 290 305 306 @Override 307 public void actionPerformed(ActionEvent e) { 308 String cmd = e.getActionCommand(); 309 310 if(cmd.equals("ok")) { 311 System.out.println("Aufraeumarbeiten beginnen"); 312 tabManagerDialog.setVisible(false); 313 tabManagerDialog.dispose(); 314 return; 315 } 316 317 if(cmd.equals("cancel")) { 318 tabManagerDialog.setVisible(false); 319 tabManagerDialog.dispose(); 320 return; 321 } 322 323 if(cmd.equals("all")) { 324 selModel.addSelectionInterval(0, modelSize - 1); 325 return; 326 } 327 328 if(cmd.equals("none")) { 329 selModel.removeSelectionInterval(0, modelSize - 1); 330 return; 331 } 332 333 if(cmd.equals("invisible")) { 334 for(int i = 0; i < modelSize ; i++) { 335 if(selModel.isSelectedIndex(i)) model.set(i,"invisible"); 336 } 337 } 338 339 if(cmd.equals("delete")) { 340 for(int i = 0; i < modelSize ; i++) { 341 if(selModel.isSelectedIndex(i)) model.set(i,""); 342 } 343 } 344 345 if(cmd.equals("undo")) { 346 int i = 0; 347 348 for(SmedPluggable p : plugins) model.set(i++,p.getName()); 349 selModel.removeSelectionInterval(0, modelSize - 1); 350 } 351 352 } 353 291 354 } -
applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabbedPane.java
r23288 r23324 18 18 19 19 public class SmedTabbedPane extends JPanel { 20 21 List<SmedPluggable> plugins = null;22 20 23 21 /** … … 26 24 private static final long serialVersionUID = 1L; 27 25 26 static private List<SmedPluggable> plugins = null; 27 28 28 public SmedTabbedPane() { 29 29 super(new GridLayout(1, 1)); … … 58 58 } 59 59 } 60 61 public static List<SmedPluggable> getPlugins() { 62 return plugins; 63 } 60 64 }
Note:
See TracChangeset
for help on using the changeset viewer.