Changeset 25682 in osm
- Timestamp:
- 2011-03-23T23:13:50+01:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/relcontext
- Files:
-
- 7 added
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/relcontext/src/relcontext/ChosenRelationComponent.java
r25670 r25682 57 57 if( tag != null ) 58 58 sb.append("; ").append(tag); 59 sb.append(" (").append(rel.getMembersCount()).append(')'); 59 60 60 61 return sb.toString(); -
applications/editors/josm/plugins/relcontext/src/relcontext/RelContextDialog.java
r25680 r25682 1 1 package relcontext; 2 2 3 import java.awt.Dimension; 4 import org.openstreetmap.josm.tools.ImageProvider; 3 5 import org.openstreetmap.josm.gui.DefaultNameFormatter; 4 6 import org.openstreetmap.josm.data.osm.NameFormatter; 5 import java.awt.Component;6 7 import javax.swing.event.ListSelectionEvent; 7 import javax.swing.table.DefaultTableCellRenderer;8 8 import javax.swing.table.TableColumnModel; 9 9 import javax.swing.table.DefaultTableModel; … … 37 37 import org.openstreetmap.josm.tools.GBC; 38 38 import org.openstreetmap.josm.command.ChangeCommand; 39 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 39 40 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingComboBox; 40 41 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; … … 60 61 tr("Opens advanced relation/multipolygon editor panel"), 61 62 Shortcut.registerShortcut("view:relcontext", tr("Toggle: {0}", tr("Open Relation Editor")), 62 KeyEvent.VK_R, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150); 63 KeyEvent.VK_R, Shortcut.GROUP_LAYER, Shortcut.SHIFT_DEFAULT), 150, true); 64 65 // todo: shrink all panels to ~20 pixels 63 66 64 67 JPanel rcPanel = new JPanel(new BorderLayout()); … … 78 81 // [^] roles [new role][V][Apply] 79 82 final JPanel rolePanel = new JPanel(new GridBagLayout()); 80 final JButton toggleRolePanelButtonTop = new JButton(new TogglePanelAction(rolePanel)); 81 final JButton toggleRolePanelButtonIn = new JButton(new TogglePanelAction(rolePanel)); 82 rolePanel.add(toggleRolePanelButtonIn, GBC.std()); 83 final JButton toggleRolePanelButtonTop = new JButton(new TogglePanelAction(rolePanel) { 84 @Override 85 protected void init() { 86 putValue(Action.SMALL_ICON, ImageProvider.get("svpDown")); 87 putValue(Action.SHORT_DESCRIPTION, tr("Show role panel")); 88 } 89 }); 90 final JButton toggleRolePanelButtonIn = new JButton(new TogglePanelAction(rolePanel) { 91 @Override 92 protected void init() { 93 putValue(Action.SMALL_ICON, ImageProvider.get("svpUp")); 94 putValue(Action.SHORT_DESCRIPTION, tr("Hide role panel")); 95 } 96 }); 97 rolePanel.add(sizeButton(toggleRolePanelButtonIn, 16, 20), GBC.std()); 83 98 crRoleIndicator = new JLabel(); 84 99 rolePanel.add(crRoleIndicator, GBC.std().insets(5, 0, 5, 0)); … … 86 101 roleBox.setEditable(false); 87 102 rolePanel.add(roleBox, GBC.std().fill(GBC.HORIZONTAL)); 88 rolePanel.add( new JButton(new ApplyNewRoleAction()), GBC.std());89 rolePanel.add( new JButton(new EnterNewRoleAction()), GBC.eol());103 rolePanel.add(sizeButton(new JButton(new ApplyNewRoleAction()), 40, 20), GBC.std()); 104 rolePanel.add(sizeButton(new JButton(new EnterNewRoleAction()), 40, 20), GBC.eol()); 90 105 // rolePanel.setVisible(false); // todo: take from preferences 91 106 92 107 // [±][X] relation U [AZ][Down][Edit] 93 JPanel topLine = new JPanel(new BorderLayout()); 94 JPanel topLeftButtons = new JPanel(new FlowLayout(FlowLayout.LEFT)); 95 topLeftButtons.add(new JButton(new AddRemoveMemberAction(chosenRelation))); 96 topLeftButtons.add(toggleRolePanelButtonTop); 97 topLeftButtons.add(new JButton(new ClearChosenRelationAction(chosenRelation))); 98 topLine.add(topLeftButtons, BorderLayout.WEST); 108 JPanel topLine = new JPanel(new GridBagLayout()); 109 topLine.add(new JButton(new AddRemoveMemberAction(chosenRelation)), GBC.std()); 110 topLine.add(sizeButton(toggleRolePanelButtonTop, 16, 24), GBC.std()); 111 topLine.add(sizeButton(new JButton(new ClearChosenRelationAction(chosenRelation)), 32, 0), GBC.std()); 99 112 final ChosenRelationComponent chosenRelationComponent = new ChosenRelationComponent(chosenRelation); 100 113 chosenRelationComponent.addMouseListener(new ChosenRelationMouseAdapter()); 101 topLine.add(chosenRelationComponent, BorderLayout.CENTER); 102 JPanel topRightButtons = new JPanel(new FlowLayout(FlowLayout.RIGHT)); 114 topLine.add(chosenRelationComponent, GBC.std().fill().insets(5, 0, 5, 0)); 103 115 final Action sortAndFixAction = new SortAndFixAction(chosenRelation); 104 116 final JButton sortAndFixButton = new JButton(sortAndFixAction); 105 top RightButtons.add(sortAndFixButton);117 topLine.add(sortAndFixButton, GBC.std()); 106 118 final Action downloadChosenRelationAction = new DownloadChosenRelationAction(chosenRelation); 107 119 final JButton downloadButton = new JButton(downloadChosenRelationAction); 108 topRightButtons.add(downloadButton); 109 topRightButtons.add(new JButton(new EditChosenRelationAction(chosenRelation))); 110 topLine.add(topRightButtons, BorderLayout.EAST); 120 topLine.add(downloadButton, GBC.std()); 121 topLine.add(new JButton(new EditChosenRelationAction(chosenRelation)), GBC.eol()); 111 122 112 123 chosenRelationPanel.add(topLine, BorderLayout.CENTER); … … 148 159 bottomLine.add(Box.createHorizontalGlue(), GBC.std().fill()); 149 160 bottomLine.add(new JButton(new FindRelationAction(chosenRelation)), GBC.eol()); 150 rcPanel.add( bottomLine, BorderLayout.SOUTH);161 rcPanel.add(sizeButton(bottomLine, 0, 24), BorderLayout.SOUTH); 151 162 152 163 add(rcPanel, BorderLayout.CENTER); 153 164 154 165 popupMenu = new ChosenRelationPopupMenu(); 155 }156 157 private void configureRelationList( final JList relationsList ) {158 relationsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);159 relationsList.setCellRenderer(new OsmPrimitivRenderer() {160 @Override161 protected String getComponentToolTipText( OsmPrimitive value ) {162 return null;163 }164 });165 relationsList.addMouseListener(new MouseAdapter() {166 @Override167 public void mouseClicked( MouseEvent e ) {168 if( Main.main.getEditLayer() == null ) {169 return;170 }171 chosenRelation.set((Relation)relationsList.getSelectedValue());172 relationsList.clearSelection();173 }174 });175 166 } 176 167 … … 198 189 } 199 190 191 private JComponent sizeButton( JComponent b, int width, int height ) { 192 Dimension pref = b.getPreferredSize(); 193 b.setPreferredSize(new Dimension(width <= 0 ? pref.width : width, height <= 0 ? pref.height : height)); 194 return b; 195 } 196 200 197 @Override 201 198 public void hideNotify() { … … 219 216 if( chosenRelationPanel != null ) 220 217 chosenRelationPanel.setVisible(newRelation != null); 221 if( oldRelation != newRelation &&Main.main.getCurrentDataSet() != null )218 if( Main.main.getCurrentDataSet() != null ) 222 219 selectionChanged(Main.main.getCurrentDataSet().getSelected()); 223 220 updateRoleIndicator(); … … 421 418 422 419 public TogglePanelAction( JPanel panel ) { 423 super( "R");420 super(); 424 421 this.component = panel; 425 } 422 init(); 423 if( getValue(Action.SMALL_ICON) == null ) 424 putValue(Action.NAME, "R"); 425 } 426 427 protected void init() {} 426 428 427 429 public void actionPerformed( ActionEvent e ) { … … 451 453 private class ApplyNewRoleAction extends AbstractAction { 452 454 public ApplyNewRoleAction() { 453 super("OK"); 455 super(null, ImageProvider.get("apply")); 456 putValue(Action.SHORT_DESCRIPTION, tr("Apply chosen role to selected relation members")); 454 457 } 455 458 … … 466 469 private class EnterNewRoleAction extends AbstractAction { 467 470 public EnterNewRoleAction() { 468 super("+"); 471 super(); 472 putValue(Action.NAME, "…"); 473 // putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil")); 474 putValue(SHORT_DESCRIPTION, tr("Enter new role for selected relation members")); 469 475 } 470 476 -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/AddRemoveMemberAction.java
r25669 r25682 5 5 import static org.openstreetmap.josm.tools.I18n.tr; 6 6 import java.awt.event.ActionEvent; 7 import javax.swing.Action;8 7 import org.openstreetmap.josm.Main; 9 8 import org.openstreetmap.josm.actions.JosmAction; … … 11 10 import org.openstreetmap.josm.data.osm.Relation; 12 11 import org.openstreetmap.josm.data.osm.RelationMember; 12 import org.openstreetmap.josm.tools.ImageProvider; 13 13 import relcontext.ChosenRelation; 14 14 import relcontext.ChosenRelationListener; … … 26 26 27 27 public AddRemoveMemberAction( ChosenRelation rel ) { 28 super( "±", null, "Add/remove member from the chosen relation", null, false);28 super(null, "relcontext/addremove", tr("Add/remove members from the chosen relation"), null, false); 29 29 this.rel = rel; 30 30 rel.addChosenRelationListener(this); … … 79 79 protected void updateIcon() { 80 80 // todo: change icon based on selection 81 String name = "";81 int state = 0; // 0=unknown, 1=add, 2=remove, 3=both 82 82 if( getCurrentDataSet() == null || getCurrentDataSet().getSelected() == null 83 || getCurrentDataSet().getSelected(). size() == 0|| rel == null || rel.get() == null )84 name = "?";83 || getCurrentDataSet().getSelected().isEmpty() || rel == null || rel.get() == null ) 84 state = 0; 85 85 else { 86 86 Collection<OsmPrimitive> toAdd = new ArrayList<OsmPrimitive>(getCurrentDataSet().getSelected()); … … 88 88 int selectedSize = toAdd.size(); 89 89 if( selectedSize == 0 ) 90 name = "?";90 state = 0; 91 91 else { 92 92 toAdd.removeAll(rel.get().getMemberPrimitives()); 93 93 if( toAdd.isEmpty() ) 94 name = "-";94 state = 2; 95 95 else if( toAdd.size() < selectedSize ) 96 name = "±";96 state = 3; 97 97 else 98 name = "+";98 state = 1; 99 99 } 100 100 } 101 putValue(Action.NAME, name); 101 // String name = state == 0 ? "?" : state == 1 ? "+" : state == 2 ? "-" : "±"; 102 // putValue(Action.NAME, name); 103 if( state == 0 ) { 104 // putValue(NAME, "?"); 105 putValue(SMALL_ICON, ImageProvider.get("relcontext", "addremove")); 106 } else { 107 String iconName = state == 1 ? "add" : state == 2 ? "remove" : "addremove"; 108 putValue(NAME, null); 109 putValue(SMALL_ICON, ImageProvider.get("relcontext", iconName)); 110 } 102 111 } 103 112 } -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/ClearChosenRelationAction.java
r25667 r25682 3 3 import java.awt.event.ActionEvent; 4 4 import javax.swing.AbstractAction; 5 import javax.swing.Action; 6 import static org.openstreetmap.josm.tools.I18n.tr; 5 7 import org.openstreetmap.josm.data.osm.Relation; 8 import org.openstreetmap.josm.tools.ImageProvider; 6 9 import relcontext.ChosenRelation; 7 10 import relcontext.ChosenRelationListener; … … 11 14 12 15 public ClearChosenRelationAction( ChosenRelation rel ) { 13 super("X"); 16 super(); 17 // putValue(Action.NAME, "X"); 18 putValue(Action.SMALL_ICON, ImageProvider.get("relcontext", "clear")); 19 putValue(Action.SHORT_DESCRIPTION, tr("Clear chosen relation")); 14 20 this.rel = rel; 15 21 rel.addChosenRelationListener(this); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/CreateMultipolygonAction.java
r25670 r25682 29 29 30 30 public CreateMultipolygonAction( ChosenRelation chRel ) { 31 super("Multi", null, "Create a multipolygon from selected objects", null, false);31 super("Multi", "data/multipolygon", tr("Create a multipolygon from selected objects"), null, false); 32 32 this.chRel = chRel; 33 33 updateEnabledState(); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/CreateRelationAction.java
r25679 r25682 35 35 36 36 public CreateRelationAction( ChosenRelation chRel ) { 37 super( "+", null, "Create a relation from selected objects", null, false);37 super(tr("New"), "data/relation", tr("Create a relation from selected objects"), null, false); 38 38 this.chRel = chRel; 39 39 updateEnabledState(); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/DownloadChosenRelationAction.java
r25673 r25682 1 1 package relcontext.actions; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 3 4 import java.awt.event.ActionEvent; 4 5 import java.util.Collections; … … 12 13 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationMemberTask; 13 14 import org.openstreetmap.josm.gui.dialogs.relation.DownloadRelationTask; 15 import org.openstreetmap.josm.tools.ImageProvider; 14 16 import relcontext.ChosenRelation; 15 17 import relcontext.ChosenRelationListener; … … 24 26 25 27 public DownloadChosenRelationAction( ChosenRelation rel ) { 26 super("D"); 28 super(); 29 // putValue(NAME, "D"); 30 putValue(SMALL_ICON, ImageProvider.get("relcontext", "download")); 31 putValue(SHORT_DESCRIPTION, tr("Download all incomplete members for chosen relation")); 27 32 this.rel = rel; 28 33 rel.addChosenRelationListener(this); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/DownloadParentsAction.java
r25679 r25682 31 31 super(tr("Download all referrers")); 32 32 putValue(SMALL_ICON, ImageProvider.get("downloadreferrers")); 33 putValue(SHORT_DESCRIPTION, tr("Download referrers for the relation and its members")); 33 34 this.rel = rel; 34 35 rel.addChosenRelationListener(this); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/EditChosenRelationAction.java
r25667 r25682 1 1 package relcontext.actions; 2 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 3 4 import java.awt.event.ActionEvent; 4 5 import javax.swing.AbstractAction; … … 6 7 import org.openstreetmap.josm.data.osm.Relation; 7 8 import org.openstreetmap.josm.gui.dialogs.relation.RelationEditor; 9 import org.openstreetmap.josm.tools.ImageProvider; 8 10 import relcontext.ChosenRelation; 9 11 import relcontext.ChosenRelationListener; … … 18 20 19 21 public EditChosenRelationAction( ChosenRelation rel ) { 20 super("E"); 22 super(); 23 // putValue(NAME, "E"); 24 putValue(SMALL_ICON, ImageProvider.get("dialogs/mappaint", "pencil")); 25 putValue(SHORT_DESCRIPTION, tr("Open relation editor for chosen relation")); 21 26 this.rel = rel; 22 27 rel.addChosenRelationListener(this); -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/FindRelationAction.java
r25677 r25682 26 26 27 27 public FindRelationAction( ChosenRelation chRel ) { 28 super(" ?", null, "Find a relation", null, false);28 super("Find", "relcontext/find", "Find a relation", null, false); 29 29 this.chRel = chRel; 30 30 } -
applications/editors/josm/plugins/relcontext/src/relcontext/actions/SortAndFixAction.java
r25671 r25682 4 4 import java.util.*; 5 5 import javax.swing.AbstractAction; 6 import javax.swing.Action; 6 7 import static org.openstreetmap.josm.tools.I18n.tr; 7 8 import org.openstreetmap.josm.Main; … … 10 11 import org.openstreetmap.josm.command.SequenceCommand; 11 12 import org.openstreetmap.josm.data.osm.*; 13 import org.openstreetmap.josm.tools.ImageProvider; 12 14 import relcontext.ChosenRelation; 13 15 import relcontext.ChosenRelationListener; … … 17 19 18 20 public SortAndFixAction( ChosenRelation rel ) { 19 super("AZ"); 21 super(); 22 // putValue(Action.NAME, "AZ"); 23 putValue(Action.SMALL_ICON, ImageProvider.get("data", "warning")); 24 putValue(Action.SHORT_DESCRIPTION, tr("Sort members and fix their roles")); 20 25 this.rel = rel; 21 26 rel.addChosenRelationListener(this);
Note:
See TracChangeset
for help on using the changeset viewer.