Search in sources :

Example 46 with ExpansionAdapter

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

the class ModuleParameterSectionPage method createDetailsPart.

private void createDetailsPart(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 = 1;
    client.setLayout(layout);
    parameterValueText = toolkit.createText(client, "", SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    parameterValueText.setLayoutData(new GridData(GridData.FILL_BOTH));
    parameterValueText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            StructuredSelection selection = (StructuredSelection) moduleParametersTableViewer.getSelection();
            Iterator<?> iterator = selection.iterator();
            if (!iterator.hasNext()) {
                return;
            }
            ModuleParameter moduleParameter = (ModuleParameter) iterator.next();
            ConfigTreeNodeUtilities.setText(moduleParameter.getValue(), parameterValueText.getText());
            if (valueChanged) {
                valueChanged = false;
                return;
            }
            editor.setDirty();
        }
    });
    parameterValueText.setEnabled(moduleParametersHandler != null);
    section.setText("Module parameter value");
    section.setDescription("Specify the concrete value for the actually selected module parameter.");
    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);
    gd.grabExcessVerticalSpace = true;
    section.setLayoutData(gd);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModuleParameter(org.eclipse.titan.common.parsers.cfg.indices.ModuleParameterSectionHandler.ModuleParameter) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) Iterator(java.util.Iterator) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Section(org.eclipse.ui.forms.widgets.Section) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 47 with ExpansionAdapter

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

the class ExecuteSubPage method createExecuteSection.

void createExecuteSection(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));
    section.setText("Elements to be executed");
    section.setDescription("Specify the list of testcases and control parts to be executed for this configuration.\n" + "Use drag&drop to change the order of elements.");
    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);
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    section.setClient(client);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    client.setLayout(layout);
    gd = new GridData(GridData.FILL_BOTH);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessVerticalSpace = true;
    gd.verticalAlignment = SWT.FILL;
    client.setLayoutData(gd);
    toolkit.paintBordersFor(client);
    executeElementsTable = toolkit.createTable(client, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
    executeElementsTable.setEnabled(executeSectionHandler != null);
    TableColumn column = new TableColumn(executeElementsTable, SWT.LEFT, 0);
    column.setText("Module name");
    column.setWidth(200);
    column.setMoveable(false);
    column = new TableColumn(executeElementsTable, SWT.LEFT, 1);
    column.setText("Testcase name");
    column.setMoveable(false);
    column.setWidth(200);
    executeElementsTable.setHeaderVisible(true);
    executeElementsTable.setLinesVisible(true);
    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;
    executeElementsTable.setLayoutData(gd);
    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(executeSectionHandler != null);
    add.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
        // Do nothing
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (executeSectionHandler == null) {
                return;
            }
            if (executeSectionHandler.getLastSectionRoot() == null) {
                createNewExecuteSection();
            }
            ExecuteItem newItem = createNewExecuteItem();
            if (newItem == null) {
                return;
            }
            ConfigTreeNodeUtilities.addChild(executeSectionHandler.getLastSectionRoot(), newItem.getRoot());
            executeSectionHandler.getExecuteitems().add(newItem);
            internalRefresh();
            executeElementsTable.select(executeSectionHandler.getExecuteitems().size() - 1);
            executeElementsTable.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(executeSectionHandler != null);
    remove.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetDefaultSelected(final SelectionEvent e) {
        // Do nothing
        }

        @Override
        public void widgetSelected(final SelectionEvent e) {
            if (executeElementsTableViewer == null || executeSectionHandler == null) {
                return;
            }
            removeSelectedExecuteItems();
            if (executeSectionHandler.getExecuteitems().isEmpty()) {
                removeExecuteSection();
            }
            internalRefresh();
            editor.setDirty();
        }
    });
    totalExecuteElementsLabel = toolkit.createLabel(buttons, "Total: 0");
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    totalExecuteElementsLabel.setLayoutData(gd);
    executeElementsTableViewer = new TableViewer(executeElementsTable);
    executeElementsTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
        // not needed this time
        }
    });
    executeElementsTableViewer.setContentProvider(new ExecuteDataContentProvider());
    executeElementsTableViewer.setLabelProvider(new ExecuteDataLabelProvider());
    executeElementsTableViewer.setInput(executeSectionHandler);
    executeElementsTableViewer.setColumnProperties(COLUMN_NAMES);
    executeElementsTableViewer.setCellEditors(new TextCellEditor[] { new TextCellEditor(executeElementsTable), new TextCellEditor(executeElementsTable) });
    executeElementsTableViewer.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);
            ExecuteDataLabelProvider labelProvider = (ExecuteDataLabelProvider) executeElementsTableViewer.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) {
                ExecuteItem executeItem = (ExecuteItem) ((TableItem) element).getData();
                switch(columnIndex) {
                    case 0:
                        ConfigTreeNodeUtilities.setText(executeItem.getModuleName(), ((String) value).trim());
                        break;
                    case 1:
                        ConfigTreeNodeUtilities.setText(executeItem.getTestcaseName(), ((String) value).trim());
                        break;
                    default:
                        break;
                }
                executeElementsTableViewer.refresh(executeItem);
                editor.setDirty();
            }
        }
    });
    executeElementsTableViewer.addDragSupport(DND.DROP_COPY | DND.DROP_MOVE, new Transfer[] { ExecuteItemTransfer.getInstance() }, new ExecuteSectionDragSourceListener(this, executeElementsTableViewer));
    executeElementsTableViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_DEFAULT, new Transfer[] { ExecuteItemTransfer.getInstance() }, new ExecuteSectionDropTargetListener(executeElementsTableViewer, editor));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) TableItem(org.eclipse.swt.widgets.TableItem) ExecuteItem(org.eclipse.titan.common.parsers.cfg.indices.ExecuteSectionHandler.ExecuteItem) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) 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) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ICellModifier(org.eclipse.jface.viewers.ICellModifier) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 48 with ExpansionAdapter

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

the class ExternalCommandsSubPage method createExternalcommandsSection.

void createExternalcommandsSection(final Composite parent, final ScrolledForm form, final FormToolkit toolkit) {
    Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
    section.setActiveToggleColor(toolkit.getHyperlinkGroup().getActiveForeground());
    section.setToggleColor(toolkit.getColors().getColor(IFormColors.SEPARATOR));
    section.setText("External commands");
    section.setDescription("Specify the external commands to be called at execution time for this configuration.");
    section.setExpanded(true);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            form.reflow(false);
        }
    });
    GridData gd = new GridData(SWT.FILL, SWT.NONE, true, false);
    section.setLayoutData(gd);
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    section.setClient(client);
    GridLayout layout = new GridLayout();
    layout.numColumns = 3;
    client.setLayout(layout);
    toolkit.paintBordersFor(client);
    valueChanged = true;
    toolkit.createLabel(client, "Begin control part:");
    beginControlPartText = toolkit.createText(client, "", SWT.SINGLE);
    beginControlPartText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    beginControlPartText.setEnabled(executeCommandSectionHandler != null);
    beginControlPartText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            if (valueChanged || executeCommandSectionHandler == null) {
                return;
            }
            editor.setDirty();
            String temp = beginControlPartText.getText();
            if (temp == null || temp.length() == 0) {
                // remove the node
                if (executeCommandSectionHandler.getBeginControlPartRoot() != null) {
                    ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getBeginControlPartRoot());
                }
                executeCommandSectionHandler.setBeginControlPart(null);
                executeCommandSectionHandler.setBeginControlPartRoot(null);
                removeExternalCommandsSection();
            } else if (executeCommandSectionHandler.getBeginControlPart() == null) {
                // create the node
                createExternalCommandsSection();
                ParseTree beginControlPartRoot = new ParserRuleContext();
                executeCommandSectionHandler.setBeginControlPartRoot(beginControlPartRoot);
                ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), beginControlPartRoot);
                ConfigTreeNodeUtilities.addChild(beginControlPartRoot, new AddedParseTree("\nbeginControlPart := "));
                ParseTree beginControlPart = new AddedParseTree(temp.trim());
                executeCommandSectionHandler.setBeginControlPart(beginControlPart);
                ConfigTreeNodeUtilities.addChild(beginControlPartRoot, beginControlPart);
            } else {
                // simple modification
                ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getBeginControlPart(), temp.trim());
            }
        }
    });
    if (executeCommandSectionHandler != null && executeCommandSectionHandler.getBeginControlPart() != null) {
        beginControlPartText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getBeginControlPart()));
    }
    Button browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
    browse.addSelectionListener(new ExternalCommandBrowser(beginControlPartText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
    toolkit.createLabel(client, "Begin testcase:");
    beginTestCaseText = toolkit.createText(client, "", SWT.SINGLE);
    beginTestCaseText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    beginTestCaseText.setEnabled(executeCommandSectionHandler != null);
    beginTestCaseText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            if (valueChanged || executeCommandSectionHandler == null) {
                return;
            }
            editor.setDirty();
            String temp = beginTestCaseText.getText();
            if (temp == null || temp.length() == 0) {
                // remove the node
                if (executeCommandSectionHandler.getBeginTestcaseRoot() != null) {
                    ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getBeginTestcaseRoot());
                }
                executeCommandSectionHandler.setBeginTestcase(null);
                executeCommandSectionHandler.setBeginTestcaseRoot(null);
                removeExternalCommandsSection();
            } else if (executeCommandSectionHandler.getBeginTestcase() == null) {
                // create the node
                createExternalCommandsSection();
                ParseTree beginTestcaseRoot = new ParserRuleContext();
                executeCommandSectionHandler.setBeginTestcaseRoot(beginTestcaseRoot);
                ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), beginTestcaseRoot);
                ConfigTreeNodeUtilities.addChild(beginTestcaseRoot, new AddedParseTree("\nbeginTestcase := "));
                ParseTree beginTestcase = new AddedParseTree(temp.trim());
                executeCommandSectionHandler.setBeginTestcase(beginTestcase);
                ConfigTreeNodeUtilities.addChild(beginTestcaseRoot, beginTestcase);
            } else {
                // simple modification
                ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getBeginTestcase(), temp.trim());
            }
        }
    });
    if (executeCommandSectionHandler != null && executeCommandSectionHandler.getBeginTestcase() != null) {
        beginTestCaseText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getBeginTestcase()));
    }
    browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
    browse.addSelectionListener(new ExternalCommandBrowser(beginTestCaseText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
    toolkit.createLabel(client, "End control part:");
    endControlPartText = toolkit.createText(client, "", SWT.SINGLE);
    endControlPartText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    endControlPartText.setEnabled(executeCommandSectionHandler != null);
    endControlPartText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            if (valueChanged || executeCommandSectionHandler == null) {
                return;
            }
            editor.setDirty();
            String temp = endControlPartText.getText();
            if (temp == null || temp.length() == 0) {
                // remove the node
                if (executeCommandSectionHandler.getEndControlPartRoot() != null) {
                    ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getEndControlPartRoot());
                }
                executeCommandSectionHandler.setEndControlPart(null);
                executeCommandSectionHandler.setEndControlPartRoot(null);
                removeExternalCommandsSection();
            } else if (executeCommandSectionHandler.getEndControlPart() == null) {
                // create the node
                createExternalCommandsSection();
                ParseTree endControlPartRoot = new ParserRuleContext();
                executeCommandSectionHandler.setEndControlPartRoot(endControlPartRoot);
                ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), endControlPartRoot);
                ConfigTreeNodeUtilities.addChild(endControlPartRoot, new AddedParseTree("\nendControlPart := "));
                ParseTree endControlPart = new AddedParseTree(temp.trim());
                executeCommandSectionHandler.setEndControlPart(endControlPart);
                ConfigTreeNodeUtilities.addChild(endControlPartRoot, endControlPart);
            } else {
                // simple modification
                ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getEndControlPart(), temp.trim());
            }
        }
    });
    if (executeCommandSectionHandler != null && executeCommandSectionHandler.getEndControlPart() != null) {
        endControlPartText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getEndControlPart()));
    }
    browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
    browse.addSelectionListener(new ExternalCommandBrowser(endControlPartText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
    toolkit.createLabel(client, "End testcase:");
    endTestCaseText = toolkit.createText(client, "", SWT.SINGLE);
    endTestCaseText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    endTestCaseText.setEnabled(executeCommandSectionHandler != null);
    endTestCaseText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(final ModifyEvent e) {
            if (valueChanged || executeCommandSectionHandler == null) {
                return;
            }
            editor.setDirty();
            String temp = endTestCaseText.getText();
            if (temp == null || temp.length() == 0) {
                // remove the node
                if (executeCommandSectionHandler.getEndTestcaseRoot() != null) {
                    ConfigTreeNodeUtilities.removeChild(executeCommandSectionHandler.getLastSectionRoot(), executeCommandSectionHandler.getEndTestcaseRoot());
                }
                executeCommandSectionHandler.setEndTestcase(null);
                executeCommandSectionHandler.setEndTestcaseRoot(null);
                removeExternalCommandsSection();
            } else if (executeCommandSectionHandler.getEndTestcase() == null) {
                // create the node
                createExternalCommandsSection();
                ParseTree endTestcaseRoot = new ParserRuleContext();
                executeCommandSectionHandler.setEndTestcaseRoot(endTestcaseRoot);
                ConfigTreeNodeUtilities.addChild(executeCommandSectionHandler.getLastSectionRoot(), endTestcaseRoot);
                ConfigTreeNodeUtilities.addChild(endTestcaseRoot, new AddedParseTree("\nendTestcase := "));
                ParseTree endTestcase = new AddedParseTree(temp.trim());
                executeCommandSectionHandler.setEndTestcase(endTestcase);
                ConfigTreeNodeUtilities.addChild(endTestcaseRoot, endTestcase);
            } else {
                // simple modification
                ConfigTreeNodeUtilities.setText(executeCommandSectionHandler.getEndTestcase(), temp.trim());
            }
        }
    });
    if (executeCommandSectionHandler != null && executeCommandSectionHandler.getEndTestcase() != null) {
        endTestCaseText.setText(ConfigTreeNodeUtilities.toString(executeCommandSectionHandler.getEndTestcase()));
    }
    browse = toolkit.createButton(client, "Browse...", SWT.PUSH);
    browse.addSelectionListener(new ExternalCommandBrowser(endTestCaseText, (IFile) editor.getEditorInput().getAdapter(IFile.class)));
    valueChanged = false;
}
Also used : ParserRuleContext(org.antlr.v4.runtime.ParserRuleContext) IFile(org.eclipse.core.resources.IFile) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) AddedParseTree(org.eclipse.titan.common.parsers.AddedParseTree) ParseTree(org.antlr.v4.runtime.tree.ParseTree)

Example 49 with ExpansionAdapter

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

the class BaseNamingConventionPropertyPage method createExtendableComposite.

/**
 * Creates an expandable composite on the user interface.
 *
 * @param parent
 *                the parent composite where this one can be added to.
 * @param title
 *                the title of the new composite.
 *
 * @return the created composite.
 */
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
    final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
    ex.setText(title);
    ex.setExpanded(false);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    ex.setLayoutData(data);
    ex.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            Composite temp = parent;
            while (temp != null && !(temp instanceof ScrolledComposite)) {
                temp = temp.getParent();
            }
            if (temp != null) {
                Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                ((ScrolledComposite) temp).setMinSize(point);
                ((ScrolledComposite) temp).layout(true, true);
            }
        }
    });
    return ex;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 50 with ExpansionAdapter

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

the class ErrorsWarningsPreferencePage method createExtendableComposite.

/**
 * Creates an expandable composite on the user interface.
 *
 * @param parent
 *                the parent composite where this one can be added to.
 * @param title
 *                the title of the new composite.
 *
 * @return the created composite.
 */
private ExpandableComposite createExtendableComposite(final Composite parent, final String title) {
    final ExpandableComposite ex = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
    ex.setText(title);
    ex.setExpanded(false);
    GridData data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    ex.setLayoutData(data);
    ex.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(final ExpansionEvent e) {
            Composite temp = parent;
            while (temp != null && !(temp instanceof ScrolledComposite)) {
                temp = temp.getParent();
            }
            if (temp != null) {
                Point point = pagecomp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
                ((ScrolledComposite) temp).setMinSize(point);
                ((ScrolledComposite) temp).layout(true, true);
            }
        }
    });
    return ex;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExpansionAdapter(org.eclipse.ui.forms.events.ExpansionAdapter) Point(org.eclipse.swt.graphics.Point) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Aggregations

ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)53 ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)53 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)43 Composite (org.eclipse.swt.widgets.Composite)42 GridData (org.eclipse.swt.layout.GridData)40 GridLayout (org.eclipse.swt.layout.GridLayout)33 Section (org.eclipse.ui.forms.widgets.Section)28 TableViewer (org.eclipse.jface.viewers.TableViewer)11 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 ICellModifier (org.eclipse.jface.viewers.ICellModifier)7 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)7 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)7 TableColumn (org.eclipse.swt.widgets.TableColumn)7 TableItem (org.eclipse.swt.widgets.TableItem)7 ArrayList (java.util.ArrayList)6 ParseTree (org.antlr.v4.runtime.tree.ParseTree)6 Point (org.eclipse.swt.graphics.Point)6 AddedParseTree (org.eclipse.titan.common.parsers.AddedParseTree)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)5