return true;
}
@Override
protected JComponent getDialogContent() {
DCPanel formPanel = new DCPanel();
int row = 0;
DCLabel descriptionLabel = DCLabel
.brightMultiLine("A datastore dictionary is a dictionary based on a column in one of your datastores. Please select a datastore in the form below and a tree of that datastore will appear. From here on you can select which column in the datastore to use for dictionary lookups.");
descriptionLabel.setBorder(new EmptyBorder(0, 0, 0, 20));
descriptionLabel.setPreferredSize(new Dimension(300, 100));
WidgetUtils.addToGridBag(descriptionLabel, formPanel, 0, row, 2, 1);
row++;
WidgetUtils.addToGridBag(DCLabel.bright("Dictionary 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("Lookup column:"), formPanel, 0, row);
WidgetUtils.addToGridBag(_columnTextField, formPanel, 1, row);
row++;
JButton createDictionaryButton = WidgetFactory.createButton("Save dictionary", "images/model/dictionary.png");
createDictionaryButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String name = _nameTextField.getText();
if (StringUtils.isNullOrEmpty(name)) {
JOptionPane.showMessageDialog(DatastoreDictionaryDialog.this,
"Please fill out the name of the dictionary");
return;
}
String datastoreName = (String) _datastoreComboBox.getSelectedItem();
if (StringUtils.isNullOrEmpty(datastoreName)) {
JOptionPane.showMessageDialog(DatastoreDictionaryDialog.this, "Please select a datastore");
return;
}
String columnPath = _columnTextField.getText();
if (StringUtils.isNullOrEmpty(columnPath)) {
JOptionPane.showMessageDialog(DatastoreDictionaryDialog.this, "Please select a lookup column");
return;
}
DatastoreDictionary dictionary = new DatastoreDictionary(name, datastoreName, columnPath);
if (_originalDictionary != null) {
_referenceDataCatalog.removeDictionary(_originalDictionary);
}
_referenceDataCatalog.addDictionary(dictionary);
DatastoreDictionaryDialog.this.dispose();
}
});
DCPanel buttonPanel = new DCPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.RIGHT, 0, 0));
buttonPanel.add(createDictionaryButton);
WidgetUtils.addToGridBag(buttonPanel, formPanel, 0, row, 2, 1);
_splitPane.add(formPanel);
_splitPane.add(_treePanel);