]> git.argeo.org Git - lgpl/argeo-commons.git/blob - i18n/providers/SimpleContentProvider.java
Prepare next development cycle
[lgpl/argeo-commons.git] / i18n / providers / SimpleContentProvider.java
1 /*
2 * Copyright (C) 2007-2012 Mathieu Baudier
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.demo.i18n.providers;
17
18 import java.util.ArrayList;
19 import java.util.List;
20
21 import org.argeo.demo.i18n.model.Place;
22 import org.argeo.eclipse.ui.TreeParent;
23 import org.eclipse.jface.viewers.ITreeContentProvider;
24 import org.eclipse.jface.viewers.Viewer;
25
26 /**
27 * Implementation of the {@code ITreeContentProvider} to display multiple
28 * repository environment in a tree like structure
29 *
30 */
31 public class SimpleContentProvider implements ITreeContentProvider {
32 // private final static Log log =
33 // LogFactory.getLog(SimpleContentProvider.class);
34
35 public SimpleContentProvider() {
36 }
37
38 /**
39 * Sends back the first level of the Tree. Independent from inputElement
40 * that can be null. Values are hard coded here.
41 */
42 public Object[] getElements(Object inputElement) {
43 List<Object> objs = new ArrayList<Object>();
44 objs.add(new Place("Home", "My house, my family",
45 "12 rue du bac, Paris"));
46 objs.add(new Place("Office", "Where I work",
47 "100 av des champs Elysées"));
48 objs.add(new Place("School",
49 "The place where the children spend their days",
50 "103 Avenue montaigne, Paris"));
51 return objs.toArray();
52 }
53
54 public Object[] getChildren(Object parentElement) {
55 if (parentElement instanceof TreeParent)
56 return ((TreeParent) parentElement).getChildren();
57 else {
58 return new Object[0];
59 }
60 }
61
62 public Object getParent(Object element) {
63 if (element instanceof TreeParent) {
64 return ((TreeParent) element).getParent();
65 } else
66 return null;
67 }
68
69 public boolean hasChildren(Object element) {
70 if (element instanceof TreeParent) {
71 TreeParent tp = (TreeParent) element;
72 return tp.hasChildren();
73 }
74 return false;
75 }
76
77 public void dispose() {
78 }
79
80 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
81 }
82 }