]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - i18n/providers/SimpleContentProvider.java
2 * Copyright (C) 2007-2012 Mathieu Baudier
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org
.argeo
.demo
.i18n
.providers
;
18 import java
.util
.ArrayList
;
19 import java
.util
.List
;
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
;
27 * Implementation of the {@code ITreeContentProvider} to display multiple
28 * repository environment in a tree like structure
31 public class SimpleContentProvider
implements ITreeContentProvider
{
32 // private final static Log log =
33 // LogFactory.getLog(SimpleContentProvider.class);
35 public SimpleContentProvider() {
39 * Sends back the first level of the Tree. Independent from inputElement
40 * that can be null. Values are hard coded here.
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();
54 public Object
[] getChildren(Object parentElement
) {
55 if (parentElement
instanceof TreeParent
)
56 return ((TreeParent
) parentElement
).getChildren();
62 public Object
getParent(Object element
) {
63 if (element
instanceof TreeParent
) {
64 return ((TreeParent
) element
).getParent();
69 public boolean hasChildren(Object element
) {
70 if (element
instanceof TreeParent
) {
71 TreeParent tp
= (TreeParent
) element
;
72 return tp
.hasChildren();
77 public void dispose() {
80 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {