Java Code Examples for org.eclipse.ui.forms.widgets.ExpandableComposite#setLayout()

The following examples show how to use org.eclipse.ui.forms.widgets.ExpandableComposite#setLayout() . 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: AppraiseDiffViewerPart.java    From git-appraise-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates an individual diff viewer in the given composite.
 */
private void createDiffViewer(final FormToolkit toolkit, Composite composite,
    final TaskAttribute diffTaskAttribute) {

  int style = ExpandableComposite.TREE_NODE | ExpandableComposite.LEFT_TEXT_CLIENT_ALIGNMENT
      | ExpandableComposite.COMPACT;
  ExpandableComposite diffComposite = toolkit.createExpandableComposite(composite, style);
  diffComposite.clientVerticalSpacing = 0;
  diffComposite.setLayout(new GridLayout());
  diffComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
  diffComposite.setTitleBarForeground(toolkit.getColors().getColor(IFormColors.TITLE));
  diffComposite.setText(calculateDiffChangeHeader(diffTaskAttribute));

  final Composite diffViewerComposite = toolkit.createComposite(diffComposite);
  diffComposite.setClient(diffViewerComposite);
  diffViewerComposite.setLayout(
      new FillWidthLayout(EditorUtil.getLayoutAdvisor(getTaskEditorPage()), 15, 0, 0, 3));

  diffComposite.addExpansionListener(new ExpansionAdapter() {
    @Override
    public void expansionStateChanged(ExpansionEvent event) {
      expandCollapseDiff(toolkit, diffViewerComposite, diffTaskAttribute, event.getState());
    }
  });
  GridDataFactory.fillDefaults().grab(true, false).applyTo(diffComposite);
}
 
Example 2
Source File: PipelineOptionsFormComponent.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private ExpandableComposite optionsTypeSection(PipelineLaunchConfiguration launchConfiguration,
    String optionsTypeName, Collection<String> optionsTypeProperties,
    Map<String, Optional<String>> optionsDescriptions, int style) {
  ExpandableComposite expandable = formToolkit.createSection(form.getBody(), style);
  expandable.setLayout(new GridLayout());
  expandable.setBackground(parent.getBackground());
  expandable.setForeground(parent.getForeground());
  expandable.setText(optionsTypeName);
  expandable.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));

  LabeledTextMapComponent typeArgs = new LabeledTextMapComponent(formToolkit, expandable,
      new GridData(SWT.FILL, SWT.CENTER, true, false), argumentSeparator);

  for (ModifyListener modifyListener : modifyListeners) {
    typeArgs.addModifyListener(modifyListener);
  }
  for (IExpansionListener expandListener : expansionListeners) {
    expandable.addExpansionListener(expandListener);
  }
  for (String property : optionsTypeProperties) {
    typeArgs.addLabeledText(property, optionsDescriptions.get(property));
  }

  optionsComponents.put(expandable, typeArgs);
  expandable.setClient(typeArgs.getControl());
  typeArgs.setTextValuesForExistingLabels(launchConfiguration.getArgumentValues());

  return expandable;
}