- Timestamp:
- 2009-07-25T11:19:33+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1822 r1828 40 40 import javax.swing.KeyStroke; 41 41 import javax.swing.SwingUtilities; 42 import javax.swing.event.ChangeEvent; 43 import javax.swing.event.ChangeListener; 42 44 import javax.swing.event.DocumentEvent; 43 45 import javax.swing.event.DocumentListener; … … 92 94 private AutoCompletionCache acCache; 93 95 private AutoCompletionList acList; 96 private ReferringRelationsBrowser referrerBrowser; 94 97 private ReferringRelationsBrowserModel referrerModel; 95 98 … … 152 155 tabbedPane.add(tr("Tags and Members"), pnl); 153 156 if (relation != null && relation.id > 0) { 154 tabbedPane.add(tr("Parent Relations"), new ReferringRelationsBrowser(getLayer(), referrerModel, this)); 155 } 157 referrerBrowser = new ReferringRelationsBrowser(getLayer(), referrerModel, this); 158 tabbedPane.add(tr("Parent Relations"), referrerBrowser); 159 } 160 tabbedPane.add(tr("Child Relations"), new ChildRelationBrowser(getLayer(), relation)); 161 tabbedPane.addChangeListener( 162 new ChangeListener() { 163 public void stateChanged(ChangeEvent e) { 164 JTabbedPane sourceTabbedPane = (JTabbedPane) e.getSource(); 165 int index = sourceTabbedPane.getSelectedIndex(); 166 String title = sourceTabbedPane.getTitleAt(index); 167 if (title.equals(tr("Parent Relations"))) { 168 referrerBrowser.init(); 169 } 170 } 171 } 172 ); 156 173 157 174 getContentPane().add(tabbedPane, BorderLayout.CENTER); … … 765 782 Shortcut.registerShortcut("relationeditor:sort", tr("Relation Editor: Sort"), KeyEvent.VK_T, 766 783 Shortcut.GROUP_MNEMONIC); 767 setEnabled(false);784 //setEnabled(false); 768 785 } 769 786 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1822 r1828 415 415 */ 416 416 417 if (map.isEmpty()) 417 if (map.isEmpty()) { 418 418 // empty relation or incomplete members 419 419 return; 420 } 420 421 segments = new Vector<LinkedList<Integer>>(); 421 // add first member of relation, not strictly necessary 422 if (map.remove(0, members.get(0))) { 422 423 while (!map.isEmpty()) { 424 // find an element for the next segment 425 // try first element in relation if we just started 426 // otherwise, or if first element is another relation, just fetch some element from the 427 // map 428 Integer next; 429 if ((segments.size() == 0) && map.remove(0, members.get(0))) { 430 next = 0; 431 } else { 432 next = map.pop(); 433 if (next == null) { 434 break; 435 } 436 } 437 423 438 segment = new LinkedList<Integer>(); 424 segment.add( Integer.valueOf(0));439 segment.add(next); 425 440 segments.add(segment); 426 }427 while (!map.isEmpty()) {428 segment = segments.lastElement();429 441 430 442 do { … … 516 528 } while (something_done); 517 529 518 Integer next = map.pop(); 519 if (next == null) { 520 break; 521 } 522 530 } 531 if (segments.size() > 0) { 532 // append map.remaining() to segments list (as a single segment) 523 533 segment = new LinkedList<Integer>(); 524 segment.add (next);534 segment.addAll(map.getRemaining()); 525 535 segments.add(segment); 526 } 527 // append map.remaining() to segments list (as a single segment) 528 segment = new LinkedList<Integer>(); 529 segment.addAll(map.getRemaining()); 530 segments.add(segment); 531 532 // now we need to actually re-order the relation members 533 ArrayList<RelationMember> newmembers = new ArrayList<RelationMember>(); 534 for (LinkedList<Integer> segment2 : segments) { 535 for (Integer p : segment2) { 536 newmembers.add(members.get(p)); 537 } 538 } 539 members.clear(); 540 members.addAll(newmembers); 541 542 fireTableDataChanged(); 536 537 // now we need to actually re-order the relation members 538 ArrayList<RelationMember> newmembers = new ArrayList<RelationMember>(); 539 for (LinkedList<Integer> segment2 : segments) { 540 for (Integer p : segment2) { 541 newmembers.add(members.get(p)); 542 } 543 } 544 members.clear(); 545 members.addAll(newmembers); 546 547 fireTableDataChanged(); 548 } 543 549 } 544 550 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowser.java
r1811 r1828 58 58 private final GenericRelationEditor relationEditor; 59 59 60 /** state flag for this browser. Initially initialized is false. 61 * It becomes initialized after the first download of the parent 62 * relations. 63 */ 64 private boolean initialized; 65 60 66 /** 61 67 * build the GUI … … 89 95 this.layer = layer; 90 96 build(); 97 } 98 99 100 /** 101 * Replies true this browser has initialized itself by downloading the reference relations 102 * parents. 103 * 104 * @return true this browser has initialized itself by downloading the reference relations 105 * parents; false, otherwise 106 */ 107 public boolean isInitialized() { 108 return initialized; 109 } 110 111 public void init() { 112 if (initialized) return; 113 initialized = true; 114 boolean full = cbReadFull.isSelected(); 115 ReloadTask task = new ReloadTask(full, relationEditor); 116 Main.worker.submit(task); 91 117 } 92 118 -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowserModel.java
r1806 r1828 6 6 import javax.swing.AbstractListModel; 7 7 8 import org.openstreetmap.josm.data.osm.DataSet;9 8 import org.openstreetmap.josm.data.osm.Relation; 10 9 import org.openstreetmap.josm.data.osm.RelationMember; -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationDialogManager.java
r1804 r1828 22 22 */ 23 23 public class RelationDialogManager extends WindowAdapter implements LayerChangeListener{ 24 25 /** keeps track of open relation editors */ 26 static RelationDialogManager relationDialogManager; 27 28 /** 29 * Replies the singleton {@see RelationDialogManager} 30 * 31 * @return the singleton {@see RelationDialogManager} 32 */ 33 static public RelationDialogManager getRelationDialogManager() { 34 if (RelationDialogManager.relationDialogManager == null) { 35 RelationDialogManager.relationDialogManager = new RelationDialogManager(); 36 Layer.listeners.add(RelationDialogManager.relationDialogManager); 37 } 38 return RelationDialogManager.relationDialogManager; 39 } 24 40 25 41 /** … … 251 267 } 252 268 } 269 253 270 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/RelationEditor.java
r1804 r1828 13 13 import org.openstreetmap.josm.data.osm.RelationMember; 14 14 import org.openstreetmap.josm.gui.ExtendedDialog; 15 import org.openstreetmap.josm.gui.layer.Layer;16 15 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 17 16 18 17 public abstract class RelationEditor extends ExtendedDialog { 19 18 20 /** keeps track of open relation editors */21 static private RelationDialogManager relationDialogManager;19 /** the list of registered relation editor classes */ 20 private static ArrayList<Class<RelationEditor>> editors = new ArrayList<Class<RelationEditor>>(); 22 21 23 22 /** 24 * Replies the singleton {@see RelationDialogManager} 23 * Registers a relation editor class. Depending on the type of relation to be edited 24 * {@see #getEditor(OsmDataLayer, Relation, Collection)} will create an instance of 25 * this class. 25 26 * 26 * @ return the singleton {@see RelationDialogManager}27 * @param clazz the class 27 28 */ 28 static public RelationDialogManager getRelationDialogManager() {29 if ( relationDialogManager == null) {30 relationDialogManager = new RelationDialogManager();31 Layer.listeners.add(relationDialogManager);29 public void registerRelationEditor(Class<RelationEditor> clazz) { 30 if (clazz == null) return; 31 if (!editors.contains(clazz)) { 32 editors.add(clazz); 32 33 } 33 return relationDialogManager;34 34 } 35 36 public static ArrayList<Class<RelationEditor>> editors = new ArrayList<Class<RelationEditor>>();37 35 38 36 /** … … 81 79 } 82 80 } 83 if ( getRelationDialogManager().isOpenInEditor(layer, r))84 return getRelationDialogManager().getEditorForRelation(layer, r);81 if (RelationDialogManager.getRelationDialogManager().isOpenInEditor(layer, r)) 82 return RelationDialogManager.getRelationDialogManager().getEditorForRelation(layer, r); 85 83 else { 86 84 RelationEditor editor = new GenericRelationEditor(layer, r, selectedMembers); 87 getRelationDialogManager().positionOnScreen(editor);88 getRelationDialogManager().register(layer, r, editor);85 RelationDialogManager.getRelationDialogManager().positionOnScreen(editor); 86 RelationDialogManager.getRelationDialogManager().register(layer, r, editor); 89 87 return editor; 90 88 }
Note:
See TracChangeset
for help on using the changeset viewer.