Changeset 2326 in josm for trunk/src/org
- Timestamp:
- 2009-10-26T22:36:54+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java
r2220 r2326 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 5 6 import java.awt.BorderLayout; … … 34 35 import org.openstreetmap.josm.gui.DefaultNameFormatter; 35 36 import org.openstreetmap.josm.gui.SideButton; 37 import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction; 38 import org.openstreetmap.josm.gui.help.HelpUtil; 36 39 import org.openstreetmap.josm.tools.ImageProvider; 37 40 import org.openstreetmap.josm.tools.WindowGeometry; … … 89 92 private JPanel pnlButtons; 90 93 private OsmPrimitive targetPrimitive; 94 95 /** the private help action */ 96 private ContextSensitiveHelpAction helpAction; 97 /** the apply button */ 98 private SideButton btnApply; 91 99 92 100 /** … … 109 117 this.targetPrimitive = primitive; 110 118 updateTitle(); 119 if (primitive instanceof Way) { 120 pnlRelationMemberConflictResolver.initForWayCombining(); 121 } else if (primitive instanceof Node) { 122 pnlRelationMemberConflictResolver.initForNodeMerging(); 123 } 111 124 } 112 125 … … 123 136 ) 124 137 ); 138 helpAction.setHelpTopic(ht("/Action/CombineWay#ResolvingConflicts")); 139 getRootPane().putClientProperty("help", ht("/Action/CombineWay#ResolvingConflicts")); 125 140 } else if (targetPrimitive instanceof Node) { 126 141 setTitle( 127 142 tr( 128 "Conflicts when merging nodes - mergednode is ''{0}''",143 "Conflicts when merging nodes - target node is ''{0}''", 129 144 targetPrimitive.getDisplayName(DefaultNameFormatter.getInstance()) 130 145 ) 131 146 ); 147 helpAction.setHelpTopic(ht("/Action/MergeNodes#ResolvingConflicts")); 148 getRootPane().putClientProperty("help", ht("/Action/MergeNodes#ResolvingConflicts")); 132 149 } 133 150 } … … 141 158 getContentPane().add(pnlButtons = buildButtonPanel(), BorderLayout.SOUTH); 142 159 addWindowListener(new AdjustDividerLocationAction()); 160 HelpUtil.setHelpContext(getRootPane(), ht("/")); 143 161 } 144 162 … … 161 179 pnlTagConflictResolver.getModel().addPropertyChangeListener(applyAction); 162 180 pnlRelationMemberConflictResolver.getModel().addPropertyChangeListener(applyAction); 163 pnl.add(new SideButton(applyAction)); 181 btnApply = new SideButton(applyAction); 182 btnApply.setFocusable(true); 183 pnl.add(btnApply); 164 184 165 185 // -- cancel button 166 186 CancelAction cancelAction = new CancelAction(); 167 187 pnl.add(new SideButton(cancelAction)); 188 189 // -- help button 190 helpAction = new ContextSensitiveHelpAction(); 191 pnl.add(new SideButton(helpAction)); 168 192 169 193 return pnl; … … 242 266 RelationMemberConflictResolverModel model = getRelationMemberConflictResolverModel(); 243 267 for (int i=0; i < model.getNumDecisions(); i++) { 244 model.getDecision(i).decide(RelationMemberConflictDecisionType. REPLACE);268 model.getDecision(i).decide(RelationMemberConflictDecisionType.KEEP); 245 269 } 246 270 model.refresh(); … … 312 336 ).applySafe(this); 313 337 setCancelled(false); 338 btnApply.requestFocusInWindow(); 314 339 } else { 315 340 new WindowGeometry(this).remember(getClass().getName() + ".geometry"); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionEditor.java
r2070 r2326 3 3 4 4 import java.awt.Component; 5 import java.awt.event.MouseAdapter;6 import java.awt.event.MouseEvent;7 5 import java.util.EventObject; 8 6 … … 20 18 setOpaque(true); 21 19 DefaultComboBoxModel model = new DefaultComboBoxModel(); 22 model.addElement(RelationMemberConflictDecisionType. REPLACE);20 model.addElement(RelationMemberConflictDecisionType.KEEP); 23 21 model.addElement(RelationMemberConflictDecisionType.REMOVE); 24 22 model.addElement(RelationMemberConflictDecisionType.UNDECIDED); -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionRenderer.java
r2099 r2326 5 5 import java.awt.Font; 6 6 7 import javax.swing.DefaultComboBoxModel; 8 import javax.swing.JComboBox; 7 9 import javax.swing.JLabel; 8 10 import javax.swing.JList; … … 14 16 public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer{ 15 17 18 private JComboBox cbDecisionTypes; 19 16 20 protected void resetTableRenderer() { 17 21 setOpaque(true); … … 28 32 } 29 33 34 public RelationMemberConflictDecisionRenderer() { 35 DefaultComboBoxModel model = new DefaultComboBoxModel(); 36 cbDecisionTypes = new JComboBox(model); 37 model.addElement(RelationMemberConflictDecisionType.KEEP); 38 model.addElement(RelationMemberConflictDecisionType.REMOVE); 39 model.addElement(RelationMemberConflictDecisionType.UNDECIDED); 40 cbDecisionTypes.setRenderer(this); 41 } 30 42 31 43 /* --------------------------------------------------------------------------------- */ … … 40 52 } 41 53 RelationMemberConflictDecisionType decision = (RelationMemberConflictDecisionType)value; 42 RelationMemberConflictDecisionType.prepareLabel(decision, this);43 return this;54 cbDecisionTypes.setSelectedItem(decision); 55 return cbDecisionTypes; 44 56 } 45 57 -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java
r2099 r2326 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 import java.awt.Font;7 5 8 6 import javax.swing.DefaultComboBoxModel; … … 12 10 public enum RelationMemberConflictDecisionType { 13 11 /** 14 * replacethe respective relation memberwith a member referring15 * to the new primitive12 * keep the respective relation member for the target primitive (the target node 13 * in a node merge operation or the target way in a combine way operation) 16 14 */ 17 REPLACE,15 KEEP, 18 16 19 17 /** … … 34 32 label.setToolTipText(tr("Remove this relation member from the relation")); 35 33 break; 36 case REPLACE:37 label.setText(tr(" Replace"));38 label.setToolTipText(tr(" Replace the way thismemberrefers to with the combined way"));34 case KEEP: 35 label.setText(tr("Keep")); 36 label.setToolTipText(tr("Keep this relation member for the target object")); 39 37 break; 40 38 case UNDECIDED: … … 44 42 } 45 43 } 46 47 static public void prepareComboBox(RelationMemberConflictDecisionType decision, JComboBox comboBox) {48 DefaultComboBoxModel model = (DefaultComboBoxModel)comboBox.getModel();49 model.removeAllElements();50 switch(decision) {51 case REMOVE:52 model.addElement(tr("Remove"));53 comboBox.setToolTipText(tr("Remove this relation member from the relation"));54 comboBox.setSelectedIndex(0);55 break;56 case REPLACE:57 model.addElement(tr("Replace"));58 comboBox.setToolTipText(tr("Replace the way this member refers to with the combined way"));59 comboBox.setSelectedIndex(0);60 break;61 case UNDECIDED:62 model.addElement(tr("Undecided"));63 comboBox.setToolTipText(tr("Not decided yet"));64 comboBox.setSelectedIndex(0);65 break;66 }67 }68 44 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java
r2237 r2326 7 7 import java.awt.BorderLayout; 8 8 import java.awt.FlowLayout; 9 import java.awt.GridBagConstraints; 10 import java.awt.GridBagLayout; 11 import java.awt.Insets; 9 12 import java.awt.event.ActionEvent; 13 import java.awt.event.FocusAdapter; 14 import java.awt.event.FocusEvent; 10 15 import java.util.Collection; 11 16 … … 27 32 import org.openstreetmap.josm.command.Command; 28 33 import org.openstreetmap.josm.data.osm.OsmPrimitive; 34 import org.openstreetmap.josm.gui.JMultilineLabel; 29 35 import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField; 30 36 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; … … 40 46 private RelationMemberConflictResolverModel model; 41 47 private RelationMemberConflictResolverTable tblResolver; 48 private JMultilineLabel lblHeader; 42 49 43 50 protected void build() { 44 setLayout(new BorderLayout()); 45 model=new RelationMemberConflictResolverModel(); 46 add (new JScrollPane(tblResolver = new RelationMemberConflictResolverTable(model)), BorderLayout.CENTER); 47 JPanel pnl = new JPanel(); 51 setLayout(new GridBagLayout()); 52 JPanel pnl = new JPanel(); 53 pnl.setLayout(new BorderLayout()); 54 pnl.add(lblHeader = new JMultilineLabel("")); 55 GridBagConstraints gc = new GridBagConstraints(); 56 gc.fill = GridBagConstraints.HORIZONTAL; 57 gc.weighty = 0.0; 58 gc.weightx = 1.0; 59 gc.insets = new Insets(5,5,5,5); 60 add(pnl, gc); 61 model = new RelationMemberConflictResolverModel(); 62 63 gc.gridy = 1; 64 gc.weighty = 1.0; 65 gc.fill = GridBagConstraints.BOTH; 66 gc.insets = new Insets(0,0,0,0); 67 add(new JScrollPane(tblResolver = new RelationMemberConflictResolverTable(model)), gc); 68 pnl = new JPanel(); 48 69 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 49 70 pnl.add(buildRoleEditingPanel()); 50 71 pnl.add(buildTagRelationsPanel()); 51 add(pnl, BorderLayout.SOUTH); 72 gc.gridy = 2; 73 gc.weighty = 0.0; 74 gc.fill = GridBagConstraints.HORIZONTAL; 75 add(pnl,gc); 52 76 } 53 77 … … 57 81 pnl.add(new JLabel(tr("Role:"))); 58 82 pnl.add(tfRole = new AutoCompletingTextField(10)); 83 tfRole.setToolTipText(tr("Enter a role for all relation memberships")); 59 84 pnl.add(new JButton(new ApplyRoleAction())); 85 tfRole.addActionListener(new ApplyRoleAction()); 86 tfRole.addFocusListener( 87 new FocusAdapter() { 88 @Override 89 public void focusGained(FocusEvent e) { 90 tfRole.selectAll(); 91 } 92 } 93 ); 60 94 return pnl; 61 95 } … … 64 98 JPanel pnl = new JPanel(); 65 99 pnl.setLayout(new FlowLayout(FlowLayout.LEFT)); 66 cbTagRelations = new JCheckBox(tr("Tag modified relations with 100 cbTagRelations = new JCheckBox(tr("Tag modified relations with ")); 67 101 cbTagRelations.addChangeListener(new ToggleTagRelationsAction()); 102 cbTagRelations.setToolTipText( 103 tr("<html>Select to enable entering a tag which will be applied<br>" 104 + "to all modified relations.</html>")); 68 105 pnl.add(cbTagRelations); 69 pnl.add(new JLabel(trc("tag","Key:"))); 106 pnl.add(new JLabel(trc("tag", "Key:"))); 70 107 pnl.add(tfKey = new AutoCompletingTextField(10)); 108 tfKey.setToolTipText(tr("<html>Enter a tag key, i.e. <strong><tt>fixme</tt></strong></html>")); 71 109 pnl.add(new JLabel(tr("Value:"))); 72 110 pnl.add(tfValue = new AutoCompletingTextField(10)); 111 tfValue.setToolTipText(tr("<html>Enter a tag value, i.e. <strong><tt>check members</tt></strong></html>")); 73 112 cbTagRelations.setSelected(false); 74 113 tfKey.setEnabled(false); … … 80 119 build(); 81 120 } 121 122 public void initForWayCombining() { 123 lblHeader.setText(tr("<html>The combined ways are members in one ore more relations. " 124 + "Please decide whether your want to <strong>keep</strong> these memberships " 125 + "for the combined way or whether you want to <strong>remove</strong> them.<br>" 126 + "The default is to <strong>keep</strong> them: the combined way will take the place of the original way in the membership." 127 + "</html>")); 128 invalidate(); 129 } 130 131 public void initForNodeMerging() { 132 lblHeader.setText(tr("<html>The merged nodes are members in one ore more relations. " 133 + "Please decide whether your want to <strong>keep</strong> these memberships " 134 + "for the target node or whether you want to <strong>remove</strong> them.<br>" 135 + "The default is to <strong>keep</strong> them: the target node will take the place of the original node in the membership." 136 + "</html>")); 137 invalidate(); 138 } 82 139 83 140 class ApplyRoleAction extends AbstractAction { … … 95 152 class ToggleTagRelationsAction implements ChangeListener { 96 153 public void stateChanged(ChangeEvent e) { 97 ButtonModel buttonModel = ((AbstractButton)e.getSource()).getModel(); 154 ButtonModel buttonModel = ((AbstractButton) e.getSource()).getModel(); 98 155 tfKey.setEnabled(buttonModel.isSelected()); 99 156 tfValue.setEnabled(buttonModel.isSelected()); 100 tfKey.setBackground(buttonModel.isSelected() ? UIManager.getColor("TextField.background") : UIManager.getColor("Panel.background")); 101 tfValue.setBackground(buttonModel.isSelected() ? UIManager.getColor("TextField.background") : UIManager.getColor("Panel.background")); 157 tfKey.setBackground(buttonModel.isSelected() ? UIManager.getColor("TextField.background") : UIManager 158 .getColor("Panel.background")); 159 tfValue.setBackground(buttonModel.isSelected() ? UIManager.getColor("TextField.background") : UIManager 160 .getColor("Panel.background")); 102 161 } 103 162 } … … 108 167 109 168 public Command buildTagApplyCommands(Collection<? extends OsmPrimitive> primitives) { 110 if (! cbTagRelations.isSelected()) return null; 111 if (tfKey.getText().trim().equals("")) return null; 112 if (tfValue.getText().trim().equals("")) return null; 113 if (primitives == null || primitives.isEmpty()) return null; 169 if (!cbTagRelations.isSelected()) 170 return null; 171 if (tfKey.getText().trim().equals("")) 172 return null; 173 if (tfValue.getText().trim().equals("")) 174 return null; 175 if (primitives == null || primitives.isEmpty()) 176 return null; 114 177 return new ChangePropertyCommand(primitives, tfKey.getText(), tfValue.getText()); 115 178 } … … 120 183 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithMemberRoles(acList); 121 184 tfRole.setAutoCompletionList(acList); 122 AutoCompletingTextField editor = (AutoCompletingTextField)tblResolver.getColumnModel().getColumn(2).getCellEditor(); 185 AutoCompletingTextField editor = (AutoCompletingTextField) tblResolver.getColumnModel().getColumn(2) 186 .getCellEditor(); 123 187 if (editor != null) { 124 188 editor.setAutoCompletionList(acList); 125 189 } 126 190 AutoCompletionList acList2 = new AutoCompletionList(); 127 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithKeys(acList2, false /* don't 191 AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithKeys(acList2, false /* don'tappend */); 128 192 tfKey.setAutoCompletionList(acList2); 129 193 } -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java
r2157 r2326 234 234 } else { 235 235 switch(decision.getDecision()) { 236 case REPLACE:236 case KEEP: 237 237 rmNew = new RelationMember(decision.getRole(),newPrimitive); 238 238 modifiedRelation.addMember(rmNew); … … 280 280 switch(decision.getDecision()) { 281 281 case REMOVE: return true; 282 case REPLACE:282 case KEEP: 283 283 if (!relation.getMember(i).getRole().equals(decision.getRole())) 284 284 return true; -
trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTable.java
r2070 r2326 6 6 7 7 import javax.swing.AbstractAction; 8 import javax.swing.JComboBox; 8 9 import javax.swing.JComponent; 9 10 import javax.swing.JTable; … … 37 38 getActionMap().put("selectNextColumnCell", selectNextColumnCellAction); 38 39 getActionMap().put("selectPreviousColumnCell", selectPreviousColumnCellAction); 40 41 setRowHeight((int)new JComboBox().getPreferredSize().getHeight()); 39 42 } 40 43 -
trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java
r2308 r2326 3 3 4 4 import java.awt.event.ActionEvent; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 6 6 7 import javax.swing.AbstractAction; … … 20 21 21 22 /** 23 * Sets the help topic 24 * 25 * @param relativeHelpTopic the relative help topic 26 */ 27 public void setHelpTopic(String relativeHelpTopic) { 28 if (relativeHelpTopic == null) 29 relativeHelpTopic = "/"; 30 this.helpTopic = relativeHelpTopic; 31 } 32 33 /** 34 * Creates a help topic for the root help topic 35 * 36 */ 37 public ContextSensitiveHelpAction() { 38 this(ht("/")); 39 } 40 41 /** 22 42 * 23 43 * @param helpTopic
Note:
See TracChangeset
for help on using the changeset viewer.