Author: julien(a)jboss.com
Date: 2008-07-09 12:19:56 -0400 (Wed, 09 Jul 2008)
New Revision: 11371
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutElement.java
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStructure.java
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/MoveUIObjectAction.java
Log:
basic DnD working
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/model/AjaxLayout.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -33,6 +33,7 @@
import java.util.Map;
import org.jboss.portal.presentation.ajax.client.Constants;
+import org.jboss.portal.presentation.ajax.client.protocol.MoveObjectAction;
import org.jboss.portal.presentation.ajax.client.dnd.Draggable;
import org.jboss.portal.presentation.ajax.client.dnd.Droppable;
@@ -144,11 +145,17 @@
log.info("Moving window " + window.getId() + " from parent
" + parent.getId() + " to layout " + getId());
//
- parent.removeChild(window);
+ MoveObjectAction action = new MoveObjectAction(window.getId(), getId());
//
- addChild(window);
+ getContext().getAgentContext().process(action);
+// //
+// parent.removeChild(window);
+//
+// //
+// addChild(window);
+
//
return true;
}
Added:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java
(rev 0)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/client/protocol/MoveObjectAction.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -0,0 +1,67 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.presentation.ajax.client.protocol;
+
+/**
+ * @author <a href="mailto:julien@jboss-portal.org">Julien
Viet</a>
+ * @version $Revision: 630 $
+ */
+public class MoveObjectAction extends AjaxAction
+{
+
+ /** . */
+ private String sourceId;
+
+ /** . */
+ private String destinationId;
+
+ public MoveObjectAction(String sourceId, String destinationId)
+ {
+ this.sourceId = sourceId;
+ this.destinationId = destinationId;
+ }
+
+ public MoveObjectAction()
+ {
+ }
+
+ public String getSourceId()
+ {
+ return sourceId;
+ }
+
+ public void setSourceId(String sourceId)
+ {
+ this.sourceId = sourceId;
+ }
+
+ public String getDestinationId()
+ {
+ return destinationId;
+ }
+
+ public void setDestinationId(String destinationId)
+ {
+ this.destinationId = destinationId;
+ }
+}
Modified:
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java
===================================================================
---
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/ajax/src/main/java/org/jboss/portal/presentation/ajax/server/PresentationClientServlet.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -29,6 +29,7 @@
import org.jboss.portal.presentation.ajax.client.protocol.AjaxResponse;
import org.jboss.portal.presentation.ajax.client.protocol.AjaxRequest;
import org.jboss.portal.presentation.ajax.client.protocol.DestroyObjectAction;
+import org.jboss.portal.presentation.ajax.client.protocol.MoveObjectAction;
import org.jboss.portal.presentation.ajax.client.model.update.ModelUpdate;
import org.jboss.portal.presentation.ajax.server.model.AjaxViewPortContext;
import org.jboss.portal.presentation.ajax.server.protocol.AjaxActionDecoderContext;
@@ -48,6 +49,7 @@
import org.jboss.portal.presentation.protocol.codec.ActionDecoder;
import org.jboss.portal.presentation.protocol.ProtocolAction;
import org.jboss.portal.presentation.protocol.DestroyUIObjectAction;
+import org.jboss.portal.presentation.protocol.MoveUIObjectAction;
import org.jboss.portal.web.ServletContextDispatcher;
import org.jboss.portal.web.ServletContainer;
import org.jboss.portal.web.WebRequest;
@@ -135,19 +137,19 @@
public AjaxResponse process(AjaxRequest request)
{
- AjaxAction action = request.getAction();
+ AjaxAction ajaxAction = request.getAction();
//
ActionDecoder decoder =
(ActionDecoder)getServletContext().getAttribute("ActionDecoder");
//
- System.out.println("handling action " + action);
+ System.out.println("handling action " + ajaxAction);
//
ProtocolAction protocolAction = null;
- if (action instanceof OpaqueWindowAction)
+ if (ajaxAction instanceof OpaqueWindowAction)
{
- OpaqueWindowAction windowAction = (OpaqueWindowAction)action;
+ OpaqueWindowAction windowAction = (OpaqueWindowAction)ajaxAction;
//
@@ -182,13 +184,20 @@
protocolAction = decoder.decode(new
AjaxActionDecoderContext(WebRequest.Verb.GET, path, queryParameterMap, body));
}
- else if (action instanceof DestroyObjectAction)
+ else if (ajaxAction instanceof DestroyObjectAction)
{
- DestroyObjectAction ajaxAction = (DestroyObjectAction)action;
+ DestroyObjectAction destroyObjectAction = (DestroyObjectAction)ajaxAction;
- protocolAction = new DestroyUIObjectAction(ajaxAction.getObjectId());
+ protocolAction = new DestroyUIObjectAction(destroyObjectAction.getObjectId());
}
+ else if (ajaxAction instanceof MoveObjectAction)
+ {
+ MoveObjectAction moveObjectAction = (MoveObjectAction)ajaxAction;
+ //
+ protocolAction = new MoveUIObjectAction(moveObjectAction.getSourceId(),
moveObjectAction.getDestinationId());
+ }
+
//
if (protocolAction != null)
{
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/PresentationServerImpl.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -30,6 +30,7 @@
import org.jboss.portal.presentation.portal.model.content.PageContentContextImpl;
import org.jboss.portal.presentation.portal.model.layout.LayoutStore;
import org.jboss.portal.presentation.portal.model.layout.LayoutElement;
+import org.jboss.portal.presentation.portal.model.layout.LayoutStructure;
import org.jboss.portal.presentation.impl.state.structural.adapter.StructuralAdapter;
import org.jboss.portal.presentation.portal.content.protocol.ContentAction;
import org.jboss.portal.presentation.portal.content.ContentHandlerRegistry;
@@ -47,6 +48,7 @@
import org.jboss.portal.presentation.protocol.LinkActivation;
import org.jboss.portal.presentation.protocol.ProtocolResponse;
import org.jboss.portal.presentation.protocol.DestroyUIObjectAction;
+import org.jboss.portal.presentation.protocol.MoveUIObjectAction;
import org.jboss.portal.presentation.server.PresentationRequest;
import org.jboss.portal.presentation.server.PresentationResponse;
import org.jboss.portal.presentation.server.PresentationServer;
@@ -197,6 +199,31 @@
//
return new PresentationResponse(response,
contentResponse.getStaleObjects());
}
+ else if (objectAction instanceof MoveUIObjectAction)
+ {
+ MoveUIObjectAction moveAction = (MoveUIObjectAction)objectAction;
+
+ //
+ LayoutStructure destinationElt =
(LayoutStructure)structuralAdapter.getNode(moveAction.getDestinationId());
+
+ //
+ LayoutElement sourceElt = layoutStore.findElementByRef(targetNode.getId());
+
+ //
+ if (sourceElt == null)
+ {
+ throw new RuntimeException("Could not find move source " +
targetId);
+ }
+
+ //
+ destinationElt.add(sourceElt);
+
+ //
+ System.out.println("Should move " + targetNode + " to " +
destinationElt);
+
+ //
+ return new PresentationResponse(new ShowUIObjectResponse("blah"));
+ }
}
//
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutElement.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutElement.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutElement.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -22,8 +22,6 @@
******************************************************************************/
package org.jboss.portal.presentation.portal.model.layout;
-import org.jboss.portal.common.NotYetImplemented;
-
import java.io.Serializable;
/**
Modified:
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStructure.java
===================================================================
---
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStructure.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/portal/src/main/java/org/jboss/portal/presentation/portal/model/layout/LayoutStructure.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -47,6 +47,30 @@
return elements;
}
+ public void add(LayoutElement element)
+ {
+ if (element == null)
+ {
+ throw new IllegalArgumentException("No null element can be added");
+ }
+
+ // Sanity check
+ if (element.structure == null)
+ {
+ throw new IllegalArgumentException("Element should be owned in an existing
structure");
+ }
+
+ // Remove + Sanity check
+ if (!element.structure.elements.remove(element))
+ {
+ throw new IllegalArgumentException("The element previous structure should
contain this element");
+ }
+
+ //
+ element.structure = this;
+ elements.add(element);
+ }
+
public SimpleElement addObjectElement(String objectRef)
{
SimpleElement item = new SimpleElement(objectRef);
Modified:
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/MoveUIObjectAction.java
===================================================================
---
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/MoveUIObjectAction.java 2008-07-09
15:14:30 UTC (rev 11370)
+++
modules/presentation/trunk/presentation/src/main/java/org/jboss/portal/presentation/protocol/MoveUIObjectAction.java 2008-07-09
16:19:56 UTC (rev 11371)
@@ -28,8 +28,26 @@
*/
public class MoveUIObjectAction extends UIObjectAction
{
- public MoveUIObjectAction(String targetId)
+
+ /** . */
+ private final String destinationId;
+
+ public MoveUIObjectAction(String targetId, String destinationId)
{
super(targetId);
+
+ //
+ if (destinationId == null)
+ {
+ throw new IllegalArgumentException("No null destination id
accepted");
+ }
+
+ //
+ this.destinationId = destinationId;
}
+
+ public String getDestinationId()
+ {
+ return destinationId;
+ }
}