diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index bcc667903048ca99119570a73e1bab599321125b..7dc34f7fe13d5f00a552065ac61931a906880ba8 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -9,7 +9,9 @@ import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.service.util.AbstractCyActivator; import org.osgi.framework.BundleContext; +import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager; import de.hhu.ba.yoshikoWrapper.core.Core; +import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; import de.hhu.ba.yoshikoWrapper.gui.MainPanel; import de.hhu.ba.yoshikoWrapper.gui.MainPanelAction; @@ -19,10 +21,22 @@ public class CyActivator extends AbstractCyActivator { public CyActivator() { super(); } - + @Override public void start(BundleContext context) throws Exception { - //TODO: Load shared library if installed on startup + //Initialize cytoscape configuration system + ConfigurationManager cm = new ConfigurationManager("yoshikoWrapper", "yoshiko.props"); + Properties propsReaderServiceProps = new Properties(); + propsReaderServiceProps.setProperty("cyPropertyName", "yoshiko.props"); + registerAllServices(context,cm,propsReaderServiceProps); + + + //Attempt to find the yoshiko lib in r a previously stored location + YoshikoLoader.provideConfiguration(cm); + if (!YoshikoLoader.isLibraryLoaded()){ + YoshikoLoader.loadLibrary(cm.getProperties().getProperty("pathToYoshiko")); + } + CyApplicationManager cyApplicationManager = getService(context, CyApplicationManager.class); Core.registerApplicationManager(cyApplicationManager); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java new file mode 100644 index 0000000000000000000000000000000000000000..3138cdd0cfb4f4d9c9cf29ea618357df498a3d79 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/ConfigurationManager.java @@ -0,0 +1,12 @@ +package de.hhu.ba.yoshikoWrapper.core; + +import org.cytoscape.property.AbstractConfigDirPropsReader; +import org.cytoscape.property.CyProperty; + +public class ConfigurationManager extends AbstractConfigDirPropsReader{ + + public ConfigurationManager(String appName, String fileName){ + super(appName, fileName, CyProperty.SavePolicy.CONFIG_DIR); + this.getProperties().list(System.out); + } +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java index 632f109d81f23cfa425e864318b2c72e6465f95e..7602223b14ad08acd1309505b127fae91c80795a 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/NetworkParser.java @@ -1,13 +1,9 @@ package de.hhu.ba.yoshikoWrapper.core; -import java.util.HashMap; import java.util.List; -import org.cytoscape.application.CyApplicationManager; -import org.cytoscape.model.CyColumn; import org.cytoscape.model.CyEdge; import org.cytoscape.model.CyNetwork; -import org.cytoscape.model.CyNode; import org.cytoscape.model.CyRow; import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java index dd4457f2fc6371c592dbac2f710730ea094afcce..b9a430f28def8440dc9a9bae6e8ec9d1dd46ad31 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoLoader.java @@ -1,59 +1,45 @@ package de.hhu.ba.yoshikoWrapper.core; +import java.io.File; + public class YoshikoLoader { - //SINGLETON TEMPLATE - - private static YoshikoLoader instance; private static boolean libraryLoaded; + private static ConfigurationManager cm; - public static YoshikoLoader getInstance() { - if (instance == null){ - instance = new YoshikoLoader(); - } - return instance; - } - - private YoshikoLoader() { - libraryLoaded = false; - } - - - public void loadLibrary() { + public static void loadLibrary(String libPath) { + if (libraryLoaded) { return; } - try { - System.loadLibrary("libyoshikoLibrary"); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - - public void loadLibrary(String libPath) { - if (libraryLoaded) { + + File f = new File (libPath); + if (!f.exists()) { + System.out.println("Could not find a previously saved yoshiko library path, needs to be set manually!"); return; } + try { + System.out.println("Attempting to load library @: "+libPath); System.load(libPath); + //update cfg + cm.getProperties().setProperty("pathToYoshiko", libPath); libraryLoaded = true; } - catch(UnsatisfiedLinkError e) { + catch(Exception e) { e.printStackTrace(); - libraryLoaded = false; } - finally { - - } - } //SETTER / GETTER - public boolean isLibraryLoaded() { + public static boolean isLibraryLoaded() { return libraryLoaded; } + + public static void provideConfiguration(ConfigurationManager _cm) { + cm = _cm; + } + } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java index 6a4a110d82c602c020dbd5ddb21bd61018bf318f..05a4de5ae137f03d88fc110fe3bc57fcd4620b48 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -14,7 +14,6 @@ import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; import de.hhu.ba.yoshikoWrapper.core.Core; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; -import de.hhu.ba.yoshikoWrapper.gui.*; import de.hhu.ba.yoshikoWrapper.swig.LibraryInterface; /**This class describes the Swing Panel that the user interacts with in cytoscape @@ -29,7 +28,6 @@ public class MainPanel extends JPanel implements CytoPanelComponent { private static final long serialVersionUID = 6214827920591046457L; //SYMBOLIC LINKS - private YoshikoLoader yoshikoLoader = YoshikoLoader.getInstance(); private MainPanel self = this; //for lambda function references //SWING COMPONENTS @@ -48,7 +46,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent { //SWING COMPONENT INITIALIZATION libStatusPanel = new LibStatusPanel(); - libStatusPanel.setStyle(yoshikoLoader.isLibraryLoaded()); + libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded()); this.add(libStatusPanel); searchLibButton = new JButton("SHOW YOSHIKO LIB"); @@ -59,35 +57,31 @@ public class MainPanel extends JPanel implements CytoPanelComponent { final YLibChooser c = new YLibChooser(); int returnVal = c.showOpenDialog(self); if (returnVal == JFileChooser.APPROVE_OPTION) { - yoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath()); + YoshikoLoader.loadLibrary(c.getSelectedFile().getAbsolutePath()); } - libStatusPanel.setStyle(yoshikoLoader.isLibraryLoaded()); + libStatusPanel.setStyle(YoshikoLoader.isLibraryLoaded()); yoshikoVersionLabel.setText(LibraryInterface.getVersionString()); } }); this.add(searchLibButton); - - // - // - //TODO: REMOVE IN FINAL RELEASE - JButton debugGraphActionButton = new JButton("DO MYSTERIOUS DEBUG STUFF"); - debugGraphActionButton.addActionListener(new ActionListener() { + + JButton runButton = new JButton("RUN"); + runButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - if (yoshikoLoader.isLibraryLoaded()){ + if (YoshikoLoader.isLibraryLoaded()){ Core.performYoshiko(timeLimitSetter.getTimeLimit()); } } }); - this.add(debugGraphActionButton); - // - // - // + this.add(runButton); + + timeLimitSetter = new TimeLimitSetter(); this.add(timeLimitSetter); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java index dfd80653f442620f8b97281d03ca4b6bb166752d..51cd3f4a014bb1f64772e697e636508e5307cdcd 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/NumberInputField.java @@ -1,9 +1,6 @@ package de.hhu.ba.yoshikoWrapper.gui; -import java.text.NumberFormat; - import javax.swing.JFormattedTextField; -import javax.swing.text.NumberFormatter; /** * Provides a more strict input field that only accepts integers diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java index e30530485089030d41c1cefbacb5a6724d084097..536f9a1d2e4fc6b6c8e5bb73220ce9dd72572d3e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/TimeLimitSetter.java @@ -1,6 +1,5 @@ package de.hhu.ba.yoshikoWrapper.gui; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/src/main/resources/yoshiko b/src/main/resources/yoshiko new file mode 100644 index 0000000000000000000000000000000000000000..bcecbad7d4949ff3f3d0f9c22073dce549f8ba9e --- /dev/null +++ b/src/main/resources/yoshiko @@ -0,0 +1 @@ +yoshiko.pathToYoshiko = "NO PATH SET" \ No newline at end of file