use of org.meteoinfo.ui.plugin.IPlugin in project MeteoInfo by meteoinfo.
the class FrmMain method loadApplication.
/**
* Load an application
*
* @param plugin Application
*/
public void loadApplication(Application plugin) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
try {
PythonInterpreter interp = this.getConsoleDockable().getInterpreter();
String path = plugin.getPath();
interp.exec("import " + path);
interp.exec("from " + path + ".loadApp import LoadApp");
PyObject loadClass = interp.get("LoadApp");
PyObject loadObj = loadClass.__call__();
IPlugin instance = (IPlugin) loadObj.__tojava__(IPlugin.class);
instance.setApplication(FrmMain.this);
instance.setName(plugin.getName());
plugin.setPluginObject(instance);
plugin.setLoad(true);
instance.load();
} catch (Exception e) {
e.printStackTrace();
}
this.setCursor(Cursor.getDefaultCursor());
}
use of org.meteoinfo.ui.plugin.IPlugin in project MeteoInfo by meteoinfo.
the class FrmAppsManager method readPyApp.
// GEN-LAST:event_formWindowClosed
public Application readPyApp(String path, String fileName) {
try {
Application plugin = new Application();
plugin.setPath(path);
plugin.setClassName("LoadApp");
PythonInterpreter interp = this.parent.getConsoleDockable().getInterpreter();
interp.exec("import " + path);
interp.exec("from " + path + ".loadApp import LoadApp");
PyObject loadClass = interp.get("LoadApp");
PyObject loadObj = loadClass.__call__();
IPlugin instance = (IPlugin) loadObj.__tojava__(IPlugin.class);
plugin.setPluginObject(instance);
return plugin;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of org.meteoinfo.ui.plugin.IPlugin in project MeteoInfo by meteoinfo.
the class FrmAppsManager method readApplication.
public Application readApplication(String jarFileName) {
try {
Application plugin = new Application();
plugin.setPath(jarFileName);
String className = GlobalUtil.getPluginClassName(jarFileName);
if (className == null) {
return null;
} else {
plugin.setClassName(className);
URL url = new URL("file:" + plugin.getPath());
URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { url });
Class<?> clazz = urlClassLoader.loadClass(plugin.getClassName());
IPlugin instance = (IPlugin) clazz.newInstance();
plugin.setPluginObject(instance);
return plugin;
}
} catch (MalformedURLException ex) {
Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(FrmMain.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
Aggregations