Ignore:
Timestamp:
2009-04-25T23:15:22+02:00 (16 years ago)
Author:
hampelratte
Message:
  • replaced joptionpanes with a custom dialog
  • added a history to the dialog input fields
Location:
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui
Files:
10 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/AddCommentAction.java

    r13497 r14748  
    3131
    3232import java.awt.event.ActionEvent;
    33 
    34 import javax.swing.JOptionPane;
     33import java.util.List;
    3534
    3635import org.openstreetmap.josm.Main;
     36import org.openstreetmap.josm.plugins.osb.OsbPlugin;
    3737import org.openstreetmap.josm.plugins.osb.api.EditAction;
     38import org.openstreetmap.josm.plugins.osb.gui.dialogs.TextInputDialog;
     39import org.openstreetmap.josm.plugins.osb.gui.historycombobox.HistoryChangedListener;
     40import org.openstreetmap.josm.plugins.osb.gui.historycombobox.StringUtils;
    3841
    3942public class AddCommentAction extends OsbAction {
     
    4952    @Override
    5053    protected void doActionPerformed(ActionEvent e) throws Exception {
    51         String comment = JOptionPane.showInputDialog(Main.parent, tr("Enter your comment"));
     54        List<String> history = StringUtils.stringToList(Main.pref.get("osb.comment.history"), "§§§");
     55        HistoryChangedListener l = new HistoryChangedListener() {
     56            public void historyChanged(List<String> history) {
     57                Main.pref.put("osb.comment.history", StringUtils.listToString(history, "§§§"));
     58            }
     59        };
     60        String comment = TextInputDialog.showDialog(
     61                Main.map,
     62                tr("Add a comment"),
     63                tr("Enter your comment"),
     64                OsbPlugin.loadIcon("add_comment22.png"),
     65                history, l);
     66       
    5267        if(comment != null) {
    5368            comment = addMesgInfo(comment);
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/CloseIssueAction.java

    r14471 r14748  
    3131
    3232import java.awt.event.ActionEvent;
    33 
    34 import javax.swing.JOptionPane;
     33import java.util.List;
    3534
    3635import org.openstreetmap.josm.Main;
     36import org.openstreetmap.josm.plugins.osb.OsbPlugin;
    3737import org.openstreetmap.josm.plugins.osb.api.CloseAction;
     38import org.openstreetmap.josm.plugins.osb.api.EditAction;
     39import org.openstreetmap.josm.plugins.osb.gui.dialogs.TextInputDialog;
     40import org.openstreetmap.josm.plugins.osb.gui.historycombobox.HistoryChangedListener;
     41import org.openstreetmap.josm.plugins.osb.gui.historycombobox.StringUtils;
    3842
    3943public class CloseIssueAction extends OsbAction {
     
    4246
    4347    private CloseAction closeAction = new CloseAction();
     48    private EditAction commentAction = new EditAction();
    4449
    4550    public CloseIssueAction() {
     
    4954    @Override
    5055    protected void doActionPerformed(ActionEvent e) throws Exception {
    51         int closeOk = JOptionPane.showConfirmDialog(Main.parent,
    52                 tr("Really mark this issue as ''done''?"),
     56        List<String> history = StringUtils.stringToList(Main.pref.get("osb.comment.history"), "§§§");
     57        HistoryChangedListener l = new HistoryChangedListener() {
     58            public void historyChanged(List<String> history) {
     59                Main.pref.put("osb.comment.history", StringUtils.listToString(history, "§§§"));
     60            }
     61        };
     62        String comment = TextInputDialog.showDialog(Main.map,
    5363                tr("Really close?"),
    54                 JOptionPane.YES_NO_OPTION);
     64                tr("<html>Really mark this issue as ''done''?<br><br>You may add an optional comment:</html>"),
     65                OsbPlugin.loadIcon("icon_valid22.png"),
     66                history, l);
    5567
    56         if(closeOk == JOptionPane.YES_OPTION) {
    57             int addComment = JOptionPane.showConfirmDialog(Main.parent,
    58                     tr("Do you want to add a comment?"),
    59                     tr("Add comment?"),
    60                     JOptionPane.YES_NO_OPTION);
    61             if(addComment == JOptionPane.YES_OPTION) {
    62                 new AddCommentAction().doActionPerformed(new ActionEvent(this, 0, "add_comment"));
     68        if(comment != null) {
     69            if(comment.length() > 0) {
     70                commentAction.execute(getSelectedNode(), comment);
    6371            }
    6472            closeAction.execute(getSelectedNode());
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/NewIssueAction.java

    r13497 r14748  
    3535import java.awt.event.MouseListener;
    3636import java.io.IOException;
     37import java.util.List;
    3738
    3839import javax.swing.JOptionPane;
     
    4445import org.openstreetmap.josm.plugins.osb.OsbPlugin;
    4546import org.openstreetmap.josm.plugins.osb.api.NewAction;
     47import org.openstreetmap.josm.plugins.osb.gui.dialogs.TextInputDialog;
     48import org.openstreetmap.josm.plugins.osb.gui.historycombobox.HistoryChangedListener;
     49import org.openstreetmap.josm.plugins.osb.gui.historycombobox.StringUtils;
    4650
    4751public class NewIssueAction extends OsbAction implements MouseListener {
     
    9397
    9498    private void addNewIssue(MouseEvent e) {
    95         // get the comment
    96         String result = JOptionPane.showInputDialog(Main.parent,
     99        List<String> history = StringUtils.stringToList(Main.pref.get("osb.new.history"), "§§§");
     100        HistoryChangedListener l = new HistoryChangedListener() {
     101            public void historyChanged(List<String> history) {
     102                Main.pref.put("osb.new.history", StringUtils.listToString(history, "§§§"));
     103            }
     104        };
     105        String result = TextInputDialog.showDialog(
     106                Main.map,
     107                tr("Create issue"),
    97108                tr("Describe the problem precisely"),
    98                 tr("Create issue"),
    99                 JOptionPane.QUESTION_MESSAGE);
     109                OsbPlugin.loadIcon("icon_error_add22.png"),
     110                history, l);
    100111
    101112        if(result != null && result.length() > 0) {
Note: See TracChangeset for help on using the changeset viewer.