Changeset 1845 in josm for trunk/src/org
- Timestamp:
- 2009-07-25T19:20:23+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/dialogs/relation
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r1840 r1845 20 20 import java.awt.event.WindowAdapter; 21 21 import java.awt.event.WindowEvent; 22 import java.beans.PropertyChangeEvent;23 import java.beans.PropertyChangeListener;24 22 import java.io.IOException; 25 23 import java.util.ArrayList; … … 46 44 import javax.swing.KeyStroke; 47 45 import javax.swing.SwingUtilities; 48 import javax.swing.event.AncestorEvent;49 import javax.swing.event.AncestorListener;50 46 import javax.swing.event.ChangeEvent; 51 47 import javax.swing.event.ChangeListener; … … 193 189 .toString())); 194 190 } 191 192 addWindowListener( 193 new WindowAdapter() { 194 @Override 195 public void windowOpened(WindowEvent e) { 196 cleanSelfReferences(); 197 } 198 } 199 ); 200 195 201 } 196 202 … … 626 632 if (!b) { 627 633 dispose(); 634 } 635 } 636 637 /** 638 * checks whether the current relation has members referring to itself. If so, 639 * warns the users and provides an option for removing these members. 640 * 641 */ 642 protected void cleanSelfReferences() { 643 ArrayList<OsmPrimitive> toCheck = new ArrayList<OsmPrimitive>(); 644 toCheck.add(getRelation()); 645 if (memberTableModel.hasMembersReferringTo(toCheck)) { 646 int ret = ConditionalOptionPaneUtil.showOptionDialog( 647 "clean_relation_self_references", 648 Main.parent, 649 tr("<html>There is at least one member in this relation referring<br>" 650 + "to the relation itself.<br>" 651 + "This creates circular dependencies and is dicuraged.<br>" 652 + "How do you want to proceed with circular dependencies?</html>"), 653 tr("Warning"), 654 JOptionPane.YES_NO_OPTION, 655 JOptionPane.WARNING_MESSAGE, 656 new String[]{tr("Remove them, clean up relation"), tr("Ignore them, leave relation as is")}, 657 tr("Remove them, clean up relation") 658 ); 659 switch(ret) { 660 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 661 case JOptionPane.CLOSED_OPTION: return; 662 case JOptionPane.NO_OPTION: return; 663 case JOptionPane.YES_OPTION: 664 memberTableModel.removeMembersReferringTo(toCheck); 665 break; 666 } 628 667 } 629 668 } … … 1316 1355 } 1317 1356 } 1357 1358 1318 1359 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/MemberTableModel.java
r1839 r1845 395 395 } 396 396 397 public boolean isEditableRelation(int row) { 398 if (row < 0 || row >= members.size()) 399 return false; 400 RelationMember member = members.get(row); 397 /** 398 * Replies true if the index-th relation members referrs 399 * to an editable relation, i.e. a relation which is not 400 * incomplete. 401 * 402 * @param index the index 403 * @return true, if the index-th relation members referrs 404 * to an editable relation, i.e. a relation which is not 405 * incomplete 406 */ 407 public boolean isEditableRelation(int index) { 408 if (index < 0 || index >= members.size()) 409 return false; 410 RelationMember member = members.get(index); 401 411 if (!(member.member instanceof Relation)) 402 412 return false; … … 429 439 return false; 430 440 } 431 432 441 433 442 void sort() {
Note:
See TracChangeset
for help on using the changeset viewer.