]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - 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
index bae1c9dc039ede8738eeac43cf492b01700b902a..1a55983b5fcc939a1eba5bf0a2190b51aca5eec1 100644 (file)
@@ -1,6 +1,27 @@
+/*
+ * 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.ResultParent;
@@ -15,6 +36,16 @@ public class ResultTreeLabelProvider extends LabelProvider {
 
        @Override
        public String getText(Object element) {
+               if (element instanceof SingleResultNode) {
+                       Node node = ((SingleResultNode) element).getNode();
+                       try {
+                               if (node.isNodeType(NodeType.MIX_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();
        }
 
@@ -27,7 +58,8 @@ public class ResultTreeLabelProvider extends LabelProvider {
                        return SlcImages.PROCESS_COMPLETED;
                } else if (obj instanceof ResultParent) {
                        ResultParent rParent = (ResultParent) obj;
-                       if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent.getName()))
+                       if (SlcUiConstants.DEFAULT_MY_RESULTS_FOLDER_LABEL.equals(rParent
+                                       .getName()))
                                return SlcImages.MY_RESULTS_FOLDER;
                        else
                                return SlcImages.FOLDER;