Ticket #2211: MakeRelEditorWorkAgain.patch

File MakeRelEditorWorkAgain.patch, 4.4 KB (added by xeen, 15 years ago)
  • src/org/openstreetmap/josm/gui/dialogs/RelationEditor.java

     
    99import java.awt.event.ActionEvent;
    1010import java.awt.event.ActionListener;
    1111import java.awt.event.KeyEvent;
     12import java.awt.event.WindowEvent;
     13import java.awt.event.WindowListener;
    1214import java.io.IOException;
    1315import java.text.Collator;
    1416import java.util.ArrayList;
     
    1820import java.util.Comparator;
    1921import java.util.Map.Entry;
    2022
     23import javax.swing.AbstractAction;
     24import javax.swing.Action;
    2125import javax.swing.JLabel;
    2226import javax.swing.JOptionPane;
    2327import javax.swing.JPanel;
     
    2529import javax.swing.JTabbedPane;
    2630import javax.swing.JTable;
    2731import javax.swing.ListSelectionModel;
     32import javax.swing.WindowConstants;
    2833import javax.swing.event.ListSelectionEvent;
    2934import javax.swing.event.ListSelectionListener;
    3035import javax.swing.event.TableModelEvent;
     
    174179    // =================== FIXME FIXME FIXME =====================
    175180    // ... until here, and also get rid of the "Collections.sort..." below.
    176181
     182    // We need this twice, so cache result
     183    protected final static String applyChangesText = tr("Apply Changes");
     184   
    177185    /**
    178186     * Creates a new relation editor for the given relation. The relation
    179187     * will be saved if the user selects "ok" in the editor.
     
    205213                            ? tr ("Edit new relation")
    206214                            : tr("Edit relation #{0}", relation.id)
    207215                       ),
    208                 new String[] { tr("Apply Changes"), tr("Cancel")},
     216                new String[] { applyChangesText, tr("Cancel")},
    209217                false
    210218        );
    211219
    212220        this.relation = relation;
    213221        ordered = !Main.pref.get("osm-server.version", "0.5").equals("0.5");
    214 ordered = true;
     222
    215223        if (relation == null) {
    216224            // create a new relation
    217225            this.clone = new Relation();
     
    234242        setSize(findMaxDialogSize());
    235243
    236244        try { setAlwaysOnTop(true); } catch (SecurityException sx) {}
    237 
    238245        setVisible(true);
    239 
    240         if(getValue() != 1)
    241             return;
    242 
    243         // User clicked "Apply"
    244         applyChanges();
    245246    }
     247   
    246248
    247249    /**
    248250     * Basic Editor panel has two blocks: a tag table at the top and a membership list below
     
    422424            DataSet.fireSelectionChanged(Main.ds.getSelected());
    423425        }
    424426    }
     427   
     428    @Override
     429    protected void buttonAction(ActionEvent evt) {
     430        String a = evt.getActionCommand();
     431        if(applyChangesText.equals(a))
     432            applyChanges();
     433           
     434        setVisible(false);
     435    }
    425436
    426437    @Override
    427438    protected Dimension findMaxDialogSize() {
  • src/org/openstreetmap/josm/gui/ExtendedDialog.java

     
    8989        for(int i=0; i < bTexts.length; i++) {
    9090            Action action = new AbstractAction(bTexts[i]) {
    9191                public void actionPerformed(ActionEvent evt) {
    92                     String a = evt.getActionCommand();
    93                     for(int i=0; i < bTexts.length; i++)
    94                         if(bTexts[i].equals(a)) {
    95                             result = i+1;
    96                             break;
    97                         }
    98                        
    99                     setVisible(false);
     92                    buttonAction(evt);
    10093                }
    10194            };
    10295           
     
    146139    }
    147140   
    148141    /**
     142     * This gets performed whenever a button is clicked or activated
     143     * @param evt the button event
     144     */
     145    protected void buttonAction(ActionEvent evt) {
     146        String a = evt.getActionCommand();
     147        for(int i=0; i < bTexts.length; i++)
     148            if(bTexts[i].equals(a)) {
     149                result = i+1;
     150                break;
     151            }
     152           
     153        setVisible(false);
     154    }
     155   
     156    /**
    149157     * Tries to find a good value of how large the dialog should be
    150158     * @return Dimension Size of the parent Component or 2/3 of screen size if not available
    151159     */