Ignore:
Timestamp:
2012-02-14T21:27:53+01:00 (8 years ago)
Author:
stoecker
Message:

fix 6833 - use WindowGeometry for toggle dialogs and mainwindow replacing old custom methods, improve dual screen handling

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
11 edited

Legend:

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

    r4571 r4932  
    456456            if(visible) {
    457457                new WindowGeometry(rememberSizePref,
    458                         defaultWindowGeometry).applySafeMultiScreen(this);
     458                        defaultWindowGeometry).applySafe(this);
    459459            } else {
    460460                new WindowGeometry(this).remember(rememberSizePref);
  • trunk/src/org/openstreetmap/josm/gui/MainApplet.java

    r4220 r4932  
    5050            setContentPane(contentPanePrivate);
    5151            setJMenuBar(menu);
    52             setBounds(bounds);
    5352        }
    5453    }
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r4906 r4932  
    6565        mainFrame.setContentPane(contentPanePrivate);
    6666        mainFrame.setJMenuBar(menu);
    67         mainFrame.setBounds(bounds);
     67        geometry.applySafe(mainFrame);
    6868        LinkedList<Image> l = new LinkedList<Image>();
    6969        l.add(ImageProvider.get("logo_16x16x32").getImage());
     
    7474        l.add(ImageProvider.get("logo_48x48x8").getImage());
    7575        l.add(ImageProvider.get("logo").getImage());
    76         //mainFrame.setIconImage(ImageProvider.get("logo").getImage());
    7776        mainFrame.setIconImages(l);
    7877        mainFrame.addWindowListener(new WindowAdapter(){
     
    247246        monitor.indeterminateSubTask(tr("Setting defaults"));
    248247        preConstructorInit(args);
    249         removeObsoletePreferences();
    250248
    251249        monitor.indeterminateSubTask(tr("Creating main GUI"));
     
    319317            RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
    320318        }
    321 
    322     }
    323 
    324     /**
    325      * Removes obsolete preference settings. If you throw out a once-used preference
    326      * setting, add it to the list here with an expiry date (written as comment). If you
    327      * see something with an expiry date in the past, remove it from the list.
    328      */
    329     public static void removeObsoletePreferences() {
    330 
    331         String[] obsolete = {
    332                 "edit.make-parallel-way-action.snap-threshold"  // 10/2011 - replaced by snap-threshold-percent. Can be removed mid 2012
    333         };
    334         for (String key : obsolete) {
    335             if (Main.pref.hasKey(key)) {
    336                 Main.pref.removeFromCollection(key, Main.pref.get(key));
    337                 System.out.println(tr("Preference setting {0} has been removed since it is no longer used.", key));
    338             }
    339         }
    340319    }
    341320}
  • trunk/src/org/openstreetmap/josm/gui/MapFrame.java

    r4850 r4932  
    479479
    480480    /**
    481      * Returns the current width of the (possibly resized) toggle dialog area
    482      */
    483     public int getToggleDlgWidth() {
    484         return dialogsPanel.getWidth();
     481     * Remember the current width of the (possibly resized) toggle dialog area
     482     */
     483    public void rememberToggleDialogWidth() {
     484        Main.pref.putInteger("toggleDialogs.width", dialogsPanel.getWidth());
    485485    }
    486486
  • trunk/src/org/openstreetmap/josm/gui/SplashScreen.java

    r4681 r4932  
    2929import org.openstreetmap.josm.gui.progress.SwingRenderingProgressMonitor;
    3030import org.openstreetmap.josm.tools.ImageProvider;
     31import org.openstreetmap.josm.tools.WindowGeometry;
    3132
    3233/**
     
    5859        GridBagConstraints gbc = new GridBagConstraints();
    5960        gbc.gridheight = 2;
     61        gbc.insets = new Insets(0, 0, 0, 70);
    6062        innerContentPane.add(logo, gbc);
    6163
     
    9294        pack();
    9395
    94         // Center the splash screen
    95         setLocationRelativeTo(null);
     96        WindowGeometry.centerOnScreen(this, "gui.geometry");
    9697
    9798        // Add ability to hide splash screen by clicking it
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r4897 r4932  
    5151import org.openstreetmap.josm.tools.ImageProvider;
    5252import org.openstreetmap.josm.tools.Shortcut;
     53import org.openstreetmap.josm.tools.WindowGeometry;
     54import org.openstreetmap.josm.tools.WindowGeometry.WindowGeometryException;
    5355
    5456/**
     
    507509            });
    508510
    509             String bounds = Main.pref.get(preferencePrefix+".bounds",null);
    510             if (bounds != null) {
    511                 String[] b = bounds.split(",");
    512                 setBounds(getDetachedGeometry(new Rectangle(
    513                         Integer.parseInt(b[0]),Integer.parseInt(b[1]),Integer.parseInt(b[2]),Integer.parseInt(b[3]))));
    514             } else {
     511            try {
     512                new WindowGeometry(preferencePrefix+".geometry").applySafe(this);
     513            } catch (WindowGeometryException e) {
    515514                ToggleDialog.this.setPreferredSize(ToggleDialog.this.getDefaultDetachedSize());
    516515                pack();
     
    523522        protected void rememberGeometry() {
    524523            if (detachedDialog != null) {
    525                 Main.pref.put(preferencePrefix+".bounds", detachedDialog.getX()+","+detachedDialog.getY()+","+detachedDialog.getWidth()+","+detachedDialog.getHeight());
     524                new WindowGeometry(detachedDialog).remember(preferencePrefix+".geometry");
    526525            }
    527526        }
  • trunk/src/org/openstreetmap/josm/gui/download/DownloadDialog.java

    r4906 r4932  
    328328            boundingBoxChanged(currentBounds,null);
    329329        }
    330         else if (Main.pref.hasKey("osm-download.bounds")) {
     330        else if (!Main.pref.get("osm-download.bounds").isEmpty()) {
    331331            // read the bounding box from the preferences
    332332            try {
  • trunk/src/org/openstreetmap/josm/gui/history/HistoryBrowserDialogManager.java

    r4760 r4932  
    7474    public void placeOnScreen(HistoryBrowserDialog dialog) {
    7575        WindowGeometry geometry = WindowGeometry.centerOnScreen(new Dimension(800,500));
    76         geometry.apply(dialog);
     76        geometry.applySafe(dialog);
    7777        Point p = dialog.getLocation();
    7878        while(hasDialogWithCloseUpperLeftCorner(p)) {
  • trunk/src/org/openstreetmap/josm/gui/io/CredentialDialog.java

    r4690 r4932  
    7575    public void setVisible(boolean visible) {
    7676        if (visible) {
    77             WindowGeometry.centerInWindow(Main.parent, new Dimension(350,300)).apply(this);
     77            WindowGeometry.centerInWindow(Main.parent, new Dimension(350,300)).applySafe(this);
    7878        }
    7979        super.setVisible(visible);
  • trunk/src/org/openstreetmap/josm/gui/io/SaveLayersDialog.java

    r4618 r4932  
    7272    protected void build() {
    7373        WindowGeometry geometry = WindowGeometry.centerOnScreen(new Dimension(600,300));
    74         geometry.apply(this);
     74        geometry.applySafe(this);
    7575        getContentPane().setLayout(new BorderLayout());
    7676
  • trunk/src/org/openstreetmap/josm/gui/preferences/GPXSettingsPanel.java

    r4844 r4932  
    297297    public void loadPreferences () {
    298298        makeAutoMarkers.setSelected(Main.pref.getBoolean("marker.makeautomarkers", true));
    299         if(layerName!=null && !Main.pref.hasKey("draw.rawgps.lines."+layerName)
    300                 && !Main.pref.hasKey("draw.rawgps.lines.local."+layerName)){
     299        if(layerName!=null && Main.pref.get("draw.rawgps.lines."+layerName).isEmpty()
     300                && Main.pref.get("draw.rawgps.lines.local."+layerName).isEmpty()){
    301301            // no line preferences for layer is found
    302302            drawRawGpsLinesGlobal.setSelected(true);
     
    323323        drawRawGpsLinesActionListener.actionPerformed(null);
    324324
    325         if(layerName!=null && !Main.pref.hasKey("draw.rawgps.colors."+layerName)) {
     325        if(layerName!=null && Main.pref.get("draw.rawgps.colors."+layerName).isEmpty()) {
    326326            colorTypeGlobal.setSelected(true);
    327327            colorDynamic.setSelected(false);
Note: See TracChangeset for help on using the changeset viewer.