下面列出了怎么用org.eclipse.ui.forms.SectionPart的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* enables a section by given id. More precisely, this
* means setting the enablement state of any child of the
* section that is a {@link Composite} but not a {@link Section}
* to enabled.
*/
private void enableSection(String id, boolean enabled)
{
SectionPart part = sectionParts.get(id);
if (part == null)
{
throw new IllegalArgumentException("No section for id [" + id + "]");
}
Section section = part.getSection();
Control[] children = section.getChildren();
for (int i = 0; i < children.length; i++)
{
if (children[i] instanceof Composite)
{
enableSectionComposite((Composite) children[i], enabled);
}
}
}
/**
* Adds a section to the manager
* @param section
* @param id
* @param pageId
*/
public void bindSection(SectionPart sectionPart, String id, String pageId)
{
// store the section
sectionParts.put(id, sectionPart);
// store the page id
pageForSection.put(id, pageId);
Vector<String> sectionIds = sectionsForPage.get(pageId);
if (sectionIds == null)
{
sectionIds = new Vector<String>();
sectionsForPage.put(pageId, sectionIds);
}
sectionIds.add(id);
}
/**
* Bind an attribute name <code>attributeName</code> to the viewer <code>attributeViewer</code> location in the section part <code>sectionPart</code>
* This method should be called after the section is bound to the section id and page using {@link DataBindingManager#bindSection(SectionPart, String, String)} method
* @param attributeName
* @param attributeViewer
* @param sectionPart
*/
public void bindAttribute(String attributeName, Object attributeViewer, SectionPart sectionPart)
{
// bind the viewer
viewerForAttribute.put(attributeName, attributeViewer);
// bind the section id
Enumeration<String> enumeration = sectionParts.keys();
while (enumeration.hasMoreElements())
{
String sectionId = enumeration.nextElement();
SectionPart registeredPart = sectionParts.get(sectionId);
if (registeredPart.equals(sectionPart))
{
sectionForAttribute.put(attributeName, sectionId);
break;
}
}
}
/**
* expands a section by given section id
*/
public void expandSection(String id)
{
SectionPart part = sectionParts.get(id);
if (part == null)
{
throw new IllegalArgumentException("No section for id");
}
if (!part.getSection().isExpanded())
{
part.getSection().setExpanded(true);
}
}
/**
* Finish aggregate change action.
*/
protected void finishAggregateChangeAction() {
editor.setFileDirty();
editor.getTypePage().markStale();
editor.getIndexesPage().markStale();
editor.getCapabilityPage().markStale();
SectionPart s = editor.getParameterPage().getParameterDelegatesSection();
if (null != s)
s.markStale();
editor.getResourcesPage().markStale();
}
/**
* Retrieves the section by id
* @param sectionId
* @return the section part, or <code>null</code> if not found
*/
public SectionPart getSection(String sectionId)
{
return (SectionPart) sectionParts.get(sectionId);
}