]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - JcrBrowserUtils.java
8649023e4e4fa4e816d62a29386490a8dfb02c12
2 * Copyright (C) 2007-2012 Argeo GmbH
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
.workbench
.jcr
.internal
;
18 import javax
.jcr
.Node
;
19 import javax
.jcr
.RepositoryException
;
21 import org
.argeo
.ArgeoException
;
22 import org
.argeo
.eclipse
.ui
.TreeParent
;
23 import org
.argeo
.eclipse
.ui
.workbench
.jcr
.internal
.model
.RepositoriesElem
;
24 import org
.argeo
.eclipse
.ui
.workbench
.jcr
.internal
.model
.RepositoryElem
;
25 import org
.argeo
.eclipse
.ui
.workbench
.jcr
.internal
.model
.SingleJcrNodeElem
;
26 import org
.argeo
.eclipse
.ui
.workbench
.jcr
.internal
.model
.WorkspaceElem
;
28 /** Centralizes useful methods to manage the JCR Browser */
29 public class JcrBrowserUtils
{
31 /** Insure that the UI component is not stale, refresh if needed */
32 public static void forceRefreshIfNeeded(TreeParent element
) {
35 boolean doRefresh
= false;
38 if (element
instanceof SingleJcrNodeElem
) {
39 curNode
= ((SingleJcrNodeElem
) element
).getNode();
40 } else if (element
instanceof WorkspaceElem
) {
41 curNode
= ((WorkspaceElem
) element
).getRootNode();
45 && element
.getChildren().length
!= curNode
.getNodes()
48 else if (element
instanceof RepositoryElem
) {
49 RepositoryElem rn
= (RepositoryElem
) element
;
50 if (rn
.isConnected()) {
51 String
[] wkpNames
= rn
.getAccessibleWorkspaceNames();
52 if (element
.getChildren().length
!= wkpNames
.length
)
55 } else if (element
instanceof RepositoriesElem
) {
57 // Always force refresh for RepositoriesElem : the condition
58 // below does not take remote repository into account and it is
59 // not trivial to do so.
61 // RepositoriesElem rn = (RepositoriesElem) element;
62 // if (element.getChildren().length !=
63 // rn.getRepositoryRegister()
64 // .getRepositories().size())
68 element
.clearChildren();
69 element
.getChildren();
71 } catch (RepositoryException re
) {
72 throw new ArgeoException(
73 "Unexpected error while synchronising the UI with the JCR repository",