X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.client.ui%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fproviders%2FResultTreeLabelProvider.java;fp=org.argeo.slc.client.ui%2Fsrc%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fproviders%2FResultTreeLabelProvider.java;h=e3570c2a980ba83b219d4e1b61bd3304f46d60ed;hb=2db415932b071525adb52c6374e021174512a924;hp=0000000000000000000000000000000000000000;hpb=7e2f6c6ae08e97925955184aaa29035ac05de149;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java new file mode 100644 index 000000000..e3570c2a9 --- /dev/null +++ b/org.argeo.slc.client.ui/src/org/argeo/slc/client/ui/providers/ResultTreeLabelProvider.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2007-2012 Argeo GmbH + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.argeo.slc.client.ui.providers; + +import javax.jcr.Node; +import javax.jcr.Property; +import javax.jcr.RepositoryException; +import javax.jcr.nodetype.NodeType; + +import org.argeo.eclipse.ui.TreeParent; +import org.argeo.slc.SlcException; +import org.argeo.slc.client.ui.SlcImages; +import org.argeo.slc.client.ui.SlcUiConstants; +import org.argeo.slc.client.ui.model.ParentNodeFolder; +import org.argeo.slc.client.ui.model.ResultParent; +import org.argeo.slc.client.ui.model.SingleResultNode; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.swt.graphics.Image; + +/** Basic label provider for a tree of result */ +public class ResultTreeLabelProvider extends LabelProvider { + // private final static Log log = LogFactory + // .getLog(ResultTreeLabelProvider.class); + + @Override + public String getText(Object element) { + try { + + if (element instanceof SingleResultNode) { + Node node = ((SingleResultNode) element).getNode(); + if (node.isNodeType(NodeType.MIX_TITLE)) + return node.getProperty(Property.JCR_TITLE).getString(); + + } else if (element instanceof ParentNodeFolder) { + Node node = ((ParentNodeFolder) element).getNode(); + if (node.hasProperty(Property.JCR_TITLE)) + return node.getProperty(Property.JCR_TITLE).getString(); + } + } catch (RepositoryException e) { + throw new SlcException("Unexpected error while getting " + + "custom result label", e); + } + return ((TreeParent) element).getName(); + } + + public Image getImage(Object obj) { + if (obj instanceof SingleResultNode) { + // FIXME add realtime modification of process icon (SCHEDULED, + // RUNNING, COMPLETED...) + // Node resultNode = ((SingleResultNode) obj).getNode(); + // int status = SlcJcrUtils.aggregateTestStatus(resultNode); + return SlcImages.PROCESS_COMPLETED; + } else if (obj instanceof ResultParent) { + ResultParent rParent = (ResultParent) obj; + if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent + .getName())) + return SlcImages.MY_RESULTS_FOLDER; + else + return SlcImages.FOLDER; + } else + return null; + } +}