Changeset 20058 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-02-18T13:37:21+01:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/tageditor
- Files:
-
- 4 added
- 1 deleted
- 21 edited
- 2 copied
- 9 moved
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/tageditor/build.xml
r19587 r20058 28 28 29 29 30 <property name="commit.message" value=" Fixed NPE when icon is missing" />31 <property name="plugin.main.version" value=" 2830" />30 <property name="commit.message" value="Tageditor plugin cleaned up" /> 31 <property name="plugin.main.version" value="3015" /> 32 32 33 33 <!-- -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/LaunchAction.java
r15319 r20058 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.Component;6 import java.awt.Dimension;7 import java.awt.GraphicsConfiguration;8 import java.awt.Point;9 import java.awt.Rectangle;10 import java.awt.Window;11 5 import java.awt.event.ActionEvent; 12 6 import java.awt.event.KeyEvent; … … 25 19 import org.openstreetmap.josm.tools.Shortcut; 26 20 27 @SuppressWarnings("serial")28 21 public class LaunchAction extends JosmAction implements SelectionChangedListener { 29 22 … … 68 61 ); 69 62 70 71 // register as dataset selection listener72 //73 63 DataSet.selListeners.add(this); 74 75 // insert a menu item76 //77 64 registerAsMenuItem(); 78 79 // initially not enabled; becomes enabled when the selection becomes non-empty80 //81 65 setEnabled(false); 82 83 }84 85 /**86 *87 * @return the top window of the JOSM GUI; can be null88 */89 protected Window getTopWindow() {90 if (Main.contentPane == null)91 return null;92 Component c = Main.contentPane;93 while(c.getParent() != null) {94 c = c.getParent();95 }96 if (c instanceof Window)97 return (Window)c;98 else99 return null;100 }101 102 /**103 * tries to center the tag editor dialog on the top window or, alternatively,104 * on the screen105 *106 * @param dialog the dialog to be placed on the screen107 */108 protected void placeDialogOnScreen(TagEditorDialog dialog) {109 Window w = getTopWindow();110 if (w == null)111 // don't center112 return;113 114 GraphicsConfiguration gc = w.getGraphicsConfiguration();115 Rectangle screenBounds = null;116 if (gc != null) {117 screenBounds = gc.getBounds();118 }119 Rectangle winBounds = w.getBounds();120 Dimension d = dialog.getPreferredSize();121 122 Point p = new Point();123 if (d.width <= winBounds.width && d.height <= winBounds.height) {124 p.x = winBounds.x + ((winBounds.width - d.width)/2 );125 p.y = winBounds.y + ((winBounds.height - d.height)/2 );126 } else {127 p.x = screenBounds.x + ((screenBounds.width - d.width)/2 );128 p.y = screenBounds.y + ((screenBounds.height - d.height)/2 );129 }130 131 dialog.setLocation(p);132 133 66 } 134 67 … … 140 73 return; 141 74 TagEditorDialog dialog = TagEditorDialog.getInstance(); 142 placeDialogOnScreen(dialog);143 75 dialog.startEditSession(); 144 76 dialog.setVisible(true); … … 152 84 setEnabled(newSelection != null && newSelection.size() >0); 153 85 } 154 155 156 157 158 86 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/TagEditorDialog.java
r20044 r20058 14 14 import java.beans.PropertyChangeEvent; 15 15 import java.beans.PropertyChangeListener; 16 import java.util.Collection;17 16 import java.util.logging.Logger; 18 17 … … 43 42 import org.openstreetmap.josm.plugins.tageditor.tagspec.ui.ITagSelectorListener; 44 43 import org.openstreetmap.josm.plugins.tageditor.tagspec.ui.TabularTagSelector; 44 import org.openstreetmap.josm.tools.ImageProvider; 45 import org.openstreetmap.josm.tools.WindowGeometry; 45 46 /** 46 47 * The dialog for editing name/value-pairs (aka <em>tags</em>) associated with {@link OsmPrimitive}s. 47 48 * 48 *49 49 */ 50 50 @SuppressWarnings("serial") 51 51 public class TagEditorDialog extends JDialog { 52 53 static private Logger logger = Logger.getLogger(TagEditorDialog.class.getName()); 52 static private final Logger logger = Logger.getLogger(TagEditorDialog.class.getName()); 54 53 55 54 /** the unique instance */ 56 static pr otectedTagEditorDialog instance = null;55 static private TagEditorDialog instance = null; 57 56 58 57 /** … … 68 67 } 69 68 70 71 /** 72 * default preferred size 73 */ 69 /** default preferred size */ 74 70 static public final Dimension PREFERRED_SIZE = new Dimension(700, 500); 75 76 71 77 72 /** the properties table */ 78 73 private TagEditor tagEditor = null; 79 private TagEditorModel model = null;80 74 81 75 /** the auto completion list viewer */ … … 85 79 private AutoCompletionCache acCache = null; 86 80 87 /** widgets */88 private JButton btnOK = null;89 private JButton btnCancel = null;90 private JButton btnAdd = null;91 private JButton btnDelete = null;92 81 private OKAction okAction = null; 93 82 private CancelAction cancelAction = null; 94 83 95 96 public OKAction getOKAction() {97 return okAction;98 }99 100 84 /** 101 85 * @return the tag editor model 102 86 */ 103 87 public TagEditorModel getModel() { 104 return model; 105 } 106 107 88 return tagEditor.getModel(); 89 } 108 90 109 91 protected JPanel buildButtonRow() { 110 // create the rows of action buttons at the bottom 111 // of the dialog 112 // 113 JPanel pnl = new JPanel(); 114 pnl.setLayout(new FlowLayout(FlowLayout.RIGHT)); 115 92 JPanel pnl = new JPanel(new FlowLayout(FlowLayout.CENTER)); 93 116 94 // the ok button 117 95 // 118 okAction = new OKAction(); 119 btnOK = new JButton(okAction); 96 pnl.add(new JButton(okAction = new OKAction())); 120 97 getModel().addPropertyChangeListener(okAction); 121 98 122 99 // the cancel button 123 100 // 124 cancelAction = new CancelAction(); 125 btnCancel = new JButton(cancelAction); 126 pnl.add(btnOK); 127 pnl.add(btnCancel); 128 129 JPanel pnl1 = new JPanel(); 130 pnl.setLayout(new FlowLayout(FlowLayout.LEFT)); 131 132 // the add button 133 // 134 btnAdd = new JButton(tagEditor.getAddAction()); 135 btnDelete = new JButton(tagEditor.getDeleteAction()); 136 137 pnl1.add(btnAdd); 138 pnl1.add(btnDelete); 139 140 JPanel pnl2 = new JPanel(); 141 pnl2.setLayout(new BorderLayout()); 142 pnl2.add(pnl1, BorderLayout.WEST); 143 pnl2.add(pnl, BorderLayout.EAST); 144 145 return pnl2; 146 } 147 148 /** 149 * build the GUI 150 */ 151 protected void build() { 152 getContentPane().setLayout(new BorderLayout()); 153 154 // basic UI prpoperties 155 // 156 setModal(true); 157 setSize(PREFERRED_SIZE); 158 setTitle(tr("JOSM Tag Editor Plugin")); 159 160 101 pnl.add(new JButton(cancelAction = new CancelAction())); 102 return pnl; 103 } 104 105 protected JPanel buildTagGridPanel() { 161 106 // create tag editor and inject an instance of the tag 162 107 // editor model 163 108 // 164 109 tagEditor = new TagEditor(); 165 tagEditor.setTagEditorModel(model); 166 167 110 168 111 // create the auto completion list viewer and connect it 169 112 // to the tag editor … … 174 117 tagEditor.setAutoCompletionCache(acCache); 175 118 aclViewer.addAutoCompletionListListener(tagEditor); 119 tagEditor.addComponentNotStoppingCellEditing(aclViewer); 176 120 177 121 JPanel pnlTagGrid = new JPanel(); 178 122 pnlTagGrid.setLayout(new BorderLayout()); 123 124 179 125 pnlTagGrid.add(tagEditor, BorderLayout.CENTER); 180 126 pnlTagGrid.add(aclViewer, BorderLayout.EAST); 181 127 pnlTagGrid.setBorder(BorderFactory.createEmptyBorder(5, 0,0,0)); 182 128 129 JSplitPane splitPane = new JSplitPane( 130 JSplitPane.HORIZONTAL_SPLIT, 131 tagEditor, 132 aclViewer 133 ); 134 splitPane.setOneTouchExpandable(false); 135 splitPane.setDividerLocation(600); 136 pnlTagGrid.add(splitPane, BorderLayout.CENTER); 137 return pnlTagGrid; 138 } 139 140 /** 141 * build the GUI 142 */ 143 protected void build() { 144 getContentPane().setLayout(new BorderLayout()); 145 146 // basic UI prpoperties 147 // 148 setModal(true); 149 setSize(PREFERRED_SIZE); 150 setTitle(tr("JOSM Tag Editor Plugin")); 151 152 JPanel pnlTagGrid = buildTagGridPanel(); 183 153 184 154 // create the preset selector … … 189 159 public void itemSelected(Item item) { 190 160 tagEditor.stopEditing(); 191 model.applyPreset(item);161 tagEditor.getModel().applyPreset(item); 192 162 tagEditor.requestFocusInTopLeftCell(); 193 163 } 194 164 } 195 165 ); 196 197 166 198 167 JPanel pnlPresetSelector = new JPanel(); … … 208 177 public void itemSelected(KeyValuePair pair) { 209 178 tagEditor.stopEditing(); 210 model.applyKeyValuePair(pair);179 tagEditor.getModel().applyKeyValuePair(pair); 211 180 tagEditor.requestFocusInTopLeftCell(); 212 181 } … … 218 187 pnlTagSelector.setBorder(BorderFactory.createEmptyBorder(0,0,5,0 )); 219 188 220 221 222 223 189 // create the tabbed pane 224 190 // … … 227 193 tabbedPane.add(pnlTagSelector, tr("Tags")); 228 194 195 229 196 // create split pane 230 197 // 231 JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, 232 tabbedPane, pnlTagGrid); 198 JSplitPane splitPane = new JSplitPane( 199 JSplitPane.VERTICAL_SPLIT, 200 tabbedPane, 201 pnlTagGrid 202 ); 233 203 splitPane.setOneTouchExpandable(true); 234 204 splitPane.setDividerLocation(200); … … 258 228 ); 259 229 260 261 230 // makes sure that 'Ctrl-Enter' in the properties table 262 231 // and in the aclViewer is handled by okAction … … 279 248 } 280 249 281 282 283 250 /** 284 251 * constructor 285 252 */ 286 253 protected TagEditorDialog() { 287 acCache = new AutoCompletionCache(); 288 model = new TagEditorModel(); 254 acCache = new AutoCompletionCache(); 289 255 build(); 290 256 } 291 257 292 293 @Override 294 public Dimension getPreferredSize() { 295 return PREFERRED_SIZE; 296 } 297 298 258 @Override 259 public void setVisible(boolean visible) { 260 if (visible) { 261 new WindowGeometry( 262 getClass().getName() + ".geometry", 263 WindowGeometry.centerInWindow( 264 Main.parent, 265 PREFERRED_SIZE 266 ) 267 ).applySafe(this); 268 } else if (!visible && isShowing()){ 269 new WindowGeometry(this).remember(getClass().getName() + ".geometry"); 270 } 271 super.setVisible(visible); 272 } 299 273 300 274 /** … … 304 278 */ 305 279 public void startEditSession() { 306 model.clearAppliedPresets();307 model.initFromJOSMSelection();280 tagEditor.getModel().clearAppliedPresets(); 281 tagEditor.getModel().initFromJOSMSelection(); 308 282 //acCache.initFromJOSMDataset(); 309 283 getModel().ensureOneTag(); 310 284 } 311 285 312 313 314 @SuppressWarnings("serial")315 286 class CancelAction extends AbstractAction { 316 317 287 public CancelAction() { 318 putValue(Action.NAME, tr("Cancel")); 319 putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0)); 288 putValue(NAME, tr("Cancel")); 289 putValue(SMALL_ICON, ImageProvider.get("cancel")); 290 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE,0)); 291 putValue(SHORT_DESCRIPTION, tr("Abort tag editing and close dialog")); 320 292 } 321 293 … … 325 297 } 326 298 327 328 329 @SuppressWarnings("serial")330 299 class OKAction extends AbstractAction implements PropertyChangeListener { 331 300 332 301 public OKAction() { 333 putValue(Action.NAME, tr("OK")); 334 putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("ctrl ENTER")); 302 putValue(NAME, tr("OK")); 303 putValue(SMALL_ICON, ImageProvider.get("ok")); 304 putValue(SHORT_DESCRIPTION, tr("Apply edited tags and close dialog")); 305 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("ctrl ENTER")); 335 306 } 336 307 … … 342 313 tagEditor.stopEditing(); 343 314 setVisible(false); 344 model.updateJOSMSelection();315 tagEditor.getModel().updateJOSMSelection(); 345 316 DataSet ds = Main.main.getCurrentDataSet(); 346 317 ds.fireSelectionChanged(); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionContext.java
r20045 r20058 2 2 3 3 import org.openstreetmap.josm.Main; 4 5 4 6 5 public class AutoCompletionContext { … … 20 19 selectionEmpty = (Main.main.getCurrentDataSet().getSelected().size() == 0); 21 20 } 22 23 21 24 22 public boolean isSelectionEmpty() { … … 49 47 this.selectionIncludesRelations = selectionIncludesRelations; 50 48 } 51 52 53 54 55 49 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListRenderer.java
r15319 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.ac; 2 2 3 import java.awt.Color;4 3 import java.awt.Component; 4 import java.awt.Font; 5 import java.net.URL; 5 6 6 7 import javax.swing.Icon; … … 8 9 import javax.swing.JLabel; 9 10 import javax.swing.JTable; 11 import javax.swing.UIManager; 10 12 import javax.swing.table.TableCellRenderer; 13 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 14 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; 15 import static org.openstreetmap.josm.tools.I18n.tr; 11 16 12 17 /** 13 18 * This is the table cell renderer for the list of auto completion list items. 14 19 * 15 * It uses an instance of {@Link JLabel} to render an {@link AutoCompletionListItem}.16 *17 *18 20 */ 19 public class AutoCompletionListRenderer implements TableCellRenderer { 20 21 public class AutoCompletionListRenderer extends JLabel implements TableCellRenderer { 21 22 22 23 static public final String RES_OSM_ICON = "/resources/osm.gif"; 23 24 static public final String RES_SELECTION_ICON = "/resources/selection.gif"; 24 public static final Color BG_COLOR_SELECTED = new Color(143,170,255);25 26 /** the renderer component */27 private final JLabel renderer;28 25 29 26 /** the icon used to decorate items of priority … … 41 38 */ 42 39 public AutoCompletionListRenderer() { 43 renderer = new JLabel(); 44 renderer.setOpaque(true); 45 40 setOpaque(true); 46 41 loadIcons(); 47 42 } … … 51 46 */ 52 47 protected void loadIcons() { 53 java.net.URL imgURL = getClass().getResource(RES_OSM_ICON);48 URL imgURL = getClass().getResource(RES_OSM_ICON); 54 49 if (imgURL != null) { 55 50 iconStandard = new ImageIcon(imgURL); … … 68 63 } 69 64 70 71 65 /** 72 66 * prepares the renderer for rendering a specific icon … … 77 71 if (item.getPriority().equals(AutoCompletionItemPritority.IS_IN_STANDARD)) { 78 72 if (iconStandard != null) { 79 renderer.setIcon(iconStandard);73 setIcon(iconStandard); 80 74 } 81 75 } else if (item.getPriority().equals(AutoCompletionItemPritority.IS_IN_SELECTION)) { 82 76 if (iconSelection != null) { 83 renderer.setIcon(iconSelection);77 setIcon(iconSelection); 84 78 } 85 79 } … … 90 84 */ 91 85 protected void resetRenderer() { 92 renderer.setIcon(null); 93 renderer.setText(""); 94 renderer.setOpaque(true); 95 renderer.setBackground(Color.WHITE); 96 renderer.setForeground(Color.BLACK); 86 setIcon(null); 87 setText(""); 88 setFont(UIManager.getFont("Table.font")); 89 setOpaque(true); 90 setBackground(UIManager.getColor("Table.background")); 91 setForeground(UIManager.getColor("Table.foreground")); 97 92 } 98 93 … … 101 96 */ 102 97 protected void renderSelected() { 103 renderer.setBackground(BG_COLOR_SELECTED);104 renderer.setForeground(Color.WHITE);98 setBackground(UIManager.getColor("Table.selectionBackground")); 99 setForeground(UIManager.getColor("Table.selectionForeground")); 105 100 } 106 101 … … 114 109 AutoCompletionListItem item = (AutoCompletionListItem)value; 115 110 prepareRendererIcon(item); 116 renderer.setText(item.getValue()); 111 setText(item.getValue()); 112 setToolTipText(item.getValue()); 117 113 } else if (value != null) { 118 renderer.setText(value.toString()); 114 setText(value.toString()); 115 setToolTipText(value.toString()); 119 116 } else { 120 renderer.setText("<null>"); 117 setText(tr("unknown")); 118 setFont(getFont().deriveFont(Font.ITALIC)); 121 119 } 122 120 … … 126 124 renderSelected(); 127 125 } 128 129 130 return renderer; 131 126 return this; 132 127 } 133 134 135 136 128 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/ac/AutoCompletionListViewer.java
r20044 r20058 41 41 setLayout(new BorderLayout()); 42 42 43 44 43 table = new JTable(); 45 44 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetItemListCellRenderer.java
r15319 r20058 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.awt.Color;6 5 import java.awt.Component; 7 import java.awt.Font;8 6 import java.util.logging.Logger; 9 7 … … 11 9 import javax.swing.JList; 12 10 import javax.swing.ListCellRenderer; 11 import javax.swing.UIManager; 13 12 14 13 import org.openstreetmap.josm.plugins.tageditor.preset.Item; 15 14 16 public class PresetItemListCellRenderer extends JLabel implements 17 ListCellRenderer { 18 15 public class PresetItemListCellRenderer extends JLabel implements ListCellRenderer { 19 16 private static final Logger logger = Logger.getLogger(PresetItemListCellRenderer.class.getName()); 20 private static final Font DEFAULT_FONT = new Font("SansSerif",Font.PLAIN,10);21 public static final Color BG_COLOR_SELECTED = new Color(143,170,255);22 17 23 18 public Component getListCellRendererComponent(JList list, Object value, … … 30 25 } else { 31 26 if (isSelected) { 32 setBackground(BG_COLOR_SELECTED); 27 setBackground(UIManager.getColor("Table.selectionBackground")); 28 setForeground(UIManager.getColor("Table.selectionForeground")); 33 29 } else { 34 setBackground(Color.WHITE); 30 setBackground(UIManager.getColor("Table.background")); 31 setForeground(UIManager.getColor("Table.foreground")); 35 32 } 36 33 setIcon(item.getIcon()); … … 41 38 setText(sb.toString()); 42 39 setOpaque(true); 43 setFont( DEFAULT_FONT);40 setFont(UIManager.getFont("Table.font")); 44 41 } 45 42 return this; 46 43 } 47 48 44 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/PresetManager.java
r15319 r20058 19 19 public class PresetManager extends JPanel { 20 20 21 static private Logger logger = Logger.getLogger(PresetManager.class.getName());21 static private final Logger logger = Logger.getLogger(PresetManager.class.getName()); 22 22 23 23 private JComboBox presets; … … 99 99 this.model = model; 100 100 } 101 102 103 104 101 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TableCellRenderer.java
r20045 r20058 9 9 import java.util.logging.Logger; 10 10 11 import javax.swing.BorderFactory;12 import javax.swing.ImageIcon;13 11 import javax.swing.JLabel; 14 12 import javax.swing.JTable; 15 import javax.swing. border.Border;13 import javax.swing.UIManager; 16 14 import javax.swing.border.EmptyBorder; 17 15 16 import org.openstreetmap.josm.gui.tagging.TagModel; 18 17 import org.openstreetmap.josm.plugins.tageditor.preset.Item; 19 18 import org.openstreetmap.josm.plugins.tageditor.preset.Tag; … … 29 28 30 29 private static Logger logger = Logger.getLogger(TableCellRenderer.class.getName()); 31 32 public static final Color BG_COLOR_SELECTED = new Color(143,170,255);33 30 public static final Color BG_COLOR_HIGHLIGHTED = new Color(255,255,204); 34 35 public static final Border BORDER_EMPHASIZED = BorderFactory.createLineBorder(new Color(253,75,45)); 36 37 /** the icon displayed for deleting a tag */ 38 private ImageIcon deleteIcon = null; 39 31 40 32 private Font fontStandard = null; 41 33 private Font fontItalic = null; … … 70 62 setText(tag.getValues().get(0)); 71 63 } else if (tag.getValueCount() > 1) { 72 setText(tr(" <multiple>"));64 setText(tr("multiple")); 73 65 setFont(fontItalic); 74 66 } 75 67 } 76 77 78 68 79 69 /** … … 121 111 } 122 112 123 124 113 /** 125 114 * renders the background color. The default color is white. It is … … 132 121 */ 133 122 protected void renderBackgroundColor(TagModel tagModel, TagEditorModel model) { 134 setBackground( Color.WHITE); // standard color123 setBackground(UIManager.getColor("Table.background")); 135 124 if (belongsToSelectedPreset(tagModel, model)) { 136 125 setBackground(BG_COLOR_HIGHLIGHTED); 137 126 } 138 127 } 139 140 141 128 142 129 /** … … 154 141 public Component getTableCellRendererComponent(JTable table, Object value, 155 142 boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { 143 156 144 resetRenderer(); 157 145 … … 159 147 // 160 148 if (isSelected){ 161 setBackground(BG_COLOR_SELECTED); 149 setBackground(UIManager.getColor("Table.selectionBackground")); 150 setForeground(UIManager.getColor("Table.selectionForeground")); 162 151 } else { 163 renderBackgroundColor(getModel(table).get(rowIndex), getModel(table)); 152 setBackground(UIManager.getColor("Table.background")); 153 setForeground(UIManager.getColor("Table.foreground")); 164 154 } 165 166 155 156 TagModel tagModel = (TagModel)value; 167 157 switch(vColIndex) { 168 case 0: renderTagName((TagModel)value); break; 169 case 1: renderTagValue((TagModel)value); break; 170 171 default: throw new RuntimeException("unexpected index in switch statement"); 158 case 0: renderTagName(tagModel); break; 159 case 1: renderTagValue(tagModel); break; 172 160 } 161 renderBackgroundColor(tagModel, (TagEditorModel)table.getModel()); 173 162 if (hasFocus && isSelected) { 174 163 if (table.getSelectedColumnCount() == 1 && table.getSelectedRowCount() == 1) { 175 boolean success = table.editCellAt(rowIndex, vColIndex);176 177 164 if (table.getEditorComponent() != null) { 178 165 table.getEditorComponent().requestFocusInWindow(); … … 182 169 return this; 183 170 } 184 185 186 171 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/TagEditor.java
r20044 r20058 2 2 3 3 import java.awt.BorderLayout; 4 import java.awt.Component; 5 import java.awt.GridBagConstraints; 6 import java.awt.GridBagLayout; 7 import java.awt.Insets; 4 8 import java.util.logging.Logger; 5 9 10 import javax.swing.BoxLayout; 11 import javax.swing.DefaultListSelectionModel; 12 import javax.swing.JButton; 6 13 import javax.swing.JPanel; 7 14 import javax.swing.JScrollPane; 8 import javax.swing.ScrollPaneConstants; 9 10 import org.openstreetmap.josm.gui.dialogs.relation.RunnableAction; 15 import javax.swing.table.TableCellEditor; 16 11 17 import org.openstreetmap.josm.gui.tagging.TagTable; 12 18 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionCache; … … 52 58 private static final Logger logger = Logger.getLogger(TagEditor.class.getName()); 53 59 54 private finalTagEditorModel tagEditorModel;60 private TagEditorModel tagEditorModel; 55 61 private TagTable tblTagEditor; 56 62 private PresetManager presetManager; 57 private AutoCompletionList autoCompletionList; 58 59 63 64 /** 65 * builds the panel with the button row 66 * 67 * @return the panel 68 */ 69 protected JPanel buildButtonsPanel() { 70 JPanel pnl = new JPanel(); 71 pnl.setLayout(new BoxLayout(pnl, BoxLayout.Y_AXIS)); 72 73 // add action 74 JButton btn; 75 pnl.add(btn = new JButton(tblTagEditor.getAddAction())); 76 btn.setMargin(new Insets(0,0,0,0)); 77 tblTagEditor.addComponentNotStoppingCellEditing(btn); 78 79 // delete action 80 pnl.add(btn = new JButton(tblTagEditor.getDeleteAction())); 81 btn.setMargin(new Insets(0,0,0,0)); 82 tblTagEditor.addComponentNotStoppingCellEditing(btn); 83 return pnl; 84 } 85 86 public void addComponentNotStoppingCellEditing(Component c) { 87 tblTagEditor.addComponentNotStoppingCellEditing(c); 88 } 89 90 /** 91 * builds the GUI 92 */ 93 protected JPanel buildTagEditorPanel() { 94 JPanel pnl = new JPanel(new GridBagLayout()); 95 96 DefaultListSelectionModel rowSelectionModel = new DefaultListSelectionModel(); 97 DefaultListSelectionModel colSelectionModel = new DefaultListSelectionModel(); 98 99 tagEditorModel = new TagEditorModel(rowSelectionModel,colSelectionModel); 100 101 // build the scrollable table for editing tag names and tag values 102 // 103 tblTagEditor = new TagTable(tagEditorModel, rowSelectionModel, colSelectionModel); 104 tblTagEditor.setTagCellEditor(new TagSpecificationAwareTagCellEditor()); 105 TableCellRenderer renderer = new TableCellRenderer(); 106 tblTagEditor.getColumnModel().getColumn(0).setCellRenderer(renderer); 107 tblTagEditor.getColumnModel().getColumn(1).setCellRenderer(renderer); 108 109 final JScrollPane scrollPane = new JScrollPane(tblTagEditor); 110 JPanel pnlTagTable = new JPanel(new BorderLayout()); 111 pnlTagTable.add(scrollPane, BorderLayout.CENTER); 112 113 GridBagConstraints gc = new GridBagConstraints(); 114 115 // -- buttons panel 116 // 117 gc.fill = GridBagConstraints.VERTICAL; 118 gc.weightx = 0.0; 119 gc.weighty = 1.0; 120 gc.anchor = GridBagConstraints.NORTHWEST; 121 pnl.add(buildButtonsPanel(),gc); 122 123 // -- the panel with the editor table 124 // 125 gc.gridx = 1; 126 gc.fill = GridBagConstraints.BOTH; 127 gc.weightx = 1.0; 128 gc.weighty = 1.0; 129 gc.anchor = GridBagConstraints.CENTER; 130 pnl.add(pnlTagTable,gc); 131 132 return pnl; 133 } 134 60 135 /** 61 136 * builds the GUI … … 64 139 protected void build() { 65 140 setLayout(new BorderLayout()); 66 67 // build the scrollable table for editing tag names and tag values 68 // 69 tblTagEditor = new TagTable(tagEditorModel); 70 final JScrollPane scrollPane = new JScrollPane(tblTagEditor); 71 scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); 72 scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); 73 add(scrollPane, BorderLayout.CENTER); 74 75 // this adapters ensures that the width of the tag table columns is adjusted 76 // to the width of the scroll pane viewport. Also tried to overwrite 77 // getPreferredViewportSize() in JTable, but did not work. 78 // 79 // scrollPane.addComponentListener( 80 // new ComponentAdapter() { 81 // @Override public void componentResized(ComponentEvent e) { 82 // super.componentResized(e); 83 // Dimension d = scrollPane.getViewport().getExtentSize(); 84 // tblTagEditor.adjustColumnWidth(d.width); 85 // } 86 // } 87 // ); 141 142 add(buildTagEditorPanel(), BorderLayout.CENTER); 88 143 89 144 // build the preset manager which shows a list of applied presets … … 94 149 } 95 150 96 97 151 /** 98 152 * constructor 99 153 */ 100 154 public TagEditor() { 101 // creates a default model and a default cache102 //103 tagEditorModel = new TagEditorModel();104 105 155 build(); 106 156 } 107 108 157 109 158 /** … … 114 163 return tagEditorModel; 115 164 } 116 117 /** 118 * sets the tag editor model 119 * 120 * @param tagEditorModel the tag editor model 121 */ 122 public void setTagEditorModel(TagEditorModel tagEditorModel) { 123 tblTagEditor.setModel(tagEditorModel); 124 for (int i=0; i<=1; i++) { 125 TableCellEditor editor = (TableCellEditor)tblTagEditor.getColumnModel().getColumn(i).getCellEditor(); 126 if (editor != null) { 127 editor.setTagEditorModel(tagEditorModel); 128 } 129 } 130 presetManager.setModel(tagEditorModel); 131 } 132 133 public RunnableAction getDeleteAction() { 134 return tblTagEditor.getDeleteAction(); 135 } 136 137 public RunnableAction getAddAction() { 138 return tblTagEditor.getAddAction(); 139 } 140 165 141 166 public void clearSelection() { 142 167 tblTagEditor.getSelectionModel().clearSelection(); … … 144 169 145 170 public void stopEditing() { 146 TableCellEditor editor = (TableCellEditor)tblTagEditor.getCellEditor();171 TableCellEditor editor = tblTagEditor.getCellEditor(); 147 172 if (editor != null) { 148 173 editor.stopCellEditing(); 149 174 } 150 175 } 151 152 public AutoCompletionList getAutoCompletionList() { 153 return null; 154 //return ((org.openstreetmap.josm.gui.tagging.TagCellEditor)tblTagEditor.getCellEditor()).getAutoCompletionList(); 155 } 156 176 157 177 public void setAutoCompletionList(AutoCompletionList autoCompletionList) { 158 178 tblTagEditor.setAutoCompletionList(autoCompletionList); … … 164 184 165 185 public void autoCompletionItemSelected(String item) { 166 org.openstreetmap.josm.plugins.tageditor.editor.TableCellEditor editor = ((org.openstreetmap.josm.plugins.tageditor.editor.TableCellEditor)tblTagEditor.getCellEditor()); 186 logger.info("autocompletion item selected ..."); 187 TagSpecificationAwareTagCellEditor editor = (TagSpecificationAwareTagCellEditor)tblTagEditor.getCellEditor(); 167 188 if (editor != null) { 168 189 editor.autoCompletionItemSelected(item); … … 173 194 tblTagEditor.requestFocusInCell(0,0); 174 195 } 196 197 public TagEditorModel getModel() { 198 return tagEditorModel; 199 } 175 200 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/AutoCompletionCache.java
r20045 r20058 1 package org.openstreetmap.josm.plugins.tageditor. ac;1 package org.openstreetmap.josm.plugins.tageditor.editor.old; 2 2 3 3 import java.util.ArrayList; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/AutoCompletionItemPritority.java
r20045 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor. ac;2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 3 4 4 public enum AutoCompletionItemPritority implements Comparable<AutoCompletionItemPritority> { -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/AutoCompletionList.java
r20045 r20058 1 package org.openstreetmap.josm.plugins.tageditor. ac;1 package org.openstreetmap.josm.plugins.tageditor.editor.old; 2 2 3 3 import java.util.ArrayList; … … 7 7 import javax.swing.JTable; 8 8 import javax.swing.table.AbstractTableModel; 9 9 10 10 11 /** -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/AutoCompletionListItem.java
r20055 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor.ac; 2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 4 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; 5 3 6 4 7 /** -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/RunnableAction.java
r20045 r20058 1 package org.openstreetmap.josm.plugins.tageditor.editor ;1 package org.openstreetmap.josm.plugins.tageditor.editor.old; 2 2 3 3 import java.awt.event.ActionEvent; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/TableCellEditor.java
r20045 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor.editor ;2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 3 4 4 import java.awt.Component; … … 9 9 import javax.swing.JTable; 10 10 11 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionCache;12 11 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext; 13 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionItemPritority;14 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionList;15 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionListItem;16 12 import org.openstreetmap.josm.plugins.tageditor.ac.IAutoCompletionListListener; 13 import org.openstreetmap.josm.plugins.tageditor.editor.TagEditorModel; 17 14 import org.openstreetmap.josm.plugins.tageditor.tagspec.TagSpecifications; 18 15 … … 72 69 // 73 70 try { 74 autoCompletionList.add(TagSpecifications.getInstance().getKeysForAutoCompletion(context));71 //autoCompletionList.add(TagSpecifications.getInstance().getKeysForAutoCompletion(context)); 75 72 } catch(Exception e) { 76 73 logger.log(Level.WARNING, "failed to initialize auto completion list with standard keys.", e); … … 80 77 // 81 78 for (String key : acCache.getKeys()) { 82 autoCompletionList.add(83 new AutoCompletionListItem(key, AutoCompletionItemPritority.IS_IN_DATASET)84 );79 // autoCompletionList.add( 80 // new AutoCompletionListItem(key, AutoCompletionItemPritority.IS_IN_DATASET) 81 // ); 85 82 } 86 83 … … 117 114 // 118 115 try { 119 autoCompletionList.add(120 TagSpecifications.getInstance().getLabelsForAutoCompletion(forKey, context)121 );116 // autoCompletionList.add( 117 // TagSpecifications.getInstance().getLabelsForAutoCompletion(forKey, context) 118 // ); 122 119 } catch(Exception e){ 123 120 logger.log(Level.WARNING, "failed to initialize auto completion list with standard values", e); … … 125 122 126 123 for (String value : acCache.getValues(forKey)) { 127 autoCompletionList.add(128 new AutoCompletionListItem(value, AutoCompletionItemPritority.IS_IN_DATASET)129 );124 // autoCompletionList.add( 125 // new AutoCompletionListItem(value, AutoCompletionItemPritority.IS_IN_DATASET) 126 // ); 130 127 } 131 128 … … 135 132 for (String value : currentTag.getValues()) { 136 133 //logger.info("adding ac item " + value + " with priority IN_SELECTION");; 137 autoCompletionList.add(138 new AutoCompletionListItem(value, AutoCompletionItemPritority.IS_IN_SELECTION)139 );134 // autoCompletionList.add( 135 // new AutoCompletionListItem(value, AutoCompletionItemPritority.IS_IN_SELECTION) 136 // ); 140 137 } 141 138 } … … 191 188 192 189 if (currentColumn == 0) { 193 tagEditorModel.updateTagName(currentTag, editor.getText());190 //tagEditorModel.updateTagName(currentTag, editor.getText()); 194 191 } else if (currentColumn == 1){ 195 192 if (currentTag.getValueCount() > 1 && ! editor.getText().equals("")) { 196 tagEditorModel.updateTagValue(currentTag, editor.getText());193 //tagEditorModel.updateTagValue(currentTag, editor.getText()); 197 194 } else if (currentTag.getValueCount() <= 1) { 198 tagEditorModel.updateTagValue(currentTag, editor.getText());195 //tagEditorModel.updateTagValue(currentTag, editor.getText()); 199 196 } 200 197 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/TagFieldEditor.java
r20045 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor.editor ;2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 3 4 4 import java.awt.event.FocusAdapter; … … 14 14 import javax.swing.text.PlainDocument; 15 15 16 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionList;17 16 18 17 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/TagModel.java
r20045 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor.editor ;2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 3 4 4 import java.util.ArrayList; -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/editor/old/TagTable.java
r20045 r20058 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.plugins.tageditor.editor ;2 package org.openstreetmap.josm.plugins.tageditor.editor.old; 3 3 4 4 import static org.openstreetmap.josm.tools.I18n.tr; … … 29 29 import javax.swing.table.TableModel; 30 30 31 import org.openstreetmap.josm.plugins.tageditor. ac.AutoCompletionCache;32 import org.openstreetmap.josm.plugins.tageditor. ac.AutoCompletionList;31 import org.openstreetmap.josm.plugins.tageditor.editor.TableCellRenderer; 32 import org.openstreetmap.josm.plugins.tageditor.editor.TagEditorModel; 33 33 34 34 /** -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/Group.java
r17637 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.preset; 2 2 3 import java.awt.Image;4 import java.io.IOException;5 import java.net.URL;6 3 import java.util.ArrayList; 7 4 import java.util.List; 8 5 import java.util.logging.Logger; 9 6 10 import javax.swing.Icon;11 import javax.swing.ImageIcon;12 13 import org.openstreetmap.josm.Main;14 import org.openstreetmap.josm.plugins.tageditor.util.IndentWriter;15 16 7 /** 17 8 * Group represents a named group of preset items. Groups can be nested. 18 9 * 19 *20 10 */ 21 public class Group implements INameIconProvider {11 public class Group extends AbstractNameIconProvider { 22 12 23 static private Logger logger = Logger.getLogger(Group.class.getName());13 static final private Logger logger = Logger.getLogger(Group.class.getName()); 24 14 25 private String name;26 private String iconName;27 private ImageIcon icon;28 15 private List<Item> items = null; 29 16 … … 35 22 this(); 36 23 setName(name); 37 }38 39 public String getName() {40 return name;41 }42 43 public void setName(String name) {44 this.name = name;45 }46 47 public String getIconName() {48 return iconName;49 }50 51 public void setIconName(String iconName) {52 this.iconName = iconName;53 }54 55 public Icon getIcon() {56 if (icon == null) {57 // load the icon from the JOSM resources, use Main classloader58 // for loading59 URL url = Main.class.getResource("/images/" + getIconName());60 if (url == null) {61 logger.warning("failed to create URL for resource 'images/" + getIconName() + "'");62 this.icon = null;63 } else {64 icon =new ImageIcon(url);65 Image i = icon.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT);66 icon = new ImageIcon(i);67 68 }69 }70 return icon;71 24 } 72 25 … … 83 36 return items; 84 37 } 85 86 public void dump(IndentWriter writer) throws IOException {87 writer.indent();88 writer.write("<group ");89 writer.write(String.format("name=\"%s\" ", name));90 writer.write(String.format("iconName=\"%s\" ", iconName));91 writer.write(">");92 writer.write("\n");93 writer.incLevel();94 for(Item item: items) {95 item.dump(writer);96 }97 writer.decLevel();98 writer.writeLine("</group>");99 }100 38 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/INameIconProvider.java
r14326 r20058 4 4 5 5 public interface INameIconProvider { 6 7 6 public String getName(); 8 7 public Icon getIcon(); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/Item.java
r19587 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.preset; 2 2 3 import java.awt.Image;4 import java.io.IOException;5 import java.net.URL;6 3 import java.util.ArrayList; 7 4 import java.util.List; 8 5 import java.util.logging.Logger; 9 6 10 import javax.swing.Icon; 11 import javax.swing.ImageIcon; 7 public class Item extends AbstractNameIconProvider { 12 8 13 import org.openstreetmap.josm.Main; 14 import org.openstreetmap.josm.plugins.tageditor.util.IndentWriter; 9 private final static Logger logger = Logger.getLogger(Item.class.getName()); 15 10 16 17 public class Item implements INameIconProvider {18 19 private static Logger logger = Logger.getLogger(Item.class.getName());20 21 private String name;22 private String iconName;23 private ImageIcon icon;24 11 private String label; 25 12 private List<Tag> tags; … … 38 25 } 39 26 40 41 27 public String getLabel() { 42 28 return label; … … 47 33 } 48 34 49 50 35 public Item(String name) { 51 36 setName(name); 52 }53 54 public String getName() {55 return name;56 }57 58 public void setName(String name) {59 this.name = name;60 }61 62 public String getIconName() {63 return iconName;64 }65 66 public void setIconName(String iconName) {67 this.iconName = iconName;68 }69 70 public Icon getIcon() {71 // FIXME: should also load icons from the image paths configured in the72 // preferences for presets73 //74 if (icon == null) {75 // load the icon from the JOSM resources, use Main classloader76 // for loading77 URL url = Main.class.getResource("/images/" + getIconName());78 if (url == null) {79 logger.warning("failed to create URL for resource 'images/" + getIconName() + "'");80 return null;81 } else {82 icon =new ImageIcon(url);83 }84 Image i = icon.getImage().getScaledInstance(16, 16, Image.SCALE_DEFAULT);85 icon = new ImageIcon(i);86 87 }88 return icon;89 37 } 90 38 … … 95 43 public List<Tag> getTags() { 96 44 return tags; 97 }98 99 public void dump(IndentWriter writer) throws IOException {100 writer.indent();101 writer.write("<item ");102 writer.write(String.format("name=\"%s\" ", name));103 writer.write(String.format("label=\"%s\" ", label));104 writer.write(String.format("iconName=\"%s\" ", iconName));105 writer.write(">");106 writer.write("\n");107 writer.incLevel();108 for(Tag tag: tags) {109 tag.dump(writer);110 }111 writer.decLevel();112 writer.writeLine("</item>");113 45 } 114 46 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/Presets.java
r17637 r20058 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 4 5 import java.io.File; 5 6 import java.io.IOException; 7 import java.io.InputStream; 6 8 import java.io.InputStreamReader; 7 9 import java.io.Reader; … … 21 23 import org.openstreetmap.josm.plugins.tageditor.preset.io.Parser; 22 24 import org.openstreetmap.josm.plugins.tageditor.preset.io.PresetIOException; 23 import org.openstreetmap.josm.plugins.tageditor.util.IndentWriter;24 25 25 26 public class Presets { … … 37 38 // 38 39 if (Main.pref.getBoolean("taggingpreset.enable-defaults", true)) { 39 sources.add("resource:// presets/presets.xml");40 sources.add("resource://data/defaultpresets.xml"); 40 41 } 41 42 sources.addAll(Main.pref.getCollection("taggingpreset.sources", 42 43 new LinkedList<String>())); 43 44 45 File zipIconArchive = null; 44 46 for (String source : sources) { 45 logger.log(Level.INFO, String.format(46 "starting to read presets from source '%1$s'", source));47 47 try { 48 48 MirroredInputStream s = new MirroredInputStream(source); 49 InputStream zip = s.getZipEntry("xml","preset"); 50 if(zip != null) { 51 zipIconArchive = s.getFile(); 52 } 49 53 InputStreamReader r; 50 54 try { … … 53 57 r = new InputStreamReader(s); 54 58 } 55 presets = loadPresets(r, presets); 56 59 presets = loadPresets(r, presets, zipIconArchive); 57 60 } catch (PresetIOException e) { 58 61 logger … … 77 80 con.connect(); 78 81 Reader reader = new InputStreamReader(con.getInputStream()); 79 return loadPresets(reader, null );82 return loadPresets(reader, null, null); 80 83 } catch (Exception e) { 81 84 logger.log(Level.SEVERE, … … 83 86 throw new PresetIOException(e); 84 87 } 85 86 88 } 87 89 88 static public Presets loadPresets(Reader reader, Presets p ) throws PresetIOException {90 static public Presets loadPresets(Reader reader, Presets p, File zipIconArchive) throws PresetIOException { 89 91 try { 90 92 Parser parser = new Parser(); … … 120 122 } 121 123 122 public void dump(IndentWriter writer) throws IOException {123 writer.indent();124 writer.write("<presets>\n");125 writer.incLevel();126 for (Group group : groups) {127 group.dump(writer);128 }129 writer.decLevel();130 writer.indent();131 writer.write("</presets>");132 }133 134 124 public List<Group> getGroups() { 135 125 return groups; 136 126 } 137 138 127 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/Tag.java
r14326 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.preset; 2 3 import java.io.IOException;4 5 import org.openstreetmap.josm.plugins.tageditor.util.IndentWriter;6 7 2 8 3 public class Tag { … … 46 41 this.optional = optional; 47 42 } 48 49 50 public void dump(IndentWriter writer) throws IOException {51 writer.indent();52 writer.write("<tag ");53 writer.write(String.format("key=\"%s\" ", key));54 writer.write(String.format("optional=\"%s\" ", Boolean.toString(optional)));55 if (value != null) {56 writer.write(String.format("value=\"%s\" ", value));57 }58 writer.write(String.format("displayName=\"%s\" ", displayName));59 writer.write("/>");60 writer.write("\n");61 }62 63 64 65 66 67 43 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/io/Parser.java
r17637 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.preset.io; 2 2 3 import java.io.File; 3 4 import java.io.Reader; 4 5 import java.util.Stack; … … 22 23 public class Parser { 23 24 24 static private Logger logger = Logger.getLogger(Parser.class.getName()); 25 static final private Logger logger = Logger.getLogger(Parser.class.getName()); 26 25 27 private Presets presets = null; 26 28 private Reader reader; … … 29 31 private boolean inOptionalKeys = false; 30 32 private XMLReader parser; 33 private File zipIconArchive; 31 34 32 35 public Parser() { … … 49 52 public Reader getReader() { 50 53 return reader; 54 } 55 56 public void setZipIconArchive(File zipIconArchive) { 57 this.zipIconArchive = zipIconArchive; 51 58 } 52 59 … … 122 129 } 123 130 124 125 131 protected String translatedAttributeValue(String attrValue) { 126 132 if (attrValue == null) { … … 134 140 Group g = new Group(); 135 141 g.setName(translatedAttributeValue(name)); 136 g.setIconName(iconName );142 g.setIconName(iconName, zipIconArchive); 137 143 currentGroup.push(g); 138 144 } … … 146 152 currentItem = new Item(); 147 153 currentItem.setName(translatedAttributeValue(name)); 148 currentItem.setIconName(iconName );154 currentItem.setIconName(iconName, zipIconArchive); 149 155 } 150 156 … … 238 244 || "check".equals(qName)) { 239 245 onTag(getAttribute(atts, "key"), getAttribute(atts, "value"), getAttribute(atts, "text")); 240 } 241 246 } 242 247 } 243 248 -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/preset/io/PresetIOException.java
r14327 r20058 22 22 // TODO Auto-generated constructor stub 23 23 } 24 25 26 27 24 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecification.java
r16574 r20058 5 5 6 6 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext; 7 8 7 9 8 /** … … 63 62 } 64 63 65 66 64 /** 67 65 * sets the list of lables for this tag specification … … 79 77 } 80 78 81 82 79 /** 83 * adds a lable to the list of lables for this tag specification. The lable80 * Adds a label to the list of label for this tag specification. The label 84 81 * is only added if i 85 82 * 86 * @param lable the la ble to add; must not be null83 * @param lable the lalbe to add; must not be null 87 84 * @exception IllegalArgumentException thrown, if lable is null 88 85 */ -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/TagSpecifications.java
r15319 r20058 11 11 import java.util.logging.Logger; 12 12 13 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionItemPritority; 14 import org.openstreetmap.josm.gui.tagging.ac.AutoCompletionListItem; 13 15 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionContext; 14 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionItemPritority;15 import org.openstreetmap.josm.plugins.tageditor.ac.AutoCompletionListItem;16 16 import org.xml.sax.Attributes; 17 17 import org.xml.sax.EntityResolver; … … 58 58 private ArrayList<TagSpecification> tagSpecifications = null; 59 59 60 61 62 60 private static TagSpecifications instance = null; 63 61 … … 123 121 parser = null; 124 122 } 125 126 127 128 123 } 129 124 … … 160 155 return items; 161 156 } 162 163 157 164 158 /** 165 159 * replies a list of {@see KeyValuePair}s for all {@see TagSpecification}s and … … 292 286 } 293 287 294 295 288 /** 296 289 * handles a start element with name <code>label</code> … … 359 352 logger.log(Level.WARNING, "XML parsing warning", e); 360 353 } 361 362 363 364 } 365 354 } 366 355 367 356 /** … … 383 372 } 384 373 385 386 374 static public void main(String args[]) throws Exception{ 387 375 TagSpecifications.loadFromResources(); 388 376 } 389 390 377 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/ITagSelectorListener.java
r14330 r20058 3 3 import org.openstreetmap.josm.plugins.tageditor.tagspec.KeyValuePair; 4 4 5 6 5 public interface ITagSelectorListener { 7 8 6 public void itemSelected(KeyValuePair pair); 9 7 } -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/KeyValueCellRenderer.java
r15319 r20058 1 1 package org.openstreetmap.josm.plugins.tageditor.tagspec.ui; 2 2 3 import java.awt.Color;4 3 import java.awt.Component; 5 4 import java.awt.Font; … … 8 7 import javax.swing.JLabel; 9 8 import javax.swing.JTable; 9 import javax.swing.UIManager; 10 10 import javax.swing.table.TableCellRenderer; 11 11 12 12 public class KeyValueCellRenderer extends JLabel implements TableCellRenderer { 13 13 14 private static Logger logger = Logger.getLogger(KeyValueCellRenderer.class.getName()); 15 public static final Color BG_COLOR_SELECTED = new Color(143,170,255); 16 14 private static final Logger logger = Logger.getLogger(KeyValueCellRenderer.class.getName()); 17 15 18 16 protected void init() { 19 setFont(new Font("Courier",Font.PLAIN, 12));17 setFont(new Font("Courier",Font.PLAIN,getFont().getSize())); 20 18 setOpaque(true); 21 19 } … … 29 27 30 28 if (isSelected) { 31 setBackground(BG_COLOR_SELECTED); 29 setBackground(UIManager.getColor("Table.selectionBackground")); 30 setForeground(UIManager.getColor("Table.selectionForeground")); 32 31 } else { 33 setBackground(Color.WHITE); 32 setBackground(UIManager.getColor("Table.background")); 33 setForeground(UIManager.getColor("Table.foreground")); 34 34 } 35 35 setText((String)value); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TabularTagSelector.java
r15319 r20058 31 31 import org.openstreetmap.josm.plugins.tageditor.tagspec.KeyValuePair; 32 32 33 34 35 33 public class TabularTagSelector extends JPanel { 36 34 … … 40 38 private JScrollPane scrollPane; 41 39 private final ArrayList<ITagSelectorListener> listeners = new ArrayList<ITagSelectorListener>(); 42 43 40 44 41 protected JPanel buildFilterPanel() { … … 123 120 } 124 121 125 126 122 protected JPanel buildControlButtonPanel() { 127 123 JPanel pnl = new JPanel(); -
applications/editors/josm/plugins/tageditor/src/org/openstreetmap/josm/plugins/tageditor/tagspec/ui/TagsTableModel.java
r15319 r20058 12 12 import org.openstreetmap.josm.plugins.tageditor.tagspec.KeyValuePair; 13 13 import org.openstreetmap.josm.plugins.tageditor.tagspec.TagSpecifications; 14 15 14 16 15 public class TagsTableModel extends AbstractTableModel { … … 117 116 return visibleItems.get(row); 118 117 } 119 120 118 }
Note:
See TracChangeset
for help on using the changeset viewer.