下面列出了怎么用org.eclipse.ui.forms.events.ExpansionEvent的API类实例代码及写法,或者点击链接到github查看源代码。
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;
}
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;
}
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;
}
/**
* 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);
}
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;
}
private void createSecondSection( ScrolledForm form, FormToolkit toolkit) {
ExpandableComposite ec = toolkit.createExpandableComposite(form.getBody(),
ExpandableComposite.TREE_NODE|
ExpandableComposite.CLIENT_INDENT);
ec.setText("Expandable Composite title");
String ctext = "We will now create a somewhat long text so that "+
"we can use it as content for the expandable composite. "+
"Expandable composite is used to hide or show the text using the " +
"toggle control";
Label client = toolkit.createLabel(ec, ctext, SWT.WRAP);
ec.setClient(client);
TableWrapData td = new TableWrapData();
td.colspan = 2;
ec.setLayoutData(td);
ec.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
form.reflow(true);
}
});
}
protected void createAdvancedSection() {
createExpandableComposite();
Composite advancedSection = new Composite(expandableComposite, SWT.NONE);
populateAdvancedSection(advancedSection);
GridLayoutFactory.swtDefaults().applyTo(advancedSection);
expandableComposite.setClient(advancedSection);
expandableComposite.addExpansionListener(new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent event) {
layoutChangedHandler.run();
}
});
}
public IExpansionListener getExpansionListener()
{
if (this.formRebuildingListener == null)
{
this.formRebuildingListener = new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e)
{
getManagedForm().reflow(true);
}
};
}
return this.formRebuildingListener;
}
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;
}
@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();
}
}
});
}
}
@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);
}
}
/**
* Creates a new component.
*
* @param wizardPage
*/
public AdvancedSettingsComponent(final Composite parent,
final ProjectImportConfiguration propectImportConfiguration,
final boolean enableProjectNameTemplate,
SimplerParametersWizardPage wizardPage) {
super(parent, ExpandableComposite.COMPACT | ExpandableComposite.TWISTIE
| ExpandableComposite.EXPANDED);
this.wizardPage = wizardPage;
setText("Advanced");
final Composite advancedComposite = new Composite(this, SWT.NONE);
setClient(advancedComposite);
addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e) {
Shell shell = parent.getShell();
Point minSize = shell.getMinimumSize();
shell.setMinimumSize(shell.getSize().x, minSize.y);
shell.pack();
parent.layout();
shell.setMinimumSize(minSize);
}
});
GridLayout gridLayout = new GridLayout();
gridLayout.marginLeft = 11;
gridLayout.numColumns = 2;
advancedComposite.setLayout(gridLayout);
createAdvancedSection(advancedComposite);
}
/**
* <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;
}
/**
* <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;
}
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);
}
/**
* ExpandableComposite (Aufklapp-Feld) in der Form erzeugen
*
* @param client
* das Element, das aufgeklappt werden soll
* @param Text
* Der Text, der auf dem Composite stehen soll
*/
public ExpandableComposite createExpandableComposite(Control client, String Text){
ExpandableComposite ret =
tk.createExpandableComposite(form.getBody(), ExpandableComposite.TWISTIE);
ret.setText(Text);
client.setParent(ret);
ret.setClient(client);
ret.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e){
form.reflow(true);
}
});
return ret;
}
public static ExpandableComposite createExpandableComposite(final FormToolkit t,
final ScrolledForm f, String text){
ExpandableComposite ret =
t.createExpandableComposite(f.getBody(), ExpandableComposite.TWISTIE);
ret.setText(text);
ret.addExpansionListener(new ExpansionAdapter() {
public void expansionStateChanged(ExpansionEvent e){
f.reflow(true);
}
});
return ret;
}
/**
* 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;
}
@Override
public void expansionStateChanging(ExpansionEvent event) { // ignored
}
@Override
public void expansionStateChanged(ExpansionEvent event) {
run();
}
@Override
public void expansionStateChanging(final ExpansionEvent ee) {
if (!ee.getState()) {
m_lastSectionSizeOnCollapse = m_section.getSize();
}
}
public void expansionStateChanged(final ExpansionEvent e) {
accept(Boolean.valueOf(e.getState()));
}
public EnterXMPPAccountComposite(Composite composite, int style) {
super(composite, style);
super.setLayout(new GridLayout(2, false));
SarosPluginContext.initComponent(this);
/*
* Row 1: JID
*/
Label jidLabel = new Label(this, SWT.NONE);
jidLabel.setText(Messages.jid_shortform);
Combo combo = new Combo(this, SWT.BORDER);
combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
this.jidCombo = new JIDCombo(combo);
/*
* Row 2: Password
*/
Label passwordLabel = new Label(this, SWT.NONE);
passwordLabel.setText("Password");
passwordText = new Text(this, SWT.BORDER);
passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
passwordText.setEchoChar('*');
/*
* Row 3: Server Options
*/
new Label(this, SWT.NONE);
serverOptionsExpandableComposite =
new ExpandableComposite(
this, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
serverOptionsExpandableComposite.setText("Advanced Options");
serverOptionsExpandableComposite.addExpansionListener(
new ExpansionAdapter() {
@Override
public void expansionStateChanged(ExpansionEvent e) {
getParent().layout();
}
});
createServerExpandableCompositeContent();
/*
* Row 4: Create Account Button
*/
createAccountButton = new Button(this, SWT.PUSH);
createAccountButton.setText(Messages.ConfigurationWizard_button_create_account);
createAccountButton.setVisible(CreateXMPPAccountWizard.CREATE_DIALOG_ENABLED);
hookListeners();
}
@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);
}
@Override
public void expansionStateChanging(ExpansionEvent e) {
//NOTHING TO DO
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
toLayout.layout();
}
@Override
public void expansionStateChanging(ExpansionEvent e) {
//NOTHING TO DO
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
toLayout.getShell().pack(true);
toLayout.layout();
}
@Override
public void expansionStateChanged(ExpansionEvent e) {
ExpandableComposite src = (ExpandableComposite) e.getSource();
CoreHub.localCfg.set(KEY_PATIENTENBLATT + src.getText(), src.isExpanded());
scrldfrm.reflow(true);
}