下面列出了怎么用org.eclipse.ui.forms.widgets.ExpandableComposite的API类实例代码及写法,或者点击链接到github查看源代码。
public ProjectInfoSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
section.setText(Messages.AppOverviewEditorProjectInfoSection);
section.setLayoutData(new GridData(SWT.FILL,SWT.FILL, true, false, hSpan, vSpan));
section.setExpanded(true);
Composite composite = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 5;
layout.marginWidth = 10;
layout.verticalSpacing = 5;
layout.horizontalSpacing = 10;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
typeEntry = new StringEntry(composite, Messages.AppOverviewEditorTypeEntry);
languageEntry = new StringEntry(composite, Messages.AppOverviewEditorLanguageEntry);
projectIdEntry = new StringEntry(composite, Messages.AppOverviewEditorProjectIdEntry);
locationEntry = new StringEntry(composite, Messages.AppOverviewEditorLocationEntry);
}
private void createJUnitSection(int nColumns, Composite parent) {
final int defaultIndent = 0;
String label = MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_section_junit;
Key twistieKey = OptionsConfigurationBlock.getLocalKey("JavaEditorCodeMiningPreferencePage_section_junit"); //$NON-NLS-1$
PreferenceTreeNode<?> section = fFilteredPrefTree.addExpandableComposite(parent, label, nColumns, twistieKey,
null, false);
ExpandableComposite excomposite = getExpandableComposite(twistieKey);
Composite inner = createInnerComposite(excomposite, nColumns, parent.getFont());
// - Show JUnit status
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showJUnitStatus_label,
PREF_SHOW_JUNIT_STATUS, TRUE_FALSE, defaultIndent, section);
// - Show JUnit run
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showJUnitRun_label, PREF_SHOW_JUNIT_RUN,
TRUE_FALSE, defaultIndent, section);
// - Show JUnit debug
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showJUnitDebug_label,
PREF_SHOW_JUNIT_DEBUG, TRUE_FALSE, defaultIndent, section);
}
private void createDebuggingSection(int nColumns, Composite parent) {
final int defaultIndent = 0;
String label = MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_section_debugging;
Key twistieKey = OptionsConfigurationBlock.getLocalKey("JavaEditorCodeMiningPreferencePage_section_debugging"); //$NON-NLS-1$
PreferenceTreeNode<?> section = fFilteredPrefTree.addExpandableComposite(parent, label, nColumns, twistieKey,
null, false);
ExpandableComposite excomposite = getExpandableComposite(twistieKey);
Composite inner = createInnerComposite(excomposite, nColumns, parent.getFont());
// - Show main run/debug
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showMainRun_label, PREF_SHOW_MAIN_RUN,
TRUE_FALSE, defaultIndent, section);
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showMainDebug_label, PREF_SHOW_MAIN_DEBUG,
TRUE_FALSE, defaultIndent, section);
// - Show variable value while debugging
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showVariableValueWhileDebugging_label,
PREF_SHOW_VARIABLE_VALUE_WHILE_DEBUGGING, TRUE_FALSE, defaultIndent, section);
}
private void createUnstagedComposite(Composite parent) {
this.unstagedSection = this.toolkit.createSection(parent, ExpandableComposite.SHORT_TITLE_BAR);
this.unstagedSection.setText(Messages.AbapGitStaging_unstaged_changes_section_header + " (0)"); //$NON-NLS-1$
this.unstagedSection.clientVerticalSpacing = 0;
//unstaged section toolbar
this.createUnstagedSectionToolbar();
Composite unstagedComposite = this.toolkit.createComposite(this.unstagedSection);
this.toolkit.paintBordersFor(unstagedComposite);
GridLayoutFactory.fillDefaults().applyTo(unstagedComposite);
this.unstagedSection.setClient(unstagedComposite);
//create the treeviewer
this.unstagedTreeViewer = this.createTreeViewer(unstagedComposite, true);
this.unstagedTreeViewer.setInput(this.unstagedTreeViewerInput);
addDragAndDropSupport(this.unstagedTreeViewer, true);
//add context menu support to the tree viewer
this.unstagedMenuFactory = new AbapGitStagingObjectMenuFactory(this.unstagedTreeViewer, true, this, this.stagingUtil);
}
private void createStagedComposite(Composite parent) {
this.stagedSection = this.toolkit.createSection(parent, ExpandableComposite.SHORT_TITLE_BAR);
this.stagedSection.setText(Messages.AbapGitStaging_staged_changes_section_header + " (0)"); //$NON-NLS-1$
this.stagedSection.clientVerticalSpacing = 0;
//staged section toolbar
this.createStagedSectionToolbar();
Composite stagedComposite = this.toolkit.createComposite(this.stagedSection);
this.toolkit.paintBordersFor(stagedComposite);
GridLayoutFactory.fillDefaults().applyTo(stagedComposite);
this.stagedSection.setClient(stagedComposite);
//create the treeviewer
this.stagedTreeViewer = this.createTreeViewer(stagedComposite, false);
this.stagedTreeViewer.setInput(this.stagedTreeViewerInput);
addDragAndDropSupport(this.stagedTreeViewer, false);
//add context menu support to the tree viewer
this.stagedMenuFactory = new AbapGitStagingObjectMenuFactory(this.stagedTreeViewer, false, this, this.stagingUtil);
}
@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;
}
@Override
public void setUnlocked(boolean unlocked){
bLocked = !unlocked;
ipp.setUnlocked(unlocked);
inpZusatzAdresse.setUnlocked(unlocked);
hHA.setEnabled(unlocked);
// delZA.setEnabled(!bLock);
removeZAAction.setEnabled(unlocked);
removeAdditionalAddressAction.setEnabled(unlocked);
additionalAddresses.setUnlocked(unlocked);
dmd.setUnlocked(unlocked);
if (unlocked) {
hHA.setForeground(UiDesk.getColor(UiDesk.COL_BLUE));
} else {
hHA.setForeground(UiDesk.getColor(UiDesk.COL_GREY));
}
for (ExpandableComposite ex : ec) {
ex.getClient().setEnabled(unlocked);
}
detailComposites.forEach(dc -> dc.setUnlocked(unlocked));
}
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;
}
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();
}
}
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);
}
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();
}
}
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 Composite createForm(Composite parent) {
FormToolkit toolkit = new FormToolkit(Display.getCurrent());
ScrolledForm form = toolkit.createScrolledForm(parent);
Composite body = form.getBody();
body.setLayout(new FillLayout());
toolkit.paintBordersFor(body);
SashForm sash = new SashForm(body, SWT.VERTICAL);
toolkit.adapt(sash, true, true);
Section section = toolkit.createSection(sash,
ExpandableComposite.NO_TITLE | ExpandableComposite.EXPANDED);
section.setText("");
Composite composite = toolkit.createComposite(section, SWT.NONE);
composite.setLayout(new GridLayout());
section.setClient(composite);
toolkit.paintBordersFor(composite);
return composite;
}
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);
}
}
}
/**
* 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);
}
}
}
private void createGitSection(int nColumns, Composite parent) {
final int defaultIndent = 0;
int extraIndent = LayoutUtil.getIndent();
String label = MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_section_scsm;
Key twistieKey = OptionsConfigurationBlock.getLocalKey("JavaEditorCodeMiningPreferencePage_section_sccm"); //$NON-NLS-1$
PreferenceTreeNode<?> section = fFilteredPrefTree.addExpandableComposite(parent, label, nColumns, twistieKey,
null, false);
ExpandableComposite excomposite = getExpandableComposite(twistieKey);
Composite inner = createInnerComposite(excomposite, nColumns, parent.getFont());
// - Show git recent change
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showRevisionRecentChange,
PREF_SHOW_REVISION_RECENT_CHANGE, TRUE_FALSE, defaultIndent, section);
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showRevisionRecentChangeWithAvatar,
PREF_SHOW_REVISION_RECENT_CHANGE_WITH_AVATAR, TRUE_FALSE, extraIndent, section);
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showRevisionRecentChangeWithDate,
PREF_SHOW_REVISION_RECENT_CHANGE_WITH_DATE, TRUE_FALSE, extraIndent, section);
// Show authors
fFilteredPrefTree.addCheckBox(inner,
MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showRevisionAuthors,
PREF_SHOW_REVISION_AUTHORS, TRUE_FALSE, defaultIndent, section);
// - Show git changes
// fFilteredPrefTree.addCheckBox(inner,
// MyPreferencesMessages.JavaEditorCodeMiningConfigurationBlock_showGitChanges_label,
// PREF_SHOW_GIT_CHANGES, enabledDisabled, defaultIndent, section);
}
private Composite createInnerComposite(ExpandableComposite excomposite, int nColumns, Font font) {
Composite inner = new Composite(excomposite, SWT.NONE);
inner.setFont(font);
inner.setLayout(new GridLayout(nColumns, false));
excomposite.setClient(inner);
return inner;
}
private void createCommitComposite(Composite parent) {
this.commitSection = this.toolkit.createSection(parent, ExpandableComposite.SHORT_TITLE_BAR);
this.commitSection.clientVerticalSpacing = 0;
this.commitSection.setText(Messages.AbapGitStaging_commit_section_header);
this.commitSection.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
Composite commitComposite = this.toolkit.createComposite(this.commitSection);
GridLayoutFactory.fillDefaults().numColumns(1).applyTo(commitComposite);
this.commitSection.setClient(commitComposite);
//commit section : warnings and errors composite
createToggleableWarningsComposite(commitComposite);
//commit message text
createCommitMessageComposite(commitComposite);
Composite commitPersonComposite = this.toolkit.createComposite(commitComposite);
this.toolkit.paintBordersFor(commitPersonComposite);
GridDataFactory.fillDefaults().grab(true, false).applyTo(commitPersonComposite);
GridLayoutFactory.swtDefaults().margins(1, 2).numColumns(3).spacing(1, LayoutConstants.getSpacing().y)
.applyTo(commitPersonComposite);
//author
createAuthorComposite(commitPersonComposite);
//committer
createCommitterComposite(commitPersonComposite);
//commit button
this.commitAndPushButton = this.toolkit.createButton(commitComposite, Messages.AbapGitStaging_commit_button, SWT.PUSH);
this.commitAndPushButton.setLayoutData(GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.BEGINNING).create());
SWTUtil.setButtonWidthHint(this.commitAndPushButton);
this.commitAndPushButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
validateInputAndPushChanges();
}
});
}
public Composite createStandardSection ( final Composite parent, final String sectionLabel, final boolean fillVeritcal )
{
final Section section = this.toolkit.createSection ( parent, sectionLabel != null ? ExpandableComposite.TITLE_BAR : ExpandableComposite.NO_TITLE );
if ( sectionLabel != null )
{
section.setText ( sectionLabel );
}
final Composite client = createStandardComposite ( section );
section.setClient ( client );
client.setLayout ( new GridLayout ( 3, false ) );
section.setLayoutData ( new GridData ( GridData.FILL, GridData.BEGINNING, true, fillVeritcal ) );
return client;
}
public void createListSection ( final ScrolledForm form, final ConfigurationEditorInput input, final String attribute, final String label, final String delimiter, final String pattern )
{
final IObservableList list = StringSplitListObservable.observeString ( Observables.observeMapEntry ( input.getDataMap (), attribute, String.class ), delimiter, pattern );
// section
final Section section = this.toolkit.createSection ( form.getBody (), ExpandableComposite.TITLE_BAR );
section.setText ( label );
final Composite client = this.toolkit.createComposite ( section, SWT.NONE );
section.setClient ( client );
this.toolkit.paintBordersFor ( client );
client.setLayout ( new GridLayout ( 1, true ) );
final GridData gd = new GridData ( GridData.FILL_BOTH );
gd.horizontalSpan = 2;
section.setLayoutData ( gd );
// fields
final ListViewer viewer = new ListViewer ( client );
viewer.setContentProvider ( new ObservableListContentProvider () );
viewer.setInput ( list );
viewer.getControl ().setLayoutData ( new GridData ( GridData.FILL_BOTH ) );
viewer.setSorter ( new ViewerSorter () );
}
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;
}
protected Composite createSection(String label, Composite composite, int nColumns) {
ExpandableComposite excomposite = createStyleSection(composite, label, nColumns);
Composite inner = new Composite(excomposite, SWT.NONE);
inner.setFont(composite.getFont());
inner.setLayout(new GridLayout(nColumns, false));
excomposite.setClient(inner);
return inner;
}
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)));
}
}
}
protected ExpandableComposite getParentExpandableComposite(Control control) {
Control parent = control.getParent();
while (!(parent instanceof ExpandableComposite) && parent != null) {
parent = parent.getParent();
}
if (parent instanceof ExpandableComposite) {
return (ExpandableComposite) parent;
}
return null;
}
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)));
}
}
}
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
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;
}
@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();
}
}
});
}
}