Changeset 2326 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2009-10-26T22:36:54+01:00 (15 years ago)
Author:
Gubaer
Message:

Slightly improved dialogs for way combining and node merging.
Added context sensitive help.

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  
    22
    33import static org.openstreetmap.josm.tools.I18n.tr;
     4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    45
    56import java.awt.BorderLayout;
     
    3435import org.openstreetmap.josm.gui.DefaultNameFormatter;
    3536import org.openstreetmap.josm.gui.SideButton;
     37import org.openstreetmap.josm.gui.help.ContextSensitiveHelpAction;
     38import org.openstreetmap.josm.gui.help.HelpUtil;
    3639import org.openstreetmap.josm.tools.ImageProvider;
    3740import org.openstreetmap.josm.tools.WindowGeometry;
     
    8992    private JPanel pnlButtons;
    9093    private OsmPrimitive targetPrimitive;
     94   
     95    /** the private help action */
     96    private ContextSensitiveHelpAction helpAction;
     97    /** the apply button */
     98    private SideButton btnApply;
    9199
    92100    /**
     
    109117        this.targetPrimitive = primitive;
    110118        updateTitle();
     119        if (primitive instanceof Way) {
     120            pnlRelationMemberConflictResolver.initForWayCombining();           
     121        } else if (primitive instanceof Node) {
     122            pnlRelationMemberConflictResolver.initForNodeMerging();
     123        }
    111124    }
    112125
     
    123136                    )
    124137            );
     138            helpAction.setHelpTopic(ht("/Action/CombineWay#ResolvingConflicts"));
     139            getRootPane().putClientProperty("help", ht("/Action/CombineWay#ResolvingConflicts"));
    125140        } else if (targetPrimitive instanceof Node) {
    126141            setTitle(
    127142                    tr(
    128                             "Conflicts when merging nodes - merged node is ''{0}''",
     143                            "Conflicts when merging nodes - target node is ''{0}''",
    129144                            targetPrimitive.getDisplayName(DefaultNameFormatter.getInstance())
    130145                    )
    131146            );
     147            helpAction.setHelpTopic(ht("/Action/MergeNodes#ResolvingConflicts"));
     148            getRootPane().putClientProperty("help", ht("/Action/MergeNodes#ResolvingConflicts"));
    132149        }
    133150    }
     
    141158        getContentPane().add(pnlButtons = buildButtonPanel(), BorderLayout.SOUTH);
    142159        addWindowListener(new AdjustDividerLocationAction());
     160        HelpUtil.setHelpContext(getRootPane(), ht("/"));
    143161    }
    144162
     
    161179        pnlTagConflictResolver.getModel().addPropertyChangeListener(applyAction);
    162180        pnlRelationMemberConflictResolver.getModel().addPropertyChangeListener(applyAction);
    163         pnl.add(new SideButton(applyAction));
     181        btnApply = new SideButton(applyAction);
     182        btnApply.setFocusable(true);
     183        pnl.add(btnApply);
    164184
    165185        // -- cancel button
    166186        CancelAction cancelAction = new CancelAction();
    167187        pnl.add(new SideButton(cancelAction));
     188
     189        // -- help button
     190        helpAction = new ContextSensitiveHelpAction();
     191        pnl.add(new SideButton(helpAction));
    168192
    169193        return pnl;
     
    242266        RelationMemberConflictResolverModel model = getRelationMemberConflictResolverModel();
    243267        for (int i=0; i < model.getNumDecisions(); i++) {
    244             model.getDecision(i).decide(RelationMemberConflictDecisionType.REPLACE);
     268            model.getDecision(i).decide(RelationMemberConflictDecisionType.KEEP);
    245269        }
    246270        model.refresh();
     
    312336            ).applySafe(this);
    313337            setCancelled(false);
     338            btnApply.requestFocusInWindow();
    314339        } else {
    315340            new WindowGeometry(this).remember(getClass().getName() + ".geometry");
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionEditor.java

    r2070 r2326  
    33
    44import java.awt.Component;
    5 import java.awt.event.MouseAdapter;
    6 import java.awt.event.MouseEvent;
    75import java.util.EventObject;
    86
     
    2018        setOpaque(true);
    2119        DefaultComboBoxModel model = new DefaultComboBoxModel();
    22         model.addElement(RelationMemberConflictDecisionType.REPLACE);
     20        model.addElement(RelationMemberConflictDecisionType.KEEP);
    2321        model.addElement(RelationMemberConflictDecisionType.REMOVE);
    2422        model.addElement(RelationMemberConflictDecisionType.UNDECIDED);
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionRenderer.java

    r2099 r2326  
    55import java.awt.Font;
    66
     7import javax.swing.DefaultComboBoxModel;
     8import javax.swing.JComboBox;
    79import javax.swing.JLabel;
    810import javax.swing.JList;
     
    1416public class RelationMemberConflictDecisionRenderer extends JLabel implements TableCellRenderer, ListCellRenderer{
    1517
     18    private JComboBox cbDecisionTypes;
     19   
    1620    protected void resetTableRenderer() {
    1721        setOpaque(true);
     
    2832    }
    2933
     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    }
    3042
    3143    /* --------------------------------------------------------------------------------- */
     
    4052        }
    4153        RelationMemberConflictDecisionType decision = (RelationMemberConflictDecisionType)value;
    42         RelationMemberConflictDecisionType.prepareLabel(decision, this);
    43         return this;
     54        cbDecisionTypes.setSelectedItem(decision);
     55        return cbDecisionTypes;
    4456    }
    4557
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictDecisionType.java

    r2099 r2326  
    33
    44import static org.openstreetmap.josm.tools.I18n.tr;
    5 
    6 import java.awt.Font;
    75
    86import javax.swing.DefaultComboBoxModel;
     
    1210public enum RelationMemberConflictDecisionType {
    1311    /**
    14      * replace the respective relation member with a member referring
    15      * to the new primitive
     12     * 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)
    1614     */
    17     REPLACE,
     15    KEEP,
    1816
    1917    /**
     
    3432            label.setToolTipText(tr("Remove this relation member from the relation"));
    3533            break;
    36         case REPLACE:
    37             label.setText(tr("Replace"));
    38             label.setToolTipText(tr("Replace the way this member refers 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"));
    3937            break;
    4038        case UNDECIDED:
     
    4442        }
    4543    }
    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     }
    6844}
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolver.java

    r2237 r2326  
    77import java.awt.BorderLayout;
    88import java.awt.FlowLayout;
     9import java.awt.GridBagConstraints;
     10import java.awt.GridBagLayout;
     11import java.awt.Insets;
    912import java.awt.event.ActionEvent;
     13import java.awt.event.FocusAdapter;
     14import java.awt.event.FocusEvent;
    1015import java.util.Collection;
    1116
     
    2732import org.openstreetmap.josm.command.Command;
    2833import org.openstreetmap.josm.data.osm.OsmPrimitive;
     34import org.openstreetmap.josm.gui.JMultilineLabel;
    2935import org.openstreetmap.josm.gui.tagging.AutoCompletingTextField;
    3036import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache;
     
    4046    private RelationMemberConflictResolverModel model;
    4147    private RelationMemberConflictResolverTable tblResolver;
     48    private JMultilineLabel lblHeader;
    4249
    4350    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();
    4869        pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS));
    4970        pnl.add(buildRoleEditingPanel());
    5071        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);
    5276    }
    5377
     
    5781        pnl.add(new JLabel(tr("Role:")));
    5882        pnl.add(tfRole = new AutoCompletingTextField(10));
     83        tfRole.setToolTipText(tr("Enter a role for all relation memberships"));
    5984        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        );
    6094        return pnl;
    6195    }
     
    6498        JPanel pnl = new JPanel();
    6599        pnl.setLayout(new FlowLayout(FlowLayout.LEFT));
    66         cbTagRelations = new JCheckBox(tr("Tag modified relations with   "));
     100        cbTagRelations = new JCheckBox(tr("Tag modified relations with "));
    67101        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>"));
    68105        pnl.add(cbTagRelations);
    69         pnl.add(new JLabel(trc("tag","Key:")));
     106        pnl.add(new JLabel(trc("tag", "Key:")));       
    70107        pnl.add(tfKey = new AutoCompletingTextField(10));
     108        tfKey.setToolTipText(tr("<html>Enter a tag key, i.e. <strong><tt>fixme</tt></strong></html>"));
    71109        pnl.add(new JLabel(tr("Value:")));
    72110        pnl.add(tfValue = new AutoCompletingTextField(10));
     111        tfValue.setToolTipText(tr("<html>Enter a tag value, i.e. <strong><tt>check members</tt></strong></html>"));
    73112        cbTagRelations.setSelected(false);
    74113        tfKey.setEnabled(false);
     
    80119        build();
    81120    }
     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     }
    82139
    83140    class ApplyRoleAction extends AbstractAction {
     
    95152    class ToggleTagRelationsAction implements ChangeListener {
    96153        public void stateChanged(ChangeEvent e) {
    97             ButtonModel buttonModel = ((AbstractButton)e.getSource()).getModel();
     154            ButtonModel buttonModel = ((AbstractButton) e.getSource()).getModel();
    98155            tfKey.setEnabled(buttonModel.isSelected());
    99156            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"));
    102161        }
    103162    }
     
    108167
    109168    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;
    114177        return new ChangePropertyCommand(primitives, tfKey.getText(), tfValue.getText());
    115178    }
     
    120183        AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithMemberRoles(acList);
    121184        tfRole.setAutoCompletionList(acList);
    122         AutoCompletingTextField editor = (AutoCompletingTextField)tblResolver.getColumnModel().getColumn(2).getCellEditor();
     185        AutoCompletingTextField editor = (AutoCompletingTextField) tblResolver.getColumnModel().getColumn(2)
     186                .getCellEditor();
    123187        if (editor != null) {
    124188            editor.setAutoCompletionList(acList);
    125189        }
    126190        AutoCompletionList acList2 = new AutoCompletionList();
    127         AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithKeys(acList2, false /* don't append */);
     191        AutoCompletionCache.getCacheForLayer(Main.main.getEditLayer()).populateWithKeys(acList2, false /* don'tappend */);
    128192        tfKey.setAutoCompletionList(acList2);
    129193    }
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java

    r2157 r2326  
    234234            } else {
    235235                switch(decision.getDecision()) {
    236                     case REPLACE:
     236                    case KEEP:
    237237                        rmNew = new RelationMember(decision.getRole(),newPrimitive);
    238238                        modifiedRelation.addMember(rmNew);
     
    280280            switch(decision.getDecision()) {
    281281                case REMOVE: return true;
    282                 case REPLACE:
     282                case KEEP:
    283283                    if (!relation.getMember(i).getRole().equals(decision.getRole()))
    284284                        return true;
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverTable.java

    r2070 r2326  
    66
    77import javax.swing.AbstractAction;
     8import javax.swing.JComboBox;
    89import javax.swing.JComponent;
    910import javax.swing.JTable;
     
    3738        getActionMap().put("selectNextColumnCell", selectNextColumnCellAction);
    3839        getActionMap().put("selectPreviousColumnCell", selectPreviousColumnCellAction);
     40       
     41        setRowHeight((int)new JComboBox().getPreferredSize().getHeight());
    3942    }
    4043
  • trunk/src/org/openstreetmap/josm/gui/help/ContextSensitiveHelpAction.java

    r2308 r2326  
    33
    44import java.awt.event.ActionEvent;
     5import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
    56
    67import javax.swing.AbstractAction;
     
    2021
    2122    /**
     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    /**
    2242     *
    2343     * @param helpTopic
Note: See TracChangeset for help on using the changeset viewer.