Search in sources :

Example 31 with Section

use of org.eclipse.ui.forms.widgets.Section in project tdq-studio-se by Talend.

the class AbstractFormPage method createSection.

/**
 * DOC bZhou Comment method "createSection".
 *
 * @param form
 * @param parent
 * @param title
 * @param description
 * @return
 */
public Section createSection(final ScrolledForm form, Composite parent, String title, String description) {
    int style = Section.DESCRIPTION | Section.TWISTIE | Section.TITLE_BAR | Section.LEFT_TEXT_CLIENT_ALIGNMENT;
    if (description == null) {
        style = Section.TWISTIE | Section.TITLE_BAR | Section.LEFT_TEXT_CLIENT_ALIGNMENT;
    }
    Section section = toolkit.createSection(parent, style);
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    section.setText(title);
    section.setDescription(description);
    section.setExpanded(getExpandedStatus(title));
    registerSection(section);
    sectionCount++;
    return section;
}
Also used : GridData(org.eclipse.swt.layout.GridData) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 32 with Section

use of org.eclipse.ui.forms.widgets.Section in project tdq-studio-se by Talend.

the class AbstractMetadataFormPage method creatMetadataSection.

protected Section creatMetadataSection(final ScrolledForm currentform, Composite parentCom) {
    Section section = createSection(currentform, topComp, getMetadataSectionTitle(), getMetadataSectionDescription());
    Composite parent = toolkit.createComposite(section);
    parent.setLayout(new GridLayout(2, false));
    // $NON-NLS-1$
    nameText = createMetadataTextFiled(DefaultMessagesImpl.getString("AbstractMetadataFormPage.name"), parent);
    // set the max number of characters to be entered in the text field
    // ADDED sgandon 16/03/2010 bug 11760
    nameText.setTextLimit(EmfHelper.getStringMaxSize(CorePackage.Literals.MODEL_ELEMENT__NAME, MAX_TEXT_FIELD_STRING_SIZE_FOR_USUAL_STRING));
    // $NON-NLS-1$
    purposeText = createMetadataTextFiled(DefaultMessagesImpl.getString("AbstractMetadataFormPage.purpose"), parent);
    // set the max number of characters to be entered in the text field
    // ADDED sgandon 16/03/2010 bug 11760
    purposeText.setTextLimit(TaggedValueHelper.getStringMaxSize(TaggedValueHelper.PURPOSE, MAX_TEXT_FIELD_STRING_SIZE_FOR_USUAL_STRING));
    // description fields
    // ADDED sgandon 16/03/2010 bug 11760
    // $NON-NLS-1$
    toolkit.createLabel(parent, DefaultMessagesImpl.getString("AbstractMetadataFormPage.description"));
    descriptionText = toolkit.createText(parent, null, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    GridDataFactory.fillDefaults().hint(META_FIELD_WIDTH, 60).applyTo(descriptionText);
    // set the max number of characters to be entered in the text field
    descriptionText.setTextLimit(TaggedValueHelper.getStringMaxSize(TaggedValueHelper.DESCRIPTION, MAX_TEXT_FIELD_STRING_SIZE_FOR_USUAL_STRING));
    // $NON-NLS-1$
    authorText = createMetadataTextFiled(DefaultMessagesImpl.getString("AbstractMetadataFormPage.author"), parent);
    // ADDED 2010-04-01 sgandon bug 11760 : author size limitation
    authorText.setTextLimit(TaggedValueHelper.getStringMaxSize(TaggedValueHelper.AUTHOR, MAX_TEXT_FIELD_STRING_SIZE_FOR_USUAL_STRING));
    // MOD 2009-09-08 yyi Feature: 8870.
    if (!ReponsitoryContextBridge.isDefautProject()) {
        authorText.setEnabled(false);
        authorText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
    }
    // $NON-NLS-1$
    toolkit.createLabel(parent, DefaultMessagesImpl.getString("AbstractMetadataFormPage.status"));
    statusCombo = new CCombo(parent, SWT.BORDER);
    statusCombo.setEditable(false);
    // MOD mzhao feature 7479 2009-10-16
    String statusValue = getProperty() != null ? getProperty().getStatusCode() : DevelopmentStatus.DRAFT.getLiteral();
    List<org.talend.core.model.properties.Status> statusList = MetadataHelper.getTechnicalStatus();
    if (statusList != null && statusList.size() > 0) {
        List<String> statusArray = MetadataHelper.toArray(statusList);
        String[] tempString = new String[statusList.size()];
        statusCombo.setItems(statusArray.toArray(tempString));
        if (statusArray.contains(statusValue)) {
            statusCombo.remove(statusValue);
            statusCombo.add(statusValue, 0);
        }
    } else {
        for (DevelopmentStatus status : DevelopmentStatus.values()) {
            statusCombo.add(status.getLiteral());
        }
        // statusCombo.remove(statusValue);
        statusCombo.add(statusValue, 0);
    }
    initMetaTextFied();
    nameText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            // boolean dirty = isDirty();
            if (!isRefreshText) {
                modify = true;
                setDirty(true);
                // MOD msjian 2011-7-18 23216: when changed the name of a connection to null, write a warning
                // $NON-NLS-1$
                String NAMECONNOTBEEMPTY = DefaultMessagesImpl.getString("AbstractMetadataFormPage.nameCannotBeEmpty");
                if (PluginConstant.EMPTY_STRING.equals(nameText.getText())) {
                    getManagedForm().getMessageManager().addMessage(NAMECONNOTBEEMPTY, NAMECONNOTBEEMPTY, null, IMessageProvider.ERROR, nameText);
                } else {
                    getManagedForm().getMessageManager().removeMessage(NAMECONNOTBEEMPTY, nameText);
                }
            }
        }
    });
    purposeText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setDirty(true);
        // fireTextChange();
        }
    });
    descriptionText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setDirty(true);
        // fireTextChange();
        }
    });
    authorText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setDirty(true);
        // fireTextChange();
        }
    });
    statusCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            setDirty(true);
        // fireTextChange();
        }
    });
    addWhitespaceValidate(nameText, purposeText, descriptionText, authorText, purposeText);
    section.setClient(parent);
    return section;
}
Also used : DevelopmentStatus(org.talend.cwm.constants.DevelopmentStatus) Composite(org.eclipse.swt.widgets.Composite) ContextComposite(org.talend.dataprofiler.core.ui.editor.composite.ContextComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) CCombo(org.eclipse.swt.custom.CCombo) DevelopmentStatus(org.talend.cwm.constants.DevelopmentStatus)

Example 33 with Section

use of org.eclipse.ui.forms.widgets.Section in project ecf by eclipse.

the class NotificationDialog method createContents.

protected Control createContents(Composite parent) {
    toolkit = new FormToolkit(parent.getDisplay());
    Section section = toolkit.createSection(parent, Section.TITLE_BAR);
    section.setLayout(new GridLayout(1, false));
    section.setText("Incoming Collaboration Request");
    Composite composite = toolkit.createComposite(section);
    composite.setLayout(new GridLayout(1, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    section.setClient(composite);
    ImageHyperlink hyperlink = toolkit.createImageHyperlink(composite, SWT.LEAD);
    hyperlink.setHoverImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT));
    hyperlink.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED));
    hyperlink.setText("Share Project Request");
    if (listener != null) {
        hyperlink.addHyperlinkListener(listener);
    }
    hyperlink.addHyperlinkListener(new CloseDialogListener());
    Control text = toolkit.createText(composite, sender.getName() + " has sent a request to share project '" + projectName + "' with you.");
    text.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    return section;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) Section(org.eclipse.ui.forms.widgets.Section)

Example 34 with Section

use of org.eclipse.ui.forms.widgets.Section in project titan.EclipsePlug-ins by eclipse.

the class ComponentsSubPage method createComponentsSection.

void createComponentsSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    client.setLayout(layout);
    toolkit.paintBordersFor(client);
    componentsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    componentsTable.setEnabled(componentsSectionHandler != null);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 100;
    gd.heightHint = 200;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    componentsTable.setLayoutData(gd);
    componentsTable.setLinesVisible(true);
    componentsTable.setHeaderVisible(true);
    TableColumn column = new TableColumn(componentsTable, SWT.LEFT, 0);
    column.setText("Component name");
    column.setWidth(130);
    column.setMoveable(false);
    column = new TableColumn(componentsTable, SWT.LEFT, 1);
    column.setText("Host name");
    column.setWidth(100);
    column.setMoveable(false);
    componentsTableViewer = new TableViewer(componentsTable);
    componentsTableViewer.setContentProvider(new ComponentsDataContentProvider());
    componentsTableViewer.setLabelProvider(new ComponentsDataLabelProvider());
    componentsTableViewer.setInput(componentsSectionHandler);
    componentsTableViewer.setColumnProperties(COLUMN_NAMES);
    final TextCellEditor[] cellEditors = new TextCellEditor[] { new TextCellEditor(componentsTable), new TextCellEditor(componentsTable) };
    componentsTableViewer.setCellEditors(cellEditors);
    componentsTableViewer.setCellModifier(new ICellModifier() {

        @Override
        public boolean canModify(final Object element, final String property) {
            return true;
        }

        @Override
        public String getValue(final Object element, final String property) {
            int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
            ComponentsDataLabelProvider labelProvider = (ComponentsDataLabelProvider) componentsTableViewer.getLabelProvider();
            return labelProvider.getColumnText(element, columnIndex);
        }

        @Override
        public void modify(final Object element, final String property, final Object value) {
            int columnIndex = Arrays.asList(COLUMN_NAMES).indexOf(property);
            if (element != null && element instanceof TableItem && value instanceof String) {
                Component component = (Component) ((TableItem) element).getData();
                switch(columnIndex) {
                    case 0:
                        ConfigTreeNodeUtilities.setText(component.getComponentName(), ((String) value).trim());
                        break;
                    case 1:
                        ConfigTreeNodeUtilities.setText(component.getHostName(), ((String) value).trim());
                        break;
                    default:
                        break;
                }
                componentsTableViewer.refresh(component);
                editor.setDirty();
            }
        }
    });
    Composite buttons = toolkit.createComposite(client);
    buttons.setLayout(new GridLayout());
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.GRAB_VERTICAL));
    add = toolkit.createButton(buttons, "Add...", SWT.PUSH);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    add.setLayoutData(gd);
    add.setEnabled(componentsSectionHandler != null);
    add.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (componentsSectionHandler == null) {
                return;
            }
            if (componentsSectionHandler.getLastSectionRoot() == null) {
                createNewComponentsSection();
            }
            Component newComponent = createNewComponent();
            if (newComponent == null) {
                return;
            }
            ConfigTreeNodeUtilities.addChild(componentsSectionHandler.getLastSectionRoot(), newComponent.getRoot());
            componentsSectionHandler.getComponents().add(newComponent);
            internalRefresh();
            componentsTable.select(componentsSectionHandler.getComponents().size() - 1);
            componentsTable.showSelection();
            editor.setDirty();
        }
    });
    remove = toolkit.createButton(buttons, "Remove", SWT.PUSH);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    remove.setLayoutData(gd);
    remove.setEnabled(componentsSectionHandler != null);
    remove.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (componentsTableViewer == null || componentsSectionHandler == null) {
                return;
            }
            removeSelectedComponents();
            if (componentsSectionHandler.getComponents().isEmpty()) {
                removeComponentsSection();
            }
            internalRefresh();
            editor.setDirty();
        }
    });
    totalComponentsLabel = toolkit.createLabel(buttons, "Total: 0");
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    totalComponentsLabel.setLayoutData(gd);
    section.setText("Components");
    section.setDescription("Specify the list of remote components for this configuration.");
    section.setClient(client);
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    section.setLayoutData(gd);
    final ComponentItemTransfer instance = ComponentItemTransfer.getInstance();
    componentsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { instance }, new ComponentSectionDragSourceListener(this, componentsTableViewer));
    componentsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { instance }, new ComponentSectionDropTargetListener(componentsTableViewer, editor));
    internalRefresh();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ICellModifier(org.eclipse.jface.viewers.ICellModifier) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Component(org.eclipse.titan.common.parsers.cfg.indices.ComponentSectionHandler.Component) TableViewer(org.eclipse.jface.viewers.TableViewer) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 35 with Section

use of org.eclipse.ui.forms.widgets.Section in project titan.EclipsePlug-ins by eclipse.

the class GroupsSubPage method createGroupsSection.

void createGroupsSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    section.setText("Groups section");
    section.setDescription("Specify the contents of the groups section for this configuration.");
    section.setClient(client);
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    GridData gd = new GridData(GridData.FILL_BOTH);
    section.setLayoutData(gd);
    createMainGroupsSection(client, form, toolkit);
    createGroupItemsSection(client, form, toolkit);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

Section (org.eclipse.ui.forms.widgets.Section)260 Composite (org.eclipse.swt.widgets.Composite)229 GridLayout (org.eclipse.swt.layout.GridLayout)216 GridData (org.eclipse.swt.layout.GridData)215 ISection (org.eclipse.ui.views.properties.tabbed.ISection)103 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)70 TableViewer (org.eclipse.jface.viewers.TableViewer)33 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)32 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)30 TableWrapData (org.eclipse.ui.forms.widgets.TableWrapData)29 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)28 SelectionEvent (org.eclipse.swt.events.SelectionEvent)25 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)19 Group (org.eclipse.swt.widgets.Group)19 EJFrameworkExtensionProperties (org.entirej.framework.core.properties.definitions.interfaces.EJFrameworkExtensionProperties)19 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)17 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)17 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)17 FillLayout (org.eclipse.swt.layout.FillLayout)16 HyperlinkAdapter (org.eclipse.ui.forms.events.HyperlinkAdapter)16