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 ResultSetFilterPanel method getActiveSourceQuery.
@NotNull
private String getActiveSourceQuery() {
String displayName;
DBSDataContainer dataContainer = viewer.getDataContainer();
if (dataContainer != null) {
displayName = dataContainer.getName();
} else {
displayName = getActiveQueryText();
}
return displayName;
}
use of org.jkiss.code.NotNull in project dbeaver by serge-rider.
the class DB2BaseTableToolDialog method getScriptListener.
@Override
protected SQLScriptProgressListener<DB2Table> getScriptListener() {
final int nbExtraColumns = getNumberExtraResultingColumns();
return new SQLScriptStatusDialog<DB2Table>(getShell(), getTitle() + " " + DB2Messages.dialog_table_tools_progress, null) {
@Override
protected void createStatusColumns(Tree objectTree) {
TreeColumn msgColumn = new TreeColumn(objectTree, SWT.NONE);
msgColumn.setText(DB2Messages.dialog_table_tools_result);
for (int i = 0; i < nbExtraColumns; i++) {
new TreeColumn(objectTree, SWT.NONE);
}
}
@Override
public void endObjectProcessing(@NotNull DB2Table db2Table, Exception exception) {
TreeItem treeItem = getTreeItem(db2Table);
if (exception == null) {
treeItem.setText(1, DB2Messages.dialog_table_tools_success_title);
} else {
treeItem.setText(1, exception.getMessage());
}
UIUtils.packColumns(treeItem.getParent(), false, null);
}
// DF: This method is for tools that return resultsets
@Override
public void processObjectResults(@NotNull DB2Table db2Table, @Nullable DBCStatement statement, @Nullable DBCResultSet resultSet) throws DBCException {
if (resultSet == null) {
return;
}
// Retrive column names
JDBCResultSetMetaDataImpl rsMetaData = (JDBCResultSetMetaDataImpl) resultSet.getMeta();
try {
TreeItem treeItem = getTreeItem(db2Table);
Font f = UIUtils.makeBoldFont(treeItem.getFont());
if (treeItem != null) {
// Display the column names
TreeItem subItem = null;
subItem = new TreeItem(treeItem, SWT.NONE);
subItem.setFont(f);
for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
subItem.setText(i, rsMetaData.getColumnName(i + 1));
subItem.setGrayed(true);
}
// Display the data for each row
while (resultSet.nextRow()) {
subItem = new TreeItem(treeItem, SWT.NONE);
for (int i = 0; i < rsMetaData.getColumnCount(); i++) {
subItem.setText(i, CommonUtils.toString(resultSet.getAttributeValue(i)));
}
}
treeItem.setExpanded(true);
}
} catch (SQLException e) {
throw new DBCException(e.getMessage());
}
}
};
}
Aggregations