[kune-commits] r1773 - in trunk/src/main/java/cc/kune: chat/client core/client/dnd core/client/errors core/client/rpcservices core/server/access core/server/content core/server/rpc core/shared/dto domain gspace/client/actions gspace/client/tool/selector tasks/client/actions trash/client
Vicente J. Ruiz Jurado
vjrj_ at ourproject.org
Tue Mar 20 13:38:51 CET 2012
Author: vjrj_
Date: 2012-03-20 13:38:50 +0100 (Tue, 20 Mar 2012)
New Revision: 1773
Added:
trunk/src/main/java/cc/kune/core/client/errors/CannotDeleteDefaultContentException.java
trunk/src/main/java/cc/kune/core/client/errors/ContainerNotEmptyException.java
trunk/src/main/java/cc/kune/tasks/client/actions/DelTaskMenuItem.java
Modified:
trunk/src/main/java/cc/kune/chat/client/ChatInstances.java
trunk/src/main/java/cc/kune/core/client/dnd/FolderContainerDropController.java
trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
trunk/src/main/java/cc/kune/core/client/rpcservices/ContentServiceHelper.java
trunk/src/main/java/cc/kune/core/server/access/FinderService.java
trunk/src/main/java/cc/kune/core/server/access/FinderServiceDefault.java
trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java
trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rpc/ContentRPC.java
trunk/src/main/java/cc/kune/core/shared/dto/ContainerDTO.java
trunk/src/main/java/cc/kune/domain/Container.java
trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java
trunk/src/main/java/cc/kune/gspace/client/actions/DelContentMenuItem.java
trunk/src/main/java/cc/kune/gspace/client/actions/GoParentContainerBtn.java
trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerBtn.java
trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerMenuItem.java
trunk/src/main/java/cc/kune/gspace/client/actions/NewContentAction.java
trunk/src/main/java/cc/kune/gspace/client/actions/RenameAction.java
trunk/src/main/java/cc/kune/gspace/client/actions/SetAsHomePageMenuItem.java
trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java
trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java
trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPanel.java
trunk/src/main/java/cc/kune/tasks/client/actions/TasksClientActions.java
trunk/src/main/java/cc/kune/trash/client/TrashClientTool.java
Log:
NEW - # 222: Create a trash folder icon and improve contents delete functionality
http://kune.ourproject.org/issues/ticket/222
Modified: trunk/src/main/java/cc/kune/chat/client/ChatInstances.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/ChatInstances.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/chat/client/ChatInstances.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -34,6 +34,7 @@
import com.calclab.suco.client.Suco;
import com.google.inject.Provider;
+ at SuppressWarnings("deprecation")
public class ChatInstances {
public static class AvatarManagerProvider implements Provider<AvatarManager> {
Modified: trunk/src/main/java/cc/kune/core/client/dnd/FolderContainerDropController.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/dnd/FolderContainerDropController.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/client/dnd/FolderContainerDropController.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -29,7 +29,9 @@
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.StateContainerDTO;
+import cc.kune.gspace.client.tool.selector.ToolSelectorItemPanel;
import cc.kune.gspace.client.viewers.items.FolderItemWidget;
+import cc.kune.trash.shared.TrashToolConstants;
import com.allen_sauer.gwt.dnd.client.drop.SimpleDropController;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -64,36 +66,60 @@
this.contentCache = contentCache;
}
+ private void move(final Widget widget, final StateToken destToken) {
+ widget.removeFromParent();
+ final StateToken tokenToMove = ((FolderItemWidget) widget).getToken();
+ contentService.moveContent(session.getUserHash(), tokenToMove, destToken,
+ new AsyncCallback<StateContainerDTO>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ erroHandler.process(caught);
+ stateManager.refreshCurrentState();
+ NotifyUser.hideProgress();
+ }
+
+ @Override
+ public void onSuccess(final StateContainerDTO result) {
+ NotifyUser.hideProgress();
+ contentCache.remove(tokenToMove);
+ contentCache.remove(destToken);
+ }
+ });
+ }
+
+ private void notImplemented() {
+ NotifyUser.info(i18n.t(TextUtils.IN_DEVELOPMENT));
+ NotifyUser.hideProgress();
+ }
+
@Override
public void onDropAllowed(final Widget widget, final SimpleDropController dropController) {
dropController.getDropTarget().removeStyleName("k-drop-allowed-hover");
if (widget instanceof FolderItemWidget) {
NotifyUser.showProgress(i18n.t("Moving"));
if (getTarget() != null) {
- final StateToken destToken = (StateToken) getTarget();
- widget.removeFromParent();
- final StateToken tokenToMove = ((FolderItemWidget) widget).getToken();
- contentService.moveContent(session.getUserHash(), tokenToMove, destToken,
- new AsyncCallback<StateContainerDTO>() {
- @Override
- public void onFailure(final Throwable caught) {
- erroHandler.process(caught);
- stateManager.refreshCurrentState();
- NotifyUser.hideProgress();
- }
-
- @Override
- public void onSuccess(final StateContainerDTO result) {
- NotifyUser.hideProgress();
- contentCache.remove(tokenToMove);
- contentCache.remove(destToken);
- }
- });
+ StateToken destToken;
+ if (getTarget() instanceof StateToken) {
+ destToken = (StateToken) getTarget();
+ } else if (getTarget() instanceof ToolSelectorItemPanel) {
+ destToken = new StateToken(session.getCurrentGroupShortName(),
+ ((ToolSelectorItemPanel) getTarget()).getName());
+ if (!destToken.getTool().equals(TrashToolConstants.NAME)) {
+ // By now only move to trash
+ notImplemented();
+ return;
+ }
+ } else {
+ // No implemented
+ notImplemented();
+ return;
+ }
+ move(widget, destToken);
} else {
- NotifyUser.info(i18n.t(TextUtils.IN_DEVELOPMENT));
- NotifyUser.hideProgress();
+ notImplemented();
}
+ } else {
+ notImplemented();
}
}
-
}
Added: trunk/src/main/java/cc/kune/core/client/errors/CannotDeleteDefaultContentException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/CannotDeleteDefaultContentException.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/CannotDeleteDefaultContentException.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+/**
+ * The Class ContainerNotEmptyException throwed when people try to remove
+ * folders that not are empty
+ */
+public class CannotDeleteDefaultContentException extends DefaultException {
+
+ private static final long serialVersionUID = -8266435530937045998L;
+
+}
Added: trunk/src/main/java/cc/kune/core/client/errors/ContainerNotEmptyException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ContainerNotEmptyException.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/ContainerNotEmptyException.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -0,0 +1,30 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+/**
+ * The Class ContainerNotEmptyException throwed when people try to remove
+ * folders that not are empty
+ */
+public class ContainerNotEmptyException extends DefaultException {
+
+ private static final long serialVersionUID = 2589365980768175735L;
+
+}
Modified: trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -141,6 +141,14 @@
} else if (caught instanceof NameNotPermittedException) {
logException(caught);
eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.info, i18n.t("This name is not permitted")));
+ } else if (caught instanceof ContainerNotEmptyException) {
+ logException(caught);
+ eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.error, i18n.t("This is not empty")));
+ } else if (caught instanceof CannotDeleteDefaultContentException) {
+ logException(caught);
+ eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.error,
+ i18n.t("This is the default content of the group, you cannot delete it. "
+ + "Please select other content as default group content before delete this")));
} else if (caught instanceof UnderDevelopmentException) {
logException(caught);
eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.info, i18n.t(TextUtils.IN_DEVELOPMENT)));
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/ContentServiceHelper.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/ContentServiceHelper.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/ContentServiceHelper.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -4,11 +4,13 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.client.utils.OnAcceptCallback;
import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.client.state.ContentCache;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.SocialNetworkSubGroup;
import cc.kune.core.shared.dto.StateContainerDTO;
+import cc.kune.gspace.client.viewers.FolderViewerPresenter;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -17,8 +19,10 @@
public class ContentServiceHelper {
+ private final ContentCache cache;
private final Provider<ContentServiceAsync> contentService;
private final EventBus eventBus;
+ private final FolderViewerPresenter folderViewer;
private final I18nTranslationService i18n;
private final Session session;
private final StateManager stateManager;
@@ -26,7 +30,9 @@
@Inject
public ContentServiceHelper(final Session session, final I18nTranslationService i18n,
final EventBus eventBus, final Provider<ContentServiceAsync> contentService,
- final StateManager stateManager) {
+ final ContentCache cache, final FolderViewerPresenter folderViewer, final StateManager stateManager) {
+ this.cache = cache;
+ this.folderViewer = folderViewer;
this.session = session;
this.i18n = i18n;
this.eventBus = eventBus;
@@ -34,6 +40,26 @@
this.stateManager = stateManager;
}
+ public void addContainer(final String id, final String newName) {
+ NotifyUser.showProgress();
+ // stateManager.gotoStateToken(((HasContent)
+ // session.getCurrentState()).getContainer().getStateToken());
+ final StateToken parentToken = session.getCurrentStateToken();
+ contentService.get().addFolder(session.getUserHash(), parentToken, newName, id,
+ new AsyncCallbackSimple<StateContainerDTO>() {
+ @Override
+ public void onSuccess(final StateContainerDTO state) {
+ stateManager.removeCache(parentToken);
+ stateManager.setRetrievedStateAndGo(state);
+ NotifyUser.hideProgress();
+ // NotifyUser.info(i18n.tWithNT("[%s] created",
+ // "New folder created, for instance", newName));
+ folderViewer.highlightTitle();
+ }
+ });
+ cache.remove(parentToken);
+ }
+
public void addParticipants(final StateToken token, final SocialNetworkSubGroup subGroup) {
contentService.get().addParticipants(session.getUserHash(), token,
session.getCurrentGroupShortName(), subGroup, new AsyncCallback<Boolean>() {
@@ -60,6 +86,14 @@
contentService.get().delContent(session.getUserHash(), token,
new AsyncCallbackSimple<StateContainerDTO>() {
@Override
+ public void onFailure(final Throwable caught) {
+ // Should we do something with
+ // ContainerNotEmptyException?
+ super.onFailure(caught);
+ NotifyUser.hideProgress();
+ }
+
+ @Override
public void onSuccess(final StateContainerDTO state) {
final StateToken parentToken = state.getStateToken();
if (session.getCurrentStateToken().equals(parentToken)) {
Modified: trunk/src/main/java/cc/kune/core/server/access/FinderService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/access/FinderService.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/server/access/FinderService.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -19,6 +19,7 @@
*/
package cc.kune.core.server.access;
+import cc.kune.core.client.errors.ContentNotFoundException;
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.domain.Container;
@@ -29,12 +30,18 @@
public interface FinderService {
+ Content findByRootOnGroup(String groupName, String toolName) throws DefaultException;
+
Container getContainer(Long folderId) throws DefaultException;
+ Container getContainer(String folderId);
+
Content getContent(Long contentId) throws DefaultException;
Content getContent(StateToken token, Group defaultGroup) throws DefaultException;
+ Content getContent(String contentId) throws ContentNotFoundException;
+
Container getFolder(Long folderId) throws DefaultException;
Rate getRate(User user, Content content);
Modified: trunk/src/main/java/cc/kune/core/server/access/FinderServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/access/FinderServiceDefault.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/server/access/FinderServiceDefault.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -29,6 +29,7 @@
import cc.kune.core.client.errors.ToolNotFoundException;
import cc.kune.core.server.content.ContainerManager;
import cc.kune.core.server.content.ContentManager;
+import cc.kune.core.server.content.ContentUtils;
import cc.kune.core.server.manager.GroupManager;
import cc.kune.core.server.manager.RateManager;
import cc.kune.core.shared.domain.utils.StateToken;
@@ -97,7 +98,8 @@
}
}
- private Content findByRootOnGroup(final String groupName, final String toolName)
+ @Override
+ public Content findByRootOnGroup(final String groupName, final String toolName)
throws DefaultException {
try {
final Group group = groupManager.findByShortName(groupName);
@@ -132,6 +134,16 @@
}
@Override
+ public Container getContainer(final Long folderId) throws DefaultException {
+ return getFolder(folderId);
+ }
+
+ @Override
+ public Container getContainer(final String folderId) throws DefaultException {
+ return getContainer(ContentUtils.parseId(folderId));
+ }
+
+ @Override
public Content getContent(final Long contentId) throws ContentNotFoundException {
try {
return contentManager.find(contentId);
@@ -162,6 +174,11 @@
}
@Override
+ public Content getContent(final String contentId) throws ContentNotFoundException {
+ return getContent(ContentUtils.parseId(contentId));
+ }
+
+ @Override
public Container getFolder(final Long folderId) throws ContentNotFoundException {
try {
return containerManager.find(folderId);
@@ -186,9 +203,4 @@
return rateManager.getRateByUsers(content);
}
- @Override
- public Container getContainer(Long folderId) throws DefaultException {
- return getFolder(folderId);
- }
-
}
Modified: trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/server/content/ContainerManager.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -39,7 +39,7 @@
boolean hasTrashFolder(Group group);
- void moveContainer(Container container, Container newContainer);
+ Container moveContainer(Container container, Container newContainer);
Container renameFolder(Group group, Container container, String newName) throws DefaultException;
Modified: trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/server/content/ContainerManagerDefault.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -110,7 +110,7 @@
}
@Override
- public void moveContainer(final Container container, final Container newContainer) {
+ public Container moveContainer(final Container container, final Container newContainer) {
if (newContainer.equals(container.getParent())) {
throw new MoveOnSameContainerException();
}
@@ -125,7 +125,8 @@
final Container oldContainer = container.getParent();
oldContainer.removeChild(container);
newContainer.addChild(container);
- persist(container);
+ container.setParent(newContainer);
+ return persist(container);
}
@Override
Modified: trunk/src/main/java/cc/kune/core/server/rpc/ContentRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/ContentRPC.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/server/rpc/ContentRPC.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -27,6 +27,8 @@
import cc.kune.chat.server.ChatManager;
import cc.kune.core.client.errors.AccessViolationException;
+import cc.kune.core.client.errors.CannotDeleteDefaultContentException;
+import cc.kune.core.client.errors.ContainerNotEmptyException;
import cc.kune.core.client.errors.ContentNotFoundException;
import cc.kune.core.client.errors.ContentNotPermittedException;
import cc.kune.core.client.errors.DefaultException;
@@ -72,6 +74,7 @@
import cc.kune.domain.Content;
import cc.kune.domain.Group;
import cc.kune.domain.User;
+import cc.kune.trash.shared.TrashToolConstants;
import com.google.inject.Inject;
@@ -253,21 +256,25 @@
@Override
@Authenticated
- @Authorizated(accessRolRequired = AccessRol.Administrator)
+ @Authorizated(actionLevel = ActionLevel.container, accessRolRequired = AccessRol.Editor)
@KuneTransactional
public StateContainerDTO delContent(final String userHash, final StateToken token)
throws DefaultException {
- final Long contentId = ContentUtils.parseId(token.getDocument());
- final Content content = finderService.getContent(contentId);
- contentManager.setStatus(contentId, ContentStatus.inTheDustbin);
- final Container previousParent = content.getContainer();
+ final boolean isContent = token.hasAll();
+ Container previousParent;
+ if (isContent) {
+ final Content content = setStatusInTheDustbin(token);
+ previousParent = content.getContainer();
+ } else {
+ previousParent = finderService.getContainer(token.getFolder());
+ }
final Group group = previousParent.getOwner();
if (!containerManager.hasTrashFolder(group)) {
groupManager.initTrash(group);
}
final Container trash = containerManager.getTrashFolder(group);
- moveContent(userHash, token, trash.getStateToken());
- return getState(getCurrentUser(), previousParent);
+ return moveContent(userHash, token, trash.getStateToken());
+ // return getState(getCurrentUser(), previousParent);
}
@Override
@@ -395,24 +402,42 @@
public StateContainerDTO moveContent(final String userHash, final StateToken movedToken,
final StateToken newContainerToken) throws DefaultException {
final User user = getCurrentUser();
+ final boolean toTrash = newContainerToken.getTool().equals(TrashToolConstants.NAME);
+ // Search the container id (because sometimes we get only #group.tool
+ // tokens)
+ final Long newContainerId = newContainerToken.hasGroupToolAndFolder() ? ContentUtils.parseId(newContainerToken.getFolder())
+ : finderService.findByRootOnGroup(newContainerToken.getGroup(), newContainerToken.getTool()).getContainer().getId();
try {
if (movedToken.isComplete()) {
- final Content content = accessService.accessToContent(
- ContentUtils.parseId(movedToken.getDocument()), user, AccessRol.Editor);
- final Container newContainer = accessService.accessToContainer(
- ContentUtils.parseId(newContainerToken.getFolder()), user, AccessRol.Editor);
+ final Long contentId = ContentUtils.parseId(movedToken.getDocument());
+ final Content content = accessService.accessToContent(contentId, user, AccessRol.Editor);
+
+ if (content.equals(content.getContainer().getOwner().getDefaultContent())) {
+ throw new CannotDeleteDefaultContentException();
+ }
+
+ final Container newContainer = accessService.accessToContainer(newContainerId, user,
+ AccessRol.Editor);
+
final Container oldContainer = content.getContainer();
+ if (toTrash) {
+ // Remove operation
+ setStatusInTheDustbin(movedToken);
+ }
contentManager.moveContent(content, newContainer);
return getState(user, oldContainer);
} else if (movedToken.hasGroupToolAndFolder()) {
- // Folder to folder
+ // Folder to folder move
final Container container = accessService.accessToContainer(
ContentUtils.parseId(movedToken.getFolder()), user, AccessRol.Editor);
- final Container newContainer = accessService.accessToContainer(
- ContentUtils.parseId(newContainerToken.getFolder()), user, AccessRol.Editor);
final Container oldParent = container.getParent();
+ if (toTrash && !container.isLeaf()) {
+ throw new ContainerNotEmptyException();
+ }
+ final Container newContainer = accessService.accessToContainer(newContainerId, user,
+ AccessRol.Editor);
containerManager.moveContainer(container, newContainer);
- return getState(user, oldParent);
+ return getState(user, finderService.getContainer(oldParent.getId()));
} else {
throw new ContentNotPermittedException();
}
@@ -581,6 +606,13 @@
return getState(getCurrentUser(), content);
}
+ private Content setStatusInTheDustbin(final StateToken token) {
+ final Long contentId = ContentUtils.parseId(token.getDocument());
+ final Content content = finderService.getContent(contentId);
+ contentManager.setStatus(contentId, ContentStatus.inTheDustbin);
+ return content;
+ }
+
@Override
@Authenticated
@Authorizated(accessRolRequired = AccessRol.Editor, mustCheckMembership = false)
Modified: trunk/src/main/java/cc/kune/core/shared/dto/ContainerDTO.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/dto/ContainerDTO.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/core/shared/dto/ContainerDTO.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -31,7 +31,7 @@
private List<ContentSimpleDTO> contents;
private Long id;
private String name;
- private Long parentFolderId;
+ private StateToken parentToken;
private StateToken stateToken;
private String typeId;
@@ -58,8 +58,8 @@
return name;
}
- public Long getParentFolderId() {
- return parentFolderId;
+ public StateToken getParentToken() {
+ return parentToken;
}
public StateToken getStateToken() {
@@ -71,7 +71,7 @@
}
public boolean isRoot() {
- return parentFolderId == null;
+ return parentToken == null;
}
public void setAbsolutePath(final ContainerSimpleDTO[] absolutePath) {
@@ -94,8 +94,8 @@
this.name = name;
}
- public void setParentFolderId(final Long parentFolderId) {
- this.parentFolderId = parentFolderId;
+ public void setParentToken(final StateToken parentToken) {
+ this.parentToken = parentToken;
}
public void setStateToken(final StateToken stateToken) {
Modified: trunk/src/main/java/cc/kune/domain/Container.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/Container.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/domain/Container.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -202,8 +202,8 @@
return parent;
}
- public Long getParentFolderId() {
- return parent != null ? parent.getId() : null;
+ public StateToken getParentToken() {
+ return parent != null ? parent.getStateToken() : null;
}
@Override
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -21,21 +21,15 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
-import cc.kune.common.client.notify.ConfirmAskEvent;
-import cc.kune.common.client.notify.NotifyUser;
-import cc.kune.common.client.utils.OnAcceptCallback;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.resources.CoreResources;
-import cc.kune.core.client.rpcservices.ContentServiceAsync;
-import cc.kune.core.client.state.StateManager;
-import cc.kune.core.shared.SessionConstants;
+import cc.kune.core.client.rpcservices.ContentServiceHelper;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.AbstractContentSimpleDTO;
import cc.kune.core.shared.dto.AccessRolDTO;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
-import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -43,39 +37,19 @@
public static class DelContainerAction extends RolAction {
- private final Provider<ContentServiceAsync> contentService;
- private final EventBus eventBus;
- private final I18nTranslationService i18n;
- private final Provider<FolderViewerPresenter> presenter;
- private final SessionConstants session;
- private final StateManager stateManager;
+ private final ContentServiceHelper contentService;
@Inject
- public DelContainerAction(final EventBus eventBus, final StateManager stateManager,
- final SessionConstants session, final Provider<ContentServiceAsync> contentService,
- final I18nTranslationService i18n, final Provider<FolderViewerPresenter> presenter) {
- super(AccessRolDTO.Administrator, true);
- this.eventBus = eventBus;
- this.stateManager = stateManager;
- this.session = session;
+ public DelContainerAction(final Provider<FolderViewerPresenter> presenter,
+ final ContentServiceHelper contentService) {
+ super(AccessRolDTO.Editor, true);
this.contentService = contentService;
- this.i18n = i18n;
- this.presenter = presenter;
}
@Override
public void actionPerformed(final ActionEvent event) {
final StateToken token = ((AbstractContentSimpleDTO) event.getTarget()).getStateToken();
- ConfirmAskEvent.fire(eventBus, i18n.t("Please confirm"),
- i18n.t("Are you sure you want this? It will be deleted with all its contents."),
- i18n.t("Yes"), i18n.t("No"), null, null, new OnAcceptCallback() {
- @Override
- public void onSuccess() {
- NotifyUser.showProgress();
- NotifyUser.info("Sorry, in development");
- NotifyUser.hideProgress();
- }
- });
+ contentService.delContent(token);
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/DelContentMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/DelContentMenuItem.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/DelContentMenuItem.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -38,7 +38,7 @@
@Inject
public DelContentAction(final ContentServiceHelper contentService) {
- super(AccessRolDTO.Administrator, true);
+ super(AccessRolDTO.Editor, true);
this.contentService = contentService;
}
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/GoParentContainerBtn.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/GoParentContainerBtn.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/GoParentContainerBtn.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -57,7 +57,7 @@
stateToken = ((StateContentDTO) state).getContainer().getStateToken();
} else {
final ContainerDTO container = ((StateContainerDTO) state).getContainer();
- stateToken = container.getStateToken().copy().setFolder(container.getParentFolderId());
+ stateToken = container.getParentToken();
}
stateManager.gotoStateToken(stateToken);
// NotifyUser.hideProgress();
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerBtn.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerBtn.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerBtn.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -21,63 +21,29 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.ButtonDescriptor;
-import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.actions.RolAction;
-import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
-import cc.kune.core.client.rpcservices.ContentServiceAsync;
-import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.StateManager;
-import cc.kune.core.shared.domain.utils.StateToken;
+import cc.kune.core.client.rpcservices.ContentServiceHelper;
import cc.kune.core.shared.dto.AccessRolDTO;
-import cc.kune.core.shared.dto.HasContent;
-import cc.kune.core.shared.dto.StateContainerDTO;
-import cc.kune.gspace.client.viewers.FolderViewerPresenter;
import com.google.gwt.resources.client.ImageResource;
import com.google.inject.Inject;
-import com.google.inject.Provider;
public class NewContainerBtn extends ButtonDescriptor {
public static class NewContainerAction extends RolAction {
- private final Provider<ContentServiceAsync> contentService;
- private final FolderViewerPresenter folderViewer;
- private final I18nTranslationService i18n;
- private final Session session;
- private final StateManager stateManager;
+ private final ContentServiceHelper contentService;
@Inject
- public NewContainerAction(final Session session, final StateManager stateManager,
- final I18nTranslationService i18n, final Provider<ContentServiceAsync> contentService,
- final FolderViewerPresenter folderViewer) {
+ public NewContainerAction(final ContentServiceHelper contentService) {
super(AccessRolDTO.Editor, true);
- this.session = session;
- this.stateManager = stateManager;
- this.i18n = i18n;
this.contentService = contentService;
- this.folderViewer = folderViewer;
}
@Override
public void actionPerformed(final ActionEvent event) {
- NotifyUser.showProgress();
- stateManager.gotoStateToken(((HasContent) session.getCurrentState()).getContainer().getStateToken());
- final String newName = (String) getValue(NEW_NAME);
- final StateToken parentToken = session.getCurrentStateToken();
- contentService.get().addFolder(session.getUserHash(), parentToken, newName, (String) getValue(ID),
- new AsyncCallbackSimple<StateContainerDTO>() {
- @Override
- public void onSuccess(final StateContainerDTO state) {
- // contextNavigator.setEditOnNextStateChange(true);
- stateManager.removeCache(parentToken);
- stateManager.setRetrievedStateAndGo(state);
- NotifyUser.hideProgress();
- NotifyUser.info(i18n.tWithNT("[%s] created", "New folder created, for instance", newName));
- folderViewer.highlightTitle();
- }
- });
+ contentService.addContainer((String) getValue(ID), (String) getValue(NEW_NAME));
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerMenuItem.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/NewContainerMenuItem.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -24,67 +24,29 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.MenuDescriptor;
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
-import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.actions.RolAction;
-import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
-import cc.kune.core.client.rpcservices.ContentServiceAsync;
-import cc.kune.core.client.state.ContentCache;
-import cc.kune.core.client.state.Session;
-import cc.kune.core.client.state.StateManager;
-import cc.kune.core.shared.domain.utils.StateToken;
+import cc.kune.core.client.rpcservices.ContentServiceHelper;
import cc.kune.core.shared.dto.AccessRolDTO;
-import cc.kune.core.shared.dto.HasContent;
-import cc.kune.core.shared.dto.StateContainerDTO;
-import cc.kune.gspace.client.viewers.FolderViewerPresenter;
import com.google.gwt.resources.client.ImageResource;
import com.google.inject.Inject;
-import com.google.inject.Provider;
public class NewContainerMenuItem extends MenuItemDescriptor {
public static class NewContainerAction extends RolAction {
- private final ContentCache cache;
- private final Provider<ContentServiceAsync> contentService;
- private final FolderViewerPresenter folderViewer;
- private final I18nTranslationService i18n;
- private final Session session;
- private final StateManager stateManager;
+ private final ContentServiceHelper contentService;
@Inject
- public NewContainerAction(final Session session, final StateManager stateManager,
- final I18nTranslationService i18n, final Provider<ContentServiceAsync> contentService,
- final ContentCache cache, final FolderViewerPresenter folderViewer) {
+ public NewContainerAction(final ContentServiceHelper contentService) {
super(AccessRolDTO.Editor, true);
- this.session = session;
- this.stateManager = stateManager;
- this.i18n = i18n;
this.contentService = contentService;
- this.cache = cache;
- this.folderViewer = folderViewer;
}
@Override
public void actionPerformed(final ActionEvent event) {
- NotifyUser.showProgress();
- stateManager.gotoStateToken(((HasContent) session.getCurrentState()).getContainer().getStateToken());
- final String newName = (String) getValue(NEW_NAME);
- final StateToken parentToken = session.getCurrentStateToken();
- contentService.get().addFolder(session.getUserHash(), parentToken, newName, (String) getValue(ID),
- new AsyncCallbackSimple<StateContainerDTO>() {
- @Override
- public void onSuccess(final StateContainerDTO state) {
- // contextNavigator.setEditOnNextStateChange(true);
- stateManager.removeCache(parentToken);
- stateManager.setRetrievedStateAndGo(state);
- NotifyUser.hideProgress();
- NotifyUser.info(i18n.tWithNT("[%s] created", "New folder created, for instance", newName));
- folderViewer.highlightTitle();
- }
- });
- cache.remove(parentToken);
+ contentService.addContainer((String) getValue(ID), (String) getValue(NEW_NAME));
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/NewContentAction.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/NewContentAction.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/NewContentAction.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -74,7 +74,8 @@
NotifyUser.hideProgress();
// stateManager.refreshCurrentGroupState();
// contextNavigator.setEditOnNextStateChange(true);
- NotifyUser.info(i18n.tWithNT("[%s] created", "New content created, for instance", newName));
+ // NotifyUser.info(i18n.tWithNT("[%s] created",
+ // "New content created, for instance", newName));
contentViewer.blinkTitle();
}
});
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/RenameAction.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/RenameAction.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/RenameAction.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -92,7 +92,7 @@
contentCache.remove(((StateContentDTO) state).getContainer().getStateToken());
} else if (state instanceof StateContainerDTO) {
final ContainerDTO container = ((StateContainerDTO) state).getContainer();
- contentCache.remove(token.copy().setFolder(container.getParentFolderId()));
+ contentCache.remove(container.getParentToken());
}
}
};
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/SetAsHomePageMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/SetAsHomePageMenuItem.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/SetAsHomePageMenuItem.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -74,7 +74,7 @@
public SetAsHomePageMenuItem(final I18nTranslationService i18n, final SetAsHomePageAction action,
final CoreResources res) {
super(action);
- this.withText(i18n.t("Delete")).withIcon(res.groupHome()).withText(i18n.t("Select as the homepage"));
+ this.withIcon(res.groupHome()).withText(i18n.t("Select as the homepage"));
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPanel.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -60,8 +60,10 @@
InlineLabel label;
@UiField
FocusPanel self;
+ private final String shortName;
public ToolSelectorItemPanel(final String shortName, final ImageResource icon) {
+ this.shortName = shortName;
initWidget(uiBinder.createAndBindUi(this));
ensureDebugId(TOOL_ID_PREFIX + shortName);
setVisibleImpl(false);
@@ -92,6 +94,15 @@
return label;
}
+ public String getName() {
+ return shortName;
+ }
+
+ @Override
+ public Object getTarget() {
+ return this;
+ }
+
@UiHandler("self")
void onSelfMouseOut(final MouseOutEvent event) {
unfocus();
Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorItemPresenter.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -36,6 +36,8 @@
HasText getLabel();
+ Object getTarget();
+
void setSelected(boolean selected);
void setTooltip(String tooltip);
@@ -44,12 +46,12 @@
}
private final String longName;
- private final AccessRolDTO visibleFoRol;
private final String shortName;
private StateToken token;
private final ToolSelector toolSelector;
private final String tooltip;
private ToolSelectorItemView view;
+ private final AccessRolDTO visibleFoRol;
public ToolSelectorItemPresenter(final String shortName, final String longName, final String tooltip,
final AccessRolDTO visibleForRol, final ToolSelector toolSelector) {
@@ -61,11 +63,6 @@
}
@Override
- public AccessRolDTO getVisibleForRol() {
- return visibleFoRol;
- }
-
- @Override
public String getShortName() {
return shortName;
}
@@ -75,6 +72,11 @@
return view;
}
+ @Override
+ public AccessRolDTO getVisibleForRol() {
+ return visibleFoRol;
+ }
+
public void init(final ToolSelectorItemView view) {
this.view = view;
toolSelector.addTool(this);
Modified: trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPanel.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/gspace/client/tool/selector/ToolSelectorPanel.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -56,9 +56,9 @@
public void addItem(final ToolSelectorItemView item) {
final Widget widget = item.asWidget();
flow.add(widget);
- // dropControllerProv.get().init((InlineLabel) ((ToolSelectorItemPanel)
- // widget).getLabel());
- dropControllerProv.get().init(((ToolSelectorItemPanel) widget).getFocusPanel());
+ final FolderContainerDropController dropController = dropControllerProv.get();
+ dropController.init(((ToolSelectorItemPanel) widget).getFocusPanel());
+ dropController.setTarget(item.getTarget());
}
@Override
Added: trunk/src/main/java/cc/kune/tasks/client/actions/DelTaskMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/tasks/client/actions/DelTaskMenuItem.java (rev 0)
+++ trunk/src/main/java/cc/kune/tasks/client/actions/DelTaskMenuItem.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program 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 Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.tasks.client.actions;
+
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.client.resources.CoreResources;
+import cc.kune.gspace.client.actions.DelContentMenuItem;
+
+import com.google.inject.Inject;
+
+public class DelTaskMenuItem extends DelContentMenuItem {
+
+ @Inject
+ public DelTaskMenuItem(final I18nTranslationService i18n, final DelContentAction action, final CoreResources res) {
+ super(i18n, action, res);
+ }
+}
Modified: trunk/src/main/java/cc/kune/tasks/client/actions/TasksClientActions.java
===================================================================
--- trunk/src/main/java/cc/kune/tasks/client/actions/TasksClientActions.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/tasks/client/actions/TasksClientActions.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -70,6 +70,7 @@
final Provider<ContentViewerShareMenu> shareMenuContent,
final Provider<ParticipateInContentBtn> participateBtn,
final Provider<TutorialContainerBtn> tutorialBtn,
+ final Provider<DelTaskMenuItem> delContentMenuItem,
final Provider<AddAllMembersToContentMenuItem> addAllMenuItem,
final Provider<AddAdminMembersToContentMenuItem> addAdminMembersMenuItem,
final Provider<AddCollabMembersToContentMenuItem> addCollabMembersMenuItem,
@@ -110,6 +111,7 @@
actionsRegistry.addAction(ActionGroups.ITEM_MENU, marksAsNotDoneMenuItem,
ContentStatus.inTheDustbin, TYPE_TASK);
actionsRegistry.addAction(ActionGroups.ITEM_MENU, delFolderMenuItem, containersNoRoot);
+ actionsRegistry.addAction(ActionGroups.ITEM_MENU, delContentMenuItem, contents);
actionsRegistry.addAction(ActionGroups.ITEM_MENU, addAllMenuItem, contents);
actionsRegistry.addAction(ActionGroups.ITEM_MENU, addAdminMembersMenuItem, contents);
actionsRegistry.addAction(ActionGroups.ITEM_MENU, addCollabMembersMenuItem, contents);
Modified: trunk/src/main/java/cc/kune/trash/client/TrashClientTool.java
===================================================================
--- trunk/src/main/java/cc/kune/trash/client/TrashClientTool.java 2012-03-18 22:30:59 UTC (rev 1772)
+++ trunk/src/main/java/cc/kune/trash/client/TrashClientTool.java 2012-03-20 12:38:50 UTC (rev 1773)
@@ -41,8 +41,8 @@
public TrashClientTool(final I18nTranslationService i18n, final ToolSelector toolSelector,
final ContentCapabilitiesRegistry cntCapRegistry, final CoreResources res,
final NavResources navResources) {
- super(NAME, i18n.t(ROOT_NAME), "", res.trashWhite(), AccessRolDTO.Administrator, toolSelector,
- cntCapRegistry, i18n, navResources);
+ super(NAME, i18n.t(ROOT_NAME), i18n.t("You can drop here contents to delete then"),
+ res.trashWhite(), AccessRolDTO.Editor, toolSelector, cntCapRegistry, i18n, navResources);
this.res = res;
// registerAclEditableTypes();
More information about the kune-commits
mailing list