Changeset 34497 in osm for applications/editors/josm
- Timestamp:
- 2018-08-18T03:15:04+02:00 (6 years ago)
- Location:
- applications/editors/josm/plugins/colorscheme
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/colorscheme/build.xml
r34091 r34497 5 5 <property name="commit.message" value="Uses new constructor for Plugin"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 2987"/>7 <property name="plugin.main.version" value="14153"/> 8 8 9 9 <property name="plugin.author" value="Christof Dallermassl"/> -
applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme/ColorSchemePreference.java
r34095 r34497 26 26 import javax.swing.JScrollPane; 27 27 28 import org.openstreetmap.josm. Main;28 import org.openstreetmap.josm.data.Preferences; 29 29 import org.openstreetmap.josm.data.preferences.ColorInfo; 30 import org.openstreetmap.josm.gui.MainApplication; 30 31 import org.openstreetmap.josm.gui.preferences.PreferenceSetting; 31 32 import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane; … … 33 34 import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting; 34 35 import org.openstreetmap.josm.gui.preferences.display.ColorPreference; 36 import org.openstreetmap.josm.spi.preferences.Config; 35 37 import org.openstreetmap.josm.tools.ColorHelper; 36 38 import org.openstreetmap.josm.tools.GBC; … … 56 58 panel.setBorder(BorderFactory.createEmptyBorder(5,5,5,5)); 57 59 58 Map<String, String> colorMap = Main.pref.getAllPrefix(PREF_KEY_COLOR_PREFIX);60 Map<String, String> colorMap = Preferences.main().getAllPrefix(PREF_KEY_COLOR_PREFIX); 59 61 colorKeys = new ArrayList<>(colorMap.keySet()); 60 62 Collections.sort(colorKeys); 61 63 listModel = new DefaultListModel<>(); 62 64 schemesList = new JList<>(listModel); 63 String schemes = Main.pref.get(PREF_KEY_SCHEMES_NAMES);65 String schemes = Config.getPref().get(PREF_KEY_SCHEMES_NAMES); 64 66 StringTokenizer st = new StringTokenizer(schemes, ";"); 65 67 String schemeName; … … 72 74 useScheme.addActionListener(e -> { 73 75 if (schemesList.getSelectedIndex() == -1) 74 JOptionPane.showMessageDialog(Main .parent, tr("Please select a scheme to use."));76 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Please select a scheme to use.")); 75 77 else { 76 78 String schemeName1 = (String) listModel.get(schemesList.getSelectedIndex()); … … 80 82 JButton addScheme = new JButton(tr("Add")); 81 83 addScheme.addActionListener(e -> { 82 String schemeName1 = JOptionPane.showInputDialog(Main .parent, tr("Color Scheme"));84 String schemeName1 = JOptionPane.showInputDialog(MainApplication.getMainFrame(), tr("Color Scheme")); 83 85 if (schemeName1 == null) 84 86 return; … … 92 94 deleteScheme.addActionListener(e -> { 93 95 if (schemesList.getSelectedIndex() == -1) 94 JOptionPane.showMessageDialog(Main .parent, tr("Please select the scheme to delete."));96 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Please select the scheme to delete.")); 95 97 else { 96 98 String schemeName1 = (String) listModel.get(schemesList.getSelectedIndex()); … … 133 135 for (int i = 0; i < schemesList.getModel().getSize(); ++i) 134 136 sb.append(";"+schemesList.getModel().getElementAt(i)); 135 Main.pref.put(PREF_KEY_SCHEMES_NAMES, sb.toString().substring(1));137 Config.getPref().put(PREF_KEY_SCHEMES_NAMES, sb.toString().substring(1)); 136 138 } else 137 Main.pref.put(PREF_KEY_SCHEMES_NAMES, null);139 Config.getPref().put(PREF_KEY_SCHEMES_NAMES, null); 138 140 } 139 141 … … 154 156 public void removeColorSchemeFromPreferences(String schemeName) { 155 157 // delete color entries for scheme in preferences: 156 Map<String, String> colors = Main.pref.getAllPrefix(PREF_KEY_SCHEMES_PREFIX + schemeName + ".");158 Map<String, String> colors = Preferences.main().getAllPrefix(PREF_KEY_SCHEMES_PREFIX + schemeName + "."); 157 159 for(String key : colors.keySet()) { 158 Main.pref.put(key, null);160 Config.getPref().put(key, null); 159 161 } 160 162 } … … 169 171 for(String colorKey : colorMap.keySet()) { 170 172 key = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX + colorKey; 171 Main.pref.put(key, ColorHelper.color2html(colorMap.get(colorKey).getValue()));173 Config.getPref().put(key, ColorHelper.color2html(colorMap.get(colorKey).getValue())); 172 174 } 173 175 } … … 183 185 String prefix = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX; 184 186 Map<String, ColorInfo> colorMap = new HashMap<>(); 185 for(String schemeColorKey : Main.pref.getAllPrefix(prefix).keySet()) {187 for(String schemeColorKey : Preferences.main().getAllPrefix(prefix).keySet()) { 186 188 colorKey = schemeColorKey.substring(prefix.length()); 187 189 colorMap.put(colorKey, ColorInfo.fromPref(Arrays.asList( 188 190 // FIXME: does not work, corrupts the color table ? See #16110 189 Main.pref.get(schemeColorKey), "", "", ""), false));191 Config.getPref().get(schemeColorKey), "", "", ""), false)); 190 192 } 191 193 return colorMap;
Note:
See TracChangeset
for help on using the changeset viewer.