diff --git a/.gitignore b/.gitignore index f6eef68764e006bfd771c54e32cbcaa1e9efa6fc..aa8cbea7d01dec00f51954921c6ab6d2e10fd6f5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ /.settings/org.eclipse.jdt.core.prefs /bin/de /.gradle/ +*.eclipse.m2e.core.prefs diff --git a/pom.xml b/pom.xml index f12c3a6c5af44da5ca9345d575bfc866d0d497f1..0834ba6988575e4f88bf9bcc4d014533ba4c589f 100644 --- a/pom.xml +++ b/pom.xml @@ -2,8 +2,8 @@ <modelVersion>4.0.0</modelVersion> <properties> - <bundle.symbolicName>org.cytoscape.sample-control-panel</bundle.symbolicName> - <bundle.namespace>org.cytoscape.sample.internal</bundle.namespace> + <bundle.symbolicName>de.hhu.ba.yoshikoWrapper</bundle.symbolicName> + <bundle.namespace>de.hhu.ba.yoshikoWrapper</bundle.namespace> <cytoscape.api.version>3.0.0</cytoscape.api.version> <maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version> diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/internal/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java similarity index 91% rename from src/main/java/de/hhu/ba/yoshikoWrapper/internal/CyActivator.java rename to src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index 76e6dc2fc5cd516d3a8c048b4b2c89b581c26627..7cabdf8b74f8508349346356cfbb2c980e0cb32d 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/internal/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -1,4 +1,4 @@ -package de.hhu.ba.yoshikoWrapper.internal; +package de.hhu.ba.yoshikoWrapper; import java.util.Properties; @@ -9,6 +9,7 @@ import org.cytoscape.service.util.AbstractCyActivator; import org.osgi.framework.BundleContext; import de.hhu.ba.yoshikoWrapper.gui.MainPanel; +import de.hhu.ba.yoshikoWrapper.gui.MainPanelAction; public class CyActivator extends AbstractCyActivator { diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoInterface.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoInterface.java new file mode 100644 index 0000000000000000000000000000000000000000..736716d19370d21b96caef1b2dab0caea99ba986 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/YoshikoInterface.java @@ -0,0 +1,43 @@ +package de.hhu.ba.yoshikoWrapper.core; + +public class YoshikoInterface { + + //SINGLETON TEMPLATE + + private static YoshikoInterface instance; + private static boolean libraryLoaded; + + public static YoshikoInterface getInstance() { + if (instance == null){ + instance = new YoshikoInterface(); + } + return instance; + } + + private YoshikoInterface() { + libraryLoaded = false; + } + + + public void loadLibrary(String libPath) { + try { + System.loadLibrary(libPath); + libraryLoaded = true; + } + catch(Exception e) { + e.printStackTrace(); + libraryLoaded = false; + } + finally { + + } + + } + + //SETTER / GETTER + + public boolean isLibraryLoaded() { + return libraryLoaded; + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/package-info.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..93b406c8378c0ca6f3c9bcaf520d69ba105153e4 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author Philipp Spohr, Aug 6, 2017 + * + */ +package de.hhu.ba.yoshikoWrapper.core; \ No newline at end of file diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java new file mode 100644 index 0000000000000000000000000000000000000000..82e0e9618c10b5e952d6157d23bfeb522a2fe478 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/LibStatusPanel.java @@ -0,0 +1,21 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import javax.swing.JLabel; + +public class LibStatusPanel extends JLabel { + + /** + * + */ + private static final long serialVersionUID = 6178348169993497344L; + + public void setStyle(boolean libraryLoaded) { + if(libraryLoaded) { + this.setText("YOSHIKO LOADED: TRUE"); + } + else { + this.setText("YOSHIKO LOADED: FALSE"); + } + } + +} 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 99bc8522e2ef12fb74b1b4da623133444e6d2997..f1e511d526150329690220f37d472cb854450810 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -1,13 +1,18 @@ package de.hhu.ba.yoshikoWrapper.gui; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import javax.swing.Icon; +import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JPanel; import org.cytoscape.application.swing.CytoPanelComponent; import org.cytoscape.application.swing.CytoPanelName; +import de.hhu.ba.yoshikoWrapper.core.YoshikoInterface; + /**This class describes the Swing Panel that the user interacts with in cytoscape * @author Philipp Spohr, Aug 6, 2017 * @@ -18,16 +23,41 @@ public class MainPanel extends JPanel implements CytoPanelComponent { * Unique identifier for serialization */ private static final long serialVersionUID = 6214827920591046457L; - + + //SYMBOLIC LINKS + private YoshikoInterface yoshikoInterface = YoshikoInterface.getInstance(); + private MainPanel self = this; //for lambda function references + //SWING COMPONENTS + + private LibStatusPanel libStatusPanel; + private JButton searchLibButton; /** * Main constructor, creates a new Panel and intializes subcomponents */ public MainPanel() { - JFileChooser yoshikoNativeChooser = new JFileChooser(); + //SWING COMPONENT INITIALIZATION + + libStatusPanel = new LibStatusPanel(); + libStatusPanel.setStyle(yoshikoInterface.isLibraryLoaded()); + this.add(libStatusPanel); + + searchLibButton = new JButton("SHOW YOSHIKO LIB"); + searchLibButton.addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + final YLibChooser c = new YLibChooser(); + int returnVal = c.showOpenDialog(self); + if (returnVal == JFileChooser.APPROVE_OPTION) { + yoshikoInterface.loadLibrary(c.getSelectedFile().getAbsolutePath()); + } + } + + }); + this.add(searchLibButton); - this.add(yoshikoNativeChooser); this.setVisible(true); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/internal/MainPanelAction.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanelAction.java similarity index 92% rename from src/main/java/de/hhu/ba/yoshikoWrapper/internal/MainPanelAction.java rename to src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanelAction.java index 42f3103a67036b89804aeffd3058cff2899b37b5..34b8cb7ee60394be31b85a57d384bf5130797674 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/internal/MainPanelAction.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanelAction.java @@ -1,4 +1,4 @@ -package de.hhu.ba.yoshikoWrapper.internal; +package de.hhu.ba.yoshikoWrapper.gui; import java.awt.event.ActionEvent; @@ -7,8 +7,6 @@ import org.cytoscape.application.swing.CySwingApplication; //import org.cytoscape.application.swing.CytoPanel; //import org.cytoscape.application.swing.CytoPanelName; -import de.hhu.ba.yoshikoWrapper.gui.MainPanel; - public class MainPanelAction extends AbstractCyAction { /** diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YLibChooser.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YLibChooser.java new file mode 100644 index 0000000000000000000000000000000000000000..176ec96476cec2782e1e9be3b2353d08ba67fe12 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/YLibChooser.java @@ -0,0 +1,39 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import java.io.File; + +import javax.swing.JFileChooser; +import javax.swing.filechooser.FileFilter; + +/**Implementation of the JFileChooser that limits choices to shared library + * TODO: Perform basic sanity checks on the selected file (Checksum?) + * @author Philipp Spohr, Aug 6, 2017 + * + */ +public class YLibChooser extends JFileChooser { + /** + * + */ + private static final long serialVersionUID = -2528894543739757962L; + + /** + * Default constructor + */ + public YLibChooser() { + super(); + this.setFileFilter(new FileFilter() { + + @Override + public boolean accept(File f) { + //TODO + return true; + } + + @Override + public String getDescription() { + return "Compiled Yoshiko-Libraries"; + } + + }); + } +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java new file mode 100644 index 0000000000000000000000000000000000000000..312d9193351f22fd2d291114f1927339abba7452 --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/package-info.java @@ -0,0 +1,8 @@ +/** + * + */ +/** + * @author Philipp Spohr, Aug 6, 2017 + * + */ +package de.hhu.ba.yoshikoWrapper.gui; \ No newline at end of file