]>
git.argeo.org Git - lgpl/argeo-commons.git/blob - ui/jcr/JcrBrowserUtils.java
1 package org
.argeo
.cms
.ui
.jcr
;
4 import javax
.jcr
.Property
;
5 import javax
.jcr
.PropertyType
;
6 import javax
.jcr
.RepositoryException
;
8 import org
.argeo
.cms
.ui
.jcr
.model
.RepositoriesElem
;
9 import org
.argeo
.cms
.ui
.jcr
.model
.RepositoryElem
;
10 import org
.argeo
.cms
.ui
.jcr
.model
.SingleJcrNodeElem
;
11 import org
.argeo
.cms
.ui
.jcr
.model
.WorkspaceElem
;
12 import org
.argeo
.cms
.ux
.widgets
.TreeParent
;
13 import org
.argeo
.eclipse
.ui
.EclipseUiException
;
15 /** Useful methods to manage the JCR Browser */
16 public class JcrBrowserUtils
{
18 public static String
getPropertyTypeAsString(Property prop
) {
20 return PropertyType
.nameFromValue(prop
.getType());
21 } catch (RepositoryException e
) {
22 throw new EclipseUiException("Cannot check type for " + prop
, e
);
26 /** Insure that the UI component is not stale, refresh if needed */
27 public static void forceRefreshIfNeeded(TreeParent element
) {
30 boolean doRefresh
= false;
33 if (element
instanceof SingleJcrNodeElem
) {
34 curNode
= ((SingleJcrNodeElem
) element
).getNode();
35 } else if (element
instanceof WorkspaceElem
) {
36 curNode
= ((WorkspaceElem
) element
).getRootNode();
39 if (curNode
!= null && element
.getChildren().length
!= curNode
.getNodes().getSize())
41 else if (element
instanceof RepositoryElem
) {
42 RepositoryElem rn
= (RepositoryElem
) element
;
43 if (rn
.isConnected()) {
44 String
[] wkpNames
= rn
.getAccessibleWorkspaceNames();
45 if (element
.getChildren().length
!= wkpNames
.length
)
48 } else if (element
instanceof RepositoriesElem
) {
50 // Always force refresh for RepositoriesElem : the condition
51 // below does not take remote repository into account and it is
52 // not trivial to do so.
54 // RepositoriesElem rn = (RepositoriesElem) element;
55 // if (element.getChildren().length !=
56 // rn.getRepositoryRegister()
57 // .getRepositories().size())
61 element
.clearChildren();
62 element
.getChildren();
64 } catch (RepositoryException re
) {
65 throw new EclipseUiException("Unexpected error while synchronising the UI with the JCR repository", re
);