KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > visualcontent > ui > nodepropertylist > ViewContentProvider


1 /**
2  * VC Browser - Visualizes the content of a JSR 170 compatible repository
3  * Copyright (C) 2006 Sandro Böhme
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.visualcontent.ui.nodepropertylist;
19
20 import java.util.LinkedList JavaDoc;
21 import java.util.List JavaDoc;
22
23 import javax.jcr.Node;
24 import javax.jcr.Property;
25 import javax.jcr.PropertyIterator;
26 import javax.jcr.RepositoryException;
27
28 import org.eclipse.jface.viewers.IStructuredContentProvider;
29 import org.eclipse.jface.viewers.Viewer;
30 import org.visualcontent.ui.UiPlugin;
31
32 class ViewContentProvider implements IStructuredContentProvider {
33
34     /**
35      *
36      */

37     private final NodePropertyList viewContentProvider;
38
39     /**
40      * @param list
41      */

42     ViewContentProvider(NodePropertyList list) {
43         viewContentProvider = list;
44     }
45
46     public void inputChanged(Viewer v, Object JavaDoc oldInput, Object JavaDoc newInput) {
47
48     }
49
50     public void dispose() {
51     }
52
53     public Object JavaDoc[] getElements(Object JavaDoc parent) {
54         Property[] propertyArray = null;
55         PropertyIterator propertyIterator = null;
56         try {
57             Node contentNode = (Node) parent;
58             propertyIterator = contentNode.getProperties();
59             List JavaDoc propertyList = new LinkedList JavaDoc();
60             while (propertyIterator.hasNext()) {
61                 Property element = (Property) propertyIterator.nextProperty();
62                 propertyList.add(element);
63             }
64             propertyArray = (Property[]) propertyList
65                     .toArray(new Property[propertyList.size()]);
66         } catch (RepositoryException e) {
67             // occurs on getProperties() for example if a session has been
68
// closed externally
69
UiPlugin.getDefault().showError("Could not get the properties.",e);
70         }
71         return propertyArray;
72     }
73 }
Popular Tags