Skip to content

Commit

Permalink
Refresh toolbar after the first layer is loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
maripo committed Nov 7, 2020
1 parent a572fea commit b538f1d
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/org/maripo/josm/easypresets/EasyPresetsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@
import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation;

public class EasyPresetsPlugin extends Plugin implements ListDataListener {
import org.openstreetmap.josm.gui.layer.LayerManager;
import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;

import java.util.Timer;
import java.util.TimerTask;

public class EasyPresetsPlugin extends Plugin implements ListDataListener, LayerChangeListener {
public static final EasyPresets root = new EasyPresets();
public static final GroupPresetMenu groupMenu = new GroupPresetMenu(root);

Expand All @@ -36,11 +45,24 @@ public EasyPresetsPlugin (PluginInformation info) {
// Group for all custom presets
groupMenu.updatePresetListMenu();
menu.add(groupMenu.menu);
TaggingPresetNameTemplateList.getInstance().taggingPresetsModified();
// Call ToolbarPreferences.refreshToolbarControl
MainApplication.getToolbar().refreshToolbarControl();
MainApplication.getLayerManager().addLayerChangeListener(this);
}

@Override
public void layerAdded (LayerAddEvent e) {
TimerTask task = new TimerTask() {
public void run() {
MainApplication.getToolbar().refreshToolbarControl();
}
};
new Timer().schedule(task, 1000);
}
@Override public void layerRemoving(LayerRemoveEvent e) {

}
@Override public void layerOrderChanged(LayerOrderChangeEvent e) {

}
@Override
public void contentsChanged(ListDataEvent arg0) {
TaggingPresetNameTemplateList.getInstance().taggingPresetsModified();
Expand Down

0 comments on commit b538f1d

Please sign in to comment.