Java Code Examples for org.eclipse.ui.forms.widgets.Section#addExpansionListener()

The following examples show how to use org.eclipse.ui.forms.widgets.Section#addExpansionListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FormHelper.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * Constructs a section and returns a section client composite
 * 
 * the section layout is TableWrapLayout
 * 
 * 
 * @param parent parent container for the section
 * @param title title of the section
 * @param description description of the section
 * @param toolkit toolkit to create the composite
 * @param sectionFlags parameters of the section
 * @param expansionListener 
 * @return a section client (the content container of the section)
 */
public static Section createSectionComposite(Composite parent, String title, String description,
        FormToolkit toolkit, int sectionFlags, IExpansionListener expansionListener)
{
    final Section section = toolkit.createSection(parent, sectionFlags);

    section.setData(SECTION_IS_NOT_SPACE_GRABBING, new Object());
    section.setText(title);
    section.setDescription(description);

    if (expansionListener != null)
    {
        section.addExpansionListener(expansionListener);
    }

    // create section client
    Composite sectionClient = toolkit.createComposite(section);
    TableWrapLayout layout = new TableWrapLayout();
    layout.numColumns = 1;
    sectionClient.setLayout(layout);
    section.setClient(sectionClient);

    // draw flat borders
    toolkit.paintBordersFor(sectionClient);
    return section;
}
 
Example 2
Source File: ImportWorkspaceControlSupplier.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void doCreateWorkspaceTips(Composite mainComposite) {
    Label workspaceTips = new Label(mainComposite, SWT.NONE);
    workspaceTips.setLayoutData(GridDataFactory.fillDefaults().create());
    workspaceTips.setText(Messages.workspaceTips);

    final Section section = new Section(mainComposite, Section.TREE_NODE | Section.CLIENT_INDENT);
    section.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create());
    section.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.FILL, SWT.TOP).hint(200, SWT.DEFAULT)
                    .grab(true, false).create());
    section.setText(Messages.moreInfo);
    Label label = new Label(section, SWT.WRAP);
    label.setLayoutData(GridDataFactory.swtDefaults().create());
    label.setText(Messages.importWorkspaceOverwriteBehavior);
    section.setClient(label);
    section.setExpanded(false);
    section.addExpansionListener(new UpdateLayoutListener(mainComposite));
}
 
Example 3
Source File: AppraiseDiffViewerPart.java    From git-appraise-eclipse with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createControl(Composite parent, final FormToolkit toolkit) {
  final List<TaskAttribute> diffTaskAttributes = getDiffTaskAttributes();

  if (diffTaskAttributes == null || diffTaskAttributes.isEmpty()) {
    return;
  }
  int style = ExpandableComposite.TWISTIE | ExpandableComposite.SHORT_TITLE_BAR;
  final Section groupSection = toolkit.createSection(parent, style);
  groupSection.setText("Changes (" + diffTaskAttributes.size() + ')');
  groupSection.clientVerticalSpacing = 0;
  groupSection.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));

  if (groupSection.isExpanded()) {
    addDiffViewersToSection(toolkit, diffTaskAttributes, groupSection);
  } else {
    groupSection.addExpansionListener(new ExpansionAdapter() {
      @Override
      public void expansionStateChanged(ExpansionEvent e) {
        if (groupSection.getClient() == null) {
          try {
            getTaskEditorPage().setReflow(false);
            addDiffViewersToSection(toolkit, diffTaskAttributes, groupSection);
          } finally {
            getTaskEditorPage().setReflow(true);
          }
          getTaskEditorPage().reflow();
        }
      }
    });
  }
}
 
Example 4
Source File: ICEMatrixComponentSectionPart.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation reads the MatrixComponent assigned to this SectionPart and
 * renders the view of that data for the user.
 * </p>
 * 
 */
public void renderSection() {
	// Get this SectionPart's reference to the
	// underlying Section
	Section section = getSection();

	// Set the description and title for this SectionPart
	section.setDescription(matrixComponent.getDescription());
	section.setText(matrixComponent.getName());

	// Set this SectionParts reference to the underlying SWT Composite
	sectionClient = parentForm.getToolkit().createComposite(section);

	// Set the Composite's layout
	sectionClient.setLayout(new GridLayout(2, false));

	// Construct the JFace TableViewer and its controlling buttons
	setupTableViewer();
	setupButtons();

	// Add an ExpansionListener to this Section
	section.addExpansionListener(new ExpansionAdapter() {
		@Override
		public void expansionStateChanged(ExpansionEvent e) {
			parentForm.reflow(true);
		}
	});

	// Set the Composite on this Section
	section.setClient(sectionClient);

	return;
}
 
Example 5
Source File: ICETableComponentSectionPart.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <p>
 * This operation reads the TableComponent assigned to this SectionPart and
 * renders the view of that data for the user.
 * </p>
 * 
 */
public void renderSection() {
	// Local Declarations
	Section section = getSection();

	// Add the main description and title to the section
	section.setDescription(tableComponent.getDescription());
	section.setText(tableComponent.getName());

	// setup the composite given the IManagedForm (parentForm)
	// and the section of this sectionPart.
	sectionClient = parentForm.getToolkit().createComposite(section);

	// Set the layout to have three columns.
	// Sets the table to take up one column, and the
	// add and delete buttons take the next column.
	sectionClient.setLayout(new GridLayout(2, false));

	// Setup the tableComponentViewer and buttons
	this.setupTableViewer();
	this.setupButtons();

	// Set an expansion listener in order to control the
	// sectionPart's visibility to the user.
	section.addExpansionListener(new ExpansionAdapter() {
		@Override
		public void expansionStateChanged(ExpansionEvent e) {
			parentForm.reflow(true);
		}
	});

	// Add the sectionClient Composite to the sectionPart.
	section.setClient(sectionClient);

	return;
}
 
Example 6
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createTreeHeader(Composite parent, DataBindingContext ctx) {
    treeSection = new Section(parent, Section.TREE_NODE);
    treeSection.setLayout(GridLayoutFactory.fillDefaults().create());
    treeSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    treeSection.setText(Messages.importDetails);
    treeSection.addExpansionListener(new UpdateLayoutListener(parent));
    treeSection.setExpanded(false);
    descriptionLabel = new Label(treeSection, SWT.WRAP);
    archiveStatusObservable = PojoProperties.value("archiveStatus").observe(this);

    ctx.bindValue(WidgetProperties.text().observe(descriptionLabel), archiveStatusObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withValidator(this::archiveStatusValidator)
                    .withConverter(createArchiveStatusConverter()).create());
    treeSection.setDescriptionControl(descriptionLabel);
}
 
Example 7
Source File: ImportWorkspaceControlSupplier.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Section createStatusSection(Composite parent) {
    final Section section = new Section(parent, Section.TREE_NODE | Section.CLIENT_INDENT);
    section.setLayout(GridLayoutFactory.fillDefaults().create());
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    section.setText(Messages.importDetails);
    section.addExpansionListener(new UpdateLayoutListener(parent));
    section.setExpanded(false);
    return section;
}
 
Example 8
Source File: MessageDialogWithPrompt.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    if (detailsMessage != null) {
        parent.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
        //Above Image filler
        Image image = getImage();
        if (image != null) {
            Label filler = new Label(parent, SWT.NULL);
            filler.setImage(image);
            GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.BEGINNING)
                    .applyTo(filler);
            filler.setVisible(false);
        }

        Section section = new Section(parent,
                Section.TWISTIE | Section.NO_TITLE_FOCUS_BOX | Section.CLIENT_INDENT);
        section.setText(Messages.moreDetails);
        section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

        Composite client = new Composite(section, SWT.NONE);
        client.setLayoutData(GridDataFactory.fillDefaults().create());
        client.setLayout(GridLayoutFactory.fillDefaults().create());

        Link detailsLabel = new Link(client, getMessageLabelStyle());
        linkSelectionListener.ifPresent(listener -> detailsLabel.addListener(SWT.Selection, listener));
        detailsLabel.setText(detailsMessage);
        GridDataFactory
                .fillDefaults()
                .align(SWT.FILL, SWT.BEGINNING)
                .grab(true, false)
                .hint(convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH),
                        SWT.DEFAULT)
                .applyTo(detailsLabel);
        section.setClient(client);
        section.addExpansionListener(new ExpansionAdapter() {

            @Override
            public void expansionStateChanged(ExpansionEvent e) {
                parent.getShell().pack();
            }
        });
        return section;
    }
    return super.createCustomArea(parent);
}