Ignore:
Timestamp:
2009-02-01T14:23:24+01:00 (16 years ago)
Author:
hampelratte
Message:

moved adding of nickname and date to super class

Location:
applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action
Files:
3 edited

Legend:

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

    r12778 r13477  
    3535
    3636import org.openstreetmap.josm.Main;
    37 import org.openstreetmap.josm.plugins.osb.ConfigKeys;
    3837import org.openstreetmap.josm.plugins.osb.api.EditAction;
    3938
     
    5049    @Override
    5150    protected void doActionPerformed(ActionEvent e) throws Exception {
    52         // get the user nickname
    53         String nickname = Main.pref.get(ConfigKeys.OSB_NICKNAME);
    54         if(nickname == null || nickname.length() == 0) {
    55             nickname = JOptionPane.showInputDialog(Main.parent, tr("Please enter a user name"));
    56             if(nickname == null) {
    57                 nickname = tr("NoName");
    58             } else {
    59                 Main.pref.put(ConfigKeys.OSB_NICKNAME, nickname);
    60             }
    61         }
    62 
    6351        String comment = JOptionPane.showInputDialog(Main.parent, tr("Enter your comment"));
    6452        if(comment != null) {
    65             comment = comment.concat(" [").concat(nickname).concat("]");
     53            comment = addMesgInfo(comment);
    6654            editAction.execute(getSelectedNode(), comment);
    6755        }
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/NewIssueAction.java

    r13212 r13477  
    9393
    9494    private void addNewIssue(MouseEvent e) {
    95         // get the user nickname
    96         String nickname = Main.pref.get(ConfigKeys.OSB_NICKNAME);
    97         if(nickname == null || nickname.length() == 0) {
    98             nickname = JOptionPane.showInputDialog(Main.parent, tr("Please enter a user name"));
    99             if(nickname == null) {
    100                 nickname = "NoName";
    101             } else {
    102                 Main.pref.put(ConfigKeys.OSB_NICKNAME, nickname);
    103             }
    104         }
    105 
    10695        // get the comment
    10796        String result = JOptionPane.showInputDialog(Main.parent,
     
    112101        if(result != null && result.length() > 0) {
    113102            try {
    114                 result = result.concat(" [").concat(nickname).concat("]");
     103                result = addMesgInfo(result);
    115104                Node n = newAction.execute(e.getPoint(), result);
    116105                plugin.getDataSet().addPrimitive(n);
  • applications/editors/josm/plugins/openstreetbugs/src/org/openstreetmap/josm/plugins/osb/gui/action/OsbAction.java

    r12778 r13477  
    2828package org.openstreetmap.josm.plugins.osb.gui.action;
    2929
     30import static org.openstreetmap.josm.tools.I18n.tr;
     31
    3032import java.awt.event.ActionEvent;
     33import java.text.DateFormat;
    3134import java.util.ArrayList;
     35import java.util.Date;
    3236import java.util.List;
     37import java.util.Locale;
    3338
    3439import javax.swing.AbstractAction;
     40import javax.swing.JOptionPane;
    3541
     42import org.openstreetmap.josm.Main;
    3643import org.openstreetmap.josm.data.osm.Node;
     44import org.openstreetmap.josm.plugins.osb.ConfigKeys;
    3745
    3846public abstract class OsbAction extends AbstractAction {
     
    7785        observers.remove(obs);
    7886    }
     87   
     88    protected String addMesgInfo(String msg) {
     89        // get the user nickname
     90        String nickname = Main.pref.get(ConfigKeys.OSB_NICKNAME);
     91        if(nickname == null || nickname.length() == 0) {
     92            nickname = JOptionPane.showInputDialog(Main.parent, tr("Please enter a user name"));
     93            if(nickname == null) {
     94                nickname = "NoName";
     95            } else {
     96                Main.pref.put(ConfigKeys.OSB_NICKNAME, nickname);
     97            }
     98        }
     99       
     100        // concatenate nickname and date, if date should be included
     101        String info = nickname;
     102        if(Main.pref.getBoolean(ConfigKeys.OSB_INCLUDE_DATE)) {
     103            // get the date
     104            DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.LONG, Locale.getDefault());
     105            String date = df.format(new Date());
     106           
     107            // concatenate nickname and date
     108            info = info.concat(", ").concat(date);
     109        }
     110       
     111        // add user and date info to the message
     112        msg = msg.concat(" [").concat(info).concat("]");
     113       
     114        return msg;
     115    }
    79116}
Note: See TracChangeset for help on using the changeset viewer.