01: package org.eclipse.ui.internal.provisional.views.markers;
02:
03: /*******************************************************************************
04: * Copyright (c) 2007 IBM Corporation and others.
05: * All rights reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * IBM Corporation - initial API and implementation
12: ******************************************************************************/
13:
14: import org.eclipse.core.resources.IMarker;
15: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerField;
16: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerItem;
17: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerSupportConstants;
18:
19: import com.ibm.icu.text.CollationKey;
20:
21: /**
22: * MarkerDescriptionField is the field for showing the description of a marker.
23: * @since 3.4
24: *
25: */
26: public class MarkerDescriptionField extends MarkerField {
27:
28: /**
29: * Create a new instance of the receiver.
30: */
31: public MarkerDescriptionField() {
32: super ();
33: }
34:
35: /*
36: * (non-Javadoc)
37: *
38: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#compare(org.eclipse.ui.internal.provisional.views.markers.MarkerItem,
39: * org.eclipse.ui.internal.provisional.views.markers.MarkerItem)
40: */
41: public int compare(MarkerItem item1, MarkerItem item2) {
42: return getDescriptionKey(item1).compareTo(
43: getDescriptionKey(item2));
44: }
45:
46: /*
47: * (non-Javadoc)
48: *
49: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getColumnWeight()
50: */
51: public float getColumnWeight() {
52: return 4;
53: }
54:
55: /**
56: * Return the collation key for the description.
57: *
58: * @param element
59: * @return
60: */
61: private CollationKey getDescriptionKey(Object element) {
62: if (element instanceof MarkerEntry)
63: return ((MarkerItem) element).getCollationKey(
64: IMarker.MESSAGE,
65: MarkerSupportConstants.EMPTY_STRING);
66: return MarkerSupportInternalUtilities.EMPTY_COLLATION_KEY;
67: }
68:
69: /*
70: * (non-Javadoc)
71: *
72: * @see org.eclipse.ui.internal.provisional.views.markers.MarkerField#getValue(org.eclipse.ui.internal.provisional.views.markers.MarkerItem)
73: */
74: public String getValue(MarkerItem item) {
75: return item.getAttributeValue(IMarker.MESSAGE,
76: MarkerSupportConstants.EMPTY_STRING);
77: }
78:
79: }
|