diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java index 0a088f54021c7bf0cf2362aacc42e23a75987b6b..8e191251462d26a204bc594b579bc4a30f65a812 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/CyActivator.java @@ -52,9 +52,11 @@ import org.osgi.framework.BundleContext; import de.hhu.ba.yoshikoWrapper.core.ConfigurationManager; import de.hhu.ba.yoshikoWrapper.core.CyCore; +import de.hhu.ba.yoshikoWrapper.core.Hint; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.NetChangeListener; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; +import de.hhu.ba.yoshikoWrapper.gui.HintManager; import de.hhu.ba.yoshikoWrapper.gui.MainPanel; public class CyActivator extends AbstractCyActivator { @@ -115,6 +117,8 @@ public class CyActivator extends AbstractCyActivator { registerService(context,netChangeListener, ColumnDeletedListener.class, new Properties()); registerService(context,netChangeListener, SessionLoadedListener.class, new Properties()); registerService(context,netChangeListener, SetCurrentNetworkListener.class, new Properties()); + + HintManager.showMappingHint(Hint.FIRST_START); } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java index 803d3ee74546377edfc4b2bd82ee2c3a8d8ed81e..8c6462b90370e74a428acd496480cb223cbb19c1 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/CyCore.java @@ -64,6 +64,10 @@ public class CyCore { public static ApplyVisualStyleTaskFactory applyVisualStyleTaskFactory; public static RenderingEngineFactory<CyNetwork> renderingEngineFactory; public static CloneNetworkTaskFactory cloneNetworkTaskFactory; - // + + //Convenience + public static String getConfig(String key) { + return cm.getProperties().getProperty(key); + } } diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/core/Hint.java b/src/main/java/de/hhu/ba/yoshikoWrapper/core/Hint.java new file mode 100644 index 0000000000000000000000000000000000000000..c916fe6d8b68edee465b7f7fac61758fbdcd134f --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/core/Hint.java @@ -0,0 +1,6 @@ +package de.hhu.ba.yoshikoWrapper.core; + +public enum Hint { + USE_MAPPING, + FIRST_START +} diff --git a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/HintManager.java b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/HintManager.java new file mode 100644 index 0000000000000000000000000000000000000000..09296f68d42fcc5afc5fb96eb38d08fd466c73be --- /dev/null +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/HintManager.java @@ -0,0 +1,74 @@ +package de.hhu.ba.yoshikoWrapper.gui; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import javax.swing.JOptionPane; + +import org.slf4j.Logger; + +import de.hhu.ba.yoshikoWrapper.core.CyCore; +import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader; +import de.hhu.ba.yoshikoWrapper.core.Hint; +import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; +import de.hhu.ba.yoshikoWrapper.logging.YoshikoLogger; + +/** + * Bothers the user with useful hints + * + */ +public class HintManager { + + private static Logger logger = YoshikoLogger.getInstance().getLogger(); + + private static final Runnable useMappingHint = new Runnable() { + + @Override + public void run() { + JOptionPane.showMessageDialog(null, LocalizationManager.get("noMappingHint"), LocalizationManager.get("yoshikoHint"),JOptionPane.INFORMATION_MESSAGE); + } + + }; + + private static final Runnable firstStart = new Runnable() { + + @Override + public void run() { + JOptionPane.showMessageDialog(null, LocalizationManager.get("firstStart"), "Yoshiko Welcome", JOptionPane.INFORMATION_MESSAGE, GraphicsLoader.getLogo(40)); + } + + }; + + private final static Map<Hint,Runnable> hints; + + static { + Map<Hint, Runnable> map = new HashMap<Hint,Runnable>(); + map.put(Hint.USE_MAPPING, useMappingHint); + map.put(Hint.FIRST_START, firstStart); + hints = Collections.unmodifiableMap(map); + } + + public static void showMappingHint(Hint hint) { + if ( + CyCore.getConfig( + hint.toString()+"shown" + ) == null + ) + { + + //Save property so we dont show this again + CyCore.cm.getProperties().setProperty(hint.toString()+ "shown", "1"); + if (hints.get(hint) != null) { + hints.get(hint).run(); + } + else { + logger.warn("Asked for a hint that doesnt exist with hint name: "+hint.toString()); + } + + } + } + + + +} 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 52e530c8a1134bc7fe80b304d1f1f3edb31f3e19..6b8f7f48d542d1d6cfa934a468aac8b51e4c8261 100644 --- a/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java +++ b/src/main/java/de/hhu/ba/yoshikoWrapper/gui/MainPanel.java @@ -52,6 +52,7 @@ import org.cytoscape.work.TaskIterator; import de.hhu.ba.yoshikoWrapper.core.AlgorithmTask; import de.hhu.ba.yoshikoWrapper.core.CyCore; import de.hhu.ba.yoshikoWrapper.core.GraphicsLoader; +import de.hhu.ba.yoshikoWrapper.core.Hint; import de.hhu.ba.yoshikoWrapper.core.LocalizationManager; import de.hhu.ba.yoshikoWrapper.core.ParameterSet; import de.hhu.ba.yoshikoWrapper.core.YoshikoLoader; @@ -211,6 +212,12 @@ public class MainPanel extends JPanel implements CytoPanelComponent { //SWING BLACK MAGIC if (YoshikoLoader.isLibraryLoaded()){ + + //User has mapped no values -> Annoy him + if (ecPanel.getWeightColumn() == null) { + HintManager.showMappingHint(Hint.USE_MAPPING); + } + AbstractTask yoshiko = new AlgorithmTask( popupLevel, CyCore.cy.getCurrentNetwork(), diff --git a/src/main/resources/YoshikoStrings.properties b/src/main/resources/YoshikoStrings.properties index d1693163ec21a441a8968433d59a1ce9b769285e..16b9988d9b851d4db6d0a416dc424b39b96608e6 100644 --- a/src/main/resources/YoshikoStrings.properties +++ b/src/main/resources/YoshikoStrings.properties @@ -63,4 +63,7 @@ timeoutMarker = Timed Out gap = Gap currentGap = [ILP] Current Instance Gap: disableMultiThreading = Disable Multithreading +yoshikoHint = Yoshiko Hint getYoshiko = Get Yoshiko Library +noMappingHint = You haven't mapped the cost value to a column in your edge table.\nYoshiko runs significantly faster and generates better solutions if you map values. +firstStart = Thanks for using the Yoshiko Clustering Tool!\nIt appears, that this is your first time using this tool.\nIf you want an in-depth explanation of the algorithm please refer to: [INSERT COOL LINK HERE] \ No newline at end of file