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;
}
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;
}
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();
}
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;
}
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);
}
Aggregations