Ignore:
Timestamp:
2009-01-01T18:28:53+01:00 (16 years ago)
Author:
stoecker
Message:

removed tab stop usage

Location:
applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme/ColorSchemePlugin.java

    r4278 r12778  
    1414 */
    1515public class ColorSchemePlugin extends Plugin {
    16    
     16
    1717    /**
    1818     * Default Constructor
    1919     */
    2020    public ColorSchemePlugin() {
    21        
     21
    2222    }
    2323
     
    2626        return new ColorSchemePreference();
    2727    }
    28    
    29    
     28
     29
    3030
    3131}
  • applications/editors/josm/plugins/colorscheme/src/at/dallermassl/josm/plugin/colorscheme/ColorSchemePreference.java

    r12588 r12778  
    3636    private static final String PREF_KEY_SCHEMES_NAMES = PREF_KEY_SCHEMES_PREFIX + "names";
    3737    public static final String PREF_KEY_COLOR_PREFIX = "color.";
    38         private JList schemesList;
    39         private DefaultListModel listModel;
    40         private List<String>colorKeys;
    41         private ColorPreference colorPreference;
    42        
    43         /**
    44         * Default Constructor
    45         */
    46         public ColorSchemePreference() {
    47         }
    48        
     38    private JList schemesList;
     39    private DefaultListModel listModel;
     40    private List<String>colorKeys;
     41    private ColorPreference colorPreference;
     42   
     43    /**
     44    * Default Constructor
     45    */
     46    public ColorSchemePreference() {
     47    }
     48   
    4949
    50         /* (non-Javadoc)
    51         * @see org.openstreetmap.josm.gui.preferences.PreferenceSetting#addGui(org.openstreetmap.josm.gui.preferences.PreferenceDialog)
    52         */
    53         public void addGui(final PreferenceDialog gui) {
     50    /* (non-Javadoc)
     51    * @see org.openstreetmap.josm.gui.preferences.PreferenceSetting#addGui(org.openstreetmap.josm.gui.preferences.PreferenceDialog)
     52    */
     53    public void addGui(final PreferenceDialog gui) {
    5454        Map<String, String> colorMap = Main.pref.getAllPrefix(PREF_KEY_COLOR_PREFIX);
    5555        colorKeys = new ArrayList<String>(colorMap.keySet());
    5656        Collections.sort(colorKeys);
    57             listModel = new DefaultListModel();
    58                 schemesList = new JList(listModel);
     57        listModel = new DefaultListModel();
     58        schemesList = new JList(listModel);
    5959        String schemes = Main.pref.get(PREF_KEY_SCHEMES_NAMES);
    6060        StringTokenizer st = new StringTokenizer(schemes, ";");       
     
    7676            }
    7777        });
    78                 JButton addScheme = new JButton(tr("Add"));
    79                 addScheme.addActionListener(new ActionListener(){
    80                         public void actionPerformed(ActionEvent e) {
    81                                 String schemeName = JOptionPane.showInputDialog(Main.parent, tr("Color Scheme"));
    82                                 if (schemeName == null)
    83                                         return;
    84                                 schemeName = schemeName.replaceAll("\\.", "_");
    85                                 setColorScheme(schemeName, getColorPreference().getColorModel());
    86                                 listModel.addElement(schemeName);
     78        JButton addScheme = new JButton(tr("Add"));
     79        addScheme.addActionListener(new ActionListener(){
     80            public void actionPerformed(ActionEvent e) {
     81                String schemeName = JOptionPane.showInputDialog(Main.parent, tr("Color Scheme"));
     82                if (schemeName == null)
     83                    return;
     84                schemeName = schemeName.replaceAll("\\.", "_");
     85                setColorScheme(schemeName, getColorPreference().getColorModel());
     86                listModel.addElement(schemeName);
    8787                saveSchemeNamesToPref();
    88                         }
    89                 });
     88            }
     89        });
    9090
    91                 JButton deleteScheme = new JButton(tr("Delete"));
    92                 deleteScheme.addActionListener(new ActionListener(){
    93                         public void actionPerformed(ActionEvent e) {
    94                                 if (schemesList.getSelectedIndex() == -1)
    95                                         JOptionPane.showMessageDialog(Main.parent, tr("Please select the scheme to delete."));
    96                                 else {
    97                                 String schemeName = (String) listModel.get(schemesList.getSelectedIndex());
    98                                 removeColorSchemeFromPreferences(schemeName);
    99                                     listModel.remove(schemesList.getSelectedIndex());
    100                                     saveSchemeNamesToPref();
    101                                 }
    102                         }
    103                 });
    104                 schemesList.setVisibleRowCount(3);
     91        JButton deleteScheme = new JButton(tr("Delete"));
     92        deleteScheme.addActionListener(new ActionListener(){
     93            public void actionPerformed(ActionEvent e) {
     94                if (schemesList.getSelectedIndex() == -1)
     95                    JOptionPane.showMessageDialog(Main.parent, tr("Please select the scheme to delete."));
     96                else {
     97                    String schemeName = (String) listModel.get(schemesList.getSelectedIndex());
     98                    removeColorSchemeFromPreferences(schemeName);
     99                    listModel.remove(schemesList.getSelectedIndex());
     100                    saveSchemeNamesToPref();
     101                }
     102            }
     103        });
     104        schemesList.setVisibleRowCount(3);
    105105
    106                 //schemesList.setToolTipText(tr("The sources (url or filename) of annotation preset definition files. See http://josm.eigenheimstrasse.de/wiki/AnnotationPresets for help."));
     106        //schemesList.setToolTipText(tr("The sources (url or filename) of annotation preset definition files. See http://josm.eigenheimstrasse.de/wiki/AnnotationPresets for help."));
    107107        useScheme.setToolTipText(tr("Use the selected scheme from the list."));
    108                 addScheme.setToolTipText(tr("Use the current colors as a new color scheme."));
    109                 deleteScheme.setToolTipText(tr("Delete the selected scheme from the list."));
     108        addScheme.setToolTipText(tr("Use the current colors as a new color scheme."));
     109        deleteScheme.setToolTipText(tr("Delete the selected scheme from the list."));
    110110
    111                 gui.map.add(new JLabel(tr("Color Schemes")), GBC.eol().insets(0,5,0,0));
    112                 gui.map.add(new JScrollPane(schemesList), GBC.eol().fill(GBC.BOTH));
    113                 JPanel buttonPanel = new JPanel(new GridBagLayout());
    114                 gui.map.add(buttonPanel, GBC.eol().fill(GBC.HORIZONTAL));
    115                 buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
     111        gui.map.add(new JLabel(tr("Color Schemes")), GBC.eol().insets(0,5,0,0));
     112        gui.map.add(new JScrollPane(schemesList), GBC.eol().fill(GBC.BOTH));
     113        JPanel buttonPanel = new JPanel(new GridBagLayout());
     114        gui.map.add(buttonPanel, GBC.eol().fill(GBC.HORIZONTAL));
     115        buttonPanel.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL));
    116116        buttonPanel.add(useScheme, GBC.std().insets(0,5,5,0));
    117                 buttonPanel.add(addScheme, GBC.std().insets(0,5,5,0));
    118                 buttonPanel.add(deleteScheme, GBC.std().insets(0,5,5,0));
    119         }
    120        
    121         /**
    122         * Saves the names of the schemes to the preferences.
    123         */
    124         public void saveSchemeNamesToPref() {
     117        buttonPanel.add(addScheme, GBC.std().insets(0,5,5,0));
     118        buttonPanel.add(deleteScheme, GBC.std().insets(0,5,5,0));
     119    }
     120   
     121    /**
     122    * Saves the names of the schemes to the preferences.
     123    */
     124    public void saveSchemeNamesToPref() {
    125125        if (schemesList.getModel().getSize() > 0) {
    126126            StringBuilder sb = new StringBuilder();
     
    129129            Main.pref.put(PREF_KEY_SCHEMES_NAMES, sb.toString().substring(1));
    130130        } else
    131             Main.pref.put(PREF_KEY_SCHEMES_NAMES, null);           
    132         }
     131            Main.pref.put(PREF_KEY_SCHEMES_NAMES, null);       
     132    }
    133133
    134         public boolean ok() {
    135             return false;// nothing to do
    136         }
    137        
    138         /**
    139         * Remove all color entries for the given scheme from the preferences.
    140         * @param schemeName the name of the scheme.
    141         */
    142         public void removeColorSchemeFromPreferences(String schemeName) {
     134    public boolean ok() {
     135        return false;// nothing to do
     136    }
     137   
     138    /**
     139    * Remove all color entries for the given scheme from the preferences.
     140    * @param schemeName the name of the scheme.
     141    */
     142    public void removeColorSchemeFromPreferences(String schemeName) {
    143143        // delete color entries for scheme in preferences:
    144144        Map<String, String> colors = Main.pref.getAllPrefix(PREF_KEY_SCHEMES_PREFIX + schemeName + ".");
    145145        for(String key : colors.keySet()) {
    146146            Main.pref.put(key, null);
    147         }          
    148         }
    149        
    150         /**
    151         * Copy all color entries from the given map to entries in preferences with the scheme name.
    152         * @param schemeName the name of the scheme.
    153         * @param the map containing the color key (without prefix) and the html color values.
    154         */
    155         public void setColorScheme(String schemeName, Map<String, String> colorMap) {
    156             String key;
    157             for(String colorKey : colorMap.keySet()) {
    158                 key = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX + colorKey;
    159                 Main.pref.put(key, colorMap.get(colorKey));
    160             }
    161         }
    162        
    163         /**
    164         * Reads all colors for a scheme and returns them in a map (key = color key without prefix,
    165         * value = html color code).
    166         * @param schemeName the name of the scheme.
    167         */
    168         public Map<String, String> getColorMap(String schemeName) {
    169             String colorKey;
    170             String prefix = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX;
    171             Map<String, String>colorMap = new HashMap<String, String>();
    172             for(String schemeColorKey : Main.pref.getAllPrefix(prefix).keySet()) {
    173                 colorKey = schemeColorKey.substring(prefix.length());
    174                 colorMap.put(colorKey, Main.pref.get(schemeColorKey));
    175             }
    176             return colorMap;
    177         }
     147        }      
     148    }
     149   
     150    /**
     151    * Copy all color entries from the given map to entries in preferences with the scheme name.
     152    * @param schemeName the name of the scheme.
     153    * @param the map containing the color key (without prefix) and the html color values.
     154    */
     155    public void setColorScheme(String schemeName, Map<String, String> colorMap) {
     156        String key;
     157        for(String colorKey : colorMap.keySet()) {
     158            key = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX + colorKey;
     159            Main.pref.put(key, colorMap.get(colorKey));
     160        }
     161    }
     162   
     163    /**
     164    * Reads all colors for a scheme and returns them in a map (key = color key without prefix,
     165    * value = html color code).
     166    * @param schemeName the name of the scheme.
     167    */
     168    public Map<String, String> getColorMap(String schemeName) {
     169        String colorKey;
     170        String prefix = PREF_KEY_SCHEMES_PREFIX + schemeName + "." + PREF_KEY_COLOR_PREFIX;
     171        Map<String, String>colorMap = new HashMap<String, String>();
     172        for(String schemeColorKey : Main.pref.getAllPrefix(prefix).keySet()) {
     173            colorKey = schemeColorKey.substring(prefix.length());
     174            colorMap.put(colorKey, Main.pref.get(schemeColorKey));
     175        }
     176        return colorMap;
     177    }
    178178
    179179    public ColorPreference getColorPreference() {
Note: See TracChangeset for help on using the changeset viewer.