use of org.eclipse.swt.custom.CTabItem in project dbeaver by serge-rider.
the class SQLEditor method dumpServerOutput.
private void dumpServerOutput(@NotNull final DBCExecutionContext executionContext, @NotNull final DBCServerOutputReader outputReader) {
new AbstractJob("Dump server output") {
@Override
protected IStatus run(DBRProgressMonitor monitor) {
final StringWriter dump = new StringWriter();
try {
outputReader.readServerOutput(monitor, executionContext, new PrintWriter(dump, true));
final String dumpString = dump.toString();
if (!dumpString.isEmpty()) {
DBeaverUI.asyncExec(new Runnable() {
@Override
public void run() {
if (outputViewer.isDisposed()) {
return;
}
try {
IOUtils.copyText(new StringReader(dumpString), outputViewer.getOutputWriter());
} catch (IOException e) {
log.error(e);
}
if (outputViewer.isHasNewOutput()) {
outputViewer.scrollToEnd();
CTabItem outputItem = UIUtils.getTabItem(resultTabs, outputViewer);
if (outputItem != null && outputItem != resultTabs.getSelection()) {
outputItem.setImage(IMG_OUTPUT_ALERT);
} else {
toolOutputItem.setImage(IMG_OUTPUT_ALERT);
}
}
}
});
}
} catch (Exception e) {
log.error(e);
}
return Status.OK_STATUS;
}
}.schedule();
}
use of org.eclipse.swt.custom.CTabItem in project dbeaver by serge-rider.
the class SQLEditor method showExtraView.
private void showExtraView(final ToolItem toolItem, String name, String toolTip, Image image, Control view) {
for (CTabItem item : resultTabs.getItems()) {
if (item.getData() == view) {
if (resultTabs.getSelection() == item) {
item.dispose();
toolItem.setSelection(false);
return;
} else {
resultTabs.setSelection(item);
return;
}
}
}
// Create new tab
toolItem.setSelection(true);
CTabItem item = new CTabItem(resultTabs, SWT.CLOSE);
item.setControl(view);
item.setText(name);
item.setToolTipText(toolTip);
item.setImage(image);
item.setData(view);
// De-select tool item on tab close
item.addDisposeListener(new DisposeListener() {
@Override
public void widgetDisposed(DisposeEvent e) {
toolItem.setSelection(false);
}
});
resultTabs.setSelection(item);
}
use of org.eclipse.swt.custom.CTabItem in project dbeaver by serge-rider.
the class TextViewDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogGroup = (Composite) super.createDialogArea(parent);
ReferenceValueEditor referenceValueEditor = new ReferenceValueEditor(getValueController(), this);
boolean isForeignKey = referenceValueEditor.isReferenceValue();
Label label = new Label(dialogGroup, SWT.NONE);
label.setText(CoreMessages.dialog_data_label_value);
boolean readOnly = getValueController().isReadOnly();
boolean useHex = !isForeignKey;
final DBSTypedObject valueType = getValueController().getValueType();
long maxSize = valueType.getMaxLength();
if (useHex) {
editorContainer = new CTabFolder(dialogGroup, SWT.FLAT | SWT.TOP);
editorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
lengthLabel = new Label(editorContainer, SWT.RIGHT);
lengthLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
editorContainer.setTopRight(lengthLabel, SWT.FILL);
}
int selectedType = 0;
if (getDialogSettings().get(VALUE_TYPE_SELECTOR) != null) {
selectedType = getDialogSettings().getInt(VALUE_TYPE_SELECTOR);
}
{
int style = SWT.NONE;
if (readOnly) {
style |= SWT.READ_ONLY;
}
if (useHex) {
style |= SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.WRAP;
} else {
// Use border only for plain text editor, otherwise tab folder's border will be used
style |= SWT.BORDER;
}
textEdit = new StyledText(useHex ? editorContainer : dialogGroup, style);
textEdit.setMargins(3, 3, 3, 3);
if (maxSize > 0 && valueType.getDataKind() == DBPDataKind.STRING) {
textEdit.setTextLimit((int) maxSize);
}
if (readOnly) {
//textEdit.setBackground(getShell().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
}
GridData gd = new GridData(isForeignKey ? GridData.FILL_HORIZONTAL : GridData.FILL_BOTH);
gd.widthHint = 300;
if (!isForeignKey) {
gd.heightHint = 200;
gd.grabExcessVerticalSpace = true;
}
textEdit.setLayoutData(gd);
textEdit.setFocus();
textEdit.setEditable(!readOnly);
textEdit.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
dirty = true;
updateValueLength();
}
});
UIUtils.fillDefaultStyledTextContextMenu(textEdit);
if (useHex) {
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Text");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_TEXT));
item.setControl(textEdit);
}
}
Point minSize = null;
if (useHex) {
hexEditControl = new HexEditControl(editorContainer, readOnly ? SWT.READ_ONLY : SWT.NONE, 6, 8);
GridData gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = 200;
gd.minimumWidth = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
hexEditControl.setLayoutData(gd);
minSize = hexEditControl.computeSize(SWT.DEFAULT, SWT.DEFAULT);
minSize.x += 50;
minSize.y += 50;
CTabItem item = new CTabItem(editorContainer, SWT.NO_FOCUS);
item.setText("Hex");
item.setImage(DBeaverIcons.getImage(DBIcon.TYPE_BINARY));
item.setControl(hexEditControl);
if (selectedType >= editorContainer.getItemCount()) {
selectedType = 0;
}
editorContainer.setSelection(selectedType);
editorContainer.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
getDialogSettings().put(VALUE_TYPE_SELECTOR, editorContainer.getSelectionIndex());
}
});
hexEditControl.addListener(SWT.Modify, new Listener() {
@Override
public void handleEvent(Event event) {
dirty = true;
}
});
updateValueLength();
}
primeEditorValue(getValueController().getValue());
if (isForeignKey) {
referenceValueEditor.createEditorSelector(dialogGroup);
}
if (minSize != null) {
// Set default size as minimum
getShell().setMinimumSize(minSize);
}
return dialogGroup;
}
use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.
the class BaseStreamingDialog method buildResultsTab.
private void buildResultsTab() {
wResultsTab = new CTabItem(wTabFolder, SWT.NONE);
wResultsTab.setText(BaseMessages.getString(PKG, "BaseStreamingDialog.ResultsTab"));
wResultsComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wResultsComp);
FormLayout resultsLayout = new FormLayout();
resultsLayout.marginHeight = 15;
resultsLayout.marginWidth = 15;
wResultsComp.setLayout(resultsLayout);
FormData fdResultsComp = new FormData();
fdResultsComp.left = new FormAttachment(0, 0);
fdResultsComp.top = new FormAttachment(0, 0);
fdResultsComp.right = new FormAttachment(100, 0);
fdResultsComp.bottom = new FormAttachment(100, 0);
wResultsComp.setLayoutData(fdResultsComp);
wlSubStep = new Label(wResultsComp, SWT.LEFT);
props.setLook(wlSubStep);
FormData fdlSubTrans = new FormData();
fdlSubTrans.left = new FormAttachment(0, 0);
fdlSubTrans.top = new FormAttachment(0, 0);
wlSubStep.setLayoutData(fdlSubTrans);
wlSubStep.setText(BaseMessages.getString(PKG, "BaseStreaming.Dialog.Transformation.SubTransStep"));
wSubStep = new ComboVar(transMeta, wResultsComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
props.setLook(wSubStep);
FormData fdSubStep = new FormData();
fdSubStep.left = new FormAttachment(0, 0);
fdSubStep.top = new FormAttachment(wlSubStep, 5);
fdSubStep.width = 250;
wSubStep.setLayoutData(fdSubStep);
wResultsComp.layout();
wResultsTab.setControl(wResultsComp);
}
use of org.eclipse.swt.custom.CTabItem in project pentaho-kettle by pentaho.
the class BaseStreamingDialog method buildSetupTab.
private void buildSetupTab() {
wSetupTab = new CTabItem(wTabFolder, SWT.NONE);
wSetupTab.setText(BaseMessages.getString(PKG, "BaseStreamingDialog.SetupTab"));
wSetupComp = new Composite(wTabFolder, SWT.NONE);
props.setLook(wSetupComp);
FormLayout setupLayout = new FormLayout();
setupLayout.marginHeight = 15;
setupLayout.marginWidth = 15;
wSetupComp.setLayout(setupLayout);
buildSetup(wSetupComp);
FormData fdSetupComp = new FormData();
fdSetupComp.left = new FormAttachment(0, 0);
fdSetupComp.top = new FormAttachment(0, 0);
fdSetupComp.right = new FormAttachment(100, 0);
fdSetupComp.bottom = new FormAttachment(100, 0);
wSetupComp.setLayoutData(fdSetupComp);
wSetupComp.layout();
wSetupTab.setControl(wSetupComp);
}
Aggregations