source: subversion/applications/editors/josm/plugins/CustomizePublicTransportStop/src/org/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAction.java

Last change on this file was 34501, checked in by donvip, 8 months ago

rename package

File size: 3.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.plugins.customizepublictransportstop;
3
4import static org.openstreetmap.josm.gui.help.HelpUtil.ht;
5import static org.openstreetmap.josm.tools.I18n.tr;
6
7import java.awt.event.ActionEvent;
8import java.awt.event.KeyEvent;
9
10import org.openstreetmap.josm.actions.JosmAction;
11import org.openstreetmap.josm.tools.Shortcut;
12
13/**
14 * Class of customizing of stop area Action for josm editor
15 *
16 * @author Rodion Scherbakov
17 */
18public class CustomizeStopAction extends JosmAction implements IStopAreaCustomizer {
19
20    /**
21     * Menu icon file name
22     */
23    private static final String CUSTOMIZE_STOP_ACTION_ICON_NAME = "bus.png";
24    /**
25     * Menu item tooltip
26     */
27    private static final String CUSTOMIZE_STOP_ACTION_MENU_TOOLTIP = "Customize stop under osm public transit standard v2";
28    /**
29     * Menu item caption
30     */
31    private static final String CUSTOMIZE_STOP_ACTION_MENU_NAME = "Customize stop";
32    /**
33     * Serialization UID
34     */
35    private static final long serialVersionUID = 6769508902749446137L;
36
37    /**
38     * Constructor of stop area customizing action
39     *
40     * @param name Name of action in josm menu
41     * @param iconName Name of icon file for josm menu
42     * @param tooltip Tooltip of action in josm menu
43     * @param shortcut Short key of action on josm
44     * @param registerInToolbar Flag of registration in josm menu
45     */
46    protected CustomizeStopAction(String name, String iconName, String tooltip, Shortcut shortcut,
47            boolean registerInToolbar) {
48        super(name, iconName, tooltip, shortcut, registerInToolbar);
49    }
50
51    /**
52     * Constructs a stop area customizing action.
53     *
54     * @return the stop area customizing action
55     */
56    public static CustomizeStopAction createCustomizeStopAction() {
57        // CHECKSTYLE.OFF: LineLength
58        CustomizeStopAction action = new CustomizeStopAction(tr(CUSTOMIZE_STOP_ACTION_MENU_NAME),
59                CUSTOMIZE_STOP_ACTION_ICON_NAME, tr(CUSTOMIZE_STOP_ACTION_MENU_TOOLTIP),
60                Shortcut.registerShortcut("tools:customizestop", tr("Tool: {0}", tr(CUSTOMIZE_STOP_ACTION_MENU_NAME)),
61                        KeyEvent.VK_U, Shortcut.DIRECT),
62                true);
63        action.putValue("help", ht("/Action/CustomizeStopAction"));
64        // CHECKSTYLE.ON: LineLength
65        return action;
66    }
67
68    /**
69     * Realization of action Construct stop area object from selected object and
70     * show settings dialog
71     */
72    @Override
73    public void actionPerformed(ActionEvent arg0) {
74        if (!isEnabled())
75            return;
76        CreateStopAreaFromSelectedObjectOperation createStopAreaFromSelectedObjectOperation = new CreateStopAreaFromSelectedObjectOperation(
77                getLayerManager().getEditDataSet());
78        StopArea stopArea = createStopAreaFromSelectedObjectOperation.performCustomizing(null);
79        if (stopArea == null)
80            return;
81        CustomizePublicTransportStopDialog dialog = new CustomizePublicTransportStopDialog(this, stopArea);
82        dialog.setVisible(true);
83    }
84
85    /**
86     * Perform stop area customizing under user selection This method is launched by
87     * stop area settings dialog
88     *
89     * @param stopArea Stop area object with new settings
90     */
91    @Override
92    public StopArea performCustomizing(StopArea stopArea) {
93        CustomizeStopAreaOperation customizeStopAreaOperation = new CustomizeStopAreaOperation(
94                getLayerManager().getEditDataSet());
95        return customizeStopAreaOperation.performCustomizing(stopArea);
96    }
97
98}
Note: See TracBrowser for help on using the repository browser.