Changeset 3894 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2011-02-13T10:30:28+01:00 (14 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/WireframeToggleAction.java
r3083 r3894 68 68 setEnabled(Main.map != null && Main.main.getEditLayer() != null); 69 69 } 70 71 public boolean isSelected() { 72 return selected; 73 } 70 74 } -
trunk/src/org/openstreetmap/josm/gui/MainMenu.java
r3837 r3894 138 138 139 139 /* View menu */ 140 public final WireframeToggleAction wireFrameToggleAction = new WireframeToggleAction(); 140 141 public final JosmAction toggleGPXLines = new ToggleGPXLinesAction(); 141 142 public final InfoAction info = new InfoAction(); … … 272 273 273 274 // -- wireframe toggle action 274 WireframeToggleAction wireFrameToggleAction = new WireframeToggleAction();275 275 final JCheckBoxMenuItem wireframe = new JCheckBoxMenuItem(wireFrameToggleAction); 276 276 viewMenu.add(wireframe); -
trunk/src/org/openstreetmap/josm/gui/dialogs/MapPaintDialog.java
r3882 r3894 9 9 import java.awt.Font; 10 10 import java.awt.GridBagLayout; 11 import java.awt.Insets; 11 12 import java.awt.Point; 12 13 import java.awt.Rectangle; 13 14 import java.awt.event.ActionEvent; 15 import java.awt.event.ActionListener; 14 16 import java.awt.event.KeyEvent; 15 17 import java.awt.event.MouseEvent; … … 26 28 27 29 import javax.swing.AbstractAction; 30 import javax.swing.DefaultButtonModel; 28 31 import javax.swing.DefaultListSelectionModel; 32 import javax.swing.JCheckBox; 29 33 import javax.swing.JFileChooser; 30 34 import javax.swing.JLabel; … … 38 42 import javax.swing.ListSelectionModel; 39 43 import javax.swing.SingleSelectionModel; 44 import javax.swing.SwingConstants; 40 45 import javax.swing.SwingUtilities; 41 46 import javax.swing.UIManager; 47 import javax.swing.border.EmptyBorder; 42 48 import javax.swing.event.ChangeEvent; 43 49 import javax.swing.event.ChangeListener; … … 46 52 import javax.swing.table.AbstractTableModel; 47 53 import javax.swing.table.DefaultTableCellRenderer; 54 import javax.swing.table.TableCellRenderer; 48 55 import javax.swing.table.TableModel; 49 56 … … 72 79 protected OnOffAction onoffAction; 73 80 protected ReloadAction reloadAction; 81 protected MoveUpDownAction upAction; 82 protected MoveUpDownAction downAction; 83 protected JCheckBox cbWireframe; 74 84 75 85 public MapPaintDialog() { … … 84 94 85 95 model = new StylesModel(); 96 97 cbWireframe = new JCheckBox(); 98 JLabel wfLabel = new JLabel(tr("Wireframe View"), ImageProvider.get("dialogs/mappaint", "wireframe_small"), JLabel.HORIZONTAL); 99 wfLabel.setFont(wfLabel.getFont().deriveFont(Font.PLAIN)); 100 101 cbWireframe.setModel(new DefaultButtonModel() { 102 @Override 103 public void setSelected(boolean b) { 104 super.setSelected(b); 105 tblStyles.setEnabled(!b); 106 onoffAction.updateEnabledState(); 107 upAction.updateEnabledState(); 108 downAction.updateEnabledState(); 109 } 110 }); 111 cbWireframe.addActionListener(new ActionListener() { 112 public void actionPerformed(ActionEvent e) { 113 Main.main.menu.wireFrameToggleAction.actionPerformed(null); 114 } 115 }); 116 cbWireframe.setBorder(new EmptyBorder(new Insets(1,1,1,1))); 86 117 87 118 tblStyles = new StylesTable(model); … … 94 125 tblStyles.getColumnModel().getColumn(0).setMaxWidth(1); 95 126 tblStyles.getColumnModel().getColumn(0).setResizable(false); 127 tblStyles.getColumnModel().getColumn(0).setCellRenderer(new MyCheckBoxRenderer()); 96 128 tblStyles.getColumnModel().getColumn(1).setCellRenderer(new StyleSourceRenderer()); 97 129 tblStyles.setShowGrid(false); 98 130 tblStyles.setIntercellSpacing(new Dimension(0, 0)); 99 131 100 pnl.add(new JScrollPane(tblStyles), BorderLayout.CENTER); 132 JPanel p = new JPanel(new GridBagLayout()); 133 p.add(cbWireframe, GBC.std(0, 0)); 134 p.add(wfLabel, GBC.std(1, 0).weight(1, 0)); 135 p.add(tblStyles, GBC.std(0, 1).span(2).fill()); 136 137 pnl.add(new JScrollPane(p), BorderLayout.CENTER); 101 138 102 139 pnl.add(buildButtonRow(), BorderLayout.SOUTH); … … 126 163 reloadAction = new ReloadAction(); 127 164 onoffAction = new OnOffAction(); 128 MoveUpDownAction up= new MoveUpDownAction(false);129 MoveUpDownAction down = new MoveUpDownAction(true);165 upAction = new MoveUpDownAction(false); 166 downAction = new MoveUpDownAction(true); 130 167 selectionModel.addListSelectionListener(onoffAction); 131 168 selectionModel.addListSelectionListener(reloadAction); 132 selectionModel.addListSelectionListener(up );133 selectionModel.addListSelectionListener(down );169 selectionModel.addListSelectionListener(upAction); 170 selectionModel.addListSelectionListener(downAction); 134 171 p.add(new SideButton(onoffAction)); 135 p.add(new SideButton(up ));136 p.add(new SideButton(down ));172 p.add(new SideButton(upAction)); 173 p.add(new SideButton(downAction)); 137 174 p.add(new SideButton(new LaunchMapPaintPreferencesAction())); 138 175 … … 143 180 public void showNotify() { 144 181 MapPaintStyles.addMapPaintSylesUpdateListener(model); 182 Main.main.menu.wireFrameToggleAction.addButtonModel(cbWireframe.getModel()); 145 183 } 146 184 147 185 @Override 148 186 public void hideNotify() { 187 Main.main.menu.wireFrameToggleAction.removeButtonModel(cbWireframe.getModel()); 149 188 MapPaintStyles.removeMapPaintSylesUpdateListener(model); 150 189 } … … 232 271 } 233 272 234 private static class StyleSourceRenderer extends DefaultTableCellRenderer { 273 private class MyCheckBoxRenderer extends JCheckBox implements TableCellRenderer { 274 275 public MyCheckBoxRenderer() { 276 setHorizontalAlignment(SwingConstants.CENTER); 277 setVerticalAlignment(SwingConstants.CENTER); 278 } 279 280 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,int row,int column) { 281 boolean b = (Boolean) value; 282 setSelected(b); 283 setEnabled(!cbWireframe.isSelected()); 284 return this; 285 } 286 } 287 288 private class StyleSourceRenderer extends DefaultTableCellRenderer { 235 289 @Override 236 290 public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { … … 240 294 label.setIcon(s.getIcon()); 241 295 label.setToolTipText(s.getToolTipText()); 296 label.setEnabled(!cbWireframe.isSelected()); 242 297 return label; 243 298 } … … 252 307 253 308 protected void updateEnabledState() { 254 setEnabled( tblStyles.getSelectedRowCount() > 0);309 setEnabled(!cbWireframe.isSelected() && tblStyles.getSelectedRowCount() > 0); 255 310 } 256 311 … … 274 329 * The action to move down the currently selected entries in the list. 275 330 */ 276 class MoveUpDownAction extends AbstractAction implements ListSelectionListener {331 protected class MoveUpDownAction extends AbstractAction implements ListSelectionListener { 277 332 278 333 final int increment; … … 287 342 public void updateEnabledState() { 288 343 int[] sel = tblStyles.getSelectedRows(); 289 setEnabled( MapPaintStyles.canMoveStyles(sel, increment));344 setEnabled(!cbWireframe.isSelected() && MapPaintStyles.canMoveStyles(sel, increment)); 290 345 } 291 346 … … 328 383 putValue(SHORT_DESCRIPTION, tr("reload selected styles from file")); 329 384 putValue(SMALL_ICON, ImageProvider.get("dialogs", "refresh")); 330 updateEnabledState(); 331 } 332 333 protected void updateEnabledState() { 385 setEnabled(getEnabledState()); 386 } 387 388 protected boolean getEnabledState() { 389 if (cbWireframe.isSelected()) 390 return false; 334 391 int[] pos = tblStyles.getSelectedRows(); 335 boolean e = pos.length > 0; 392 if (pos.length == 0) 393 return false; 336 394 for (int i : pos) { 337 if (!model.getRow(i).isLocal()) { 338 e = false; 339 break; 340 } 341 } 342 setEnabled(e); 395 if (!model.getRow(i).isLocal()) 396 return false; 397 } 398 return true; 343 399 } 344 400 345 401 @Override 346 402 public void valueChanged(ListSelectionEvent e) { 347 updateEnabledState();403 setEnabled(getEnabledState()); 348 404 } 349 405 … … 599 655 @Override 600 656 public void launch(MouseEvent evt) { 657 if (cbWireframe.isSelected()) 658 return; 601 659 Point p = evt.getPoint(); 602 660 int index = tblStyles.rowAtPoint(p); -
trunk/src/org/openstreetmap/josm/gui/mappaint/StyleSource.java
r3876 r3894 15 15 16 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 17 import org.openstreetmap.josm.gui.mappaint.MapPaintStyles.IconReference; 17 18 import org.openstreetmap.josm.gui.preferences.SourceEntry; 18 19 import org.openstreetmap.josm.tools.ImageProvider; … … 23 24 public File zipIcons; 24 25 25 public StyleSource(String url, String name, String shortdescription) { 26 super(url, name, shortdescription, true); 26 private ImageIcon imageIcon; 27 28 /****** 29 * The following fields is additional information found in the header 30 * of the source file. 31 */ 32 33 public String icon; 34 35 public StyleSource(String url, String name, String title) { 36 super(url, name, title, true); 27 37 } 28 38 29 39 public StyleSource(SourceEntry entry) { 30 super(entry.url, entry.name, entry. shortdescription, entry.active);40 super(entry.url, entry.name, entry.title, entry.active); 31 41 } 32 42 … … 45 55 } 46 56 47 protected void clearErrors() {57 protected void init() { 48 58 errors.clear(); 59 imageIcon = null; 60 icon = null; 49 61 } 50 62 51 private static ImageIcon pencil; 63 private static ImageIcon defaultIcon; 64 65 private static ImageIcon getDefaultIcon() { 66 if (defaultIcon == null) { 67 defaultIcon = ImageProvider.get("dialogs/mappaint", "pencil"); 68 } 69 return defaultIcon; 70 } 52 71 53 72 protected ImageIcon getSourceIcon() { 54 if (pencil == null) { 55 pencil = ImageProvider.get("dialogs/mappaint", "pencil"); 73 if (imageIcon == null) { 74 if (icon != null) { 75 imageIcon = MapPaintStyles.getIcon(new IconReference(icon, this), false); 76 } 77 if (imageIcon == null) { 78 imageIcon = getDefaultIcon(); 79 } 56 80 } 57 return pencil;81 return imageIcon; 58 82 } 59 83 -
trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSource.java
r3893 r3894 41 41 @Override 42 42 public void loadStyleSource() { 43 init(); 43 44 rules.clear(); 44 clearErrors();45 45 try { 46 46 MapCSSParser parser = new MapCSSParser(getSourceInputStream(), "UTF-8"); … … 100 100 } 101 101 Cascade c = mc.getCascade("default"); 102 String sd = c.get("title", null, String.class); 103 if (sd != null) { 104 this.shortdescription = sd; 102 String pTitle = c.get("title", null, String.class); 103 if (title == null) { 104 title = pTitle; 105 } 106 String pIcon = c.get("icon", null, String.class); 107 if (icon == null) { 108 icon = pIcon; 105 109 } 106 110 } -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSource.java
r3893 r3894 50 50 51 51 protected void init() { 52 clearErrors();52 super.init(); 53 53 icons.clear(); 54 54 lines.clear(); -
trunk/src/org/openstreetmap/josm/gui/mappaint/xml/XmlStyleSourceHandler.java
r3863 r3894 160 160 style.name = atts.getValue("name"); 161 161 } 162 if (style.shortdescription == null) { 163 style.shortdescription = atts.getValue("shortdescription"); 162 if (style.title == null) { 163 style.title = atts.getValue("shortdescription"); 164 } 165 if (style.icon == null) { 166 style.icon = atts.getValue("icon"); 164 167 } 165 168 } -
trunk/src/org/openstreetmap/josm/gui/preferences/MapPaintPreference.java
r3870 r3894 242 242 ExtendedSourceEntry i = new ExtendedSourceEntry("elemstyles.xml", "resource://styles/standard/elemstyles.xml"); 243 243 i.name = "standard"; 244 i. shortdescription = tr("Internal Style");244 i.title = tr("JOSM Internal Style"); 245 245 i.description = tr("Internal style to be used as base for runtime switchable overlay styles"); 246 246 return Collections.singletonList(i); … … 249 249 @Override 250 250 public Collection<String> serialize(SourceEntry entry) { 251 return Arrays.asList(new String[] {entry.url, entry.name, entry. shortdescription, Boolean.toString(entry.active)});251 return Arrays.asList(new String[] {entry.url, entry.name, entry.title, Boolean.toString(entry.active)}); 252 252 } 253 253 -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEditor.java
r3855 r3894 621 621 super(url, null, null, true); 622 622 this.simpleFileName = simpleFileName; 623 version = author = link = description = shortdescription= null;623 version = author = link = description = title = null; 624 624 } 625 625 … … 628 628 */ 629 629 public String getDisplayName() { 630 return shortdescription == null ? simpleFileName : shortdescription;630 return title == null ? simpleFileName : title; 631 631 } 632 632 … … 656 656 protected class EditSourceEntryDialog extends ExtendedDialog { 657 657 658 /** 659 * We call this text field "name", but it is actually the shortdescription. 660 */ 661 private JTextField tfName; 658 private JTextField tfTitle; 662 659 private JTextField tfURL; 663 660 private JCheckBox cbActive; … … 670 667 JPanel p = new JPanel(new GridBagLayout()); 671 668 672 tf Name = new JTextField(60);669 tfTitle = new JTextField(60); 673 670 p.add(new JLabel(tr("Name (optional):")), GBC.std().insets(15, 0, 5, 5)); 674 p.add(tf Name, GBC.eol().insets(0, 0, 5, 5));671 p.add(tfTitle, GBC.eol().insets(0, 0, 5, 5)); 675 672 676 673 tfURL = new JTextField(60); … … 682 679 683 680 if (e != null) { 684 if (e. shortdescription!= null) {685 tf Name.setText(e.shortdescription);681 if (e.title != null) { 682 tfTitle.setText(e.title); 686 683 } 687 684 tfURL.setText(e.url); … … 738 735 } 739 736 740 public String get Shortdescription() {741 return tf Name.getText();737 public String getTitle() { 738 return tfTitle.getText(); 742 739 } 743 740 … … 773 770 activeSourcesModel.addSource(new SourceEntry( 774 771 editEntryDialog.getURL(), 775 null, editEntryDialog.get Shortdescription(), active));772 null, editEntryDialog.getTitle(), active)); 776 773 activeSourcesModel.fireTableDataChanged(); 777 774 } … … 828 825 editEntryDialog.showDialog(); 829 826 if (editEntryDialog.getValue() == 1) { 830 if (e. shortdescription != null || !equal(editEntryDialog.getShortdescription(), "")) {831 e. shortdescription = editEntryDialog.getShortdescription();832 if (equal(e. shortdescription, "")) {833 e. shortdescription= null;827 if (e.title != null || !equal(editEntryDialog.getTitle(), "")) { 828 e.title = editEntryDialog.getTitle(); 829 if (equal(e.title, "")) { 830 e.title = null; 834 831 } 835 832 } … … 1174 1171 } else if ("description".equals(key) && last.description == null) { 1175 1172 last.description = value; 1176 } else if ("shortdescription".equals(key) && last.shortdescription == null) { 1177 last.shortdescription = value; 1173 } else if ((lang + "shortdescription").equals(key) && last.title == null) { 1174 last.title = value; 1175 } else if ("shortdescription".equals(key) && last.title == null) { 1176 last.title = value; 1178 1177 } else if ("name".equals(key) && last.name == null) { 1179 1178 last.name = value; … … 1184 1183 } else if ((lang + "description").equals(key)) { 1185 1184 last.description = value; 1186 } else if ((lang + "shortdescription").equals(key)) {1187 last.shortdescription = value;1188 1185 } 1189 1186 } … … 1222 1219 private String fromSourceEntry(SourceEntry entry) { 1223 1220 StringBuilder s = new StringBuilder("<html><b>"); 1224 if (entry. shortdescription!= null) {1225 s.append(entry. shortdescription).append("</b> (");1221 if (entry.title != null) { 1222 s.append(entry.title).append("</b> ("); 1226 1223 } 1227 1224 s.append(entry.url); 1228 if (entry. shortdescription!= null) {1225 if (entry.title != null) { 1229 1226 s.append(")"); 1230 1227 } -
trunk/src/org/openstreetmap/josm/gui/preferences/SourceEntry.java
r3886 r3894 32 32 33 33 /** 34 * A short descriptionthat can be used as menu entry.34 * A title that can be used as menu entry. 35 35 */ 36 public String shortdescription;36 public String title; 37 37 38 38 /** … … 45 45 this.url = url; 46 46 this.name = equal(name, "") ? null : name; 47 this. shortdescription= equal(shortdescription, "") ? null : shortdescription;47 this.title = equal(shortdescription, "") ? null : shortdescription; 48 48 this.active = active; 49 49 } … … 52 52 this.url = e.url; 53 53 this.name = e.name; 54 this. shortdescription = e.shortdescription;54 this.title = e.title; 55 55 this.active = e.active; 56 56 } … … 63 63 return equal(other.url, url) && 64 64 equal(other.name, name) && 65 equal(other. shortdescription, shortdescription) &&65 equal(other.title, title) && 66 66 other.active == active; 67 67 } … … 72 72 hash = 89 * hash + (this.url != null ? this.url.hashCode() : 0); 73 73 hash = 89 * hash + (this.name != null ? this.name.hashCode() : 0); 74 hash = 89 * hash + (this. shortdescription != null ? this.shortdescription.hashCode() : 0);74 hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); 75 75 hash = 89 * hash + (this.active ? 1 : 0); 76 76 return hash; … … 79 79 @Override 80 80 public String toString() { 81 return shortdescription != null ? shortdescription: url;81 return title != null ? title : url; 82 82 } 83 83 … … 88 88 */ 89 89 public String getDisplayString() { 90 if ( shortdescription!= null)91 return shortdescription;90 if (title != null) 91 return title; 92 92 else 93 93 return getFileNamePart(); -
trunk/src/org/openstreetmap/josm/gui/preferences/TaggingPresetPreference.java
r3885 r3894 329 329 public Collection<ExtendedSourceEntry> getDefault() { 330 330 ExtendedSourceEntry i = new ExtendedSourceEntry("defaultpresets.xml", "resource://data/defaultpresets.xml"); 331 i. shortdescription= tr("Internal Preset");331 i.title = tr("Internal Preset"); 332 332 i.description = tr("The default preset for JOSM"); 333 333 return Collections.singletonList(i); … … 336 336 @Override 337 337 public Collection<String> serialize(SourceEntry entry) { 338 return Arrays.asList(new String[] {entry.url, entry. shortdescription});338 return Arrays.asList(new String[] {entry.url, entry.title}); 339 339 } 340 340 -
trunk/src/org/openstreetmap/josm/tools/GBC.java
r3338 r3894 120 120 return new Box.Filler(new Dimension(x,y), new Dimension(x,y), new Dimension(maxx,maxy)); 121 121 } 122 123 public GBC grid(int x, int y) { 124 gridx = x; 125 gridy = y; 126 return this; 127 } 128 129 public GBC span(int width, int height) { 130 gridwidth = width; 131 gridheight = height; 132 return this; 133 } 134 135 public GBC span(int width) { 136 gridwidth = width; 137 return this; 138 } 139 140 public static GBC std(int x, int y) { 141 GBC c = new GBC(); 142 c.anchor = WEST; 143 c.gridx = x; 144 c.gridy = y; 145 return c; 146 } 147 122 148 }
Note:
See TracChangeset
for help on using the changeset viewer.