Ignore:
Timestamp:
06.02.2010 09:37:48 (2 years ago)
Author:
jttt
Message:

Improvements in conflicts gui

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMerger.java

    r2846 r2945  
    5757    private CopyAfterCurrentLeftAction copyAfterCurrentLeftAction; 
    5858    private CopyEndLeftAction copyEndLeftAction; 
     59    private CopyAllLeft copyAllLeft; 
    5960 
    6061    private CopyStartRightAction copyStartRightAction; 
     
    6263    private CopyAfterCurrentRightAction copyAfterCurrentRightAction; 
    6364    private CopyEndRightAction copyEndRightAction; 
     65    private CopyAllRight copyAllRight; 
    6466 
    6567    private MoveUpMergedAction moveUpMergedAction; 
     
    118120        mergedEntriesTable.getSelectionModel().addListSelectionListener(moveDownMergedAction); 
    119121        mergedEntriesTable.getSelectionModel().addListSelectionListener(removeMergedAction); 
     122 
     123        model.addObserver(copyAllLeft); 
     124        model.addObserver(copyAllRight); 
     125        model.addPropertyChangeListener(copyAllLeft); 
     126        model.addPropertyChangeListener(copyAllRight); 
    120127    } 
    121128 
     
    153160        pnl.add(btn, gc); 
    154161 
     162        gc.gridx = 0; 
     163        gc.gridy = 4; 
     164        copyAllLeft = new CopyAllLeft(); 
     165        btn = new JButton(copyAllLeft); 
     166        btn.setName("button.copyallleft"); 
     167        pnl.add(btn, gc); 
     168 
    155169        return pnl; 
    156170    } 
     
    180194        copyEndRightAction = new CopyEndRightAction(); 
    181195        pnl.add(new JButton(copyEndRightAction), gc); 
     196 
     197        gc.gridx = 0; 
     198        gc.gridy = 4; 
     199        copyAllRight = new CopyAllRight(); 
     200        pnl.add(new JButton(copyAllRight), gc); 
    182201 
    183202        return pnl; 
     
    614633                    && ! mergedEntriesTable.getSelectionModel().isSelectionEmpty() 
    615634            ); 
     635        } 
     636    } 
     637 
     638    class CopyAllLeft extends AbstractAction implements Observer, PropertyChangeListener { 
     639 
     640        public CopyAllLeft() { 
     641            ImageIcon icon = ImageProvider.get("dialogs/conflict", "useallleft.png"); 
     642            putValue(Action.SMALL_ICON, icon); 
     643            putValue(Action.SHORT_DESCRIPTION, tr("Use all mine elements")); 
     644        } 
     645 
     646        public void actionPerformed(ActionEvent arg0) { 
     647            model.copyAll(ListRole.MY_ENTRIES); 
     648            model.setFrozen(true); 
     649        } 
     650 
     651        private void updateEnabledState() { 
     652            setEnabled(model.getMergedEntries().isEmpty() && !model.isFrozen()); 
     653        } 
     654 
     655        public void update(Observable o, Object arg) { 
     656            updateEnabledState(); 
     657        } 
     658 
     659        public void propertyChange(PropertyChangeEvent evt) { 
     660            updateEnabledState(); 
     661        } 
     662    } 
     663 
     664    class CopyAllRight extends AbstractAction implements Observer, PropertyChangeListener { 
     665 
     666        public CopyAllRight() { 
     667            ImageIcon icon = ImageProvider.get("dialogs/conflict", "useallright.png"); 
     668            putValue(Action.SMALL_ICON, icon); 
     669            putValue(Action.SHORT_DESCRIPTION, tr("Use all their elements")); 
     670        } 
     671 
     672        public void actionPerformed(ActionEvent arg0) { 
     673            model.copyAll(ListRole.THEIR_ENTRIES); 
     674            model.setFrozen(true); 
     675        } 
     676 
     677        private void updateEnabledState() { 
     678            setEnabled(model.getMergedEntries().isEmpty() && !model.isFrozen()); 
     679        } 
     680 
     681        public void update(Observable o, Object arg) { 
     682            updateEnabledState(); 
     683        } 
     684 
     685        public void propertyChange(PropertyChangeEvent evt) { 
     686            updateEnabledState(); 
    616687        } 
    617688    } 
Note: See TracChangeset for help on using the changeset viewer.