Search in sources :

Example 1 with Option

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;
}
Also used : JComponent(javax.swing.JComponent) JButton(javax.swing.JButton) JTextField(javax.swing.JTextField) LinkedList(java.util.LinkedList) Int(easik.database.types.Int) Option(easik.ui.Option) EasikType(easik.database.types.EasikType)

Example 2 with Option

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;
}
Also used : Option(easik.ui.Option) LinkedList(java.util.LinkedList)

Example 3 with Option

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;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) Option(easik.ui.Option) LinkedList(java.util.LinkedList)

Example 4 with Option

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;
}
Also used : JCheckBox(javax.swing.JCheckBox) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) Option(easik.ui.Option) LinkedList(java.util.LinkedList)

Example 5 with Option

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) EntityAttribute(easik.model.attribute.EntityAttribute) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) Option(easik.ui.Option) JList(javax.swing.JList)

Aggregations

Option (easik.ui.Option)9 LinkedList (java.util.LinkedList)9 JLabel (javax.swing.JLabel)6 BoxLayout (javax.swing.BoxLayout)3 JCheckBox (javax.swing.JCheckBox)3 JPanel (javax.swing.JPanel)3 EasikType (easik.database.types.EasikType)2 Int (easik.database.types.Int)2 BigInt (easik.database.types.BigInt)1 Blob (easik.database.types.Blob)1 Char (easik.database.types.Char)1 Custom (easik.database.types.Custom)1 Date (easik.database.types.Date)1 Decimal (easik.database.types.Decimal)1 DoublePrecision (easik.database.types.DoublePrecision)1 SmallInt (easik.database.types.SmallInt)1 Text (easik.database.types.Text)1 Time (easik.database.types.Time)1 Timestamp (easik.database.types.Timestamp)1 Varchar (easik.database.types.Varchar)1