Changeset 34091 in osm for applications/editors/josm


Ignore:
Timestamp:
2018-03-20T01:44:41+01:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 12987. The plugin does not work and needs further corrections, see #josm16110

Location:
applications/editors/josm/plugins/colorscheme
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/colorscheme/build.xml

    r32680 r34091  
    55    <property name="commit.message" value="Uses new constructor for Plugin"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10580"/>
     7    <property name="plugin.main.version" value="12987"/>
    88
    99    <property name="plugin.author" value="Christof Dallermassl"/>
  • applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme/ColorSchemePlugin.java

    r23192 r34091  
    1212 * ColorScheme Plugin for JOSM.
    1313 * @author cdaller
    14  *
    1514 */
    1615public class ColorSchemePlugin extends Plugin {
     
    1817    /**
    1918     * Default Constructor
     19     * @param info plugin information
    2020     */
    2121    public ColorSchemePlugin(PluginInformation info) {
     
    2727        return new ColorSchemePreference();
    2828    }
    29 
    30 
    31 
    3229}
  • applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme/ColorSchemePreference.java

    r30737 r34091  
    88
    99import java.awt.GridBagLayout;
    10 import java.awt.event.ActionEvent;
    11 import java.awt.event.ActionListener;
    1210import java.util.ArrayList;
     11import java.util.Arrays;
    1312import java.util.Collections;
    1413import java.util.HashMap;
     
    2827
    2928import org.openstreetmap.josm.Main;
     29import org.openstreetmap.josm.data.preferences.ColorInfo;
    3030import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
    3131import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
     
    3333import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
    3434import org.openstreetmap.josm.gui.preferences.display.ColorPreference;
     35import org.openstreetmap.josm.tools.ColorHelper;
    3536import org.openstreetmap.josm.tools.GBC;
    3637
     
    6970
    7071        JButton useScheme = new JButton(tr("Use"));
    71         useScheme.addActionListener(new ActionListener(){
    72             public void actionPerformed(ActionEvent e) {
    73                 if (schemesList.getSelectedIndex() == -1)
    74                     JOptionPane.showMessageDialog(Main.parent, tr("Please select a scheme to use."));
    75                 else {
    76                     String schemeName = (String) listModel.get(schemesList.getSelectedIndex());
    77                     getColorPreference(gui).setColorModel(getColorMap(schemeName));
    78                 }
     72        useScheme.addActionListener(e -> {
     73            if (schemesList.getSelectedIndex() == -1)
     74                JOptionPane.showMessageDialog(Main.parent, tr("Please select a scheme to use."));
     75            else {
     76                String schemeName1 = (String) listModel.get(schemesList.getSelectedIndex());
     77                getColorPreference(gui).setColors(getColorMap(schemeName1));
    7978            }
    8079        });
    8180        JButton addScheme = new JButton(tr("Add"));
    82         addScheme.addActionListener(new ActionListener(){
    83             public void actionPerformed(ActionEvent e) {
    84                 String schemeName = JOptionPane.showInputDialog(Main.parent, tr("Color Scheme"));
    85                 if (schemeName == null)
    86                     return;
    87                 schemeName = schemeName.replaceAll("\\.", "_");
    88                 setColorScheme(schemeName, getColorPreference(gui).getColorModel());
    89                 listModel.addElement(schemeName);
     81        addScheme.addActionListener(e -> {
     82            String schemeName1 = JOptionPane.showInputDialog(Main.parent, tr("Color Scheme"));
     83            if (schemeName1 == null)
     84                return;
     85            schemeName1 = schemeName1.replaceAll("\\.", "_");
     86            setColorScheme(schemeName1, getColorPreference(gui).getColors());
     87            listModel.addElement(schemeName1);
     88            saveSchemeNamesToPref();
     89        });
     90
     91        JButton deleteScheme = new JButton(tr("Delete"));
     92        deleteScheme.addActionListener(e -> {
     93            if (schemesList.getSelectedIndex() == -1)
     94                JOptionPane.showMessageDialog(Main.parent, tr("Please select the scheme to delete."));
     95            else {
     96                String schemeName1 = (String) listModel.get(schemesList.getSelectedIndex());
     97                removeColorSchemeFromPreferences(schemeName1);
     98                listModel.remove(schemesList.getSelectedIndex());
    9099                saveSchemeNamesToPref();
    91             }
    92         });
    93 
    94         JButton deleteScheme = new JButton(tr("Delete"));
    95         deleteScheme.addActionListener(new ActionListener(){
    96             public void actionPerformed(ActionEvent e) {
    97                 if (schemesList.getSelectedIndex() == -1)
    98                     JOptionPane.showMessageDialog(Main.parent, tr("Please select the scheme to delete."));
    99                 else {
    100                     String schemeName = (String) listModel.get(schemesList.getSelectedIndex());
    101                     removeColorSchemeFromPreferences(schemeName);
    102                     listModel.remove(schemesList.getSelectedIndex());
    103                     saveSchemeNamesToPref();
    104                 }
    105100            }
    106101        });
     
    169164     * Copy all color entries from the given map to entries in preferences with the scheme name.
    170165     * @param schemeName the name of the scheme.
    171      * @param the map containing the color key (without prefix) and the html color values.
    172      */
    173     public void setColorScheme(String schemeName, Map<String, String> colorMap) {
     166     * @param colorMap the map containing the color key (without prefix) and the html color values.
     167     */
     168    public void setColorScheme(String schemeName, Map<String, ColorInfo> colorMap) {
    174169        String key;
    175170        for(String colorKey : colorMap.keySet()) {
    176171            key = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX + colorKey;
    177             Main.pref.put(key, colorMap.get(colorKey));
     172            Main.pref.put(key, ColorHelper.color2html(colorMap.get(colorKey).getValue()));
    178173        }
    179174    }
     
    183178     * value = html color code).
    184179     * @param schemeName the name of the scheme.
    185      */
    186     public Map<String, String> getColorMap(String schemeName) {
     180     * @return color map for the given scheme name
     181     */
     182    public Map<String, ColorInfo> getColorMap(String schemeName) {
    187183        String colorKey;
    188184        String prefix = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX;
    189         Map<String, String>colorMap = new HashMap<>();
     185        Map<String, ColorInfo> colorMap = new HashMap<>();
    190186        for(String schemeColorKey : Main.pref.getAllPrefix(prefix).keySet()) {
    191187            colorKey = schemeColorKey.substring(prefix.length());
    192             colorMap.put(colorKey, Main.pref.get(schemeColorKey));
     188            colorMap.put(colorKey, ColorInfo.fromPref(Arrays.asList(
     189                    // FIXME: does not work, corrupts the color table ? See #16110
     190                    Main.pref.get(schemeColorKey), "", "", ""), false));
    193191        }
    194192        return colorMap;
Note: See TracChangeset for help on using the changeset viewer.