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
.eclipse
.ui
.jcr
.views
;
18 import javax
.jcr
.Node
;
20 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
21 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
22 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
23 import org
.eclipse
.jface
.viewers
.TreeViewer
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.ui
.part
.ViewPart
;
27 public abstract class AbstractJcrBrowser
extends ViewPart
{
30 public abstract void createPartControl(Composite parent
);
33 * To be overridden to adapt size of form and result frames.
35 abstract protected int[] getWeights();
38 * To be overridden to provide an adapted size nodeViewer
40 abstract protected TreeViewer
createNodeViewer(Composite parent
,
41 ITreeContentProvider nodeContentProvider
);
44 * To be overridden to retrieve the current nodeViewer
46 abstract protected TreeViewer
getNodeViewer();
49 * Enables the refresh of the tree.
52 public void setFocus() {
53 getNodeViewer().getTree().setFocus();
56 public void refresh(Object obj
) {
57 // getNodeViewer().update(obj, null);
58 getNodeViewer().refresh(obj
);
59 // getNodeViewer().expandToLevel(obj, 1);
62 public void nodeAdded(Node parentNode
, Node newNode
) {
63 getNodeViewer().refresh(parentNode
);
64 getNodeViewer().expandToLevel(newNode
, 0);
67 public void nodeRemoved(Node parentNode
) {
68 IStructuredSelection newSel
= new StructuredSelection(parentNode
);
69 getNodeViewer().setSelection(newSel
, true);
71 IStructuredSelection tmpSel
= (IStructuredSelection
) getNodeViewer()
73 getNodeViewer().refresh(tmpSel
.getFirstElement());