diff options
Diffstat (limited to 'org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/search/BugzillaLabelProvider.java')
-rw-r--r-- | org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/search/BugzillaLabelProvider.java | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/search/BugzillaLabelProvider.java b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/search/BugzillaLabelProvider.java new file mode 100644 index 000000000..f117ade15 --- /dev/null +++ b/org.eclipse.mylyn.bugzilla.core/src/org/eclipse/mylyn/bugzilla/search/BugzillaLabelProvider.java @@ -0,0 +1,94 @@ +/******************************************************************************* + * Copyright (c) 2003 - 2005 University Of British Columbia and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * University Of British Columbia - initial API and implementation + *******************************************************************************/ +package org.eclipse.mylar.bugzilla.search; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.mylar.bugzilla.IBugzillaConstants; + +/** + * Label provider for Bugzilla search items. + */ +public class BugzillaLabelProvider extends LabelProvider +{ + /** A list of the default severity labels */ + private static final String [] severityLabel = {"blocker", "critical", "major", "normal", "minor", "trivial", "enhancement"}; + + /** A list of the default priority labels */ + private static final String [] priorityLabel = {"P1", "P2", "P3", "P4", "P5", "--"}; + + /** A list of the default state labels */ + private static final String [] stateLabel = {"Unconfirmed", "New", "Assigned", "Reopened", "Resolved", "Verified", "Closed"}; + + /** A list of the default result labels */ + private static final String [] resultLabel = {"", "fixed", "invalid", "wont fix", "later", "remind", "duplicate", "works for me"}; + + /** + * Returns the text for the label of the given element. + * + * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) + */ + @Override + public String getText(Object element) { + if (element instanceof IMarker) { + + try { + IMarker marker = (IMarker) element; + + // get the severity of the bug + String severity = severityLabel[((Integer) marker + .getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_SEVERITY)) + .intValue()]; + + // get the priority of the bug + String priority = priorityLabel[((Integer) marker + .getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_PRIORITY)) + .intValue()]; + + // get the state of the bug + String state = stateLabel[((Integer) marker + .getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_STATE)) + .intValue()]; + + // get the resolution of the bug + String result = resultLabel[((Integer) marker + .getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_RESULT)) + .intValue()]; + + // return a string containing the information about the bug to + // be displayed + // in the searh window + return "Bug " + + marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_ID) + + " (" + + severity + + " - " + + priority + + " - " + + state + + (result.length() > 0 ? " " + result : "") + + ") " + + " - " + + marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_DESC) + + " (" + + marker.getAttribute(IBugzillaConstants.HIT_MARKER_ATTR_OWNER) + + ") "; + } + catch (CoreException ignored) { + // ignore if there is a problem + } + } + + // return an empty string if there is a problem + return ""; + } +} |