deleteConfigButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (patternsConfigName != null) {
final MessageBox messageBox = new MessageBox(parent.getShell(),
SWT.ICON_QUESTION | SWT.YES | SWT.NO);
messageBox.setMessage("Delete \"" + patternsConfigName + "\"?");
messageBox.setText("Delete configuration");
if (messageBox.open() == SWT.YES) {
ConfigurationManager.removeTPConfig(patternsConfigName);
patternsConfigName = null;
configNameLabel.setText("");
}
}
}
});
// "Save patterns" button
saveConfigButton.setToolTipText("Save current pattern set");
saveConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
saveConfigButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (patternsConfigName != null) {
if (!ConfigurationManager.saveTPConfig(patternsConfigName)) {
final MessageBox messageBox = new MessageBox(parent.getShell(),
SWT.ICON_ERROR | SWT.OK);
messageBox.setMessage("Unable to save configuration: "
+ patternsConfigName);
messageBox.setText("Error");
messageBox.open();
}
}
}
});
// "Save patterns as..." button
saveAsConfigButton.setToolTipText("Save current pattern set as...");
saveAsConfigButton.setImage(PlatformUI.getWorkbench().getSharedImages()
.getImage(ISharedImages.IMG_ETOOL_SAVEAS_EDIT));
saveAsConfigButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
final String[] configurations = ConfigurationManager.getTPConfigs();
final Set<String> existingNames = new HashSet<String>(Arrays
.asList(configurations));
final InputDialog dialog = new ConfigurationSaveAsDialog(parent
.getShell(), "Save trace pattern configuration",
"Enter name for configuration:", patternsConfigName,
existingNames);
if (dialog.open() == Window.OK) {
if (ConfigurationManager.saveTPConfig(dialog.getValue())) {
patternsConfigName = dialog.getValue();
configNameLabel.setText(patternsConfigName);
} else {
final MessageBox messageBox = new MessageBox(parent.getShell(),
SWT.ICON_ERROR | SWT.OK);
messageBox.setMessage("Unable to save configuration: "
+ dialog.getValue());
messageBox.setText("Error");
messageBox.open();
}
}
}
});
}