|
@@ -260,10 +260,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", "Activated" };
|
|
|
tableModelHolonElement.setColumnIdentifiers(columnNames);
|
|
@@ -272,6 +271,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" };
|
|
@@ -281,42 +289,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();
|
|
@@ -331,13 +329,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) {
|
|
@@ -351,7 +345,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();
|
|
@@ -363,6 +359,8 @@ 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();
|
|
@@ -373,26 +371,10 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- 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) {
|
|
@@ -423,8 +405,36 @@ public class GUI<E> implements CategoryListener {
|
|
|
Integer iTemp = Integer.parseInt(newStuff);
|
|
|
eleTemp.setAmount(iTemp);
|
|
|
}
|
|
|
- tableModelHolonElement.fireTableDataChanged();
|
|
|
}
|
|
|
+ refreshTableProperties();
|
|
|
+ tableModelHolonElement.fireTableDataChanged();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ /***********************
|
|
|
+ * 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) {
|
|
|
|
|
@@ -432,6 +442,21 @@ public class GUI<E> implements CategoryListener {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ /***********************
|
|
|
+ * 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() {
|
|
@@ -923,23 +948,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--) {
|
|
@@ -948,6 +974,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(), he.getActive() };
|
|
@@ -956,7 +989,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();
|