Browse Source

Randomizer Feature

- Adds an update Button
Tom Troppmann 4 years ago
parent
commit
2f4c0de014
1 changed files with 11 additions and 9 deletions
  1. 11 9
      src/addOns/Randomizer.java

+ 11 - 9
src/addOns/Randomizer.java

@@ -36,21 +36,14 @@ import com.google.gson.JsonElement;
 import com.google.gson.JsonIOException;
 import com.google.gson.JsonParser;
 import com.google.gson.JsonSyntaxException;
-import com.google.gson.annotations.Expose;
-import com.google.gson.annotations.SerializedName;
 
 import addOns.JSON.HolonElementSketch;
 import api.AddOn;
 import classes.AbstractCanvasObject;
-import classes.Constrain;
 import classes.GroupNode;
-import classes.Flexibility;
 import classes.HolonElement;
-import classes.HolonElement.Priority;
 import classes.HolonObject;
-import classes.HolonSwitch;
 import ui.controller.Control;
-import ui.model.Model;
 import ui.view.RandomPriotity;
 import utility.Random;
 import utility.Util;
@@ -119,9 +112,18 @@ public class Randomizer implements AddOn {
 		checkboxList.clear();
 		
 		//HeadPanel
+		int lineSpace = 20;
 		JPanel headPanel = new JPanel();
 		headPanel.setLayout(new BoxLayout(headPanel, BoxLayout.LINE_AXIS));
 		headPanel.add(new JLabel("FILTER"));
+		JButton updateButton = new JButton();
+		updateButton.setIcon(new ImageIcon(Util.loadImage("Images/replace.png", 15, 15)));
+		updateButton.addActionListener(action -> {
+			this.updateFilterList();
+			content.updateUI();
+		});
+		updateButton.setToolTipText("Manuel updates the filter list with all canvas objects.");
+		headPanel.add(updateButton);
 		headPanel.add(Box.createHorizontalGlue());
 		headPanel.add(new JLabel("SelectAll"));
 		JCheckBox selectAllCheckbox = new JCheckBox();
@@ -132,7 +134,6 @@ public class Randomizer implements AddOn {
 		
 		
 		//Entrys
-		int lineSpace = 20;
 		for(HolonObject hObject: objectMap.keySet().stream().sorted(Comparator.comparing(ob -> ob.getName())).collect(Collectors.toList())) {
 			//Entry
 			JPanel entryPanel = new JPanel();
@@ -261,7 +262,8 @@ public class Randomizer implements AddOn {
 	
 	public void updateFilterList() {
 		objectMap.clear();
-		fillObjectMap(control.getModel().getObjectsOnCanvas());
+		if(control != null)
+			fillObjectMap(control.getModel().getObjectsOnCanvas());
 		
 		this.fillTablePanel();
 	}