Bläddra i källkod

Wip Inspector

TomTroppmann 2 år sedan
förälder
incheckning
67f9b0c449

+ 5 - 1
src/ui/controller/Control.java

@@ -55,6 +55,7 @@ public class Control {
 
     
     public Event OnCategoryChanged = new Event();
+    public Event OnSelectionChanged = new Event();
     /**
      * Constructor.
      *
@@ -89,6 +90,7 @@ public class Control {
         category.mkdirs();
         other.mkdirs();
         createAutoRandom();
+        
         try {
             autoSave();
         } catch (IOException e) {
@@ -263,7 +265,8 @@ public class Control {
      * @param obj Cpsobject
      */
     public void deleteSelectedObject(AbstractCanvasObject obj) {
-        objectController.deleteSelectedObject(obj);
+    	objectController.deleteSelectedObject(obj);
+    	OnSelectionChanged.broadcast();
     }
 
     /**
@@ -273,6 +276,7 @@ public class Control {
      */
     public void addSelectedObject(AbstractCanvasObject obj) {
         objectController.addSelectedObject(obj);
+        OnSelectionChanged.broadcast();
     }
 
 	/* Operations for Canvas */

+ 0 - 27
src/ui/controller/UpdateController.java

@@ -444,11 +444,6 @@ public class UpdateController {
 			deleteRows(model.getMultiTable());
 		}
 		// Update of the HolonElementTable (Single- or Multi-Selection)
-		if (model.getSelectedCpsObjects().size() > 1) {
-			model.getTableHolonElement().setModel(model.getMultiTable());
-		} else if (model.getSelectedCpsObjects().size() == 1) {
-			model.getTableHolonElement().setModel(model.getSingleTable());
-		}
 	}
 
 	public AbstractCanvasObject getHolonObjSelected(int id) {
@@ -462,26 +457,4 @@ public class UpdateController {
 		return obj;
 	}
 
-
-	/**
-	 * 
-	 * @return id of column that should be sorted
-	 */
-	public int getSortBy() {
-		return sortBy;
-	}
-
-	/**
-	 * sets the column id that should be sorted
-	 * @param column
-	 */
-	public void setSortBy(int column) {
-		/**
-		 * if there is no "Object" column, assume coloumn 0 is
-		 */
-		if(model.getTableHolonElement().getColumnCount()==7)
-			this.sortBy = column+1;
-		else
-			this.sortBy = column;
-	}
 }

+ 0 - 8
src/ui/model/Model.java

@@ -151,7 +151,6 @@ public class Model {
         setMultiTable(new PropertyTable());
         setPropertyTable(new DefaulTable(1000, colNames.length));
         getPropertyTable().setColumnIdentifiers(colNames);
-        setTableHolonElement(new JTable());
         initGson();
     }
 
@@ -611,13 +610,6 @@ public class Model {
         this.tableModelProperties = pt;
     }
 
-    public JTable getTableHolonElement() {
-        return tableHolonElement;
-    }
-
-    public void setTableHolonElement(JTable tableHolonElement) {
-        this.tableHolonElement = tableHolonElement;
-    }
     
 	/**
 	 * @return the tableProperties

+ 0 - 29
src/ui/view/AbstractCanvas.java

@@ -402,35 +402,6 @@ public abstract class AbstractCanvas extends JPanel {
 		cps.setPosition(p.getX()-x_off, p.getY()-y_off);
 	}
 	
-	/**
-	 * Stops Editing in HolonElementTable and PropertyTable
-	 */
-	protected void stopEditing() {
-		/**
-		 * Stop Editing, if mouse exits the Table
-		 */
-		JTable holElem = model.getTableHolonElement();
-		CellEditor cellEditor = holElem.getCellEditor();
-		if (cellEditor != null) {
-		    if (cellEditor.getCellEditorValue() != null) {
-		    	/** TODO: Maybe try to save current Data */
-		        cellEditor.stopCellEditing();
-		    } else {
-		        cellEditor.cancelCellEditing();
-		    }
-		}
-		
-		JTable propertys = model.getTableProperties();
-		cellEditor = propertys.getCellEditor();
-		if (cellEditor != null) {
-		    if (cellEditor.getCellEditorValue() != null) {
-		    	/** TODO: Maybe try to save current Data */
-		        cellEditor.stopCellEditing();
-		    } else {
-		        cellEditor.cancelCellEditing();
-		    }
-		}
-	}
 
 	/**
 	 * Closes a tab of the UpperNode with ID upperNodeID

+ 4 - 3
src/ui/view/Canvas.java

@@ -523,7 +523,10 @@ public class Canvas extends AbstractCanvas implements MouseListener,
 		
 		VisualRepresentationalState  visualState = controller.getSimManager().getActualVisualRepresentationalState();
 		//VisualState Representation:
-		if(visualState == null) System.out.println("AHHH"); 
+		if(visualState == null) {
+			System.out.println("AHHH"); 
+			return;
+		}
 		for(ExitCable cable : visualState.getExitCableList()) {
 			paintExitCable(g2d, cable);
 		}
@@ -604,7 +607,6 @@ public class Canvas extends AbstractCanvas implements MouseListener,
 
 			triggerUpdateController();
 			}
-			stopEditing();
 		}
 	}
 
@@ -620,7 +622,6 @@ public class Canvas extends AbstractCanvas implements MouseListener,
 	public void mousePressed(MouseEvent e) {
 		this.grabFocus();
 		if(!disabled){
-		stopEditing();
 		tempCps = null;
 		edgeHighlight = null;
 		controller.setSelecteEdge(null);

+ 14 - 462
src/ui/view/GUI.java

@@ -37,7 +37,6 @@ import javax.swing.AbstractAction;
 import javax.swing.ActionMap;
 import javax.swing.Box;
 import javax.swing.BoxLayout;
-import javax.swing.CellEditor;
 import javax.swing.GrayFilter;
 import javax.swing.ImageIcon;
 import javax.swing.InputMap;
@@ -58,22 +57,18 @@ import javax.swing.JPopupMenu;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
-import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.JToolBar;
 import javax.swing.JTree;
 import javax.swing.KeyStroke;
 import javax.swing.SwingUtilities;
 import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.DefaultTableModel;
-import javax.swing.table.JTableHeader;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.TreeCellRenderer;
 
 import org.apache.commons.compress.archivers.ArchiveException;
+
 import com.google.gson.JsonParseException;
 
 import classes.AbstractCanvasObject;
@@ -178,37 +173,11 @@ public class GUI {
 	 * Right Container: here comes the information about the HolonObject, such as
 	 * HolonElements Information, Properties and Consumption/Production graph.
 	 **/
+	private final Inspector inspector;
 	private final JSplitPane splitHolonElPro = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
 	private final JSplitPane splitGraphHolonEl = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
 	private final int distanceBetweenElementsAndGraph = 350;
-	// Model for single or multi selection
-	private final JPanel scrollElements = new JPanel();
-	private final JScrollPane tableHolonElementScrollPane = new JScrollPane();
-	// In this section are all the properties that correspond to the clicked
-	// HolonObject, such as connections, name, Type, etc.
-	// Table for Properties --> Cell with (0,1) is editable by CpsObjt and
-	// Cell(3,1) is editable by Edges
-	private final JTable tableProperties = new JTable() {
-
-		@Override
-		public TableCellRenderer getCellRenderer(int row, int column) {
-			if (getValueAt(row, column) instanceof Boolean) {
-				return super.getDefaultRenderer(Boolean.class);
-			} else {
-				return super.getCellRenderer(row, column);
-			}
-		}
-
-		@Override
-		public TableCellEditor getCellEditor(int row, int column) {
-			if (getValueAt(row, column) instanceof Boolean) {
-				return super.getDefaultEditor(Boolean.class);
-			} else {
-				return super.getCellEditor(row, column);
-			}
-		}
 
-	};
 	// Prechoosed local Periods
 	private String[] comboContext = { "", "5", "10", "20", "100", "1000" };
 	private JComboBox<String> localPeriodInput = new JComboBox<String>(comboContext);
@@ -219,9 +188,6 @@ public class GUI {
 	private final JPanel graphLabel = new JPanel();
 	private final JScrollPane scrollProperties = new JScrollPane();
 	// In this section is the graph for the selected HolonElement of the clicked
-	// HolonObject
-	private final JTable tableGraph = new JTable();
-	private final DefaultTableModel tableModelGraph = new DefaultTableModel();
 	private final JScrollPane scrollGraph = new JScrollPane();
 	private final Model model;
 	private final Control controller;
@@ -264,8 +230,11 @@ public class GUI {
 	private final UpdateController updCon;
 	// for doubleclick
 	private boolean click = false;
+	// TODO make GUI a JFRAME and remove holegJFrame
 	private JFrame holegJFrame;
-	private JTabbedPane tabTemp; // tabbedPaneOriginal or tabbedPaneSplit
+
+	// tabbedPaneOriginal or tabbedPaneSplit
+	private JTabbedPane tabTemp;
 	private boolean initSplit = true;
 	private String catOfObjToBeEdited;
 	private GroupNodeCanvas unc;
@@ -280,7 +249,6 @@ public class GUI {
 	private String actualObjectClicked;
 	private Image img = null;
 	private AbstractCanvasObject tempCps = null;
-	private int yValueElements = 0;
 	// Time Stuff
 	private TimePanel timePanel;
 
@@ -288,17 +256,6 @@ public class GUI {
 		return timePanel;
 	}
 
-	// Coord for all Cells with text
-	private int yThis;
-	private int xThis;
-	// Coord for all Cells with boolean values (checkbox)
-	private int yBTis;
-	private int xBThis;
-	// Coord for the Edit-Modus in the PropertieTable
-	private int yProThis;
-	private int xProThis;
-	private int yProThisOneClick;
-	private int xProThisOneClick;
 	private AbstractCanvasObject temp = null;
 	private String warningText = "Warning";
 	private String saveBeforeNew = "Do you want to save your current data?";
@@ -318,10 +275,11 @@ public class GUI {
 	GUI(Control control) {
 		this.controller = control;
 		this.model = control.getModel();
+		inspector  = new Inspector(control);
 		control.setGui(this);
+		control.calculateStateAndVisualForCurrentTimeStep();
 		this.unitGraph = new UnitGraph(model, control);
 		this.canvas = new Canvas(model, control, unitGraph);
-		model.setTableProperties(tableProperties);
 		initialize();
 		updateCategories(model.getCategories());
 		updCon = new UpdateController(model, controller);
@@ -839,56 +797,7 @@ public class GUI {
 		/********************
 		 * RIGHT CONTAINER (INFORMATION)
 		 **********************/
-		// Set up of the HolonElements section
-		// Two different Models: Multi for multi-selection mode and Single for
-		// single-selection mode (CPS-Object)
-		model.getMultiTable().setColumnIdentifiers(columnNamesMulti);
-		model.getSingleTable().setColumnIdentifiers(columnNamesSingle);
-		model.getTableHolonElement().setBorder(null);
-		model.getTableHolonElement().setFillsViewportHeight(true);
-		model.getTableHolonElement().setCellSelectionEnabled(true);
-		model.getTableHolonElement().setColumnSelectionAllowed(true);
-		/*
-		 * Register Clicks on ColumNames for sorting:
-		 */
-		model.getTableHolonElement().getTableHeader().addMouseListener(new MouseAdapter() {
-			public void mouseClicked(MouseEvent e) {
-				// TODO: sort
-				// clicked column
-				int col = model.getTableHolonElement().columnAtPoint(e.getPoint());
-				// insert column into UpdateController
-				updCon.setSortBy(col);
-				// refresh HolonElementTable
-				updCon.refreshTableHolonElement(model.getMultiTable(), model.getSingleTable());
-			}
 
-			@Override
-			public void mouseExited(MouseEvent e) {
-				/**
-				 * Stop Editing, if mouse exits the Table
-				 */
-				JTable holElem = model.getTableHolonElement();
-				JTableHeader holElemHead = holElem.getTableHeader();
-				if (e.getX() <= 0 || e.getX() >= holElemHead.getWidth() || e.getY() <= 0) {
-					CellEditor cellEditor = holElem.getCellEditor();
-					if (cellEditor != null) {
-						if (cellEditor.getCellEditorValue() != null) {
-							/** TODO: Maybe try to save current Data */
-							cellEditor.stopCellEditing();
-						} else {
-							cellEditor.cancelCellEditing();
-						}
-					}
-				}
-
-			}
-		});
-		model.getTableHolonElement().getTableHeader().setReorderingAllowed(false);
-
-		tableHolonElementScrollPane.setViewportView(model.getTableHolonElement());
-		scrollElements.setLayout(new BorderLayout(0, 0));
-		scrollElements.add(panelHolonEl, BorderLayout.NORTH);
-		scrollElements.add(tableHolonElementScrollPane);
 		panelHolonEl.setLayout(new BoxLayout(panelHolonEl, BoxLayout.X_AXIS));
 		toolBarHolonEl.add(btnAddHolEL);
 		toolBarHolonEl.add(btnDelHolEL);
@@ -896,17 +805,7 @@ public class GUI {
 		panelHolonEl.add(toolBarHolonEl);
 
 		// Set up of the Properties section
-		tableProperties.setModel(model.getPropertyTable());
-		tableProperties.setFillsViewportHeight(true);
-		tableProperties.setCellSelectionEnabled(true);
-		tableProperties.setColumnSelectionAllowed(true);
-		scrollProperties.setViewportView(tableProperties);
-
-		// Set up of the Graph section
-		tableGraph.setModel(tableModelGraph);
-		tableGraph.setFillsViewportHeight(true);
-		tableGraph.setCellSelectionEnabled(true);
-		tableGraph.setColumnSelectionAllowed(true);
+
 		scrollGraph.setViewportView(unitGraph);
 		graphLabel.setLayout(new BorderLayout(0, 10));
 		graphLabel.add(maxGraph, BorderLayout.NORTH);
@@ -1024,319 +923,6 @@ public class GUI {
 		btnDelHolEL.setIcon(new ImageIcon(ImageImport.loadImage("Images/minus.png", 16, 16)));
 		btnDelHolEL.setToolTipText(
 				"<html><b>Remove Element</b><br>Removes the selected HolonElement from the HolonObject.</html>");
-		/*
-		 * Communication between HolonElement Table and displayed Graph and Properties,
-		 * as well as selection of different HolonElements
-		 */
-		model.getTableHolonElement().addMouseListener(new MouseAdapter() {
-			public void mousePressed(MouseEvent e) {
-				HolonObject obj = null;
-				if (model.getSelectedCpsObjects().size() == 1
-						&& model.getSelectedCpsObjects().get(0) instanceof HolonObject) {
-					obj = (HolonObject) updCon.getActualCps();
-				}
-				yValueElements = e.getY();
-				HolonElement ele;
-				// Search for current clicked HolonElement
-				if (model.getSelectedCpsObjects().size() == 1) {
-					ele = updCon.getActualHolonElement(obj, yValueElements, 0, tables);
-				} else {
-					ele = updCon.getActualHolonElement(null, yValueElements, 0, tables);
-				}
-				// Multi-Selection of HolonElements through control button +
-				// mouse click
-				if (ele != null) {
-					// make energy-consumption graph visible
-					showScrollGraph();
-
-					if (e.isControlDown()) {
-						if (!selectedElements.contains(ele)) {
-							selectedElements.add(ele);
-							if (!holonEleNamesDisplayed.equals("None")) {
-								holonEleNamesDisplayed = holonEleNamesDisplayed + "; " + ele.getEleName() + " ";
-							} else {
-								holonEleNamesDisplayed = ele.getEleName() + " ";
-							}
-							updateUnitGraph((GraphEditable) selectedElements.get(selectedElements.size() - 1));
-						}
-						updCon.getActualHolonElement(null, yValueElements, 2, tables);
-					}
-					// if no control-button pressed but a HolonElement chosen
-					else {
-						selectedElements.clear();
-						selectedElements.add(ele);
-						updCon.getActualHolonElement(null, yValueElements, 1, tables);
-						holonEleNamesDisplayed = ele.getEleName() + " ";
-						updateUnitGraph((GraphEditable) selectedElements.get(selectedElements.size() - 1));
-					}
-				} else {
-					elementGraph.setText("None");
-					hideScrollGraph();
-				}
-				// if any HolonElement is double-clicked --> Edit-Mode started
-				// for selected HolonElement
-				if (e.getClickCount() == 2) {
-					yThis = e.getY();
-					xThis = e.getX();
-				}
-				// for single click and empty slot
-				if (e.getClickCount() == 1 && ele == null) {
-					selectedElements.clear();
-					holonEleNamesDisplayed = "None";
-				}
-				elementGraph.setText(holonEleNamesDisplayed);
-				yBTis = e.getY();
-				xBThis = e.getX();
-
-			}
-
-			@Override
-			public void mouseExited(MouseEvent e) {
-				/**
-				 * Stop Editing, if mouse exits the Table
-				 */
-				JTable holElem = model.getTableHolonElement();
-				if (e.getX() <= 0 || e.getX() >= holElem.getWidth()
-				/* || e.getY() <= 0 */ || e.getY() >= holElem.getHeight()) {
-					CellEditor cellEditor = holElem.getCellEditor();
-					if (cellEditor != null) {
-						if (cellEditor.getCellEditorValue() != null) {
-							/** TODO: Maybe try to save current Data */
-							cellEditor.stopCellEditing();
-						} else {
-							cellEditor.cancelCellEditing();
-						}
-					}
-				}
-
-			}
-
-		});
-
-		/*
-		 * Triggered every time a change is made
-		 */
-		model.getTableHolonElement().addPropertyChangeListener(propertyChangeEvent -> {
-			try {
-				int yMouse = yThis;
-				int yBMouse = yBTis;
-				int selectedValueY = (int) Math.floor(yMouse / 16);
-				int selectedValueBY = (int) Math.floor(yBMouse / 16);
-				// ------------------ multi-selection mode
-				// ------------------
-				if (model.getSelectedCpsObjects().size() > 1) {
-					int selectedValueX = (int) Math.floor(xThis / (model.getTableHolonElement().getWidth() / 8));
-					int selectedValueBX = (int) Math.floor(xBThis / (model.getTableHolonElement().getWidth() / 8));
-					if (updCon.getHolonObj(yMouse, model.getMultiTable()) != null) {
-						// For active column (boolean with a checkbox)
-						if (selectedValueBX == 6) {
-							System.out.println("selectedValueBX == 6");
-							HolonElement eleBTemp = updCon.getActualHolonElement(null, yBMouse, 0, tables);
-							String newBStuff = model.getMultiTable().getValueAt(selectedValueBY, selectedValueBX)
-									.toString();
-							Boolean bTemp = Boolean.parseBoolean(newBStuff);
-							eleBTemp.setActive(bTemp);
-						}
-						// For activeFlex column (boolean with a
-						// checkbox)
-						else if (selectedValueBX == 7) {
-							HolonElement eleBTemp = updCon.getActualHolonElement(null, yBMouse, 0, tables);
-							String newBStuff = model.getMultiTable().getValueAt(selectedValueBY, selectedValueBX)
-									.toString();
-							Boolean bTemp = Boolean.parseBoolean(newBStuff);
-							eleBTemp.setActive(bTemp);
-						} else {
-							// TODO: check all possible fields.
-							// Update of HolonElement
-							HolonElement eleTemp = updCon.getActualHolonElement(null, yMouse, 0, tables);
-							String newStuff = model.getMultiTable().getValueAt(selectedValueY, selectedValueX)
-									.toString();
-
-							// Name update
-							if (selectedValueX == 2) {
-								eleTemp.setEleName(newStuff);
-							}
-							// Energy Update
-							else if (selectedValueX == 3) {
-								Float ftemp = Float.parseFloat(newStuff);
-								eleTemp.setEnergyPerElement(ftemp);
-							}
-							// Flexibility
-							else if (selectedValueX == 4) {
-
-							}
-							// Amount of Elements update
-							else if (selectedValueX == 5) {
-								Integer iTemp = Integer.parseInt(newStuff);
-								eleTemp.setAmount(iTemp);
-							} else if (selectedValueX == 6) {
-							}
-						}
-					}
-				} // ------------------ single-selection mode
-					// ------------------
-				else if (model.getSelectedCpsObjects().size() == 1) {
-					int selectedValueX = (int) Math.floor(xThis / (model.getTableHolonElement().getWidth() / 7));
-					int selectedValueBX = (int) Math.floor(xBThis / (model.getTableHolonElement().getWidth() / 7));
-					if (updCon.getActualCps() != null && updCon.getActualCps().getClass() == HolonObject.class) {
-						HolonElement eleTemp;
-
-						// For active column (boolean with a checkbox)
-						if (selectedValueBX == 5) {
-							eleTemp = updCon.getActualHolonElement((HolonObject) updCon.getActualCps(), yBMouse, 0,
-									tables);
-							String newBStuff = model.getSingleTable().getValueAt(selectedValueBY, selectedValueBX)
-									.toString();
-							Boolean bTemp = Boolean.parseBoolean(newBStuff);
-							eleTemp.setActive(bTemp);
-
-						} // For activeFlex column (boolean with a
-							// checkbox)
-						else if (selectedValueBX == 6) {
-							eleTemp = updCon.getActualHolonElement((HolonObject) updCon.getActualCps(), yBMouse, 0,
-									tables);
-							String newBStuff = model.getSingleTable().getValueAt(selectedValueBY, selectedValueBX - 1)
-									.toString();
-							eleTemp.setActive(Boolean.parseBoolean(newBStuff));
-
-						} else {
-							// TODO check all possible assignements.
-							// Update of HolonElement
-							eleTemp = updCon.getActualHolonElement((HolonObject) updCon.getActualCps(), yMouse, 0,
-									tables);
-							String newStuff = model.getSingleTable().getValueAt(selectedValueY, selectedValueX)
-									.toString();
-							// Name update
-							if (selectedValueX == 1) {
-								eleTemp.setEleName(newStuff);
-							} // Energy Update
-							else if (selectedValueX == 2) {
-								Float ftemp = Float.parseFloat(newStuff);
-								eleTemp.setEnergyPerElement(ftemp);
-							} // Flexibility
-							else if (selectedValueX == 3) {
-							}
-							// Amount of Elements update
-							else if (selectedValueX == 4) {
-								Integer iTemp = Integer.parseInt(newStuff);
-								eleTemp.setAmount(iTemp);
-							}
-						}
-
-						// set all cells anew, if anything was changed
-						updateElementTableAfterChange(eleTemp, selectedValueBY);
-					}
-				}
-				controller.calculateStateAndVisualForTimeStep(model.getCurIteration());
-				model.getSingleTable().fireTableDataChanged();
-				triggerUpdateController(null);
-				contentPane.updateUI();
-				unitGraph.repaint();
-
-				// trigger update of table after UnitGraph was painted
-				SwingUtilities.invokeLater(() -> {
-					triggerUpdateController(null);
-				});
-			} catch (Exception e) {
-			}
-		});
-		/***********************
-		 * HolonElement Properties Actions
-		 **********************/
-
-		/*
-		 * Update of the mouse coord for Edit-Mode
-		 */
-		tableProperties.addMouseListener(new MouseAdapter() {
-			public void mousePressed(MouseEvent e) {
-				if (e.getClickCount() == 2) {
-					yProThis = e.getY();
-					xProThis = e.getX();
-				}
-				yProThisOneClick = e.getY();
-				xProThisOneClick = e.getX();
-			}
-		});
-
-		/*
-		 * Update any change in the Property table
-		 */
-		tableProperties.addPropertyChangeListener(propertyChangeEvent -> {
-			try {
-				Object temp;
-				Object btemp;
-				int selValueY = (int) Math.floor(yProThis / 16);
-				int selValueX = (int) Math.floor(xProThis / (tableProperties.getWidth() / 2));
-				int selValueYBool = (int) Math.floor(yProThisOneClick / 16);
-				int selValueXBool = (int) Math.floor(xProThisOneClick / (tableProperties.getWidth() / 2));
-				if (updCon.getActualCps() != null) {
-					temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
-					btemp = model.getPropertyTable().getValueAt(selValueYBool, selValueXBool);
-					// Case: Switch selected
-
-					if (updCon.getActualCps() instanceof HolonSwitch) {
-						if (selValueY == 0 && selValueX != 0) {
-							updCon.getActualCps().setName(temp.toString());
-						}
-						if (selValueYBool == 2) {
-							Boolean bbTemp = Boolean.parseBoolean(btemp.toString());
-							((HolonSwitch) updCon.getActualCps()).setManualMode(bbTemp);
-							if (bbTemp) {
-								model.getPropertyTable().setCellEditable(3, 1, true);
-							} else {
-								model.getPropertyTable().setCellEditable(3, 1, false);
-							}
-						} else if (selValueYBool == 3) {
-							if (((HolonSwitch) updCon.getActualCps()).getManualMode()) {
-								model.getPropertyTable().setCellEditable(3, 1, true);
-								Boolean bTemp = Boolean.parseBoolean(btemp.toString());
-								((HolonSwitch) updCon.getActualCps()).setManualState(bTemp);
-							}
-						}
-					} // Case: UpperNode selected
-					else if (updCon.getActualCps() instanceof GroupNode && selValueX != 0) {
-						// Name edition through double click
-						updCon.getActualCps().setName(temp.toString());
-						// Update of name on the tab in the tab section
-						for (int index = 4; index < tabbedPaneOriginal.getTabCount(); index++) {
-							tabTemp = tabbedPaneOriginal;
-							JScrollPane scrollPane = getScrollPaneFromTabbedPane();
-
-							GroupNodeCanvas unc = ((GroupNodeCanvas) scrollPane.getViewport().getComponent(0));
-
-							if (unc.getGroupNode().getId() == updCon.getActualCps().getId()) {
-								tabbedPaneOriginal.setTitleAt(index, unc.getGroupNode().getName());
-								tabbedPaneOriginal.updateUI();
-								if (!initSplit) {
-									tabbedPaneSplit.setTitleAt(index, unc.getGroupNode().getName());
-									tabbedPaneSplit.updateUI();
-								}
-							}
-						}
-					} // Case: HolonObject is selected
-					else if (updCon.getActualCps() instanceof HolonObject && selValueX != 0) {
-						// Name edition through double click
-						updCon.getActualCps().setName(temp.toString());
-					}
-				} // Case: Edge is selected
-				else {
-					temp = model.getPropertyTable().getValueAt(selValueY, selValueX);
-					btemp = model.getPropertyTable().getValueAt(selValueYBool, selValueXBool);
-					// Edit modus for capacity by double clicking
-					if (selValueY == 2) {
-						Float ftemp;
-						if (Float.parseFloat(temp.toString()) >= 0.0) {
-							ftemp = Float.parseFloat(temp.toString());
-						} else {
-							ftemp = model.getSelectedEdge().getCapacity();
-						}
-						model.getSelectedEdge().setCapacity(ftemp);
-					}
-				}
-				canvas.repaint();
-			} catch (Exception e) {
-			}
-		});
 
 		/***********************
 		 * HolonElement Graph Actions
@@ -1787,11 +1373,6 @@ public class GUI {
 						e1.printStackTrace();
 					}
 				}
-				if (model.getSelectedCpsObjects().size() > 1) {
-					model.getTableHolonElement().setModel(model.getMultiTable());
-				} else if (model.getSelectedCpsObjects().size() == 1) {
-					model.getTableHolonElement().setModel(model.getSingleTable());
-				}
 
 			}
 
@@ -2010,15 +1591,14 @@ public class GUI {
 		// containing the object's properties
 		splitHolonElPro.setBottomComponent(scrollProperties);
 
+		splitGraphHolonEl.setTopComponent(inspector);
 		splitGraphHolonEl.setDividerLocation(distanceBetweenElementsAndGraph);
-		splitGraphHolonEl.setTopComponent(scrollElements);
 		splitGraphHolonEl.setBottomComponent(scrollGraph);
 		canvasSP.setViewportView(canvas);
 
 		tabbedPaneOriginal.setBorder(null);
 		scrollProperties.setBorder(null);
 		scrollGraph.setBorder(null);
-		scrollElements.setBorder(null);
 		splitPane.setBorder(null);
 		splitPane1.setBorder(null);
 		splitHolonElPro.setBorder(null);
@@ -2026,7 +1606,6 @@ public class GUI {
 		panelHolonEl.setBorder(null);
 		canvasSP.setBorder(null);
 		hideScrollGraph();
-		tableHolonElementScrollPane.setBorder(null);
 
 		holegJFrame.getContentPane().add(timePanel, BorderLayout.SOUTH);
 
@@ -2212,13 +1791,8 @@ public class GUI {
 		model.reload();
 	}
 
-	/**
-	 * Get the Frame.
-	 *
-	 * @return the Frame
-	 */
-	JFrame getFrmCyberPhysical() {
-		return holegJFrame;
+	void setVisible(boolean value) {
+		holegJFrame.setVisible(value);
 	}
 
 	/**
@@ -2430,24 +2004,6 @@ public class GUI {
 		}
 	}
 
-	/**
-	 * if flexibility was turned on, then active needs to be turned off, the energy
-	 * currently produced/consumed
-	 *
-	 * @param eleBTemp        element that needs to be updated
-	 * @param selectedValueBY the y value in the table
-	 */
-	private void updateElementTableAfterChange(HolonElement eleBTemp, int selectedValueBY) {
-//		model.getSingleTable().setValueAt(false,
-//				selectedValueBY, 6);
-		model.getSingleTable().setValueAt(eleBTemp.isActive(), selectedValueBY, 5);
-		model.getSingleTable().setValueAt(eleBTemp.getAmount(), selectedValueBY, 4);
-		model.getSingleTable().setValueAt(
-				controller.getSimManager().getActualFlexManager().isAFlexInUseOfHolonElement(eleBTemp), selectedValueBY,
-				3);
-		model.getSingleTable().setValueAt(eleBTemp.getEnergyPerElement(), selectedValueBY, 2);
-	}
-
 	public void triggerUpdateController(AbstractCanvasObject temp) {
 		if (model != null) {
 			return;
@@ -2514,12 +2070,8 @@ public class GUI {
 	private void openWebpage(String URL) {
 		try {
 			java.awt.Desktop.getDesktop().browse(new URI(URL));
-		} catch (IOException e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
-		} catch (URISyntaxException e1) {
-			// TODO Auto-generated catch block
-			e1.printStackTrace();
+		} catch (Exception e) {
+			e.printStackTrace();
 		}
 	}
 

+ 0 - 6
src/ui/view/GroupNodeCanvas.java

@@ -158,7 +158,6 @@ public class GroupNodeCanvas extends Canvas {
 	public void mousePressed(MouseEvent e) {
 		this.grabFocus();
 		if (!disabled) {
-			stopEditing();
 			tempCps = null;
 			dataSelected = null;
 			edgeHighlight = null;
@@ -260,11 +259,6 @@ public class GroupNodeCanvas extends Canvas {
 			x = e.getX();
 			y = e.getY();
 			dragging = false;
-			if (model.getSelectedCpsObjects().size() > 1) {
-				model.getTableHolonElement().setModel(model.getMultiTable());
-			} else if (model.getSelectedCpsObjects().size() == 1) {
-				model.getTableHolonElement().setModel(model.getSingleTable());
-			}
 
 			if (drawEdge) {
 				drawEdge = false;

+ 95 - 0
src/ui/view/Inspector.java

@@ -0,0 +1,95 @@
+package ui.view;
+
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.GridLayout;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.swing.BoxLayout;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+
+import classes.AbstractCanvasObject;
+import classes.HolonElement;
+import classes.HolonObject;
+import ui.controller.Control;
+import ui.model.Model;
+
+public class Inspector extends JPanel {
+	private List<HolonElement> elements = new ArrayList<>();
+	private Model model;
+	
+	
+	Inspector(Control control){
+		control.OnSelectionChanged.addListener(() -> update_ui());
+		model = control.getModel();
+		initUI();
+	}
+	public void update_ui() {
+		System.out.println("OnSelectionChanged");
+		elements = extractElements(model.getSelectedCpsObjects());
+		//TODO Pooling
+		this.removeAll();
+		this.add(header());
+		for(HolonElement ele : elements) {
+			this.add(new ElementEdit(ele));
+		}
+	}
+	
+	
+	
+	private void initUI() {
+		this.setBackground(Color.white);
+		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
+		this.add(header());
+	}
+	
+	//	private final String[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Flexibility active", "Quantity", "Activated" };
+	private JPanel header() {
+		JPanel header = new JPanel(new GridLayout(1,6));
+		header.add(new JLabel("Object"));
+		header.add(new JLabel("Nr."));
+		header.add(new JLabel("Device"));
+		header.add(new JLabel("Energy"));
+		//this.add(new JLabel("Flexibility"));
+		header.add(new JLabel("Quantity"));
+		header.add(new JLabel("Activated"));
+		header.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+		return header;
+	}
+	
+	private List<HolonElement> extractElements(List<AbstractCanvasObject> toInspect) {
+		//Extract elements from a list of AbstractCanvasObjects
+		return toInspect.stream().filter(obj -> obj instanceof HolonObject).flatMap(obj -> {
+			HolonObject ho = (HolonObject) obj;
+			return ho.getElements().stream();
+		}).collect(Collectors.toList());
+	}
+	
+	
+	private class ElementEdit extends JPanel{
+		HolonElement element;
+		ElementEdit(HolonElement element){
+			this.element = element;
+			this.initUI();
+			this.add(new JLabel(this.element.parentObject.getName()));
+			this.add(new JLabel(Integer.toString(this.element.getId())));
+			this.add(new JLabel(this.element.getEleName()));
+			this.add(new JLabel(Float.toString(this.element.getEnergyPerElement())));
+			this.add(new JLabel(Integer.toString(this.element.getAmount())));
+			this.add(new JLabel(Boolean.toString(this.element.isActive())));
+		}
+		private void initUI() {
+			//this.setBackground(Color.gray);
+			this.setLayout(new GridLayout(1,6));
+			this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 30));
+		}
+		
+	}
+}
+
+
+
+

+ 1 - 1
src/ui/view/Main.java

@@ -32,7 +32,7 @@ public class Main {
                 Control control = new Control(model);
                 GUI view = new GUI(control);
                 IndexTranslator.model = model;
-                view.getFrmCyberPhysical().setVisible(true);
+                view.setVisible(true);
 
             } catch (Exception e) {
                 e.printStackTrace();