X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=jcr%2Forg.argeo.cms.ui%2Fsrc%2Forg%2Fargeo%2Fcms%2Fui%2Fviewers%2FJcrVersionCmsEditable.java;h=298fbdea9b6d3dd2b58fc6e01d50a5cb954c58b8;hb=ff7b3e2954398c5a6d36684725d4527c961ae080;hp=07724f4b11c51a1f00e05c6a068929d9d5c8dfe8;hpb=24241fea161ffb28b879739bbeb986bdaa30ebd7;p=lgpl%2Fargeo-commons.git diff --git a/jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/JcrVersionCmsEditable.java b/jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/JcrVersionCmsEditable.java index 07724f4b1..298fbdea9 100644 --- a/jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/JcrVersionCmsEditable.java +++ b/jcr/org.argeo.cms.ui/src/org/argeo/cms/ui/viewers/JcrVersionCmsEditable.java @@ -1,16 +1,14 @@ package org.argeo.cms.ui.viewers; -import java.util.Observable; - import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.Session; import javax.jcr.nodetype.NodeType; import javax.jcr.version.VersionManager; -import org.argeo.api.cms.ux.CmsEditable; -import org.argeo.cms.CmsException; -import org.argeo.cms.ui.CmsEditionEvent; +import org.argeo.api.cms.ux.CmsEditionEvent; +import org.argeo.cms.ux.AbstractCmsEditable; +import org.argeo.jcr.JcrException; import org.eclipse.rap.rwt.RWT; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Display; @@ -18,23 +16,21 @@ import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Listener; /** Provides the CmsEditable semantic based on JCR versioning. */ -public class JcrVersionCmsEditable extends Observable implements CmsEditable { +public class JcrVersionCmsEditable extends AbstractCmsEditable { private final String nodePath;// cache private final VersionManager versionManager; private final Boolean canEdit; public JcrVersionCmsEditable(Node node) throws RepositoryException { this.nodePath = node.getPath(); - if (node.getSession().hasPermission(node.getPath(), - Session.ACTION_SET_PROPERTY)) { + if (node.getSession().hasPermission(node.getPath(), Session.ACTION_SET_PROPERTY)) { // was Session.ACTION_ADD_NODE canEdit = true; if (!node.isNodeType(NodeType.MIX_VERSIONABLE)) { node.addMixin(NodeType.MIX_VERSIONABLE); node.getSession().save(); } - versionManager = node.getSession().getWorkspace() - .getVersionManager(); + versionManager = node.getSession().getWorkspace().getVersionManager(); } else { canEdit = false; versionManager = null; @@ -43,8 +39,7 @@ public class JcrVersionCmsEditable extends Observable implements CmsEditable { // bind keys if (canEdit) { Display display = Display.getCurrent(); - display.setData(RWT.ACTIVE_KEYS, new String[] { "CTRL+RETURN", - "CTRL+E" }); + display.setData(RWT.ACTIVE_KEYS, new String[] { "CTRL+RETURN", "CTRL+E" }); display.addFilter(SWT.KeyDown, new Listener() { private static final long serialVersionUID = -4378653870463187318L; @@ -70,8 +65,7 @@ public class JcrVersionCmsEditable extends Observable implements CmsEditable { return false; return versionManager.isCheckedOut(nodePath); } catch (RepositoryException e) { - throw new CmsException("Cannot check whether " + nodePath - + " is editing", e); + throw new JcrException("Cannot check whether " + nodePath + " is editing", e); } } @@ -79,23 +73,22 @@ public class JcrVersionCmsEditable extends Observable implements CmsEditable { public void startEditing() { try { versionManager.checkout(nodePath); - setChanged(); +// setChanged(); } catch (RepositoryException e1) { - throw new CmsException("Cannot publish " + nodePath); + throw new JcrException("Cannot publish " + nodePath, e1); } - notifyObservers(new CmsEditionEvent(nodePath, - CmsEditionEvent.START_EDITING)); + notifyListeners(new CmsEditionEvent(nodePath, CmsEditionEvent.START_EDITING, this)); } @Override public void stopEditing() { try { versionManager.checkin(nodePath); - setChanged(); +// setChanged(); } catch (RepositoryException e1) { - throw new CmsException("Cannot publish " + nodePath, e1); + throw new JcrException("Cannot publish " + nodePath, e1); } - notifyObservers(new CmsEditionEvent(nodePath, - CmsEditionEvent.STOP_EDITING)); + notifyListeners(new CmsEditionEvent(nodePath, CmsEditionEvent.STOP_EDITING, this)); } + }