Search in sources :

Example 11 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project tdq-studio-se by Talend.

the class BusinessRuleAnalysisResultPage method createResultSection.

@Override
protected void createResultSection(Composite parent) {
    // ADD gdbu 2011-3-4 bug 19242
    AbstractPagePart treeViewer = masterPage.getTreeViewer();
    if (treeViewer != null && treeViewer instanceof AnalysisTableTreeViewer) {
        tableTreeViewer = (AnalysisTableTreeViewer) treeViewer;
    }
    // ~
    // $NON-NLS-1$
    resultSection = createSection(form, parent, DefaultMessagesImpl.getString("TableAnalysisResultPage.analysisResult"), null);
    sectionClient = toolkit.createComposite(resultSection);
    sectionClient.setLayout(new GridLayout());
    sectionClient.setLayoutData(new GridData(GridData.FILL_BOTH));
    dynamicList.clear();
    for (final TableIndicator tableIndicator : tableTreeViewer.getTableIndicator()) {
        ExpandableComposite exComp = toolkit.createExpandableComposite(sectionClient, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.EXPANDED);
        // bug 10541 fix by zshen,Change some character set to be proper to add view in the table anasys
        if (tableIndicator.isTable()) {
            exComp.setText(DefaultMessagesImpl.getString("TableAnalysisResultPage.table", // $NON-NLS-1$
            tableIndicator.getColumnSet().getName()));
        } else {
            exComp.setText(DefaultMessagesImpl.getString("TableAnalysisResultPage.view", // $NON-NLS-1$
            tableIndicator.getColumnSet().getName()));
        }
        exComp.setLayout(new GridLayout());
        exComp.setLayoutData(new GridData(GridData.FILL_BOTH));
        // MOD xqliu 2009-06-23 bug 7481
        exComp.setExpanded(EditorPreferencePage.isUnfoldingAnalyzedEelementsResultPage());
        // ~
        final Composite comp = toolkit.createComposite(exComp);
        comp.setLayout(new GridLayout());
        comp.setLayoutData(new GridData(GridData.FILL_BOTH));
        exComp.setClient(comp);
        createResultDataComposite(comp, tableIndicator);
        exComp.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                form.reflow(true);
            }
        });
    }
    resultSection.setClient(sectionClient);
}
Also used : AnalysisTableTreeViewer(org.talend.dataprofiler.core.ui.editor.composite.AnalysisTableTreeViewer) GridLayout(org.eclipse.swt.layout.GridLayout) TableIndicator(org.talend.dataprofiler.core.model.TableIndicator) AbstractPagePart(org.talend.dataprofiler.core.ui.editor.composite.AbstractPagePart) 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) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 12 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent 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 13 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent 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 14 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent 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)

Example 15 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project titan.EclipsePlug-ins by eclipse.

the class GroupsSubPage method createGroupItemsSection.

private void createGroupItemsSection(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);
    itemsTable = toolkit.createTable(client, SWT.NULL);
    itemsTable.setEnabled(groupSectionHandler != null && selectedGroup != null);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 200;
    gd.widthHint = 100;
    itemsTable.setLayoutData(gd);
    toolkit.paintBordersFor(client);
    itemsTable.setLinesVisible(true);
    itemsTable.setHeaderVisible(true);
    Composite buttons = toolkit.createComposite(client);
    buttons.setLayout(new GridLayout());
    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    addItem = toolkit.createButton(buttons, "Add item", SWT.PUSH);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    addItem.setLayoutData(gd);
    addItem.setEnabled(groupSectionHandler != null && selectedGroup != null);
    addItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (groupSectionHandler == null) {
                return;
            }
            if (selectedGroup == null) {
                return;
            }
            GroupItem newItem;
            ParseTree hidden = new AddedParseTree(", ");
            ConfigTreeNodeUtilities.addChild(selectedGroup.getRoot(), hidden);
            ParseTree node = new AddedParseTree("item");
            ConfigTreeNodeUtilities.addChild(selectedGroup.getRoot(), node);
            newItem = new GroupSectionHandler.GroupItem(node);
            selectedGroup.getGroupItems().add(newItem);
            internalRefresh();
            itemsTable.select(selectedGroup.getGroupItems().size() - 1);
            itemsTable.showSelection();
            editor.setDirty();
        }
    });
    removeItem = toolkit.createButton(buttons, "Remove item", SWT.PUSH);
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    removeItem.setLayoutData(gd);
    removeItem.setEnabled(groupSectionHandler != null && selectedGroup != null);
    removeItem.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (itemsTableViewer == null || groupSectionHandler == null) {
                return;
            }
            removeSelectedItems();
            internalRefresh();
            editor.setDirty();
        }
    });
    totalGroupItemsLabel = toolkit.createLabel(buttons, "");
    if (selectedGroup == null) {
        totalGroupItemsLabel.setText("Total: ");
    } else {
        totalGroupItemsLabel.setText("Total: " + selectedGroup.getGroupItems().size());
    }
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    totalGroupItemsLabel.setLayoutData(gd);
    section.setText("Group items");
    section.setDescription("Specify items of the selected group.");
    section.setClient(client);
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    gd = new GridData(GridData.FILL_BOTH);
    section.setLayoutData(gd);
    TableColumn column = new TableColumn(itemsTable, SWT.LEFT, 0);
    column.setText("Group item");
    column.setWidth(150);
    column.setMoveable(false);
    itemsTableViewer = new TableViewer(itemsTable);
    itemsTableViewer.setContentProvider(new GroupItemDataContentProvider());
    itemsTableViewer.setLabelProvider(new GroupItemDataLabelProvider());
    itemsTableViewer.setInput(null);
    itemsTableViewer.setColumnProperties(new String[] { "groupItem" });
    itemsTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(itemsTable) });
    itemsTableViewer.setCellModifier(new ICellModifier() {

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

        @Override
        public Object getValue(final Object element, final String property) {
            GroupItemDataLabelProvider labelProvider = (GroupItemDataLabelProvider) itemsTableViewer.getLabelProvider();
            return labelProvider.getColumnText(element, 0);
        }

        @Override
        public void modify(final Object element, final String property, final Object value) {
            if (element != null && element instanceof TableItem && value instanceof String) {
                GroupItem item = (GroupItem) ((TableItem) element).getData();
                ConfigTreeNodeUtilities.setText(item.getItem(), (String) value);
                itemsTableViewer.refresh(item);
                editor.setDirty();
            }
        }
    });
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) 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) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ICellModifier(org.eclipse.jface.viewers.ICellModifier) GroupItem(org.eclipse.titan.common.parsers.cfg.indices.GroupSectionHandler.GroupItem) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)58 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)53 GridData (org.eclipse.swt.layout.GridData)46 Composite (org.eclipse.swt.widgets.Composite)46 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)46 GridLayout (org.eclipse.swt.layout.GridLayout)38 Section (org.eclipse.ui.forms.widgets.Section)30 SelectionEvent (org.eclipse.swt.events.SelectionEvent)12 TableViewer (org.eclipse.jface.viewers.TableViewer)11 ArrayList (java.util.ArrayList)7 ICellModifier (org.eclipse.jface.viewers.ICellModifier)7 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)7 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)7 SelectionListener (org.eclipse.swt.events.SelectionListener)7 Point (org.eclipse.swt.graphics.Point)7 Label (org.eclipse.swt.widgets.Label)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 TableItem (org.eclipse.swt.widgets.TableItem)7 ParseTree (org.antlr.v4.runtime.tree.ParseTree)6 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)6