use of easik.ui.Option in project fql by CategoricalData.
the class RowEntryDialog method getOptions.
/**
* @return
*/
@Override
public List<Option> getOptions() {
final List<Option> options = new LinkedList<>();
if (attsToTypes.isEmpty() && foreignKeys.isEmpty()) {
if (getTitle().startsWith("Update")) {
options.add(new Option("<html><i>(No attributes or outgoing edges)</i><br>Cannot update foreign keys involved in constraint."));
} else {
options.add(new Option("<html><i>(No attributes or outgoing edges)</i><br>Press OK to add a new row."));
}
setSize(300, 145);
return options;
}
for (final String name : attsToTypes.keySet()) {
final EasikType type = attsToTypes.get(name);
final JComponent c;
// else
if (type instanceof easik.database.types.Time) {
c = JUtils.fixHeight(new TimeChooser());
} else // else if (type instanceof easik.database.types.Timestamp)
// {
// c = JUtils.fixHeight(new DateTimeChooser());
// }
// else allow any input
{
c = JUtils.textField("");
c.setToolTipText(type.toString());
if (defaults.keySet().contains(name)) {
((JTextField) c).setText(defaults.get(name));
}
}
options.add(new Option("<html><b>" + name + "</b>", c));
dialogRows.add(new DialogRow(c, name, type));
}
for (final String fkName : foreignKeys.keySet()) {
// Grab target table name for "type"
final String targetType = foreignKeys.get(fkName).getName();
final JTextField idDisplay = JUtils.textField(5);
if (defaults.keySet().contains(fkName)) {
idDisplay.setText(defaults.get(fkName));
}
idDisplay.setEditable(false);
final JButton b = new JButton("Choose " + targetType);
b.addActionListener(new ForeignKeyListener(foreignKeys.get(fkName), idDisplay));
options.add(new Option("<html><b>" + fkName + "</b>", idDisplay, b));
dialogRows.add(new DialogRow(idDisplay, fkName, new Int()));
}
if (options.size() < 5) {
setSize(465, 275);
}
return options;
}
use of easik.ui.Option in project fql by CategoricalData.
the class ViewEdgeOptions method getOptions.
/**
* @return
*/
@Override
public List<Option> getOptions() {
LinkedList<Option> opts = new LinkedList<>();
_viewEdgeName = JUtils.textField((_viewEdge != null) ? _viewEdge.getName() : _theViewFrame.getMModel().getNewName());
opts.add(new Option("Edge name", _viewEdgeName));
return opts;
}
use of easik.ui.Option in project fql by CategoricalData.
the class XSDWriteOptions method getOptions.
/**
* Gets XMLDBDriver Write options.
*
* @return
*/
@Override
public List<Option> getOptions() {
final List<Option> opts = new LinkedList<>();
final Map<String, String> saved = _theFrame.getMModel().getConnectionParams();
final JPanel xsdopts = new JPanel();
xsdopts.setLayout(new BoxLayout(xsdopts, BoxLayout.Y_AXIS));
// FIXME -- we should add some help (mouseover? help button?) to
// describe these in more detail
_useTargetNameSpace = new JCheckBox("Use target namespace");
xsdopts.add(_useTargetNameSpace);
_useTargetNameSpace.setEnabled(true);
_useUnqualifiedAttributes = new JCheckBox("Use unqualified attributes");
xsdopts.add(_useUnqualifiedAttributes);
_useUnqualifiedAttributes.setEnabled(true);
_useUnqualifiedAttributes.setSelected(true);
_useUnqualifiedElements = new JCheckBox("Use unqualified elements");
xsdopts.add(_useUnqualifiedElements);
_useUnqualifiedElements.setEnabled(true);
_useUnqualifiedElements.setSelected(true);
opts.add(new Option(new JLabel("XMLDBDriver options"), xsdopts));
String topLevelTag = saved.get("topLevelTag");
if (topLevelTag == null) {
topLevelTag = _theFrame.getMModel().getDocInfo().getName().replaceAll("\\W+", "_").replaceFirst("^_+", "").replaceFirst("_+$", "");
}
_topLevelTag = JUtils.textField(topLevelTag);
opts.add(new Option(new JLabel("Top Level Tag"), _topLevelTag));
return opts;
}
use of easik.ui.Option in project fql by CategoricalData.
the class DatabaseOptions method getOptions.
/**
* @return
*/
@Override
public List<Option> getOptions() {
final List<Option> opts = new LinkedList<>();
final Map<String, String> saved = _theFrame.getMModel().getConnectionParams();
if (!_skipConnSettings) {
final String username = saved.get("username");
String hostname = saved.get("hostname");
final String port = saved.get("port");
if (hostname == null) {
// A reasonable hostname default
hostname = "localhost";
}
opts.add(new Option(new JLabel("Username"), _username = JUtils.textField(username)));
opts.add(new Option(new JLabel("Password"), _password = (JPasswordField) JUtils.fixHeight(new JPasswordField())));
opts.add(new Option(new JLabel("Database hostname"), _hostname = JUtils.textField(hostname)));
opts.add(new Option(new JLabel("Database port"), _port = JUtils.textField(port)));
}
String defaultDBName = saved.get("database");
if (defaultDBName == null) {
defaultDBName = _theFrame.getMModel().getDocInfo().getName().replaceAll("\\W+", "_").replaceFirst("^_+", "").replaceFirst("_+$", "");
}
opts.add(new Option(new JLabel("Database name"), _database = JUtils.textField(defaultDBName)));
if ("PostgreSQL".equals(_dialect)) {
String schema = saved.get("schema");
if (schema == null) {
schema = "";
}
opts.add(new Option(new JLabel("Schema name"), _schema = JUtils.textField(schema)));
}
final boolean quoting;
String quoteSetting = saved.get("quoteIdentifiers");
if (quoteSetting == null) {
quoteSetting = Easik.getInstance().getSettings().getProperty("sql_quoting");
}
quoting = (quoteSetting != null) && "true".equals(quoteSetting);
_quoteIdentifiers = new JCheckBox("Quote table and column names");
_quoteIdentifiers.setSelected(quoting);
opts.add(new Option(new JLabel("Identifier quoting"), _quoteIdentifiers));
// describe these in more detail
if (_dbd != null) {
// current settings:
if (_dbd.hasOption("hostname")) {
_hostname.setText((String) _dbd.getOption("hostname"));
}
if (_dbd.hasOption("port")) {
_port.setText((String) _dbd.getOption("port"));
}
if (_dbd.hasOption("username")) {
_username.setText((String) _dbd.getOption("username"));
}
if (_dbd.hasOption("database")) {
_database.setText((String) _dbd.getOption("database"));
}
if ("PostgreSQL".equals(_dialect) && _dbd.hasOption("schema")) {
_schema.setText((String) _dbd.getOption("schema"));
}
if (_dbd.hasOption("quoteIdentifiers")) {
_quoteIdentifiers.setSelected(Boolean.parseBoolean((String) _dbd.getOption("quoteIdentifiers")));
}
}
return opts;
}
use of easik.ui.Option in project fql by CategoricalData.
the class UniqueKeyUI method getOptions.
/**
* Generates the options/controls to prompt the user for unique key details
*
* @return
*/
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public List<Option> getOptions() {
LinkedList<Option> opts = new LinkedList<>();
opts.add(new Option("Unique key name:", _keyNameField = JUtils.textField("")));
if (_uniqueKey != null) {
_keyNameField.setText(_uniqueKey.getKeyName());
}
// Add the attributes box (only if there are attributes)
EntityAttribute[] atts = _entity.getEntityAttributes().toArray(new EntityAttribute[0]);
_attListField = new JList(atts);
if (atts.length > 0) {
opts.add(new Option("Unique key attributes:", JUtils.fixHeight(new JScrollPane(_attListField))));
}
// Add the outgoing edges box (only if there are outgoing edges)
UniqueIndexable[] edges = _entity.getIndexableEdges().toArray(new UniqueIndexable[0]);
_edgeListField = new JList(edges);
if (edges.length > 0) {
opts.add(new Option("Unique key edges:", JUtils.fixHeight(new JScrollPane(_edgeListField))));
}
if (_uniqueKey != null) {
Set<UniqueIndexable> elems = _uniqueKey.getElements();
ArrayList<Integer> setAtt = new ArrayList<>();
ArrayList<Integer> setEdges = new ArrayList<>();
for (int i = 0; i < atts.length; i++) {
if (elems.contains(atts[i])) {
setAtt.add(i);
}
}
for (int i = 0; i < edges.length; i++) {
if (elems.contains(edges[i])) {
setEdges.add(i);
}
}
int[] setA = new int[setAtt.size()];
int[] setE = new int[setEdges.size()];
for (int i = 0; i < setAtt.size(); i++) {
setA[i] = setAtt.get(i);
}
for (int i = 0; i < setEdges.size(); i++) {
setE[i] = setEdges.get(i);
}
_attListField.setSelectedIndices(setA);
_edgeListField.setSelectedIndices(setE);
}
return opts;
}
Aggregations