Search in sources :

Example 71 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.platform.ui by eclipse-platform.

the class SectionFactoryTest method addsSectionExpandListeners.

@Test
public void addsSectionExpandListeners() {
    final ExpansionEvent[] raisedEvents = new ExpansionEvent[1];
    Section section = SectionFactory.newSection(Section.TWISTIE).onExpanded(e -> raisedEvents[0] = e).create(shell);
    Control twistie = section.getChildren()[0];
    assertTrue("Expected a twistie", twistie instanceof Twistie);
    click(twistie);
    assertNotNull(raisedEvents[0]);
}
Also used : SectionFactory(org.eclipse.ui.forms.widgets.SectionFactory) Shell(org.eclipse.swt.widgets.Shell) Assert.assertNotNull(org.junit.Assert.assertNotNull) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Event(org.eclipse.swt.widgets.Event) Twistie(org.eclipse.ui.forms.widgets.Twistie) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) SWT(org.eclipse.swt.SWT) After(org.junit.After) Label(org.eclipse.swt.widgets.Label) Assert.assertEquals(org.junit.Assert.assertEquals) Control(org.eclipse.swt.widgets.Control) Section(org.eclipse.ui.forms.widgets.Section) Before(org.junit.Before) Control(org.eclipse.swt.widgets.Control) Twistie(org.eclipse.ui.forms.widgets.Twistie) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent) Section(org.eclipse.ui.forms.widgets.Section) Test(org.junit.Test)

Example 72 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project eclipse.platform.ui by eclipse-platform.

the class ChooseWorkspaceWithSettingsDialog method createSettingsControls.

/**
 * Create the controls for selecting the controls we are going to export.
 *
 * @param workArea
 */
private void createSettingsControls(Composite workArea) {
    final FormToolkit toolkit = new FormToolkit(workArea.getDisplay());
    workArea.addDisposeListener(e -> toolkit.dispose());
    final ScrolledForm form = toolkit.createScrolledForm(workArea);
    form.getBody().setBackground(workArea.getBackground());
    form.getBody().setLayout(new GridLayout());
    form.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    final ExpandableComposite copySettingsExpandable = toolkit.createExpandableComposite(form.getBody(), ExpandableComposite.TWISTIE);
    copySettingsExpandable.setText(IDEWorkbenchMessages.ChooseWorkspaceWithSettingsDialog_SettingsGroupName);
    copySettingsExpandable.setBackground(workArea.getBackground());
    copySettingsExpandable.setLayout(new GridLayout());
    copySettingsExpandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    copySettingsExpandable.addExpansionListener(new IExpansionListener() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
            Point size = getInitialSize();
            Shell shell = getShell();
            shell.setBounds(getConstrainedShellBounds(new Rectangle(shell.getLocation().x, shell.getLocation().y, size.x, size.y)));
        }

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
        // Nothing to do here
        }
    });
    Composite sectionClient = toolkit.createComposite(copySettingsExpandable);
    sectionClient.setBackground(workArea.getBackground());
    if (createButtons(toolkit, sectionClient))
        copySettingsExpandable.setExpanded(true);
    copySettingsExpandable.setClient(sectionClient);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) IExpansionListener(org.eclipse.ui.forms.events.IExpansionListener) Shell(org.eclipse.swt.widgets.Shell) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) GridData(org.eclipse.swt.layout.GridData) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) ExpansionEvent(org.eclipse.ui.forms.events.ExpansionEvent)

Example 73 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project jbosstools-hibernate by jbosstools.

the class HibernateJavaEntity2_0Composite method initializeTypeDefCollapsibleSection.

protected void initializeTypeDefCollapsibleSection(Composite container) {
    final Section section = this.getWidgetFactory().createSection(container, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE);
    section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    // $NON-NLS-1$
    section.setText("Type Definitions");
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            if (e.getState() && section.getClient() == null) {
                section.setClient(initializeTypeDefsSection(section, buildTypeDefContainerHolder()));
            }
        }
    });
}
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 74 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project jbosstools-hibernate by jbosstools.

the class HibernateColumnComposite method initializeLayout.

@Override
protected void initializeLayout(Composite container) {
    // // Column group pane
    // container = addTitledGroup(
    // container,
    // JptJpaUiDetailsMessages.ColumnComposite_columnSection
    // );
    // 
    // // Column widgets
    // addLabeledComposite(
    // container,
    // JptJpaUiDetailsMessages.ColumnComposite_name,
    // addColumnCombo(container),
    // JpaHelpContextIds.MAPPING_COLUMN
    // );
    // 
    // // Table widgets
    // addLabeledComposite(
    // container,
    // JptJpaUiDetailsMessages.ColumnComposite_table,
    // addTableCombo(container),
    // JpaHelpContextIds.MAPPING_COLUMN_TABLE
    // );
    // 
    // // Details sub-pane
    // container = addCollapsibleSubSection(
    // container,
    // JptJpaUiDetailsMessages.ColumnComposite_details,
    // new SimplePropertyValueModel<Boolean>(Boolean.FALSE)
    // );
    // 
    // new DetailsComposite(this, getSubjectHolder(), addSubPane(container, 0, 16));
    // Column widgets
    this.addLabel(container, JptJpaUiDetailsMessages.COLUMN_COMPOSITE_NAME);
    this.addColumnCombo(container);
    // Table widgets
    this.addLabel(container, JptJpaUiDetailsMessages.COLUMN_COMPOSITE_TABLE);
    this.addTableCombo(container);
    // Details sub-pane
    final Section detailsSection = this.getWidgetFactory().createSection(container, ExpandableComposite.TWISTIE);
    detailsSection.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    detailsSection.setText(JptJpaUiDetailsMessages.COLUMN_COMPOSITE_DETAILS);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 2;
    detailsSection.setLayoutData(gridData);
    detailsSection.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanging(ExpansionEvent e) {
            if (e.getState() && detailsSection.getClient() == null) {
                detailsSection.setClient(HibernateColumnComposite.this.initializeDetailsSection(detailsSection));
            }
        }
    });
}
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 75 with ExpansionEvent

use of org.eclipse.ui.forms.events.ExpansionEvent in project gda-core by openGDA.

the class DataCollectionStatus method createPartControl.

/**
 * Create contents of the view part.
 *
 * @param parent
 */
@Override
public void createPartControl(Composite parent) {
    toolkit = new FormToolkit(parent.getDisplay());
    form = toolkit.createScrolledForm(parent);
    form.setText("Server Data Collection Status Report");
    TableWrapLayout layout = new TableWrapLayout();
    form.getBody().setLayout(layout);
    layout.numColumns = 2;
    Section section1 = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    TableWrapData td = new TableWrapData(TableWrapData.FILL);
    td.colspan = 2;
    section1.setLayoutData(td);
    section1.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    section1.setText("Experiment Setup");
    section1.setDescription("Dispaly summary information on samples being processed on the server after start.");
    Composite section1Client = toolkit.createComposite(section1);
    section1Client.setLayout(new GridLayout(4, false));
    Label label = toolkit.createLabel(section1Client, "Sample configuration file: ");
    GridData gd = new GridData();
    gd.horizontalSpan = 1;
    label.setLayoutData(gd);
    txtSamplesfile = toolkit.createText(section1Client, "samples definition file path", SWT.READ_ONLY | SWT.WRAP);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    gd.grabExcessHorizontalSpace = true;
    txtSamplesfile.setLayoutData(gd);
    label = toolkit.createLabel(section1Client, "Number of Active Samples: ");
    txtActivesamples = toolkit.createText(section1Client, "0", SWT.READ_ONLY);
    txtActivesamples.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(section1Client, "Number of Calibrations: ");
    txtNumberCalibrations = toolkit.createText(section1Client, "0", SWT.READ_ONLY);
    txtNumberCalibrations.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(section1Client, "Total Number of Collections: ");
    txtTotalNumberCollections = toolkit.createText(section1Client, "0", SWT.READ_ONLY);
    txtTotalNumberCollections.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    section1.setClient(section1Client);
    toolkit.paintBordersFor(section1Client);
    Section section = toolkit.createSection(form.getBody(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
    td = new TableWrapData(TableWrapData.FILL);
    td.colspan = 2;
    section.setLayoutData(td);
    section.addExpansionListener(new ExpansionAdapter() {

        @Override
        public void expansionStateChanged(ExpansionEvent e) {
            form.reflow(true);
        }
    });
    section.setText("Experiment Progress");
    section.setDescription("Display data collection progress informtion of the samples on the server.");
    Composite sectionClient = toolkit.createComposite(section);
    sectionClient.setLayout(new GridLayout(4, false));
    label = toolkit.createLabel(sectionClient, "Data file to collect: ");
    gd = new GridData();
    gd.horizontalSpan = 1;
    label.setLayoutData(gd);
    txtDataFilePath = toolkit.createText(sectionClient, "Display data file name is currently collecting", SWT.READ_ONLY | SWT.WRAP);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    gd.grabExcessHorizontalSpace = true;
    txtDataFilePath.setLayoutData(gd);
    label = toolkit.createLabel(sectionClient, "Acquisition Progress: ");
    gd = new GridData();
    gd.horizontalSpan = 1;
    label.setLayoutData(gd);
    progressBar = new ProgressBar(sectionClient, SWT.NONE);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    gd.grabExcessHorizontalSpace = true;
    progressBar.setLayoutData(gd);
    progressBar.setMaximum(100);
    progressBar.setMinimum(0);
    progressBar.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER);
    label = toolkit.createLabel(sectionClient, "Progress Message: ");
    gd = new GridData();
    gd.horizontalSpan = 1;
    label.setLayoutData(gd);
    txtProgressMessage = toolkit.createText(sectionClient, "Display server data collection progress messages here.", SWT.READ_ONLY | SWT.WRAP);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 3;
    gd.grabExcessHorizontalSpace = true;
    txtProgressMessage.setLayoutData(gd);
    label = toolkit.createLabel(sectionClient, "Current Scan Number: ");
    txtScanNumber = toolkit.createText(sectionClient, "Display current scan number", SWT.READ_ONLY);
    txtScanNumber.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(sectionClient, "Current Scan Point: ");
    txtScanPointNumber = toolkit.createText(sectionClient, "0/0", SWT.READ_ONLY);
    txtScanPointNumber.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(sectionClient, "Current Sample: ");
    txtSamplename = toolkit.createText(sectionClient, "Display current sample name", SWT.READ_ONLY);
    txtSamplename.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(sectionClient, "Current Cell: ");
    txtCellname = toolkit.createText(sectionClient, "Display current cell name", SWT.READ_ONLY);
    txtCellname.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(sectionClient, "Current Stage: ");
    txtStagename = toolkit.createText(sectionClient, "Display current stage name", SWT.READ_ONLY);
    txtStagename.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    label = toolkit.createLabel(sectionClient, "Current Collection: ");
    txtCollectionNumber = toolkit.createText(sectionClient, "0/0", SWT.READ_ONLY);
    txtCollectionNumber.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    section.setClient(sectionClient);
    toolkit.paintBordersFor(sectionClient);
    initialisation();
    // register as selection listener of sample editor if exist
    // getViewSite().getWorkbenchWindow().getSelectionService().addSelectionListener(SampleViewExtensionFactory.ID, selectionListener);
    createActions();
    initializeToolBar();
    initializeMenu();
    updateActionIconsState();
}
Also used : TableWrapData(org.eclipse.ui.forms.widgets.TableWrapData) GridLayout(org.eclipse.swt.layout.GridLayout) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) TableWrapLayout(org.eclipse.ui.forms.widgets.TableWrapLayout) Label(org.eclipse.swt.widgets.Label) 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) ProgressBar(org.eclipse.swt.widgets.ProgressBar)

Aggregations

ExpansionEvent (org.eclipse.ui.forms.events.ExpansionEvent)94 ExpansionAdapter (org.eclipse.ui.forms.events.ExpansionAdapter)73 Composite (org.eclipse.swt.widgets.Composite)71 ExpandableComposite (org.eclipse.ui.forms.widgets.ExpandableComposite)70 GridData (org.eclipse.swt.layout.GridData)62 GridLayout (org.eclipse.swt.layout.GridLayout)56 Section (org.eclipse.ui.forms.widgets.Section)45 IExpansionListener (org.eclipse.ui.forms.events.IExpansionListener)18 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)16 Label (org.eclipse.swt.widgets.Label)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)15 Point (org.eclipse.swt.graphics.Point)14 TableViewer (org.eclipse.jface.viewers.TableViewer)12 ArrayList (java.util.ArrayList)11 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)10 Button (org.eclipse.swt.widgets.Button)10 SelectionListener (org.eclipse.swt.events.SelectionListener)9 FormToolkit (org.eclipse.ui.forms.widgets.FormToolkit)9 List (java.util.List)8 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)8