locking repeats while operations (insert, remove, move) are in progress to avoid double click issues.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@5059 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-02-07 00:27:45 +00:00
parent d25f46bc0f
commit 8ca91cb822
2 changed files with 29 additions and 12 deletions

View File

@@ -283,7 +283,7 @@ public class XFormsBean
* Writes the xform out to the http servlet response. This allows * Writes the xform out to the http servlet response. This allows
* us to use the browser to parse the xform using XMLHttpRequest. * us to use the browser to parse the xform using XMLHttpRequest.
*/ */
public void getXForm() public synchronized void getXForm()
throws IOException, throws IOException,
XFormsException XFormsException
{ {
@@ -302,7 +302,7 @@ public class XFormsBean
* @param value the new value * @param value the new value
* @return the list of events that may result through this action * @return the list of events that may result through this action
*/ */
public void setXFormsValue() public synchronized void setXFormsValue()
throws XFormsException, IOException throws XFormsException, IOException
{ {
final FacesContext context = FacesContext.getCurrentInstance(); final FacesContext context = FacesContext.getCurrentInstance();
@@ -357,7 +357,7 @@ public class XFormsBean
* *
* @param id the id of the control in the host document * @param id the id of the control in the host document
*/ */
public void fireAction() public synchronized void fireAction()
throws XFormsException, IOException throws XFormsException, IOException
{ {
final FacesContext context = FacesContext.getCurrentInstance(); final FacesContext context = FacesContext.getCurrentInstance();
@@ -376,7 +376,7 @@ public class XFormsBean
/** /**
* handles submits and sets the instance data. * handles submits and sets the instance data.
*/ */
public void handleAction() public synchronized void handleAction()
{ {
LOGGER.debug(this + ".handleAction"); LOGGER.debug(this + ".handleAction");
try try
@@ -410,7 +410,7 @@ public class XFormsBean
/** /**
* Swaps model nodes to implement reordering within repeats. * Swaps model nodes to implement reordering within repeats.
*/ */
public void swapRepeatItems() public synchronized void swapRepeatItems()
throws Exception throws Exception
{ {
final FacesContext context = FacesContext.getCurrentInstance(); final FacesContext context = FacesContext.getCurrentInstance();
@@ -420,8 +420,17 @@ public class XFormsBean
final String toItemId = (String)requestParameters.get("toItemId"); final String toItemId = (String)requestParameters.get("toItemId");
LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")"); LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")");
final ChibaBean chibaBean = this.xformsSession.chibaBean; final ChibaBean chibaBean = this.xformsSession.chibaBean;
this.swapRepeatItems((RepeatItem)chibaBean.getContainer().lookup(fromItemId), final RepeatItem from = (RepeatItem)chibaBean.getContainer().lookup(fromItemId);
(RepeatItem)chibaBean.getContainer().lookup(toItemId)); if (from == null)
{
throw new NullPointerException("unable to find source repeat item " + fromItemId);
}
final RepeatItem to = (RepeatItem)chibaBean.getContainer().lookup(toItemId);
if (to == null)
{
throw new NullPointerException("unable to find destination repeat item " + toItemId);
}
this.swapRepeatItems(from, to);
final ResponseWriter out = context.getResponseWriter(); final ResponseWriter out = context.getResponseWriter();
XMLUtil.print(this.getEventLog(), out); XMLUtil.print(this.getEventLog(), out);

View File

@@ -2352,6 +2352,7 @@ dojo.declare("alfresco.xforms.Repeat",
{ {
this.repeatControls = []; this.repeatControls = [];
this._selectedIndex = -1; this._selectedIndex = -1;
this._locked = false;
}, },
{ {
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
@@ -2727,13 +2728,14 @@ dojo.declare("alfresco.xforms.Repeat",
{ {
dojo.event.browser.stopEvent(event); dojo.event.browser.stopEvent(event);
var repeat = event.target.repeat; var repeat = event.target.repeat;
if (repeat.isInsertRepeatItemEnabled()) if (!repeat._locked && repeat.isInsertRepeatItemEnabled())
{ {
var index = repeat.repeatControls.indexOf(event.target.parentNode); var index = repeat.repeatControls.indexOf(event.target.parentNode);
var repeatItem = repeat.getChildAt(index); var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem); this.setFocusedChild(repeatItem);
var trigger = this._getRepeatItemTrigger("insert", { position: "after" }); var trigger = this._getRepeatItemTrigger("insert", { position: "after" });
trigger.fire(); trigger.fire();
repeat._locked = true;
} }
}, },
@@ -2747,11 +2749,12 @@ dojo.declare("alfresco.xforms.Repeat",
{ {
dojo.event.browser.stopEvent(event); dojo.event.browser.stopEvent(event);
var repeat = event.target.repeat; var repeat = event.target.repeat;
if (repeat.isInsertRepeatItemEnabled()) if (!repeat._locked && repeat.isInsertRepeatItemEnabled())
{ {
this.setFocusedChild(null); this.setFocusedChild(null);
var trigger = this._getRepeatItemTrigger("insert", { position: "before" }); var trigger = this._getRepeatItemTrigger("insert", { position: "before" });
trigger.fire(); trigger.fire();
repeat._locked = true;
} }
} }
}, },
@@ -2764,13 +2767,14 @@ dojo.declare("alfresco.xforms.Repeat",
{ {
dojo.event.browser.stopEvent(event); dojo.event.browser.stopEvent(event);
var repeat = event.target.repeat; var repeat = event.target.repeat;
if (repeat.isRemoveRepeatItemEnabled()) if (!repeat._locked && repeat.isRemoveRepeatItemEnabled())
{ {
var index = repeat.repeatControls.indexOf(event.target.parentNode); var index = repeat.repeatControls.indexOf(event.target.parentNode);
var repeatItem = repeat.getChildAt(index); var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem); this.setFocusedChild(repeatItem);
var trigger = this._getRepeatItemTrigger("delete", {}); var trigger = this._getRepeatItemTrigger("delete", {});
trigger.fire(); trigger.fire();
repeat._locked = true;
} }
}, },
@@ -2783,11 +2787,12 @@ dojo.declare("alfresco.xforms.Repeat",
dojo.event.browser.stopEvent(event); dojo.event.browser.stopEvent(event);
var repeat = event.target.repeat; var repeat = event.target.repeat;
var index = repeat.repeatControls.indexOf(event.target.parentNode); var index = repeat.repeatControls.indexOf(event.target.parentNode);
if (index != 0 && repeat._children.length != 1) if (!repeat._locked && index != 0 && repeat._children.length != 1)
{ {
var repeatItem = repeat.getChildAt(index); var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem); this.setFocusedChild(repeatItem);
repeat._swapChildren(index, index - 1); repeat._swapChildren(index, index - 1);
repeat._locked = true;
} }
}, },
@@ -2800,11 +2805,12 @@ dojo.declare("alfresco.xforms.Repeat",
dojo.event.browser.stopEvent(event); dojo.event.browser.stopEvent(event);
var repeat = event.target.repeat; var repeat = event.target.repeat;
var index = repeat.repeatControls.indexOf(event.target.parentNode); var index = repeat.repeatControls.indexOf(event.target.parentNode);
if (index != repeat._children.length - 1 && repeat._children.length != 1) if (!repeat._locked && index != repeat._children.length - 1 && repeat._children.length != 1)
{ {
var repeatItem = repeat.getChildAt(index); var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem); this.setFocusedChild(repeatItem);
repeat._swapChildren(index, index + 1); repeat._swapChildren(index, index + 1);
repeat._locked = true;
} }
}, },
@@ -2847,6 +2853,7 @@ dojo.declare("alfresco.xforms.Repeat",
var w = this.xform.createWidget(clonedPrototype); var w = this.xform.createWidget(clonedPrototype);
this._insertChildAt(w, position); this._insertChildAt(w, position);
this.xform.loadWidgets(w.xformsNode, w); this.xform.loadWidgets(w.xformsNode, w);
this._locked = false;
}, },
/** Deletes the item at the specified position. */ /** Deletes the item at the specified position. */
@@ -2854,6 +2861,7 @@ dojo.declare("alfresco.xforms.Repeat",
{ {
dojo.debug(this.id + ".handleItemDeleted(" + position + ")"); dojo.debug(this.id + ".handleItemDeleted(" + position + ")");
this._removeChildAt(position); this._removeChildAt(position);
this._locked = false;
} }
}); });