Changeset 12778 in osm for applications/editors/josm/plugins/pluginmanager
- Timestamp:
- 2009-01-01T18:28:53+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/InstallPanel.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 30 30 /** 31 31 * @param pluginUpdateFrame 32 * @param descriptions 32 * @param descriptions 33 33 */ 34 34 public InstallPanel(PluginUpdateFrame pluginUpdateFrame, List<SiteDescription> descriptions) { … … 36 36 setBorder(new javax.swing.border.EmptyBorder(12,12,12,12)); 37 37 final JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true); 38 38 39 39 /* Setup the table */ 40 40 table = new JTable(pluginModel = new PluginTableModel(descriptions)); … … 44 44 table.setPreferredScrollableViewportSize(new Dimension(500,200)); 45 45 table.getSelectionModel().addListSelectionListener(this); 46 46 47 47 TableColumn col1 = table.getColumnModel().getColumn(0); 48 48 TableColumn col2 = table.getColumnModel().getColumn(1); … … 82 82 83 83 /** 84 * 84 * 85 85 */ 86 86 public void install() { … … 101 101 infoBox.setText(text); 102 102 infoBox.setCaretPosition(0); 103 103 104 104 } 105 105 -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginDescription.java
r3412 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 23 23 private String description; 24 24 private List<PluginResource> resources = new ArrayList<PluginResource>(); 25 25 26 26 /** 27 27 * Add a resource to the plugin description. … … 31 31 resources.add(resource); 32 32 } 33 33 34 34 /** 35 35 * @return the id … … 87 87 return this.resources; 88 88 } 89 89 90 90 /** 91 91 * @return the installedVersion … … 136 136 } 137 137 if(errorReported) { 138 JOptionPane.showMessageDialog(Main.parent, "One or more installs had an error: " + errorMessages.toString()); 138 JOptionPane.showMessageDialog(Main.parent, "One or more installs had an error: " + errorMessages.toString()); 139 139 } 140 140 } 141 141 142 142 /* (non-Javadoc) 143 143 * @see java.lang.Object#toString() 144 144 */ 145 145 public String toString() { 146 return getClass().getSimpleName() + "[id=" + id 147 + ", name=" + name 148 + ", version=" + version 149 + ", desc=" + description 150 + ", resources=" + resources 146 return getClass().getSimpleName() + "[id=" + id 147 + ", name=" + name 148 + ", version=" + version 149 + ", desc=" + description 150 + ", resources=" + resources 151 151 + "]"; 152 152 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginHelper.java
r9948 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 18 18 */ 19 19 public class PluginHelper { 20 20 21 21 private static PluginHelper INSTANCE = new PluginHelper(); 22 22 private Map<String, JMenu>menus; 23 23 private VariableHelper variableHelper; 24 24 25 25 /** 26 26 * Private constructor … … 35 35 // registerMenu("layer", Main.main.menu.layerMenu); 36 36 registerMenu("help", Main.main.menu.helpMenu); 37 37 38 38 variableHelper = new VariableHelper(); 39 39 variableHelper.addAll(Main.pref.getAllPrefix("")); 40 40 variableHelper.add("josm.user.dir", Main.pref.getPreferencesDir()); 41 41 } 42 42 43 43 /** 44 44 * Returns the singleton instance of this helper. … … 48 48 return INSTANCE; 49 49 } 50 50 51 51 /** 52 52 * Adds a menu to the main menu of JOSM and registers it under the given id. … … 59 59 registerMenu(menuId, menu); 60 60 } 61 61 62 62 /** 63 63 * Register the menu under the given id so other plugins can retrieve 64 * the menu with {@link #getMenu(String)}. 64 * the menu with {@link #getMenu(String)}. 65 65 * @param menuId 66 66 * @param menu … … 69 69 menus.put(menuId, menu); 70 70 } 71 71 72 72 /** 73 * Returns the main menu that was registered with the given id or <code>null</code> 73 * Returns the main menu that was registered with the given id or <code>null</code> 74 74 * if no menu was registered with that id. The default menus have the ids: 75 75 * <code>file</code>, <code>view</code>, <code>edit</code>, <code>tools</code>, … … 87 87 return this.variableHelper; 88 88 } 89 89 90 90 /** 91 91 * Returns the plugin with the given id or <code>null</code> … … 104 104 return null; 105 105 } 106 107 106 108 107 108 109 109 110 110 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginManagerAction.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 16 16 */ 17 17 public class PluginManagerAction extends AbstractAction { 18 18 19 19 /** 20 20 * Constructor … … 36 36 // left a list of sites, right buttons "add remote site" 37 37 // list has checkboxes 38 // adding: name and url where site.xml can be found. 38 // adding: name and url where site.xml can be found. 39 39 // site.xml containing a list of plugin.xml files 40 40 // plugin info holds name, version and dependencies (including versions) … … 43 43 // page to download, page to install, page to enable new plugins 44 44 // finish 45 45 46 46 // plugin.xml holds info 47 // name, version, dependencies, installpath, 48 47 // name, version, dependencies, installpath, 48 49 49 // info about other resources: images, log4j.jar, .... 50 50 // need source url and target dir (relative to .josm? or main app dir (for josm update)) 51 51 // need restart of josm afterwards 52 52 53 53 // pluginmanager could also load the plugins itself, so dependencies could be respected 54 54 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginManagerPlugin.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 14 14 */ 15 15 public class PluginManagerPlugin extends Plugin { 16 16 17 17 public PluginManagerPlugin() { 18 18 // JMenu menu = PluginHelper.getInstance().getMenu("tools"); … … 20 20 // menu.add(new PluginManagerAction()); 21 21 } 22 22 23 23 @Override 24 24 public PreferenceSetting getPreferenceSetting() { -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginManagerPreference.java
r12707 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 56 56 if(sites.keySet().size() == 0) { 57 57 // add default entry (for demonstration purpose) 58 sites.put(PREF_KEY_REMOTE_SITE_PREFIX + "0"+PREF_KEY_SITE_URL_SUFFIX, 58 sites.put(PREF_KEY_REMOTE_SITE_PREFIX + "0"+PREF_KEY_SITE_URL_SUFFIX, 59 59 "http://www.tegmento.org/~cdaller/josm/"); 60 60 } … … 73 73 } 74 74 ++siteCount; 75 } 75 } 76 76 return listModel; 77 77 } … … 82 82 // only in 1.6 allowed @Override 83 83 public void addGui(final PreferenceDialog gui) { 84 84 85 85 siteListModel = createListModel(); 86 86 siteList = new JList(siteListModel); … … 114 114 else { 115 115 int[] selected = siteList.getSelectedIndices(); 116 for (int i = selected.length - 1; i >=0; --i) { 116 for (int i = selected.length - 1; i >=0; --i) { 117 117 siteListModel.removeElementAt(selected[i]); 118 118 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginResource.java
r3415 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 22 22 private String errorMessage; 23 23 private Exception errorException; 24 24 25 25 /** 26 26 * @return the resourceUrl … … 47 47 this.target = target; 48 48 } 49 49 50 50 /** 51 51 * @return the errorMessage … … 73 73 } 74 74 /** 75 * Installs the resource into to the target location. 76 * @throws IOException if the resource could not be read or written. 75 * Installs the resource into to the target location. 76 * @throws IOException if the resource could not be read or written. 77 77 */ 78 78 public void install() { 79 79 File targetFile = new File(target); 80 if(targetFile.isDirectory() 81 || targetFile.getAbsolutePath().endsWith("/") 80 if(targetFile.isDirectory() 81 || targetFile.getAbsolutePath().endsWith("/") 82 82 || targetFile.getAbsolutePath().endsWith("\\")) { 83 83 targetFile = new File(targetFile, resourceUrl.getFile()); … … 88 88 return; 89 89 } 90 90 91 91 // copy resource to local filesystem: 92 92 System.out.println("Install " + resourceUrl + " to " + targetFile); … … 112 112 } catch(IOException ignore) {} 113 113 } 114 114 115 115 } 116 116 /* (non-Javadoc) … … 120 120 return getClass().getSimpleName() + "[url=" + resourceUrl + ", target=" + target + "]"; 121 121 } 122 122 123 123 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginTableModel.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 17 17 private List<SiteDescription> sites; 18 18 private List<PluginDescription> plugins; 19 19 20 20 public PluginTableModel(List<SiteDescription> descriptions) { 21 21 this.sites = descriptions; 22 22 update(); 23 23 } 24 24 25 25 private void update() { 26 26 plugins = new ArrayList<PluginDescription>(); … … 29 29 } 30 30 } 31 32 31 32 33 33 34 34 /* (non-Javadoc) … … 65 65 return plugin.getInstalledVersion() + " -> " + plugin.getVersion(); 66 66 } else { 67 return plugin.getVersion(); 67 return plugin.getVersion(); 68 68 } 69 69 default: throw new IllegalArgumentException("Illegal Column Index " + columnIndex); 70 70 } 71 71 } 72 73 72 73 74 74 75 75 /* (non-Javadoc) … … 121 121 } 122 122 } 123 123 124 124 } 125 125 … … 151 151 this.plugins = plugins; 152 152 } 153 154 155 156 153 154 155 156 157 157 158 158 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/PluginUpdateFrame.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 32 32 /** 33 33 * @param title 34 * @param descriptions 34 * @param descriptions 35 35 * @throws HeadlessException 36 36 */ … … 39 39 init(descriptions); 40 40 } 41 41 42 42 public void init(List<SiteDescription> descriptions) { 43 43 44 44 /* Setup panes */ 45 45 JPanel content = new JPanel(new BorderLayout(12,12)); … … 53 53 54 54 content.add(BorderLayout.CENTER,tabPane); 55 55 56 56 JPanel buttonPannel = new JPanel(); 57 57 // <FIXXME date="23.06.2007" author="cdaller"> … … 59 59 JButton okButton = new JButton(tr("Install")); 60 60 JButton cancelButton = new JButton(tr("Cancel")); 61 // </FIXXME> 61 // </FIXXME> 62 62 buttonPannel.add(okButton); 63 63 buttonPannel.add(cancelButton); … … 68 68 setVisible(false); 69 69 dispose(); 70 } 70 } 71 71 }); 72 72 73 73 cancelButton.addActionListener(new ActionListener() { 74 74 public void actionPerformed(ActionEvent e) { 75 75 setVisible(false); 76 76 dispose(); 77 } 77 } 78 78 }); 79 79 content.add(BorderLayout.SOUTH,buttonPannel); 80 80 81 81 pack(); 82 82 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/SiteDescription.java
r9948 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 30 30 private URL url; 31 31 List<PluginDescription>plugins = new ArrayList<PluginDescription>(); 32 32 33 33 /** 34 34 * Default Constructor … … 47 47 this.url = new URL(url); 48 48 } 49 49 50 50 /** 51 51 * @param name … … 56 56 this.name = name; 57 57 } 58 58 59 59 60 60 /** … … 71 71 } 72 72 73 73 74 74 /** 75 75 * Load the site description from the url. 76 * @throws IOException 76 * @throws IOException 77 77 */ 78 78 public void loadFromUrl() throws IOException { … … 84 84 // TODO check and remember modified since date to compare and not load sites that did not change 85 85 // connection.getIfModifiedSince() 86 // </FIXXME> 87 86 // </FIXXME> 87 88 88 Reader in = new InputStreamReader(connection.getInputStream()); 89 89 SiteDescriptionParser parser = new SiteDescriptionParser(this); … … 111 111 if(info != null) { 112 112 if(info.version == null) { 113 plugin.setInstalledVersion("?"); 113 plugin.setInstalledVersion("?"); 114 114 } else { 115 115 plugin.setInstalledVersion(info.version); … … 118 118 } 119 119 } 120 120 121 121 /** 122 122 * @return the plugins … … 133 133 } 134 134 135 135 136 136 /** 137 137 * @return the url … … 158 158 return name; 159 159 } 160 160 161 161 } 162 162 163 163 /** 164 164 * Used by ListCellRenderer, so not only a debug method! … … 168 168 return getLabelName(); 169 169 } 170 170 171 171 public static void main(String[] args) { 172 172 try { -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/SiteDescriptionParser.java
r9948 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 23 23 private StringBuilder characters; 24 24 private VariableHelper variableHelper; 25 25 26 26 /** 27 27 * Constructor using a new SiteDescription object. … … 33 33 * Constructor using a description object to fill. 34 34 * @param siteDescription the object to fill. 35 * @param in the reader to fill the description with. 35 * @param in the reader to fill the description with. 36 36 */ 37 37 public SiteDescriptionParser(SiteDescription siteDescription) { 38 38 this.siteDescription = siteDescription; 39 39 } 40 40 41 41 /** 42 42 * Returns the site description object. … … 117 117 } 118 118 } 119 120 /** 119 120 /** 121 121 * Read characters for description. 122 122 */ … … 127 127 characters.append(data, start, length); 128 128 } 129 129 130 130 /* (non-Javadoc) 131 131 * @see uk.co.wilson.xml.MinML2#endElement(java.lang.String, java.lang.String, java.lang.String) … … 158 158 } 159 159 } 160 160 161 161 /** 162 162 * Clears the characters and returns the its previous content. … … 168 168 return chars; 169 169 } 170 171 170 171 172 172 173 173 } -
applications/editors/josm/plugins/pluginmanager/src/at/dallermassl/josm/plugin/pluginmanager/VariableHelper.java
r3335 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.pluginmanager; … … 10 10 11 11 /** 12 * Helper class that replaces variables in strings with its values. The variables are in the 12 * Helper class that replaces variables in strings with its values. The variables are in the 13 13 * form ${name}. Replacement values may be set. As a fallback (if the variable is not found) 14 14 * the system properties are used. If neither is found, the variable is not replaced. 15 * 15 * 16 16 * @author cdaller 17 17 * … … 20 20 private Pattern varPattern = Pattern.compile("\\$\\{(.+?)\\}"); 21 21 private Map<String, String> variables; 22 22 23 23 public VariableHelper() { 24 24 variables = new HashMap<String, String>(); 25 25 } 26 26 27 27 /** 28 28 * Adds all key/values as variables. … … 32 32 variables.putAll(values); 33 33 } 34 34 35 35 /** 36 36 * Adds a single key/value pair. … … 41 41 variables.put(key, value); 42 42 } 43 43 44 44 /** 45 45 * Replaces all variable placeholder in the given string with the replacement. … … 71 71 return source.toString(); 72 72 } 73 73 74 74 public static void main(String[] args) { 75 75 VariableHelper helper = new VariableHelper();
Note:
See TracChangeset
for help on using the changeset viewer.