Changeset 1816 in josm for trunk/src/org
- Timestamp:
- 2009-07-20T06:57:56+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1814 r1816 16 16 import java.awt.event.FocusEvent; 17 17 import java.awt.event.KeyEvent; 18 import java.awt.event.MouseAdapter; 19 import java.awt.event.MouseEvent; 20 import java.awt.event.WindowAdapter; 21 import java.awt.event.WindowEvent; 18 22 import java.io.IOException; 19 23 import java.util.ArrayList; … … 298 302 memberTable = new MemberTable(memberTableModel); 299 303 300 ListSelectionModel lsm = memberTable.getSelectionModel(); 301 lsm.addListSelectionListener(new ListSelectionListener() { 302 public void valueChanged(ListSelectionEvent e) { 303 ArrayList<OsmPrimitive> sel; 304 int cnt = memberTable.getSelectedRowCount(); 305 if(cnt > 0) { 306 sel = new ArrayList<OsmPrimitive>(cnt); 307 for (int i : memberTable.getSelectedRows()) { 308 sel.add(memberTableModel.getReferredPrimitive(i)); 309 } 310 } else { 311 cnt = memberTable.getRowCount(); 312 sel = new ArrayList<OsmPrimitive>(cnt); 313 for (int i = 0; i < cnt; ++i) { 314 sel.add(memberTableModel.getReferredPrimitive(i)); 315 } 316 } 317 getLayer().data.setSelected(sel); 318 } 319 }); 304 memberTable.getSelectionModel().addListSelectionListener(new SelectionSynchronizer()); 305 memberTable.addMouseListener(new MemberTableDblClickAdapter()); 320 306 321 307 final JScrollPane scrollPane = new JScrollPane(memberTable); … … 334 320 ); 335 321 336 337 322 GridBagConstraints gc = new GridBagConstraints(); 338 323 gc.gridx = 0; … … 364 349 pnl.add(scrollPane, gc); 365 350 366 gc.gridx = 2; 351 JPanel pnl2 = new JPanel(); 352 pnl2.setLayout(new GridBagLayout()); 353 354 gc.gridx = 0; 355 gc.gridy = 0; 356 gc.gridheight =1; 357 gc.gridwidth = 3; 358 gc.fill = GridBagConstraints.HORIZONTAL; 359 gc.anchor = GridBagConstraints.FIRST_LINE_START; 360 gc.weightx = 1.0; 361 gc.weighty = 0.0; 362 pnl2.add(new JLabel(tr("Selection")), gc); 363 364 gc.gridx = 0; 367 365 gc.gridy = 1; 366 gc.gridheight =1; 367 gc.gridwidth = 1; 368 gc.fill = GridBagConstraints.VERTICAL; 369 gc.anchor = GridBagConstraints.NORTHWEST; 368 370 gc.weightx = 0.0; 369 371 gc.weighty = 1.0; 370 pnl .add(buildSelectionControlButtonPanel(), gc);371 372 gc.gridx = 3;372 pnl2.add(buildSelectionControlButtonPanel(), gc); 373 374 gc.gridx = 1; 373 375 gc.gridy = 1; 374 gc.weightx = 0.4;376 gc.weightx = 1.0; 375 377 gc.weighty = 1.0; 376 pnl.add(buildSelectionTablePanel(), gc); 377 378 gc.gridx = 1; 379 gc.gridy = 2; 380 gc.weightx = 1.0; 381 gc.weighty = 0.0; 382 pnl.add(buildButtonPanel(), gc); 383 384 return pnl; 378 gc.fill = GridBagConstraints.BOTH; 379 pnl2.add(buildSelectionTablePanel(), gc); 380 381 final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); 382 splitPane.setLeftComponent(pnl); 383 splitPane.setRightComponent(pnl2); 384 splitPane.setOneTouchExpandable(false); 385 addWindowListener( 386 new WindowAdapter() { 387 @Override 388 public void windowOpened(WindowEvent e) { 389 // has to be called when the window is visible, otherwise 390 // no effect 391 splitPane.setDividerLocation(0.6); 392 } 393 } 394 ); 395 396 JPanel pnl3 = new JPanel(); 397 pnl3.setLayout(new BorderLayout()); 398 pnl3.add(splitPane, BorderLayout.CENTER); 399 pnl3.add(buildButtonPanel(), BorderLayout.SOUTH); 400 return pnl3; 385 401 } 386 402 … … 407 423 */ 408 424 protected JSplitPane buildSplitPane() { 409 JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);425 final JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); 410 426 pane.setTopComponent(buildTagEditorPanel()); 411 427 pane.setBottomComponent(buildMemberEditorPanel()); 412 428 pane.setOneTouchExpandable(true); 413 pane.setDividerLocation(150); 429 addWindowListener( 430 new WindowAdapter() { 431 @Override 432 public void windowOpened(WindowEvent e) { 433 // has to be called when the window is visible, otherwise 434 // no effect 435 pane.setDividerLocation(0.3); 436 } 437 } 438 ); 414 439 return pane; 415 440 } … … 998 1023 } 999 1024 1000 public void actionPerformed(ActionEvent e){1025 public void run() { 1001 1026 int idx = memberTable.getSelectedRow(); 1002 1027 if (idx < 0) return; … … 1009 1034 } 1010 1035 1036 public void actionPerformed(ActionEvent e) { 1037 if (!isEnabled()) 1038 return; 1039 run(); 1040 } 1041 1011 1042 public void valueChanged(ListSelectionEvent e) { 1012 1043 refreshEnabled(); 1044 } 1045 } 1046 1047 class MemberTableDblClickAdapter extends MouseAdapter { 1048 @Override 1049 public void mouseClicked(MouseEvent e) { 1050 if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) { 1051 new EditAction().run(); 1052 } 1053 } 1054 } 1055 1056 class SelectionSynchronizer implements ListSelectionListener { 1057 public void valueChanged(ListSelectionEvent e) { 1058 ArrayList<OsmPrimitive> sel; 1059 int cnt = memberTable.getSelectedRowCount(); 1060 if (cnt <=0) return; 1061 sel = new ArrayList<OsmPrimitive>(cnt); 1062 for (int i : memberTable.getSelectedRows()) { 1063 sel.add(memberTableModel.getReferredPrimitive(i)); 1064 } 1065 getLayer().data.setSelected(sel); 1013 1066 } 1014 1067 }
Note:
See TracChangeset
for help on using the changeset viewer.