Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 82523 Details for
Bug 208967
Manifest editor can't handle a large number of friends
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch for ExportPackageObject to support formatting of x-friends
patch-208967-exportPackageObject-friendsFormatting.txt (text/plain), 6.61 KB, created by
Les Jones
on 2007-11-09 04:26:44 EST
(
hide
)
Description:
Patch for ExportPackageObject to support formatting of x-friends
Filename:
MIME Type:
Creator:
Les Jones
Created:
2007-11-09 04:26:44 EST
Size:
6.61 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.pde.core >Index: text/org/eclipse/pde/internal/core/text/bundle/ExportPackageObject.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.pde.core/text/org/eclipse/pde/internal/core/text/bundle/ExportPackageObject.java,v >retrieving revision 1.9 >diff -u -r1.9 ExportPackageObject.java >--- text/org/eclipse/pde/internal/core/text/bundle/ExportPackageObject.java 8 Jun 2007 16:06:49 -0000 1.9 >+++ text/org/eclipse/pde/internal/core/text/bundle/ExportPackageObject.java 9 Nov 2007 09:16:56 -0000 >@@ -13,6 +13,7 @@ > import java.io.PrintWriter; > import java.util.ArrayList; > import java.util.Iterator; >+import java.util.List; > import java.util.StringTokenizer; > import java.util.TreeMap; > >@@ -27,6 +28,10 @@ > private static final String INTERNAL = "x-internal"; //$NON-NLS-1$ > private static final String FRIENDS = "x-friends"; //$NON-NLS-1$ > >+ private static final int NEWLINE_LIMIT = 3; >+ private static final int NEWLINE_LIMIT_BOTH = 1; >+ >+ > private static final long serialVersionUID = 1L; > > private TreeMap fFriends = new TreeMap(); >@@ -137,56 +142,156 @@ > } > > protected void appendValuesToBuffer(StringBuffer sb, TreeMap table) { >- if (table == null) >+ >+ if (table == null) { > return; >+ } >+ > Object usesValue = null; > // remove the Uses directive, we will make sure to put it at the end >- if (table.containsKey(Constants.USES_DIRECTIVE)) >+ if (table.containsKey(Constants.USES_DIRECTIVE)) { > usesValue = table.remove(Constants.USES_DIRECTIVE); >+ } >+ >+ Object friendsValue = null; >+ // remove the friends directive, ensure it's appropriately formatted >+ if (table.containsKey(FRIENDS)) { >+ friendsValue = table.remove(FRIENDS); >+ } >+ > super.appendValuesToBuffer(sb, table); >+ >+ // If only one of uses and x-friends is specified, then the directives >+ // have new lines at commas if there are more than 3 of them; if they're >+ // both specified then they insert new lines for more than 1. >+ int newLineLimit = NEWLINE_LIMIT; >+ if (friendsValue != null && usesValue != null) { >+ newLineLimit = NEWLINE_LIMIT_BOTH; >+ } >+ >+ if( friendsValue != null ) { >+ table.put(FRIENDS, friendsValue); >+ formatDirective(FRIENDS, sb, friendsValue, newLineLimit); >+ } >+ >+ // uses goes last > if (usesValue != null) { > table.put(Constants.USES_DIRECTIVE, usesValue); >- formatUsesDirective(sb, usesValue); >+ formatDirective(Constants.USES_DIRECTIVE, sb, usesValue, newLineLimit); > } > } > >- private void formatUsesDirective(StringBuffer sb, Object usesValue) { >- StringTokenizer tokenizer = null; >- if (usesValue instanceof String) >- tokenizer = new StringTokenizer((String)usesValue, ","); //$NON-NLS-1$ >- boolean newLine = (tokenizer != null) ? tokenizer.countTokens() > 3 : >- ((ArrayList)usesValue).size() > 3; >- String eol = getHeader().getLineLimiter(); >+ /** >+ * Format the specified directive of the Export-Package manifest header. >+ * >+ * @param directiveName >+ * The name of the directive, e.g. x-friends or uses >+ * @param sb >+ * buffer to append the directives >+ * @param usesValue >+ * The value of the uses directive, expected to be a String or a >+ * List. >+ * @param newLineLimit >+ * The number of items, above which, a new line would be needed >+ * between all values. >+ */ >+ private void formatDirective(String directiveName, StringBuffer sb, >+ Object usesValue, final int newLineLimit) { >+ >+ final String INDENT2 = " "; //$NON-NLS-1$ >+ final String INDENT3 = " "; //$NON-NLS-1$ >+ >+ StringTokenizer tokenizer = null; >+ >+ boolean newLine = false; >+ >+ if (usesValue instanceof String) { >+ >+ // break the string down at commas >+ >+ tokenizer = new StringTokenizer((String) usesValue, ","); //$NON-NLS-1$ >+ >+ if (tokenizer.countTokens() > newLineLimit) { >+ newLine = true; >+ } >+ >+ } else if (usesValue instanceof List) { >+ >+ List usesList = (List) usesValue; >+ >+ if (usesList.size() > newLineLimit) { >+ newLine = true; >+ } >+ >+ } else { >+ // wrong type for usesValue! - in this situation the old >+ // formatUsesDirective() would throw a ClassCastException. >+ // So for consistency! :-( >+ Object foo = (ArrayList) usesValue; >+ // To remove 'non-usage' error :-( >+ foo.getClass(); >+ >+ // return should be unreachable >+ return; >+ } >+ >+ final String EOL = getHeader().getLineLimiter(); >+ > sb.append(';'); >- if (newLine) >- sb.append(eol).append(" "); //$NON-NLS-1$ >- sb.append(Constants.USES_DIRECTIVE); >+ >+ if (newLine) { >+ sb.append(EOL).append(INDENT2); >+ } >+ >+ sb.append(directiveName); > sb.append(":=\""); //$NON-NLS-1$ >- if (tokenizer != null) >+ >+ if (tokenizer != null) { >+ >+ // For a String based value, output each value (comma separated), >+ // potentially adding a new line between them >+ > while (tokenizer.hasMoreTokens()) { > sb.append(tokenizer.nextToken()); > if (tokenizer.hasMoreTokens()) { > sb.append(','); >- if (newLine) >- sb.append(eol).append(" "); //$NON-NLS-1$ >+ if (newLine) { >+ sb.append(EOL).append(INDENT3); >+ } > } > } >- else { >- ArrayList list = ((ArrayList)usesValue); >- for (int i = 0; i < list.size(); i++) { >- if (i != 0) { >+ } else { >+ List usesList = (List) usesValue; >+ >+ // For each item in the collection, output each value (comma >+ // separated), potentially adding a new line between them >+ >+ boolean firstTime = true; >+ for (Iterator iterator = usesList.iterator(); iterator.hasNext();) { >+ >+ if (!firstTime) { >+ > sb.append(','); >- if (newLine) >- sb.append(eol).append(" "); //$NON-NLS-1$ >+ if (newLine) { >+ sb.append(EOL).append(INDENT3); >+ } >+ >+ } else { >+ // No comma first time through >+ firstTime = false; > } >- sb.append(list.get(i)); >+ >+ sb.append(iterator.next()); > } > } > sb.append("\""); //$NON-NLS-1$ >- } >- >- /* (non-Javadoc) >- * @see org.eclipse.pde.internal.core.bundle.BundleObject#write(java.lang.String, java.io.PrintWriter) >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.pde.internal.core.bundle.BundleObject#write(java.lang.String, >+ * java.io.PrintWriter) > */ > public void write(String indent, PrintWriter writer) { > // Used for text transfers for copy, cut, paste operations
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 208967
: 82523 |
82524