Search in sources :

Example 56 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 57 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)

Example 58 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 59 with CTabFolder

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

the class SQLBuilderDialog method okPressed.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.Dialog#okPressed()
     */
@Override
public void okPressed() {
    // gain the contextmode from sqlbuilder,and set it in connParameters,add by hyWang
    MultiPageSqlBuilderEditor editor = null;
    CTabFolder folder = getEditorComposite().getTabFolder();
    CTabItem[] a = folder.getItems();
    for (CTabItem itm : a) {
        //$NON-NLS-1$
        Object obj = itm.getData("KEY");
        if (obj instanceof MultiPageSqlBuilderEditor) {
            editor = (MultiPageSqlBuilderEditor) obj;
        }
        if (editor != null) {
            if (itm.getData() instanceof Query) {
                Query q = (Query) itm.getData();
                connParameters.setIfContextButtonCheckedFromBuiltIn(q.isContextMode());
            }
        }
    }
    if (EParameterFieldType.DBTABLE.equals(connParameters.getFieldType())) {
        final IStructuredSelection selection = (IStructuredSelection) structureComposite.getTreeViewer().getSelection();
        final Object firstElement = selection.getFirstElement();
        if (firstElement instanceof RepositoryNode) {
            RepositoryNode node = (RepositoryNode) firstElement;
            boolean is = node.getProperties(EProperties.CONTENT_TYPE).equals(RepositoryNodeType.TABLE);
            if (is) {
                MetadataTableRepositoryObject object = (MetadataTableRepositoryObject) node.getObject();
                connParameters.setSelectDBTable(object.getSourceName());
            }
        }
    } else {
        //$NON-NLS-1$
        String sql = "";
        // sql = editorComposite.getDefaultTabSql();
        sql = editorComposite.getCurrentTabSql();
        // if (ConnectionParameters.isJavaProject()) {
        // sql = sql.replace("\"", "\\" + "\"");
        // } else {
        // sql = sql.replace("'", "\\'");
        // }
        // sql = QueryUtil.checkAndAddQuotes(sql);
        connParameters.setQuery(sql);
        if (connParameters.isFromRepository() && !connParameters.isNodeReadOnly()) {
            List<Query> qs = new ArrayList<Query>();
            boolean isInfo = false;
            final CTabFolder tabFolder = getEditorComposite().getTabFolder();
            final CTabItem[] items = tabFolder.getItems();
            for (CTabItem item : items) {
                final String text = item.getText();
                //$NON-NLS-1$
                boolean isInfo2 = text.length() > 1 && text.substring(0, 1).equals("*");
                if (isInfo2) {
                    isInfo = true;
                }
            }
            if (isInfo) {
                //$NON-NLS-1$
                String title = Messages.getString("SQLBuilderDialog.SaveAllQueries.Title");
                //$NON-NLS-1$
                String info = Messages.getString("SQLBuilderDialog.SaveAllQueries.Info");
                boolean openQuestion = MessageDialog.openQuestion(getShell(), title, info);
                if (openQuestion) {
                    for (CTabItem item : items) {
                        final String text = item.getText();
                        //$NON-NLS-1$
                        boolean isInfo2 = text.length() > 1 && text.substring(0, 1).equals("*");
                        if (isInfo2) {
                            MultiPageSqlBuilderEditor meditor = null;
                            //$NON-NLS-1$
                            Object control = item.getData("KEY");
                            if (control instanceof MultiPageSqlBuilderEditor) {
                                meditor = (MultiPageSqlBuilderEditor) control;
                            }
                            if (meditor != null) {
                                RepositoryNode node = null;
                                node = meditor.getActivePageRepositoryNode();
                                if (text.substring(1).startsWith(AbstractSQLEditorComposite.QUERY_PREFIX)) {
                                    if (item.getData() instanceof Query) {
                                        Query q = (Query) item.getData();
                                        q.setValue(meditor.getActivePageSqlString());
                                        // add by hyWang
                                        q.setContextMode(meditor.getActiveEditors().getContextmode().getContextmodeaction().isChecked());
                                        qs.add(q);
                                        if (node != null && q != null) {
                                            manager.saveQuery(node, q, null);
                                        }
                                    }
                                } else {
                                    meditor.getActivePageSaveAsSQLAction().run();
                                }
                            }
                        }
                    }
                }
            }
            if (connParameters.getQueryObject() != null) {
                RepositoryUpdateManager.updateQuery(connParameters.getQueryObject(), node);
            }
        }
    }
    deleteNoUseTable();
    super.okPressed();
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) Query(org.talend.core.model.metadata.builder.connection.Query) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) RepositoryNode(org.talend.repository.model.RepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) CTabItem(org.eclipse.swt.custom.CTabItem) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) MultiPageSqlBuilderEditor(org.talend.sqlbuilder.editors.MultiPageSqlBuilderEditor) MetadataTableRepositoryObject(org.talend.sqlbuilder.dbstructure.DBTreeProvider.MetadataTableRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 60 with CTabFolder

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

the class CpuSection method createControls.

/*
     * @see AbstractPropertySection#createControls(Composite, TabbedPropertySheetPage)
     */
@Override
public void createControls(Composite parent) {
    contributeToActionBars();
    // hide the highlight margin with SWT.FLAT
    final CTabFolder tabFolder = getWidgetFactory().createTabFolder(parent, SWT.BOTTOM | SWT.FLAT);
    tabFolder.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            tabSelectionChanged(tabFolder.getSelection());
        }
    });
    callTree = new CallTreeTabPage(this, tabFolder);
    hotSpots = new HotSpotsTabPage(this, tabFolder);
    callerCallee = new CallerCalleeTabPage(this, tabFolder);
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IHelpContextIds.CPU_PAGE);
}
Also used : CTabFolder(org.eclipse.swt.custom.CTabFolder) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

CTabFolder (org.eclipse.swt.custom.CTabFolder)66 CTabItem (org.eclipse.swt.custom.CTabItem)36 GridData (org.eclipse.swt.layout.GridData)35 GridLayout (org.eclipse.swt.layout.GridLayout)27 Composite (org.eclipse.swt.widgets.Composite)26 SelectionEvent (org.eclipse.swt.events.SelectionEvent)18 FillLayout (org.eclipse.swt.layout.FillLayout)18 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)13 Label (org.eclipse.swt.widgets.Label)13 Point (org.eclipse.swt.graphics.Point)9 Shell (org.eclipse.swt.widgets.Shell)8 StyledText (org.eclipse.swt.custom.StyledText)7 SelectionListener (org.eclipse.swt.events.SelectionListener)7 Button (org.eclipse.swt.widgets.Button)7 SashForm (org.eclipse.swt.custom.SashForm)6 FormAttachment (org.eclipse.swt.layout.FormAttachment)6 FormData (org.eclipse.swt.layout.FormData)6 Text (org.eclipse.swt.widgets.Text)6 ToolBar (org.eclipse.swt.widgets.ToolBar)6 ToolItem (org.eclipse.swt.widgets.ToolItem)6