下面列出了org.eclipse.ui.forms.widgets.Section#setExpanded ( ) 实例代码,或者点击链接到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);
}
@Override
public Control doCreateControl(final Composite parent, final EMFDataBindingContext context) {
final Composite mainComposite = new Composite(parent, SWT.NONE) ;
mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 0).create());
final Composite pageComposite = new Composite(mainComposite, SWT.NONE);
pageComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(3, 10).create());
pageComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
final Page page = getPage();
final PageComponentSwitch componentSwitch = getPageComponentSwitch(context, pageComposite);
componentSwitch.setIsPageFlowContext(isPageFlowContext());
for(final Component component : page.getWidget()){
componentSwitch.doSwitch(component) ;
}
for(final Section section : componentSwitch.getSectionsToExpand()){
section.setExpanded(true) ;
}
return mainComposite;
}
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));
}
void render(Composite body, FormToolkit toolkit) {
log.trace("render flow-use-section for flow {}", flow);
FlowDao dao = new FlowDao(database);
Set<Long> recipients = dao.getWhereInput(flow.id);
Set<Long> providers = dao.getWhereOutput(flow.id);
if (recipients.isEmpty() && providers.isEmpty())
return;
Section section = UI.section(body, toolkit, M.UsedInProcesses);
section.setExpanded(false);
parent = UI.sectionClient(section, toolkit);
this.toolkit = toolkit;
App.runInUI("Render usage links", () -> {
renderLinks(M.ConsumedBy, recipients, Icon.INPUT.get());
renderLinks(M.ProducedBy, providers, Icon.OUTPUT.get());
});
}
void create(FormToolkit tk, Composite body) {
Section section = UI.section(body, tk, "Pinned contributions");
section.setExpanded(false);
Composite comp = UI.sectionClient(section, tk);
UI.gridLayout(comp, 1);
Composite filterComp = tk.createComposite(comp);
UI.gridLayout(filterComp, 2, 10, 0);
UI.gridData(filterComp, true, false);
filter = UI.formText(filterComp, tk, M.Filter);
filter.addModifyListener(e -> table.setInput(selectInput()));
table = Tables.createViewer(comp,
"Pin / Unpin",
"Process / Sub-System",
M.Product,
"Display in chart");
Tables.bindColumnWidths(table, 0.15, 0.35, 0.35, 0.15);
Label label = new Label();
table.setLabelProvider(label);
Viewers.sortByLabels(table, label, 0, 1);
table.setInput(selectInput());
bindActions();
}
@SuppressWarnings("unchecked") // generic casting
protected void compensateForExpandableCompositesPoorDesign(final Section section, final boolean expand) {
section.setExpanded(expand);
if (section.getData(FormHelper.SECTION_IS_NOT_SPACE_GRABBING) == null) {
final GridData gd = (GridData) section.getLayoutData();
gd.grabExcessVerticalSpace = expand;
section.setLayoutData(gd);
}
final Object o = section.getData(SECTION_EXPANSION_LISTENER);
if (o != null) {
((Consumer<Boolean>)o).accept(Boolean.valueOf(expand));
}
}
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);
}
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;
}
public ProjectStatusSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
section.setText(Messages.AppOverviewEditorProjectStatusSection);
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);
autoBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorAutoBuildEntry);
injectMetricsEntry = new StringEntry(composite, Messages.AppOverviewEditorInjectMetricsEntry);
appStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorAppStatusEntry);
buildStatusEntry = new StringEntry(composite, Messages.AppOverviewEditorBuildStatusEntry);
lastImageBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastImageBuildEntry);
lastBuildEntry = new StringEntry(composite, Messages.AppOverviewEditorLastBuildEntry);
Label label = new Label(composite, SWT.NONE);
label.setFont(boldFont);
label.setText(Messages.AppOverviewEditorProjectLogs);
label.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, false, false));
projectLogs = new Link(composite, SWT.NONE);
projectLogs.setText("");
projectLogs.setVisible(false);
GridData data = new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false);
data.horizontalIndent = 2;
data.exclude = true;
projectLogs.setLayoutData(data);
IDEUtil.paintBackgroundToMatch(projectLogs, composite);
projectLogs.addListener(SWT.Selection, event -> {
CodewindEclipseApplication app = (CodewindEclipseApplication) getApp(getConn());
if (app == null) {
Logger.logError("A log link was selected but could not find the application for the " + connectionId //$NON-NLS-1$
+ " connection with name: " + projectId); //$NON-NLS-1$
return;
}
Optional<ProjectLogInfo> logInfo = app.getLogInfos().stream().filter(info -> info.logName.equals(event.text)).findFirst();
if (logInfo.isPresent()) {
try {
SocketConsole console = app.getConsole(logInfo.get());
if (console == null) {
console = CodewindConsoleFactory.createLogFileConsole(app, logInfo.get());
app.addConsole(console);
}
ConsolePlugin.getDefault().getConsoleManager().showConsoleView(console);
} catch (Exception e) {
Logger.logError("An error occurred trying to open the " + logInfo.get().logName //$NON-NLS-1$
+ "log file for application: " + projectId, e); //$NON-NLS-1$
MessageDialog.openError(parent.getShell(), Messages.AppOverviewEditorOpenLogErrorTitle,
NLS.bind(Messages.AppOverviewEditorOpenLogErrorMsg, new String[] {logInfo.get().logName, app.name, e.getMessage()}));
}
} else {
Logger.logError("The " + event.text + " was selected but the associated log info could not be found for the " + projectId + " project."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
});
noProjectLogs = new Text(composite, SWT.READ_ONLY);
noProjectLogs.setText(Messages.AppOverviewEditorNoProjectLogs);
noProjectLogs.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
noProjectLogs.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
IDEUtil.paintBackgroundToMatch(noProjectLogs, composite);
}
public ProjectLinkSection(Composite parent, FormToolkit toolkit, int hSpan, int vSpan) {
Section section = toolkit.createSection(parent, ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR);
section.setText(Messages.AppOverviewEditorProjectLinksSection);
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 = 10;
layout.horizontalSpacing = 10;
composite.setLayout(layout);
composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL));
toolkit.paintBordersFor(composite);
section.setClient(composite);
// Link description and manage link
toLinkDescriptionText = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
toLinkDescriptionText.setText(Messages.AppOverviewEditorProjectLinksNoLinks);
toLinkDescriptionText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
toLinkDescriptionText.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false));
IDEUtil.paintBackgroundToMatch(toLinkDescriptionText, composite);
Hyperlink manageLink = toolkit.createHyperlink(composite, Messages.AppOverviewEditorProjectLinksManageLinks, SWT.WRAP);
GridData data = new GridData(GridData.END, GridData.BEGINNING, false, false);
manageLink.setLayoutData(data);
manageLink.addHyperlinkListener(new HyperlinkAdapter() {
@Override
public void linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent e) {
final CodewindConnection conn = getConn();
final CodewindApplication app = getApp(conn);
ManageLinksAction.openManageLinksDialog(app);
}
});
// Link table
toLinkTable = new LinkTable(composite, toolkit, Messages.LinkMgmtProjectColumn);
// From link description
fromLinkDescriptionText = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.READ_ONLY);
fromLinkDescriptionText.setText(Messages.AppOverviewEditorProjectLinksNoFromLinks);
fromLinkDescriptionText.setData(FormToolkit.KEY_DRAW_BORDER, Boolean.FALSE);
fromLinkDescriptionText.setLayoutData(new GridData(GridData.BEGINNING, GridData.BEGINNING, true, false, 2, 1));
IDEUtil.paintBackgroundToMatch(fromLinkDescriptionText, composite);
// From link table
fromLinkTable = new LinkTable(composite, toolkit, Messages.AppOverviewEditorProjectLinksSourceProject);
// Initialize
toLinkTable.tableComp.setVisible(false);
((GridData) toLinkTable.tableComp.getLayoutData()).exclude = true;
fromLinkTable.tableComp.setVisible(false);
((GridData) fromLinkTable.tableComp.getLayoutData()).exclude = true;
}
/**
* @wbp.parser.entryPoint
*/
@Override
public void buildUI() {
Section generalSection = formToolkit.createSection(composite,
Section.TWISTIE | Section.TITLE_BAR);
GridData gd_generalSection = new GridData(SWT.FILL, SWT.FILL, true,
false, 1, 1);
gd_generalSection.heightHint = 240;
generalSection.setLayoutData(gd_generalSection);
formToolkit.paintBordersFor(generalSection);
generalSection.setText(Messages.BASICATTRIBUTE);
generalSection.setExpanded(true);
Composite generalComposite = new Composite(generalSection, SWT.NONE);
formToolkit.adapt(generalComposite);
formToolkit.paintBordersFor(generalComposite);
generalSection.setClient(generalComposite);
generalComposite.setLayout(new GridLayout(4, false));
FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault()
.getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
String decorationDescription = Messages.NULLERROR;
Image decorationImage = fieldDecoration.getImage();
Label appNameLabel = formToolkit.createLabel(generalComposite, Messages.APPNAME, SWT.NONE);
appNameLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
appNameText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
appNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
appNameDecoration = createTextErrorDecoration(appNameText, decorationDescription, decorationImage);
Label lblNewLabel_1 = formToolkit.createLabel(generalComposite, Messages.AUTHERNAME, SWT.NONE);
lblNewLabel_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
authorNameText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
authorNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
authorNameDecoration = createTextErrorDecoration(authorNameText, decorationDescription, decorationImage);
Label lblNewLabel_2 = formToolkit.createLabel(generalComposite,Messages.AUTHEREMAIL, SWT.NONE);
lblNewLabel_2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
authorEmailText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
authorEmailText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
authorEmailDecoration = createTextErrorDecoration(authorEmailText, decorationDescription, decorationImage);
Label lblNewLabel_3 = formToolkit.createLabel(generalComposite,Messages.AUTHORIZEDCONNECTION, SWT.NONE);
lblNewLabel_3.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
authorHrefText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
authorHrefText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
authorHrefDecoration = createTextErrorDecoration(authorHrefText, decorationDescription, decorationImage);
Label lblNewLabel_4 = formToolkit.createLabel(generalComposite,Messages.STARTPAGE, SWT.NONE);
lblNewLabel_4.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1));
ContentSrcText = formToolkit.createText(generalComposite, StringUtils.EMPTY_STRING, SWT.NONE);
ContentSrcText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 1, 1));
ContentSrcDecoration = createTextErrorDecoration(ContentSrcText, decorationDescription, decorationImage);
Label lblNewLabel_6 = new Label(generalComposite, SWT.NONE);
lblNewLabel_6.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
formToolkit.adapt(lblNewLabel_6, true, true);
lblNewLabel_6.setText("\u63CF\u8FF0");
descriptionText = new Text(generalComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.CANCEL | SWT.MULTI);
GridData gd_descriptionText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_descriptionText.heightHint = 49;
descriptionText.setLayoutData(gd_descriptionText);
formToolkit.adapt(descriptionText, true, true);
}