Author: norman
Date: Thu Aug 13 14:07:30 2009
New Revision: 803894
URL: http://svn.apache.org/viewvc?rev=803894&view=rev
Log:
Support moving message from folder to folder
Added:
labs/hupa/src/main/java/org/apache/hupa/client/bundles/email.png (with
props)
labs/hupa/src/main/java/org/apache/hupa/client/bundles/email_link.png
(with props)
labs/hupa/src/main/java/org/apache/hupa/client/dnd/
labs/hupa/src/main/java/org/apache/hupa/client/dnd/DragRefetchPagingScrollTable.java
labs/hupa/src/main/java/org/apache/hupa/client/dnd/PagingScrollTableRowDragController.java
labs/hupa/src/main/java/org/apache/hupa/server/handler/MoveMessageHandler.java
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEvent.java
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEventHandler.java
labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessage.java
labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessageResult.java
Modified:
labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml
labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
labs/hupa/src/main/java/org/apache/hupa/client/HupaMessages.java
labs/hupa/src/main/java/org/apache/hupa/client/bundles/HupaImageBundle.java
labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPFolderView.java
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java
Modified: labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml (original)
+++ labs/hupa/src/main/java/org/apache/hupa/Hupa.gwt.xml Thu Aug 13 14:07:30
2009
@@ -23,7 +23,9 @@
<inherits name="com.google.gwt.inject.Inject"/>
<inherits name="gwtupload.GWTUpload"/>
<inherits name="eu.maydu.gwt.validation.ValidationLibrary"/>
-
+ <!-- Inherit gwt-dnd support -->
+ <inherits name='com.allen_sauer.gwt.dnd.gwt-dnd'/>
+
<source path="shared"/>
<source path="client"/>
Modified: labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/Hupa.java Thu Aug 13
14:07:30 2009
@@ -33,7 +33,7 @@
AppPresenter aPres = injector.getAppPresenter();
aPres.go(RootPanel.get());
-
+
injector.getPlaceManager().fireCurrentPlace();
}
Modified: labs/hupa/src/main/java/org/apache/hupa/client/HupaMessages.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/HupaMessages.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/HupaMessages.java (original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/HupaMessages.java Thu Aug 13
14:07:30 2009
@@ -25,4 +25,7 @@
@DefaultMessage("Are you sure you want to delete the selected
messages?")
public String confirmDeleteMessages();
+
+ @DefaultMessage("Moving message")
+ public String moveMessage();
}
Modified:
labs/hupa/src/main/java/org/apache/hupa/client/bundles/HupaImageBundle.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/bundles/HupaImageBundle.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/bundles/HupaImageBundle.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/bundles/HupaImageBundle.java
Thu Aug 13 14:07:30 2009
@@ -26,4 +26,10 @@
@Resource("attach.png")
public AbstractImagePrototype attachmentIcon();
+
+ @Resource("email_link.png")
+ public AbstractImagePrototype readyToMoveMailIcon();
+
+ @Resource("email.png")
+ public AbstractImagePrototype moveMailIcon();
}
Added: labs/hupa/src/main/java/org/apache/hupa/client/bundles/email.png
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/bundles/email.png?rev=803894&view=auto
==============================================================================
Binary file - no diff available.
Propchange: labs/hupa/src/main/java/org/apache/hupa/client/bundles/email.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: labs/hupa/src/main/java/org/apache/hupa/client/bundles/email_link.png
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/bundles/email_link.png?rev=803894&view=auto
==============================================================================
Binary file - no diff available.
Propchange:
labs/hupa/src/main/java/org/apache/hupa/client/bundles/email_link.png
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added:
labs/hupa/src/main/java/org/apache/hupa/client/dnd/DragRefetchPagingScrollTable.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/dnd/DragRefetchPagingScrollTable.java?rev=803894&view=auto
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/client/dnd/DragRefetchPagingScrollTable.java
(added)
+++
labs/hupa/src/main/java/org/apache/hupa/client/dnd/DragRefetchPagingScrollTable.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,104 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.client.dnd;
+
+import java.util.Iterator;
+
+import org.apache.hupa.client.widgets.RefetchPagingScrollTable;
+
+import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
+import com.google.gwt.gen2.table.client.DefaultTableDefinition;
+import com.google.gwt.gen2.table.client.FixedWidthFlexTable;
+import com.google.gwt.gen2.table.client.FixedWidthGrid;
+import com.google.gwt.gen2.table.client.MutableTableModel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class DragRefetchPagingScrollTable<RowType> extends
RefetchPagingScrollTable<RowType>{
+ private DragHandlerFactory factory;
+ private int cellIndex =-1;
+ private PagingScrollTableRowDragController tableRowDragController;
+ public DragRefetchPagingScrollTable(MutableTableModel<RowType>
tableModel,
+ FixedWidthGrid dataTable, FixedWidthFlexTable
headerTable,
+ DefaultTableDefinition<RowType> tableDefinition,
PagingScrollTableRowDragController tableRowDragController,int dragColumn) {
+ super(tableModel, dataTable, headerTable, tableDefinition);
+ this.tableRowDragController = tableRowDragController;
+ }
+
+ /**
+ * Factory which will create new Handler Widgets
+ * */
+ public interface DragHandlerFactory {
+ public Widget createHandler();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setDragHandler(int cellIndex,int
cellWidth,DragHandlerFactory factory) {
+ this.factory = factory;
+ this.cellIndex = cellIndex;
+ if (cellIndex < 0) {
+ throw new IllegalArgumentException("cellIndex needs to
be higher then 0");
+ }
+
+ DefaultTableDefinition tableDef = (DefaultTableDefinition)
getTableDefinition();
+
+ // remove old definition
+ if (cellIndex != -1) {
+
tableDef.removeColumnDefinition(tableDef.getColumnDefinition(cellIndex));
+ }
+
+ // Create new ghost definition which will get used later to add
the drag widget
+ DragColumnDefinition def = new DragColumnDefinition();
+ def.setColumnSortable(false);
+ def.setColumnTruncatable(false);
+ def.setMaximumColumnWidth(cellWidth);
+ def.setPreferredColumnWidth(cellWidth);
+ def.setMinimumColumnWidth(cellWidth);
+ tableDef.addColumnDefinition(cellIndex,def);
+ }
+
+
+ @Override
+ protected void setData(int firstRow, Iterator<RowType> rows) {
+ super.setData(firstRow, rows);
+
+ if (getRowValues().size() >0 && factory != null && cellIndex >
-1) {
+ for (int i = firstRow; i < getRowValues().size();i++) {
+ Widget handler = factory.createHandler();
+ getDataTable().setWidget(i, cellIndex, handler);
+ tableRowDragController.makeDraggable(handler);
+ }
+ }
+ }
+
+ private final class DragColumnDefinition extends
AbstractColumnDefinition<RowType, Boolean> {
+
+ @Override
+ public Boolean getCellValue(RowType rowValue) {
+ return true;
+ }
+
+ @Override
+ public void setCellValue(RowType rowValue, Boolean cellValue) {
+
+ }
+
+ }
+
+}
Added:
labs/hupa/src/main/java/org/apache/hupa/client/dnd/PagingScrollTableRowDragController.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/dnd/PagingScrollTableRowDragController.java?rev=803894&view=auto
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/client/dnd/PagingScrollTableRowDragController.java
(added)
+++
labs/hupa/src/main/java/org/apache/hupa/client/dnd/PagingScrollTableRowDragController.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,120 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.client.dnd;
+
+import org.apache.hupa.client.HupaMessages;
+import org.apache.hupa.client.bundles.HupaImageBundle;
+import org.cobogw.gwt.user.client.ui.RoundedPanel;
+
+import com.allen_sauer.gwt.dnd.client.DragContext;
+import com.allen_sauer.gwt.dnd.client.PickupDragController;
+import com.allen_sauer.gwt.dnd.client.drop.BoundaryDropController;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.gen2.table.client.FixedWidthGrid;
+import com.google.gwt.gen2.table.client.PagingScrollTable;
+import com.google.gwt.user.client.ui.AbsolutePanel;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public class PagingScrollTableRowDragController extends PickupDragController {
+
+
+ private HupaMessages messages = GWT.create(HupaMessages.class);
+ private HupaImageBundle bundle =GWT.create(HupaImageBundle.class);
+ private FixedWidthGrid draggableTable;
+ private PagingScrollTable parentTable;
+ private int dragRow;
+
+
+ public PagingScrollTableRowDragController() {
+ this(RootPanel.get());
+ }
+ public PagingScrollTableRowDragController(AbsolutePanel boundaryPanel) {
+ super(boundaryPanel, false);
+ setBehaviorDragProxy(true);
+ setBehaviorMultipleSelection(false);
+ }
+
+ @Override
+ public void dragEnd() {
+ super.dragEnd();
+
+ // cleanup
+ // draggableTable = null;
+ }
+
+ @Override
+ public void setBehaviorDragProxy(boolean dragProxyEnabled) {
+ if (!dragProxyEnabled) {
+ // TODO implement drag proxy behavior
+ throw new IllegalArgumentException();
+ }
+ super.setBehaviorDragProxy(dragProxyEnabled);
+ }
+
+ @Override
+ protected BoundaryDropController newBoundaryDropController(
+ AbsolutePanel boundaryPanel, boolean
allowDroppingOnBoundaryPanel) {
+ if (allowDroppingOnBoundaryPanel) {
+ throw new IllegalArgumentException();
+ }
+ return super.newBoundaryDropController(boundaryPanel,
+ allowDroppingOnBoundaryPanel);
+ }
+
+
+ @SuppressWarnings("unchecked")
+ protected Widget newDragProxy(DragContext context) {
+
+ draggableTable = (FixedWidthGrid) context.draggable.getParent();
+ parentTable = (PagingScrollTable)draggableTable.getParent();
+ RoundedPanel proxyPanel = new RoundedPanel(RoundedPanel.ALL,1);
+ HorizontalPanel proxy = new HorizontalPanel();
+ proxy.add(bundle.moveMailIcon().createImage());
+ proxy.add(new Label(" " + messages.moveMessage()));
+ dragRow = getWidgetRow(context.draggable);
+ proxyPanel.add(proxy);
+ proxyPanel.setBorder();
+ proxyPanel.setWidth("150px");
+ return proxyPanel;
+ }
+
+ private int getWidgetRow(Widget widget) {
+ FixedWidthGrid grid = draggableTable;
+ for (int row = 0; row < grid.getRowCount(); row++) {
+ for (int col = 0; col < grid.getCellCount(row); col++) {
+ Widget w = grid.getWidget(row, col);
+ if (w == widget) {
+ return row;
+ }
+ }
+ }
+ throw new RuntimeException("Unable to determine widget row");
+ }
+
+
+
+ public Object getDragValue() {
+ return parentTable.getRowValue(dragRow);
+ }
+
+}
\ No newline at end of file
Modified:
labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/gin/HupaClientModule.java
Thu Aug 13 14:07:30 2009
@@ -25,6 +25,7 @@
import net.customware.gwt.presenter.client.place.PlaceManager;
import org.apache.hupa.client.CachingDispatchAsync;
+import org.apache.hupa.client.dnd.PagingScrollTableRowDragController;
import org.apache.hupa.client.mvp.AppPresenter;
import org.apache.hupa.client.mvp.IMAPFolderPresenter;
import org.apache.hupa.client.mvp.IMAPFolderView;
@@ -55,7 +56,7 @@
bindPresenter(IMAPFolderPresenter.class,
IMAPFolderPresenter.Display.class, IMAPFolderView.class);
bind(AppPresenter.class).in(Singleton.class);
bind(CachingDispatchAsync.class);
-
+
bind(PagingScrollTableRowDragController.class).in(Singleton.class);
}
}
Modified: labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPFolderView.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPFolderView.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPFolderView.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPFolderView.java Thu
Aug 13 14:07:30 2009
@@ -19,14 +19,29 @@
package org.apache.hupa.client.mvp;
+import java.util.ArrayList;
import java.util.List;
+import net.customware.gwt.presenter.client.EventBus;
+
import org.apache.hupa.client.bundles.IMAPTreeImages;
+import org.apache.hupa.client.dnd.PagingScrollTableRowDragController;
import org.apache.hupa.client.mvp.IMAPFolderPresenter.Display;
import org.apache.hupa.client.widgets.IMAPTreeItem;
import org.apache.hupa.client.widgets.Loading;
import org.apache.hupa.shared.data.IMAPFolder;
-
+import org.apache.hupa.shared.data.IMAPMessage;
+import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.events.LoginEvent;
+import org.apache.hupa.shared.events.LoginEventHandler;
+import org.apache.hupa.shared.events.LogoutEvent;
+import org.apache.hupa.shared.events.LogoutEventHandler;
+import org.apache.hupa.shared.events.MoveMessageEvent;
+
+import com.allen_sauer.gwt.dnd.client.DragContext;
+import com.allen_sauer.gwt.dnd.client.VetoDragException;
+import com.allen_sauer.gwt.dnd.client.drop.DropController;
+import com.allen_sauer.gwt.dnd.client.drop.SimpleDropController;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
import com.google.gwt.user.client.ui.Composite;
@@ -34,16 +49,40 @@
import com.google.gwt.user.client.ui.Tree;
import com.google.gwt.user.client.ui.TreeItem;
import com.google.gwt.user.client.ui.Widget;
+import com.google.inject.Inject;
public class IMAPFolderView extends Composite implements Display{
private IMAPTreeImages tImages = GWT.create(IMAPTreeImages.class);
private Tree folderTree = new Tree(tImages,true);
private SimplePanel panel = new SimplePanel();
+
private Loading loader = new Loading(false);
- public IMAPFolderView() {
+ private List<DropController> dropControllerList = new
ArrayList<DropController>();
+ private EventBus bus;
+ private PagingScrollTableRowDragController controller;
+ protected User user;
+
+ @Inject
+ public IMAPFolderView(EventBus bus, PagingScrollTableRowDragController
controllerProvider) {
folderTree.setAnimationEnabled(true);
panel.add(loader);
+ this.controller = controllerProvider;
+ this.bus = bus;
+ bus.addHandler(LoginEvent.TYPE,new LoginEventHandler() {
+
+ public void onLogin(LoginEvent event) {
+ user = event.getUser();
+ }
+
+ });
+ bus.addHandler(LogoutEvent.TYPE,new LogoutEventHandler() {
+
+ public void onLogout(LogoutEvent event) {
+ user = null;
+ }
+
+ });
initWidget(panel);
}
@@ -53,9 +92,15 @@
*/
public void bindTreeItems(List<IMAPTreeItem> treeList) {
folderTree.clear();
+ for (int i = 0; i < dropControllerList.size();i++) {
+
controller.unregisterDropController(dropControllerList.get(i));
+ }
for (int i = 0; i < treeList.size(); i++) {
IMAPTreeItem item = treeList.get(i);
+ IMAPFolderDropController dropController = new
IMAPFolderDropController(item);
+ controller.registerDropController(dropController);
+ dropControllerList.add(dropController);
folderTree.addItem(item);
if (((IMAPFolder)
item.getUserObject()).getFullName().equalsIgnoreCase(IMAPFolder.DEFAULT_INBOX))
{
folderTree.setSelectedItem(item, false);
@@ -97,5 +142,38 @@
panel.clear();
panel.add(folderTree);
}
+
+ private class IMAPFolderDropController extends SimpleDropController {
+ private IMAPTreeItem item;
+
+ public IMAPFolderDropController(IMAPTreeItem item) {
+ super(item.getWidget());
+ this.item = item;
+ }
+
+ public void onPreviewDrop(DragContext context) throws
VetoDragException {
+ if (item.equals(folderTree.getSelectedItem())) {
+ throw new VetoDragException();
+ }
+ }
+
+ public void onDrop(DragContext context) {
+ bus.fireEvent(new
MoveMessageEvent(user,(IMAPFolder)folderTree.getSelectedItem().getUserObject(),(IMAPFolder)item.getUserObject(),(IMAPMessage)controller.getDragValue()));
+ }
+
+ @Override
+ public void onEnter(DragContext context) {
+
context.selectedWidgets.get(0).removeStyleName("hupa-droptarget-invalid");
+ super.onEnter(context);
+ }
+ @Override
+ public void onLeave(DragContext context) {
+
context.selectedWidgets.get(0).addStyleName("hupa-droptarget-invalid");
+ super.onLeave(context);
+ }
+
+
+
+ }
}
Modified:
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
(original)
+++
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListPresenter.java
Thu Aug 13 14:07:30 2009
@@ -41,10 +41,15 @@
import org.apache.hupa.shared.events.LoginEventHandler;
import org.apache.hupa.shared.events.LogoutEvent;
import org.apache.hupa.shared.events.LogoutEventHandler;
+import org.apache.hupa.shared.events.MoveMessageEvent;
+import org.apache.hupa.shared.events.MoveMessageEventHandler;
import org.apache.hupa.shared.events.NewMessageEvent;
import org.apache.hupa.shared.rpc.DeleteMessage;
import org.apache.hupa.shared.rpc.DeleteMessageResult;
+import org.apache.hupa.shared.rpc.MoveMessage;
+import org.apache.hupa.shared.rpc.MoveMessageResult;
+import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.HasClickHandlers;
@@ -53,6 +58,7 @@
import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
import com.google.gwt.gen2.table.event.client.TableEvent.Row;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
import com.google.inject.Inject;
@@ -127,6 +133,29 @@
});
+ eventBus.addHandler(MoveMessageEvent.TYPE, new
MoveMessageEventHandler() {
+
+ public void onMoveMessageHandler(MoveMessageEvent
event) {
+ final long uid = event.getMessage().getUid();
+ GWT.log("Start moving",null);
+ dispatcher.execute(new
MoveMessage(event.getUser().getSessionId(),event.getOldFolder(),event.getNewFolder(),uid),
new AsyncCallback<MoveMessageResult>() {
+
+ public void onFailure(Throwable caught)
{
+ GWT.log("ERROR while
moving",caught);
+ }
+
+ public void onSuccess(MoveMessageResult
result) {
+ ArrayList<Long> uidArray = new
ArrayList<Long>();
+ uidArray.add(uid);
+
display.removeMessages(uidArray);
+ GWT.log("Stop moving",null);
+
+ }
+
+ });
+ }
+
+ });
display.addTableListner(new TableListener() {
public void onCellClicked(SourcesTableEvents sender,
int row,
Modified:
labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/client/mvp/IMAPMessageListView.java
Thu Aug 13 14:07:30 2009
@@ -31,10 +31,12 @@
import org.apache.hupa.client.HupaMessages;
import org.apache.hupa.client.bundles.HupaImageBundle;
import org.apache.hupa.client.bundles.MyPagingOptionImages;
+import org.apache.hupa.client.dnd.DragRefetchPagingScrollTable;
+import org.apache.hupa.client.dnd.PagingScrollTableRowDragController;
+import
org.apache.hupa.client.dnd.DragRefetchPagingScrollTable.DragHandlerFactory;
import org.apache.hupa.client.mvp.IMAPMessageListPresenter.Display;
import org.apache.hupa.client.widgets.ConfirmDialogBox;
import org.apache.hupa.client.widgets.HasDialog;
-import org.apache.hupa.client.widgets.RefetchPagingScrollTable;
import org.apache.hupa.shared.data.IMAPFolder;
import org.apache.hupa.shared.data.IMAPMessage;
import org.apache.hupa.shared.data.User;
@@ -61,7 +63,6 @@
import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
import com.google.gwt.gen2.table.client.MutableTableModel;
import com.google.gwt.gen2.table.client.PagingOptions;
-import com.google.gwt.gen2.table.client.TableDefinition;
import com.google.gwt.gen2.table.client.TableModelHelper;
import com.google.gwt.gen2.table.client.AbstractScrollTable.ColumnResizePolicy;
import com.google.gwt.gen2.table.client.AbstractScrollTable.ResizePolicy;
@@ -88,6 +89,8 @@
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
@SuppressWarnings("deprecation")
public class IMAPMessageListView extends Composite implements Display{
@@ -100,7 +103,7 @@
private IMAPFolder folder;
private String searchValue;
- private RefetchPagingScrollTable<IMAPMessage> mailTable;
+ private DragRefetchPagingScrollTable<IMAPMessage> mailTable;
private CachedTableModel<IMAPMessage> cTableModel = new
CachedTableModel<IMAPMessage>(new IMAPMessageTableModel());
private EventBus bus;
@@ -109,25 +112,33 @@
private Button newMailButton = new Button(constants.newMailButton());
private ConfirmDialogBox confirmBox = new ConfirmDialogBox();
private ListBox pageBox = new ListBox();
+ private PagingScrollTableRowDragController controller;
@Inject
- public IMAPMessageListView(DispatchAsync dispatcher,EventBus bus) {
+ public IMAPMessageListView(DispatchAsync dispatcher,EventBus bus,
PagingScrollTableRowDragController controller) {
this.bus = bus;
this.dispatcher = dispatcher;
+ this.controller = controller;
+ //this.controller = controllerProvider.get();
VerticalPanel vPanel = new VerticalPanel();
cTableModel.setPostCachedRowCount(50);
cTableModel.setRowCount(MutableTableModel.UNKNOWN_ROW_COUNT);
-
- mailTable = new RefetchPagingScrollTable<IMAPMessage>(
+ mailTable = new DragRefetchPagingScrollTable<IMAPMessage>(
cTableModel, dataTable,
createHeaderTable(),
- createTableDefinitation());
+ createTableDefinitation(),controller,1);
mailTable.setPageSize(20);
-
+ mailTable.setDragHandler(0,30, new DragHandlerFactory() {
+
+ public Widget createHandler() {
+ return new
HTML(imageBundle.readyToMoveMailIcon().getHTML());
+ }
+
+ });
HTML emptyTable = new HTML(constants.emptyMailTable());
emptyTable.setHorizontalAlignment(HTML.ALIGN_CENTER);
@@ -140,7 +151,6 @@
mailTable.setResizePolicy(ResizePolicy.FILL_WIDTH);
mailTable.setColumnResizePolicy(ColumnResizePolicy.MULTI_CELL);
mailTable.setScrollPolicy(ScrollPolicy.DISABLED);
-
mailTable.addPageLoadHandler(new PageLoadHandler() {
public void onPageLoad(PageLoadEvent event) {
@@ -223,7 +233,7 @@
initWidget(vPanel);
}
- private TableDefinition<IMAPMessage> createTableDefinitation() {
+ private DefaultTableDefinition<IMAPMessage> createTableDefinitation() {
DefaultTableDefinition<IMAPMessage> def = new
DefaultTableDefinition<IMAPMessage>(createColumnDefinitionList());
return def;
Modified: labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java?rev=803894&r1=803893&r2=803894&view=diff
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java
(original)
+++ labs/hupa/src/main/java/org/apache/hupa/server/guice/ServerModul.java Thu
Aug 13 14:07:30 2009
@@ -35,6 +35,7 @@
import org.apache.hupa.server.handler.LoginSessionHandler;
import org.apache.hupa.server.handler.LoginUserHandler;
import org.apache.hupa.server.handler.LogoutUserHandler;
+import org.apache.hupa.server.handler.MoveMessageHandler;
import org.apache.hupa.server.handler.NoopHandler;
import org.apache.hupa.server.handler.ReplyMessageHandler;
import org.apache.hupa.server.handler.SendMessageHandler;
@@ -66,7 +67,7 @@
bindHandler(ForwardMessageHandler.class);
bindHandler(NoopHandler.class);
bindHandler(LoginSessionHandler.class);
-
+ bindHandler(MoveMessageHandler.class);
bind(FileItemRegistry.class).in(Singleton.class);
bind(IMAPStoreCache.class).in(Singleton.class);
bind(Log.class).toProvider(LogProvider.class).in(Singleton.class);
Added:
labs/hupa/src/main/java/org/apache/hupa/server/handler/MoveMessageHandler.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/handler/MoveMessageHandler.java?rev=803894&view=auto
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/server/handler/MoveMessageHandler.java
(added)
+++
labs/hupa/src/main/java/org/apache/hupa/server/handler/MoveMessageHandler.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,83 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.server.handler;
+
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.servlet.http.HttpSession;
+
+import net.customware.gwt.dispatch.server.ExecutionContext;
+import net.customware.gwt.dispatch.shared.ActionException;
+
+import org.apache.commons.logging.Log;
+import org.apache.hupa.server.IMAPStoreCache;
+import org.apache.hupa.shared.data.User;
+import org.apache.hupa.shared.rpc.MoveMessage;
+import org.apache.hupa.shared.rpc.MoveMessageResult;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.sun.mail.imap.IMAPFolder;
+import com.sun.mail.imap.IMAPStore;
+
+public class MoveMessageHandler extends AbstractSessionHandler<MoveMessage,
MoveMessageResult>{
+
+ @Inject
+ public MoveMessageHandler(IMAPStoreCache cache, Log logger,
+ Provider<HttpSession> sessionProvider) {
+ super(cache, logger, sessionProvider);
+ }
+
+ @Override
+ protected MoveMessageResult executeInternal(MoveMessage action,
+ ExecutionContext context) throws ActionException {
+ User user = getUser(action.getSessionId());
+ try {
+ IMAPStore store = cache.get(user);
+ IMAPFolder folder =
(IMAPFolder)store.getFolder(action.getOldFolder().getFullName());
+ if (folder.isOpen() == false) {
+ folder.open(Folder.READ_WRITE);
+ }
+ Message m =
folder.getMessageByUID(action.getMessageUid());
+ Message[] mArray = new Message[] {m};
+ folder.copyMessages(mArray,
store.getFolder(action.getNewFolder().getFullName()));
+ folder.setFlags(mArray, new Flags(Flags.Flag.DELETED),
true);
+ folder.expunge(mArray);
+ folder.close(true);
+ return new MoveMessageResult();
+ } catch (MessagingException e) {
+ logger.error("Error while moving message " +
action.getMessageUid() + " from folder" + action.getOldFolder() + " to " +
action.getNewFolder(),e);
+ throw new ActionException(e);
+ }
+ }
+
+ public Class<MoveMessage> getActionType() {
+ return MoveMessage.class;
+ }
+
+ public void rollback(MoveMessage arg0, MoveMessageResult arg1,
+ ExecutionContext arg2) throws ActionException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Added:
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEvent.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEvent.java?rev=803894&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEvent.java
(added)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEvent.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,69 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.shared.events;
+
+import org.apache.hupa.shared.data.IMAPFolder;
+import org.apache.hupa.shared.data.IMAPMessage;
+import org.apache.hupa.shared.data.User;
+
+import com.google.gwt.event.shared.GwtEvent;
+
+public class MoveMessageEvent extends GwtEvent<MoveMessageEventHandler> {
+
+ public final static Type<MoveMessageEventHandler> TYPE = new
Type<MoveMessageEventHandler>();
+ private User user;
+ private IMAPFolder oldFolder;
+ private IMAPFolder newFolder;
+ private IMAPMessage message;
+
+ public MoveMessageEvent(User user, IMAPFolder oldFolder,
+ IMAPFolder newFolder, IMAPMessage message) {
+ this.user = user;
+ this.oldFolder = oldFolder;
+ this.newFolder = newFolder;
+ this.message = message;
+ }
+
+ public User getUser() {
+ return user;
+ }
+
+ public IMAPFolder getOldFolder() {
+ return oldFolder;
+ }
+
+ public IMAPFolder getNewFolder() {
+ return newFolder;
+ }
+
+ public IMAPMessage getMessage() {
+ return message;
+ }
+
+ protected void dispatch(MoveMessageEventHandler handler) {
+ handler.onMoveMessageHandler(this);
+ }
+
+ @Override
+ public
com.google.gwt.event.shared.GwtEvent.Type<MoveMessageEventHandler>
getAssociatedType() {
+ return TYPE;
+ }
+
+}
Added:
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEventHandler.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEventHandler.java?rev=803894&view=auto
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEventHandler.java
(added)
+++
labs/hupa/src/main/java/org/apache/hupa/shared/events/MoveMessageEventHandler.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,27 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.shared.events;
+
+import com.google.gwt.event.shared.EventHandler;
+
+public interface MoveMessageEventHandler extends EventHandler{
+
+ public void onMoveMessageHandler(MoveMessageEvent event);
+}
Added: labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessage.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessage.java?rev=803894&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessage.java (added)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessage.java Thu Aug
13 14:07:30 2009
@@ -0,0 +1,56 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.shared.rpc;
+
+import org.apache.hupa.shared.data.IMAPFolder;
+
+public class MoveMessage extends Session<MoveMessageResult>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 7771146077050895244L;
+ private IMAPFolder oldFolder;
+ private IMAPFolder newFolder;
+ private long messageUid;
+
+ public MoveMessage(String sessionId,IMAPFolder oldFolder, IMAPFolder
newFolder, long messageUid) {
+ super(sessionId);
+ this.oldFolder = oldFolder;
+ this.newFolder = newFolder;
+ this.messageUid = messageUid;
+ }
+
+ protected MoveMessage() {
+
+ }
+
+ public long getMessageUid() {
+ return messageUid;
+ }
+
+ public IMAPFolder getOldFolder() {
+ return oldFolder;
+ }
+
+ public IMAPFolder getNewFolder() {
+ return newFolder;
+ }
+}
Added: labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessageResult.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessageResult.java?rev=803894&view=auto
==============================================================================
--- labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessageResult.java
(added)
+++ labs/hupa/src/main/java/org/apache/hupa/shared/rpc/MoveMessageResult.java
Thu Aug 13 14:07:30 2009
@@ -0,0 +1,29 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.hupa.shared.rpc;
+
+public class MoveMessageResult extends EmptyResult{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 341407423455525004L;
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]