diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/CyUtilities.java b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/CyUtilities.java new file mode 100644 index 0000000000000000000000000000000000000000..c01e49bbcfd8a67aed747028f352ef74aa9c095c --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/CyUtilities.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (C) 2018 Philipp Spohr + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ + +package de.hhu.ba.yoshikoWrapper.cytoUtil; + + +import java.awt.Component; + +import org.cytoscape.application.swing.CytoPanel; +import org.cytoscape.application.swing.CytoPanelComponent; +import org.cytoscape.application.swing.CytoPanelName; + +import de.hhu.ba.yoshikoWrapper.core.CyCore; + +/** + * Helper functions that simplify the Cytoscape API that haven't found a home in any other class + * + */ +public class CyUtilities { + + /** + * Selects the tab containing the CyBrowser in the result panel if such a tab exists + */ + public static void highlightCyBrowser() { + //We retrieve the result panel + CytoPanel resultPanel = CyCore.swing.getCytoPanel(CytoPanelName.EAST); + for (int i= 0; i< resultPanel.getCytoPanelComponentCount(); i++) { + Component component = resultPanel.getComponentAt(i); + if (component instanceof CytoPanelComponent) { + CytoPanelComponent cmp = (CytoPanelComponent) component; + if (cmp.getTitle().equals("CyBrowser")) { + resultPanel.setSelectedIndex(i); + return; + } + } + + } +// int index = resultPanel.indexOfComponent("edu.ucsf.rbvi.cyBrowser.internal.view.ResultsPanelBrowser"); +// if (index != -1) { +// resultPanel.setSelectedIndex(index); +// } +// else { +// //TODO: Output something? +// System.err.println("Failed to identify CyBrowser tab"); +// } + } + +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/NodeMap.java b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/NodeMap.java index 6406ac9822cc8a74a87f5315912fe60db287bb74..c822caa421c04aff86c5e422c17495695bd1fc88 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/NodeMap.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/NodeMap.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2017 Philipp Spohr + * Copyright (C) 2018 Philipp Spohr * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/StyleManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/StyleManager.java index b5eccc11a43f51ec3f43564f8703caa8f044c3eb..48c8d13dcc6a4f972c6bd1cfe57db55b39b6263e 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/StyleManager.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/cytoUtil/StyleManager.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (C) 2017 Philipp Spohr + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.cytoUtil; import java.util.List; diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/help/HelpLinks.java b/src/main/java/de/hhu/ba/yoshikoWrapper/help/HelpLinks.java index edefa932dce4a11925351be112944e59ae126a01..90537e42aea974c3c7b1a9e18beeda63d4f6998b 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/help/HelpLinks.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/help/HelpLinks.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (C) 2017 Philipp Spohr + * Copyright (C) 2018 Philipp Spohr * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -22,10 +22,11 @@ package de.hhu.ba.yoshikoWrapper.help; import java.util.HashMap; +import java.util.Map; public final class HelpLinks { - public static final HashMap<String,Object> mainInfo = new HashMap<String,Object>(); + public static final Map<String, Object> mainInfo = new HashMap<String,Object>(); static { mainInfo.put("url", "file:///home/philipp/workspace/cs/cytoscape-tutorials/presentations/yoshiko.html"); //mainInfo.put("url", "https://spqrph.github.io/cytoscape-tutorials/presentations/yoshiko.html#/title"); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java index fc2dc1887274ab61b759b955382d35cee3c300ed..f349637db103d42bce956ae53e1e0a64bc7a011f 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/swing/components/HelpButton.java @@ -1,3 +1,24 @@ +/******************************************************************************* + * Copyright (C) 2018 Philipp Spohr + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + ******************************************************************************/ package de.hhu.ba.yoshikoWrapper.swing.components; import java.awt.event.ActionEvent; @@ -12,6 +33,7 @@ import javax.swing.JButton; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.cytoUtil.CommandExecutor; +import de.hhu.ba.yoshikoWrapper.cytoUtil.CyUtilities; import de.hhu.ba.yoshikoWrapper.help.HelpLinks; import de.hhu.ba.yoshikoWrapper.swing.GraphicsLoader; @@ -34,7 +56,9 @@ public class HelpButton extends JButton{ private static final ImageIcon hlIcon = GraphicsLoader.getInfoIconHL(SIZE); - + /** + * Default Constructor, creates a JButton that opens the help section in CyBrowser + */ public HelpButton() { super(defaultIcon); @@ -48,8 +72,9 @@ public class HelpButton extends JButton{ new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - CommandExecutor.executeCommand("cybrowser", "show",HelpLinks.mainInfo , null); + //Workaround to instantly select/highlight the CyBrowser tab + CyUtilities.highlightCyBrowser(); } } ); diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java index 1f252f95c85a0038134f0717efd2e7816061b5ea..bf314c9f8e136816f05a95713a56c1c255dce017 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/tasks/AlgorithmTask.java @@ -293,7 +293,7 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask, Tunab public void cancel() { //Free C++ resources if (c_algorithm != null) { - System.out.println("Deleting CoreAlgorithm instance!"); + //System.out.println("Deleting CoreAlgorithm instance!"); c_algorithm.cancel(); c_algorithm.delete(); }