Search in sources :

Example 1 with CloseSQLResultTabAction

use of org.talend.sqlbuilder.actions.CloseSQLResultTabAction in project tdi-studio-se by Talend.

the class SQLResultComposite method createHeaderComposite.

/**
     * 
     * DOC dev Comment method "createHeaderComposite".
     * 
     * @param parent a TabItem 's Control
     * @param tabItem a TabItem
     */
private void createHeaderComposite(Composite parent, CTabItem tabItem) {
    // add sql statement, first create temp label to calculate correct size
    // int labelStyle = SWT.WRAP | SWT.MULTI | SWT.V_SCROLL;
    //
    // Text tmpLabel = new Text(parent, labelStyle);
    // tmpLabel.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
    // tmpLabel.setLayoutData(new FillLayout());
    // int parentWidth = this.getClientArea().width;
    // Point idealSize = tmpLabel.computeSize(parentWidth - 30, SWT.DEFAULT);
    //
    // if (idealSize.y > 60) {
    // // we need a scroll bar
    // labelStyle = SWT.WRAP | SWT.MULTI | SWT.V_SCROLL;
    // }
    //
    // tmpLabel.dispose();
    // now create real label
    // create spanned cell for table data
    Composite headerComposite = new Composite(parent, SWT.FILL);
    headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    GridLayout hLayout = new GridLayout();
    hLayout.numColumns = 2;
    hLayout.marginLeft = 0;
    hLayout.horizontalSpacing = 0;
    hLayout.verticalSpacing = 0;
    hLayout.marginWidth = 0;
    hLayout.marginHeight = 0;
    headerComposite.setLayout(hLayout);
    Text label = new Text(headerComposite, SWT.H_SCROLL);
    // label.setEnabled(false);
    label.setEditable(false);
    label.setBackground(this.getBackground());
    label.setText(TextUtil.removeLineBreaks(sqlExecution.getSqlStatement()));
    label.setToolTipText(TextUtil.getWrappedText(sqlExecution.getSqlStatement()));
    GridData labelGridData = new GridData(SWT.FILL, SWT.TOP, true, true);
    // labelGridData.heightHint = labelHeight;
    label.setLayoutData(labelGridData);
    label.setVisible(true);
    // add action bar
    ToolBarManager toolBarMgr = new ToolBarManager(SWT.FLAT);
    toolBarMgr.createControl(headerComposite);
    toolBarMgr.add(new CloseSQLResultTabAction(tabItem));
    toolBarMgr.update(true);
    GridData gid = new GridData();
    gid.horizontalAlignment = SWT.RIGHT;
    gid.verticalAlignment = SWT.TOP;
    toolBarMgr.getControl().setLayoutData(gid);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) CloseSQLResultTabAction(org.talend.sqlbuilder.actions.CloseSQLResultTabAction) ToolBarManager(org.eclipse.jface.action.ToolBarManager)

Aggregations

ToolBarManager (org.eclipse.jface.action.ToolBarManager)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Text (org.eclipse.swt.widgets.Text)1 CloseSQLResultTabAction (org.talend.sqlbuilder.actions.CloseSQLResultTabAction)1