### Eclipse Workspace Patch 1.0 #P org.eclipse.pde.core Index: src/org/eclipse/pde/internal/core/schema/DocumentSection.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/DocumentSection.java,v retrieving revision 1.11 diff -u -r1.11 DocumentSection.java --- src/org/eclipse/pde/internal/core/schema/DocumentSection.java 3 Apr 2006 19:48:17 -0000 1.11 +++ src/org/eclipse/pde/internal/core/schema/DocumentSection.java 10 Jul 2007 04:13:08 -0000 @@ -15,9 +15,18 @@ import org.eclipse.pde.internal.core.ischema.IDocumentSection; import org.eclipse.pde.internal.core.ischema.ISchemaObject; -public class DocumentSection extends SchemaObject implements IDocumentSection { +public class DocumentSection extends SchemaObject implements IDocumentSection, Comparable { private static final long serialVersionUID = 1L; + + public static final String [] DOC_SECTIONS = { + IDocumentSection.SINCE, + IDocumentSection.EXAMPLES, + IDocumentSection.API_INFO, + IDocumentSection.IMPLEMENTATION, + IDocumentSection.COPYRIGHT + }; + private String sectionId; public DocumentSection(ISchemaObject parent, String sectionId, String name) { @@ -30,6 +39,9 @@ } public void write(String indent, PrintWriter writer) { + String description = getWritableDescription(); + if (description == null || description.equals("")) + return; String indent2 = indent + Schema.INDENT; String indent3 = indent2 + Schema.INDENT; writer.println(indent + ""); //$NON-NLS-1$ @@ -37,8 +49,38 @@ writer.println(indent3 + ""); //$NON-NLS-1$ //$NON-NLS-2$ writer.println(indent2 + ""); //$NON-NLS-1$ writer.println(indent2 + ""); //$NON-NLS-1$ - writer.println(indent3 + getWritableDescription()); + writer.println(indent3 + description); writer.println(indent2 + ""); //$NON-NLS-1$ writer.println(indent + ""); //$NON-NLS-1$ } + + public boolean equals(Object obj) { + if (obj instanceof DocumentSection && ((DocumentSection)obj).getSectionId().equals(sectionId)) + return true; + return false; + } + + public int compareTo(Object arg0) { + if (arg0 instanceof DocumentSection) { + int otherIndex = getIndex(((DocumentSection)arg0).getSectionId()); + int thisIndex = getIndex(sectionId); + if (otherIndex == thisIndex) + return 0; + else if (otherIndex == -1) + return -1; + else + return thisIndex - otherIndex; + } + return -1; + } + + private int getIndex (String sectionId) { + if (sectionId == null) + return -1; + for (int i = 0; i < DOC_SECTIONS.length; i++) { + if (DOC_SECTIONS[i].equals(sectionId)) + return i; + } + return -1; + } } Index: src/org/eclipse/pde/internal/core/schema/Schema.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/schema/Schema.java,v retrieving revision 1.65 diff -u -r1.65 Schema.java --- src/org/eclipse/pde/internal/core/schema/Schema.java 8 Jun 2007 16:06:50 -0000 1.65 +++ src/org/eclipse/pde/internal/core/schema/Schema.java 10 Jul 2007 04:13:08 -0000 @@ -15,6 +15,7 @@ import java.io.InputStream; import java.io.PrintWriter; import java.net.URL; +import java.util.Collections; import java.util.Iterator; import java.util.Locale; import java.util.Vector; @@ -49,7 +50,7 @@ import org.xml.sax.SAXException; public class Schema extends PlatformObject implements ISchema { - + private URL fURL; private Vector fListeners = new Vector(); @@ -101,6 +102,7 @@ fDocSections.addElement(docSection); fireModelChanged(new ModelChangedEvent(this, IModelChangedEvent.INSERT, new Object[] { docSection }, null)); + } public void addElement(ISchemaElement element) { @@ -927,11 +929,22 @@ } } } + addOmittedDocumentSections(); fLoaded = true; if (fReferences.size() > 0) resolveReferences(fReferences); fReferences = null; } + + private void addOmittedDocumentSections() { + for (int i = 0; i < DocumentSection.DOC_SECTIONS.length; i++) { + DocumentSection section = new DocumentSection(this, DocumentSection.DOC_SECTIONS[i], null); + if (!fDocSections.contains(section)) { + addDocumentSection(section); + } + } + Collections.sort(fDocSections); + } public void updateReferencesFor(ISchemaElement element) { updateReferencesFor(element, ISchema.REFRESH_RENAME);