Search in sources :

Example 1 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.

the class APTStubAnalysisCTabItem method createAPTStubAnalysisCTablItemUI.

/**
	 * 初始化页面中的所有UI
	 * @param parent
	 */
private void createAPTStubAnalysisCTablItemUI(Composite parent) {
    int margin = 5;
    /**
		 * 三种展示视图的CTabFolder
		 */
    FormData showViewTabFolderFD = new FormData();
    showViewTabFolderFD.left = new FormAttachment(0, margin);
    showViewTabFolderFD.top = new FormAttachment(0, 25);
    showViewTabFolderFD.right = new FormAttachment(100, -margin);
    showViewTabFolderFD.bottom = new FormAttachment(100, -margin);
    showViewTF = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
    showViewTF.setTabHeight(20);
    showViewTF.setLayoutData(showViewTabFolderFD);
    showViewTF.marginHeight = 10;
    showViewTF.marginWidth = 10;
    showViewTF.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    showViewTF.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    showViewTF.setUnselectedCloseVisible(true);
    showViewTF.pack();
    /**
		 * 详细视图按钮初始化
		 */
    FormData detailBtnFD = new FormData();
    detailBtnFD.left = new FormAttachment(0, margin);
    detailBtnFD.top = new FormAttachment(0, margin);
    detailBtnFD.height = 16;
    detailBtnFD.width = 16;
    detailBtn = new Button(parent, SWT.NONE);
    detailBtn.setToolTipText(StubAnalysisUtil.DETAIL_TAB_NAME);
    detailBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/detail.png").createImage());
    detailBtn.setLayoutData(detailBtnFD);
    detailBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                detailTabItem = createDetailCTabItem(showViewTF);
                detailTabItem.updateData(detailData);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.DETAIL_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                detailTabItem = createDetailCTabItem(showViewTF);
                detailTabItem.updateData(detailData);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }
    });
    /**
		 * 统计视图按钮初始化
		 */
    FormData topBtnFD = new FormData();
    topBtnFD.left = new FormAttachment(detailBtn, margin);
    topBtnFD.top = new FormAttachment(0, margin);
    topBtnFD.height = 16;
    topBtnFD.width = 16;
    topBtn = new Button(parent, SWT.NONE);
    topBtn.setToolTipText(StubAnalysisUtil.TOP_TAB_NAME);
    topBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/stat.png").createImage());
    topBtn.setLayoutData(topBtnFD);
    topBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                topTabItem = createTopCTabItem(showViewTF);
                topTabItem.updateData(topData);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TOP_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                topTabItem = createTopCTabItem(showViewTF);
                topTabItem.updateData(topData);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }
    });
    /**
		 * 树形视图按钮初始化
		 */
    FormData treeBtnFD = new FormData();
    treeBtnFD.left = new FormAttachment(topBtn, margin);
    treeBtnFD.top = new FormAttachment(0, margin);
    treeBtnFD.height = 16;
    treeBtnFD.width = 16;
    treeBtn = new Button(parent, SWT.NONE);
    treeBtn.setToolTipText(StubAnalysisUtil.TREE_TAB_NAME);
    treeBtn.setImage(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/tree.png").createImage());
    treeBtn.setLayoutData(treeBtnFD);
    treeBtn.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                treeTabItem = createTreeCTabItem(showViewTF);
                treeTabItem.updateData(treeData);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] openedTabItems = showViewTF.getItems();
            CTabItem targetTabItem = CTabFolderItemUtil.getTabItem(openedTabItems, StubAnalysisUtil.TREE_TAB_NAME);
            if (openedTabItems == null || openedTabItems.length == 0 || targetTabItem == null) {
                treeTabItem = createTreeCTabItem(showViewTF);
            } else {
                if (!showViewTF.getSelection().getText().equals(targetTabItem.getText()))
                    ;
                {
                    showViewTF.setSelection(targetTabItem);
                }
            }
        }
    });
    /**
		 * 打开三个视图
		 */
    detailTabItem = createDetailCTabItem(showViewTF);
    topTabItem = createTopCTabItem(showViewTF);
    treeTabItem = createTreeCTabItem(showViewTF);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 2 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.

the class StubAnalysisView method createRootTabFolder.

/**
	 * 初始化根CTablFolder
	 * @param parent
	 */
private void createRootTabFolder(Composite parent) {
    rootTabFolder = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
    rootTabFolder.setTabHeight(20);
    //TODO 是否需要进行修改
    rootTabFolder.setLayout(new FillLayout());
    rootTabFolder.marginHeight = 10;
    rootTabFolder.marginWidth = 10;
    rootTabFolder.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    rootTabFolder.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    rootTabFolder.setUnselectedCloseVisible(true);
    rootTabFolder.pack();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) FillLayout(org.eclipse.swt.layout.FillLayout)

Example 3 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project GT by Tencent.

the class PMAPView method createRootTabFolder.

/**
	 * 初始化tab页的根
	 * @param parent
	 */
private void createRootTabFolder(Composite parent) {
    rootTabFolder = new CTabFolder(parent, SWT.TOP | SWT.CLOSE | SWT.BORDER);
    rootTabFolder.setTabHeight(20);
    rootTabFolder.setLayout(new FillLayout());
    rootTabFolder.marginHeight = 10;
    rootTabFolder.marginWidth = 10;
    // 显示“最大化、最小化”按钮
    rootTabFolder.setMaximizeVisible(true);
    rootTabFolder.setMinimizeVisible(true);
    rootTabFolder.setSelectionBackground(parent.getDisplay().getSystemColor(SWT.COLOR_GRAY));
    rootTabFolder.setSelectionForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
    rootTabFolder.setUnselectedCloseVisible(true);
    rootTabFolder.pack();
    FormData rootTabFormData = new FormData();
    rootTabFormData.left = new FormAttachment(0, 5);
    rootTabFormData.right = new FormAttachment(100, -5);
    rootTabFormData.top = new FormAttachment(toolGroup, 5);
    rootTabFormData.bottom = new FormAttachment(100, -5);
    rootTabFolder.setLayoutData(rootTabFormData);
}
Also used : FormData(org.eclipse.swt.layout.FormData) CTabFolder(org.eclipse.swt.custom.CTabFolder) FillLayout(org.eclipse.swt.layout.FillLayout) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 4 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder 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 5 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project dbeaver by serge-rider.

the class MultiPageAbstractEditor method setContainerStyles.

protected void setContainerStyles() {
    Composite pageContainer = getContainer();
    if (pageContainer instanceof CTabFolder) {
        CTabFolder tabFolder = (CTabFolder) pageContainer;
        tabFolder.setSimple(false);
        tabFolder.setMRUVisible(true);
        tabFolder.setTabPosition(SWT.TOP);
        Control topRight = createTopRightControl(tabFolder);
        if (topRight != null) {
            Point trSize = topRight.computeSize(SWT.DEFAULT, SWT.DEFAULT);
            tabFolder.setTabHeight(trSize.y);
            tabFolder.setTopRight(topRight, SWT.RIGHT | SWT.WRAP);
        }
        //            tabFolder.setSimple(false);
        //tabFolder.setBorderVisible(true);
        Layout parentLayout = tabFolder.getParent().getLayout();
        if (parentLayout instanceof FillLayout) {
            ((FillLayout) parentLayout).marginHeight = 0;
        //                ((FillLayout)parentLayout).marginWidth = 5;
        }
    }
}
Also used : Control(org.eclipse.swt.widgets.Control) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) Layout(org.eclipse.swt.widgets.Layout) FillLayout(org.eclipse.swt.layout.FillLayout) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout)

Aggregations

CTabFolder (org.eclipse.swt.custom.CTabFolder)49 GridData (org.eclipse.swt.layout.GridData)28 CTabItem (org.eclipse.swt.custom.CTabItem)23 GridLayout (org.eclipse.swt.layout.GridLayout)21 Composite (org.eclipse.swt.widgets.Composite)20 SelectionEvent (org.eclipse.swt.events.SelectionEvent)17 FillLayout (org.eclipse.swt.layout.FillLayout)14 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Label (org.eclipse.swt.widgets.Label)8 SelectionListener (org.eclipse.swt.events.SelectionListener)6 SashForm (org.eclipse.swt.custom.SashForm)5 StyledText (org.eclipse.swt.custom.StyledText)5 Point (org.eclipse.swt.graphics.Point)5 Button (org.eclipse.swt.widgets.Button)5 FormAttachment (org.eclipse.swt.layout.FormAttachment)4 FormData (org.eclipse.swt.layout.FormData)4 Menu (org.eclipse.swt.widgets.Menu)4 MenuItem (org.eclipse.swt.widgets.MenuItem)4 ToolBar (org.eclipse.swt.widgets.ToolBar)4 ToolItem (org.eclipse.swt.widgets.ToolItem)4