Changeset 2969 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2010-02-12T20:01:55+01:00 (15 years ago)
Author:
bastiK
Message:

fixed #4502 - Photomapping pannel open just one time;
make tiger highlight color a little transparent (see #2381)

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

Legend:

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

    r2869 r2969  
    122122         * in the last panel anyway.
    123123         */
    124         int k = N-1;                // index of the current Panel (start with last one)
    125         JPanel p = panels.get(k);   // current Panel
    126         k = -1;                     // indicates that the current Panel index is N-1, but no default-view-Dialog was added to this Panel yet.
     124        JPanel p = panels.get(N-1); // current Panel (start with last one)
     125        int k = -1;                 // indicates that the current Panel index is N-1, but no default-view-Dialog has been added to this Panel yet.
    127126        for (int i=N-1; i >= 0 ; --i) {
    128127            final ToggleDialog dlg = allDialogs.get(i);
     
    171170                if (dlg.isDialogInDefaultView()) {
    172171                    if (dlg != triggeredBy) {
    173                         final int ph = dlg.getPreferredHeight();
    174                         final int ah = dlg.getHeight();
    175                         sumP += ph;
    176                         sumA += ah;
     172                        sumP += dlg.getPreferredHeight();
     173                        sumA += dlg.getHeight();
    177174                    }
    178175                } else if (dlg.isDialogInCollapsedView()) {
    179176                    sumC += dlg.getHeight();
    180177                }
     178            }
     179           
     180            /**
     181             * If we add additional dialogs on startup (e.g. geoimage), they may
     182             * not have an actual height yet.
     183             * In this case we simply reset everything to it's preferred size.
     184             */
     185            if (sumA == 0) {
     186                reconstruct(Action.ELEMENT_SHRINKS, null);
     187                return;
    181188            }
    182189
  • trunk/src/org/openstreetmap/josm/gui/dialogs/ToggleDialog.java

    r2887 r2969  
    5050    protected ToggleDialogAction toggleAction;
    5151    protected String preferencePrefix;
     52    final protected String name;
    5253
    5354    /** DialogsPanel that manages all ToggleDialogs */
     
    100101        super(new BorderLayout());
    101102        this.preferencePrefix = iconName;
     103        this.name = name;
    102104
    103105        /** Use the full width of the parent element */
     
    516518        return "Dialog/"+help;
    517519    }
     520
     521    @Override
     522    public String toString() {
     523        return name;
     524    }
     525
    518526    /**
    519527     * Replies true if this dialog is showing either as docked or as detached dialog
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/GeoImageLayer.java

    r2931 r2969  
    236236                Main.main.addLayer(layer);
    237237                layer.hook_up_mouse_events(); // Main.map.mapView should exist
    238                 // now. Can add mouse listener
     238                                              // now. Can add mouse listener
    239239                Main.map.mapView.addPropertyChangeListener(layer);
    240                 if (!addedToggleDialog) {
    241                     // TODO Workaround for bug in DialogsPanel
    242                     // When GeoImageLayer is added as a first layer, division by zero exception is thrown
    243                     // This is caused by DialogsPanel.reconstruct method which use height of other dialogs
    244                     // to calculate height of newly added ImageViewerDialog. But height of other dialogs is
    245                     // zero because it's calculated by layout manager later
    246                     SwingUtilities.invokeLater(new Runnable() {
    247                         public void run() {
    248                             Main.map.addToggleDialog(ImageViewerDialog.getInstance());
    249                         }
    250                     });
    251                     addedToggleDialog = true;
     240                if (Main.map.getToggleDialog(ImageViewerDialog.class) == null) {
     241                    System.err.println("JO");
     242                    ImageViewerDialog.newInstance();// = new ImageViewerDialog();
     243                    Main.map.addToggleDialog(ImageViewerDialog.getInstance());
    252244                }
    253245
     
    271263    }
    272264
    273     private static boolean addedToggleDialog = false;
    274 
    275265    public static void create(Collection<File> files, GpxLayer gpxLayer) {
    276266        Loader loader = new Loader(files, gpxLayer);
     
    291281        return ImageProvider.get("dialogs/geoimage");
    292282    }
    293    
     283
    294284    public static interface LayerMenuAddition {
    295285        public Component getComponent(Layer layer);
     
    306296        JMenuItem correlateItem = new JMenuItem(tr("Correlate to GPX"), ImageProvider.get("dialogs/geoimage/gpx2img"));
    307297        correlateItem.addActionListener(new CorrelateGpxWithImages(this));
    308        
     298
    309299        List<Component> entries = new ArrayList<Component>();
    310300        entries.add(new JMenuItem(LayerListDialog.getInstance().createShowHideLayerAction(this)));
     
    323313
    324314        return entries.toArray(new Component[0]);
    325        
     315
    326316    }
    327317
     
    335325        + " " + trn("{0} was found to be GPS tagged.", "{0} were found to be GPS tagged.", i, i);
    336326    }
    337    
     327
    338328    @Override public Object getInfoComponent() {
    339329        return infoText();
     
    752742        Main.map.mapView.repaint();
    753743    }
    754    
     744
    755745    public List<ImageEntry> getImages() {
    756746        List<ImageEntry> copy = new ArrayList<ImageEntry>();
  • trunk/src/org/openstreetmap/josm/gui/layer/geoimage/ImageViewerDialog.java

    r2931 r2969  
    4444    private boolean centerView = false;
    4545
    46     // Only one instance of that class
    47     static private ImageViewerDialog INSTANCE = null;
     46    // Only one instance of that class is present at one time
     47    private static ImageViewerDialog dialog;
    4848
    4949    private boolean collapseButtonClicked = false;
    5050
     51    static void newInstance() {
     52        dialog = new ImageViewerDialog();
     53    }
     54
    5155    public static ImageViewerDialog getInstance() {
    52         if (INSTANCE == null) {
    53             INSTANCE = new ImageViewerDialog();
    54         }
    55         return INSTANCE;
     56        if (dialog == null) {
     57            throw new AssertionError(); // a new instance needs to be created first
     58        }
     59        return dialog;
    5660    }
    5761
     
    6367        super(tr("Geotagged Images"), "geoimage", tr("Display geotagged images"), Shortcut.registerShortcut("tools:geotagged", tr("Tool: {0}", tr("Display geotagged images")), KeyEvent.VK_Y, Shortcut.GROUP_EDIT), 200);
    6468
    65         if (INSTANCE != null) {
    66             throw new IllegalStateException("Image viewer dialog should not be instanciated twice !");
    67         }
    68 
    6969        /* Don't show a detached dialog right from the start. */
    7070        if (isShowing && !isDocked) {
    7171            setIsShowing(false);
    7272        }
    73 
    74         INSTANCE = this;
    7573
    7674        JPanel content = new JPanel();
     
    254252            //    osd.append(tr("\nImage gps time: {0}", Long.toString(entry.getGpsTime().getTime())));
    255253            //}
    256            
     254
    257255            imgDisplay.setOsdText(osd.toString());
    258256        } else {
Note: See TracChangeset for help on using the changeset viewer.