Search in sources :

Example 36 with CTabItem

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();
}
Also used : AbstractJob(org.jkiss.dbeaver.model.runtime.AbstractJob) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) CTabItem(org.eclipse.swt.custom.CTabItem) InvocationTargetException(java.lang.reflect.InvocationTargetException) DBException(org.jkiss.dbeaver.DBException)

Example 37 with CTabItem

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);
}
Also used : CTabItem(org.eclipse.swt.custom.CTabItem)

Example 38 with CTabItem

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;
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) StyledText(org.eclipse.swt.custom.StyledText) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) ReferenceValueEditor(org.jkiss.dbeaver.ui.data.editors.ReferenceValueEditor) CTabItem(org.eclipse.swt.custom.CTabItem) Point(org.eclipse.swt.graphics.Point) HexEditControl(org.jkiss.dbeaver.ui.editors.binary.HexEditControl) DBSTypedObject(org.jkiss.dbeaver.model.struct.DBSTypedObject) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 39 with CTabItem

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ComboVar(org.pentaho.di.ui.core.widget.ComboVar) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 40 with CTabItem

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);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

CTabItem (org.eclipse.swt.custom.CTabItem)377 Composite (org.eclipse.swt.widgets.Composite)246 FormLayout (org.eclipse.swt.layout.FormLayout)189 FormAttachment (org.eclipse.swt.layout.FormAttachment)185 FormData (org.eclipse.swt.layout.FormData)185 SelectionEvent (org.eclipse.swt.events.SelectionEvent)173 Label (org.eclipse.swt.widgets.Label)168 CTabFolder (org.eclipse.swt.custom.CTabFolder)165 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)149 Button (org.eclipse.swt.widgets.Button)142 Text (org.eclipse.swt.widgets.Text)117 Event (org.eclipse.swt.widgets.Event)107 Listener (org.eclipse.swt.widgets.Listener)107 TextVar (org.pentaho.di.ui.core.widget.TextVar)107 ModifyListener (org.eclipse.swt.events.ModifyListener)106 ModifyEvent (org.eclipse.swt.events.ModifyEvent)104 Shell (org.eclipse.swt.widgets.Shell)101 ColumnInfo (org.pentaho.di.ui.core.widget.ColumnInfo)100 TableView (org.pentaho.di.ui.core.widget.TableView)99 ShellEvent (org.eclipse.swt.events.ShellEvent)95