Package com.dci.intellij.dbn.connection

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


        connectionsList.addListSelectionListener(listener);
        schemasList.addListSelectionListener(listener);
    }

    private void populateSchemaList() {
        ConnectionHandler selectedConnection = getSelectedConnection();
        if (selectedConnection == null) {
            schemasList.setModel(new DefaultListModel());
        } else {
            List<DBSchema> schemas = selectedConnection.getObjectBundle().getSchemas();
            DefaultListModel model = new DefaultListModel();

            for (DBSchema schema : schemas) {
                model.addElement(schema);
            }
            schemasList.setModel(model);
            DBSchema selectedSchema =
                    activeConnection == selectedConnection ? currentSchema :
                    selectedConnection.getObjectBundle().getUserSchema();
            schemasList.setSelectedValue(selectedSchema, true);
        }
    }
View Full Code Here


import java.awt.Color;
import java.awt.Component;

public class ConnectionListCellRenderer extends DefaultListCellRenderer{
    public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
        ConnectionHandler connectionHandler = (ConnectionHandler) value;
        JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus );
        String name = connectionHandler.getQualifiedName();

        ConnectivityStatus connectivityStatus = connectionHandler.getSettings().getDatabaseSettings().getConnectivityStatus();
        boolean active = connectionHandler.isActive();

        Icon icon = Icons.CONNECTION_DISABLED;
        if (active) {
            icon = connectivityStatus == ConnectivityStatus.VALID ? Icons.CONNECTION_ACTIVE :
                   connectivityStatus == ConnectivityStatus.INVALID ? Icons.CONNECTION_INVALID : Icons.CONNECTION_INACTIVE;
View Full Code Here

    public void invoke(@NotNull Project project, Editor editor, PsiFile psiFile) throws IncorrectOperationException {
        DefaultActionGroup actionGroup = new DefaultActionGroup();
        DBLanguageFile dbLanguageFile = (DBLanguageFile) psiFile;

        ConnectionHandler connectionHandler = dbLanguageFile.getActiveConnection();
        if (connectionHandler != null && !connectionHandler.isVirtual() && !connectionHandler.isDisposed()) {
            List<DBSchema> schemas = connectionHandler.getObjectBundle().getSchemas();
            for (DBSchema schema  :schemas) {
                SelectSchemaAction schemaAction = new SelectSchemaAction(schema, dbLanguageFile);
                actionGroup.add(schemaAction);
            }
        }
View Full Code Here

        ProgressMonitor.setTaskDescription("Loading " + dynamicContent.getContentDescription());

        DebugInfo debugInfo = preLoadContent(dynamicContent);

        dynamicContent.checkDisposed();
        ConnectionHandler connectionHandler = dynamicContent.getConnectionHandler();
        LoaderCache loaderCache = new LoaderCache();
        Connection connection = null;
        ResultSet resultSet = null;
        int count = 0;
        try {
            connectionHandler.getLoadMonitor().incrementLoaderCount();
            connection = connectionHandler.getPoolConnection();
            dynamicContent.checkDisposed();
            resultSet = createResultSet(dynamicContent, connection);
            if (addDelay) Thread.sleep(500);
            List<T> list = null;
            while (resultSet != null && resultSet.next()) {
                if (addDelay) Thread.sleep(10);
                dynamicContent.checkDisposed();
               
                T element = null;
                try {
                    element = createElement(dynamicContent, resultSet, loaderCache);
                } catch (RuntimeException e){
                    System.out.println("RuntimeException: " + e.getMessage());
                }

                dynamicContent.checkDisposed();
                if (element != null && dynamicContent.accepts(element)) {
                    if (list == null) list = new ArrayList<T>();
                    list.add(element);
                    if (count%10 == 0) {
                        String description = element.getDescription();
                        if (description != null)
                            ProgressMonitor.setSubtaskDescription(description);
                    }
                    count++;
                }
            }
            dynamicContent.checkDisposed();
            dynamicContent.setElements(list);
            postLoadContent(dynamicContent, debugInfo);
        } catch (Exception e) {
            if (e instanceof InterruptedException) throw (InterruptedException) e;
            if (e == DynamicContentLoader.DBN_INTERRUPTED_EXCEPTION) throw new InterruptedException();

            String message = StringUtil.trim(e.getMessage()).replace("\n", " ");
            LOGGER.warn("Error loading database content (" + dynamicContent.getContentDescription() + "): " + message);

            boolean modelException = false;
            if (e instanceof SQLException) {

                SQLException sqlException = (SQLException) e;
                DatabaseInterfaceProvider interfaceProvider = dynamicContent.getConnectionHandler().getInterfaceProvider();
                modelException = interfaceProvider.getMessageParserInterface().isModelException(sqlException);
            }
            throw new DynamicContentLoadException(e, modelException);
        } finally {
            connectionHandler.getLoadMonitor().decrementLoaderCount();
            ConnectionUtil.closeResultSet(resultSet);
            connectionHandler.freePoolConnection(connection);
        }
    }
View Full Code Here

            if (schemaObject != null && DatabaseFileSystem.getInstance().isFileOpened(schemaObject)) {
                return schemaObject.getConnectionHandler();
            }

            // lookup connection mappings
            ConnectionHandler connectionHandler = virtualFile.getUserData(ACTIVE_CONNECTION_KEY);
            if (connectionHandler == null) {
                FileConnectionMapping mapping = lookupMapping(virtualFile);
                if (mapping != null) {
                    ConnectionManager connectionManager = ConnectionManager.getInstance(project);
                    connectionHandler = connectionManager.getConnectionHandler(mapping.getConnectionId());
View Full Code Here

            }

            // lookup schema mappings
            DBObjectRef<DBSchema> currentSchemaRef = virtualFile.getUserData(CURRENT_SCHEMA_KEY);
            if (currentSchemaRef == null) {
                ConnectionHandler connectionHandler = getActiveConnection(virtualFile);
                if (connectionHandler != null && !connectionHandler.isVirtual()) {
                    FileConnectionMapping mapping = lookupMapping(virtualFile);
                    if (mapping != null) {
                        String schemaName = mapping.getCurrentSchema();
                        if (StringUtil.isEmptyOrSpaces(schemaName)) {
                            DBSchema userSchema = connectionHandler.getUserSchema();
                            currentSchemaRef = userSchema == null ? null : userSchema.getRef();
                            schemaName = currentSchemaRef == null ? null : currentSchemaRef.getName();
                        } else {
                            DBSchema schema = connectionHandler.getObjectBundle().getSchema(schemaName);
                            currentSchemaRef = schema == null ? null : schema.getRef();
                        }
                        mapping.setCurrentSchema(schemaName);
                        virtualFile.putUserData(CURRENT_SCHEMA_KEY, currentSchemaRef);
                    }
View Full Code Here

        }

        if (psiElement instanceof TokenPsiElement) annotateToken((TokenPsiElement) psiElement, holder)else
        if (psiElement instanceof IdentifierPsiElement) {
            IdentifierPsiElement identifierPsiElement = (IdentifierPsiElement) psiElement;
            ConnectionHandler connectionHandler = identifierPsiElement.getActiveConnection();
            if (connectionHandler != null) {
                annotateIdentifier(psiElement, holder);
            }
        }
View Full Code Here

        }
       
        Language language = getLanguage();
        if (language instanceof DBLanguage) {
            DBLanguage dbLanguage = (DBLanguage) language;
            ConnectionHandler connectionHandler = getActiveConnection();
            if (connectionHandler != null) {

                DBLanguageDialect languageDialect = connectionHandler.getLanguageDialect(dbLanguage);
                if (languageDialect != null){
                    return languageDialect;
                }
            } else {
                return dbLanguage.getAvailableLanguageDialects()[0];
View Full Code Here

    public SyntaxHighlighter getSyntaxHighlighter(Project project, VirtualFile virtualFile) {
        if (virtualFile != null && virtualFile.getFileType() instanceof DBLanguageFileType) {
            DBLanguageFileType fileType = (DBLanguageFileType) virtualFile.getFileType();
            DBLanguage language = (DBLanguage) fileType.getLanguage();
            if (project != null) {
                ConnectionHandler connectionHandler = FileConnectionMappingManager.getInstance(project).getActiveConnection(virtualFile);
                DBLanguageDialect languageDialect = connectionHandler == null ?
                        language.getMainLanguageDialect() :
                        connectionHandler.getLanguageDialect(language);

                return languageDialect.getSyntaxHighlighter();
            }
        }
View Full Code Here

        }
        return null;
    }

    public void selectElement(BrowserTreeNode treeNode, boolean requestFocus) {
        ConnectionHandler connectionHandler = treeNode.getConnectionHandler();
        SimpleBrowserForm browserForm = getBrowserForm(connectionHandler);
        if (browserForm != null) {
            connectionTabs.select(browserForm.getComponent(), requestFocus);
            browserForm.selectElement(treeNode, requestFocus);
        }
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.