Changeset 1397 in josm


Ignore:
Timestamp:
Feb 14, 2009 12:25:54 PM (4 years ago)
Author:
stoecker
Message:

apply patches from xeen for #1977.

Location:
trunk/src/org/openstreetmap/josm
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r1169 r1397  
    3838import org.openstreetmap.josm.data.osm.TigerUtils; 
    3939import org.openstreetmap.josm.data.osm.Way; 
     40import org.openstreetmap.josm.gui.ExtendedDialog; 
    4041import org.openstreetmap.josm.tools.GBC; 
    4142import org.openstreetmap.josm.tools.Pair; 
     
    108109        for (HashSet<Way> waylinks : backlinks.values()) { 
    109110            if (!waylinks.containsAll(selectedWays)) { 
    110                 int option = JOptionPane.showConfirmDialog(Main.parent, 
    111                     tr("The selected ways have differing relation memberships.  " 
    112                         + "Do you still want to combine them?"), 
    113                     tr("Combine ways with different memberships?"), 
    114                     JOptionPane.YES_NO_OPTION); 
    115                 if (option == JOptionPane.YES_OPTION) 
    116                     break; 
     111                int option = new ExtendedDialog(Main.parent,  
     112                        tr("Combine ways with different memberships?"),  
     113                        tr("The selected ways have differing relation memberships.  " 
     114                            + "Do you still want to combine them?"), 
     115                        new String[] {tr("Combine Anyway"), tr("Cancel")},  
     116                        new String[] {"combineway.png", "cancel.png"}).getValue();   
     117                if (option == 1) break; 
     118                 
    117119                return; 
    118120            } 
     
    136138            Object secondTry = actuallyCombineWays(selectedWays, true); 
    137139            if (secondTry instanceof List) { 
    138                 int option = JOptionPane.showConfirmDialog(Main.parent, 
     140                int option = new ExtendedDialog(Main.parent,  
     141                    tr("Change directions?"),  
    139142                    tr("The ways can not be combined in their current directions.  " 
    140                     + "Do you want to reverse some of them?"), tr("Change directions?"), 
    141                     JOptionPane.YES_NO_OPTION); 
    142                 if (option != JOptionPane.YES_OPTION) { 
    143                     return; 
    144                 } 
     143                        + "Do you want to reverse some of them?"), 
     144                    new String[] {tr("Reverse and Combine"), tr("Cancel")},  
     145                    new String[] {"wayflip.png", "cancel.png"}).getValue();  
     146                if (option != 1) return; 
    145147                nodeList = (List<Node>) secondTry; 
    146148            } else { 
     
    191193 
    192194        if (!components.isEmpty()) { 
    193             int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Enter values for all conflicts."), JOptionPane.OK_CANCEL_OPTION); 
    194             if (answer != JOptionPane.OK_OPTION) 
    195                 return; 
     195            int answer = new ExtendedDialog(Main.parent,  
     196                tr("Enter values for all conflicts."),  
     197                p, 
     198                new String[] {tr("Solve Conflicts"), tr("Cancel")},  
     199                new String[] {"dialogs/conflict.png", "cancel.png"}).getValue();   
     200            if (answer != 1) return; 
     201             
    196202            for (Entry<String, JComboBox> e : components.entrySet()) 
    197203                newWay.put(e.getKey(), e.getValue().getEditor().getItem().toString()); 
  • trunk/src/org/openstreetmap/josm/actions/DiskAccessAction.java

    r1180 r1397  
    1010 
    1111import org.openstreetmap.josm.Main; 
     12import org.openstreetmap.josm.gui.ExtendedDialog; 
    1213import org.openstreetmap.josm.tools.Shortcut; 
    1314 
     
    4344        if (!open) { 
    4445            File file = fc.getSelectedFile(); 
    45             if (file == null || (file.exists() && JOptionPane.YES_OPTION != 
    46                     JOptionPane.showConfirmDialog(Main.parent, tr("File exists. Overwrite?"), tr("Overwrite"), JOptionPane.YES_NO_OPTION))) 
     46            if (file == null || (file.exists() && 1 != 
     47                new ExtendedDialog(Main.parent,  
     48                        tr("Overwrite"),  
     49                        tr("File exists. Overwrite?"), 
     50                        new String[] {tr("Overwrite"), tr("Cancel")},  
     51                        new String[] {"save_as.png", "cancel.png"}).getValue())) 
    4752                return null; 
    4853        } 
  • trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java

    r1212 r1397  
    3232import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    3333import org.openstreetmap.josm.io.GpxWriter; 
     34import org.openstreetmap.josm.gui.ExtendedDialog; 
    3435import org.openstreetmap.josm.tools.GBC; 
    3536import org.openstreetmap.josm.tools.Shortcut; 
     
    111112        p.add(keywords, GBC.eop().fill(GBC.HORIZONTAL)); 
    112113 
    113         int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Export options"), JOptionPane.OK_CANCEL_OPTION); 
    114         if (answer != JOptionPane.OK_OPTION) 
     114        int answer = new ExtendedDialog(Main.parent,  
     115                        tr("Export options"),  
     116                        p, 
     117                        new String[] {tr("Export and Save"), tr("Cancel")},  
     118                        new String[] {"exportgpx.png", "cancel.png"}).getValue();   
     119        if (answer != 1) 
    115120            return; 
    116121 
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r1169 r1397  
    3838import org.openstreetmap.josm.data.osm.Way; 
    3939import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 
     40import org.openstreetmap.josm.gui.ExtendedDialog; 
    4041import org.openstreetmap.josm.tools.GBC; 
    4142import org.openstreetmap.josm.tools.Pair; 
     
    144145        for (HashSet<Node> nodelinks : backlinks.values()) { 
    145146            if (!nodelinks.containsAll(allNodes)) { 
    146                 int option = JOptionPane.showConfirmDialog(Main.parent, 
    147                     tr("The selected nodes have differing relation memberships.  " 
    148                         + "Do you still want to merge them?"), 
    149                     tr("Merge nodes with different memberships?"), 
    150                     JOptionPane.YES_NO_OPTION); 
    151                 if (option == JOptionPane.YES_OPTION) 
    152                     break; 
     147                int option = new ExtendedDialog(Main.parent,  
     148                        tr("Merge nodes with different memberships?"),  
     149                        tr("The selected nodes have differing relation memberships.  " 
     150                            + "Do you still want to merge them?"), 
     151                        new String[] {tr("Merge Anyway"), tr("Cancel")},  
     152                        new String[] {"mergenodes.png", "cancel.png"}).getValue();   
     153                if (option == 1) break; 
    153154                return null; 
    154155            } 
     
    191192 
    192193        if (!components.isEmpty()) { 
    193             int answer = JOptionPane.showConfirmDialog(Main.parent, p, tr("Enter values for all conflicts."), JOptionPane.OK_CANCEL_OPTION); 
    194             if (answer != JOptionPane.OK_OPTION) 
     194            int answer = new ExtendedDialog(Main.parent,  
     195                tr("Enter values for all conflicts."),  
     196                p, 
     197                new String[] {tr("Solve Conflicts"), tr("Cancel")},  
     198                new String[] {"dialogs/conflict.png", "cancel.png"}).getValue();   
     199            if (answer != 1) 
    195200                return null; 
    196201            for (Entry<String, JComboBox> e : components.entrySet()) 
  • trunk/src/org/openstreetmap/josm/actions/OpenLocationAction.java

    r1195 r1397  
    2424import org.openstreetmap.josm.actions.downloadtasks.DownloadOsmTask; 
    2525import org.openstreetmap.josm.data.osm.DataSet; 
     26import org.openstreetmap.josm.gui.ExtendedDialog; 
    2627import org.openstreetmap.josm.gui.layer.GpxLayer; 
    2728import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
     
    5556        layer.setSelected(Main.pref.getBoolean("download.newlayer")); 
    5657        JPanel all = new JPanel(new GridBagLayout()); 
    57         all.add(new JLabel("Enter URL to download:"), GBC.eol()); 
     58        all.add(new JLabel(tr("Enter URL to download:")), GBC.eol()); 
    5859        JTextField urltext = new JTextField(40); 
    5960        all.add(urltext, GBC.eol()); 
    6061        all.add(layer, GBC.eol()); 
    61         int answer = JOptionPane.showConfirmDialog(Main.parent, all, tr("Download Location"), JOptionPane.OK_CANCEL_OPTION); 
    62         if (answer != JOptionPane.OK_OPTION) 
    63             return; 
     62        int answer = new ExtendedDialog(Main.parent,  
     63                        tr("Download Location"),  
     64                        all, 
     65                        new String[] {tr("Download URL"), tr("Cancel")},  
     66                        new String[] {"download.png", "cancel.png"}).getValue();   
     67        if (answer != 1) return; 
    6468        openUrl(layer.isSelected(), urltext.getText()); 
    6569    } 
  • trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java

    r1373 r1397  
    1717import org.openstreetmap.josm.Main; 
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     19import org.openstreetmap.josm.gui.ExtendedDialog; 
    1920import org.openstreetmap.josm.gui.layer.OsmDataLayer; 
    2021import org.openstreetmap.josm.gui.layer.Layer; 
     
    7879        } 
    7980 
    80         if (layer instanceof OsmDataLayer && isDataSetEmpty((OsmDataLayer)layer) && JOptionPane.NO_OPTION == JOptionPane.showConfirmDialog(Main.parent,tr("The document contains no data. Save anyway?"), tr("Empty document"), JOptionPane.YES_NO_OPTION)) { 
     81        if (layer instanceof OsmDataLayer && isDataSetEmpty((OsmDataLayer)layer) && 1 != new ExtendedDialog(Main.parent, tr("Empty document"), tr("The document contains no data."), new String[] {tr("Save anyway"), tr("Cancel")}, new String[] {"save.png", "cancel.png"}).getValue()) { 
    8182            return false; 
    8283        } 
     
    8586        } 
    8687        if (!Main.map.conflictDialog.conflicts.isEmpty()) { 
    87             int answer = JOptionPane.showConfirmDialog(Main.parent, 
    88                     tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"),tr("Conflicts"), JOptionPane.YES_NO_OPTION); 
    89             if (answer != JOptionPane.YES_OPTION) 
    90                 return false; 
     88            int answer = new ExtendedDialog(Main.parent, 
     89                tr("Conflicts"), 
     90                tr("There are unresolved conflicts. Conflicts will not be saved and handled as if you rejected all. Continue?"), 
     91                new String[] {tr("Reject Conflicts and Save"), tr("Cancel")}, 
     92                new String[] {"save.png", "cancel.png"}).getValue(); 
     93 
     94            if (answer != 1) return false; 
    9195        } 
    9296        return true; 
  • trunk/src/org/openstreetmap/josm/actions/UploadAction.java

    r1212 r1397  
    1818import org.openstreetmap.josm.Main; 
    1919import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     20import org.openstreetmap.josm.gui.ExtendedDialog; 
    2021import org.openstreetmap.josm.gui.OsmPrimitivRenderer; 
    2122import org.openstreetmap.josm.gui.PleaseWaitRunnable; 
     
    9899                } 
    99100 
    100                 return JOptionPane.showConfirmDialog(Main.parent, p, tr("Upload these changes?"), 
    101                         JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION; 
     101                return new ExtendedDialog(Main.parent,  
     102                        tr("Upload these changes?"),  
     103                        p, 
     104                        new String[] {tr("Upload Changes"), tr("Cancel")},  
     105                        new String[] {"upload.png", "cancel.png"}).getValue() == 1;   
    102106            } 
    103107        }); 
  • trunk/src/org/openstreetmap/josm/actions/search/SearchAction.java

    r1375 r1397  
    2121import org.openstreetmap.josm.actions.JosmAction; 
    2222import org.openstreetmap.josm.data.osm.OsmPrimitive; 
     23import org.openstreetmap.josm.gui.ExtendedDialog; 
    2324import org.openstreetmap.josm.tools.GBC; 
    2425import org.openstreetmap.josm.tools.Shortcut; 
     
    5556        JLabel label = new JLabel(tr("Please enter a search string.")); 
    5657        final JTextField input = new JTextField(initialValues.text); 
     58        input.selectAll(); 
     59        input.requestFocusInWindow(); 
    5760        JRadioButton replace = new JRadioButton(tr("replace selection"), initialValues.mode == SearchMode.replace); 
    5861        JRadioButton add = new JRadioButton(tr("add to selection"), initialValues.mode == SearchMode.add); 
     
    99102        p.add(left); 
    100103        p.add(right); 
    101  
    102         JOptionPane pane = new JOptionPane(p, JOptionPane.INFORMATION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, null) { 
    103             @Override 
    104             public void selectInitialValue() { 
    105                 input.requestFocusInWindow(); 
    106                 input.selectAll(); 
    107             } 
    108         }; 
    109         pane.createDialog(Main.parent, tr("Search")).setVisible(true); 
    110         if (!Integer.valueOf(JOptionPane.OK_OPTION).equals(pane.getValue())) 
    111             return; 
     104         
     105        int result = new ExtendedDialog(Main.parent,  
     106            tr("Search"),  
     107            p, 
     108            new String[] {tr("Start Search"), tr("Cancel")},  
     109            new String[] {"dialogs/search.png", "cancel.png"}).getValue();   
     110        if(result != 1) return; 
     111 
    112112        // User pressed OK - let's perform the search 
    113113        SearchMode mode = replace.isSelected() ? SearchAction.SearchMode.replace 
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r1169 r1397  
    3131import org.openstreetmap.josm.data.osm.visitor.CollectBackReferencesVisitor; 
    3232import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 
     33import org.openstreetmap.josm.gui.ExtendedDialog; 
    3334import org.openstreetmap.josm.tools.DontShowAgainInfo; 
    3435import org.openstreetmap.josm.tools.ImageProvider; 
     
    154155        } 
    155156        if (role.length() > 0) { 
    156             return JOptionPane.showConfirmDialog(Main.parent, tr( 
    157                     "Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", s.name, 
    158                     n.name, role), tr("Conflicting relation"), JOptionPane.YES_NO_OPTION); 
     157            return new ExtendedDialog(Main.parent,  
     158                        tr("Conflicting relation"),  
     159                        tr("Selection \"{0}\" is used by relation \"{1}\" with role {2}.\nDelete from relation?", 
     160                            s.name, n.name, role), 
     161                        new String[] {tr("Delete from relation"), tr("Cancel")},  
     162                        new String[] {"dialogs/delete.png", "cancel.png"}).getValue();   
    159163        } else { 
    160             return JOptionPane.showConfirmDialog(Main.parent, tr( 
    161                     "Selection \"{0}\" is used by relation \"{1}\".\nDelete from relation?", s.name, n.name), 
    162                     tr("Conflicting relation"), JOptionPane.YES_NO_OPTION); 
     164            return new ExtendedDialog(Main.parent,  
     165                        tr("Conflicting relation"),  
     166                        tr("Selection \"{0}\" is used by relation \"{1}\".\nDelete from relation?", 
     167                            s.name, n.name), 
     168                        new String[] {tr("Delete from relation"), tr("Cancel")},  
     169                        new String[] {"dialogs/delete.png", "cancel.png"}).getValue();   
    163170        } 
    164171    } 
     
    208215                    waysToBeChanged.add((Way) ref); 
    209216                } else if (ref instanceof Relation) { 
    210                     if (testRelation((Relation) ref, osm) == JOptionPane.YES_OPTION) { 
     217                    if (testRelation((Relation) ref, osm) == 1) { 
    211218                        Collection<OsmPrimitive> relset = relationsToBeChanged.get(ref); 
    212219                        if (relset == null) 
     
    248255                        } 
    249256                        if (!found) { 
    250                             if (testRelation((Relation) ref, w) == JOptionPane.YES_OPTION) { 
     257                            if (testRelation((Relation) ref, w) == 1) { 
    251258                                relset.add(w); 
    252259                                relationsToBeChanged.put(ref, relset); 
  • trunk/src/org/openstreetmap/josm/gui/ExtendedDialog.java

    r1373 r1397  
    77import java.awt.event.ComponentListener; 
    88import java.awt.GridBagLayout; 
     9import java.awt.Toolkit; 
    910 
    1011import javax.swing.AbstractAction; 
     
    1920import javax.swing.JPanel; 
    2021import javax.swing.JRootPane; 
     22import javax.swing.JScrollBar; 
    2123import javax.swing.JScrollPane; 
    2224import javax.swing.KeyStroke; 
    2325 
    2426import org.openstreetmap.josm.Main; 
     27import org.openstreetmap.josm.gui.JMultilineLabel; 
    2528import org.openstreetmap.josm.tools.GBC; 
    2629import org.openstreetmap.josm.tools.I18n; 
     
    4750     
    4851    public ExtendedDialog(Component parent, String title, Component content, String[] buttonTexts) { 
     52        this(parent, title, content, buttonTexts, null); 
     53    } 
     54     
     55    // just display a breakable message 
     56    public ExtendedDialog(Component parent, String title, String message, String[] buttonTexts, String[] buttonIcons) { 
    4957        super(JOptionPane.getFrameForComponent(parent), title, true); 
    50         bTexts = buttonTexts; 
    51         setupDialog(parent, title, content, buttonTexts, null); 
     58         
     59        JMultilineLabel lbl = new JMultilineLabel(message); 
     60        // Make it not wider than 2/3 of the screen 
     61        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
     62        lbl.setMaxWidth(Math.round(screenSize.width*2/3)); 
     63         
     64        bTexts = buttonTexts;         
     65        setupDialog(parent, title, lbl, buttonTexts, buttonIcons); 
     66    } 
     67     
     68    public ExtendedDialog(Component parent, String title, String message, String[] buttonTexts) { 
     69        this(parent, title, message, buttonTexts, null); 
    5270    } 
    5371     
    5472    private void setupDialog(Component parent, String title, Component content, String[] buttonTexts, String[] buttonIcons) { 
     73        setupEscListener(); 
     74         
    5575        JButton button; 
    5676        JPanel buttonsPanel = new JPanel(new GridBagLayout()); 
     
    7999         
    80100        JPanel cp = new JPanel(new GridBagLayout());         
    81         cp.add(content, GBC.eol().anchor(GBC.CENTER).insets(0,10,0,0)); //fill(GBC.HORIZONTAL). 
     101        cp.add(content, GBC.eol().anchor(GBC.CENTER).insets(5,10,5,0)); 
    82102        cp.add(buttonsPanel, GBC.eol().anchor(GBC.CENTER).insets(5,5,5,5)); 
    83103         
    84         JScrollPane pane = new JScrollPane(cp);  
     104        JScrollPane pane = new JScrollPane(cp); 
    85105        pane.setBorder(null);         
    86106        setContentPane(pane); 
     
    88108        pack();  
    89109         
    90         // Try to make it not larger than the parent window or at least not larger than a reasonable value 
     110        // Try to make it not larger than the parent window or at least not larger than 2/3 of the screen 
    91111        Dimension d = getSize(); 
    92         Dimension x = new Dimension(700, 500); 
     112        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); 
     113        Dimension x = new Dimension(Math.round(screenSize.width*2/3), Math.round(screenSize.height*2/3)); 
     114         
    93115        try { 
    94              
    95116            if(parent != null) 
    96117                x = JOptionPane.getFrameForComponent(parent).getSize(); 
    97118        } catch(NullPointerException e) { } 
     119         
     120        boolean limitedInWidth = d.width > x.width; 
     121        boolean limitedInHeight = d.height > x.height; 
    98122 
    99123        if(x.width  > 0 && d.width  > x.width)  d.width  = x.width; 
    100124        if(x.height > 0 && d.height > x.height) d.height = x.height; 
     125         
     126        // We have a vertical scrollbar and enough space to prevent a horizontal one 
     127        if(!limitedInWidth && limitedInHeight) 
     128            d.width += new JScrollBar().getPreferredSize().width; 
     129         
    101130        setSize(d); 
    102          
    103         setLocationRelativeTo(parent);         
    104          
    105         setupEscListener(); 
     131        setLocationRelativeTo(parent); 
    106132        setVisible(true); 
    107133    } 
  • trunk/src/org/openstreetmap/josm/gui/JMultilineLabel.java

    r1169 r1397  
    9393        float w = insets.left + insets.right; 
    9494        float x = insets.left, y=insets.top; 
     95               
     96         
    9597        if (width > 0 && text != null && text.length() > 0) { 
    96             AttributedString as = new AttributedString(getText()); 
    97             as.addAttribute(TextAttribute.FONT, getFont()); 
    98             AttributedCharacterIterator aci = as.getIterator(); 
    99             LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc); 
    100             float max = 0; 
    101             while (lbm.getPosition() < aci.getEndIndex()) { 
    102                 TextLayout textLayout = lbm.nextLayout(width); 
    103                 if (g != null && isJustified() && textLayout.getVisibleAdvance() > 0.80 * width) 
    104                     textLayout = textLayout.getJustifiedLayout(width); 
    105                 if (g != null) 
    106                     textLayout.draw(g, x, y + textLayout.getAscent()); 
    107                 y += textLayout.getDescent() + textLayout.getLeading() + textLayout.getAscent(); 
    108                 max = Math.max(max, textLayout.getVisibleAdvance()); 
     98            String[] lines = getText().split("\n");              
     99            for(String line : lines) { 
     100                // Insert a space so new lines get rendered 
     101                if(line.length() == 0) line = " "; 
     102                AttributedString as = new AttributedString(line); 
     103                as.addAttribute(TextAttribute.FONT, getFont()); 
     104                AttributedCharacterIterator aci = as.getIterator(); 
     105                LineBreakMeasurer lbm = new LineBreakMeasurer(aci, frc); 
     106                float max = 0; 
     107                while (lbm.getPosition() < aci.getEndIndex()) { 
     108                    TextLayout textLayout = lbm.nextLayout(width); 
     109                    if (g != null && isJustified() && textLayout.getVisibleAdvance() > 0.80 * width) 
     110                        textLayout = textLayout.getJustifiedLayout(width); 
     111                    if (g != null) 
     112                        textLayout.draw(g, x, y + textLayout.getAscent()); 
     113                    y += textLayout.getDescent() + textLayout.getLeading() + textLayout.getAscent(); 
     114                    max = Math.max(max, textLayout.getVisibleAdvance()); 
     115                } 
     116                w += max; 
    109117            } 
    110             w += max; 
    111118        } 
    112119        return new Dimension((int)Math.ceil(w), (int)Math.ceil(y) + insets.bottom); 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/LayerListDialog.java

    r1265 r1397  
    2222import javax.swing.JLabel; 
    2323import javax.swing.JList; 
    24 import javax.swing.JOptionPane; 
    2524import javax.swing.JPanel; 
    2625import javax.swing.JScrollPane; 
     
    3130 
    3231import org.openstreetmap.josm.Main; 
     32import org.openstreetmap.josm.gui.ExtendedDialog; 
    3333import org.openstreetmap.josm.gui.MapFrame; 
    3434import org.openstreetmap.josm.gui.MapView; 
     
    7777                if (((OsmDataLayer)l).isModified()) 
    7878                { 
    79                     if(JOptionPane.showConfirmDialog(instance, tr("There are unsaved changes. Delete the layer anwyay?"), 
    80                     tr("Unsaved Changes"), JOptionPane.YES_NO_OPTION) != JOptionPane.YES_OPTION) 
    81                         return; 
     79                    int result = new ExtendedDialog(Main.parent, tr("Unsaved Changes"), 
     80                        tr("There are unsaved changes. Delete the layer anwyay?"), 
     81                        new String[] {tr("Delete Layer"), tr("Cancel")}, 
     82                        new String[] {"dialogs/delete.png", "cancel.png"}).getValue();  
     83 
     84                    if(result != 1) return; 
    8285                } 
    8386                else if(!DontShowAgainInfo.show("delete_layer", tr("Do you really want to delete the whole layer?"), false)) 
  • trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java

    r1354 r1397  
    5757import org.openstreetmap.josm.data.osm.RelationMember; 
    5858import org.openstreetmap.josm.data.osm.visitor.NameVisitor; 
     59import org.openstreetmap.josm.gui.ExtendedDialog; 
    5960import org.openstreetmap.josm.gui.MapFrame; 
    6061import org.openstreetmap.josm.gui.SideButton; 
     
    548549                        NameVisitor n = new NameVisitor(); 
    549550                        cur.visit(n); 
    550                         if(JOptionPane.showConfirmDialog(Main.parent, tr("Really delete selection from relation {0}?", n.name), 
    551                         tr("Change relation"), JOptionPane.YES_NO_OPTION) == JOptionPane.YES_NO_OPTION) 
     551                         
     552                        int result = new ExtendedDialog(Main.parent,  
     553                            tr("Change relation"),  
     554                            tr("Really delete selection from relation {0}?", n.name), 
     555                            new String[] {tr("Delete from relation"), tr("Cancel")},  
     556                            new String[] {"dialogs/delete.png", "cancel.png"}).getValue();   
     557                         
     558                        if(result == 1) 
    552559                        { 
    553560                            Relation rel = new Relation(cur); 
  • trunk/src/org/openstreetmap/josm/io/OsmConnection.java

    r1169 r1397  
    1717import javax.swing.JCheckBox; 
    1818import javax.swing.JLabel; 
    19 import javax.swing.JOptionPane; 
    2019import javax.swing.JPanel; 
    2120import javax.swing.JPasswordField; 
     
    2322 
    2423import org.openstreetmap.josm.Main; 
     24import org.openstreetmap.josm.gui.ExtendedDialog;  
    2525import org.openstreetmap.josm.tools.Base64; 
    2626import org.openstreetmap.josm.tools.GBC; 
     
    9090                p.add(savePassword, GBC.eop()); 
    9191 
    92                 int choice = JOptionPane.showConfirmDialog(Main.parent, p, tr("Enter Password"), JOptionPane.OK_CANCEL_OPTION); 
    93                 if (choice == JOptionPane.CANCEL_OPTION) { 
     92                int choice = new ExtendedDialog(Main.parent,  
     93                        tr("Enter Password"),  
     94                        p, 
     95                        new String[] {tr("Login"), tr("Cancel")},  
     96                        new String[] {"ok.png", "cancel.png"}).getValue();   
     97                 
     98                if (choice != 1) { 
    9499                    authCancelled = true; 
    95100                    return null; 
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r1390 r1397  
    3434import org.openstreetmap.josm.gui.MapFrame; 
    3535import org.openstreetmap.josm.gui.download.DownloadSelection; 
     36import org.openstreetmap.josm.gui.ExtendedDialog;  
    3637import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 
    3738import org.openstreetmap.josm.tools.GBC; 
     
    150151                } catch (Throwable e) { 
    151152                    e.printStackTrace(); 
    152                     if(JOptionPane.showConfirmDialog(Main.parent, 
    153                     tr("Could not load plugin {0}. Delete from preferences?", 
    154                     info.name), tr("Disable plugin"), 
    155                     JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) 
     153                     
     154                    int result = new ExtendedDialog(Main.parent,  
     155                        tr("Disable plugin"),  
     156                        tr("Could not load plugin {0}. Delete from preferences?", info.name), 
     157                        new String[] {tr("Disable plugin"), tr("Cancel")},  
     158                        new String[] {"dialogs/delete.png", "cancel.png"}).getValue();   
     159                     
     160                    if(result == 1) 
    156161                    { 
    157162                        plugins.remove(info.name); 
     
    247252 
    248253        if (plugin != null) { 
    249             int answer = JOptionPane.showConfirmDialog( 
    250                     Main.parent, tr("An unexpected exception occurred that may have come from the ''{0}'' plugin.", 
    251                     plugin.info.name) + "\n"+ (plugin.info.author != null ? 
    252                     tr("According to the information within the plugin, the author is {0}.", 
    253                     plugin.info.author) : "") + "\n" + 
    254                     tr("Try updating to the newest version of this plugin before reporting a bug.") + "\n" + 
    255                     tr("Should the plugin be disabled?"), 
    256                     tr("Disable plugin"), 
    257                     JOptionPane.YES_NO_OPTION); 
    258             if (answer == JOptionPane.OK_OPTION) { 
     254            int answer = new ExtendedDialog(Main.parent,  
     255                tr("Disable plugin"),  
     256                tr("An unexpected exception occurred that may have come from the ''{0}'' plugin.", plugin.info.name) 
     257                    + "\n" 
     258                    + (plugin.info.author != null 
     259                        ? tr("According to the information within the plugin, the author is {0}.", plugin.info.author) 
     260                        : "") 
     261                    + "\n" 
     262                    + tr("Try updating to the newest version of this plugin before reporting a bug.") 
     263                    + "\n" 
     264                    + tr("Should the plugin be disabled?"), 
     265                new String[] {tr("Disable plugin"), tr("Cancel")},  
     266                new String[] {"dialogs/delete.png", "cancel.png"}).getValue();   
     267            if (answer == 1) { 
    259268                LinkedList<String> plugins = new LinkedList<String>(Arrays.asList(Main.pref.get("plugins").split(","))); 
    260269                if (plugins.contains(plugin.info.name)) { 
  • trunk/src/org/openstreetmap/josm/plugins/PluginSelection.java

    r1326 r1397  
    3939 
    4040import org.openstreetmap.josm.Main; 
     41import org.openstreetmap.josm.gui.ExtendedDialog; 
    4142import org.openstreetmap.josm.tools.OpenBrowser; 
    4243import org.openstreetmap.josm.tools.XmlObjectParser.Uniform; 
     
    7879            done = true; 
    7980        } else { 
    80             int answer = JOptionPane.showConfirmDialog(Main.parent, tr("Update the following plugins:\n\n{0}", 
    81             toUpdateStr.toString()), tr("Update"), JOptionPane.OK_CANCEL_OPTION); 
    82             if (answer == JOptionPane.OK_OPTION) { 
     81            int answer = new ExtendedDialog(Main.parent,  
     82                        tr("Update"),  
     83                        tr("Update the following plugins:\n\n{0}", toUpdateStr.toString()), 
     84                        new String[] {tr("Update Plugins"), tr("Cancel")},  
     85                        new String[] {"dialogs/refresh.png", "cancel.png"}).getValue();   
     86            if (answer == 1) { 
    8387                PluginDownloader.update(toUpdate); 
    8488                done = true; 
     
    100104        } 
    101105        if (!toDownload.isEmpty()) { 
    102             int answer = JOptionPane.showConfirmDialog(Main.parent, 
    103                     tr("Download the following plugins?\n\n{0}", msg), 
    104                     tr("Download missing plugins"), 
    105                     JOptionPane.YES_NO_OPTION); 
    106             if (answer != JOptionPane.OK_OPTION) 
     106            int answer = new ExtendedDialog(Main.parent,  
     107                        tr("Download missing plugins"), 
     108                        tr("Download the following plugins?\n\n{0}", msg), 
     109                        new String[] {tr("Download Plugins"), tr("Cancel")},  
     110                        new String[] {"download.png", "cancel.png"}).getValue();   
     111            if (answer != 1) 
    107112                for (PluginDescription pd : toDownload) 
    108113                    pluginMap.put(pd.name, false); 
     
    202207                        if ((getLoaded(plugin.name) == null) && (plinfo != null)) { 
    203208                            try { 
    204                                 int answer = JOptionPane.showConfirmDialog(Main.parent, 
    205                                     tr("Plugin archive already available. Do you want to download the current version by deleting existing archive?\n\n{0}", 
    206                                     plinfo.file.getCanonicalPath()), tr("Plugin already exists"), JOptionPane.OK_CANCEL_OPTION); 
    207                                 if (answer == JOptionPane.OK_OPTION) { 
     209                                int answer = new ExtendedDialog(Main.parent,  
     210                                    tr("Plugin already exists"),  
     211                                    tr("Plugin archive already available. Do you want to download" 
     212                                        + " the current version by deleting existing archive?\n\n{0}", 
     213                                        plinfo.file.getCanonicalPath()), 
     214                                    new String[] {tr("Delete and Download"), tr("Cancel")},  
     215                                    new String[] {"download.png", "cancel.png"}).getValue();       
     216                                     
     217                                if (answer == 1) { 
    208218                                    if (!plinfo.file.delete()) { 
    209219                                        JOptionPane.showMessageDialog(Main.parent, tr("Error deleting plugin file: {0}", plinfo.file.getCanonicalPath())); 
Note: See TracChangeset for help on using the changeset viewer.