|
@@ -80,6 +80,7 @@ import classes.IdCounter;
|
|
import classes.IdCounterElem;
|
|
import classes.IdCounterElem;
|
|
import interfaces.CategoryListener;
|
|
import interfaces.CategoryListener;
|
|
import ui.controller.Control;
|
|
import ui.controller.Control;
|
|
|
|
+import ui.controller.UpdateController;
|
|
import ui.model.Model;
|
|
import ui.model.Model;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -267,6 +268,8 @@ public class GUI<E> implements CategoryListener {
|
|
private String eraseCategory = "Do you really want to delete the Category ";
|
|
private String eraseCategory = "Do you really want to delete the Category ";
|
|
private String selectObjBeforeErase = "Please select a Category or an Object in order to delete something.";
|
|
private String selectObjBeforeErase = "Please select a Category or an Object in order to delete something.";
|
|
|
|
|
|
|
|
+ UpdateController updCon;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Create the application.
|
|
* Create the application.
|
|
*
|
|
*
|
|
@@ -288,7 +291,7 @@ public class GUI<E> implements CategoryListener {
|
|
simMenu = new SimulationMenu(model, control);
|
|
simMenu = new SimulationMenu(model, control);
|
|
initialize();
|
|
initialize();
|
|
updateCategories(model.getCategories());
|
|
updateCategories(model.getCategories());
|
|
-
|
|
|
|
|
|
+ updCon = new UpdateController(model, controller);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -685,8 +688,8 @@ public class GUI<E> implements CategoryListener {
|
|
controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
|
|
controller.addElementCanvasObject(tempCpsObject.getID(), ele.getEleName(), ele.getAmount(),
|
|
ele.getEnergy());
|
|
ele.getEnergy());
|
|
}
|
|
}
|
|
- refreshTableHolonElement();
|
|
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableHolonElement(tableModelHolonElementMulti, tableModelHolonElementSingle);
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -704,8 +707,8 @@ public class GUI<E> implements CategoryListener {
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
HolonObject obj = (HolonObject) getActualCps();
|
|
for (HolonElement e : selectedElements) {
|
|
for (HolonElement e : selectedElements) {
|
|
controller.deleteElementCanvas(obj.getID(), e.getId());
|
|
controller.deleteElementCanvas(obj.getID(), e.getId());
|
|
- refreshTableHolonElement();
|
|
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableHolonElement(tableModelHolonElementMulti, tableModelHolonElementSingle);
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
// Names displayed in graph are not updated
|
|
// Names displayed in graph are not updated
|
|
}
|
|
}
|
|
@@ -719,8 +722,8 @@ public class GUI<E> implements CategoryListener {
|
|
controller.deleteElementCanvas(i, e.getId());
|
|
controller.deleteElementCanvas(i, e.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- refreshTableHolonElement();
|
|
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableHolonElement(tableModelHolonElementMulti, tableModelHolonElementSingle);
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
eleToDelete.clear();
|
|
eleToDelete.clear();
|
|
selectedElements.clear();
|
|
selectedElements.clear();
|
|
}
|
|
}
|
|
@@ -801,7 +804,7 @@ public class GUI<E> implements CategoryListener {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
int selectedValueX = (int) Math.floor(xThis / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueX = (int) Math.floor(xThis / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueBX = (int) Math.floor(xBThis / (tableHolonElement.getWidth() / 6));
|
|
int selectedValueBX = (int) Math.floor(xBThis / (tableHolonElement.getWidth() / 6));
|
|
- if (getHolonObj(yMouse) != null) {
|
|
|
|
|
|
+ if (updCon.getHolonObj(yMouse, tableModelHolonElementMulti) != null) {
|
|
// For last column (boolean with a checkbox)
|
|
// For last column (boolean with a checkbox)
|
|
if (selectedValueBX == 5) {
|
|
if (selectedValueBX == 5) {
|
|
HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
|
|
HolonElement eleBTemp = getActualHolonElement(null, yBMouse, 0);
|
|
@@ -862,7 +865,7 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
tableModelHolonElementSingle.fireTableDataChanged();
|
|
tableModelHolonElementSingle.fireTableDataChanged();
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
controller.calculateStateForTimeStep(model.getCurIteration());
|
|
unitGraph.repaint();
|
|
unitGraph.repaint();
|
|
@@ -922,9 +925,10 @@ public class GUI<E> implements CategoryListener {
|
|
((HolonSwitch) getActualCps()).setManualState(bTemp);
|
|
((HolonSwitch) getActualCps()).setManualState(bTemp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }// else if (getActualCps() instanceof AbstractCpsObject) {
|
|
|
|
- getActualCps().setName(temp.toString());
|
|
|
|
- //}
|
|
|
|
|
|
+ } // else if (getActualCps() instanceof
|
|
|
|
+ // AbstractCpsObject) {
|
|
|
|
+ getActualCps().setName(temp.toString());
|
|
|
|
+ // }
|
|
} else {
|
|
} else {
|
|
temp = tableModelProperties.getValueAt(selValueY, selValueX);
|
|
temp = tableModelProperties.getValueAt(selValueY, selValueX);
|
|
btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
|
|
btemp = tableModelProperties.getValueAt(mousePos.y / tableProperties.getRowHeight(),
|
|
@@ -1085,8 +1089,8 @@ public class GUI<E> implements CategoryListener {
|
|
.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
|
|
.getPathForLocation(e.getX(), e.getY()).getLastPathComponent();
|
|
if (selectedNode.getLevel() == 2) {
|
|
if (selectedNode.getLevel() == 2) {
|
|
controller.searchCategoryObject(selectedNode.getParent().toString(), selectedNode.toString());
|
|
controller.searchCategoryObject(selectedNode.getParent().toString(), selectedNode.toString());
|
|
- deleteRows(tableModelHolonElementSingle);
|
|
|
|
- deleteRows(tableModelHolonElementMulti);
|
|
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementSingle);
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementMulti);
|
|
// if (selected instanceof HolonObject && selected !=
|
|
// if (selected instanceof HolonObject && selected !=
|
|
// null) {
|
|
// null) {
|
|
// selected = (HolonObject) selected;
|
|
// selected = (HolonObject) selected;
|
|
@@ -1244,7 +1248,7 @@ public class GUI<E> implements CategoryListener {
|
|
// For HolonObjects the Total Energy (production or
|
|
// For HolonObjects the Total Energy (production or
|
|
// consumption) is calculated
|
|
// consumption) is calculated
|
|
if (temp instanceof HolonObject) {
|
|
if (temp instanceof HolonObject) {
|
|
- refreshTableHolonElement();
|
|
|
|
|
|
+ updCon.refreshTableHolonElement(tableModelHolonElementMulti, tableModelHolonElementSingle);
|
|
Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) temp).getCurrentEnergy() };
|
|
Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) temp).getCurrentEnergy() };
|
|
tableModelProperties.addRow(tempEnergy);
|
|
tableModelProperties.addRow(tempEnergy);
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
@@ -1253,8 +1257,8 @@ public class GUI<E> implements CategoryListener {
|
|
} // For HolonSwitches is showed the actual status (active
|
|
} // For HolonSwitches is showed the actual status (active
|
|
// or inactive)
|
|
// or inactive)
|
|
else if (temp instanceof HolonSwitch) {
|
|
else if (temp instanceof HolonSwitch) {
|
|
- deleteRows(tableModelHolonElementSingle);
|
|
|
|
- deleteRows(tableModelHolonElementMulti);
|
|
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementSingle);
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementMulti);
|
|
Object[] tempMode = { Languages.getLanguage()[74], ((HolonSwitch) temp).getManualMode() };
|
|
Object[] tempMode = { Languages.getLanguage()[74], ((HolonSwitch) temp).getManualMode() };
|
|
tableModelProperties.addRow(tempMode);
|
|
tableModelProperties.addRow(tempMode);
|
|
if (((HolonSwitch) temp).getManualMode()) {
|
|
if (((HolonSwitch) temp).getManualMode()) {
|
|
@@ -1273,8 +1277,8 @@ public class GUI<E> implements CategoryListener {
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
tableModelProperties.setCellEditable(0, 1, true);
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
} else {
|
|
} else {
|
|
- deleteRows(tableModelHolonElementSingle);
|
|
|
|
- deleteRows(tableModelHolonElementMulti);
|
|
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementSingle);
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementMulti);
|
|
}
|
|
}
|
|
// For Objects the only editable cell is the name
|
|
// For Objects the only editable cell is the name
|
|
ArrayList<CpsEdge> tempArray = temp.getConnections();
|
|
ArrayList<CpsEdge> tempArray = temp.getConnections();
|
|
@@ -1330,8 +1334,8 @@ public class GUI<E> implements CategoryListener {
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
tableModelProperties.setCellEditable(2, 1, true);
|
|
tableModelProperties.setCellEditable(3, 1, true);
|
|
tableModelProperties.setCellEditable(3, 1, true);
|
|
} else if (getActualCps() == null) {
|
|
} else if (getActualCps() == null) {
|
|
- deleteRows(tableModelHolonElementSingle);
|
|
|
|
- deleteRows(tableModelHolonElementMulti);
|
|
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementSingle);
|
|
|
|
+ updCon.deleteRows(tableModelHolonElementMulti);
|
|
} // Update of the HolonElementTable (Single- or
|
|
} // Update of the HolonElementTable (Single- or
|
|
// Multi-Selection)
|
|
// Multi-Selection)
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
@@ -1347,8 +1351,8 @@ public class GUI<E> implements CategoryListener {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void mouseReleased(MouseEvent e) {
|
|
public void mouseReleased(MouseEvent e) {
|
|
- refreshTableHolonElement();
|
|
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableHolonElement(tableModelHolonElementMulti, tableModelHolonElementSingle);
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
if (model.getSelectedCpsObjects().size() > 1) {
|
|
tableHolonElement.setModel(tableModelHolonElementMulti);
|
|
tableHolonElement.setModel(tableModelHolonElementMulti);
|
|
} else if (model.getSelectedCpsObjects().size() == 1) {
|
|
} else if (model.getSelectedCpsObjects().size() == 1) {
|
|
@@ -1499,7 +1503,7 @@ public class GUI<E> implements CategoryListener {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
Languages.setLanguage(0);
|
|
Languages.setLanguage(0);
|
|
refreshLanguages();
|
|
refreshLanguages();
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
spanishBtn.addActionListener(new ActionListener() {
|
|
spanishBtn.addActionListener(new ActionListener() {
|
|
@@ -1508,7 +1512,7 @@ public class GUI<E> implements CategoryListener {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
Languages.setLanguage(1);
|
|
Languages.setLanguage(1);
|
|
refreshLanguages();
|
|
refreshLanguages();
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
germanBtn.addActionListener(new ActionListener() {
|
|
germanBtn.addActionListener(new ActionListener() {
|
|
@@ -1517,7 +1521,7 @@ public class GUI<E> implements CategoryListener {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
Languages.setLanguage(2);
|
|
Languages.setLanguage(2);
|
|
refreshLanguages();
|
|
refreshLanguages();
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
czechBtn.addActionListener(new ActionListener() {
|
|
czechBtn.addActionListener(new ActionListener() {
|
|
@@ -1526,7 +1530,7 @@ public class GUI<E> implements CategoryListener {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
Languages.setLanguage(3);
|
|
Languages.setLanguage(3);
|
|
refreshLanguages();
|
|
refreshLanguages();
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
chineseBtn.addActionListener(new ActionListener() {
|
|
chineseBtn.addActionListener(new ActionListener() {
|
|
@@ -1535,7 +1539,8 @@ public class GUI<E> implements CategoryListener {
|
|
public void actionPerformed(ActionEvent e) {
|
|
public void actionPerformed(ActionEvent e) {
|
|
Languages.setLanguage(4);
|
|
Languages.setLanguage(4);
|
|
refreshLanguages();
|
|
refreshLanguages();
|
|
- refreshTableProperties();
|
|
|
|
|
|
+ updCon.refreshTableProperties(tableModelProperties);
|
|
|
|
+ ;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
@@ -1852,98 +1857,6 @@ public class GUI<E> implements CategoryListener {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * Search for clicked HolonObject through the mouse's y-Coord.
|
|
|
|
- *
|
|
|
|
- * @param yValue
|
|
|
|
- * the Y Coordination
|
|
|
|
- * @return clicked HolonObject
|
|
|
|
- */
|
|
|
|
- private HolonObject getHolonObj(int yValue) {
|
|
|
|
- final int yTemp = (int) Math.floor(yValue / 16);
|
|
|
|
- HolonObject obtTemp = null;
|
|
|
|
- String temp = tableModelHolonElementMulti.getValueAt(yTemp, 0).toString();
|
|
|
|
- int idTemp = Integer.parseInt(temp.split(", ")[1]);
|
|
|
|
- obtTemp = (HolonObject) controller.searchByID(idTemp);
|
|
|
|
- return obtTemp;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Update the HolonElement Table, that means erase all rows and add the new
|
|
|
|
- * rows with new data.
|
|
|
|
- */
|
|
|
|
- private void refreshTableHolonElement() {
|
|
|
|
- // Update of the Information about the HolonElements - only for
|
|
|
|
- // HolonObjects
|
|
|
|
-
|
|
|
|
- if (model.getSelectedCpsObjects().size() > 1) {
|
|
|
|
- deleteRows(tableModelHolonElementMulti);
|
|
|
|
- fillElementTable(model.getSelectedCpsObjects());
|
|
|
|
- tableModelHolonElementMulti.fireTableDataChanged();
|
|
|
|
- } else if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
|
- deleteRows(tableModelHolonElementSingle);
|
|
|
|
- fillElementTable(model.getSelectedCpsObjects());
|
|
|
|
- tableModelHolonElementSingle.fireTableDataChanged();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Erase all information of the HolonElement Model.
|
|
|
|
- *
|
|
|
|
- * @param t
|
|
|
|
- * the Table
|
|
|
|
- */
|
|
|
|
- private void deleteRows(PropertyTable t) {
|
|
|
|
- if (t.getRowCount() > 0) {
|
|
|
|
- for (int i = t.getRowCount() - 1; i > -1; i--) {
|
|
|
|
- t.removeRow(i);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Add the Information of the given ArrayList in the HolonElement Model as
|
|
|
|
- * Name,Energy and Amount.
|
|
|
|
- *
|
|
|
|
- * @param objects
|
|
|
|
- * ArrayList to be displayed
|
|
|
|
- */
|
|
|
|
- private void fillElementTable(ArrayList<AbstractCpsObject> objects) {
|
|
|
|
- if (objects.size() > 1) {
|
|
|
|
- for (AbstractCpsObject o : objects) {
|
|
|
|
- if (o instanceof HolonObject) {
|
|
|
|
- for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
|
|
- Object[] temp = { o.getName() + ", " + o.getID(), he.getId(), he.getEleName(), he.getEnergy(),
|
|
|
|
- he.getAmount(), he.getActive() };
|
|
|
|
- tableModelHolonElementMulti.addRow(temp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (objects.size() == 1) {
|
|
|
|
- AbstractCpsObject o = objects.get(0);
|
|
|
|
- if (o instanceof HolonObject) {
|
|
|
|
- for (HolonElement he : ((HolonObject) o).getElements()) {
|
|
|
|
- Object[] temp = { he.getId(), he.getEleName(), he.getEnergy(), he.getAmount(), he.getActive() };
|
|
|
|
- tableModelHolonElementSingle.addRow(temp);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- /**
|
|
|
|
- * Update the information concerning properties of the selected CpsObject.
|
|
|
|
- */
|
|
|
|
- private void refreshTableProperties() {
|
|
|
|
- if (model.getSelectedCpsObjects().size() == 1) {
|
|
|
|
- AbstractCpsObject tempCps = getActualCps();
|
|
|
|
- if (tempCps != null && tempCps.getClass() == HolonObject.class) {
|
|
|
|
- tableModelProperties.removeRow(2);
|
|
|
|
- Object[] tempEnergy = { Languages.getLanguage()[73], ((HolonObject) tempCps).getCurrentEnergy() };
|
|
|
|
- tableModelProperties.insertRow(2, tempEnergy);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* Adds a Popup.
|
|
* Adds a Popup.
|
|
*
|
|
*
|
|
@@ -2058,13 +1971,14 @@ public class GUI<E> implements CategoryListener {
|
|
*/
|
|
*/
|
|
private void openNewUpperNodeTab() {
|
|
private void openNewUpperNodeTab() {
|
|
UpperNodeCanvas unc;
|
|
UpperNodeCanvas unc;
|
|
- if(((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
- .getComponent(0) instanceof MyCanvas){
|
|
|
|
- unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp, "" );
|
|
|
|
|
|
+ if (((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0) instanceof MyCanvas) {
|
|
|
|
+ unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp, "");
|
|
} else {
|
|
} else {
|
|
- unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp, ((UpperNodeCanvas)((JScrollPane) tabbedPane.getSelectedComponent()).getViewport().getComponent(0)).path+" -> " );
|
|
|
|
|
|
+ unc = new UpperNodeCanvas(model, controller, (CpsUpperNode) temp,
|
|
|
|
+ ((UpperNodeCanvas) ((JScrollPane) tabbedPane.getSelectedComponent()).getViewport()
|
|
|
|
+ .getComponent(0)).path + " -> ");
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
unc.setBorder(null);
|
|
unc.setBorder(null);
|
|
unc.setBackground(Color.WHITE);
|
|
unc.setBackground(Color.WHITE);
|
|
unc.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|
|
unc.setPreferredSize(new Dimension(model.getCanvasX(), model.getCanvasY()));
|