Ignore:
Timestamp:
2011-02-02T23:03:00+01:00 (13 years ago)
Author:
bastiK
Message:

Experimental mapcss support. All *.java files in the gui/mappaint/mapcss/parser folder are generated from the javacc source file MapCSSParser.jj in the same folder. The generated code sums up to 2700 lines, there is no further build dependency.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java

    r3843 r3848  
    77import java.awt.Dimension;
    88import java.awt.Point;
    9 import java.awt.Rectangle;
    109import java.awt.event.ActionEvent;
    1110import java.awt.event.KeyEvent;
     
    2221import javax.swing.JTable;
    2322import javax.swing.ListSelectionModel;
     23import javax.swing.SwingUtilities;
    2424import javax.swing.UIManager;
    2525import javax.swing.event.ListSelectionEvent;
     
    2929import org.openstreetmap.josm.Main;
    3030import org.openstreetmap.josm.gui.SideButton;
    31 import org.openstreetmap.josm.gui.mappaint.ElemStyles;
    3231import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     32import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.MapPaintStyleLoader;
    3333import org.openstreetmap.josm.gui.mappaint.StyleSource;
    3434import org.openstreetmap.josm.gui.widgets.PopupMenuLauncher;
     
    151151                model.fireTableDataChanged();
    152152            }
    153             ElemStyles.cacheIdx++;
     153            MapPaintStyles.getStyles().clearCached();
    154154            Main.map.mapView.preferenceChanged(null);
    155155            Main.map.mapView.repaint();
     
    207207        @Override
    208208        public void actionPerformed(ActionEvent e) {
    209             int[] pos = tblStyles.getSelectedRows();
    210             for (int p : pos) {
    211                 StyleSource s = model.data.get(p);
    212                 s.loadStyleSource();
    213             }
    214             ElemStyles.cacheIdx++;
    215             Main.map.mapView.preferenceChanged(null);
    216             Main.map.mapView.repaint();
    217         }
    218     }
    219 
     209
     210            final int[] rows = tblStyles.getSelectedRows();
     211            List<StyleSource> sources = new ArrayList<StyleSource>();
     212            for (int p : rows) {
     213                sources.add(model.data.get(p));
     214            }
     215            Main.worker.submit(new MapPaintStyleLoader(sources));
     216            Main.worker.submit(new Runnable() {
     217                @Override
     218                public void run() {
     219                    SwingUtilities.invokeLater(new Runnable() {
     220                        @Override
     221                        public void run() {
     222                            if (rows.length == 1) {
     223                                model.fireTableCellUpdated(rows[0], 1);
     224                            } else {
     225                                model.fireTableDataChanged();
     226                            }
     227                            MapPaintStyles.getStyles().clearCached();
     228                            Main.map.mapView.preferenceChanged(null);
     229                            Main.map.mapView.repaint();
     230                        }
     231                    });
     232                }
     233            });
     234        }
     235    }
     236   
    220237    class PopupMenuHandler extends PopupMenuLauncher {
    221238        @Override
Note: See TracChangeset for help on using the changeset viewer.