Revision 37893 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.swing/org.gvsig.installer.swing.impl/src/main/java/org/gvsig/installer/swing/impl/execution/panel/PackagesTablePanel.java

View differences:

PackagesTablePanel.java
44 44
import javax.swing.event.ListSelectionListener;
45 45
import javax.swing.table.TableColumnModel;
46 46

  
47
import org.gvsig.installer.lib.api.Dependencies;
48 47
import org.gvsig.installer.lib.api.PackageInfo;
49 48
import org.gvsig.installer.swing.api.SwingInstallerLocator;
50 49
import org.gvsig.installer.swing.api.SwingInstallerManager;
......
96 95
				new OsAndArchitectureCellRenderer());
97 96
		pluginsTable.setDefaultRenderer(String.class, ipcr);
98 97
		pluginsTable.setDefaultRenderer(Number.class, ipcr);
99
		pluginsTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
98
		pluginsTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
100 99
	}
101 100

  
102 101
	private void initComponents() {
......
165 164
		add(descriptionScrollPane, gridBagConstraints);
166 165
	}
167 166

  
167
	public void resetFilter() {
168
		filterPanel.resetPanel();
169
		valueChanged();
170
	}
171
	
168 172
	public void selectPackages() {
169 173
		PackagesTableModel pluginsTableModel = (PackagesTableModel) pluginsTable
170 174
				.getModel();
......
194 198
				.hasAnyPackageSelected();
195 199
	}
196 200

  
197
	// shows the package info in the wizard
198
	public void valueChanged(ListSelectionEvent e) {
199
		int row = pluginsTable.getSelectedRow();
200
		if (row != -1) {
201

  
202
			String code = ((PackagesTableModel) pluginsTable.getModel())
203
					.getPackageInfoAt(row).getCode();
204
			if (code == null || code.equals("")) {
205
				code = "";
206
			} else {
207
				code = "<li type='circle'>Code: " + code + "</li>";
201
	private class HTMLCoder {
202
		private StringBuffer buffer = new StringBuffer();
203
	
204
		public String toString() {
205
			return buffer.toString();
206
		}
207
		
208
		public void addTitle(String title) {
209
			if( title == null ) {
210
				return;
208 211
			}
209

  
210
			String name = ((PackagesTableModel) pluginsTable.getModel())
211
					.getPackageInfoAt(row).getName();
212
			if (name == null || name.equals("")) {
213
				name = "";
214
			} else {
215
				name = name + "<br>";
212
			buffer.append("<h1>");
213
			buffer.append(title);
214
			buffer.append("</h1>");
215
		}
216
		
217
		public void addParagraph(Object text) {
218
			if( text == null ) {
219
				return;
216 220
			}
217

  
218
			String owner = ((PackagesTableModel) pluginsTable.getModel())
219
					.getOwnerAt(row).trim();
220
			if (owner == null || owner.equals("")) {
221
				owner = "";
222
			} else {
223
				owner = "<li type='circle'>Owner: " + owner + "</li>";
221
			String t = text.toString().replaceAll("\\n", "<br>\n");
222
			buffer.append("<p>");
223
			buffer.append(t);
224
			buffer.append("</p>");
225
		}
226
		
227
		public void addBeginList() {
228
			buffer.append("<ul>");
229
		}
230
		
231
		public void addEndList() {
232
			buffer.append("</ul>");
233
		}
234
		
235
		public void addListItem(String label, Object value) {
236
			if( value == null ) {
237
				return;
224 238
			}
225

  
226
			String ownerUrlStr;
227
			URL ownerURL = ((PackagesTableModel) pluginsTable.getModel())
228
					.getOwnerUrlAt(row);
229
			if (ownerURL == null) {
230
				ownerUrlStr = "";
231
			} else {
232
				ownerUrlStr = "<li type='circle'>Owner URL:"
233
						+ ownerURL.toString() + "</li>";
239
			buffer.append("<li>");
240
			buffer.append(label);
241
			buffer.append(": <i>");
242
			buffer.append(value.toString());
243
			buffer.append("</i></li>");
244
		}
245
		
246
		public void addListItem(String label, URL value) {
247
			if( value == null ) {
248
				return;
234 249
			}
250
			buffer.append("<li>");
251
			buffer.append(label);
252
			buffer.append(": <a href=\"");
253
			buffer.append(value.toString());
254
			buffer.append("\">");
255
			buffer.append(value.toString());
256
			buffer.append("</a></li>");
257
		}
258
		
259
	}
260
	public void valueChanged(ListSelectionEvent e) {
261
		valueChanged();
262
	}
235 263

  
236
			String sources;
237
			URL sourcesURL = ((PackagesTableModel) pluginsTable.getModel())
238
					.getSourcesAt(row);
239
			if (sourcesURL == null) {
240
				sources = "";
241
			} else {
242
				String sourcesb = "Sources:" + sourcesURL.toString();
243
				sources = "<li type='circle'>" + sourcesb + "</li>";
244
			}
264
	public void valueChanged() {
265
		int row = pluginsTable.getSelectedRow();
266
		if (row < 0) {
267
			descriptionTextEditor.setText("<p></p>");
268
			return;
269
		}
245 270

  
246
			String description = ((PackagesTableModel) pluginsTable.getModel())
247
					.getDescriptionAt(row);
248
			if (description == null) {
249
				description = "";
250
			} else {
251
				description = description + "<br>";
252
			}
271
		PackageInfo pkginfo = ((PackagesTableModel) pluginsTable.getModel())
272
				.getPackageInfoAt(row);
253 273

  
254
			String depends = "";
255
			Dependencies dependencies = ((PackagesTableModel) pluginsTable
256
					.getModel()).getPackageInfoAt(row).getDependencies();
257
			if (dependencies != null && !dependencies.isEmpty()) {
258
				depends = "<li type='circle'>Dependencies: "
259
						+ dependencies.toString() + "</li>";
260
			}
274
		HTMLCoder html = new HTMLCoder();
275
		html.addTitle(pkginfo.getName());
276
		html.addParagraph(pkginfo.getDescription());
277
		html.addBeginList();
278
		html.addListItem("code", pkginfo.getCode());
279
		html.addListItem("Organization", pkginfo.getOwner());
280
		html.addListItem("Organization URL", pkginfo.getOwnerURL());
281
		html.addListItem("Sources", pkginfo.getSourcesURL());
282
		html.addListItem("Dependencies", pkginfo.getDependencies());
283
		html.addListItem("Categories", pkginfo.getCategoriesAsString());
284
		html.addListItem("Official", pkginfo.isOfficial());
285
		html.addListItem("Signed", pkginfo.isSigned());
286
		html.addEndList();
261 287

  
262
			String categories = ((PackagesTableModel) pluginsTable.getModel())
263
					.getPackageInfoAt(row).getCategoriesAsString();
264
			if (categories == null || categories.equals("")) {
265
				categories = "";
266
			} else {
267
				categories = "<li type='circle'>Categories: " + categories
268
						+ "</li>";
269
			}
288
		descriptionTextEditor.setText(html.toString());
270 289

  
271
			// sets the html format
272
			String descriptionTextHtml = "<b>" + name + "</b>"
273
					+ "<br><font size='-1'>" + description
274
					+ "<br></font><hr /><font size='-1'>" + code + owner
275
					+ ownerUrlStr + sources + depends + categories + "</font>";
290
		// get the view area to the top-left corner
291
		descriptionTextEditor.setCaretPosition(0);
276 292

  
277
			descriptionTextEditor.setText(descriptionTextHtml);
278

  
279
			// get the view area to the top-left corner
280
			descriptionTextEditor.setCaretPosition(0);
281

  
282
		}
283 293
	}
284 294

  
285 295
	public void setFilter(PackageFilter filter) {

Also available in: Unified diff