Revision: 19234
http://sourceforge.net/p/gate/code/19234
Author: markagreenwood
Date: 2016-04-12 17:50:15 +0000 (Tue, 12 Apr 2016)
Log Message:
-----------
a little tidying in the plugin manager, but more importantly loading/saving an
application now handles the new plugin mechanism while still being able to load
existing applications :)
Modified Paths:
--------------
gate/branches/sawdust2/src/main/gate/Plugin.java
gate/branches/sawdust2/src/main/gate/gui/MainFrame.java
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java
gate/branches/sawdust2/src/main/gate/util/persistence/PersistenceManager.java
Modified: gate/branches/sawdust2/src/main/gate/Plugin.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/Plugin.java 2016-04-12 12:29:08 UTC
(rev 19233)
+++ gate/branches/sawdust2/src/main/gate/Plugin.java 2016-04-12 17:50:15 UTC
(rev 19234)
@@ -11,6 +11,7 @@
import java.io.IOException;
import java.io.InputStream;
+import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -65,18 +66,18 @@
* Is the plugin valid (i.e. is the location reachable and the
* creole.xml file parsable).
*/
- protected boolean valid = true;
+ protected transient boolean valid = true;
- protected URL baseURL;
+ protected transient URL baseURL;
- protected String name;
+ protected transient String name;
/**
* The list of {@link Gate.ResourceInfo} objects.
*/
- protected List<ResourceInfo> resourceInfoList = null;
+ protected transient List<ResourceInfo> resourceInfoList = null;
- protected Set<Plugin> requiredPlugins = null;
+ protected transient Set<Plugin> requiredPlugins = null;
public abstract org.jdom.Document getCreoleXML() throws Exception,
JDOMException;
@@ -124,6 +125,8 @@
}
protected void parseCreole() {
+
+ valid = true;
resourceInfoList = new ArrayList<ResourceInfo>();
requiredPlugins = new LinkedHashSet<Plugin>();
@@ -357,7 +360,7 @@
}
}
- public static class Maven extends Plugin {
+ public static class Maven extends Plugin implements Serializable {
// TODO needs a better name that isn't tied to using Maven but talks
// more about dependency resolution
@@ -427,11 +430,11 @@
new URL("jar:"
+ artifactResult.getArtifact().getFile().toURI().toURL()
+ "!/");
- System.out.println(baseURL);
+ //System.out.println(baseURL);
// check it has a creole.xml at the root
URL directoryXmlFileUrl = new URL(baseURL, "creole.xml");
- System.out.println(directoryXmlFileUrl);
+ //System.out.println(directoryXmlFileUrl);
InputStream creoleStream = null;
Modified: gate/branches/sawdust2/src/main/gate/gui/MainFrame.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/gui/MainFrame.java 2016-04-12
12:29:08 UTC (rev 19233)
+++ gate/branches/sawdust2/src/main/gate/gui/MainFrame.java 2016-04-12
17:50:15 UTC (rev 19234)
@@ -1250,7 +1250,7 @@
@Override
public void actionPerformed(ActionEvent e) {
- // TODO Auto-generated method stub
+
JPanel panel = new JPanel(new SpringLayout());
JTextField txtGroup = new JTextField("uk.ac.gate.plugins",20);
Modified:
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java
===================================================================
---
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java
2016-04-12 12:29:08 UTC (rev 19233)
+++
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java
2016-04-12 17:50:15 UTC (rev 19234)
@@ -26,6 +26,7 @@
import gate.resources.img.svg.AvailableIcon;
import gate.resources.img.svg.GATEIcon;
import gate.resources.img.svg.InvalidIcon;
+import gate.resources.img.svg.MavenIcon;
import gate.resources.img.svg.OpenFileIcon;
import gate.resources.img.svg.RemotePluginIcon;
import gate.resources.img.svg.RemoveIcon;
@@ -394,7 +395,7 @@
private class MainTableModel extends AbstractTableModel {
- private Icon coreIcon, userIcon, remoteIcon, otherIcon, invalidIcon;
+ private Icon coreIcon, userIcon, remoteIcon, otherIcon, invalidIcon,
mavenIcon;
public MainTableModel() {
otherIcon = new OpenFileIcon(32, 32);
@@ -402,6 +403,7 @@
userIcon = new UserPluginIcon(32, 32);
remoteIcon = new RemotePluginIcon(32, 32);
invalidIcon = new InvalidIcon(32, 32);
+ mavenIcon = new MavenIcon(32, 32);
}
@Override
@@ -455,6 +457,7 @@
//return dInfo.toHTMLString();
case ICON_COLUMN:
if(!dInfo.isValid()) return invalidIcon;
+ if (dInfo instanceof Plugin.Maven) return mavenIcon;
//if(dInfo.isRemotePlugin()) return remoteIcon;
//if(dInfo.isCorePlugin()) return coreIcon;
//if(dInfo.isUserPlugin()) return userIcon;
Modified:
gate/branches/sawdust2/src/main/gate/util/persistence/PersistenceManager.java
===================================================================
---
gate/branches/sawdust2/src/main/gate/util/persistence/PersistenceManager.java
2016-04-12 12:29:08 UTC (rev 19233)
+++
gate/branches/sawdust2/src/main/gate/util/persistence/PersistenceManager.java
2016-04-12 17:50:15 UTC (rev 19234)
@@ -20,6 +20,7 @@
import gate.Gate;
import gate.LanguageAnalyser;
import gate.LanguageResource;
+import gate.Plugin;
import gate.ProcessingResource;
import gate.VisualResource;
import gate.creole.ConditionalController;
@@ -202,7 +203,17 @@
public void extractDataFromSource(Object source)
throws PersistenceException {
try {
- URL url = (URL)source;
+ URL url = null;
+
+ if (source instanceof URL) {
+ url = (URL)source;
+ }
+ else if (source instanceof Plugin.Directory) {
+ url = ((Plugin.Directory)source).getBaseURL();
+ }
+
+ if (url == null) throw new UnsupportedOperationException("Whatever you
are trying to persist isn't a URL");
+
if(url.getProtocol().equals("file")) {
// url is what we want to convert to something that is relative to
$relpath$,
// $resourceshome$ or $gatehome$
@@ -1015,7 +1026,9 @@
cleanedList.add(url);
}
}
- Object persistentList = getPersistentRepresentation(cleanedList);
+ //Object persistentList = getPersistentRepresentation(cleanedList);
+
+ Object persistentList =
getPersistentRepresentation(Gate.getCreoleRegister().getPlugins());
Object persistentObject = getPersistentRepresentation(obj);
@@ -1180,19 +1193,22 @@
try {
// first read the list of creole URLs.
@SuppressWarnings("unchecked")
- Iterator<URL> urlIter =
- ((Collection<URL>)getTransientRepresentation(ois.readObject()))
+ Iterator<?> urlIter =
+ ((Collection<?>)getTransientRepresentation(ois.readObject()))
.iterator();
// and re-register them
while(urlIter.hasNext()) {
- URL anUrl = urlIter.next();
+ Object anUrl = urlIter.next();
try {
- Gate.getCreoleRegister().registerDirectories(anUrl,false);
+ if (anUrl instanceof URL)
+ Gate.getCreoleRegister().registerPlugin(new
Plugin.Directory((URL)anUrl),false);
+ else
+ Gate.getCreoleRegister().registerPlugin((Plugin)anUrl, false);
}
catch(GateException ge) {
Err.prln("Could not reload creole directory "
- + anUrl.toExternalForm());
+ + ((URL)anUrl).toExternalForm());
ge.printStackTrace(Err.getPrintWriter());
}
}
@@ -1404,7 +1420,13 @@
registerPersistentEquivalent(VisualResource.class,
SlashDevSlashNull.class);
registerPersistentEquivalent(URL.class, URLHolder.class);
-
+
+ //for compatibility reasons we treat Plugins loaded from a directory URL
as a URL
+ registerPersistentEquivalent(Plugin.Directory.class, URLHolder.class);
+
+ //we've never supported saving registered components as plugins and we
aren't about to start now
+ registerPersistentEquivalent(Plugin.Component.class,
SlashDevSlashNull.class);
+
registerPersistentEquivalent(Map.class, MapPersistence.class);
registerPersistentEquivalent(Collection.class,
CollectionPersistence.class);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs