Search in sources :

Example 46 with CTabFolder

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

the class AddTablesComposite method createTabFolder.

private void createTabFolder() {
    if (tabFolder == null || tabFolder.isDisposed()) {
        clearParent();
        // create tab folder for different sessions
        tabFolder = new CTabFolder(this, SWT.NULL | SWT.BORDER);
        tabFolder.setLayout(new GridLayout());
        tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
        tabFolder.setSimple(false);
        this.layout();
        this.redraw();
    }
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) GridData(org.eclipse.swt.layout.GridData)

Example 47 with CTabFolder

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

the class DetailTabManager method createTabs.

/**
     * Creates all the tabs in the detail pane to display the information for a
     * given node.
     * 
     * @param composite
     * @param node
     */
public static void createTabs(Composite composite, INode node) {
    List tabs = getTabs(node);
    if (tabs == null || tabs.size() == 0) {
        // no detail found..
        Label label = new Label(composite, SWT.FILL | SWT.WRAP);
        //$NON-NLS-1$ //$NON-NLS-2$
        label.setText(Messages.getString("DatabaseDetailView.Tab.Unavailable") + " " + node.getLabelText());
        return;
    }
    // create tabs
    CTabFolder tabFolder = new CTabFolder(composite, SWT.NULL);
    tabFolder.setSimple(false);
    // only init tabs when the tab becomes active
    tabFolder.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            CTabItem tabItem = (CTabItem) e.item;
            IDetailTab tab = (IDetailTab) tabItem.getData();
            if (tab != null) {
                // create composite on tab and fill it..
                Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
                tabItem.setControl(detailComposite);
                detailComposite.setLayout(new FillLayout());
                tab.fillComposite(detailComposite);
                detailComposite.layout();
                // store tab name, so we can reselect when other node is
                // chosen
                DetailTabManager.setActiveTabName(tabItem.getText());
            }
        }
    });
    // add tabs to folder
    Iterator it = tabs.iterator();
    int tabIndex = 0;
    while (it.hasNext()) {
        IDetailTab detailTab = (IDetailTab) it.next();
        // create tab
        CTabItem tabItem = new CTabItem(tabFolder, SWT.NULL);
        tabItem.setText(detailTab.getLabelText());
        tabItem.setToolTipText(detailTab.getLabelToolTipText());
        // store tab so we can fill later
        tabItem.setData(detailTab);
        // reselect same tab as was previous selected
        if (tabItem.getText() != null && pActiveTabName != null) {
            if (tabItem.getText().equals(pActiveTabName)) {
                tabFolder.setSelection(tabIndex);
            }
        }
        tabIndex++;
    }
    // load data for active tab, default to first one if none is selected
    tabIndex = tabFolder.getSelectionIndex();
    if (tabIndex == -1) {
        tabIndex = 0;
    }
    CTabItem tabItem = tabFolder.getItem(tabIndex);
    if (tabItem != null) {
        Composite detailComposite = new Composite(tabItem.getParent(), SWT.FILL);
        tabItem.setControl(detailComposite);
        detailComposite.setLayout(new FillLayout());
        IDetailTab tab = (IDetailTab) tabItem.getData();
        tab.fillComposite(detailComposite);
        detailComposite.layout();
    }
    if (tabFolder.getChildren().length > 0 && tabFolder.getSelection() == null) {
        tabFolder.setSelection(0);
    }
    tabFolder.layout();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) FillLayout(org.eclipse.swt.layout.FillLayout) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 48 with CTabFolder

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

the class JSONFileStep2Form method addGroupFileViewer.

/**
     * add Field to Group File Viewer.
     * 
     * @param parent
     * @param form
     * @param width
     * @param height
     */
private void addGroupFileViewer(final Composite parent, final int width, int height) {
    // composite JSON File Preview
    // Group previewGroup = Form.createGroup(parent, 1, Messages.getString("FileStep2.groupPreview"), height);
    // //$NON-NLS-1$
    // Composite compositeJSONFilePreviewButton = Form.startNewDimensionnedGridLayout(previewGroup, 4, width,
    // HEIGHT_BUTTON_PIXEL);
    // height = height - HEIGHT_BUTTON_PIXEL - 15;
    tabFolder = new CTabFolder(parent, SWT.BORDER);
    tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
    previewTabItem = new CTabItem(tabFolder, SWT.BORDER);
    //$NON-NLS-1$
    previewTabItem.setText("Preview");
    outputTabItem = new CTabItem(tabFolder, SWT.BORDER);
    outputTabItem.setText("Output");
    fileTabItem = new CTabItem(tabFolder, SWT.BORDER);
    fileTabItem.setText("File Viewer");
    Composite previewComposite = Form.startNewGridLayout(tabFolder, 1);
    outputComposite = Form.startNewGridLayout(tabFolder, 1);
    Composite compositeFileViewer = Form.startNewGridLayout(tabFolder, 1);
    // previewGroup.setLayout(new GridLayout());
    Composite preivewButtonPart = new Composite(previewComposite, SWT.NONE);
    preivewButtonPart.setLayout(new GridLayout(3, false));
    preivewButtonPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // Preview Button
    previewButton = new Button(preivewButtonPart, SWT.NONE);
    //$NON-NLS-1$
    previewButton.setText("Refresh Preview");
    previewButton.setSize(WIDTH_BUTTON_PIXEL, HEIGHT_BUTTON_PIXEL);
    XmlArray.setLimitToDefault();
    previewInformationLabel = new Label(previewComposite, SWT.NONE);
    previewInformationLabel.setForeground(getDisplay().getSystemColor(SWT.COLOR_BLUE));
    // JSON File Preview
    jsonFilePreview = new JSONShadowProcessPreview(previewComposite, null, width, height - 10);
    jsonFilePreview.newTablePreview();
    // File View
    fileJSONText = new Text(compositeFileViewer, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.minimumWidth = width;
    gridData.minimumHeight = HEIGHT_BUTTON_PIXEL;
    fileJSONText.setLayoutData(gridData);
    fileJSONText.setToolTipText("When Filepath is specified, you can read here the" + " " + TreePopulator.getMaximumRowsToPreview() + " " + "first rows of the file.");
    fileJSONText.setEditable(false);
    fileJSONText.setText("Filepath must be specified to show the Data file");
    previewTabItem.setControl(previewComposite);
    outputTabItem.setControl(outputComposite);
    fileTabItem.setControl(compositeFileViewer);
    tabFolder.setSelection(previewTabItem);
    tabFolder.pack();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) CTabFolder(org.eclipse.swt.custom.CTabFolder) Composite(org.eclipse.swt.widgets.Composite) CommandStackForComposite(org.talend.commons.ui.command.CommandStackForComposite) Button(org.eclipse.swt.widgets.Button) UtilsButton(org.talend.commons.ui.swt.formtools.UtilsButton) JSONShadowProcessPreview(org.talend.repository.json.ui.preview.JSONShadowProcessPreview) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) StyledText(org.eclipse.swt.custom.StyledText) Text(org.eclipse.swt.widgets.Text) CTabItem(org.eclipse.swt.custom.CTabItem)

Example 49 with CTabFolder

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

the class MetadataColumnComparator method synchronizeAllSqlEditors.

public void synchronizeAllSqlEditors(SQLBuilderDialog builderDialog) {
    if (builderDialog.getStructureComposite() == null) {
        return;
    }
    List<Query> displayQueries = builderDialog.getStructureComposite().getTreeLabelProvider().getDisplayQueries();
    for (Query activeQuery : displayQueries) {
        CTabFolder tabFolder = builderDialog.getEditorComposite().getTabFolder();
        if (tabFolder != null) {
            CTabItem[] items = tabFolder.getItems();
            for (CTabItem item : items) {
                final boolean b = (item.getData() instanceof Query) && item.getData(TextUtil.KEY) instanceof MultiPageSqlBuilderEditor && activeQuery != null;
                Query data2 = (Query) item.getData();
                if (b && data2.getLabel().equals(activeQuery.getLabel())) {
                    data2.setValue(activeQuery.getValue());
                    data2.setComment(activeQuery.getComment());
                    data2.setLabel(activeQuery.getLabel());
                    //$NON-NLS-1$
                    updateEditor(activeQuery, (MultiPageSqlBuilderEditor) item.getData("KEY"));
                }
            }
        }
    }
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Query(org.talend.core.model.metadata.builder.connection.Query) MultiPageSqlBuilderEditor(org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor) CTabItem(org.eclipse.swt.custom.CTabItem)

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