Search in sources :

Example 1 with SQLEditorKit

use of org.santfeliu.swing.text.SQLEditorKit in project gdmatrix by gdmatrix.

the class SelectBoxEditor method initComponents.

private void initComponents() throws Exception {
    this.setLayout(gridBagLayout2);
    this.setMinimumSize(new Dimension(400, 340));
    this.setBorder(new EmptyBorder(10, 10, 10, 10));
    addButton.setText("Add");
    addButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addButton_actionPerformed(e);
        }
    });
    insertButton.setText("Insert");
    insertButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            insertButton_actionPerformed(e);
        }
    });
    deleteButton.setText("Delete");
    deleteButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            deleteButton_actionPerformed(e);
        }
    });
    JTextPane sqlTextPane = sqlEditor.getTextPane();
    sqlTextPane.setEditorKitForContentType("text/sql", new SQLEditorKit());
    sqlTextPane.setContentType("text/sql");
    sqlTextPane.setSelectionColor(new Color(198, 198, 198));
    sqlTextPane.setFont(Options.getEditorFont());
    scrollPane.getViewport().add(optionsTable, null);
    scrollPane.setPreferredSize(new Dimension(400, 150));
    sqlEditor.setPreferredSize(new Dimension(300, 100));
    sqlEditor.setMinimumSize(new Dimension(300, 100));
    sqlEditor.setBorder(new LineBorder(Color.LIGHT_GRAY));
    SymbolHighlighter symbolHighlighter = new SymbolHighlighter(sqlEditor.getTextPane(), "({[", ")}]");
    datarefLabel.setText("Dataref:");
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    this.add(scrollPane, new GridBagConstraints(1, 2, 2, 3, 1.0, 0.5, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(addButton, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(insertButton, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(deleteButton, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(variableLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(variableTextField, new GridBagConstraints(1, 0, 1, 1, 0.4, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(sqlEditor, new GridBagConstraints(1, 7, 2, 1, 0.0, 0.5, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(4, 4, 4, 4), 0, 0));
    this.add(staticLabel, new GridBagConstraints(0, 1, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(dynamicLabel, new GridBagConstraints(0, 5, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(sqlLabel, new GridBagConstraints(0, 7, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(connLabel, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(connTextField, new GridBagConstraints(1, 6, 1, 1, 0.4, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(connInfoLabel, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(usernameLabel, new GridBagConstraints(0, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(usernameTextField, new GridBagConstraints(1, 8, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(passwordLabel, new GridBagConstraints(0, 9, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(passwordField, new GridBagConstraints(1, 9, 1, 1, 0.4, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(datarefLabel, new GridBagConstraints(0, 10, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    this.add(datarefTextField, new GridBagConstraints(1, 10, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(4, 4, 4, 4), 0, 0));
    optionsTable.setAutoCreateColumnsFromModel(false);
    tableModel.addColumn("Label");
    tableModel.addColumn("Value");
    optionsTable.setModel(tableModel);
    passwordLabel.setText("Password:");
    usernameLabel.setText("Username:");
    connLabel.setText("Connection:");
    connInfoLabel.setText("DSN or alias");
    sqlLabel.setText("SQL (id, label):");
    dynamicLabel.setText("Dynamic options:");
    staticLabel.setText("Static options:");
    variableLabel.setText("Variable:");
    JTextField editorTextField = new JTextField();
    editorTextField.setBorder(null);
    DefaultCellEditor editor = new DefaultCellEditor(editorTextField);
    editor.setClickCountToStart(2);
    optionsTable.addColumn(new TableColumn(0, 300, null, editor));
    optionsTable.addColumn(new TableColumn(1, 100, null, editor));
    optionsTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    optionsTable.getTableHeader().setReorderingAllowed(false);
}
Also used : SQLEditorKit(org.santfeliu.swing.text.SQLEditorKit) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) ActionEvent(java.awt.event.ActionEvent) Color(java.awt.Color) LineBorder(javax.swing.border.LineBorder) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) TableColumn(javax.swing.table.TableColumn) DefaultCellEditor(javax.swing.DefaultCellEditor) JTextPane(javax.swing.JTextPane) SymbolHighlighter(org.santfeliu.swing.text.SymbolHighlighter) ActionListener(java.awt.event.ActionListener) EmptyBorder(javax.swing.border.EmptyBorder)

Example 2 with SQLEditorKit

use of org.santfeliu.swing.text.SQLEditorKit in project gdmatrix by gdmatrix.

the class SQLNodeEditor method initComponents.

private void initComponents() throws Exception {
    this.setLayout(borderLayout);
    northPanel.setLayout(gridBagLayout1);
    dsnLabel.setText("DSN:");
    centerPanel.setLayout(borderLayout1);
    centerPanel.setBorder(BorderFactory.createTitledBorder("SQL statements"));
    JTextPane textPane = textEditor.getTextPane();
    textPane.setFont(Options.getEditorFont());
    northPanel.add(dsnLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 4, 2, 4), 0, 0));
    northPanel.add(dsnTextField, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 0, 2, 6), 0, 0));
    northPanel.add(maxRowsLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(2, 4, 2, 4), 0, 0));
    northPanel.add(maxRowsSpinner, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(2, 0, 2, 6), 0, 0));
    this.add(northPanel, BorderLayout.NORTH);
    textEditor.setBorder(new LineBorder(Color.LIGHT_GRAY));
    centerPanel.add(textEditor, BorderLayout.CENTER);
    this.add(centerPanel, BorderLayout.CENTER);
    textPane.setEditorKitForContentType("text/sql", new SQLEditorKit());
    textPane.setContentType("text/sql");
    textPane.setSelectionColor(new Color(198, 198, 198));
    maxRowsLabel.setText("Max. rows:");
    spinnerModel.setStepSize(1);
    spinnerModel.setMinimum(1);
    maxRowsSpinner.setModel(spinnerModel);
    Dimension dim = maxRowsSpinner.getPreferredSize();
    dim.width = 3 * dim.height;
    maxRowsSpinner.setPreferredSize(dim);
    maxRowsSpinner.setMinimumSize(dim);
}
Also used : SQLEditorKit(org.santfeliu.swing.text.SQLEditorKit) JTextPane(javax.swing.JTextPane) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) LineBorder(javax.swing.border.LineBorder) Color(java.awt.Color) Dimension(java.awt.Dimension)

Aggregations

Color (java.awt.Color)2 Dimension (java.awt.Dimension)2 GridBagConstraints (java.awt.GridBagConstraints)2 Insets (java.awt.Insets)2 JTextPane (javax.swing.JTextPane)2 LineBorder (javax.swing.border.LineBorder)2 SQLEditorKit (org.santfeliu.swing.text.SQLEditorKit)2 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 DefaultCellEditor (javax.swing.DefaultCellEditor)1 JTextField (javax.swing.JTextField)1 EmptyBorder (javax.swing.border.EmptyBorder)1 TableColumn (javax.swing.table.TableColumn)1 SymbolHighlighter (org.santfeliu.swing.text.SymbolHighlighter)1