Changeset 4189 in josm


Ignore:
Timestamp:
Jul 1, 2011 9:31:07 AM (23 months ago)
Author:
stoecker
Message:

unify geometry code

File:
1 edited

Legend:

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

    r3767 r4189  
    1313import java.beans.PropertyChangeEvent; 
    1414import java.beans.PropertyChangeListener; 
    15 import java.util.logging.Logger; 
    1615 
    1716import javax.swing.AbstractAction; 
     
    3231import org.openstreetmap.josm.gui.help.HelpUtil; 
    3332import org.openstreetmap.josm.tools.ImageProvider; 
     33import org.openstreetmap.josm.tools.WindowGeometry; 
    3434 
    3535/** 
     
    3838 */ 
    3939public class ConflictResolutionDialog extends JDialog implements PropertyChangeListener { 
    40     private static final Logger logger = Logger.getLogger(ConflictResolutionDialog.class.getName()); 
    41     public final static Dimension DEFAULT_SIZE = new Dimension(600,400); 
    42  
    4340    /** the conflict resolver component */ 
    4441    private ConflictResolver resolver; 
    4542 
    4643    private ApplyResolutionAction applyResolutionAction; 
    47  
    48     /** 
    49      * restore position and size on screen from preference settings 
    50      * 
    51      */ 
    52     protected void restorePositionAndDimension() { 
    53         Point p = new Point(); 
    54         Dimension d = new Dimension(); 
    55         try { 
    56             p.x = Integer.parseInt(Main.pref.get("conflictresolutiondialog.x", "0")); 
    57             p.x = Math.max(0,p.x); 
    58         } catch(Exception e) { 
    59             logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0"); 
    60             p.x = 0; 
    61         } 
    62         try { 
    63             p.y = Integer.parseInt(Main.pref.get("conflictresolutiondialog.y", "0")); 
    64             p.y = Math.max(0,p.y); 
    65         } catch(Exception e) { 
    66             logger.warning("unexpected value for preference conflictresolutiondialog.x, assuming 0"); 
    67             p.y = 0; 
    68         } 
    69         try { 
    70             d.width = Integer.parseInt(Main.pref.get("conflictresolutiondialog.width", Integer.toString(DEFAULT_SIZE.width))); 
    71             d.width = Math.max(0,d.width); 
    72         } catch(Exception e) { 
    73             logger.warning("unexpected value for preference conflictresolutiondialog.width, assuming " + DEFAULT_SIZE.width); 
    74             p.y = 0; 
    75         } 
    76         try { 
    77             d.height = Integer.parseInt(Main.pref.get("conflictresolutiondialog.height", Integer.toString(DEFAULT_SIZE.height))); 
    78             d.height = Math.max(0,d.height); 
    79         } catch(Exception e) { 
    80             logger.warning("unexpected value for preference conflictresolutiondialog.height, assuming " +  + DEFAULT_SIZE.height); 
    81             p.y = 0; 
    82         } 
    83  
    84         setLocation(p); 
    85         setSize(d); 
    86     } 
    87  
    88     /** 
    89      * remember position and size on screen in the preferences 
    90      * 
    91      */ 
    92     protected void rememberPositionAndDimension() { 
    93         Point p = getLocation(); 
    94         Main.pref.put("conflictresolutiondialog.x", Integer.toString(p.x)); 
    95         Main.pref.put("conflictresolutiondialog.y", Integer.toString(p.y)); 
    96  
    97         Dimension d = getSize(); 
    98         Main.pref.put("conflictresolutiondialog.width", Integer.toString(d.width)); 
    99         Main.pref.put("conflictresolutiondialog.height", Integer.toString(d.height)); 
    100     } 
    10144 
    10245    @Override 
     
    10851    @Override 
    10952    public void setVisible(boolean isVisible) { 
     53        String geom = getClass().getName() + ".geometry"; 
    11054        if (isVisible){ 
    111             restorePositionAndDimension(); 
    11255            toFront(); 
     56            new WindowGeometry(geom, WindowGeometry.centerInWindow(Main.parent, 
     57                new Dimension(600, 400))).applySafe(this); 
    11358        } else { 
    114             rememberPositionAndDimension(); 
     59            new WindowGeometry(this).remember(geom); 
    11560            unregisterListeners(); 
    11661        } 
Note: See TracChangeset for help on using the changeset viewer.