[kune-commits] r891 -
trunk/src/main/java/org/ourproject/kune/docs/client
vjrj
vjrj at ourproject.org
Mon Sep 29 10:35:21 CEST 2008
Author: vjrj
Date: 2008-09-29 10:35:20 +0200 (Mon, 29 Sep 2008)
New Revision: 891
Modified:
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
Log:
ya estamos con errores en el svn y si la abuela fuma
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-09-27 20:03:56 UTC (rev 890)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-09-29 08:35:20 UTC (rev 891)
@@ -4,9 +4,11 @@
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_DOCUMENT;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_FOLDER;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_GALLERY;
+import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_POST;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_ROOT;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_UPLOADEDFILE;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKI;
+import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKIPAGE;
import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
@@ -16,19 +18,24 @@
import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.BasicMimeTypeDTO;
import org.ourproject.kune.platf.client.dto.ContentSimpleDTO;
+import org.ourproject.kune.platf.client.dto.ContentStatusDTO;
+import org.ourproject.kune.platf.client.dto.GroupDTO;
import org.ourproject.kune.platf.client.dto.InitDataDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.dialogs.upload.FileUploader;
+import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
+import org.ourproject.kune.platf.client.ui.upload.FileUploader;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
+import org.ourproject.kune.workspace.client.entitylogo.EntityLogo;
import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
import org.ourproject.kune.workspace.client.site.Site;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.listener.Listener;
@@ -43,22 +50,27 @@
private final ContentActionRegistry contentActionRegistry;
private final ContextActionRegistry contextActionRegistry;
private final Provider<ContentServiceAsync> contentServiceProvider;
- private final WorkspaceSkeleton ws;
+ private final Provider<GroupServiceAsync> groupServiceProvider;
+ private final Provider<FileDownloadUtils> fileDownloadProvider;
+ private final EntityLogo entityLogo;
public DocumentClientActions(final I18nUITranslationService i18n, final ContextNavigator contextNavigator,
- final Session session, final StateManager stateManager, final WorkspaceSkeleton ws,
+ final Session session, final StateManager stateManager,
final Provider<ContentServiceAsync> contentServiceProvider,
- final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry,
- final ContextActionRegistry contextActionRegistry) {
+ final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
+ final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
+ final Provider<FileDownloadUtils> fileDownloadProvider, final EntityLogo entityLogo) {
this.i18n = i18n;
this.contextNavigator = contextNavigator;
this.session = session;
this.stateManager = stateManager;
- this.ws = ws;
this.contentServiceProvider = contentServiceProvider;
+ this.groupServiceProvider = groupServiceProvider;
this.fileUploaderProvider = fileUploaderProvider;
this.contextActionRegistry = contextActionRegistry;
this.contentActionRegistry = contentActionRegistry;
+ this.fileDownloadProvider = fileDownloadProvider;
+ this.entityLogo = entityLogo;
createActions();
}
@@ -134,14 +146,14 @@
}
});
- final ActionMenuDescriptor<StateToken> rename = new ActionMenuDescriptor<StateToken>(AccessRolDTO.Editor,
+ final ActionMenuDescriptor<StateToken> renameCtn = new ActionMenuDescriptor<StateToken>(AccessRolDTO.Editor,
ActionPosition.topbarAndItemMenu, new Listener<StateToken>() {
public void onEvent(final StateToken stateToken) {
contextNavigator.editItem(stateToken);
}
});
- rename.setTextDescription(i18n.t("Rename"));
- rename.setParentMenuTitle(i18n.t("File"));
+ renameCtn.setTextDescription(i18n.t("Rename"));
+ renameCtn.setParentMenuTitle(i18n.t("File"));
final ActionMenuDescriptor<StateToken> renameCtx = new ActionMenuDescriptor<StateToken>(AccessRolDTO.Editor,
ActionPosition.topbarAndItemMenu, new Listener<StateToken>() {
@@ -221,7 +233,7 @@
final ActionDescriptor<StateToken> uploadMedia = createUploadAction(i18n.t("Upload media"),
"images/nav/upload.png", i18n.t("Upload some media (images, videos)"), session
.getGalleryPermittedExtensions());
- contextActionRegistry.addAction(TYPE_GALLERY, uploadMedia);
+ contextActionRegistry.addAction(uploadMedia, TYPE_GALLERY);
}
});
@@ -244,49 +256,93 @@
downloadCtx.setTextDescription(i18n.t("Download"));
downloadCtx.setIconUrl("images/nav/download.png");
- contextActionRegistry.addAction(TYPE_FOLDER, go);
- contextActionRegistry.addAction(TYPE_FOLDER, addDoc);
- contextActionRegistry.addAction(TYPE_FOLDER, addFolder);
- contextActionRegistry.addAction(TYPE_FOLDER, renameCtx);
- contextActionRegistry.addAction(TYPE_FOLDER, refreshCtx);
- contextActionRegistry.addAction(TYPE_FOLDER, delContainer);
- contextActionRegistry.addAction(TYPE_FOLDER, goGroupHome);
- contextActionRegistry.addAction(TYPE_FOLDER, uploadFile);
+ final ActionMenuDescriptor<StateToken> setGroupLogo = new ActionMenuDescriptor<StateToken>(
+ AccessRolDTO.Administrator, ActionPosition.topbarAndItemMenu, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ groupServiceProvider.get().setGroupLogo(session.getUserHash(), token,
+ new AsyncCallbackSimple<GroupDTO>() {
+ public void onSuccess(GroupDTO newGroup) {
+ Site.info("Logo selected");
+ if (session.getCurrentState().getGroup().getShortName().equals(
+ newGroup.getShortName())) {
+ session.getCurrentState().setGroup(newGroup);
+ }
+ entityLogo.refreshGroupLogo();
+ }
+ });
+ }
+ });
+ setGroupLogo.setParentMenuTitle(i18n.t("File"));
+ setGroupLogo.setTextDescription(i18n.t("Set this as the group logo"));
+ setGroupLogo.setIconUrl("images/nav/picture.png");
+ setGroupLogo.setEnableCondition(new ActionEnableCondition<StateToken>() {
+ public boolean mustBeEnabled(final StateToken param) {
+ final BasicMimeTypeDTO mime = session.getCurrentState().getMimeType();
+ return mime != null && mime.getType().equals("image");
+ }
+ });
- contextActionRegistry.addAction(TYPE_BLOG, go);
- contextActionRegistry.addAction(TYPE_BLOG, uploadFile);
- contextActionRegistry.addAction(TYPE_BLOG, refreshCtx);
- contextActionRegistry.addAction(TYPE_BLOG, setAsDefGroupContent);
+ final ActionMenuDescriptor<StateToken> setPublishStatus = createSetStatusAction(AccessRolDTO.Administrator,
+ i18n.t("Published online"), ContentStatusDTO.publishedOnline);
+ final ActionMenuDescriptor<StateToken> setEditionInProgressStatus = createSetStatusAction(
+ AccessRolDTO.Administrator, i18n.t("Editing in progress"), ContentStatusDTO.editingInProgress);
+ final ActionMenuDescriptor<StateToken> setRejectStatus = createSetStatusAction(AccessRolDTO.Administrator, i18n
+ .t("Rejected"), ContentStatusDTO.rejected);
+ final ActionMenuDescriptor<StateToken> setSubmittedForPublishStatus = createSetStatusAction(
+ AccessRolDTO.Administrator, i18n.t("Submitted for publish"), ContentStatusDTO.publishedOnline);
+ final ActionMenuDescriptor<StateToken> setInTheDustBinStatus = createSetStatusAction(
+ AccessRolDTO.Administrator, i18n.t("In the dustbin"), ContentStatusDTO.inTheDustbin);
- contextActionRegistry.addAction(TYPE_GALLERY, go);
- contextActionRegistry.addAction(TYPE_GALLERY, goGroupHome);
- contextActionRegistry.addAction(TYPE_GALLERY, refreshCtx);
+ final ActionButtonDescriptor<StateToken> translateContent = new ActionButtonDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ Site.important(i18n.t("Sorry, this functionality is currently in development"));
+ }
+ });
+ translateContent.setTextDescription(i18n.tWithNT("Translate", "used in button"));
+ translateContent.setToolTip(i18n.t("Translate this document to other languages"));
+ translateContent.setIconUrl("images/language.gif");
- contextActionRegistry.addAction(TYPE_UPLOADEDFILE, go);
- contextActionRegistry.addAction(TYPE_UPLOADEDFILE, setAsDefGroupContent);
- contentActionRegistry.addAction(TYPE_UPLOADEDFILE, rename);
- contentActionRegistry.addAction(TYPE_UPLOADEDFILE, refreshCnt);
- contentActionRegistry.addAction(TYPE_UPLOADEDFILE, delContent);
- contentActionRegistry.addAction(TYPE_UPLOADEDFILE, download);
- contextActionRegistry.addAction(TYPE_UPLOADEDFILE, downloadCtx);
+ final ActionButtonDescriptor<StateToken> editContent = new ActionButtonDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ }
+ });
+ editContent.setTextDescription(i18n.tWithNT("Edit", "used in button"));
+ editContent.setIconUrl("images/content_edit.png");
- contextActionRegistry.addAction(TYPE_WIKI, go);
- contextActionRegistry.addAction(TYPE_WIKI, goGroupHome);
- contextActionRegistry.addAction(TYPE_WIKI, refreshCtx);
+ final String[] all = { TYPE_ROOT, TYPE_FOLDER, TYPE_DOCUMENT, TYPE_GALLERY, TYPE_BLOG, TYPE_POST, TYPE_WIKI,
+ TYPE_WIKIPAGE, TYPE_UPLOADEDFILE };
+ final String[] containersNoRoot = { TYPE_FOLDER, TYPE_GALLERY, TYPE_BLOG, TYPE_WIKI };
+ final String[] containers = { TYPE_ROOT, TYPE_FOLDER, TYPE_GALLERY, TYPE_BLOG, TYPE_WIKI };
+ final String[] contents = { TYPE_DOCUMENT, TYPE_POST, TYPE_WIKIPAGE, TYPE_UPLOADEDFILE };
+ final String[] contentsModerated = { TYPE_DOCUMENT, TYPE_POST, TYPE_UPLOADEDFILE };
- contextActionRegistry.addAction(TYPE_ROOT, addDoc);
- contextActionRegistry.addAction(TYPE_ROOT, addFolder);
- contextActionRegistry.addAction(TYPE_ROOT, addGallery);
- contextActionRegistry.addAction(TYPE_ROOT, addWiki);
- contextActionRegistry.addAction(TYPE_ROOT, refreshCtx);
- contextActionRegistry.addAction(TYPE_ROOT, goGroupHome);
- contextActionRegistry.addAction(TYPE_ROOT, uploadFile);
-
- contextActionRegistry.addAction(TYPE_DOCUMENT, go);
- contextActionRegistry.addAction(TYPE_DOCUMENT, setAsDefGroupContent);
- contentActionRegistry.addAction(TYPE_DOCUMENT, rename);
- contentActionRegistry.addAction(TYPE_DOCUMENT, refreshCnt);
- contentActionRegistry.addAction(TYPE_DOCUMENT, delContent);
+ contentActionRegistry.addAction(setPublishStatus, contentsModerated);
+ contentActionRegistry.addAction(setEditionInProgressStatus, contentsModerated);
+ contentActionRegistry.addAction(setRejectStatus, contentsModerated);
+ contentActionRegistry.addAction(setSubmittedForPublishStatus, contentsModerated);
+ contentActionRegistry.addAction(setInTheDustBinStatus, contentsModerated);
+ contextActionRegistry.addAction(addDoc, TYPE_ROOT, TYPE_FOLDER);
+ contextActionRegistry.addAction(addFolder, TYPE_ROOT, TYPE_FOLDER);
+ contextActionRegistry.addAction(addGallery, TYPE_ROOT);
+ contextActionRegistry.addAction(addWiki, TYPE_ROOT);
+ contextActionRegistry.addAction(go, all);
+ contextActionRegistry.addAction(uploadFile, TYPE_ROOT, TYPE_FOLDER, TYPE_BLOG);
+ contentActionRegistry.addAction(download, TYPE_UPLOADEDFILE);
+ contextActionRegistry.addAction(renameCtx, containersNoRoot);
+ contentActionRegistry.addAction(renameCtn, contents);
+ contextActionRegistry.addAction(refreshCtx, containers);
+ contentActionRegistry.addAction(refreshCnt, contents);
+ contentActionRegistry.addAction(delContent, contents);
+ contextActionRegistry.addAction(delContainer, containersNoRoot);
+ contextActionRegistry.addAction(setAsDefGroupContent, TYPE_BLOG, TYPE_DOCUMENT, TYPE_UPLOADEDFILE);
+ contextActionRegistry.addAction(goGroupHome, containers);
+ contentActionRegistry.addAction(setGroupLogo, TYPE_UPLOADEDFILE);
+ contextActionRegistry.addAction(downloadCtx, TYPE_UPLOADEDFILE);
+ contentActionRegistry.addAction(editContent, TYPE_DOCUMENT, TYPE_POST, TYPE_WIKIPAGE);
+ contentActionRegistry.addAction(translateContent, TYPE_DOCUMENT, TYPE_FOLDER, TYPE_GALLERY, TYPE_UPLOADEDFILE,
+ TYPE_WIKI, TYPE_WIKIPAGE);
}
private ActionMenuDescriptor<StateToken> createFolderAction(final String contentTypeId, final String iconUrl,
@@ -313,6 +369,30 @@
return addFolder;
}
+ private ActionMenuDescriptor<StateToken> createSetStatusAction(final AccessRolDTO rol,
+ final String textDescription, final ContentStatusDTO status) {
+ final ActionMenuDescriptor<StateToken> action = new ActionMenuDescriptor<StateToken>(rol,
+ ActionPosition.topbarAndItemMenu, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ final AsyncCallbackSimple<Object> callback = new AsyncCallbackSimple<Object>() {
+ public void onSuccess(final Object result) {
+ session.getCurrentState().setStatus(status);
+ }
+ };
+ if (status.equals(ContentStatusDTO.publishedOnline) || status.equals(ContentStatusDTO.rejected)) {
+ contentServiceProvider.get().setStatusAsAdmin(session.getUserHash(), stateToken, status,
+ callback);
+ } else {
+ contentServiceProvider.get().setStatus(session.getUserHash(), stateToken, status, callback);
+ }
+ }
+ });
+ action.setTextDescription(textDescription);
+ action.setParentMenuTitle(i18n.t("File"));
+ action.setParentSubMenuTitle(i18n.t("Change the status"));
+ return action;
+ }
+
private ActionButtonDescriptor<StateToken> createUploadAction(final String textDescription, final String iconUrl,
final String toolTip, final String permitedExtensions) {
final ActionButtonDescriptor<StateToken> uploadFile;
@@ -334,8 +414,6 @@
}
private void downloadContent(final StateToken token) {
- final String url = "/kune/servlets/FileDownloadManager?token=" + token + "&hash=" + session.getUserHash()
- + "&download=true";
- ws.openUrl(url);
+ fileDownloadProvider.get().downloadFile(token);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-09-27 20:03:56 UTC (rev 890)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-09-29 08:35:20 UTC (rev 891)
@@ -1,12 +1,5 @@
package org.ourproject.kune.docs.client;
-import org.ourproject.kune.docs.client.actions.ContentEditAction;
-import org.ourproject.kune.docs.client.actions.ContentEditInProgressAction;
-import org.ourproject.kune.docs.client.actions.ContentPublishAction;
-import org.ourproject.kune.docs.client.actions.ContentRejectAction;
-import org.ourproject.kune.docs.client.actions.ContentSubmitForPublishAction;
-import org.ourproject.kune.docs.client.actions.ContentTranslationAction;
-import org.ourproject.kune.docs.client.actions.ContentTrashAction;
import org.ourproject.kune.docs.client.cnt.DocumentContent;
import org.ourproject.kune.docs.client.cnt.DocumentContentPanel;
import org.ourproject.kune.docs.client.cnt.DocumentContentPresenter;
@@ -35,14 +28,17 @@
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
import org.ourproject.kune.platf.client.app.ToolGroup;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
import org.ourproject.kune.platf.client.services.KuneErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.tool.ToolSelector;
-import org.ourproject.kune.platf.client.ui.dialogs.upload.FileUploader;
+import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.rate.RateIt;
+import org.ourproject.kune.platf.client.ui.upload.FileUploader;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.editor.TextEditor;
+import org.ourproject.kune.workspace.client.entitylogo.EntityLogo;
import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import org.ourproject.kune.workspace.client.tags.TagsSummary;
@@ -72,49 +68,12 @@
}
});
- register(Singleton.class, new Factory<ContentPublishAction>(ContentPublishAction.class) {
- public ContentPublishAction create() {
- return new ContentPublishAction($(Session.class), $$(ContentServiceAsync.class),
- $(I18nUITranslationService.class));
- }
- }, new Factory<ContentRejectAction>(ContentRejectAction.class) {
- public ContentRejectAction create() {
- return new ContentRejectAction($(Session.class), $$(ContentServiceAsync.class),
- $(I18nUITranslationService.class));
- }
- }, new Factory<ContentEditInProgressAction>(ContentEditInProgressAction.class) {
- public ContentEditInProgressAction create() {
- return new ContentEditInProgressAction($(Session.class), $$(ContentServiceAsync.class),
- $(I18nUITranslationService.class));
- }
- }, new Factory<ContentSubmitForPublishAction>(ContentSubmitForPublishAction.class) {
- public ContentSubmitForPublishAction create() {
- return new ContentSubmitForPublishAction($(Session.class), $$(ContentServiceAsync.class),
- $(I18nUITranslationService.class));
- }
- }, new Factory<ContentTrashAction>(ContentTrashAction.class) {
- public ContentTrashAction create() {
- return new ContentTrashAction($(Session.class), $$(ContentServiceAsync.class),
- $(I18nUITranslationService.class));
- }
- });
-
- register(Singleton.class, new Factory<ContentEditAction>(ContentEditAction.class) {
- public ContentEditAction create() {
- return new ContentEditAction($(I18nUITranslationService.class));
- }
- }, new Factory<ContentTranslationAction>(ContentTranslationAction.class) {
- public ContentTranslationAction create() {
- return new ContentTranslationAction($(I18nUITranslationService.class));
- }
- });
-
register(ToolGroup.class, new Factory<DocumentClientActions>(DocumentClientActions.class) {
public DocumentClientActions create() {
return new DocumentClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $(WorkspaceSkeleton.class),
- $$(ContentServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class),
- $(ContextActionRegistry.class));
+ $(Session.class), $(StateManager.class), $$(ContentServiceAsync.class),
+ $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class),
+ $(ContextActionRegistry.class), $$(FileDownloadUtils.class), $(EntityLogo.class));
}
});
@@ -130,20 +89,6 @@
$(RateIt.class), $$(DocumentReader.class), $$(TextEditor.class), $$(FolderViewer.class),
$$(ContentServiceAsync.class), toolbar, $(ContentActionRegistry.class));
final DocumentContentPanel panel = new DocumentContentPanel($(WorkspaceSkeleton.class));
-
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT,
- $(ContentPublishAction.class));
- $(ContentActionRegistry.class)
- .addAction(DocumentClientTool.TYPE_DOCUMENT, $(ContentRejectAction.class));
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT,
- $(ContentSubmitForPublishAction.class));
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT,
- $(ContentEditInProgressAction.class));
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT, $(ContentTrashAction.class));
-
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT, $(ContentEditAction.class));
- $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT,
- $(ContentTranslationAction.class));
presenter.init(panel);
return presenter;
}
More information about the kune-commits
mailing list