Changeset 1191 in josm
- Timestamp:
- 2008-12-30T00:55:23+01:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/preferences/PluginPreference.java
r1188 r1191 6 6 7 7 import java.awt.Dimension; 8 import java.awt.Gr aphics;8 import java.awt.GridBagConstraints; 9 9 import java.awt.GridBagLayout; 10 import java.awt.Insets; 11 import java.awt.Rectangle; 10 12 import java.awt.event.ActionEvent; 11 13 import java.awt.event.ActionListener; … … 28 30 import javax.swing.AbstractAction; 29 31 import javax.swing.BorderFactory; 30 import javax.swing.Box;31 import javax.swing.BoxLayout;32 32 import javax.swing.DefaultListModel; 33 33 import javax.swing.JButton; 34 34 import javax.swing.JCheckBox; 35 import javax.swing.JEditorPane; 35 36 import javax.swing.JLabel; 36 37 import javax.swing.JList; … … 38 39 import javax.swing.JPanel; 39 40 import javax.swing.JScrollPane; 41 import javax.swing.Scrollable; 42 import javax.swing.UIManager; 43 import javax.swing.event.HyperlinkEvent; 44 import javax.swing.event.HyperlinkListener; 45 import javax.swing.event.HyperlinkEvent.EventType; 40 46 41 47 import org.openstreetmap.josm.Main; … … 45 51 import org.openstreetmap.josm.plugins.PluginProxy; 46 52 import org.openstreetmap.josm.tools.GBC; 53 import org.openstreetmap.josm.tools.OpenBrowser; 47 54 import org.openstreetmap.josm.tools.XmlObjectParser.Uniform; 48 55 … … 82 89 private Map<String, PluginDescription> availablePlugins; 83 90 private JPanel plugin; 84 private class MyBox extends Box { 85 int lastwidth; 86 int offset = 40; 87 public MyBox() 88 { 89 super(BoxLayout.Y_AXIS); 90 } 91 public int myGetWidth() 92 { 93 int w = plugin.getWidth()-offset; 94 if(w <= 0) w = 450; 95 lastwidth = w; 96 return w; 97 } 98 public void paint(Graphics g) 99 { 100 if(lastwidth != plugin.getWidth()-offset) 101 refreshPluginPanel(gui); 102 super.paint(g); 103 } 104 } 105 private MyBox pluginPanel = new MyBox(); 91 private JPanel pluginPanel = new NoHorizontalScrollPanel(new GridBagLayout()); 106 92 private PreferenceDialog gui; 93 private JScrollPane pluginPane; 107 94 108 95 public void addGui(final PreferenceDialog gui) { 109 96 this.gui = gui; 110 97 plugin = gui.createPreferenceTab("plugin", tr("Plugins"), tr("Configure available plugins."), false); 111 JScrollPane pluginPane = new JScrollPane(pluginPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);98 pluginPane = new JScrollPane(pluginPanel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 112 99 pluginPane.setBorder(null); 113 100 plugin.add(pluginPane, GBC.eol().fill(GBC.BOTH)); … … 239 226 240 227 pluginPanel.removeAll(); 241 int width = pluginPanel.myGetWidth(); 242 228 229 GridBagConstraints gbc = new GridBagConstraints(); 230 gbc.gridx = 0; 231 gbc.anchor = GridBagConstraints.NORTHWEST; 232 233 int row = 0; 243 234 for (final PluginDescription plugin : availablePlugins.values()) { 244 235 boolean enabled = (enabledPlugins != null) && enabledPlugins.contains(plugin.name); … … 264 255 tr("{0}: Version {1}{2}", plugin.name, remoteversion, localversion), 265 256 pluginMap.get(plugin.name)); 266 pluginPanel.add(pluginCheck); 267 268 pluginCheck.setToolTipText(plugin.resource != null ? "" + plugin.resource : tr("Plugin bundled with JOSM")); 269 JLabel label = new JLabel("<html><i>" + (plugin.description == null ? tr("no description available") : plugin.description) + "</i></html>"); 270 label.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0)); 271 label.setMaximumSize(new Dimension(width, 1000)); 272 pluginPanel.add(label); 273 pluginPanel.add(Box.createVerticalStrut(5)); 257 gbc.gridy = row++; 258 gbc.insets = new Insets(5,5,0,5); 259 gbc.weighty = 0.1; 260 gbc.fill = GridBagConstraints.NONE; 261 pluginPanel.add(pluginCheck, gbc); 262 263 pluginCheck.setToolTipText(plugin.resource != null ? ""+plugin.resource : tr("Plugin bundled with JOSM")); 264 265 JEditorPane description = new JEditorPane(); 266 description.setContentType("text/html"); 267 description.setEditable(false); 268 description.setText("<html><i>"+(plugin.description==null?tr("no description available"):plugin.description)+"</i></html>"); 269 description.setBorder(BorderFactory.createEmptyBorder(0,20,0,0)); 270 description.setBackground(UIManager.getColor("Panel.background")); 271 description.addHyperlinkListener(new HyperlinkListener() { 272 public void hyperlinkUpdate(HyperlinkEvent e) { 273 if(e.getEventType() == EventType.ACTIVATED) { 274 OpenBrowser.displayUrl(e.getURL().toString()); 275 } 276 } 277 }); 278 279 gbc.gridy = row++; 280 gbc.insets = new Insets(3,5,5,5); 281 gbc.weighty = 0.9; 282 gbc.weightx = 1.0; 283 gbc.anchor = GridBagConstraints.WEST; 284 gbc.fill = GridBagConstraints.HORIZONTAL; 285 pluginPanel.add(description, gbc); 274 286 275 287 pluginCheck.addActionListener(new ActionListener(){ … … 382 394 return Main.pref.putCollection("plugins", plugins); 383 395 } 396 397 class NoHorizontalScrollPanel extends JPanel implements Scrollable { 398 public NoHorizontalScrollPanel(GridBagLayout gridBagLayout) { 399 super(gridBagLayout); 400 } 401 402 public Dimension getPreferredScrollableViewportSize() { 403 return super.getPreferredSize(); 404 } 405 406 public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { 407 return 30; 408 } 409 410 public boolean getScrollableTracksViewportHeight() { 411 return false; 412 } 413 414 public boolean getScrollableTracksViewportWidth() { 415 return true; 416 } 417 418 public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { 419 return 10; 420 } 421 } 384 422 }
Note:
See TracChangeset
for help on using the changeset viewer.