use of org.jkiss.dbeaver.ui.controls.resultset.ResultSetValueController in project dbeaver by serge-rider.
the class FilterValueEditDialog method createSingleValueEditor.
private void createSingleValueEditor(Composite composite) {
Composite editorPlaceholder = UIUtils.createPlaceholder(composite, 1);
editorPlaceholder.setLayoutData(new GridData(GridData.FILL_BOTH));
editorPlaceholder.setLayout(new FillLayout());
ResultSetRow singleRow = handler.getRows()[0];
final ResultSetValueController valueController = new ResultSetValueController(handler.getViewer(), handler.getAttribute(), singleRow, IValueController.EditType.INLINE, editorPlaceholder) {
@Override
public boolean isReadOnly() {
// Filter value is never read-only
return false;
}
};
IValueEditor editor = null;
try {
editor = valueController.getValueManager().createEditor(valueController);
} catch (Exception e) {
log.error("Can't create inline value editor", e);
}
if (editor == null) {
editor = new StringInlineEditor(valueController);
}
handler.setEditor(editor);
editor.createControl();
try {
editor.primeEditorValue(valueController.getValue());
} catch (DBException e) {
log.error("Error populating filter value", e);
}
}
use of org.jkiss.dbeaver.ui.controls.resultset.ResultSetValueController in project dbeaver by serge-rider.
the class GenerateUUIDHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart == null) {
return null;
}
IResultSetController rsc = activePart.getAdapter(IResultSetController.class);
if (rsc != null && UIUtils.hasFocus(rsc.getControl())) {
IResultSetSelection selection = rsc.getSelection();
if (selection != null && !selection.isEmpty()) {
for (Object cell : selection.toArray()) {
DBDAttributeBinding attr = selection.getElementAttribute(cell);
ResultSetRow row = selection.getElementRow(cell);
if (row != null && attr != null) {
ResultSetValueController valueController = new ResultSetValueController(rsc, attr, row, IValueController.EditType.NONE, null);
DBDValueHandler valueHandler = valueController.getValueHandler();
String uuid = generateUUID();
valueController.updateValue(uuid, false);
}
}
rsc.redrawData(false, false);
rsc.updateEditControls();
}
} else {
ITextViewer textViewer = activePart.getAdapter(ITextViewer.class);
if (textViewer != null) {
ISelection selection = textViewer.getSelectionProvider().getSelection();
if (selection instanceof TextSelection) {
try {
int offset = ((TextSelection) selection).getOffset();
int length = ((TextSelection) selection).getLength();
String uuid = generateUUID();
textViewer.getDocument().replace(offset, length, uuid);
textViewer.getSelectionProvider().setSelection(new TextSelection(offset + uuid.length(), 0));
} catch (BadLocationException e) {
DBWorkbench.getPlatformUI().showError("Insert UUID", "Error inserting UUID in text editor", e);
}
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.controls.resultset.ResultSetValueController in project dbeaver by dbeaver.
the class GenerateUUIDHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart == null) {
return null;
}
IResultSetController rsc = activePart.getAdapter(IResultSetController.class);
if (rsc != null && UIUtils.hasFocus(rsc.getControl())) {
IResultSetSelection selection = rsc.getSelection();
if (selection != null && !selection.isEmpty()) {
for (Object cell : selection.toArray()) {
DBDAttributeBinding attr = selection.getElementAttribute(cell);
ResultSetRow row = selection.getElementRow(cell);
if (row != null && attr != null) {
ResultSetValueController valueController = new ResultSetValueController(rsc, attr, row, IValueController.EditType.NONE, null);
DBDValueHandler valueHandler = valueController.getValueHandler();
String uuid = generateUUID();
valueController.updateValue(uuid, false);
}
}
rsc.redrawData(false, false);
rsc.updateEditControls();
}
} else {
ITextViewer textViewer = activePart.getAdapter(ITextViewer.class);
if (textViewer != null) {
ISelection selection = textViewer.getSelectionProvider().getSelection();
if (selection instanceof TextSelection) {
try {
int offset = ((TextSelection) selection).getOffset();
int length = ((TextSelection) selection).getLength();
String uuid = generateUUID();
textViewer.getDocument().replace(offset, length, uuid);
textViewer.getSelectionProvider().setSelection(new TextSelection(offset + uuid.length(), 0));
} catch (BadLocationException e) {
DBWorkbench.getPlatformUI().showError("Insert UUID", "Error inserting UUID in text editor", e);
}
}
}
}
return null;
}
use of org.jkiss.dbeaver.ui.controls.resultset.ResultSetValueController in project dbeaver by dbeaver.
the class FilterValueEditDialog method createSingleValueEditor.
private void createSingleValueEditor(Composite composite) {
Composite editorPlaceholder = UIUtils.createPlaceholder(composite, 1);
editorPlaceholder.setLayoutData(new GridData(GridData.FILL_BOTH));
editorPlaceholder.setLayout(new FillLayout());
ResultSetRow singleRow = handler.getRows()[0];
final ResultSetValueController valueController = new ResultSetValueController(handler.getViewer(), handler.getAttribute(), singleRow, IValueController.EditType.INLINE, editorPlaceholder) {
@Override
public boolean isReadOnly() {
// Filter value is never read-only
return false;
}
};
IValueEditor editor = null;
try {
editor = valueController.getValueManager().createEditor(valueController);
} catch (Exception e) {
log.error("Can't create inline value editor", e);
}
if (editor == null) {
editor = new StringInlineEditor(valueController);
}
handler.setEditor(editor);
editor.createControl();
try {
editor.primeEditorValue(valueController.getValue());
} catch (DBException e) {
log.error("Error populating filter value", e);
}
}
Aggregations