Search in sources :

Example 1 with NotNull

use of org.jkiss.code.NotNull in project dbeaver by serge-rider.

the class NavigatorHandlerLinkEditor method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
    final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
    if (activeEditor == null) {
        return null;
    }
    NavigatorViewBase navigatorView = NavigatorUtils.getActiveNavigatorView(event);
    if (navigatorView == null) {
        return null;
    }
    if (navigatorView instanceof ProjectExplorerView) {
        if (activeEditor instanceof SQLEditor) {
            IFile file = EditorUtils.getFileFromInput(activeEditor.getEditorInput());
            if (file != null) {
                showResourceInNavigator(navigatorView, file);
            }
        } else if (activeEditor.getEditorInput() instanceof ProjectFileEditorInput) {
            IFile editorFile = ((ProjectFileEditorInput) activeEditor.getEditorInput()).getFile();
            showResourceInNavigator(navigatorView, editorFile);
        }
    } else if (activeEditor.getEditorInput() instanceof IDatabaseEditorInput) {
        IDatabaseEditorInput editorInput = (IDatabaseEditorInput) activeEditor.getEditorInput();
        DBNNode dbnNode = editorInput.getNavigatorNode();
        if (dbnNode != null) {
            navigatorView.showNode(dbnNode);
        }
    } else if (activeEditor instanceof IDataSourceContainerProvider) {
        DBPDataSourceContainer dsContainer = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
        @NotNull final DBSObject activeObject;
        if (dsContainer != null) {
            DBPDataSource dataSource = dsContainer.getDataSource();
            if (dataSource != null) {
                activeObject = DBUtils.getDefaultOrActiveObject(dataSource);
            } else {
                activeObject = dsContainer;
            }
            final NavigatorViewBase view = navigatorView;
            DBeaverUI.runInUI(activePage.getWorkbenchWindow(), new DBRRunnableWithProgress() {

                @Override
                public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                    DBSObject showObject = activeObject;
                    if (showObject instanceof DBPDataSource) {
                        showObject = ((DBPDataSource) showObject).getContainer();
                    }
                    DBNDatabaseNode objectNode = view.getModel().getNodeByObject(monitor, showObject, true);
                    if (objectNode != null) {
                        view.showNode(objectNode);
                    }
                }
            });
        }
    }
    activePage.activate(navigatorView);
    return null;
}
Also used : SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) IDataSourceContainerProvider(org.jkiss.dbeaver.model.IDataSourceContainerProvider) ProjectExplorerView(org.jkiss.dbeaver.ui.navigator.project.ProjectExplorerView) IFile(org.eclipse.core.resources.IFile) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) ProjectFileEditorInput(org.jkiss.dbeaver.ui.editors.ProjectFileEditorInput) IEditorPart(org.eclipse.ui.IEditorPart) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource) NotNull(org.jkiss.code.NotNull) InvocationTargetException(java.lang.reflect.InvocationTargetException) IDatabaseEditorInput(org.jkiss.dbeaver.ui.editors.IDatabaseEditorInput) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) NavigatorViewBase(org.jkiss.dbeaver.ui.navigator.database.NavigatorViewBase) DBRRunnableWithProgress(org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)

Example 2 with NotNull

use of org.jkiss.code.NotNull in project dbeaver by serge-rider.

the class ConnectionWizard method getActiveDataSource.

@NotNull
public DataSourceDescriptor getActiveDataSource() {
    DriverDescriptor driver = getSelectedDriver();
    DataSourceDescriptor info = infoMap.get(driver);
    if (info == null) {
        DBPConnectionConfiguration connectionInfo = new DBPConnectionConfiguration();
        info = new DataSourceDescriptor(getDataSourceRegistry(), DataSourceDescriptor.generateNewId(getSelectedDriver()), getSelectedDriver(), connectionInfo);
        info.getConnectionConfiguration().setClientHomeId(driver.getDefaultClientHomeId());
        infoMap.put(driver, info);
    }
    return info;
}
Also used : DBPConnectionConfiguration(org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration) DriverDescriptor(org.jkiss.dbeaver.registry.driver.DriverDescriptor) DataSourceDescriptor(org.jkiss.dbeaver.registry.DataSourceDescriptor) NotNull(org.jkiss.code.NotNull)

Example 3 with NotNull

use of org.jkiss.code.NotNull in project dbeaver by serge-rider.

the class DialogUtils method createOutputFolderChooser.

@NotNull
public static Text createOutputFolderChooser(final Composite parent, @Nullable String label, @Nullable ModifyListener changeListener) {
    final String message = label != null ? label : CoreMessages.data_transfer_wizard_output_label_directory;
    UIUtils.createControlLabel(parent, message);
    final TextWithOpen directoryText = new TextWithOpen(parent) {

        @Override
        protected void openBrowser() {
            DirectoryDialog dialog = new DirectoryDialog(parent.getShell(), SWT.NONE);
            dialog.setMessage("Choose target directory");
            dialog.setText(message);
            String directory = getText();
            if (CommonUtils.isEmpty(directory)) {
                directory = curDialogFolder;
            }
            if (!CommonUtils.isEmpty(directory)) {
                dialog.setFilterPath(directory);
            }
            directory = dialog.open();
            if (directory != null) {
                setText(directory);
                setCurDialogFolder(directory);
            }
        }
    };
    directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (changeListener != null) {
        directoryText.getTextControl().addModifyListener(changeListener);
    }
    return directoryText.getTextControl();
}
Also used : TextWithOpen(org.jkiss.dbeaver.ui.controls.TextWithOpen) GridData(org.eclipse.swt.layout.GridData) NotNull(org.jkiss.code.NotNull)

Example 4 with NotNull

use of org.jkiss.code.NotNull in project dbeaver by serge-rider.

the class ExasolTableUniqueKeyCache method prepareObjectsStatement.

@SuppressWarnings("rawtypes")
@NotNull
@Override
protected JDBCStatement prepareObjectsStatement(JDBCSession session, ExasolSchema exasolSchema, ExasolTable forTable) throws SQLException {
    String sql;
    if (forTable != null) {
        sql = String.format(SQL_UK_TAB, ExasolUtils.quoteString(exasolSchema.getName()), ExasolUtils.quoteString(forTable.getName()));
    } else {
        sql = String.format(SQL_UK_ALL, ExasolUtils.quoteString(exasolSchema.getName()));
    }
    JDBCStatement dbStat = session.createStatement();
    ((JDBCStatementImpl) dbStat).setQueryString(sql);
    return dbStat;
}
Also used : JDBCStatement(org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement) JDBCStatementImpl(org.jkiss.dbeaver.model.impl.jdbc.exec.JDBCStatementImpl) NotNull(org.jkiss.code.NotNull)

Example 5 with NotNull

use of org.jkiss.code.NotNull in project dbeaver by serge-rider.

the class GenericDataSourceProvider method openDataSource.

@NotNull
@Override
public DBPDataSource openDataSource(@NotNull DBRProgressMonitor monitor, @NotNull DBPDataSourceContainer container) throws DBException {
    GenericMetaModelDescriptor metaModel = null;
    Object metaModelId = container.getDriver().getDriverParameter(GenericConstants.PARAM_META_MODEL);
    if (metaModelId != null && !GenericConstants.META_MODEL_STANDARD.equals(metaModelId)) {
        metaModel = metaModels.get(metaModelId.toString());
        if (metaModel == null) {
            log.warn("Meta model '" + metaModelId + "' not recognized. Default one will be used");
        }
    }
    if (metaModel == null) {
        // Try to get model by driver class
        metaModel = metaModels.get(container.getDriver().getDriverClassName());
    }
    if (metaModel == null) {
        metaModel = getStandardMetaModel();
    }
    GenericMetaModel metaModelInstance = metaModel.getInstance();
    return metaModelInstance.createDataSource(monitor, container);
}
Also used : GenericMetaModelDescriptor(org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModelDescriptor) GenericMetaModel(org.jkiss.dbeaver.ext.generic.model.meta.GenericMetaModel) NotNull(org.jkiss.code.NotNull)

Aggregations

NotNull (org.jkiss.code.NotNull)58 JDBCPreparedStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCPreparedStatement)11 SQLException (java.sql.SQLException)9 DBCException (org.jkiss.dbeaver.model.exec.DBCException)9 DBException (org.jkiss.dbeaver.DBException)7 JDBCStatement (org.jkiss.dbeaver.model.exec.jdbc.JDBCStatement)7 DBCResultSet (org.jkiss.dbeaver.model.exec.DBCResultSet)6 ArrayList (java.util.ArrayList)5 Tree (org.eclipse.swt.widgets.Tree)5 TreeColumn (org.eclipse.swt.widgets.TreeColumn)5 TreeItem (org.eclipse.swt.widgets.TreeItem)5 Nullable (org.jkiss.code.Nullable)5 DBCStatement (org.jkiss.dbeaver.model.exec.DBCStatement)5 JDBCSession (org.jkiss.dbeaver.model.exec.jdbc.JDBCSession)5 DBRProgressMonitor (org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)5 DBSTypedObject (org.jkiss.dbeaver.model.struct.DBSTypedObject)5 SQLScriptStatusDialog (org.jkiss.dbeaver.ui.dialogs.sql.SQLScriptStatusDialog)4 DBDValueHandler (org.jkiss.dbeaver.model.data.DBDValueHandler)3 SQLDataSource (org.jkiss.dbeaver.model.sql.SQLDataSource)3 SQLDialect (org.jkiss.dbeaver.model.sql.SQLDialect)3