Ignore:
Timestamp:
2009-07-28T19:48:39+02:00 (16 years ago)
Author:
Gubaer
Message:

replaced JOptionPane.show* by OptionPaneUtil.show*
ExtendeDialog now always on top, too

File:
1 edited

Legend:

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

    r1863 r1865  
    7070import org.openstreetmap.josm.gui.MapFrame;
    7171import org.openstreetmap.josm.gui.MapView;
     72import org.openstreetmap.josm.gui.OptionPaneUtil;
    7273import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    7374import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    125126            if (cachedImageRef != null) {
    126127                Image cachedImage = cachedImageRef.get();
    127                 if (cachedImage != null) {
     128                if (cachedImage != null)
    128129                    return cachedImage;
    129                 }
    130130            }
    131131            return Toolkit.getDefaultToolkit().createImage(currentEntry.file.getAbsolutePath());
     
    147147        }
    148148        private void loadImage() {
    149             if (currentEntry != null) {
     149            if (currentEntry != null)
    150150                return;
    151             }
    152151            while (!queue.isEmpty()) {
    153152                currentEntry = queue.get(0);
     
    217216
    218217            while (true) {
    219                 if (entry.scaledImage != null) {
     218                if (entry.scaledImage != null)
    220219                    return entry.scaledImage;
    221                 }
    222220                try {
    223221                    wait();
     
    259257
    260258        public Image getIcon() {
    261             if (icon.scaledImage == null) {
     259            if (icon.scaledImage == null)
    262260                return EMPTY_IMAGE;
    263             } else {
     261            else
    264262                return icon.scaledImage;
    265             }
    266263        }
    267264
     
    330327            ArrayList<ImageEntry> data = new ArrayList<ImageEntry>(files.size());
    331328            for (File f : files) {
    332                 if (progressMonitor.isCancelled())
     329                if (progressMonitor.isCancelled()) {
    333330                    break;
     331                }
    334332                progressMonitor.subTask(tr("Reading {0}...",f.getName()));
    335333
     
    341339                    continue;
    342340                }
    343                 if (e.time == null)
     341                if (e.time == null) {
    344342                    continue;
     343                }
    345344
    346345                data.add(e);
     
    350349        }
    351350        @Override protected void finish() {
    352             if (layer != null)
     351            if (layer != null) {
    353352                Main.main.addLayer(layer);
     353            }
    354354        }
    355355        @Override
     
    412412                    return;
    413413                mousePressed  = true;
    414                 if (visible)
     414                if (visible) {
    415415                    Main.map.mapView.repaint();
     416                }
    416417            }
    417418            @Override public void mouseReleased(MouseEvent ev) {
     
    423424                for (int i = data.size(); i > 0; --i) {
    424425                    ImageEntry e = data.get(i-1);
    425                     if (e.pos == null)
     426                    if (e.pos == null) {
    426427                        continue;
     428                    }
    427429                    Point p = Main.map.mapView.getPoint(e.pos);
    428430                    Rectangle r = new Rectangle(p.x-ICON_SIZE/2, p.y-ICON_SIZE/2, ICON_SIZE, ICON_SIZE);
     
    440442            public void layerAdded(Layer newLayer) {}
    441443            public void layerRemoved(Layer oldLayer) {
    442                 if (oldLayer == self)
     444                if (oldLayer == self) {
    443445                    Main.map.mapView.removeMouseListener(mouseAdapter);
     446                }
    444447            }
    445448        });
     
    550553            nextButton.setEnabled(currentImage < data.size() - 1);
    551554
    552             if (scaleToggle.getModel().isSelected())
     555            if (scaleToggle.getModel().isSelected()) {
    553556                imageLabel.setIcon(new ImageIcon(imageLoader.waitForImage(currentImageEntry.image,
    554557                        Math.max(imageViewport.getWidth(), imageViewport.getHeight()))));
    555             else
     558            } else {
    556559                imageLabel.setIcon(new ImageIcon(imageLoader.waitForImage(currentImageEntry.image)));
    557 
    558             if (centerToggle.getModel().isSelected())
     560            }
     561
     562            if (centerToggle.getModel().isSelected()) {
    559563                Main.map.mapView.zoomTo(currentImageEntry.pos);
     564            }
    560565
    561566            dlg.setTitle(currentImageEntry.image +
     
    594599                setIcon(new ImageIcon(e.getIcon()));
    595600                setText(e.image.getName()+" ("+dateFormat.format(new Date(e.time.getTime()+(delta+gpstimezone)))+")");
    596                 if (e.pos == null)
     601                if (e.pos == null) {
    597602                    setForeground(Color.red);
     603                }
    598604                return this;
    599605            }
     
    607613        int i = 0;
    608614        for (ImageEntry e : data)
    609             if (e.pos != null)
     615            if (e.pos != null) {
    610616                i++;
     617            }
    611618        return data.size()+" "+trn("image","images",data.size())+". "+tr("{0} within the track.",i);
    612619    }
     
    662669
    663670    @Override public void visitBoundingBox(BoundingXYVisitor v) {
    664         for (ImageEntry e : data)
     671        for (ImageEntry e : data) {
    665672            v.visit(e.pos);
     673        }
    666674    }
    667675
     
    723731            exifDate = ExifReader.readTime(f);
    724732        } catch (ParseException e) {
    725             JOptionPane.showMessageDialog(Main.parent, tr("The date in file \"{0}\" could not be parsed.", f.getName()));
     733            OptionPaneUtil.showMessageDialog(
     734                    Main.parent,
     735                    tr("The date in file \"{0}\" could not be parsed.", f.getName()),
     736                    tr("Error"),
     737                    JOptionPane.ERROR_MESSAGE
     738            );
    726739            return;
    727740        }
    728741        if (exifDate == null) {
    729             JOptionPane.showMessageDialog(Main.parent, tr("There is no EXIF time within the file \"{0}\".", f.getName()));
     742            OptionPaneUtil.showMessageDialog(
     743                    Main.parent,
     744                    tr("There is no EXIF time within the file \"{0}\".", f.getName()),
     745                    tr("Error"),
     746                    JOptionPane.ERROR_MESSAGE
     747            );
    730748            return;
    731749        }
     
    738756        p.add(new JLabel(tr("GPS unit timezone (difference to photo)")), GBC.eol());
    739757        String t = Main.pref.get("tagimages.gpstimezone", "0");
    740         if (t.charAt(0) != '-')
     758        if (t.charAt(0) != '-') {
    741759            t = "+"+t;
     760        }
    742761        JTextField gpsTimezone = new JTextField(t);
    743762        p.add(gpsTimezone, GBC.eol().fill(GBC.HORIZONTAL));
    744763
    745764        while (true) {
    746             int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Synchronize Time with GPS Unit"), JOptionPane.OK_CANCEL_OPTION);
     765            int answer = OptionPaneUtil.showConfirmationDialog(
     766                    Main.parent,
     767                    p,
     768                    tr("Synchronize Time with GPS Unit"),
     769                    JOptionPane.OK_CANCEL_OPTION,
     770                    JOptionPane.QUESTION_MESSAGE
     771            );
    747772            if (answer != JOptionPane.OK_OPTION || gpsText.getText().equals(""))
    748773                return;
     
    750775                delta = DateParser.parse(gpsText.getText()).getTime() - exifDate.getTime();
    751776                String time = gpsTimezone.getText();
    752                 if (!time.equals("") && time.charAt(0) == '+')
     777                if (!time.equals("") && time.charAt(0) == '+') {
    753778                    time = time.substring(1);
    754                 if (time.equals(""))
     779                }
     780                if (time.equals("")) {
    755781                    time = "0";
     782                }
    756783                gpstimezone = Long.valueOf(time)*60*60*1000;
    757784                Main.pref.put("tagimages.delta", ""+delta);
     
    760787                return;
    761788            } catch (NumberFormatException x) {
    762                 JOptionPane.showMessageDialog(Main.parent, tr("Time entered could not be parsed."));
     789                OptionPaneUtil.showMessageDialog(
     790                        Main.parent,
     791                        tr("Time entered could not be parsed."),
     792                        tr("Error"),
     793                        JOptionPane.ERROR_MESSAGE
     794                );
    763795            } catch (ParseException x) {
    764                 JOptionPane.showMessageDialog(Main.parent, tr("Time entered could not be parsed."));
     796                OptionPaneUtil.showMessageDialog(
     797                        Main.parent,
     798                        tr("Time entered could not be parsed."),
     799                        tr("Error"),
     800                        JOptionPane.ERROR_MESSAGE
     801                );
    765802            }
    766803        }
Note: See TracChangeset for help on using the changeset viewer.