use of org.jkiss.code.Nullable in project dbeaver by serge-rider.
the class ActionUtils method findCommandDescription.
@Nullable
public static String findCommandDescription(String commandId, IServiceLocator serviceLocator, boolean shortcutOnly) {
String commandName = null;
String shortcut = null;
ICommandService commandService = serviceLocator.getService(ICommandService.class);
if (commandService != null) {
Command command = commandService.getCommand(commandId);
if (command != null && command.isDefined()) {
try {
commandName = command.getName();
} catch (NotDefinedException e) {
log.debug(e);
}
}
}
IBindingService bindingService = serviceLocator.getService(IBindingService.class);
if (bindingService != null) {
TriggerSequence sequence = null;
for (Binding b : bindingService.getBindings()) {
ParameterizedCommand parameterizedCommand = b.getParameterizedCommand();
if (parameterizedCommand != null && commandId.equals(parameterizedCommand.getId())) {
sequence = b.getTriggerSequence();
}
}
if (sequence == null) {
sequence = bindingService.getBestActiveBindingFor(commandId);
}
if (sequence != null) {
shortcut = sequence.format();
}
}
if (shortcutOnly) {
return shortcut == null ? "?" : shortcut;
}
if (shortcut == null) {
return commandName;
}
if (commandName == null) {
return shortcut;
}
return commandName + " (" + shortcut + ")";
}
use of org.jkiss.code.Nullable in project dbeaver by serge-rider.
the class SQLEditor method getCurrentLines.
@Nullable
@Override
public int[] getCurrentLines() {
synchronized (runningQueries) {
Document document = getDocument();
if (document == null || runningQueries.isEmpty()) {
return null;
}
List<Integer> lines = new ArrayList<>(runningQueries.size() * 2);
for (SQLQuery statementInfo : runningQueries) {
try {
int firstLine = document.getLineOfOffset(statementInfo.getOffset());
int lastLine = document.getLineOfOffset(statementInfo.getOffset() + statementInfo.getLength());
for (int k = firstLine; k <= lastLine; k++) {
lines.add(k);
}
} catch (BadLocationException e) {
// ignore - this may happen is SQL was edited after execution start
}
}
if (lines.isEmpty()) {
return null;
}
int[] results = new int[lines.size()];
for (int i = 0; i < lines.size(); i++) {
results[i] = lines.get(i);
}
return results;
}
}
use of org.jkiss.code.Nullable in project dbeaver by serge-rider.
the class GenerateSQLContributor method getSelectionFromPart.
@Nullable
static IStructuredSelection getSelectionFromPart(IWorkbenchPart part) {
if (part == null) {
return null;
}
ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
if (selectionProvider == null) {
return null;
}
ISelection selection = selectionProvider.getSelection();
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
return null;
}
return (IStructuredSelection) selection;
}
use of org.jkiss.code.Nullable in project dbeaver by serge-rider.
the class JDBCCallableStatementImpl method getResultSet.
@Nullable
@Override
public JDBCResultSet getResultSet() throws SQLException {
JDBCResultSet resultSet = makeResultSet(getOriginal().getResultSet());
if (resultSet == null && procedure != null) {
JDBCResultSetCallable procResults = new JDBCResultSetCallable(getConnection(), this);
try {
Collection<? extends DBSProcedureParameter> params = procedure.getParameters(getConnection().getProgressMonitor());
if (!CommonUtils.isEmpty(params)) {
for (DBSProcedureParameter param : params) {
if (param.getParameterKind() == DBSProcedureParameterKind.OUT || param.getParameterKind() == DBSProcedureParameterKind.INOUT) {
procResults.addColumn(param.getName(), param.getParameterType());
}
}
}
} catch (DBException e) {
log.warn("Error extracting callable results", e);
}
procResults.addRow();
return procResults;
}
return resultSet;
}
use of org.jkiss.code.Nullable in project dbeaver by serge-rider.
the class SCMRoot method parseComposite.
@Nullable
@Override
public IToken parseComposite(@NotNull SCMSourceScanner scanner) {
for (; ; ) {
IToken token = scanner.nextToken();
if (token.isEOF()) {
break;
}
parseToken(this, token);
}
return null;
}
Aggregations