Skip to content

Commit

Permalink
Add preference setting
Browse files Browse the repository at this point in the history
  • Loading branch information
simon04 committed Aug 13, 2020
1 parent d4f2ae6 commit fc1a7c1
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import org.openstreetmap.josm.gui.MainApplication;
import org.openstreetmap.josm.gui.MainMenu;
import org.openstreetmap.josm.gui.MapFrame;
import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
import org.openstreetmap.josm.plugins.Plugin;
import org.openstreetmap.josm.plugins.PluginInformation;

Expand All @@ -27,4 +28,9 @@ public AustriaAddressHelperPlugin(PluginInformation info) {
public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {

}

@Override
public PreferenceSetting getPreferenceSetting() {
return new AustriaAddressHelperPreferenceSetting();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package org.openstreetmap.josm.plugins.austriaaddresshelper;

import static org.openstreetmap.josm.tools.I18n.tr;

import java.awt.GridBagLayout;

import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
import org.openstreetmap.josm.gui.preferences.SubPreferenceSetting;
import org.openstreetmap.josm.gui.preferences.TabPreferenceSetting;
import org.openstreetmap.josm.tools.GBC;

public class AustriaAddressHelperPreferenceSetting implements SubPreferenceSetting {

private final JTextField url = new JTextField();
private final JCheckBox checkDuplicates = new JCheckBox(tr("Check existing addresses"));

@Override
public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
return gui.getPluginPreference();
}

@Override
public void addGui(PreferenceTabbedPane gui) {
url.setText(AustriaAddressHelperAction.baseUrl.get());
checkDuplicates.setSelected(AustriaAddressHelperAction.checkDuplicates.get());

final JPanel panel = new JPanel(new GridBagLayout());
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.add(new JLabel(tr("Server URL:")), GBC.eol().fill(GBC.HORIZONTAL));
panel.add(url, GBC.eop().fill(GBC.HORIZONTAL));
panel.add(checkDuplicates, GBC.eop().fill(GBC.HORIZONTAL));
getTabPreferenceSetting(gui).addSubTab(this, tr("Austria Address Helper"), panel);
}

@Override
public boolean ok() {
AustriaAddressHelperAction.baseUrl.put(url.getText());
AustriaAddressHelperAction.checkDuplicates.put(checkDuplicates.isSelected());
return false;
}

@Override
public boolean isExpert() {
return false;
}
}

0 comments on commit fc1a7c1

Please sign in to comment.