Revision: 19195
          http://sourceforge.net/p/gate/code/19195
Author:   markagreenwood
Date:     2016-04-04 09:14:20 +0000 (Mon, 04 Apr 2016)
Log Message:
-----------
used LinkedHashSet for plugins like we did with directories to try and keep the 
new API close to the old, also fixed the equals/hashcode for Maven plugins

Modified Paths:
--------------
    gate/branches/sawdust2/src/main/gate/CreoleRegister.java
    gate/branches/sawdust2/src/main/gate/Plugin.java
    gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
    
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java

Modified: gate/branches/sawdust2/src/main/gate/CreoleRegister.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/CreoleRegister.java    2016-04-04 
08:11:19 UTC (rev 19194)
+++ gate/branches/sawdust2/src/main/gate/CreoleRegister.java    2016-04-04 
09:14:20 UTC (rev 19195)
@@ -73,7 +73,7 @@
   @Deprecated
   public Set<URL> getDirectories();
   
-  public List<Plugin> getPlugins();
+  public Set<Plugin> getPlugins();
 
   /**
    * Given the class object for a class with {@link CreoleResource}

Modified: gate/branches/sawdust2/src/main/gate/Plugin.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/Plugin.java    2016-04-04 08:11:19 UTC 
(rev 19194)
+++ gate/branches/sawdust2/src/main/gate/Plugin.java    2016-04-04 09:14:20 UTC 
(rev 19195)
@@ -326,6 +326,38 @@
     
 
     @Override
+    public int hashCode() {
+      final int prime = 31;
+      int result = 1;
+      result = prime * result + ((artifact == null) ? 0 : artifact.hashCode());
+      result = prime * result + ((group == null) ? 0 : group.hashCode());
+      result = prime * result + ((version == null) ? 0 : version.hashCode());
+      return result;
+    }
+
+
+
+    @Override
+    public boolean equals(Object obj) {
+      if(this == obj) return true;
+      
+      if(getClass() != obj.getClass()) return false;
+      Maven other = (Maven)obj;
+      if(artifact == null) {
+        if(other.artifact != null) return false;
+      } else if(!artifact.equals(other.artifact)) return false;
+      if(group == null) {
+        if(other.group != null) return false;
+      } else if(!group.equals(other.group)) return false;
+      if(version == null) {
+        if(other.version != null) return false;
+      } else if(!version.equals(other.version)) return false;
+      return true;
+    }
+
+
+
+    @Override
     public Document getCreoleXML() throws Exception {
       Artifact artifactObj =
               new DefaultArtifact(group, artifact, "jar", version);

Modified: gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java
===================================================================
--- gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java 
2016-04-04 08:11:19 UTC (rev 19194)
+++ gate/branches/sawdust2/src/main/gate/creole/CreoleRegisterImpl.java 
2016-04-04 09:14:20 UTC (rev 19195)
@@ -86,11 +86,8 @@
 
   /** Debug flag */
   protected static final boolean DEBUG = false;
-
-  /** The set of CREOLE directories (URLs). */
-  protected Set<URL> directories;
   
-  protected List<Plugin> plugins;
+  protected Set<Plugin> plugins;
 
   /** The parser for the CREOLE directory files */
   protected transient SAXBuilder jdomBuilder = null;
@@ -112,14 +109,14 @@
   public CreoleRegisterImpl() throws GateException {
 
     // initialise the various maps
-    directories = new LinkedHashSet<URL>();
+    
     lrTypes = new HashSet<String>();
     prTypes = new HashSet<String>();
     vrTypes = new LinkedList<String>();
     toolTypes = new HashSet<String>();
     applicationTypes = new HashSet<String>();
     
-    plugins = new ArrayList<Plugin>();
+    plugins = new LinkedHashSet<Plugin>();
 
     // construct a SAX parser for parsing the CREOLE directory files
     jdomBuilder = new SAXBuilder(false);
@@ -171,7 +168,9 @@
   /** Get the list of CREOLE directory URLs. */
   @Override
   public Set<URL> getDirectories() {
-    return Collections.unmodifiableSet(directories);
+    //TODO make this work again
+    //return Collections.unmodifiableSet(directories);
+    return Collections.unmodifiableSet(new HashSet<URL>());
   }
   
   @Override
@@ -211,7 +210,7 @@
    * Register a single CREOLE directory. The <CODE>creole.xml</CODE> file at 
the
    * URL is parsed, and <CODE>CreoleData</CODE> objects added to the register.
    * If the directory URL has not yet been added it is now added. If any other
-   * plugins that nees top be loaded for this plugin to load (specified by
+   * plugins that need to be loaded for this plugin to load (specified by
    * <CODE>REQUIRES</Code> elements in <code>creole.xml</code>) will only be
    * loaded if the <code>loadDependencies</code> param is true. It is useful to
    * be able to ignore dependencies when loading an xgapp where we know they
@@ -220,7 +219,7 @@
   @Override
   public void registerDirectories(URL directoryUrl, boolean loadDependencies)
       throws GateException {
-    
+    //TODO we need to add support for the loadDependencies option to 
registerPlugin
     try {
       Plugin plugin = new Plugin.Directory(directoryUrl);
     
@@ -527,8 +526,8 @@
     prTypes.clear();
     vrTypes.clear();
     toolTypes.clear();
-    directories.clear();
     applicationTypes.clear();
+    plugins.clear();
     super.clear();
   } // clear()
 
@@ -1186,8 +1185,8 @@
   }
 
   @Override
-  public List<Plugin> getPlugins() {
-    return Collections.unmodifiableList(plugins);
+  public Set<Plugin> getPlugins() {
+    return Collections.unmodifiableSet(plugins);
   }
 
 } // class CreoleRegisterImpl

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-04 08:11:19 UTC (rev 19194)
+++ 
gate/branches/sawdust2/src/main/gate/gui/creole/manager/AvailablePlugins.java   
    2016-04-04 09:14:20 UTC (rev 19195)
@@ -545,7 +545,7 @@
 
   protected boolean unsavedChanges() {
 
-    List<Plugin> creoleDirectories = Gate.getCreoleRegister().getPlugins();
+    Set<Plugin> creoleDirectories = Gate.getCreoleRegister().getPlugins();
 
     Iterator<Plugin> pluginIter = loadNowByURL.keySet().iterator();
     while(pluginIter.hasNext()) {
@@ -570,7 +570,7 @@
 
   protected Set<Plugin> updateAvailablePlugins() {
 
-    List<Plugin> creoleDirectories = Gate.getCreoleRegister().getPlugins();
+    Set<Plugin> creoleDirectories = Gate.getCreoleRegister().getPlugins();
 
     // update the data structures to reflect the user's choices
     Iterator<Plugin> pluginIter = loadNowByURL.keySet().iterator();

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to