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

The following examples show how to use org.eclipse.ui.forms.widgets.ExpandableComposite#setExpanded() . 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: ErrorsWarningsPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
private Composite createProblemCategory(Composite parent, String label) {
  // Expandable panel for each category of problems
  ExpandableComposite expandPanel = new ExpandableComposite(parent, SWT.NONE,
      ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
  expandPanel.setText(label);
  expandPanel.setExpanded(false);
  expandPanel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
  expandPanel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
  expandPanel.addExpansionListener(new ExpansionAdapter() {
    @Override
    public void expansionStateChanged(ExpansionEvent e) {
      topPanel.layout(true, true);
      scrollPanel.setMinSize(topPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    }
  });

  // Create panel to store the actual problems
  Composite categoryPanel = new Composite(expandPanel, SWT.NONE);
  categoryPanel.setLayout(new GridLayout(2, false));
  expandPanel.setClient(categoryPanel);

  return categoryPanel;
}
 
Example 2
Source File: UserSettings.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Set the state of an expandable Composite to the previously saved state.
 * 
 * @param ec
 *            the expandable Composite to expand or collapse
 * @param field
 *            the unique name
 * @since 3.0.0 extracted from UserSettings2
 */
public static void setExpandedState(final ExpandableComposite ec, final String field){
	String mode =
		CoreHub.userCfg.get(USERSETTINGS2_EXPANDABLE_COMPOSITES,
			USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_REMEMBER_STATE);
	if (mode.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_OPEN)) {
		ec.setExpanded(true);
	} else if (mode.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED)) {
		ec.setExpanded(false);
	} else {
		String state =
			CoreHub.userCfg.get(USERSETTINGS2_EXPANDABLE_COMPOSITES_STATES + field,
				USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED);
		if (state.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED)) {
			ec.setExpanded(false);
		} else {
			ec.setExpanded(true);
		}
	}
}
 
Example 3
Source File: RechnungsBlatt.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private void setExpandedState(ExpandableComposite ec, String field){
	String mode = CoreHub.userCfg.get(USERSETTINGS2_EXPANDABLE_COMPOSITES,
		USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_REMEMBER_STATE);
	if (mode.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_OPEN)) {
		ec.setExpanded(true);
	} else if (mode.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED)) {
		ec.setExpanded(false);
	} else {
		String state = CoreHub.userCfg.get(USERSETTINGS2_EXPANDABLE_COMPOSITES_STATES + field,
			USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED);
		if (state.equals(USERSETTINGS2_EXPANDABLECOMPOSITE_STATE_CLOSED)) {
			ec.setExpanded(false);
		} else {
			ec.setExpanded(true);
		}
	}
}
 
Example 4
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns, Key key) {
	ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
	excomposite.setText(label);
	if (key != null) {
		excomposite.setData(key);
	}
	excomposite.setExpanded(false);
	excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
	excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
	excomposite.addExpansionListener(new ExpansionAdapter() {
		@Override
		public void expansionStateChanged(ExpansionEvent e) {
			expandedStateChanged((ExpandableComposite) e.getSource());
		}
	});
	fExpandableComposites.add(excomposite);
	makeScrollableCompositeAware(excomposite);
	return excomposite;
}
 
Example 5
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public void selectOption(Key key) {
	Control control= findControl(key);
	if (control != null) {
		if (!fExpandableComposites.isEmpty()) {
			ExpandableComposite expandable= getParentExpandableComposite(control);
			if (expandable != null) {
				for (int i= 0; i < fExpandableComposites.size(); i++) {
					ExpandableComposite curr= fExpandableComposites.get(i);
					curr.setExpanded(curr == expandable);
				}
				expandedStateChanged(expandable);
			}
		}
		control.setFocus();
	}
}
 
Example 6
Source File: CogniCryptPreferencePage.java    From CogniCrypt with Eclipse Public License 2.0 6 votes vote down vote up
@Override
protected Control createContents(Composite parent) {
	final Composite container = new Composite(parent, SWT.FILL);
	container.setLayout(new GridLayout(1, true));
	notifyBasicPreferenceListeners(container);

	new Label(container, SWT.NONE);
	final ExpandableComposite collap = new ExpandableComposite(container, SWT.Collapse);
	collap.setText("Advanced Options");

	final Composite advancedOptions = new Composite(collap, SWT.None);
	collap.setClient(advancedOptions);
	advancedOptions.setLayout(new RowLayout(SWT.VERTICAL));
	notifyAdvancedPreferenceListeners(advancedOptions);

	collap.setExpanded(true);
	return container;
}
 
Example 7
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 6 votes vote down vote up
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
	ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE,
			ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
	excomposite.setText(label);
	excomposite.setExpanded(false);
	excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
	excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
	excomposite.addExpansionListener(new ExpansionAdapter() {
		public void expansionStateChanged(ExpansionEvent e) {
			expandedStateChanged((ExpandableComposite) e.getSource());
		}
	});
	fExpandedComposites.add(excomposite);
	makeScrollableCompositeAware(excomposite);
	return excomposite;
}
 
Example 8
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 6 votes vote down vote up
public void selectOption(Key key) {
	Control control = findControl(key);
	if (control != null) {
		if (!fExpandedComposites.isEmpty()) {
			ExpandableComposite expandable = getParentExpandableComposite(control);
			if (expandable != null) {
				for (int i = 0; i < fExpandedComposites.size(); i++) {
					ExpandableComposite curr = (ExpandableComposite) fExpandedComposites.get(i);
					curr.setExpanded(curr == expandable);
				}
				expandedStateChanged(expandable);
			}
		}
		control.setFocus();
	}
}
 
Example 9
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
	ExpandableComposite excomposite = new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE
			| ExpandableComposite.CLIENT_INDENT);
	excomposite.setText(label);
	excomposite.setExpanded(false);
	excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
	excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
	excomposite.addExpansionListener(new ExpansionAdapter() {
		@Override
		public void expansionStateChanged(ExpansionEvent e) {
			expandedStateChanged((ExpandableComposite) e.getSource());
		}
	});
	expandedComposites.add(excomposite);
	makeScrollableCompositeAware(excomposite);
	return excomposite;
}
 
Example 10
Source File: OptionsConfigurationBlock.java    From typescript.java with MIT License 5 votes vote down vote up
protected void restoreSectionExpansionStates(IDialogSettings settings) {
	for (int i = 0; i < fExpandedComposites.size(); i++) {
		ExpandableComposite excomposite = (ExpandableComposite) fExpandedComposites.get(i);
		if (settings == null) {
			excomposite.setExpanded(i == 0); // only expand the first node
												// by default
		} else {
			excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
		}
	}
}
 
Example 11
Source File: AbstractWizardNewTypeScriptProjectCreationPage.java    From typescript.java with MIT License 5 votes vote down vote up
protected ExpandableComposite createStyleSection(Composite parent, String label, int nColumns) {
	ExpandableComposite excomposite= new ExpandableComposite(parent, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
	excomposite.setText(label);
	excomposite.setExpanded(false);
	excomposite.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DIALOG_FONT));
	excomposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, nColumns, 1));
	excomposite.addExpansionListener(new ExpansionAdapter() {
		public void expansionStateChanged(ExpansionEvent e) {
			expandedStateChanged((ExpandableComposite) e.getSource());
		}
	});
	//fExpandables.add(excomposite);
	makeScrollableCompositeAware(excomposite);
	return excomposite;
}
 
Example 12
Source File: ErrorsWarningsPage.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createPreferenceContent(Composite parent) {
  scrollPanel = new ScrolledComposite(parent, SWT.V_SCROLL);
  GridData scrollPanelGridData = new GridData(GridData.FILL_BOTH);
  scrollPanel.setLayoutData(scrollPanelGridData);
  GridLayout scrollPanelLayout = new GridLayout(1, false);
  scrollPanel.setLayout(scrollPanelLayout);

  topPanel = new Composite(scrollPanel, SWT.NONE);
  GridLayout layout = new GridLayout(1, false);
  layout.marginHeight = 0;
  layout.marginWidth = 0;
  topPanel.setLayout(layout);

  // Set up main composite to be scrollable
  scrollPanel.setContent(topPanel);
  scrollPanel.setExpandHorizontal(true);
  scrollPanel.setExpandVertical(true);

  // Create the list of problems (grouped by category)
  createProblemsList(topPanel);

  ExpandableComposite firstChild = (ExpandableComposite) problemsPanel.getChildren()[0];
  firstChild.setExpanded(true);

  // Initialize the severity combos
  populateSeverityCombosFromWorkingCopy();

  return topPanel;
}
 
Example 13
Source File: AbstractConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void expansionStateChanged(ExpansionEvent e) {
	ExpandableComposite source= (ExpandableComposite) e.getSource();
	updateSectionStyle(source);
	if (fIsBeingManaged)
		return;
	if (e.getState()) {
		try {
			fIsBeingManaged= true;
			for (Iterator<ExpandableComposite> iter= fSections.iterator(); iter.hasNext();) {
				ExpandableComposite composite= iter.next();
				if (composite != source)
					composite.setExpanded(false);
			}
		} finally {
			fIsBeingManaged= false;
		}
		if (fLastOpenKey != null && fDialogSettingsStore != null)
			fDialogSettingsStore.setValue(fLastOpenKey, source.getText());
	} else {
		if (!fIsBeingManaged && fLastOpenKey != null && fDialogSettingsStore != null)
			fDialogSettingsStore.setValue(fLastOpenKey, __NONE);
	}
	ExpandableComposite exComp= getParentExpandableComposite(source);
	if (exComp != null)
		exComp.layout(true, true);
	ScrolledPageContent parentScrolledComposite= getParentScrolledComposite(source);
	if (parentScrolledComposite != null) {
		parentScrolledComposite.reflow(true);
	}
}
 
Example 14
Source File: AbstractConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates an expandable section within the parent created previously by
 * calling <code>createSectionComposite</code>. Controls can be added
 * directly to the returned composite, which has no layout initially.
 *
 * @param label the display name of the section
 * @return a composite within the expandable section
 */
public Composite createSection(String label) {
	Assert.isNotNull(fBody);
	final ExpandableComposite excomposite= new ExpandableComposite(fBody, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT | ExpandableComposite.COMPACT);
	if (fFirstChild == null)
		fFirstChild= excomposite;
	excomposite.setText(label);
	String last= null;
	if (fLastOpenKey != null && fDialogSettingsStore != null)
		last= fDialogSettingsStore.getString(fLastOpenKey);

	if (fFirstChild == excomposite && !__NONE.equals(last) || label.equals(last)) {
		excomposite.setExpanded(true);
		if (fFirstChild != excomposite)
			fFirstChild.setExpanded(false);
	} else {
		excomposite.setExpanded(false);
	}
	excomposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false));

	updateSectionStyle(excomposite);
	manage(excomposite);

	Composite contents= new Composite(excomposite, SWT.NONE);
	excomposite.setClient(contents);

	return contents;
}
 
Example 15
Source File: OptionsConfigurationBlock.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void restoreSectionExpansionStates(IDialogSettings settings) {
	for (int i = 0; i < expandedComposites.size(); i++) {
		ExpandableComposite excomposite = expandedComposites.get(i);
		if (settings == null) {
			excomposite.setExpanded(i == 0); // only expand the first node by default
		} else {
			excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
		}
	}
}
 
Example 16
Source File: OptionsConfigurationBlock.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
protected void restoreSectionExpansionStates(IDialogSettings settings) {
	for (int i= 0; i < fExpandableComposites.size(); i++) {
		ExpandableComposite excomposite= fExpandableComposites.get(i);
		if (settings == null) {
			excomposite.setExpanded(i == 0); // only expand the first node by default
		} else {
			excomposite.setExpanded(settings.getBoolean(SETTINGS_EXPANDED + String.valueOf(i)));
		}
	}
}
 
Example 17
Source File: WidgetMessageDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void updateExpandState() {
    Composite parent = composite.getParent().getParent();
    ExpandableComposite expandableComposite = (ExpandableComposite) composite;
    if (messageLabel.getText() != null && !messageLabel.getText().isEmpty()) {
        expandableComposite.setClient(messageLabel);
        expandableComposite.setExpanded(true);
        expandableComposite.pack();
    } else {
        expandableComposite.setExpanded(false);
    }
    parent.layout();
}
 
Example 18
Source File: InvoiceCorrectionView.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
public void createComponents(FallDTO fallDTO){
	this.setBackground(UiDesk.getColor(UiDesk.COL_WHITE));
	FormToolkit tk = UiDesk.getToolkit();
	ScrolledForm form = tk.createScrolledForm(this);
	form.setBackground(UiDesk.getColor(UiDesk.COL_WHITE));
	form.setLayoutData(SWTHelper.getFillGridData(1, true, 1, false));
	Composite body = form.getBody();
	GridLayout gd1 = new GridLayout();
	gd1.marginWidth = 0;
	gd1.marginHeight = 0;
	body.setLayout(gd1);
	ExpandableComposite expandable = WidgetFactory.createExpandableComposite(tk, form, ""); //$NON-NLS-1$
	expandable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	expandable.setExpanded(false);
	expandable.setText("Fallangaben");
	expandable.addExpansionListener(new ExpansionAdapter() {
		
		@Override
		public void expansionStateChanged(ExpansionEvent e){
			invoiceComposite.updateScrollBars();
		}
	});
	Composite group = tk.createComposite(expandable, SWT.NONE);
	GridLayout gd = new GridLayout(2, false);
	gd.marginWidth = 0;
	gd.marginHeight = 0;
	group.setLayout(gd);
	group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	expandable.setClient(group);
	
	fallDetailBlatt2 = new FallDetailBlatt2(group, fallDTO, true);
	GridData gd2 = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
	gd2.heightHint = 340;
	fallDetailBlatt2.setLayoutData(gd2);
}
 
Example 19
Source File: AppEngineDeployPreferencesPanel.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
private void createExpandableComposite() {
  expandableComposite = new ExpandableComposite(this, SWT.NONE, ExpandableComposite.TWISTIE);
  FontUtil.convertFontToBold(expandableComposite);
  expandableComposite.setText(Messages.getString("settings.advanced"));
  expandableComposite.setExpanded(false);
  GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false);
  gridData.horizontalSpan = 2;
  expandableComposite.setLayoutData(gridData);

  formToolkit.adapt(expandableComposite, true, true);
}
 
Example 20
Source File: MechanicDialog.java    From workspacemechanic with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Add a form to the supplied Composite.
 */
private Control createForm(Composite parent) {

  final FormToolkit toolkit = new FormToolkit(parent.getDisplay());
  final ScrolledForm form = toolkit.createScrolledForm(parent);

  /*
   * For the life of me I can't understand why I have to supply
   * a GridData instance to the form object in order to get the form
   * to fill the dialog area.
   * 
   * BTW, I only found this out through trial and error.
   */
  form.setLayoutData(new GridData(GridData.FILL_BOTH));

  TableWrapLayout layout = new TableWrapLayout();
  layout.numColumns = 2;
  layout.horizontalSpacing = 15;
  layout.verticalSpacing = 10;

  form.getBody().setLayout(layout);
  form.getBody().setLayoutData(new TableWrapData(
      TableWrapData.FILL_GRAB, TableWrapData.FILL_GRAB, 1, 3));

  for (Task item : items) {

    // add an expandable description of the task, with a pretty title
    ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(),
        ExpandableComposite.TREE_NODE | ExpandableComposite.CLIENT_INDENT);
    ec.setText(item.getTitle());
    Label label = toolkit.createLabel(ec, item.getDescription(), SWT.WRAP);
    ec.setClient(label);
    ec.addExpansionListener(new ExpansionAdapter() {
      @Override 
      public void expansionStateChanged(ExpansionEvent e) {
        form.reflow(true);
      }
    });
    ec.setExpanded(true);
    ec.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));

    // add a combo box allowing the user to select the repair action to take
    createDecisionCombo(form.getBody(), item);
  }

  return parent;
}