|
@@ -257,10 +257,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
scrollPane_2.setViewportView(dtrpnHereWillBe);
|
|
|
|
|
|
- /*
|
|
|
- * Right Container Set up
|
|
|
- */
|
|
|
-
|
|
|
+ /********************
|
|
|
+ * RIGHT CONTAINER (INFORMATION)
|
|
|
+ **********************/
|
|
|
// Set up of the HolonElements section
|
|
|
Object[] columnNames = { "Device", "Energy", "Quantity" };
|
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
@@ -269,6 +268,15 @@ public class GUI<E> implements CategoryListener {
|
|
|
tableHolonElement.setFillsViewportHeight(true);
|
|
|
tableHolonElement.setCellSelectionEnabled(true);
|
|
|
tableHolonElement.setColumnSelectionAllowed(true);
|
|
|
+ tableHolonElementScrollPane.setViewportView(tableHolonElement);
|
|
|
+ scrollElements.setLayout(new BorderLayout(0, 0));
|
|
|
+ scrollElements.add(panel_HolonEl, BorderLayout.NORTH);
|
|
|
+ scrollElements.add(tableHolonElementScrollPane);
|
|
|
+ panel_HolonEl.setLayout(new BoxLayout(panel_HolonEl, BoxLayout.X_AXIS));
|
|
|
+ toolBarHolonEl.add(btnAddHolEL);
|
|
|
+ toolBarHolonEl.add(btnDelHolEL);
|
|
|
+ toolBarHolonEl.setFloatable(false);
|
|
|
+ panel_HolonEl.add(toolBarHolonEl);
|
|
|
|
|
|
// Set up of the Properties section
|
|
|
Object[] colNames = { "Field", "Information" };
|
|
@@ -278,42 +286,32 @@ public class GUI<E> implements CategoryListener {
|
|
|
tableProperties.setFillsViewportHeight(true);
|
|
|
tableProperties.setCellSelectionEnabled(true);
|
|
|
tableProperties.setColumnSelectionAllowed(true);
|
|
|
- // Set up of the Graph section
|
|
|
+ scrollProperties.setViewportView(tableProperties);
|
|
|
|
|
|
+ // Set up of the Graph section
|
|
|
Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
|
|
|
tableModelGraph.setColumnIdentifiers(tempText);
|
|
|
tableGraph.setModel(tableModelGraph);
|
|
|
tableGraph.setFillsViewportHeight(true);
|
|
|
tableGraph.setCellSelectionEnabled(true);
|
|
|
tableGraph.setColumnSelectionAllowed(true);
|
|
|
-
|
|
|
- /*
|
|
|
- * End of right container setup
|
|
|
- */
|
|
|
- scrollProperties.setViewportView(tableProperties);
|
|
|
- tableHolonElementScrollPane.setViewportView(tableHolonElement);
|
|
|
scrollGraph.setViewportView(unitGraph);
|
|
|
graphLabel.setLayout(new BorderLayout(0, 10));
|
|
|
graphLabel.add(maxGraph, BorderLayout.NORTH);
|
|
|
graphLabel.add(medGraph, BorderLayout.CENTER);
|
|
|
graphLabel.add(minGraph, BorderLayout.SOUTH);
|
|
|
toolBarGraph.add(elementGraph);
|
|
|
- // comboBoxGraph.setModel(new DefaultComboBoxModel(new String[] { "Day",
|
|
|
- // "Month", "Year" }));
|
|
|
- // toolBarGraph.add(comboBoxGraph);
|
|
|
toolBarGraph.add(resetGraphBtn);
|
|
|
toolBarGraph.setFloatable(false);
|
|
|
scrollGraph.setRowHeaderView(graphLabel);
|
|
|
scrollGraph.setColumnHeaderView(toolBarGraph);
|
|
|
- scrollElements.setLayout(new BorderLayout(0, 0));
|
|
|
- scrollElements.add(panel_HolonEl, BorderLayout.NORTH);
|
|
|
- scrollElements.add(tableHolonElementScrollPane);
|
|
|
-
|
|
|
- panel_HolonEl.setLayout(new BoxLayout(panel_HolonEl, BoxLayout.X_AXIS));
|
|
|
- toolBarHolonEl.setFloatable(false);
|
|
|
|
|
|
- panel_HolonEl.add(toolBarHolonEl);
|
|
|
- toolBarHolonEl.add(btnAddHolEL);
|
|
|
+ /***********************
|
|
|
+ * HolonElement Table Actions
|
|
|
+ **********************/
|
|
|
+ /*
|
|
|
+ * Add HolonElement to given HolonObject
|
|
|
+ */
|
|
|
btnAddHolEL.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
CpsObject tempCpsObject = getActualCps();
|
|
@@ -328,12 +326,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- resetGraphBtn.addActionListener(new ActionListener() {
|
|
|
- public void actionPerformed(ActionEvent arg0) {
|
|
|
- unitGraph.reset();
|
|
|
- }
|
|
|
- });
|
|
|
- toolBarHolonEl.add(btnDelHolEL);
|
|
|
+ /*
|
|
|
+ * Delete the choosen HolonElement of the selected HolonObject
|
|
|
+ */
|
|
|
btnDelHolEL.addActionListener(new ActionListener() {
|
|
|
public void actionPerformed(ActionEvent arg0) {
|
|
|
if (getActualCps().getClass() == HolonObject.class) {
|
|
@@ -347,7 +342,9 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ /*
|
|
|
+ * Communication between HolonElement Table and displayed Graph
|
|
|
+ */
|
|
|
tableHolonElement.addMouseListener(new MouseAdapter() {
|
|
|
public void mousePressed(MouseEvent e) {
|
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
@@ -359,32 +356,18 @@ public class GUI<E> implements CategoryListener {
|
|
|
} else {
|
|
|
elementGraph.setText("None ");
|
|
|
}
|
|
|
+ // if any HolonElement is double-clicked --> Edit instance of
|
|
|
+ // selected HolonElement
|
|
|
if (e.getClickCount() == 2) {
|
|
|
yTHIS = e.getY();
|
|
|
xTHIS = e.getX();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
- @Override
|
|
|
- public void propertyChange(PropertyChangeEvent evt) {
|
|
|
- try {
|
|
|
- Object temp;
|
|
|
- if (getActualCps() != null) {
|
|
|
- temp = tableModelProperties.getValueAt(0, 1);
|
|
|
- getActualCps().setName(temp.toString());
|
|
|
- } else {
|
|
|
- temp = tableModelProperties.getValueAt(2, 1);
|
|
|
- Float ftemp = Float.parseFloat(temp.toString());
|
|
|
- model.getSelectedEdge().setCapacity(ftemp);
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
+ /*
|
|
|
+ * If the HolonElement Table enters to editing instance, than is the
|
|
|
+ * propertyChangeListener triggered
|
|
|
+ */
|
|
|
tableHolonElement.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
@Override
|
|
|
public void propertyChange(PropertyChangeEvent evt) {
|
|
@@ -404,6 +387,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
|
eleTemp.setAmount(iTemp);
|
|
|
}
|
|
|
+ refreshTableProperties();
|
|
|
tableModelHolonElement.fireTableDataChanged();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -412,6 +396,48 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /***********************
|
|
|
+ * HolonElement Properties Actions
|
|
|
+ **********************/
|
|
|
+ /*
|
|
|
+ * If any value at the Properties Table enters to editing instance, than
|
|
|
+ * is PropertyChangeListener triggered (For HolonObject, the only value
|
|
|
+ * to be edited is the name and for CpsEdge the Max.flow)
|
|
|
+ */
|
|
|
+ tableProperties.addPropertyChangeListener(new PropertyChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void propertyChange(PropertyChangeEvent evt) {
|
|
|
+ try {
|
|
|
+ Object temp;
|
|
|
+ if (getActualCps() != null) {
|
|
|
+ temp = tableModelProperties.getValueAt(0, 1);
|
|
|
+ getActualCps().setName(temp.toString());
|
|
|
+ } else {
|
|
|
+ temp = tableModelProperties.getValueAt(2, 1);
|
|
|
+ Float ftemp = Float.parseFloat(temp.toString());
|
|
|
+ model.getSelectedEdge().setCapacity(ftemp);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /***********************
|
|
|
+ * HolonElement Graph Actions
|
|
|
+ **********************/
|
|
|
+ /*
|
|
|
+ * Reset the graph of the selected HolonElement
|
|
|
+ */
|
|
|
+ resetGraphBtn.addActionListener(new ActionListener() {
|
|
|
+ public void actionPerformed(ActionEvent arg0) {
|
|
|
+ unitGraph.reset();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ /*****************************
|
|
|
+ * RIGHT CONTAINER DONE
|
|
|
+ *****************************/
|
|
|
+
|
|
|
frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
|
|
|
|
|
|
TreeCellRenderer customRenderer = new TreeCellRenderer() {
|
|
@@ -500,10 +526,12 @@ public class GUI<E> implements CategoryListener {
|
|
|
CpsObject selected = controller.searchObjInCat(selectedNode.toString(),
|
|
|
selectedNode.getParent().toString());
|
|
|
deleteRows();
|
|
|
-// if (selected instanceof HolonObject && selected != null) {
|
|
|
-// selected = (HolonObject) selected;
|
|
|
-// fillElementTable(((HolonObject) selected).getElements());
|
|
|
-// }
|
|
|
+ // if (selected instanceof HolonObject && selected !=
|
|
|
+ // null) {
|
|
|
+ // selected = (HolonObject) selected;
|
|
|
+ // fillElementTable(((HolonObject)
|
|
|
+ // selected).getElements());
|
|
|
+ // }
|
|
|
}
|
|
|
for (Category cat : model.getCategories()) {
|
|
|
for (CpsObject cps : cat.getObjects()) {
|
|
@@ -901,23 +929,24 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- * Refresh the Table displaying the HolonElements
|
|
|
+ /**
|
|
|
+ * Update the HolonElement Table, that means erase all rows and add the new
|
|
|
+ * rows with new data
|
|
|
*/
|
|
|
public void refreshTableHolonElement() {
|
|
|
// Update of the Information about the HolonElements - only for
|
|
|
// HolonObjects
|
|
|
+
|
|
|
deleteRows();
|
|
|
if (getActualCps() != null) {
|
|
|
fillElementTable(((HolonObject) getActualCps()).getElements());
|
|
|
- } /**
|
|
|
- * hinzugef�gt damit man auch nach dem objekt platziert wurde
|
|
|
- * elemente von Objekten in Kategorien ansehen kann
|
|
|
- */
|
|
|
+ }
|
|
|
tableModelHolonElement.fireTableDataChanged();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Erase all information of the HolonElement Model
|
|
|
+ */
|
|
|
public void deleteRows() {
|
|
|
if (tableModelHolonElement.getRowCount() > 0) {
|
|
|
for (int i = tableModelHolonElement.getRowCount() - 1; i > -1; i--) {
|
|
@@ -926,6 +955,13 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Add the Information of the given ArrayList in the HolonElement Model as
|
|
|
+ * Name,Energy and Amount
|
|
|
+ *
|
|
|
+ * @param elements
|
|
|
+ * ArrayList to be displayed
|
|
|
+ */
|
|
|
public void fillElementTable(ArrayList<HolonElement> elements) {
|
|
|
for (HolonElement he : elements) {
|
|
|
Object[] temp = { he.getEleName(), he.getEnergy(), he.getAmount() };
|
|
@@ -934,7 +970,7 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Update the information about properties of the selected CpsObject
|
|
|
+ * Update the information concerning properties of the selected CpsObject
|
|
|
*/
|
|
|
public void refreshTableProperties() {
|
|
|
CpsObject tempCps = getActualCps();
|