001 // GraphLab Project: http://graphlab.sharif.edu 002 // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology 003 // Distributed under the terms of the GNU General Public License (GPL): http://www.gnu.org/licenses/ 004 package graphlab.plugins; 005 006 007 //import graphlab.extensions.graphactions.GeneralizedPetersonIndepSetListerAction; 008 import graphlab.extensions.io.LatexCAD; 009 import graphlab.extensions.io.LatexWriter; 010 import graphlab.extensions.io.LoadSimpleGraph; 011 import graphlab.extensions.io.SaveSimpleGraph; 012 import graphlab.extensions.reports.MaxIndependentSetReport; 013 import graphlab.extensions.reports.ColoringReport; 014 import graphlab.extensions.actions.LineGraph; 015 import graphlab.extensions.actions.GraphPower; 016 import graphlab.platform.Application; 017 import graphlab.platform.GSplash; 018 import graphlab.platform.StaticUtils; 019 import graphlab.platform.core.BlackBoard; 020 import graphlab.platform.core.exception.ExceptionOccuredData; 021 import graphlab.platform.extension.Extension; 022 import graphlab.platform.extension.ExtensionClassLoader; 023 import graphlab.platform.extension.ExtensionLoader; 024 import graphlab.platform.preferences.Preferences; 025 import graphlab.samples.extensions.BinaryTreeGenerator; 026 027 import java.io.File; 028 import java.net.MalformedURLException; 029 import java.net.URL; 030 import java.net.URLClassLoader; 031 032 033 /** 034 * this class creathed ONLY for test reasons, don't mistake it with main class of program which is GraphLab. 035 * GraphLab loads the plugins from the jar files in the plugins directory, but in graphlab they are loaded manually 036 * both of them load plugins from their setBlackBoard file setBlackBoard() method, the GraphLabDebugger class 037 * is for test purposes, so if you want to debug your plugins just load it manually like 038 * other plugins in the run method,... try to load it as the last plugin for avoiding dependency problems 039 * 040 * @author azin azadi 041 * @see graphlab.platform.Application 042 */ 043 public class GraphLabDebugger extends Application { 044 public void run(BlackBoard b) { 045 // try { 046 // UIManager.setLookAndFeel(); 047 // } catch (Exception e) { 048 // e.printStackTrace(); 049 // } 050 try { 051 // plugger = new Plugger(b); 052 Preferences p = new Preferences(b); 053 GSplash gs = new GSplash(); 054 gs.showMessages(); 055 b.setData("SETTINGS", SETTINGS); 056 057 new graphlab.plugins.main.Init().init(b); 058 new graphlab.plugins.commandline.Init().init(b); 059 new graphlab.plugins.visualization.Init().init(b); 060 new graphlab.plugins.algorithmanimator.Init().init(b); 061 new graphlab.plugins.reports.Init().init(b); 062 new graphlab.plugins.graphgenerator.Init().init(b); 063 new graphlab.plugins.commonplugin.Init().init(b); 064 new graphlab.plugins.connector.Init().init(b); 065 new graphlab.plugins.automaticupdator.Init().init(b); 066 067 // new graphlab.plugins.metrics.Init().init(b); 068 // new graphlab.plugins.manageplugins.Init().init(b); 069 // new graphlab.plugins.developeplugin.Init().init(b); 070 // new graphlab.plugins.search.Init().init(b); 071 072 // new graphlab.plugins.main.hibernate.Init().init(b); 073 // new graphlab.plugins.zinoo.Init().init(b); 074 loadExtensions(b); 075 076 // loading Extensions 077 StaticUtils.loadSingleExtension(MaxIndependentSetReport.class); 078 // StaticUtils.loadSingleExtension(RadiusReport.class); 079 StaticUtils.loadSingleExtension(LineGraph.class); 080 // StaticUtils.loadSingleExtension(TotalGraph1.class); 081 StaticUtils.loadSingleExtension(GraphPower.class); 082 StaticUtils.loadSingleExtension(LoadSimpleGraph.class); 083 StaticUtils.loadSingleExtension(SaveSimpleGraph.class); 084 // StaticUtils.loadSingleExtension(GeneralizedPetersonIndepSetListerAction.class); 085 StaticUtils.loadSingleExtension(LatexWriter.class); 086 StaticUtils.loadSingleExtension(LatexCAD.class); 087 StaticUtils.loadSingleExtension(BinaryTreeGenerator.class); 088 // StaticUtils.loadSingleExtension(ColoringReport.class); 089 b.setData(POST_INIT_EVENT, "Pi"); 090 // UI.getGFrame(b).setTitle("GraphLab"); 091 gs.setVisible(false); 092 gs.stopShowing(); 093 094 // Thread.sleep(1000); 095 096 } catch (Throwable e) { 097 e.printStackTrace(); 098 ExceptionOccuredData bod = new ExceptionOccuredData(e); 099 b.setData(ExceptionOccuredData.EVENT_KEY, bod); 100 } 101 } 102 103 // public void loadExtensions(BlackBoard blackboard) { 104 //// try { 105 //// ExtensionClassLoader.cl = new URLClassLoader(new URL[]{new File("extensions").toURL()}, ClassLoader.getSystemClassLoader());// plugger.classLoader; 106 //// } catch (MalformedURLException e) { 107 //// e.printStackTrace(); 108 //// } 109 // 110 ////---------------- 111 //// String dir = "extensions"; 112 //// loadexts(dir, blackboard); 113 //// loadexts("graphlab\\extensions", blackboard); 114 // 115 // } 116 117 private void loadexts(String dir, BlackBoard blackboard) { 118 ExtensionClassLoader e = new ExtensionClassLoader(dir); 119 for (String c : e.classesData.keySet()) { 120 try { 121 Class s = ExtensionClassLoader.cl.loadClass(c); 122 StaticUtils.loadSingleExtension(s); 123 } catch (ClassNotFoundException e1) { 124 e1.printStackTrace(); 125 } 126 // for (Class c:e.getLoadedClasses()) { 127 } 128 for (File f : e.getUnknownFilesFound()) { 129 Extension extension = ExtensionLoader.loadUnknownExtension(f, blackboard); 130 ExtensionLoader.handleExtension(blackboard, extension); 131 } 132 } 133 134 135 protected URLClassLoader getExtensionsClassLoader() { 136 try { 137 return new URLClassLoader(new URL[]{new File("extensions").toURL()}); 138 } catch (MalformedURLException e) { 139 e.printStackTrace(); 140 } 141 return null; 142 } 143 144 public static void main(String[] args) { 145 new GraphLabDebugger().init(); 146 } 147 }