Package com.dci.intellij.dbn.editor.data.model

Examples of com.dci.intellij.dbn.editor.data.model.DatasetEditorModel


            editorDialog.show();
        }
    }

    public boolean isInserting() {
        DatasetEditorModel model = getTableModel();
        return model != null && model.isInserting();
    }
View Full Code Here


    /**
     * The dataset is readonly. This can not be changed by the flag isReadonly
     */
    public boolean isReadonlyData() {
        DatasetEditorModel model = getTableModel();
        return model == null || model.isReadonly();
    }
View Full Code Here

     * TransactionListener                     *
     * ******************************************************
     */
    public void beforeAction(ConnectionHandler connectionHandler, TransactionAction action) {
        if (connectionHandler == getConnectionHandler()) {
            DatasetEditorModel model = getTableModel();
            DatasetEditorTable editorTable = getEditorTable();
            if (model != null && editorTable != null) {
                if (action == TransactionAction.COMMIT) {

                    if (editorTable.isEditing()) {
                        editorTable.stopCellEditing();
                    }

                    if (isInserting()) {
                        try {
                            model.postInsertRecord(true, false);
                        } catch (SQLException e1) {
                            MessageUtil.showErrorDialog("Could not create row in " + getDataset().getQualifiedNameWithType() + ".", e1);
                        }
                    }
                }

                if (action == TransactionAction.ROLLBACK || action == TransactionAction.ROLLBACK_IDLE) {
                    if (editorTable.isEditing()) {
                        editorTable.stopCellEditing();
                    }
                    if (isInserting()) {
                        model.cancelInsert(true);
                    }
                }
            }
        }
    }
View Full Code Here

        }
    }

    public void afterAction(ConnectionHandler connectionHandler, TransactionAction action, boolean succeeded) {
        if (connectionHandler == getConnectionHandler()) {
            DatasetEditorModel model = getTableModel();
            DatasetEditorTable editorTable = getEditorTable();
            if (model != null && editorTable != null) {
                if (action == TransactionAction.COMMIT || action == TransactionAction.ROLLBACK) {
                    if (succeeded && isModified()) loadData(STATUS_CHANGE_LOAD_INSTRUCTIONS);
                }

                if (action == TransactionAction.DISCONNECT) {
                    editorTable.stopCellEditing();
                    model.revertChanges();
                    editorTable.repaint();
                }
            }
        }
    }
View Full Code Here

            }
        }
    }

    public boolean isEditable() {
        DatasetEditorModel tableModel = getTableModel();
        return tableModel != null && tableModel.isEditable() && tableModel.getConnectionHandler().isConnected();
    }
View Full Code Here

    public void navigate(boolean requestFocus) {
        if (!datasetEditor.isDisposed()) {
            DatasetEditorTable table = datasetEditor.getEditorTable();
            table.cancelEditing();
            DatasetEditorModel model = table.getModel();
            if (treeNode instanceof DBColumn &&  model.getSize() > 0) {
                DBColumn column = (DBColumn) treeNode;
                int modelColumnIndex = model.getHeader().indexOfColumn(column);
                int tableColumnIndex = table.convertColumnIndexToView(modelColumnIndex);
                int rowIndex = table.getSelectedRow();
                if (rowIndex == -1rowIndex = 0;
                if (tableColumnIndex == -1) tableColumnIndex = 0;
                table.selectCell(rowIndex, tableColumnIndex);
View Full Code Here

        textLabel.setCursor(HAND_CURSOR);
    }

    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        BasicTableGutter tableGutter = (BasicTableGutter) list;
        DatasetEditorModel model = (DatasetEditorModel) list.getModel();
        DatasetEditorModelRow row = model.getRowAtIndex(index);
        DatasetEditorTable table = (DatasetEditorTable) tableGutter.getTable();
        if (row != null) {
            Icon icon =
                    row.isNew() ? Icons.DATA_EDITOR_ROW_NEW :
                            row.isInsert() ? Icons.DATA_EDITOR_ROW_INSERT :
View Full Code Here

    public DatasetEditorKeyListener(DatasetEditorTable table) {
        this.table = table;
    }

    public void keyPressed(KeyEvent e) {
        DatasetEditorModel model = table.getModel();
        if (!e.isConsumed()) {
            int keyChar = e.getKeyChar();
            if (model.isInserting()) {
                switch (keyChar) {
                    case 27// escape
                        model.cancelInsert(true);
                        break;
                    case 10// enter
                        int index = model.getInsertRowIndex();
                        try {
                            model.postInsertRecord(false, true);
                            if (!model.isInserting()) {
                                model.insertRecord(index + 1);
                            }
                        } catch (SQLException e1) {
                            MessageUtil.showErrorDialog("Could not create row in " + table.getDataset().getQualifiedNameWithType() + ".", e1);
                        }
                        e.consume();
                }
            } else if (!table.isEditing()){
                if (keyChar == 127) {
                    for (int rowIndex : table.getSelectedRows()) {
                        for (int columnIndex : table.getSelectedColumns()) {
                            DatasetEditorModelCell cell = model.getCellAt(rowIndex, columnIndex);
                            DBDataType dataType = cell.getColumnInfo().getDataType();
                            if (dataType.isNative() && !dataType.getNativeDataType().isLOB()) {
                                cell.updateUserValue(null, true);
                            }
                        }
View Full Code Here

        mainPanel.setOpaque(false);
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int columnIndex) {
        DatasetEditorModel model = (DatasetEditorModel) table.getModel();
        sortingLabel.setText(null);
        int width = 0;
        String columnName = value.toString();
        SortingState sortingState = (SortingState) model.getSortingState();
        SortingInstruction sortingInstruction = sortingState.getSortingInstruction(columnName);

        if (sortingInstruction != null) {
            Icon icon = sortingInstruction.getDirection() == SortDirection.ASCENDING ?
                    Icons.DATA_EDITOR_SORT_ASC :
                    Icons.DATA_EDITOR_SORT_DESC;
            sortingLabel.setIcon(icon);
            width += icon.getIconWidth();
            if (sortingState.size() > 1) {
                sortingLabel.setText(Integer.toString(sortingInstruction.getIndex()));
            }
        } else {
            sortingLabel.setIcon(null);
        }

        nameLabel.setText(columnName);
        DBDataset dataset = model.getDataset();
        if (dataset != null) {
            DBColumn column = dataset.getColumn(columnName);
            if (column != null) {
                boolean primaryKey = column.isPrimaryKey();
                boolean foreignKey = column.isForeignKey();
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.editor.data.model.DatasetEditorModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.