Ignore:
Timestamp:
2009-06-01T22:20:03+02:00 (15 years ago)
Author:
Gubaer
Message:

added support for merging member lists of relations in extended conflict resolution dialog

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ConflictResolutionDialog.java

    r1627 r1631  
    1010import java.awt.Point;
    1111import java.awt.event.ActionEvent;
    12 import java.net.URL;
    1312import java.util.logging.Logger;
    1413
     
    1615import javax.swing.Action;
    1716import javax.swing.BorderFactory;
    18 import javax.swing.ImageIcon;
    1917import javax.swing.JButton;
    2018import javax.swing.JDialog;
     
    2523import org.openstreetmap.josm.command.Command;
    2624import org.openstreetmap.josm.gui.conflict.ConflictResolver;
     25import org.openstreetmap.josm.tools.ImageProvider;
    2726
     27/**
     28 * This is an extended dialog for resolving conflict between {@see OsmPrimitive}.
     29 *
     30 *
     31 */
    2832public class ConflictResolutionDialog extends JDialog {
    2933    private static final Logger logger = Logger.getLogger(ConflictResolutionDialog.class.getName());
    3034    public final static Dimension DEFAULT_SIZE = new Dimension(600,400);
    3135
     36    /** the conflict resolver component */
    3237    private ConflictResolver resolver;
    33        
     38
     39    /**
     40     * restore position and size on screen from preference settings
     41     *
     42     */
    3443    protected void restorePositionAndDimension() {
    3544        Point p = new Point();
     
    3948            p.x = Math.max(0,p.x);
    4049        } catch(Exception e) {
    41             logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0"); 
     50            logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0");
    4251            p.x = 0;
    4352        }
     
    4655            p.y = Math.max(0,p.y);
    4756        } catch(Exception e) {
    48             logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0"); 
     57            logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0");
    4958            p.y = 0;
    5059        }
     
    5362            d.width = Math.max(0,d.width);
    5463        } catch(Exception e) {
    55             logger.warning("unexpected value for preference conflictresolutiondialog.width, assuming " + DEFAULT_SIZE.width); 
     64            logger.warning("unexpected value for preference conflictresolutiondialog.width, assuming " + DEFAULT_SIZE.width);
    5665            p.y = 0;
    5766        }
     
    6069            d.height = Math.max(0,d.height);
    6170        } catch(Exception e) {
    62             logger.warning("unexpected value for preference conflictresolutiondialog.height, assuming " +  + DEFAULT_SIZE.height); 
     71            logger.warning("unexpected value for preference conflictresolutiondialog.height, assuming " +  + DEFAULT_SIZE.height);
    6372            p.y = 0;
    6473        }
    65        
     74
    6675        setLocation(p);
    6776        setSize(d);
    6877    }
    69    
     78
     79    /**
     80     * remember position and size on screen in the preferences
     81     *
     82     */
    7083    protected void rememberPositionAndDimension() {
    7184        Point p = getLocation();
    7285        Main.pref.put("conflictresolutiondialog.x", Integer.toString(p.x));
    7386        Main.pref.put("conflictresolutiondialog.y", Integer.toString(p.y));
    74        
     87
    7588        Dimension d = getSize();
    7689        Main.pref.put("conflictresolutiondialog.width", Integer.toString(d.width));
    7790        Main.pref.put("conflictresolutiondialog.height", Integer.toString(d.height));
    7891    }
    79    
     92
     93
     94    @Override
    8095    public void setVisible(boolean isVisible) {
    8196        if (isVisible){
     
    86101        super.setVisible(isVisible);
    87102    }
    88    
     103
     104    /**
     105     * builds the sub panel with the control buttons
     106     *
     107     * @return the panel
     108     */
    89109    protected JPanel buildButtonRow() {
    90110        JPanel pnl = new JPanel();
    91111        pnl.setLayout(new FlowLayout(FlowLayout.RIGHT));
    92        
     112
    93113        JButton btn = new JButton(new CancelAction());
    94114        btn.setName("button.cancel");
    95115        pnl.add(btn);
    96        
     116
    97117        btn = new JButton(new ApplyResolutionAction());
    98118        btn.setName("button.apply");
    99119        pnl.add(btn);
    100        
     120
    101121        pnl.setBorder(BorderFactory.createLoweredBevelBorder());
    102122        return pnl;
    103123    }
    104    
     124
     125    /**
     126     * builds the GUI
     127     */
    105128    protected void build() {
    106        setTitle(tr("Resolve conflicts"));
    107        getContentPane().setLayout(new BorderLayout());     
    108        
    109        resolver = new ConflictResolver();
    110        getContentPane().add(resolver, BorderLayout.CENTER);       
    111        getContentPane().add(buildButtonRow(), BorderLayout.SOUTH);       
     129        setTitle(tr("Resolve conflicts"));
     130        getContentPane().setLayout(new BorderLayout());
     131
     132        resolver = new ConflictResolver();
     133        resolver.setName("panel.conflictresolver");
     134        getContentPane().add(resolver, BorderLayout.CENTER);
     135        getContentPane().add(buildButtonRow(), BorderLayout.SOUTH);
    112136    }
    113    
    114    
     137
     138
    115139    public ConflictResolutionDialog(Component parent) {
    116140        super(JOptionPane.getFrameForComponent(parent), true /* modal */);
    117141        build();
    118142    }
    119    
     143
    120144    public ConflictResolver getConflictResolver() {
    121145        return resolver;
    122146    }
    123    
    124     protected ImageIcon getIcon(String iconPath) {
    125         URL imageURL   = this.getClass().getResource(iconPath);           
    126         if (imageURL == null) {
    127             System.out.println(tr("WARNING: failed to load resource {0}", iconPath));
    128             return null;
    129         }
    130         return new ImageIcon(imageURL);
    131     }
    132147
    133    
    134148    class CancelAction extends AbstractAction {
    135        
    136         public CancelAction() {           
     149        public CancelAction() {
    137150            putValue(Action.SHORT_DESCRIPTION, tr("Cancel conflict resolution and close the dialog"));
    138151            putValue(Action.NAME, tr("Cancel"));
    139             putValue(Action.SMALL_ICON, getIcon("/images/cancel.png"));
     152            putValue(Action.SMALL_ICON, ImageProvider.get("", "cancel"));
    140153            setEnabled(true);
    141154        }
    142155
    143        
     156
    144157        public void actionPerformed(ActionEvent arg0) {
    145158            setVisible(false);
    146         }       
    147     }   
    148    
    149     class ApplyResolutionAction extends AbstractAction {       
     159        }
     160    }
     161
     162    class ApplyResolutionAction extends AbstractAction {
    150163        public ApplyResolutionAction() {
    151164            putValue(Action.SHORT_DESCRIPTION, tr("Apply resolved conflicts and close the dialog"));
    152165            putValue(Action.NAME, tr("Apply Resolution"));
    153             putValue(Action.SMALL_ICON, getIcon("/images/dialogs/conflict.png"));
    154             setEnabled(true);           
     166            putValue(Action.SMALL_ICON, ImageProvider.get("dialogs", "conflict"));
     167            setEnabled(true);
    155168        }
    156169
    157        
    158170        public void actionPerformed(ActionEvent arg0) {
    159171            Command cmd = resolver.buildResolveCommand();
    160172            Main.main.undoRedo.add(cmd);
    161173            setVisible(false);
    162         }       
     174        }
    163175    }
    164176}
Note: See TracChangeset for help on using the changeset viewer.