Search in sources :

Example 11 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project tdi-studio-se by Talend.

the class MultiPageSqlBuilderEditor method createContainer.

private CTabFolder createContainer(Composite parent) {
    // use SWT.FLAT style so that an extra 1 pixel border is not reserved
    // inside the folder
    parent.setLayout(new FillLayout());
    final CTabFolder newContainer = new CTabFolder(parent, SWT.BOTTOM | SWT.FLAT);
    newContainer.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            int newPageIndex = newContainer.indexOf((CTabItem) e.item);
            pageChange(newPageIndex);
        }
    });
    newContainer.addTraverseListener(new TraverseListener() {

        // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=199499 : Switching tabs by Ctrl+PageUp/PageDown must not be caught on the inner tab set
        @Override
        public void keyTraversed(TraverseEvent e) {
            switch(e.detail) {
                case SWT.TRAVERSE_PAGE_NEXT:
                case SWT.TRAVERSE_PAGE_PREVIOUS:
                    int detail = e.detail;
                    e.doit = true;
                    e.detail = SWT.TRAVERSE_NONE;
                    Control control = newContainer.getParent();
                    do {
                        if (control.traverse(detail))
                            return;
                        if (control.getListeners(SWT.Traverse).length != 0)
                            return;
                        if (control instanceof Shell)
                            return;
                        control = control.getParent();
                    } while (control != null);
            }
        }
    });
    return newContainer;
}
Also used : Control(org.eclipse.swt.widgets.Control) Shell(org.eclipse.swt.widgets.Shell) CTabFolder(org.eclipse.swt.custom.CTabFolder) TraverseEvent(org.eclipse.swt.events.TraverseEvent) TraverseListener(org.eclipse.swt.events.TraverseListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 12 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project tdi-studio-se by Talend.

the class SQLBuilderTabComposite method createTabItem.

/**
     * Creates tab item. Changed by Marvin Wang on Feb. 24, 2012 for bug TDI-7643, for all SQLBuilderEditorComposite
     * when using <code>editorComposite.getConnParam().getQueryObject()</code> to get the query object, the query every
     * time get is the same object. Caz all <code>SQLBuilderEditorComposite</code>s use the same connection parameter.
     * 
     * @param node
     * @param connParam
     * @param isDefaultEditor
     */
private void createTabItem(RepositoryNode node, ConnectionParameters connParam, boolean isDefaultEditor) {
    //$NON-NLS-1$
    String queryStr = "";
    if (node != null) {
        CTabItem[] tabItems = tabFolder.getItems();
        for (int i = 0; i < tabItems.length; i++) {
            SQLBuilderEditorComposite editorComposite = (SQLBuilderEditorComposite) (((CTabFolder) tabItems[i].getControl()).getItems()[0]).getControl();
            // To get the different query object for each SQLBuilderEditorComposite, use the following method. The
            // queryObject is stored in <code>SQLBuilderEditorComposite.doSaveSQL()</code>
            Query query2 = editorComposite.getQueryObject();
            if ((RepositoryNodeType) node.getProperties(EProperties.CONTENT_TYPE) == RepositoryNodeType.QUERY) {
                Query query = ((QueryRepositoryObject) node.getObject()).getQuery();
                if (query2 == null && tabItems[i].getData() instanceof Query) {
                    query2 = (Query) tabItems[i].getData();
                }
                if (query2 != null && query.getLabel().equals(query2.getLabel())) {
                    if ("".equals(editorComposite.getEditorContent())) {
                        //$NON-NLS-1$
                        editorComposite.setEditorContent(query.getValue());
                    }
                    tabFolder.setSelection(i);
                    return;
                }
                connParam.setQueryObject(query);
                queryStr = query.getValue();
            }
        }
    }
    CTabItem tabItem = null;
    if (connParam.isFromDBNode()) {
        tabItem = new CTabItem(tabFolder, SWT.NULL);
    } else {
        tabItem = new CTabItem(tabFolder, SWT.CLOSE);
    }
    node = SQLBuilderRepositoryNodeManager.getRoot(node);
    if (!"".equals(queryStr)) {
        //$NON-NLS-1$
        try {
            nodesSel = EMFRepositoryNodeManager.getInstance().parseSqlStatement(queryStr, node);
        } catch (Exception e) {
            MessageDialog.openError(new Shell(), Messages.getString("SQLBuilderTabComposite.Notice.title"), //$NON-NLS-1$
            Messages.getString(//$NON-NLS-1$
            "SQLBuilderTabComposite.Notice.Info"));
        }
    }
    MultiPageSqlBuilderEditor builderEditor = new MultiPageSqlBuilderEditor(nodesSel, tabItem, isDefaultEditor, connParam, node, dialog);
    builderEditor.setReadOnly(readOnly);
    try {
        builderEditor.init(new SQLBuilderEditorSite(), new SQLBuilderEditorInput());
    } catch (PartInitException e) {
        ExceptionHandler.process(e);
    }
    builderEditor.createPartControl2(tabFolder);
    tabItem.setControl(builderEditor.getContainer());
    tabItem.setData(TextUtil.KEY, builderEditor);
    if (connParam.isFromRepository() && connParam.getQueryObject() != null) {
        queryStr = connParam.getQueryObject().getValue();
    }
    builderEditor.setSqlText(queryStr);
    if (connParam.isShowDesignerPage()) {
        builderEditor.showDesignerPage();
    }
    // set new tab as the active one.
    tabFolder.setSelection(tabFolder.getItemCount() - 1);
    // refresh view
    tabFolder.layout();
    tabFolder.redraw();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Query(org.talend.core.model.metadata.builder.connection.Query) SQLBuilderEditorInput(org.talend.sqlbuilder.editors.SQLBuilderEditorInput) CTabItem(org.eclipse.swt.custom.CTabItem) PartInitException(org.eclipse.ui.PartInitException) QueryRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.QueryRepositoryObject) Shell(org.eclipse.swt.widgets.Shell) MultiPageSqlBuilderEditor(org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor) PartInitException(org.eclipse.ui.PartInitException) SQLBuilderEditorSite(org.talend.sqlbuilder.editors.SQLBuilderEditorSite)

Example 13 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project tdi-studio-se by Talend.

the class SQLBuilderTabComposite method createTabFolder.

/**
     * 
     * Creates tab folder.
     * 
     */
private void createTabFolder() {
    if (tabFolder == null || tabFolder.isDisposed()) {
        clearParent();
        // create tab folder for different sessions
        tabFolder = new CTabFolder(this, SWT.NULL | SWT.BORDER);
        tabFolder.setSimple(false);
        //$NON-NLS-1$
        tabFolder.setToolTipText(Messages.getString("SQLBuilderTabComposite.toolTipText"));
        this.layout();
        this.redraw();
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder)

Example 14 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project tdi-studio-se by Talend.

the class SQLResultComposite method createTabFolder.

/**
     * 
     * DOC dev Comment method "createTabFolder".
     * 
     */
private void createTabFolder() {
    if (tabFolder == null || tabFolder.isDisposed()) {
        clearParent();
        // create tab folder for different sessions
        tabFolder = new CTabFolder(this, SWT.NULL);
        tabFolder.setSimple(false);
        //$NON-NLS-1$
        tabFolder.setToolTipText(Messages.getString("SQLResultComposite.SQLResults.ToolTip"));
        GridData gd = new GridData(GridData.FILL_BOTH);
        tabFolder.setLayoutData(gd);
        this.layout();
        this.redraw();
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData)

Example 15 with CTabFolder

use of org.eclipse.swt.custom.CTabFolder in project cubrid-manager by CUBRID.

the class ViewDashboardEditorPart method createTabFolder.

public void createTabFolder(Composite parent) {
    tabFolder = new CTabFolder(parent, SWT.TOP);
    tabFolder.setLayout(new FillLayout());
    tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    tabFolder.setSimple(false);
    tabFolder.setUnselectedImageVisible(true);
    tabFolder.setUnselectedCloseVisible(true);
    tabFolder.setBorderVisible(true);
    tabFolder.setSelectionBackground(ResourceManager.getColor(136, 161, 227));
    tabFolder.setSelectionForeground(ResourceManager.getColor(SWT.COLOR_BLACK));
    Menu menu = new Menu(tabFolder.getShell(), SWT.POP_UP);
    tabFolder.setMenu(menu);
    MenuItem closeItem = new MenuItem(menu, SWT.PUSH);
    closeItem.setText(Messages.tablesDetailInfoPartCloseMenu);
    closeItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem item = tabFolder.getSelection();
            item.dispose();
        }
    });
    MenuItem closeOthersItem = new MenuItem(menu, SWT.PUSH);
    closeOthersItem.setText(Messages.tablesDetailInfoPartCloseOthersMenu);
    closeOthersItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] items = tabFolder.getItems();
            CTabItem selectedItem = tabFolder.getSelection();
            for (CTabItem item : items) {
                if (!item.equals(selectedItem)) {
                    item.dispose();
                }
            }
        }
    });
    MenuItem closeAllItem = new MenuItem(menu, SWT.PUSH);
    closeAllItem.setText(Messages.tablesDetailInfoPartCloseAllMenu);
    closeAllItem.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            widgetDefaultSelected(e);
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            CTabItem[] items = tabFolder.getItems();
            for (CTabItem item : items) {
                item.dispose();
            }
        }
    });
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) MenuItem(org.eclipse.swt.widgets.MenuItem) FillLayout(org.eclipse.swt.layout.FillLayout) Menu(org.eclipse.swt.widgets.Menu) ViewsDetailInfoCTabItem(com.cubrid.common.ui.cubrid.view.editor.ViewDashboardComposite.ViewsDetailInfoCTabItem) CTabItem(org.eclipse.swt.custom.CTabItem) SelectionListener(org.eclipse.swt.events.SelectionListener)

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