Package com.dci.intellij.dbn.connection

Examples of com.dci.intellij.dbn.connection.ConnectionHandler


    private void doCompileObject(DBSchemaObject object, DBContentType contentType, CompileType compileType, boolean silently) {
        object.getStatus().set(contentType, DBObjectStatus.COMPILING, true);
        Connection connection = null;
        DatabaseCompilerManager compilerManager = DatabaseCompilerManager.getInstance(getProject());
        ConnectionHandler connectionHandler = object.getConnectionHandler();
        try {
            connection = connectionHandler.getPoolConnection();
            DatabaseMetadataInterface metadataInterface = connectionHandler.getInterfaceProvider().getMetadataInterface();

            boolean isDebug = compileType == CompileType.DEBUG;

            if (compileType == CompileType.KEEP) {
                isDebug = object.getStatus().is(DBObjectStatus.DEBUG);
            }

            if (contentType == DBContentType.CODE_SPEC || contentType == DBContentType.CODE) {
                metadataInterface.compileObject(
                            object.getSchema().getName(),
                            object.getName(),
                            object.getTypeName().toUpperCase(),
                            isDebug,
                            connection);
            }
            else if (contentType == DBContentType.CODE_BODY){
                metadataInterface.compileObjectBody(
                            object.getSchema().getName(),
                            object.getName(),
                            object.getTypeName().toUpperCase(),
                            isDebug,
                            connection);

            } else if (contentType == DBContentType.CODE_SPEC_AND_BODY) {
                metadataInterface.compileObject(
                            object.getSchema().getName(),
                            object.getName(),
                            object.getTypeName().toUpperCase(),
                            isDebug,
                            connection);
                metadataInterface.compileObjectBody(
                            object.getSchema().getName(),
                            object.getName(),
                            object.getTypeName().toUpperCase(),
                            isDebug,
                            connection);
            }

            if (!silently) compilerManager.createCompilerResult(object);
        } catch (SQLException e) {
            if (!silently) compilerManager.createErrorCompilerResult(object, e);
        finally{
            connectionHandler.freePoolConnection(connection);
            if (!silently) connectionHandler.getObjectBundle().refreshObjectsStatus();
            object.getStatus().set(contentType, DBObjectStatus.COMPILING, false);
        }
    }
View Full Code Here


        }
    }

    public void compileInvalidObjects(final DBSchema schema, final CompileType compileType) {
        final Project project = schema.getProject();
        final ConnectionHandler connectionHandler = schema.getConnectionHandler();
        boolean allowed = DatabaseDebuggerManager.getInstance(project).checkForbiddenOperation(connectionHandler);
        if (allowed) {
            final CompileType selectedCompileType = getCompileTypeSelection(compileType, null);
            if (selectedCompileType != null) {
                new BackgroundTask(project, "Compiling invalid objects", false, true) {
                    public void execute(@NotNull ProgressIndicator progressIndicator) {
                        doCompileInvalidObjects(schema.getPackages(), "packages", progressIndicator, selectedCompileType);
                        doCompileInvalidObjects(schema.getFunctions(), "functions", progressIndicator, selectedCompileType);
                        doCompileInvalidObjects(schema.getProcedures(), "procedures", progressIndicator, selectedCompileType);
                        doCompileInvalidObjects(schema.getTriggers(), "triggers", progressIndicator, selectedCompileType);
                        connectionHandler.getObjectBundle().refreshObjectsStatus();

                        if (!progressIndicator.isCanceled()) {
                            List<CompilerResult> compilerErrors = new ArrayList<CompilerResult>();
                            buildCompilationErrors(schema.getPackages(), compilerErrors);
                            buildCompilationErrors(schema.getFunctions(), compilerErrors);
View Full Code Here

    public synchronized void update(AnActionEvent e) {
        Presentation presentation = e.getPresentation();
        String text = "Select connection";
        Icon icon = null;

        ConnectionHandler connectionHandler = browserComponent.getSettings().getConnectionHandler();
        if (connectionHandler != null) {
            text = NamingUtil.enhanceUnderscoresForDisplay(connectionHandler.getQualifiedName());
            icon = connectionHandler.getIcon();
        }

        presentation.setText(text);
        presentation.setIcon(icon);
    }
View Full Code Here

    }

    @NotNull
    protected DefaultActionGroup createPopupActionGroup(JComponent jComponent) {
        DefaultActionGroup actionGroup = new DefaultActionGroup();
        ConnectionHandler connectionHandler = browserComponent.getSettings().getConnectionHandler();
        if (connectionHandler != null) {
            for (DBSchema schema : connectionHandler.getObjectBundle().getSchemas()) {
                SelectSchemaAction selectSchemaAction = new SelectSchemaAction(browserComponent, schema);
                actionGroup.add(selectSchemaAction);
            }
        }
        return actionGroup;
View Full Code Here

     * ******************************************************
     */
    @Override
    public void statusChanged(String connectionId) {
        DatasetEditorTable editorTable = getEditorTable();
        ConnectionHandler connectionHandler = getConnectionHandler();
        if (editorTable != null && connectionHandler.getId().equals(connectionId)) {
            editorTable.updateBackground(!connectionHandler.isConnected());
            if (connectionHandler.isConnected()) {
                loadData(STATUS_CHANGE_LOAD_INSTRUCTIONS);
            } else {
                editorTable.repaint();
            }
        }
View Full Code Here

    public void environmentConfigChanged(String environmentTypeId) {
        EnvironmentVisibilitySettings visibilitySettings = getEnvironmentSettings(project).getVisibilitySettings();
        for (TabInfo tabInfo : resultTabs.getTabs()) {
            ExecutionResult executionResult = (ExecutionResult) tabInfo.getObject();
            if (executionResult != null) {
                ConnectionHandler connectionHandler = executionResult.getConnectionHandler();
                if (connectionHandler.getSettings().getDetailSettings().getEnvironmentTypeId().equals(environmentTypeId)) {
                    if (visibilitySettings.getExecutionResultTabs().value()){
                        tabInfo.setTabColor(connectionHandler.getEnvironmentType().getColor());
                    } else {
                        tabInfo.setTabColor(null);
                    }
                }
            }
View Full Code Here

            }
        }
    }

    private boolean selectConnection(DBLanguageFile file) {
        ConnectionHandler activeConnection = file.getActiveConnection();
        DBSchema currentSchema = file.getCurrentSchema();
        if (activeConnection == null || currentSchema == null || activeConnection.isVirtual()) {
            String message =
                    activeConnection == null ?
                            "The file is not linked to any connection.\n" +
                            "To continue with the statement execution please select a target connection." :
                    activeConnection.isVirtual() ?
                            "The connection you selected for this file is a virtual connection, used only to decide the SQL dialect.\n" +
                            "You can not execute statements against this connection. Please select a proper connection to continue." :
                    currentSchema == null ?
                            "You did not select any schema to run the statement against.\n" +
                            "To continue with the statement execution please select a schema." : null;

            String okOption =
                    activeConnection == null || activeConnection.isVirtual() ? "Select Connection" :
                    currentSchema == null ? "Select Schema" : null;

            String[] options = {okOption, "Cancel"};

            int response = Messages.showDialog(message, Constants.DBN_TITLE_PREFIX + "No valid Connection / Schema", options, 0, Messages.getWarningIcon());
View Full Code Here

    public void execute(ProgressIndicator progressIndicator) {
        progressIndicator.setText("Executing " + getStatementName());
        long startTimeMillis = System.currentTimeMillis();
        resultName = null;
        ConnectionHandler activeConnection = getActiveConnection();
        DBSchema currentSchema = getCurrentSchema();
        String originalStatementText = executablePsiElement == null ? executableStatement : executablePsiElement.getText();
        String executeStatementText = executablePsiElement == null ? executableStatement : executablePsiElement.prepareStatementText();

        StatementExecutionInput executionInput = new StatementExecutionInput(originalStatementText, executeStatementText, this);
        boolean continueExecution = true;

        if (executionVariables != null) {
            executeStatementText = executionVariables.prepareStatementText(activeConnection, executeStatementText, false);
            executionInput.setExecuteStatement(executeStatementText);

            if (executionVariables.hasErrors()) {
                executionResult = createErrorExecutionResult(executionInput, "Could not bind all variables. ");
                continueExecution = false;
            }
        }

        if (continueExecution) {
            try {
                if (!activeConnection.isDisposed()) {
                    Connection connection = activeConnection.getStandaloneConnection(currentSchema);
                    Statement statement = connection.createStatement();

                    statement.setQueryTimeout(getStatementExecutionSettings().getExecutionTimeout());
                    statement.execute(executeStatementText);
                    executionResult = createExecutionResult(statement, executionInput);
                    if (executablePsiElement != null) {
                        if (executablePsiElement.isTransactional()) activeConnection.notifyChanges(file.getVirtualFile());
                        if (executablePsiElement.isTransactionControl()) activeConnection.resetChanges();
                    }
                }
            } catch (SQLException e) {
                executionResult = createErrorExecutionResult(executionInput, e.getMessage());
            }
View Full Code Here

                int subnameIndex = StringUtil.indexOfIgnoreCase(text, contentType.getObjectTypeSubname(), typeEndIndex);
                typeEndIndex = subnameIndex + contentType.getObjectTypeSubname().length();
                if (!Character.isWhitespace(text.charAt(typeEndIndex))) return false;
            }

            ConnectionHandler connectionHandler = object.getConnectionHandler();
            char quotes = DatabaseCompatibilityInterface.getInstance(connectionHandler).getIdentifierQuotes();


            String objectName = object.getName();
            int nameIndex = StringUtil.indexOfIgnoreCase(text, objectName, typeEndIndex);
View Full Code Here

    public SQLConsoleEditorToolbarForm(SQLConsoleEditor fileEditor) {
        ActionToolbar actionToolbar = ActionUtil.createActionToolbar("", true, "DBNavigator.ActionGroup.FileEditor");
        actionsPanel.add(actionToolbar.getComponent(), BorderLayout.CENTER);
        actionToolbar.setTargetComponent(fileEditor.getComponent());

        ConnectionHandler connectionHandler = fileEditor.getVirtualFile().getConnectionHandler();
        autoCommitLabel.setConnectionHandler(connectionHandler);
    }
View Full Code Here

TOP

Related Classes of com.dci.intellij.dbn.connection.ConnectionHandler

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.