001: /*******************************************************************************
002: * Copyright (c) 2007 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: ******************************************************************************/package org.eclipse.ui.internal.provisional.views.markers;
011:
012: import java.net.URL;
013:
014: import org.eclipse.core.resources.IMarker;
015: import org.eclipse.core.resources.IResource;
016: import org.eclipse.jface.resource.ImageDescriptor;
017: import org.eclipse.jface.resource.JFaceResources;
018: import org.eclipse.swt.graphics.Image;
019: import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
020: import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
021: import org.eclipse.ui.internal.provisional.views.markers.api.FilterConfigurationArea;
022: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerFieldFilter;
023: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerItem;
024: import org.eclipse.ui.internal.provisional.views.markers.api.MarkerSupportConstants;
025: import org.eclipse.ui.internal.util.BundleUtility;
026:
027: import com.ibm.icu.text.CollationKey;
028: import com.ibm.icu.text.Collator;
029:
030: /**
031: * MarkerSupportUtilities is the class that maintains constants and functionality used
032: * by multiple classes.
033: *
034: * @since 3.4
035: *
036: */
037: class MarkerSupportInternalUtilities {
038:
039: static final String ATTRIBUTE_CLASS = "class"; //$NON-NLS-1$
040: static final CollationKey EMPTY_COLLATION_KEY = Collator
041: .getInstance().getCollationKey(
042: MarkerSupportConstants.EMPTY_STRING);
043: static final IMarker[] EMPTY_MARKER_ARRAY = new IMarker[0];
044:
045: static final MarkerItem[] EMPTY_MARKER_ITEM_ARRAY = new MarkerItem[0];
046: static final IResource[] EMPTY_RESOURCE_ARRAY = new IResource[0];
047: static final Object CONTAINS_MODIFIER_TOKEN = new Object();
048: static final Object CONTAINS_TEXT_TOKEN = new Object();
049:
050: /**
051: * The markers quick fix decoration.
052: */
053: static final String IMG_MARKERS_QUICK_FIX_DECORATION_PATH = "markers/contassist_ovr.gif"; //$NON-NLS-1$
054: /**
055: * The markers help decoration.
056: */
057: static final String IMG_MARKERS_HELP_DECORATION_PATH = "markers/help_small.gif"; //$NON-NLS-1$
058:
059: /**
060: * Create the image at the supplied path.
061: *
062: * @param completeImagePath
063: * @return Image or <code>null</code>.
064: */
065: public static Image createImage(String completeImagePath) {
066: URL url = BundleUtility.find(IDEWorkbenchPlugin.getDefault()
067: .getBundle().getSymbolicName(), completeImagePath);
068: if (url == null)
069: return null;
070: return IDEWorkbenchPlugin.getDefault().getResourceManager()
071: .createImageWithDefault(
072: ImageDescriptor.createFromURL(url));
073: }
074:
075: /**
076: * Get the IDE image at path.
077: *
078: * @param constantName
079: * @return Image
080: */
081: private static Image getIDEImage(String constantName) {
082:
083: return JFaceResources.getResources().createImageWithDefault(
084: IDEInternalWorkbenchImages
085: .getImageDescriptor(constantName));
086:
087: }
088:
089: /**
090: * Get the image for the supplied severity
091: *
092: * @param severity
093: * @return {@link Image}
094: */
095: public static Image getSeverityImage(int severity) {
096:
097: if (severity == IMarker.SEVERITY_ERROR) {
098: return getIDEImage(IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH);
099: }
100: if (severity == IMarker.SEVERITY_WARNING) {
101: return getIDEImage(IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH);
102: }
103: if (severity == IMarker.SEVERITY_INFO) {
104: return getIDEImage(IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH);
105: }
106:
107: return null;
108:
109: }
110:
111: /**
112: * Get the MarkerFieldFilter associated with the filter in group.
113: *
114: * @param group
115: * @param area
116: * @return MarkerFieldFilter or <code>null</code>
117: */
118: public final MarkerFieldFilter getFilter(
119: MarkerFieldFilterGroup group, FilterConfigurationArea area) {
120: return group.getFilter(area.getField());
121: }
122:
123: }
|