]> 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
Remove SLC process notifiers
[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.ParentNodeFolder;
28 import org.argeo.slc.client.ui.model.ResultParent;
29 import org.argeo.slc.client.ui.model.SingleResultNode;
30 import org.eclipse.jface.viewers.LabelProvider;
31 import org.eclipse.swt.graphics.Image;
32
33 /** Basic label provider for a tree of result */
34 public class ResultTreeLabelProvider extends LabelProvider {
35 // private final static Log log = LogFactory
36 // .getLog(ResultTreeLabelProvider.class);
37
38 @Override
39 public String getText(Object element) {
40 try {
41
42 if (element instanceof SingleResultNode) {
43 Node node = ((SingleResultNode) element).getNode();
44 if (node.isNodeType(NodeType.MIX_TITLE))
45 return node.getProperty(Property.JCR_TITLE).getString();
46
47 } else if (element instanceof ParentNodeFolder) {
48 Node node = ((ParentNodeFolder) element).getNode();
49 if (node.hasProperty(Property.JCR_TITLE))
50 return node.getProperty(Property.JCR_TITLE).getString();
51 }
52 } catch (RepositoryException e) {
53 throw new SlcException("Unexpected error while getting "
54 + "custom result label", e);
55 }
56 return ((TreeParent) element).getName();
57 }
58
59 public Image getImage(Object obj) {
60 if (obj instanceof SingleResultNode) {
61 // FIXME add realtime modification of process icon (SCHEDULED,
62 // RUNNING, COMPLETED...)
63 // Node resultNode = ((SingleResultNode) obj).getNode();
64 // int status = SlcJcrUtils.aggregateTestStatus(resultNode);
65 return SlcImages.PROCESS_COMPLETED;
66 } else if (obj instanceof ResultParent) {
67 ResultParent rParent = (ResultParent) obj;
68 if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
69 .getName()))
70 return SlcImages.MY_RESULTS_FOLDER;
71 else
72 return SlcImages.FOLDER;
73 } else
74 return null;
75 }
76 }