Permalink
Browse files

fix GraphViz Adapter for Linux and show install instruction

  • Loading branch information...
Zasch committed Oct 22, 2014
1 parent 70166ba commit dea69ba3267109adbe0d10eda19277fb40396ae4
Showing with 34 additions and 23 deletions.
  1. +5 −1 Adapter/GraphViz/Java/org/sdmlib/doc/GraphViz.java
  2. +29 −22 src/main/java/org/sdmlib/doc/GraphFactory.java
@@ -165,7 +165,11 @@ public boolean drawImg(String imgName, String context)
}
catch (Exception e)
{
- e.printStackTrace();
+ System.err.println("Can't run GraphViz: "+ e.getMessage());
+ if("linux".equals(System.getProperty("os.name").toLowerCase())){
+ System.err.println("Please install GraphViz: "+ "apt-get install graphviz");
+ }
+ //e.printStackTrace();
}
return true;
}
@@ -1,6 +1,7 @@
package org.sdmlib.doc;
import java.io.File;
+import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
@@ -67,7 +68,7 @@ public void generate(String path) {
rootPath = rootPath.substring(0, rootPath.length() - 1);
}
if (rootPath.length()>0 && !(rootPath.endsWith("\\") || rootPath.endsWith("/"))) {
- rootPath += "/";
+ rootPath += File.separator;
}
ArrayList<URL> plugins = new ArrayList<URL>();
for (File item : dir.listFiles()) {
@@ -94,8 +95,11 @@ public void generate(String path) {
if (libPath.startsWith("file:\\")) {
libPath = libPath.substring(6);
}
- if (!(libPath.endsWith("\\") || libPath.endsWith("/"))) {
- libPath += "/";
+ if (libPath.startsWith("file:/")) {
+ libPath = libPath.substring(5);
+ }
+ if (!(libPath.endsWith(File.separator))) {
+ libPath += File.separator;
}
if (libPath.startsWith(rootPath)) {
@@ -106,7 +110,6 @@ public void generate(String path) {
public void loadPlugins(List<URL> plugins) {
- try {
URLClassLoader ucl = new URLClassLoader(plugins.toArray(new URL[plugins.size()]), this.getClass().getClassLoader());
for (URL plugin : plugins) {
@@ -128,25 +131,29 @@ public void loadPlugins(List<URL> plugins) {
if (name.indexOf("_")>0) {
name = name.substring(0, name.indexOf("_"));
}
- Class<?> c = ucl.loadClass("org.sdmlib.doc." + name);
- Object p =c.newInstance();
- if( p instanceof GuiAdapter){
- this.with((GuiAdapter)p);
- }else if(p instanceof GuiFileDrawer){
- GuiFileDrawer drawer = (GuiFileDrawer) p;
- ArrayList<GuiAdapter> adapters = getAdapters();
- for(GuiAdapter item : adapters){
- if(item.getName().equalsIgnoreCase(name)){
- item.withDrawer(drawer);
- drawer.withPlugin(new File(path), plugin.getPath());
- }
- }
- }
+ try {
+ Class<?> c = ucl.loadClass("org.sdmlib.doc." + name);
+ Object p =c.newInstance();
+ if( p instanceof GuiAdapter){
+ this.with((GuiAdapter)p);
+ }else if(p instanceof GuiFileDrawer){
+ GuiFileDrawer drawer = (GuiFileDrawer) p;
+ ArrayList<GuiAdapter> adapters = getAdapters();
+ for(GuiAdapter item : adapters){
+ if(item.getName().equalsIgnoreCase(name)){
+ item.withDrawer(drawer);
+ drawer.withPlugin(new File(path), plugin.getPath());
+ }
+ }
+ }
+ } catch (Exception e) {
+ //e.printStackTrace();
+ }
}
- ucl.close();
- } catch (Exception e) {
- //e.printStackTrace();
- }
+ try {
+ ucl.close();
+ } catch (IOException e) {
+ }
}
public ArrayList<GuiAdapter> getAdapters()

0 comments on commit dea69ba

Please sign in to comment.