if (!_currentTabContent.getController().isRunning()) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.OPEN).setFilter(FileDialogFilter.TSP).open();
if (path != null) {
try {
File file = new File(path);
TSPData data = Persister.loadTSPFile(file);
_currentTabContent.setTSPFile(file);
_tabFolder.getSelection().setText(data.getName());
_currentTabContent.getController().getProject().setTSPData(data);
}
catch (IllegalArgumentException pEx) {
MessageDialog.openError(pParent, "Ung�ltige Datei", pEx.getMessage());
}
}
}
else {
MessageDialog.openError(pParent, "TSP Datei �ffnen", "Es kann keine TSP Datei ge�ffnet werden, wenn der Algorithmus l�uft.");
}
}
});
fileMenuItemSaveTSPFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
File file = _currentTabContent.getTSPFile();
if (file == null) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSP).open();
if (path != null) {
file = new File(path);
_currentTabContent.setTSPFile(file);
}
}
if (file != null) {
Persister.saveTSPFile(file, _currentTabContent.getController().getProject().getTSPData());
}
}
});
fileMenuItemSaveTSPFileAs.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
String path = new FileDialogFactory().setParent(pParent).setStyle(SWT.SAVE).setFilter(FileDialogFilter.TSP).open();
if (path != null) {
File file = new File(path);
_currentTabContent.setTSPFile(file);
Persister.saveTSPFile(file, _currentTabContent.getController().getProject().getTSPData());
}
}
});
fileMenuItemOpenConfigFile.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent pE) {
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 {