Ignore:
Timestamp:
2009-07-28T19:48:39+02:00 (15 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/markerlayer/MarkerLayer.java

    r1724 r1865  
    3434import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
    3535import org.openstreetmap.josm.gui.MapView;
     36import org.openstreetmap.josm.gui.OptionPaneUtil;
    3637import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
    3738import org.openstreetmap.josm.gui.dialogs.LayerListPopup;
     
    9091            if (wpt_has_link) {
    9192                for (GpxLink oneLink : (Collection<GpxLink>) wpt.attr.get(GpxData.META_LINKS)) {
    92                     if (!oneLink.uri.equals(lastLinkedFile))firstTime = time;
     93                    if (!oneLink.uri.equals(lastLinkedFile)) {
     94                        firstTime = time;
     95                    }
    9396                    lastLinkedFile = oneLink.uri;
    9497                    break;
     
    9699            }
    97100            Marker m = Marker.createMarker(wpt, indata.storageFile, this, time, time - firstTime);
    98             if (m != null)
     101            if (m != null) {
    99102                data.add(m);
     103            }
    100104        }
    101105
     
    118122                            return;
    119123                        mousePressed  = true;
    120                         if (visible)
     124                        if (visible) {
    121125                            Main.map.mapView.repaint();
     126                        }
    122127                    }
    123128                    @Override public void mouseReleased(MouseEvent ev) {
     
    129134                        if (ev.getPoint() != null) {
    130135                            for (Marker mkr : data) {
    131                                 if (mkr.containsPoint(ev.getPoint()))
     136                                if (mkr.containsPoint(ev.getPoint())) {
    132137                                    mkr.actionPerformed(new ActionEvent(this, 0, null));
     138                                }
    133139                            }
    134140                        }
     
    183189
    184190    @Override public void visitBoundingBox(BoundingXYVisitor v) {
    185         for (Marker mkr : data)
     191        for (Marker mkr : data) {
    186192            v.visit(mkr.getEastNorth());
     193        }
    187194    }
    188195
     
    198205                JColorChooser c = new JColorChooser(getColor(name));
    199206                Object[] options = new Object[]{tr("OK"), tr("Cancel"), tr("Default")};
    200                 int answer = JOptionPane.showOptionDialog(Main.parent, c, tr("Choose a color"), JOptionPane.OK_CANCEL_OPTION,
    201                 JOptionPane.PLAIN_MESSAGE, null, options, options[0]);
     207                int answer = OptionPaneUtil.showOptionDialog(
     208                        Main.parent,
     209                        c,
     210                        tr("Choose a color"),
     211                        JOptionPane.OK_CANCEL_OPTION,
     212                        JOptionPane.PLAIN_MESSAGE,
     213                        options,
     214                        options[0]
     215                );
    202216                switch (answer) {
    203217                case 0:
     
    219233            public void actionPerformed(ActionEvent e) {
    220234                if (! AudioPlayer.paused()) {
    221                     JOptionPane.showMessageDialog(Main.parent,tr("You need to pause audio at the moment when you hear your synchronization cue."));
     235                    OptionPaneUtil.showMessageDialog(
     236                            Main.parent,
     237                            tr("You need to pause audio at the moment when you hear your synchronization cue."),
     238                            tr("Warning"),
     239                            JOptionPane.WARNING_MESSAGE
     240                    );
    222241                    return;
    223242                }
    224243                AudioMarker recent = AudioMarker.recentlyPlayedMarker();
    225244                if (synchronizeAudioMarkers(recent)) {
    226                     JOptionPane.showMessageDialog(Main.parent, tr("Audio synchronized at point {0}.", recent.text));
     245                    OptionPaneUtil.showMessageDialog(
     246                            Main.parent,
     247                            tr("Audio synchronized at point {0}.", recent.text),
     248                            tr("Information"),
     249                            JOptionPane.INFORMATION_MESSAGE
     250                    );
    227251                } else {
    228                     JOptionPane.showMessageDialog(Main.parent,tr("Unable to synchronize in layer being played."));
     252                    OptionPaneUtil.showMessageDialog(
     253                            Main.parent,
     254                            tr("Unable to synchronize in layer being played."),
     255                            tr("Error"),
     256                            JOptionPane.ERROR_MESSAGE
     257                    );
    229258                }
    230259            }
     
    236265            public void actionPerformed(ActionEvent e) {
    237266                if (! AudioPlayer.paused()) {
    238                     JOptionPane.showMessageDialog(Main.parent,tr("You need to have paused audio at the point on the track where you want the marker."));
     267                    OptionPaneUtil.showMessageDialog(
     268                            Main.parent,
     269                            tr("You need to have paused audio at the point on the track where you want the marker."),
     270                            tr("Warning"),
     271                            JOptionPane.WARNING_MESSAGE
     272                    );
    239273                    return;
    240274                }
     
    285319        URL url = startMarker.url();
    286320        for (Marker m : data) {
    287             if (m == startMarker)
     321            if (m == startMarker) {
    288322                seenStart = true;
     323            }
    289324            if (seenStart) {
    290325                AudioMarker ma = (AudioMarker) m; // it must be an AudioMarker
    291                 if (ma.url().equals(url))
     326                if (ma.url().equals(url)) {
    292327                    ma.adjustOffset(adjustment);
     328                }
    293329            }
    294330        }
     
    308344        }
    309345        if (am == null) {
    310             JOptionPane.showMessageDialog(Main.parent,tr("No existing audio markers in this layer to offset from."));
     346            OptionPaneUtil.showMessageDialog(
     347                    Main.parent,
     348                    tr("No existing audio markers in this layer to offset from."),
     349                    tr("Error"),
     350                    JOptionPane.ERROR_MESSAGE
     351            );
    311352            return null;
    312353        }
     
    314355        // make our new marker
    315356        AudioMarker newAudioMarker = AudioMarker.create(coor,
    316             AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);
     357                AudioMarker.inventName(offset), AudioPlayer.url().toString(), this, time, offset);
    317358
    318359        // insert it at the right place in a copy the collection
     
    333374
    334375        if (newAudioMarker != null) {
    335             if (am != null)
     376            if (am != null) {
    336377                newAudioMarker.adjustOffset(am.syncOffset()); // i.e. same as predecessor
     378            }
    337379            newData.add(newAudioMarker); // insert at end
    338380        }
     
    363405            for (Marker marker : markerLayer.data) {
    364406                if (marker == startMarker) {
    365                     if (next)
     407                    if (next) {
    366408                        nextTime = true;
    367                     else {
    368                         if (previousMarker == null)
     409                    } else {
     410                        if (previousMarker == null) {
    369411                            previousMarker = startMarker; // if no previous one, play the first one again
     412                        }
    370413                        return previousMarker;
    371414                    }
     
    389432            return;
    390433        Layer l = Main.map.mapView.getActiveLayer();
    391         if(l != null)
     434        if(l != null) {
    392435            m = getAdjacentMarker(startMarker, next, l);
     436        }
    393437        if(m == null)
    394438        {
     
    396440            {
    397441                m = getAdjacentMarker(startMarker, next, layer);
    398                 if(m != null)
    399                     break;
    400             }
    401         }
    402         if(m != null)
     442                if(m != null) {
     443                    break;
     444                }
     445            }
     446        }
     447        if(m != null) {
    403448            ((AudioMarker)m).play();
     449        }
    404450    }
    405451
Note: See TracChangeset for help on using the changeset viewer.