Changeset 14029 in josm for trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java
- Timestamp:
- 2018-07-15T12:16:21+02:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorAction.java
r14027 r14029 30 30 */ 31 31 public abstract class AbstractRelationEditorAction extends AbstractAction 32 33 34 32 implements TableModelListener, ListSelectionListener, PropertyChangeListener { 33 private static final long serialVersionUID = 1L; 34 protected final transient IRelationEditorActionAccess editorAccess; 35 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 36 /** 37 * Create a new relation editor action 38 * 39 * @param editorAccess 40 * The editor this action is for 41 * @param actionMapKey 42 * The key for the member table action map. 43 * @param updateOn 44 * The events that may cause the enabled state of this button to 45 * change. 46 */ 47 protected AbstractRelationEditorAction(IRelationEditorActionAccess editorAccess, 48 IRelationEditorUpdateOn... updateOn) { 49 Objects.requireNonNull(editorAccess, "editorAccess"); 50 Objects.requireNonNull(updateOn, "updateOn"); 51 this.editorAccess = editorAccess; 52 for (IRelationEditorUpdateOn u : updateOn) { 53 u.register(editorAccess, this); 54 } 55 } 56 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 57 /** 58 * Create a new relation editor action 59 * 60 * @param editorAccess 61 * The editor this action is for 62 * @param actionMapKey 63 * The key for the member table action map. 64 * @param updateOn 65 * The events that may cause the enabled state of this button to 66 * change. 67 */ 68 protected AbstractRelationEditorAction(IRelationEditorActionAccess editorAccess, String actionMapKey, 69 IRelationEditorUpdateOn... updateOn) { 70 this(editorAccess, updateOn); 71 Objects.requireNonNull(actionMapKey, "actionMapKey"); 72 72 73 74 73 this.editorAccess.addMemberTableAction(actionMapKey, this); 74 } 75 75 76 77 78 79 76 @Override 77 public void tableChanged(TableModelEvent e) { 78 updateEnabledState(); 79 } 80 80 81 82 83 84 81 @Override 82 public void valueChanged(ListSelectionEvent e) { 83 updateEnabledState(); 84 } 85 85 86 86 @Override … … 89 89 } 90 90 91 91 protected abstract void updateEnabledState(); 92 92 93 94 95 96 97 98 99 93 protected final boolean canDownload() { 94 if (editorAccess.getEditor().getRelation() == null) 95 return false; 96 DataSet ds = editorAccess.getEditor().getRelation().getDataSet(); 97 return !Main.isOffline(OnlineResource.OSM_API) && ds != null && !ds.isLocked() 98 && !DownloadPolicy.BLOCKED.equals(ds.getDownloadPolicy()); 99 } 100 100 101 102 103 101 protected MemberTable getMemberTable() { 102 return editorAccess.getMemberTable(); 103 } 104 104 105 106 107 105 protected MemberTableModel getMemberTableModel() { 106 return editorAccess.getMemberTableModel(); 107 } 108 108 109 110 111 109 protected SelectionTable getSelectionTable() { 110 return editorAccess.getSelectionTable(); 111 } 112 112 113 114 115 113 protected SelectionTableModel getSelectionTableModel() { 114 return editorAccess.getSelectionTableModel(); 115 } 116 116 117 118 119 117 protected IRelationEditor getEditor() { 118 return editorAccess.getEditor(); 119 } 120 120 121 122 123 121 protected TagEditorModel getTagModel() { 122 return editorAccess.getTagModel(); 123 } 124 124 125 126 127 125 protected OsmDataLayer getLayer() { 126 return editorAccess.getEditor().getLayer(); 127 } 128 128 129 130 131 129 public boolean isExpertOnly() { 130 return false; 131 } 132 132 }
Note:
See TracChangeset
for help on using the changeset viewer.