]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/decorators/ResultFailedDecorator.java
Refactor JCR utils and home usage
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / decorators / ResultFailedDecorator.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.argeo.slc.client.ui.decorators;
17
18 import org.apache.commons.logging.Log;
19 import org.apache.commons.logging.LogFactory;
20 import org.argeo.slc.client.ui.ClientUiPlugin;
21 import org.argeo.slc.client.ui.model.ResultParent;
22 import org.eclipse.jface.resource.ImageDescriptor;
23 import org.eclipse.jface.viewers.DecorationOverlayIcon;
24 import org.eclipse.jface.viewers.IDecoration;
25 import org.eclipse.jface.viewers.ILabelDecorator;
26 import org.eclipse.jface.viewers.LabelProvider;
27 import org.eclipse.swt.graphics.Image;
28 import org.eclipse.ui.ISharedImages;
29
30 public class ResultFailedDecorator extends LabelProvider implements
31 ILabelDecorator {
32
33 private final static Log log = LogFactory
34 .getLog(ResultFailedDecorator.class);
35
36 public ResultFailedDecorator() {
37 super();
38 }
39
40 // Method to decorate Image
41 public Image decorateImage(Image image, Object object) {
42
43 // This method returns an annotated image or null if the
44 // image need not be decorated. Returning a null image
45 // decorates resource icon with basic decorations provided
46 // by Eclipse
47 if (object instanceof ResultParent) {
48 log.debug("decorate : " + ((ResultParent) object).getName()
49 + " - passed : " + ((ResultParent) object).isPassed());
50 if (!((ResultParent) object).isPassed()) {
51 ImageDescriptor desc = ClientUiPlugin.getDefault()
52 .getWorkbench().getSharedImages()
53 .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR);
54 DecorationOverlayIcon decoratedImage = new DecorationOverlayIcon(
55 image, desc, IDecoration.TOP_LEFT);
56 return decoratedImage.createImage();
57 } else
58 return null;
59 }
60 return null;
61 }
62
63 // Method to decorate Text
64 public String decorateText(String label, Object object) {
65 return null;
66 }
67 }