Ignore:
Timestamp:
2009-06-06T16:25:25+02:00 (15 years ago)
Author:
Gubaer
Message:

added row numbers and synchronized scrolling in conflict resolution dialog
fixed bugs in conflict resolution

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagMerger.java

    r1631 r1642  
    1313import java.awt.event.MouseAdapter;
    1414import java.awt.event.MouseEvent;
    15 import java.net.URL;
    1615import java.util.ArrayList;
    1716
     
    2726import javax.swing.event.ListSelectionListener;
    2827
     28import org.openstreetmap.josm.tools.ImageProvider;
     29/**
     30 * UI component for resolving conflicts in the tag sets of two {@see OsmPrimitive}s.
     31 *
     32 */
    2933public class TagMerger extends JPanel {
    3034
     
    3741    AdjustmentSynchronizer adjustmentSynchronizer;
    3842
     43    /**
     44     * embeds table in a new {@see JScrollPane} and returns th scroll pane
     45     *
     46     * @param table the table
     47     * @return the scroll pane embedding the table
     48     */
    3949    protected JScrollPane embeddInScrollPane(JTable table) {
    4050        JScrollPane pane = new JScrollPane(table);
     
    4656    }
    4757
     58    /**
     59     * builds the table for my tag set (table already embedded in a scroll pane)
     60     *
     61     * @return the table (embedded in a scroll pane)
     62     */
    4863    protected JScrollPane buildMineTagTable() {
    4964        mineTable  = new JTable(
     
    5772    }
    5873
     74    /**
     75     * builds the table for their tag set (table already embedded in a scroll pane)
     76     *
     77     * @return the table (embedded in a scroll pane)
     78     */
    5979    protected JScrollPane buildTheirTable() {
    6080        theirTable  = new JTable(
     
    6888    }
    6989
    70     protected JScrollPane buildUndecidedTable() {
     90    /**
     91     * builds the table for the merged tag set (table already embedded in a scroll pane)
     92     *
     93     * @return the table (embedded in a scroll pane)
     94     */
     95
     96    protected JScrollPane buildMergedTable() {
    7197        mergedTable  = new JTable(
    7298                model,
    7399                new TagMergeColumnModel(
    74                         new UndecidedTableCellRenderer()
     100                        new MergedTableCellRenderer()
    75101                )
    76102        );
     
    79105    }
    80106
     107    /**
     108     * build the user interface
     109     */
    81110    protected void build() {
    82111        GridBagConstraints gc = new GridBagConstraints();
     
    152181        gc.weightx = 0.3;
    153182        gc.weighty = 1.0;
    154         add(buildUndecidedTable(), gc);
     183        add(buildMergedTable(), gc);
    155184
    156185        gc.gridx = 3;
     
    205234    }
    206235
     236    /**
     237     * replies the model used by this tag merger
     238     *
     239     * @return the model
     240     */
    207241    public TagMergeModel getModel() {
    208242        return model;
    209243    }
    210244
    211     protected ImageIcon loadIcon(String name) {
    212         String path = "/images/dialogs/conflict/" + name;
    213         URL url = this.getClass().getResource(path);
    214         if (url == null) {
    215             System.out.println(tr("WARNING: failed to load resource {0}", path));
    216             return null;
    217         }
    218         return new ImageIcon(url);
    219     }
    220 
     245    /**
     246     * Keeps the currently selected tags in my table in the list of merged tags.
     247     *
     248     */
    221249    class KeepMineAction extends AbstractAction implements ListSelectionListener {
    222 
    223 
    224250        public KeepMineAction() {
    225             ImageIcon icon = loadIcon("tagkeepmine.png");
     251            ImageIcon icon = ImageProvider.get("dialogs/conflict", "tagkeepmine.png");
    226252            if (icon != null) {
    227253                putValue(Action.SMALL_ICON, icon);
     
    246272    }
    247273
     274    /**
     275     * Keeps the currently selected tags in their table in the list of merged tags.
     276     *
     277     */
    248278    class KeepTheirAction extends AbstractAction implements ListSelectionListener {
    249 
    250279        public KeepTheirAction() {
    251             ImageIcon icon = loadIcon("tagkeeptheir.png");
     280            ImageIcon icon = ImageProvider.get("dialogs/conflict", "tagkeeptheir.png");
    252281            if (icon != null) {
    253282                putValue(Action.SMALL_ICON, icon);
     
    272301    }
    273302
     303    /**
     304     * Synchronizes scrollbar adjustments between a set of
     305     * {@see Adjustable}s. Whenever the adjustment of one of
     306     * the registerd Adjustables is updated the adjustment of
     307     * the other registered Adjustables is adjusted too.
     308     *
     309     */
    274310    class AdjustmentSynchronizer implements AdjustmentListener {
    275311        private final ArrayList<Adjustable> synchronizedAdjustables;
     
    297333    }
    298334
     335    /**
     336     * Handler for double clicks on entries in the three tag tables.
     337     *
     338     */
    299339    class DoubleClickAdapter extends MouseAdapter {
    300340
     
    324364    }
    325365
     366    /**
     367     * Sets the currently selected tags in the table of merged tags to state
     368     * {@see MergeDecisionType#UNDECIDED}
     369     *
     370     */
    326371    class UndecideAction extends AbstractAction implements ListSelectionListener  {
    327372
    328373        public UndecideAction() {
    329             ImageIcon icon = loadIcon("tagundecide.png");
     374            ImageIcon icon = ImageProvider.get("dialogs/conflict", "tagundecide.png");
    330375            if (icon != null) {
    331376                putValue(Action.SMALL_ICON, icon);
Note: See TracChangeset for help on using the changeset viewer.