kopia lustrzana https://github.com/JOSM/MapWithAI
Initial preferences panel (JComboBox needs to be smaller)
Signed-off-by: Taylor Smock <smocktaylor@gmail.com>pull/1/head v0.0.5
rodzic
a40ffc10a4
commit
1dc9c664e5
|
@ -5,6 +5,7 @@ import javax.swing.JMenu;
|
|||
|
||||
import org.openstreetmap.josm.gui.MainApplication;
|
||||
import org.openstreetmap.josm.gui.MainMenu;
|
||||
import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
|
||||
import org.openstreetmap.josm.plugins.Plugin;
|
||||
import org.openstreetmap.josm.plugins.PluginInformation;
|
||||
import org.openstreetmap.josm.plugins.rapid.backend.RapiDAction;
|
||||
|
@ -14,6 +15,9 @@ import org.openstreetmap.josm.plugins.rapid.backend.RapiDMoveAction;
|
|||
public final class RapiDPlugin extends Plugin {
|
||||
/** The name of the plugin */
|
||||
public static final String NAME = "RapiD";
|
||||
private static String versionInfo;
|
||||
|
||||
private final PreferenceSetting preferences = new RapiDPreferences();
|
||||
|
||||
public RapiDPlugin(PluginInformation info) {
|
||||
super(info);
|
||||
|
@ -23,5 +27,16 @@ public final class RapiDPlugin extends Plugin {
|
|||
MainMenu.add(dataMenu, new RapiDMoveAction(), false);
|
||||
|
||||
RapiDDataUtils.addRapiDPaintStyles();
|
||||
|
||||
versionInfo = info.localversion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PreferenceSetting getPreferenceSetting() {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
public static String getVersionInfo() {
|
||||
return versionInfo;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
package org.openstreetmap.josm.plugins.rapid;
|
||||
|
||||
import static org.openstreetmap.josm.tools.I18n.tr;
|
||||
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.Insets;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
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.plugins.rapid.backend.RapiDDataUtils;
|
||||
|
||||
public class RapiDPreferences implements SubPreferenceSetting {
|
||||
|
||||
private final JLabel rapidApiUrl = new JLabel(tr("RapiD API URL"));
|
||||
private final JComboBox<String> possibleRapidApiUrl = new JComboBox<>();
|
||||
|
||||
@Override
|
||||
public void addGui(PreferenceTabbedPane gui) {
|
||||
final JPanel container = new JPanel(new GridBagLayout());
|
||||
container.setAlignmentY(JPanel.TOP_ALIGNMENT);
|
||||
final GridBagConstraints constraints = new GridBagConstraints();
|
||||
|
||||
for (String url : RapiDDataUtils.getRapiDURLs()) {
|
||||
possibleRapidApiUrl.addItem(url);
|
||||
}
|
||||
|
||||
possibleRapidApiUrl.setEditable(true);
|
||||
possibleRapidApiUrl.setSelectedItem(RapiDDataUtils.getRapiDURL());
|
||||
|
||||
constraints.gridx = 0;
|
||||
constraints.gridy = 0;
|
||||
constraints.weightx = .1;
|
||||
constraints.weighty = 0;
|
||||
constraints.insets = new Insets(5, 10, 5, 10);
|
||||
constraints.anchor = GridBagConstraints.EAST;
|
||||
constraints.fill = GridBagConstraints.HORIZONTAL;
|
||||
container.add(rapidApiUrl, constraints);
|
||||
|
||||
constraints.gridx++;
|
||||
constraints.weightx = 1;
|
||||
container.add(possibleRapidApiUrl, constraints);
|
||||
gui.getMaximumSize().getWidth();
|
||||
|
||||
getTabPreferenceSetting(gui).addSubTab(this, "RapiD", container);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ok() {
|
||||
RapiDDataUtils.setRapiDUrl((String) possibleRapidApiUrl.getSelectedItem());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpert() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabPreferenceSetting getTabPreferenceSetting(PreferenceTabbedPane gui) {
|
||||
return gui.getPluginPreference();
|
||||
}
|
||||
|
||||
}
|
Ładowanie…
Reference in New Issue