]> git.argeo.org Git - gpl/argeo-slc.git/blob - plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java
Update licence headers
[gpl/argeo-slc.git] / plugins / org.argeo.slc.client.ui / src / main / java / org / argeo / slc / client / ui / providers / ResultTreeLabelProvider.java
1 /*
2 * Copyright (C) 2007-2012 Argeo GmbH
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.providers;
17
18 import javax.jcr.Node;
19 import javax.jcr.Property;
20 import javax.jcr.RepositoryException;
21 import javax.jcr.nodetype.NodeType;
22
23 import org.argeo.eclipse.ui.TreeParent;
24 import org.argeo.slc.SlcException;
25 import org.argeo.slc.client.ui.SlcImages;
26 import org.argeo.slc.client.ui.SlcUiConstants;
27 import org.argeo.slc.client.ui.model.ResultParent;
28 import org.argeo.slc.client.ui.model.SingleResultNode;
29 import org.eclipse.jface.viewers.LabelProvider;
30 import org.eclipse.swt.graphics.Image;
31
32 /** Basic label provider for a tree of result */
33 public class ResultTreeLabelProvider extends LabelProvider {
34 // private final static Log log = LogFactory
35 // .getLog(ResultTreeLabelProvider.class);
36
37 @Override
38 public String getText(Object element) {
39 if (element instanceof SingleResultNode) {
40 Node node = ((SingleResultNode) element).getNode();
41 try {
42 if (node.isNodeType(NodeType.MIX_TITLE))
43 return node.getProperty(Property.JCR_TITLE).getString();
44 } catch (RepositoryException e) {
45 throw new SlcException("Unexpected error while getting "
46 + "custom result label", e);
47 }
48 }
49 return ((TreeParent) element).getName();
50 }
51
52 public Image getImage(Object obj) {
53 if (obj instanceof SingleResultNode) {
54 // FIXME add realtime modification of process icon (SCHEDULED,
55 // RUNNING, COMPLETED...)
56 // Node resultNode = ((SingleResultNode) obj).getNode();
57 // int status = SlcJcrUtils.aggregateTestStatus(resultNode);
58 return SlcImages.PROCESS_COMPLETED;
59 } else if (obj instanceof ResultParent) {
60 ResultParent rParent = (ResultParent) obj;
61 if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
62 .getName()))
63 return SlcImages.MY_RESULTS_FOLDER;
64 else
65 return SlcImages.FOLDER;
66 } else
67 return null;
68 }
69 }