if (!_currentTabContent.getController().isRunning()) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.OPEN).setFilter(FileDialogFilter.TSPCONFIG).open();
if (path != null) {
try {
File file = new File(path);
Parameter parameter = Persister.loadParameterFile(file);
_currentTabContent.setTSPConfigFile(file);
_currentTabContent.getController().getProject().setParameter(parameter);
}
catch (IllegalArgumentException pEx) {
MessageDialog.openError(pParent, "Ung�ltige Datei", pEx.getMessage());
}
}
}
else {
MessageDialog.openError(pParent, "Konfigurationsdatei �ffnen",
"Es kann keine Konfigurationsdatei ge�ffnet werden, wenn der Algorithmus l�uft.");
}
}
});
fileMenuItemSaveConfigFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
File file = _currentTabContent.getTSPConfigFile();
if (file == null) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSPCONFIG).open();
if (path != null) {
file = new File(path);
_currentTabContent.setTSPConfigFile(file);
}
}
if (file != null) {
Persister.saveParameterFile(file, _currentTabContent.getController().getProject().getParameter());
}
}
});
fileMenuItemSaveConfigFileAs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSPCONFIG).open();
if (path != null) {
File file = new File(path);
_currentTabContent.setTSPConfigFile(file);
Persister.saveParameterFile(file, _currentTabContent.getController().getProject().getParameter());
}
}
});
fileMenuItemClose.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
pParent.close();
}
});
editMenuItemCreateRandomProject.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
if (!_currentTabContent.getController().isRunning()) {
RandomProjectDialog randomProjectDialog = new RandomProjectDialog(pParent, _currentTabContent.getController().getProject());
TSPData data = randomProjectDialog.open();
if (data != null) {
_currentTabContent.getController().getProject().setTSPData(data);
}
}
else {
MessageDialog.openError(pParent, "Zufallsprojekt erstellen",
"Es kann kein Zufallsprojekt erstellt werden, wenn der Algorithmus l�uft.");
}
}
});
editMenuItemCreateRandomParameter.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
if (!_currentTabContent.getController().isRunning()) {
int antCount = (int) (Math.random() * 99) + 1;
int iterationCount = (int) (Math.random() * 9999) + 1;
double pheromonParameter = 5 - Math.random() * 5;
double localInformation = 5 - Math.random() * 5;
double evaporationParameter = 1 - Math.random();
double initialPheromonParameter = 10 - Math.random() * 10;
double pheromonUpdateParameter = 10 - Math.random() * 10;
Parameter param = _currentTabContent.getController().getProject().getParameter();
param.setAntCount(antCount);
param.setIterationCount(iterationCount);
param.setPheromonParameter(pheromonParameter);
param.setLocalInformation(localInformation);
param.setEvaporationParameter(evaporationParameter);
param.setInitialPheromonParameter(initialPheromonParameter);
param.setPheromonUpdateParameter(pheromonUpdateParameter);
}
else {
MessageDialog.openError(pParent, "Zufallsparameter erstellen",
"Es k�nnen keine Zufallsparameter erstellt werden, wenn der Algorithmus l�uft.");
}