* @author Gerald Toepper
* @param toggled
* Indicates whether the scenarios export button was toggled.
*/
private void onScenariosCheck(final boolean toggled) {
final ModelManager modelManager = ModelManager.getInstance();
final Collection<ModelElement> elements = modelManager.getAllModelElements();
boolean startAreaDefined = false;
boolean destinationAreaDefined = false;
final List<String> startAreasWithNoDestinationAreas = new ArrayList<String>();
final List<String> areasWithNoUnderlyingEdges = new ArrayList<String>();
final List<AreaModel> areas = new ArrayList<AreaModel>();
for (final ModelElement element : elements) {
if (element instanceof AreaModel) {
final AreaModel area = (AreaModel) element;
areas.add(area);
if (area.getAreaType() == AreaType.START) {
startAreaDefined = true;
final List<AreaModel> destinationAreas = area.getDestinationAreas();
if ((destinationAreas == null) || (destinationAreas.size() == 0)) {
startAreasWithNoDestinationAreas.add(area.getIdentifier());
}
} else {
destinationAreaDefined = true;
}
final List<EdgeModel> edges = area.getLocation().getEdges();
if ((edges == null) || (edges.size() == 0)) {
areasWithNoUnderlyingEdges.add(area.getIdentifier());
}
}
}
// generate error list
final List<String> errorList = new ArrayList<String>();
// check whether a start and a destination area is defined
if (!startAreaDefined && !destinationAreaDefined) {
errorList.add("- no area defined (at least one start area or one destination area)");
}
// check whether all start areas have destination areas defined in case
// destination areas exist
if ((startAreasWithNoDestinationAreas.size() > 0) && destinationAreaDefined) {
final StringBuffer buffer = new StringBuffer();
for (final String startArea : startAreasWithNoDestinationAreas) {
if (buffer.length() == 0) {
buffer.append("- the following start areas have no destination area: ");
} else {
buffer.append(", ");
}
buffer.append(startArea);
}
errorList.add(buffer.toString());
}
// check whether all areas have underlying edges
if (areasWithNoUnderlyingEdges.size() > 0) {
final StringBuffer buffer = new StringBuffer();
for (final String area : areasWithNoUnderlyingEdges) {
if (buffer.length() == 0) {
buffer.append("- the following areas have no underlying edges: ");
} else {
buffer.append(", ");
}
buffer.append(area);
}
errorList.add(buffer.toString());
}
if (errorList.size() > 0) {
// generate error string
final StringBuffer errorBuffer = new StringBuffer("The following errors occured:");
for (final String error : errorList) {
errorBuffer.append("\n").append(error);
}
// create message box
JOptionPane.showMessageDialog(this, errorBuffer.toString(), "Errors in scenarios-config", JOptionPane.WARNING_MESSAGE);
scenariosCheckBox.setSelected(false);
return;
} else if (scenariosCheckBox.isSelected()) {
// generate warning list
final List<String> warningList = new ArrayList<String>();
// check simulation times
final int simulationStartTime = modelManager.getSimulationStartTime();
final int simulationEndTime = modelManager.getSimulationEndTime();
final List<AreaModel> adaptedSimulationTimes = new ArrayList<AreaModel>();
for (final AreaModel area : areas) {
final int actualSimulationTime = area.getSimulationTime();