Commit b9c1a47d authored by Tobias Meuser's avatar Tobias Meuser Committed by Jose Ignacio Monreal Bailey
Browse files

Made selection of active layers persisent

parent 0d921e5e
...@@ -26,14 +26,15 @@ import java.util.List; ...@@ -26,14 +26,15 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JMenu;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.SimControlPanel;
import de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationComponent; import de.tud.kom.p2psim.impl.topology.views.visualization.ui.VisualizationComponent;
import de.tud.kom.p2psim.impl.util.guirunner.Config;
/** /**
* This manager keeps track of all components that are added to the UI. It can * This manager keeps track of all components that are added to the UI. It can
...@@ -148,8 +149,14 @@ public class ComponentVisManager { ...@@ -148,8 +149,14 @@ public class ComponentVisManager {
* @param component * @param component
*/ */
public void toggleComponent(String name) { public void toggleComponent(String name) {
boolean first = true;
for (JComponent component : nameToComponentMap.get(name)) { for (JComponent component : nameToComponentMap.get(name)) {
toggleComponent(component); toggleComponent(component);
if (first) {
Config.setValue(SimControlPanel.getConfMainPath(name), component.isVisible());
first = false;
}
} }
} }
......
...@@ -43,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza ...@@ -43,6 +43,7 @@ import de.tud.kom.p2psim.impl.topology.views.VisualizationTopologyView.Visualiza
import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager; import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager;
import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisInfo; import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisInfo;
import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisualizationListener; import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.VisualizationListener;
import de.tud.kom.p2psim.impl.util.guirunner.Config;
/** /**
* Menu-Bar containing means to alter the simulation speed, pause and un-pause * Menu-Bar containing means to alter the simulation speed, pause and un-pause
...@@ -51,8 +52,9 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.V ...@@ -51,8 +52,9 @@ import de.tud.kom.p2psim.impl.topology.views.visualization.ComponentVisManager.V
* @author Bjoern Richerzhagen * @author Bjoern Richerzhagen
* @version 1.0, 27.08.2012 * @version 1.0, 27.08.2012
*/ */
public class SimControlPanel extends JMenuBar public class SimControlPanel extends JMenuBar implements ActionListener, ChangeListener, VisualizationListener {
implements ActionListener, ChangeListener, VisualizationListener {
private static final String CONF_PATH = "GUIRunner/Menu/Layels/";
private static final long serialVersionUID = -914578954798611308L; private static final long serialVersionUID = -914578954798611308L;
...@@ -119,7 +121,14 @@ public class SimControlPanel extends JMenuBar ...@@ -119,7 +121,14 @@ public class SimControlPanel extends JMenuBar
@Override @Override
public void visualizationAdded(VisInfo visInfo) { public void visualizationAdded(VisInfo visInfo) {
JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(visInfo.getName()); JCheckBoxMenuItem checkBox = new JCheckBoxMenuItem(visInfo.getName());
checkBox.setSelected(visInfo.isActiveByDefault()); boolean isActive = visInfo.isActiveByDefault();
isActive = Config.getValue(getConfMainPath(visInfo.getName()), isActive);
checkBox.setSelected(isActive);
if (!isActive) {
getVisManager().deactivateComponent(visInfo.getName());
}
checkBox.addActionListener(new ActionListener() { checkBox.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent arg0) { public void actionPerformed(ActionEvent arg0) {
...@@ -221,4 +230,22 @@ public class SimControlPanel extends JMenuBar ...@@ -221,4 +230,22 @@ public class SimControlPanel extends JMenuBar
} }
} }
/**
* @return the confPath
*/
public static String getConfPath(String pName) {
return CONF_PATH + pName.replace(":", "").replaceAll(" ", "");
}
/**
* @return the confPath
*/
public static String getConfMainPath(String pName) {
String newName = "Layer_" + pName.replace(":", "").replaceAll(" ", "").replace("/", "_");
if (newName.length() > 1) {
return CONF_PATH + newName + "/Main";
}
return null;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment