Changeset 11974 in josm for trunk/src


Ignore:
Timestamp:
2017-04-22T17:57:11+02:00 (7 years ago)
Author:
Don-vip
Message:

add unit tests, javadoc

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java

    r11946 r11974  
    144144    }
    145145
     146    static final class PluginInformationAction extends AbstractAction {
     147        private final PluginInformation info;
     148
     149        PluginInformationAction(PluginInformation info) {
     150            super(tr("Information"));
     151            this.info = info;
     152        }
     153
     154        /**
     155         * Returns plugin information text.
     156         * @return plugin information text
     157         */
     158        public String getText() {
     159            StringBuilder b = new StringBuilder();
     160            for (Entry<String, String> e : info.attr.entrySet()) {
     161                b.append(e.getKey());
     162                b.append(": ");
     163                b.append(e.getValue());
     164                b.append('\n');
     165            }
     166            return b.toString();
     167        }
     168
     169        @Override
     170        public void actionPerformed(ActionEvent event) {
     171            String text = getText();
     172            JosmTextArea a = new JosmTextArea(10, 40);
     173            a.setEditable(false);
     174            a.setText(text);
     175            a.setCaretPosition(0);
     176            if (!GraphicsEnvironment.isHeadless()) {
     177                JOptionPane.showMessageDialog(Main.parent, new JScrollPane(a), tr("Plugin information"),
     178                        JOptionPane.INFORMATION_MESSAGE);
     179            }
     180        }
     181    }
     182
    146183    /**
    147184     * Description of a deprecated plugin
     
    14081445            pluginTab.add(new JLabel(name), GBC.std());
    14091446            pluginTab.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
    1410             pluginTab.add(new JButton(new AbstractAction(tr("Information")) {
    1411                 @Override
    1412                 public void actionPerformed(ActionEvent event) {
    1413                     StringBuilder b = new StringBuilder();
    1414                     for (Entry<String, String> e : info.attr.entrySet()) {
    1415                         b.append(e.getKey());
    1416                         b.append(": ");
    1417                         b.append(e.getValue());
    1418                         b.append('\n');
    1419                     }
    1420                     JosmTextArea a = new JosmTextArea(10, 40);
    1421                     a.setEditable(false);
    1422                     a.setText(b.toString());
    1423                     a.setCaretPosition(0);
    1424                     JOptionPane.showMessageDialog(Main.parent, new JScrollPane(a), tr("Plugin information"),
    1425                             JOptionPane.INFORMATION_MESSAGE);
    1426                 }
    1427             }), GBC.eol());
     1447            pluginTab.add(new JButton(new PluginInformationAction(info)), GBC.eol());
    14281448
    14291449            JosmTextArea description = new JosmTextArea(info.description == null ? tr("no description available")
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r11809 r11974  
    2121import org.openstreetmap.josm.data.osm.Way;
    2222
     23/**
     24 * The context switch offers possibility to use tags of referenced primitive when constructing primitive name.
     25 * @author jttt
     26 * @since 4546
     27 */
    2328public class ContextSwitchTemplate implements TemplateEntry {
    2429
     
    244249    }
    245250
     251    /**
     252     * Constructs a new {@code ContextSwitchTemplate}.
     253     * @param match match
     254     * @param template template
     255     * @param searchExpressionPosition search expression position
     256     * @throws ParseError if a parse error occurs, or if the match transformation returns the same primitive
     257     */
    246258    public ContextSwitchTemplate(Match match, TemplateEntry template, int searchExpressionPosition) throws ParseError {
    247259        Match m = transform(match, searchExpressionPosition);
Note: See TracChangeset for help on using the changeset viewer.