Changeset 11974 in josm
- Timestamp:
- 2017-04-22T17:57:11+02:00 (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r11946 r11974 144 144 } 145 145 146 static final class PluginInformationAction extends AbstractAction { 147 private final PluginInformation info; 148 149 PluginInformationAction(PluginInformation info) { 150 super(tr("Information")); 151 this.info = info; 152 } 153 154 /** 155 * Returns plugin information text. 156 * @return plugin information text 157 */ 158 public String getText() { 159 StringBuilder b = new StringBuilder(); 160 for (Entry<String, String> e : info.attr.entrySet()) { 161 b.append(e.getKey()); 162 b.append(": "); 163 b.append(e.getValue()); 164 b.append('\n'); 165 } 166 return b.toString(); 167 } 168 169 @Override 170 public void actionPerformed(ActionEvent event) { 171 String text = getText(); 172 JosmTextArea a = new JosmTextArea(10, 40); 173 a.setEditable(false); 174 a.setText(text); 175 a.setCaretPosition(0); 176 if (!GraphicsEnvironment.isHeadless()) { 177 JOptionPane.showMessageDialog(Main.parent, new JScrollPane(a), tr("Plugin information"), 178 JOptionPane.INFORMATION_MESSAGE); 179 } 180 } 181 } 182 146 183 /** 147 184 * Description of a deprecated plugin … … 1408 1445 pluginTab.add(new JLabel(name), GBC.std()); 1409 1446 pluginTab.add(Box.createHorizontalGlue(), GBC.std().fill(GBC.HORIZONTAL)); 1410 pluginTab.add(new JButton(new AbstractAction(tr("Information")) { 1411 @Override 1412 public void actionPerformed(ActionEvent event) { 1413 StringBuilder b = new StringBuilder(); 1414 for (Entry<String, String> e : info.attr.entrySet()) { 1415 b.append(e.getKey()); 1416 b.append(": "); 1417 b.append(e.getValue()); 1418 b.append('\n'); 1419 } 1420 JosmTextArea a = new JosmTextArea(10, 40); 1421 a.setEditable(false); 1422 a.setText(b.toString()); 1423 a.setCaretPosition(0); 1424 JOptionPane.showMessageDialog(Main.parent, new JScrollPane(a), tr("Plugin information"), 1425 JOptionPane.INFORMATION_MESSAGE); 1426 } 1427 }), GBC.eol()); 1447 pluginTab.add(new JButton(new PluginInformationAction(info)), GBC.eol()); 1428 1448 1429 1449 JosmTextArea description = new JosmTextArea(info.description == null ? tr("no description available") -
trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java
r11809 r11974 21 21 import org.openstreetmap.josm.data.osm.Way; 22 22 23 /** 24 * The context switch offers possibility to use tags of referenced primitive when constructing primitive name. 25 * @author jttt 26 * @since 4546 27 */ 23 28 public class ContextSwitchTemplate implements TemplateEntry { 24 29 … … 244 249 } 245 250 251 /** 252 * Constructs a new {@code ContextSwitchTemplate}. 253 * @param match match 254 * @param template template 255 * @param searchExpressionPosition search expression position 256 * @throws ParseError if a parse error occurs, or if the match transformation returns the same primitive 257 */ 246 258 public ContextSwitchTemplate(Match match, TemplateEntry template, int searchExpressionPosition) throws ParseError { 247 259 Match m = transform(match, searchExpressionPosition); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
r10378 r11974 17 17 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 18 import org.openstreetmap.josm.plugins.PluginDownloadTask; 19 import org.openstreetmap.josm.plugins.PluginException; 19 20 import org.openstreetmap.josm.plugins.PluginInformation; 20 21 … … 41 42 42 43 /** 44 * Returns a dummy plugin information. 45 * @return a dummy plugin information 46 * @throws PluginException if an error occurs 47 */ 48 public static PluginInformation getDummyPluginInformation() throws PluginException { 49 return new PluginInformation( 50 new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin"); 51 } 52 53 /** 43 54 * Unit test of {@link PluginPreference#buildDownloadSummary}. 44 55 * @throws Exception if an error occurs … … 46 57 @Test 47 58 public void testBuildDownloadSummary() throws Exception { 48 final PluginInformation dummy = new PluginInformation( 49 new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin"); 59 final PluginInformation dummy = getDummyPluginInformation(); 50 60 assertEquals("", PluginPreference.buildDownloadSummary( 51 61 new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), ""))); -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
r10758 r11974 15 15 import org.openstreetmap.josm.JOSMFixture; 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.gui.preferences.plugin.PluginPreferenceTest; 17 18 import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin; 19 import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction; 18 20 import org.openstreetmap.josm.tools.Utils; 19 21 … … 84 86 assertFalse(plugins.contains("gpsbabelgui")); 85 87 } 88 89 /** 90 * Unit test of {@link PluginInformationAction} class. 91 * @throws PluginException if an error occurs 92 */ 93 @Test 94 public void testPluginInformationAction() throws PluginException { 95 PluginInformationAction action = new PluginInformationAction(PluginPreferenceTest.getDummyPluginInformation()); 96 assertEquals( 97 "Ant-Version: Apache Ant 1.9.6\n" + 98 "Author: Don-vip\n" + 99 "Created-By: 1.7.0_91-b02 (Oracle Corporation)\n" + 100 "Manifest-Version: 1.0\n" + 101 "Plugin-Canloadatruntime: true\n" + 102 "Plugin-Class: org.openstreetmap.josm.plugins.fr.epci.EpciPlugin\n" + 103 "Plugin-Date: 2015-11-19T08:21:07.645033Z\n" + 104 "Plugin-Description: Handling of French EPCIs (boundary=local_authority)\n" + 105 "Plugin-Early: true\n" + 106 "Plugin-Link: http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/EPCI-fr\n" + 107 "Plugin-Mainversion: 7001\n" + 108 "Plugin-Version: 31772\n", action.getText()); 109 action.actionPerformed(null); 110 } 86 111 } -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java
r11057 r11974 237 237 238 238 @Test 239 public void testSetAnd() throws ParseError { 240 TemplateParser parser = new TemplateParser("!{(parent(type=child) type=parent) & (parent type=child subtype=parent) '{name}'}"); 241 DatasetFactory ds = new DatasetFactory(); 242 Relation parent1 = ds.addRelation(1); 243 parent1.put("type", "parent"); 244 parent1.put("subtype", "parent"); 245 parent1.put("name", "name_parent1"); 246 Node child = ds.addNode(1); 247 child.put("type", "child"); 248 parent1.addMember(new RelationMember("", child)); 249 250 StringBuilder sb = new StringBuilder(); 251 TemplateEntry entry = parser.parse(); 252 entry.appendText(sb, child); 253 254 Assert.assertEquals("name_parent1", sb.toString()); 255 } 256 257 @Test 239 258 public void testSetOr() throws ParseError { 240 259 TemplateParser parser = new TemplateParser("!{(parent(type=type1) type=parent1) | (parent type=type2 type=parent2) '{name}'}");
Note:
See TracChangeset
for help on using the changeset viewer.