}
@Override
protected JComponent getDialogContent() {
final DCPanel formPanel = new DCPanel();
int row = 0;
final DCLabel descriptionLabel = DCLabel
.brightMultiLine("A datastore synonym catalog is based on a datastore and columns within it. The layout of the datastore is flexible: There should be a master term column and either a single or multiple synonym columns.");
descriptionLabel.setBorder(new EmptyBorder(10, 10, 10, 20));
descriptionLabel.setPreferredSize(new Dimension(300, 100));
WidgetUtils.addToGridBag(DCLabel.bright("Synonym catalog name:"), formPanel, 0, row);
WidgetUtils.addToGridBag(_nameTextField, formPanel, 1, row);
row++;
WidgetUtils.addToGridBag(DCLabel.bright("Datastore:"), formPanel, 0, row);
WidgetUtils.addToGridBag(_datastoreComboBox, formPanel, 1, row);
row++;
WidgetUtils.addToGridBag(DCLabel.bright("Master term column:"), formPanel, 0, row);
WidgetUtils.addToGridBag(_masterTermColumnComboBox, formPanel, 1, row);
row++;
WidgetUtils.addToGridBag(DCLabel.bright("Synonym columns:"), formPanel, 0, row);
WidgetUtils.addToGridBag(_synonymColumnsPanel.createPanel(), formPanel, 1, row);
row++;
final JButton saveButton = WidgetFactory.createButton("Save Synonym Catalog", "images/model/synonym.png");
saveButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = _nameTextField.getText();
if (StringUtils.isNullOrEmpty(name)) {
JOptionPane.showMessageDialog(DatastoreSynonymCatalogDialog.this,
"Please fill out the name of the synonym catalog");
return;
}
String nameOfDatastore = (String) _datastoreComboBox.getSelectedItem();
if (StringUtils.isNullOrEmpty(nameOfDatastore)) {
JOptionPane.showMessageDialog(DatastoreSynonymCatalogDialog.this, "Please select a character encoding");
return;
}
Column selectedItem = _masterTermColumnComboBox.getSelectedItem();
String[] synonymColumnNames = _synonymColumnsPanel.getColumnNames();
DatastoreSynonymCatalog dataStoreBasedSynonymCatalog = new DatastoreSynonymCatalog(name, nameOfDatastore,
selectedItem.getQualifiedLabel(), synonymColumnNames);
if (_originalsynonymCatalog != null) {
_mutableReferenceCatalog.removeSynonymCatalog(_originalsynonymCatalog);
}
_mutableReferenceCatalog.addSynonymCatalog(dataStoreBasedSynonymCatalog);
DatastoreSynonymCatalogDialog.this.dispose();
}
});
final DCPanel buttonPanel = new DCPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
buttonPanel.add(saveButton);
WidgetUtils.addToGridBag(buttonPanel, formPanel, 0, row, 2, 1);
final DCPanel mainPanel = new DCPanel();
mainPanel.setLayout(new VerticalLayout(4));
mainPanel.add(descriptionLabel);
mainPanel.add(formPanel);
return mainPanel;
}