Search in sources :

Example 1 with IDataSourceContainerProviderEx

use of org.jkiss.dbeaver.model.IDataSourceContainerProviderEx in project dbeaver by dbeaver.

the class DataSourceInvalidateHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    DBCExecutionContext context = getActiveExecutionContext(event, false);
    if (context != null) {
        invalidateDataSource(context.getDataSource());
    } else {
        IEditorPart editor = HandlerUtil.getActiveEditor(event);
        if (editor instanceof IDataSourceContainerProviderEx) {
            // Try to set the same container.
            // It should trigger connection instantiation if for some reason it was lost (SQLEditor specific?)
            DBPDataSourceContainer dsContainer = ((IDataSourceContainerProviderEx) editor).getDataSourceContainer();
            if (dsContainer != null) {
                ((IDataSourceContainerProviderEx) editor).setDataSourceContainer(null);
                ((IDataSourceContainerProviderEx) editor).setDataSourceContainer(dsContainer);
            }
        }
    }
    return null;
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) IEditorPart(org.eclipse.ui.IEditorPart) IDataSourceContainerProviderEx(org.jkiss.dbeaver.model.IDataSourceContainerProviderEx) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 2 with IDataSourceContainerProviderEx

use of org.jkiss.dbeaver.model.IDataSourceContainerProviderEx in project dbeaver by serge-rider.

the class DataSourceInvalidateHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    DBCExecutionContext context = getActiveExecutionContext(event, false);
    if (context != null) {
        invalidateDataSource(context.getDataSource());
    } else {
        IEditorPart editor = HandlerUtil.getActiveEditor(event);
        if (editor instanceof IDataSourceContainerProviderEx) {
            // Try to set the same container.
            // It should trigger connection instantiation if for some reason it was lost (SQLEditor specific?)
            DBPDataSourceContainer dsContainer = ((IDataSourceContainerProviderEx) editor).getDataSourceContainer();
            if (dsContainer != null) {
                ((IDataSourceContainerProviderEx) editor).setDataSourceContainer(null);
                ((IDataSourceContainerProviderEx) editor).setDataSourceContainer(dsContainer);
            }
        }
    }
    return null;
}
Also used : DBCExecutionContext(org.jkiss.dbeaver.model.exec.DBCExecutionContext) IEditorPart(org.eclipse.ui.IEditorPart) IDataSourceContainerProviderEx(org.jkiss.dbeaver.model.IDataSourceContainerProviderEx) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Aggregations

IEditorPart (org.eclipse.ui.IEditorPart)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 IDataSourceContainerProviderEx (org.jkiss.dbeaver.model.IDataSourceContainerProviderEx)2 DBCExecutionContext (org.jkiss.dbeaver.model.exec.DBCExecutionContext)2