Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2008-09-09 20:13:40 +0000
committerrelves2008-09-09 20:13:40 +0000
commit3983cf2e7cb769619d03de973bf537cc53e6e554 (patch)
treea833e05a225f71fa9f2beaeb87b4f5f63e60f076
parentb421a075d10f054487e8f02380e500ccf776091d (diff)
downloadorg.eclipse.mylyn.tasks-3983cf2e7cb769619d03de973bf537cc53e6e554.tar.gz
org.eclipse.mylyn.tasks-3983cf2e7cb769619d03de973bf537cc53e6e554.tar.xz
org.eclipse.mylyn.tasks-3983cf2e7cb769619d03de973bf537cc53e6e554.zip
ASSIGNED - bug 197539: [patch] comments in bugzilla 2.18 don't wrap
https://bugs.eclipse.org/bugs/show_bug.cgi?id=197539
-rw-r--r--org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java60
-rw-r--r--org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java4
2 files changed, 62 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
index 41c3df4e4..fa0975b07 100644
--- a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
+++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/internal/bugzilla/core/BugzillaClient.java
@@ -102,7 +102,7 @@ public class BugzillaClient {
private static final String PROCESS_BUG_CGI = "/process_bug.cgi";
- public static final int WRAP_LENGTH = 90;
+ public static final int WRAP_LENGTH = 80;
private static final String VAL_PROCESS_BUG = "process_bug";
@@ -920,7 +920,19 @@ public class BugzillaClient {
TaskAttribute descAttribute = taskData.getRoot().getMappedAttribute(TaskAttribute.DESCRIPTION);
if (descAttribute != null && !descAttribute.getValue().equals("")) {
- fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, descAttribute.getValue()));
+ String bugzillaVersion = null;
+ if (repositoryConfiguration != null) {
+ bugzillaVersion = repositoryConfiguration.getInstallVersion();
+ } else {
+ bugzillaVersion = "2.18";
+ }
+
+ if (bugzillaVersion.startsWith("2.18")) {
+ fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, formatTextToLineWrap(descAttribute.getValue(),
+ true)));
+ } else {
+ fields.put(KEY_COMMENT, new NameValuePair(KEY_COMMENT, descAttribute.getValue()));
+ }
}
return fields.values().toArray(new NameValuePair[fields.size()]);
@@ -967,6 +979,18 @@ public class BugzillaClient {
continue;
}
+ if (a.getId().equals(BugzillaAttribute.NEW_COMMENT.getKey())) {
+ String bugzillaVersion = null;
+ if (repositoryConfiguration != null) {
+ bugzillaVersion = repositoryConfiguration.getInstallVersion();
+ } else {
+ bugzillaVersion = "2.18";
+ }
+ if (bugzillaVersion.startsWith("2.18")) {
+ a.setValue(formatTextToLineWrap(a.getValue(), true));
+ }
+ }
+
if (a.getId().equals(BugzillaAttribute.GROUP.getKey()) && a.getValue().length() > 0) {
groupSecurityEnabled = true;
}
@@ -1485,4 +1509,36 @@ public class BugzillaClient {
((MultiThreadedHttpConnectionManager) httpClient.getHttpConnectionManager()).shutdown();
}
+ /**
+ * Break text up into lines so that it is displayed properly in bugzilla
+ */
+ public static String formatTextToLineWrap(String origText, boolean hardWrap) {
+ if (!hardWrap) {
+ return origText;
+ } else {
+ String newText = "";
+
+ while (!origText.equals("")) {
+ int newLine = origText.indexOf('\n');
+ if (newLine == -1) {
+ if (origText.length() > WRAP_LENGTH) {
+ int spaceIndex = origText.lastIndexOf(" ", WRAP_LENGTH);
+ if (spaceIndex == -1) {
+ spaceIndex = WRAP_LENGTH;
+ }
+ newText = newText + origText.substring(0, spaceIndex) + "\n";
+ origText = origText.substring(spaceIndex + 1, origText.length());
+ } else {
+ newText = newText + origText;
+ origText = "";
+ }
+ } else {
+ newText = newText + origText.substring(0, newLine + 1);
+ origText = origText.substring(newLine + 1, origText.length());
+ }
+ }
+ return newText;
+ }
+ }
+
}
diff --git a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
index 97c4cc721..3908c10b3 100644
--- a/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
+++ b/org.eclipse.mylyn.bugzilla.ui/src/org/eclipse/mylyn/internal/bugzilla/ui/BugzillaUiPlugin.java
@@ -13,6 +13,7 @@ import java.util.List;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.internal.bugzilla.core.BugzillaClient;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaCorePlugin;
import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryConnector;
import org.eclipse.mylyn.internal.bugzilla.core.IBugzillaConstants;
@@ -192,7 +193,10 @@ public class BugzillaUiPlugin extends AbstractUIPlugin {
/**
* Break text up into lines so that it is displayed properly in bugzilla
+ *
+ * @deprecated use {@link BugzillaClient#formatTextToLineWrap(String, boolean)} instead
*/
+ @Deprecated
public static String formatTextToLineWrap(String origText, boolean hardWrap) {
// BugzillaServerVersion bugzillaServerVersion =
// IBugzillaConstants.BugzillaServerVersion.fromString(repository

Back to the top