Changeset 300 in josm
- Timestamp:
- 2007-08-08T08:49:22+02:00 (17 years ago)
- Location:
- src/org/openstreetmap/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r299 r300 6 6 7 7 import java.awt.Dimension; 8 import java.awt.GridBagLayout; 8 9 import java.awt.event.ActionEvent; 9 10 import java.awt.event.ActionListener; … … 22 23 import java.util.Map.Entry; 23 24 25 import javax.swing.AbstractAction; 24 26 import javax.swing.BorderFactory; 25 27 import javax.swing.Box; 28 import javax.swing.DefaultListModel; 26 29 import javax.swing.JButton; 27 30 import javax.swing.JCheckBox; 28 31 import javax.swing.JLabel; 32 import javax.swing.JList; 29 33 import javax.swing.JOptionPane; 30 34 import javax.swing.JPanel; … … 102 106 configureSites.addActionListener(new ActionListener(){ 103 107 public void actionPerformed(ActionEvent e) { 104 JOptionPane.showMessageDialog(Main.parent, tr("Not implemented yet.")); 105 } 108 configureSites(); 109 } 110 106 111 }); 107 //TODO:plugin.add(configureSites, GBC.std());112 plugin.add(configureSites, GBC.std()); 108 113 109 114 refreshPluginPanel(gui); 115 } 116 117 private void configureSites() { 118 JPanel p = new JPanel(new GridBagLayout()); 119 p.add(new JLabel(tr("Add either site-josm.xml or Wiki Pages.")), GBC.eol()); 120 final DefaultListModel model = new DefaultListModel(); 121 for (String s : PluginDownloader.getSites()) 122 model.addElement(s); 123 final JList list = new JList(model); 124 p.add(new JScrollPane(list), GBC.std().fill()); 125 JPanel buttons = new JPanel(new GridBagLayout()); 126 buttons.add(new JButton(new AbstractAction(tr("Add")){ 127 public void actionPerformed(ActionEvent e) { 128 String s = JOptionPane.showInputDialog(gui, tr("Add either site-josm.xml or Wiki Pages.")); 129 if (s != null) 130 model.addElement(s); 131 } 132 }), GBC.eol().fill(GBC.HORIZONTAL)); 133 buttons.add(new JButton(new AbstractAction(tr("Edit")){ 134 public void actionPerformed(ActionEvent e) { 135 if (list.getSelectedValue() == null) { 136 JOptionPane.showMessageDialog(gui, tr("Please select an entry.")); 137 return; 138 } 139 String s = JOptionPane.showInputDialog(gui, tr("Add either site-josm.xml or Wiki Pages."), list.getSelectedValue()); 140 model.setElementAt(s, list.getSelectedIndex()); 141 } 142 }), GBC.eol().fill(GBC.HORIZONTAL)); 143 buttons.add(new JButton(new AbstractAction(tr("Delete")){ 144 public void actionPerformed(ActionEvent event) { 145 if (list.getSelectedValue() == null) { 146 JOptionPane.showMessageDialog(gui, tr("Please select an entry.")); 147 return; 148 } 149 model.removeElement(list.getSelectedValue()); 150 } 151 }), GBC.eol().fill(GBC.HORIZONTAL)); 152 p.add(buttons, GBC.eol()); 153 int answer = JOptionPane.showConfirmDialog(gui, p, tr("Configure Plugin Sites"), JOptionPane.OK_CANCEL_OPTION); 154 if (answer != JOptionPane.OK_OPTION) 155 return; 156 StringBuilder b = new StringBuilder(); 157 for (int i = 0; i < model.getSize(); ++i) { 158 b.append(model.getElementAt(i)); 159 if (i < model.getSize()-1) 160 b.append(" "); 161 } 162 Main.pref.put("pluginmanager.sites", b.toString()); 110 163 } 111 164 -
src/org/openstreetmap/josm/plugins/PluginDownloader.java
r299 r300 69 69 public static int downloadDescription() { 70 70 int count = 0; 71 for (String site : Main.pref.get("pluginmanager.sites", "http://josm.openstreetmap.de/wiki/Plugins").split(" ")) {71 for (String site : getSites()) { 72 72 try { 73 73 BufferedReader r = new BufferedReader(new InputStreamReader(new URL(site).openStream())); … … 88 88 return count; 89 89 } 90 91 public static String[] getSites() { 92 return Main.pref.get("pluginmanager.sites", "http://josm.openstreetmap.de/wiki/Plugins").split(" "); 93 } 90 94 91 95 private static CharSequence readXml(BufferedReader r) throws IOException {
Note:
See TracChangeset
for help on using the changeset viewer.