Revision: 14667
http://gate.svn.sourceforge.net/gate/?rev=14667&view=rev
Author: markagreenwood
Date: 2011-12-04 16:55:35 +0000 (Sun, 04 Dec 2011)
Log Message:
-----------
moved some of the info about plugins into Gate.DirectoryInfo so we only need to
calculate and store it once
Modified Paths:
--------------
gate/trunk/src/gate/Gate.java
gate/trunk/src/gate/gui/creole/manager/AvailablePlugins.java
gate/trunk/src/gate/gui/creole/manager/PluginUpdateManager.java
Modified: gate/trunk/src/gate/Gate.java
===================================================================
--- gate/trunk/src/gate/Gate.java 2011-12-04 14:49:23 UTC (rev 14666)
+++ gate/trunk/src/gate/Gate.java 2011-12-04 16:55:35 UTC (rev 14667)
@@ -47,6 +47,7 @@
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.net.URLConnection;
@@ -1314,14 +1315,63 @@
* Stores information about the contents of a CREOLE directory.
*/
public static class DirectoryInfo {
+
+ private String name, html;
+
+ private boolean core, remote;
+
+ public boolean isCorePlugin() {
+ return core;
+ }
+
+ public boolean isRemotePlugin() {
+ return remote;
+ }
+
+ public String toHTMLString() {
+ return html;
+ }
+
public DirectoryInfo(URL url) {
this.url = normaliseCreoleUrl(url);
valid = true;
resourceInfoList = new ArrayList<ResourceInfo>();
// this may invalidate it if something goes wrong
parseCreole();
+
+ remote = !this.url.getProtocol().equalsIgnoreCase("file");
+
+ core = !remote &&
(url.toString().startsWith(Gate.getPluginsHome().toURI().toString()));
+
+ html =
+ "<html><body>"
+ + getName()
+ + "<br><span style='font-size: 80%;'>"
+ + (remote ? this.url.toString() : Files.fileFromURL(
+ this.url).getAbsolutePath())
+ + "</span></body></html>";
}
+ public String getName() {
+ if(name != null) return name;
+
+ name = "";
+ try {
+ name = url.toURI().getPath();
+ } catch(URISyntaxException ex) {
+ // ignore, this should have been checked when adding the URL!
+ }
+ if(name.endsWith("/")) {
+ name = name.substring(0, name.length() - 1);
+ }
+ int lastSlash = name.lastIndexOf("/");
+ if(lastSlash != -1) {
+ name = name.substring(lastSlash + 1);
+ }
+
+ return name;
+ }
+
/**
* Performs a shallow parse of the creole.xml file to get the information
* about the resources contained.
Modified: gate/trunk/src/gate/gui/creole/manager/AvailablePlugins.java
===================================================================
--- gate/trunk/src/gate/gui/creole/manager/AvailablePlugins.java
2011-12-04 14:49:23 UTC (rev 14666)
+++ gate/trunk/src/gate/gui/creole/manager/AvailablePlugins.java
2011-12-04 16:55:35 UTC (rev 14667)
@@ -41,7 +41,6 @@
import java.awt.event.KeyEvent;
import java.io.File;
import java.net.MalformedURLException;
-import java.net.URISyntaxException;
import java.net.URL;
import java.text.Collator;
import java.util.ArrayList;
@@ -286,8 +285,7 @@
loadAlwaysByURL.clear();
visibleRows.clear();
visibleRows.addAll(Gate.getKnownPlugins());
- if (mainTable.getRowCount() > 0)
- mainTable.setRowSelectionInterval(0, 0);
+ if(mainTable.getRowCount() > 0) mainTable.setRowSelectionInterval(0, 0);
filterRows("");
}
@@ -424,16 +422,11 @@
if(dInfo == null) { return null; }
switch(column){
case NAME_COLUMN:
- return "<html><body>" + getName4URL(dInfo.getUrl())
- + "<br><span style='font-size: 80%;'>"
- + dInfo.getUrl().toString() + "</span></body></html>";
+ return dInfo.toHTMLString();
case ICON_COLUMN:
if(!dInfo.isValid()) return invalidIcon;
- if(!dInfo.getUrl().getProtocol().equalsIgnoreCase("file"))
- return remoteIcon;
- if(dInfo.getUrl().toString()
- .startsWith(Gate.getPluginsHome().toURI().toString()))
- return coreIcon;
+ if(dInfo.isRemotePlugin()) return remoteIcon;
+ if(dInfo.isCorePlugin()) return coreIcon;
File userPluginsHome = PluginUpdateManager.getUserPluginsHome();
if(userPluginsHome != null
&& dInfo.getUrl().toString()
@@ -449,24 +442,6 @@
}
}
- private String getName4URL(URL url) {
- String path = "";
- try {
- path = url.toURI().getPath();
- } catch(URISyntaxException ex) {
- // ignore, this should have been checked when adding the URL!
- }
- if(path.endsWith("/")) {
- path = path.substring(0, path.length() - 1);
- }
- int lastSlash = path.lastIndexOf("/");
- if(lastSlash == -1) {
- return path;
- } else {
- return path.substring(lastSlash + 1);
- }
- }
-
@Override
public boolean isCellEditable(int row, int column) {
Gate.DirectoryInfo dInfo = Gate.getDirectoryInfo(visibleRows.get(row));
Modified: gate/trunk/src/gate/gui/creole/manager/PluginUpdateManager.java
===================================================================
--- gate/trunk/src/gate/gui/creole/manager/PluginUpdateManager.java
2011-12-04 14:49:23 UTC (rev 14666)
+++ gate/trunk/src/gate/gui/creole/manager/PluginUpdateManager.java
2011-12-04 16:55:35 UTC (rev 14667)
@@ -178,8 +178,6 @@
new Thread() {
@Override
public void run() {
- // TODO why was this called here?
- // installed.reInit();
// reset the info ready for a reload
availableModel.data.clear();
updatesModel.data.clear();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs