[kune-commits] r965 - in trunk/src/main/java/org/ourproject/kune:
docs/client docs/client/cnt platf/client/actions
platf/client/actions/toolbar platf/client/services
platf/client/state workspace/client workspace/client/cnt
workspace/client/skel
vjrj
vjrj at ourproject.org
Mon Nov 24 19:14:44 CET 2008
Author: vjrj
Date: 2008-11-24 19:14:39 +0100 (Mon, 24 Nov 2008)
New Revision: 965
Added:
trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContent.java
Modified:
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewer.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java
trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
Log:
Incomplete - task UI tools & workspace refactorization
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -29,27 +29,14 @@
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKIPAGE;
import org.ourproject.kune.docs.client.cnt.DocumentViewer;
-import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
-import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
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.StateContainerDTO;
-import org.ourproject.kune.platf.client.dto.StateContentDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.errors.SessionExpiredException;
-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.services.KuneErrorHandler;
@@ -57,75 +44,47 @@
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.upload.FileUploader;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.workspace.client.AbstractFoldableContentActions;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
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.site.Site;
import com.calclab.suco.client.ioc.Provider;
-import com.calclab.suco.client.listener.Listener;
-import com.calclab.suco.client.listener.Listener0;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-public class DocumentClientActions {
-
- private final I18nUITranslationService i18n;
- private final ContextNavigator contextNavigator;
- private final Session session;
- private final StateManager stateManager;
- private final Provider<FileUploader> fileUploaderProvider;
- private final ContentActionRegistry contentActionRegistry;
- private final ContextActionRegistry contextActionRegistry;
- private final Provider<ContentServiceAsync> contentServiceProvider;
- private final Provider<GroupServiceAsync> groupServiceProvider;
- private final Provider<FileDownloadUtils> fileDownloadProvider;
- private final EntityLogo entityLogo;
- private final Provider<TextEditor> textEditorProvider;
- private final KuneErrorHandler errorHandler;
- private final DocumentViewer documentViewer;
- private final Provider<ContextPropEditor> contextPropEditorProvider;
-
+public class DocumentClientActions extends AbstractFoldableContentActions {
public DocumentClientActions(final I18nUITranslationService i18n, final ContextNavigator contextNavigator,
final Session session, final StateManager stateManager,
+ final DeferredCommandWrapper deferredCommandWrapper,
final Provider<ContentServiceAsync> contentServiceProvider,
final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
final Provider<FileDownloadUtils> fileDownloadProvider, final EntityLogo entityLogo,
final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler,
final DocumentViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider) {
- this.i18n = i18n;
- this.contextNavigator = contextNavigator;
- this.session = session;
- this.stateManager = stateManager;
- this.contentServiceProvider = contentServiceProvider;
- this.groupServiceProvider = groupServiceProvider;
- this.fileUploaderProvider = fileUploaderProvider;
- this.contextActionRegistry = contextActionRegistry;
- this.contentActionRegistry = contentActionRegistry;
- this.fileDownloadProvider = fileDownloadProvider;
- this.entityLogo = entityLogo;
- this.textEditorProvider = textEditorProvider;
- this.errorHandler = errorHandler;
- this.documentViewer = documentViewer;
- this.contextPropEditorProvider = contextProvEditorProvider;
- createActions();
+ super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider,
+ contentServiceProvider, fileUploaderProvider, contextNavigator, contentActionRegistry,
+ contextActionRegistry, fileDownloadProvider, textEditorProvider, contextProvEditorProvider,
+ documentViewer, entityLogo);
}
- private void createActions() {
+ @Override
+ protected void createActions() {
+ String parentMenuTitle = i18n.t("File");
+ String parentMenuTitleCtx = i18n.t("Folder");
+
final ActionToolbarMenuAndItemDescriptor<StateToken> addFolder = createFolderAction(TYPE_FOLDER,
- "images/nav/folder_add.png", i18n.t("New folder"), i18n.t("Folder"), i18n.t("New"),
+ "images/nav/folder_add.png", i18n.t("New folder"), parentMenuTitleCtx, i18n.t("New"),
i18n.t("New folder"));
final ActionToolbarMenuAndItemDescriptor<StateToken> addGallery = createFolderAction(TYPE_GALLERY,
- "images/nav/gallery_add.png", i18n.t("New gallery"), i18n.t("Folder"), i18n.t("New"),
+ "images/nav/gallery_add.png", i18n.t("New gallery"), parentMenuTitleCtx, i18n.t("New"),
i18n.t("New gallery"));
final ActionToolbarMenuAndItemDescriptor<StateToken> addWiki = createFolderAction(TYPE_WIKI,
- "images/nav/wiki_add.png", i18n.t("New wiki"), i18n.t("Folder"), i18n.t("New"), i18n.t("wiki"));
+ "images/nav/wiki_add.png", i18n.t("New wiki"), parentMenuTitleCtx, i18n.t("New"), i18n.t("wiki"));
final ActionToolbarMenuAndItemDescriptor<StateToken> addBlog = createFolderAction(TYPE_BLOG,
- "images/nav/blog_add.png", i18n.t("New blog"), i18n.t("Folder"), i18n.t("New"), i18n.t("New blog"));
+ "images/nav/blog_add.png", i18n.t("New blog"), parentMenuTitleCtx, i18n.t("New"), i18n.t("New blog"));
final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = createDocAction("images/nav/page_add.png",
i18n.t("New document"), TYPE_DOCUMENT);
@@ -134,181 +93,29 @@
final ActionToolbarMenuAndItemDescriptor<StateToken> addPost = createDocAction("images/nav/post_add.png",
i18n.t("New post"), TYPE_POST);
- final ActionToolbarMenuAndItemDescriptor<StateToken> delContainer = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- Site.info("Sorry, in development");
- }
- });
- delContainer.setParentMenuTitle(i18n.t("Folder"));
- delContainer.setTextDescription(i18n.t("Delete folder"));
- delContainer.setMustBeConfirmed(true);
- delContainer.setConfirmationTitle(i18n.t("Please confirm"));
- delContainer.setConfirmationText(i18n.t("You will delete it and also all its contents. Are you sure?"));
+ final ActionToolbarMenuAndItemDescriptor<StateToken> delContainer = createDelContainerAction("Delete folder",
+ parentMenuTitleCtx);
- final ActionToolbarMenuAndItemDescriptor<StateToken> delContent = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- contentServiceProvider.get().delContent(session.getUserHash(), token,
- new AsyncCallbackSimple<String>() {
- public void onSuccess(final String result) {
- final StateToken parent = token.clone().clearDocument();
- stateManager.gotoToken(parent);
- }
- });
- }
- });
- delContent.setParentMenuTitle(i18n.t("File"));
- delContent.setTextDescription(i18n.t("Delete"));
- delContent.setMustBeConfirmed(true);
- delContent.setConfirmationTitle(i18n.t("Please confirm"));
- delContent.setConfirmationText(i18n.t("Are you sure?"));
- delContent.setEnableCondition(new ActionEnableCondition<StateToken>() {
- public boolean mustBeEnabled(final StateToken itemToken) {
- final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
- return !itemToken.equals(defContentToken);
- }
- });
+ final ActionToolbarMenuAndItemDescriptor<StateToken> delContent = createDelContentAction(parentMenuTitle,
+ i18n.t("Delete"));
- final ActionMenuItemDescriptor<StateToken> go = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer,
- new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- stateManager.gotoToken(token);
- }
- });
- go.setMustBeAuthenticated(false);
- go.setTextDescription(i18n.t("Open"));
- go.setIconUrl("images/nav/go.png");
- go.setEnableCondition(new ActionEnableCondition<StateToken>() {
- public boolean mustBeEnabled(final StateToken itemToken) {
- return !contextNavigator.isSelected(itemToken);
- }
- });
+ final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtn = createContentRenameAction(parentMenuTitle,
+ i18n.t("Rename"));
- final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtn = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- contextNavigator.editItem(stateToken);
- }
- });
- renameCtn.setTextDescription(i18n.t("Rename"));
- renameCtn.setParentMenuTitle(i18n.t("File"));
+ final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtx = createRenameContentInCtxAction(
+ parentMenuTitleCtx, i18n.t("Rename"));
- final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtx = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- contextNavigator.editItem(stateToken);
- }
- });
- renameCtx.setTextDescription(i18n.t("Rename"));
- renameCtx.setParentMenuTitle(i18n.t("Folder"));
+ final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCnt = createSetAsDefContent(parentMenuTitle);
- final ActionToolbarButtonDescriptor<StateToken> goGroupHome = new ActionToolbarButtonDescriptor<StateToken>(
- AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- stateManager.gotoToken(token.getGroup());
- }
- });
- goGroupHome.setMustBeAuthenticated(false);
- goGroupHome.setIconUrl("images/group-home.png");
- goGroupHome.setEnableCondition(new ActionEnableCondition<StateToken>() {
- public boolean mustBeEnabled(final StateToken itemToken) {
- final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
- return !itemToken.equals(defContentToken);
- }
- });
+ final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCxt = createSetAsDefContent(parentMenuTitleCtx);
- final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCnt;
- setAsDefGroupCnt = createSetAsDefContent();
- setAsDefGroupCnt.setParentMenuTitle(i18n.t("File"));
+ final ActionToolbarMenuDescriptor<StateToken> refreshCnt = createRefreshCntAction(parentMenuTitle);
- final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupCxt;
- setAsDefGroupCxt = createSetAsDefContent();
- setAsDefGroupCxt.setParentMenuTitle(i18n.t("Folder"));
+ final ActionToolbarMenuDescriptor<StateToken> refreshCtx = createRefreshCxtAction(parentMenuTitleCtx);
- final ActionToolbarMenuDescriptor<StateToken> refreshCtx = new ActionToolbarMenuDescriptor<StateToken>(
- AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- stateManager.reload();
- contextNavigator.selectItem(stateToken);
- }
- });
- refreshCtx.setMustBeAuthenticated(false);
- refreshCtx.setParentMenuTitle(i18n.t("Folder"));
- refreshCtx.setTextDescription(i18n.t("Refresh"));
- refreshCtx.setIconUrl("images/nav/refresh.png");
-
- final ActionToolbarMenuDescriptor<StateToken> refreshCnt = new ActionToolbarMenuDescriptor<StateToken>(
- AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- stateManager.reload();
- contextNavigator.selectItem(stateToken);
- }
- });
- refreshCnt.setMustBeAuthenticated(false);
- refreshCnt.setParentMenuTitle(i18n.t("File"));
- refreshCnt.setTextDescription(i18n.t("Refresh"));
- refreshCnt.setIconUrl("images/nav/refresh.png");
-
final ActionToolbarButtonAndItemDescriptor<StateToken> uploadFile = createUploadAction(i18n.t("Upload file"),
"images/nav/upload.png", i18n.t("Upload some files (images, PDFs, ...)"), null);
- session.onInitDataReceived(new Listener<InitDataDTO>() {
- public void onEvent(final InitDataDTO parameter) {
- final ActionToolbarButtonAndItemDescriptor<StateToken> uploadMedia = createUploadAction(
- i18n.t("Upload media"), "images/nav/upload.png", i18n.t("Upload some media (images, videos)"),
- session.getGalleryPermittedExtensions());
- contextActionRegistry.addAction(uploadMedia, TYPE_GALLERY);
- }
- });
-
- final ActionToolbarButtonDescriptor<StateToken> download = new ActionToolbarButtonDescriptor<StateToken>(
- AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- downloadContent(token);
- }
- });
- download.setMustBeAuthenticated(false);
- download.setTextDescription(i18n.t("Download"));
- download.setToolTip(i18n.t("Download this file"));
- download.setIconUrl("images/nav/download.png");
-
- final ActionMenuItemDescriptor<StateToken> downloadCtx = new ActionMenuItemDescriptor<StateToken>(
- AccessRolDTO.Viewer, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- downloadContent(token);
- }
- });
- downloadCtx.setMustBeAuthenticated(false);
- downloadCtx.setTextDescription(i18n.t("Download"));
- downloadCtx.setIconUrl("images/nav/download.png");
-
- final ActionToolbarMenuAndItemDescriptor<StateToken> setGroupLogo = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- groupServiceProvider.get().setGroupFullLogo(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 itemToken) {
- final BasicMimeTypeDTO mime = session.getContentState().getMimeType();
- return mime != null && mime.getType().equals("image");
- }
- });
-
final ActionToolbarMenuDescriptor<StateToken> setPublishStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("Published online"), ContentStatusDTO.publishedOnline);
final ActionToolbarMenuDescriptor<StateToken> setEditionInProgressStatus = createSetStatusAction(
@@ -320,74 +127,6 @@
final ActionToolbarMenuDescriptor<StateToken> setInTheDustBinStatus = createSetStatusAction(
AccessRolDTO.Administrator, i18n.t("In the dustbin"), ContentStatusDTO.inTheDustbin);
- final ActionToolbarButtonDescriptor<StateToken> translateContent = new ActionToolbarButtonDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.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");
- translateContent.setLeftSeparator(ActionToolbarButtonSeparator.spacer);
-
- final ActionToolbarButtonDescriptor<StateToken> editContent = new ActionToolbarButtonDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- session.check(new AsyncCallbackSimple<Object>() {
- public void onSuccess(final Object result) {
- final TextEditor editor = textEditorProvider.get();
- documentViewer.detach();
- contextNavigator.detach();
- contextPropEditorProvider.get().attach();
- editor.editContent(session.getContentState().getContent(), new Listener<String>() {
- public void onEvent(final String html) {
- Site.showProgressSaving();
- contentServiceProvider.get().save(session.getUserHash(), stateToken, html,
- new AsyncCallback<Object>() {
- public void onFailure(final Throwable caught) {
- Site.hideProgress();
- try {
- throw caught;
- } catch (final SessionExpiredException e) {
- errorHandler.doSessionExpired();
- } catch (final Throwable e) {
- Site.error(i18n.t("Error saving document. Retrying..."));
- errorHandler.process(caught);
- editor.onSaveFailed();
- }
- }
-
- public void onSuccess(Object param) {
- Site.hideProgress();
- session.getContentState().setContent(html);
- editor.onSaved();
- }
- });
- }
- }, new Listener0() {
- public void onEvent() {
- // onClose
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- documentViewer.attach();
- contextPropEditorProvider.get().detach();
- contextNavigator.attach();
- if (session.getCurrentStateToken().equals(stateToken)) {
- documentViewer.refreshState();
- }
- }
- });
- }
- });
- }
- });
- }
- });
- editContent.setTextDescription(i18n.tWithNT("Edit", "used in button"));
- editContent.setIconUrl("images/content_edit.png");
- editContent.setLeftSeparator(ActionToolbarButtonSeparator.spacer);
-
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 };
@@ -419,135 +158,14 @@
contentActionRegistry.addAction(setAsDefGroupCnt, TYPE_DOCUMENT, TYPE_UPLOADEDFILE);
contentActionRegistry.addAction(setAsDefGroupCxt, TYPE_BLOG);
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 ActionToolbarMenuAndItemDescriptor<StateToken> createDocAction(String iconUrl, final String description,
- final String typeId) {
- final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- Site.showProgressProcessing();
- contentServiceProvider.get().addContent(session.getUserHash(),
- session.getCurrentState().getStateToken(), description, typeId,
- new AsyncCallbackSimple<StateContentDTO>() {
- public void onSuccess(final StateContentDTO state) {
- contextNavigator.setEditOnNextStateChange(true);
- stateManager.setRetrievedState(state);
- }
- });
- }
- });
- addDoc.setTextDescription(description);
- addDoc.setParentMenuTitle(i18n.t("Folder"));
- addDoc.setParentSubMenuTitle(i18n.t("New"));
- addDoc.setIconUrl(iconUrl);
- return addDoc;
+ @Override
+ protected void createPostSessionInitActions() {
+ contextActionRegistry.addAction(uploadMedia, TYPE_GALLERY);
}
-
- private ActionToolbarMenuAndItemDescriptor<StateToken> createFolderAction(final String contentTypeId,
- final String iconUrl, final String textDescription, final String parentMenuTitle,
- final String parentMenuSubtitle, final String defaultName) {
- final ActionToolbarMenuAndItemDescriptor<StateToken> addFolder;
- addFolder = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor,
- ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- Site.showProgressProcessing();
- contentServiceProvider.get().addFolder(session.getUserHash(), stateToken, defaultName,
- contentTypeId, new AsyncCallbackSimple<StateContainerDTO>() {
- public void onSuccess(final StateContainerDTO state) {
- contextNavigator.setEditOnNextStateChange(true);
- stateManager.setRetrievedState(state);
- }
- });
- }
- });
- addFolder.setTextDescription(textDescription);
- addFolder.setParentMenuTitle(parentMenuTitle);
- addFolder.setParentSubMenuTitle(parentMenuSubtitle);
- addFolder.setIconUrl(iconUrl);
- return addFolder;
- }
-
- private ActionToolbarMenuDescriptor<StateToken> createSetAsDefContent() {
- final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupContent;
- setAsDefGroupContent = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Administrator,
- ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- Site.showProgressProcessing();
- contentServiceProvider.get().setAsDefaultContent(session.getUserHash(), token,
- new AsyncCallbackSimple<ContentSimpleDTO>() {
- public void onSuccess(final ContentSimpleDTO defContent) {
- session.getCurrentState().getGroup().setDefaultContent(defContent);
- Site.hideProgress();
- Site.info(i18n.t("Document selected as the group homepage"));
- }
- });
- }
- });
- setAsDefGroupContent.setTextDescription(i18n.t("Set this as the group default page"));
- setAsDefGroupContent.setIconUrl("images/group-home.png");
- setAsDefGroupContent.setEnableCondition(new ActionEnableCondition<StateToken>() {
- public boolean mustBeEnabled(final StateToken itemToken) {
- final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
- return !itemToken.equals(defContentToken);
- }
- });
- return setAsDefGroupContent;
- }
-
- private ActionToolbarMenuAndItemDescriptor<StateToken> createSetStatusAction(final AccessRolDTO rol,
- final String textDescription, final ContentStatusDTO status) {
- final ActionToolbarMenuAndItemDescriptor<StateToken> action = new ActionToolbarMenuAndItemDescriptor<StateToken>(
- rol, ActionToolbarPosition.topbar, new Listener<StateToken>() {
- public void onEvent(final StateToken stateToken) {
- final AsyncCallbackSimple<Object> callback = new AsyncCallbackSimple<Object>() {
- public void onSuccess(final Object result) {
- session.getContentState().setStatus(status);
- contextNavigator.setItemStatus(stateToken, 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 ActionToolbarButtonAndItemDescriptor<StateToken> createUploadAction(final String textDescription,
- final String iconUrl, final String toolTip, final String permitedExtensions) {
- final ActionToolbarButtonAndItemDescriptor<StateToken> uploadFile;
- uploadFile = new ActionToolbarButtonAndItemDescriptor<StateToken>(AccessRolDTO.Editor,
- ActionToolbarPosition.bottombar, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- if (permitedExtensions != null) {
- // FIXME: can't be reset ...
- // fileUploaderProvider.get().setPermittedExtensions(permitedExtensions);
- } else {
- // FIXME: can't be reset ...
- // fileUploaderProvider.get().resetPermittedExtensions();
- }
- fileUploaderProvider.get().show();
- }
- });
- uploadFile.setTextDescription(textDescription);
- uploadFile.setIconUrl(iconUrl);
- uploadFile.setToolTip(toolTip);
- return uploadFile;
- }
-
- private void downloadContent(final StateToken token) {
- 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-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -36,27 +36,20 @@
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
-import org.ourproject.kune.platf.client.services.Images;
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.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.upload.FileUploader;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPanel;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView;
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.i18n.LanguageSelector;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import org.ourproject.kune.workspace.client.tags.TagsSummary;
import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
-import org.ourproject.kune.workspace.client.title.EntitySubTitle;
-import org.ourproject.kune.workspace.client.title.EntityTitle;
import com.calclab.suco.client.ioc.decorator.Singleton;
import com.calclab.suco.client.ioc.module.AbstractModule;
@@ -80,28 +73,14 @@
@Override
public DocumentClientActions create() {
return new DocumentClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $$(ContentServiceAsync.class),
- $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class),
- $(ContextActionRegistry.class), $$(FileDownloadUtils.class), $(EntityLogo.class),
- $$(TextEditor.class), $(KuneErrorHandler.class), $(DocumentViewer.class),
+ $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
+ $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
+ $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
+ $(EntityLogo.class), $$(TextEditor.class), $(KuneErrorHandler.class), $(DocumentViewer.class),
$$(ContextPropEditor.class));
}
});
- register(Singleton.class, new Factory<ContextPropEditor>(ContextPropEditor.class) {
- @Override
- public ContextPropEditor create() {
- final ContextPropEditorPresenter presenter = new ContextPropEditorPresenter($(Session.class),
- $(StateManager.class), $(ContentCapabilitiesRegistry.class), $$(TagsSummary.class),
- $$(ContentServiceAsync.class), $(EntityTitle.class), $(EntitySubTitle.class));
- final ContextPropEditorView view = new ContextPropEditorPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $$(LanguageSelector.class),
- $(Images.class));
- presenter.init(view);
- return presenter;
- }
- });
-
register(ToolGroup.class, new Factory<DocumentContext>(DocumentContext.class) {
@Override
public DocumentContext create() {
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewer.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewer.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewer.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -19,12 +19,7 @@
*/
package org.ourproject.kune.docs.client.cnt;
-public interface DocumentViewer {
+import org.ourproject.kune.workspace.client.cnt.FoldableContent;
- void attach();
-
- void detach();
-
- void refreshState();
-
+public interface DocumentViewer extends FoldableContent {
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentViewerPresenter.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -50,10 +50,6 @@
this.view = view;
}
- public void refreshState() {
- setState(session.getContentState());
- }
-
@Override
protected void setState(StateContentDTO state) {
super.setState(state);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -22,6 +22,8 @@
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
+import com.allen_sauer.gwt.log.client.Log;
+
public class ActionRegistry<T> {
private static final String GENERIC = "kgenacts";
@@ -36,8 +38,10 @@
}
public void addAction(final ActionDescriptor<T> action, String... typeIds) {
- for (final String contentTypeId : typeIds) {
- final ActionCollection<T> actionColl = getActions(contentTypeId);
+ assert (action != null);
+ for (final String typeId : typeIds) {
+ Log.debug("Registering action '" + action.getText() + "' for " + typeId);
+ final ActionCollection<T> actionColl = getActions(typeId);
actionColl.add(action);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -40,6 +40,8 @@
this.ws = ws;
topbar = new SimpleToolbar();
bottombar = new SimpleToolbar();
+ topbar.setWidth("100%");
+ bottombar.setWidth("100%");
this.actionManagerProvider = actionManagerProvider;
toolbarMenus = new HashMap<String, Menu>();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -71,6 +71,10 @@
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPanel;
import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPresenter;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPanel;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView;
import org.ourproject.kune.workspace.client.editor.TextEditor;
import org.ourproject.kune.workspace.client.editor.TextEditorPanel;
import org.ourproject.kune.workspace.client.editor.TextEditorPresenter;
@@ -118,7 +122,9 @@
import org.ourproject.kune.workspace.client.site.rpc.UserServiceAsync;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import org.ourproject.kune.workspace.client.tags.TagsSummary;
import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
+import org.ourproject.kune.workspace.client.title.EntitySubTitle;
import org.ourproject.kune.workspace.client.title.EntityTitle;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
@@ -495,6 +501,20 @@
}
});
+ register(Singleton.class, new Factory<ContextPropEditor>(ContextPropEditor.class) {
+ @Override
+ public ContextPropEditor create() {
+ final ContextPropEditorPresenter presenter = new ContextPropEditorPresenter($(Session.class),
+ $(StateManager.class), $(ContentCapabilitiesRegistry.class), $$(TagsSummary.class),
+ $$(ContentServiceAsync.class), $(EntityTitle.class), $(EntitySubTitle.class));
+ final ContextPropEditorView view = new ContextPropEditorPanel(presenter,
+ $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $$(LanguageSelector.class),
+ $(Images.class));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
@Override
public FileDownloadUtils create() {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -182,6 +182,7 @@
}
private Object[][] mapCountries() {
+ assert (initData != null);
final Object[][] objs = new Object[initData.getCountries().size()][1];
int i = 0;
for (I18nCountryDTO country : initData.getCountries()) {
@@ -192,6 +193,7 @@
}
private Object[][] mapLangs() {
+ assert (initData != null);
final Object[][] objs = new Object[initData.getLanguages().size()][1];
int i = 0;
for (I18nLanguageSimpleDTO language : initData.getLanguages()) {
@@ -202,6 +204,7 @@
}
private void mapTimezones() {
+ assert (initData != null);
timezonesArray = new Object[initData.getTimezones().length][1];
for (int i = 0; i < getTimezones().length; i++) {
final Object[] obj = new Object[] { initData.getTimezones()[i] };
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -0,0 +1,496 @@
+package org.ourproject.kune.workspace.client;
+
+import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
+import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
+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.StateContainerDTO;
+import org.ourproject.kune.platf.client.dto.StateContentDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.errors.SessionExpiredException;
+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.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
+import org.ourproject.kune.platf.client.ui.upload.FileUploader;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.workspace.client.cnt.FoldableContent;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
+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.site.Site;
+
+import com.calclab.suco.client.ioc.Provider;
+import com.calclab.suco.client.listener.Listener;
+import com.calclab.suco.client.listener.Listener0;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public abstract class AbstractFoldableContentActions {
+
+ protected final Session session;
+ protected final StateManager stateManager;
+ protected final I18nUITranslationService i18n;
+ protected final Provider<ContentServiceAsync> contentServiceProvider;
+ protected final Provider<FileUploader> fileUploaderProvider;
+ protected final ContextNavigator contextNavigator;
+ protected final KuneErrorHandler errorHandler;
+ protected final Provider<GroupServiceAsync> groupServiceProvider;
+ protected final ContentActionRegistry contentActionRegistry;
+ protected final ContextActionRegistry contextActionRegistry;
+ protected final Provider<FileDownloadUtils> fileDownloadProvider;
+ protected final Provider<TextEditor> textEditorProvider;
+ protected final Provider<ContextPropEditor> contextPropEditorProvider;
+ protected final FoldableContent foldableContent;
+ protected final DeferredCommandWrapper deferredCommandWrapper;
+ protected final EntityLogo entityLogo;
+ protected ActionMenuItemDescriptor<StateToken> go;
+ protected ActionToolbarButtonDescriptor<StateToken> goGroupHome;
+ protected ActionToolbarButtonAndItemDescriptor<StateToken> uploadMedia;
+ protected ActionToolbarButtonDescriptor<StateToken> download;
+ protected ActionMenuItemDescriptor<StateToken> downloadCtx;
+ protected ActionToolbarButtonDescriptor<StateToken> translateContent;
+ protected ActionToolbarButtonDescriptor<StateToken> editContent;
+
+ public AbstractFoldableContentActions(Session session, StateManager stateManager, I18nUITranslationService i18n,
+ KuneErrorHandler errorHandler, DeferredCommandWrapper deferredCommandWrapper,
+ Provider<GroupServiceAsync> groupServiceProvider, Provider<ContentServiceAsync> contentServiceProvider,
+ Provider<FileUploader> fileUploaderProvider, ContextNavigator contextNavigator,
+ ContentActionRegistry contentActionRegistry, ContextActionRegistry contextActionRegistry,
+ Provider<FileDownloadUtils> fileDownloadProvider, Provider<TextEditor> textEditorProvider,
+ Provider<ContextPropEditor> contextPropEditorProvider, FoldableContent foldableContent,
+ EntityLogo entityLogo) {
+ this.session = session;
+ this.stateManager = stateManager;
+ this.i18n = i18n;
+ this.errorHandler = errorHandler;
+ this.deferredCommandWrapper = deferredCommandWrapper;
+ this.groupServiceProvider = groupServiceProvider;
+ this.contentServiceProvider = contentServiceProvider;
+ this.fileUploaderProvider = fileUploaderProvider;
+ this.contextNavigator = contextNavigator;
+ this.contentActionRegistry = contentActionRegistry;
+ this.contextActionRegistry = contextActionRegistry;
+ this.fileDownloadProvider = fileDownloadProvider;
+ this.textEditorProvider = textEditorProvider;
+ this.contextPropEditorProvider = contextPropEditorProvider;
+ this.foldableContent = foldableContent;
+ this.entityLogo = entityLogo;
+ createCommonActions();
+ createActions();
+ session.onInitDataReceived(new Listener<InitDataDTO>() {
+ public void onEvent(InitDataDTO parameter) {
+ createCommonPostSessionInitActions();
+ createPostSessionInitActions();
+ }
+ });
+ }
+
+ protected void createActions() {
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createContentRenameAction(String parentMenuTitle,
+ String textDescription) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtn = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ contextNavigator.editItem(stateToken);
+ }
+ });
+ renameCtn.setTextDescription(textDescription);
+ renameCtn.setParentMenuTitle(parentMenuTitle);
+ return renameCtn;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createDelContainerAction(String text,
+ String parentMenuTitle) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> delContainer = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ Site.info("Sorry, in development");
+ }
+ });
+ delContainer.setParentMenuTitle(parentMenuTitle);
+ delContainer.setTextDescription(i18n.t(text));
+ delContainer.setMustBeConfirmed(true);
+ delContainer.setConfirmationTitle(i18n.t("Please confirm"));
+ delContainer.setConfirmationText(i18n.t("You will delete it and also all its contents. Are you sure?"));
+ return delContainer;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createDelContentAction(String parentMenuTitle,
+ String textDescription) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> delContent = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ contentServiceProvider.get().delContent(session.getUserHash(), token,
+ new AsyncCallbackSimple<String>() {
+ public void onSuccess(final String result) {
+ final StateToken parent = token.clone().clearDocument();
+ stateManager.gotoToken(parent);
+ }
+ });
+ }
+ });
+ delContent.setParentMenuTitle(parentMenuTitle);
+ delContent.setTextDescription(textDescription);
+ delContent.setMustBeConfirmed(true);
+ delContent.setConfirmationTitle(i18n.t("Please confirm"));
+ delContent.setConfirmationText(i18n.t("Are you sure?"));
+ delContent.setEnableCondition(new ActionEnableCondition<StateToken>() {
+ public boolean mustBeEnabled(final StateToken itemToken) {
+ final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
+ return !itemToken.equals(defContentToken);
+ }
+ });
+ return delContent;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createDocAction(String iconUrl, final String description,
+ final String typeId) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addDoc = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ Site.showProgressProcessing();
+ contentServiceProvider.get().addContent(session.getUserHash(),
+ session.getCurrentState().getStateToken(), description, typeId,
+ new AsyncCallbackSimple<StateContentDTO>() {
+ public void onSuccess(final StateContentDTO state) {
+ contextNavigator.setEditOnNextStateChange(true);
+ stateManager.setRetrievedState(state);
+ }
+ });
+ }
+ });
+ addDoc.setTextDescription(description);
+ addDoc.setParentMenuTitle(i18n.t("Folder"));
+ addDoc.setParentSubMenuTitle(i18n.t("New"));
+ addDoc.setIconUrl(iconUrl);
+ return addDoc;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createFolderAction(final String contentTypeId,
+ final String iconUrl, final String textDescription, final String parentMenuTitle,
+ final String parentMenuSubtitle, final String defaultName) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> addFolder;
+ addFolder = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor,
+ ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ Site.showProgressProcessing();
+ contentServiceProvider.get().addFolder(session.getUserHash(), stateToken, defaultName,
+ contentTypeId, new AsyncCallbackSimple<StateContainerDTO>() {
+ public void onSuccess(final StateContainerDTO state) {
+ contextNavigator.setEditOnNextStateChange(true);
+ stateManager.setRetrievedState(state);
+ }
+ });
+ }
+ });
+ addFolder.setTextDescription(textDescription);
+ addFolder.setParentMenuTitle(parentMenuTitle);
+ addFolder.setParentSubMenuTitle(parentMenuSubtitle);
+ addFolder.setIconUrl(iconUrl);
+ return addFolder;
+ }
+
+ protected void createPostSessionInitActions() {
+ }
+
+ protected ActionToolbarMenuDescriptor<StateToken> createRefreshCntAction(String parentMenuTitle) {
+ final ActionToolbarMenuDescriptor<StateToken> refreshCnt = new ActionToolbarMenuDescriptor<StateToken>(
+ AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ stateManager.reload();
+ contextNavigator.selectItem(stateToken);
+ }
+ });
+ refreshCnt.setMustBeAuthenticated(false);
+ refreshCnt.setParentMenuTitle(parentMenuTitle);
+ refreshCnt.setTextDescription(i18n.t("Refresh"));
+ refreshCnt.setIconUrl("images/nav/refresh.png");
+ return refreshCnt;
+ }
+
+ protected ActionToolbarMenuDescriptor<StateToken> createRefreshCxtAction(String parentMenuTitleCtx) {
+ final ActionToolbarMenuDescriptor<StateToken> refreshCtx = new ActionToolbarMenuDescriptor<StateToken>(
+ AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ stateManager.reload();
+ contextNavigator.selectItem(stateToken);
+ }
+ });
+ refreshCtx.setMustBeAuthenticated(false);
+ refreshCtx.setParentMenuTitle(parentMenuTitleCtx);
+ refreshCtx.setTextDescription(i18n.t("Refresh"));
+ refreshCtx.setIconUrl("images/nav/refresh.png");
+ return refreshCtx;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createRenameContentInCtxAction(String parentMenuTitleCtx,
+ String textDescription) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtx = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ contextNavigator.editItem(stateToken);
+ }
+ });
+ renameCtx.setTextDescription(textDescription);
+ renameCtx.setParentMenuTitle(parentMenuTitleCtx);
+ return renameCtx;
+ }
+
+ protected ActionToolbarMenuDescriptor<StateToken> createSetAsDefContent(String parentMenuTitle) {
+ final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupContent;
+ setAsDefGroupContent = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Administrator,
+ ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ Site.showProgressProcessing();
+ contentServiceProvider.get().setAsDefaultContent(session.getUserHash(), token,
+ new AsyncCallbackSimple<ContentSimpleDTO>() {
+ public void onSuccess(final ContentSimpleDTO defContent) {
+ session.getCurrentState().getGroup().setDefaultContent(defContent);
+ Site.hideProgress();
+ Site.info(i18n.t("Document selected as the group homepage"));
+ }
+ });
+ }
+ });
+ setAsDefGroupContent.setTextDescription(i18n.t("Set this as the group default page"));
+ setAsDefGroupContent.setIconUrl("images/group-home.png");
+ setAsDefGroupContent.setEnableCondition(new ActionEnableCondition<StateToken>() {
+ public boolean mustBeEnabled(final StateToken itemToken) {
+ final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
+ return !itemToken.equals(defContentToken);
+ }
+ });
+ setAsDefGroupContent.setParentMenuTitle(parentMenuTitle);
+ return setAsDefGroupContent;
+ }
+
+ protected ActionToolbarMenuAndItemDescriptor<StateToken> createSetStatusAction(final AccessRolDTO rol,
+ final String textDescription, final ContentStatusDTO status) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> action = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ rol, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ final AsyncCallbackSimple<Object> callback = new AsyncCallbackSimple<Object>() {
+ public void onSuccess(final Object result) {
+ session.getContentState().setStatus(status);
+ contextNavigator.setItemStatus(stateToken, 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;
+ }
+
+ protected ActionToolbarButtonAndItemDescriptor<StateToken> createUploadAction(final String textDescription,
+ final String iconUrl, final String toolTip, final String permitedExtensions) {
+ final ActionToolbarButtonAndItemDescriptor<StateToken> uploadFile;
+ uploadFile = new ActionToolbarButtonAndItemDescriptor<StateToken>(AccessRolDTO.Editor,
+ ActionToolbarPosition.bottombar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ if (permitedExtensions != null) {
+ // FIXME: can't be reset ...
+ // fileUploaderProvider.get().setPermittedExtensions(permitedExtensions);
+ } else {
+ // FIXME: can't be reset ...
+ // fileUploaderProvider.get().resetPermittedExtensions();
+ }
+ fileUploaderProvider.get().show();
+ }
+ });
+ uploadFile.setTextDescription(textDescription);
+ uploadFile.setIconUrl(iconUrl);
+ uploadFile.setToolTip(toolTip);
+ return uploadFile;
+ }
+
+ protected void downloadContent(final StateToken token) {
+ fileDownloadProvider.get().downloadFile(token);
+ }
+
+ private void createCommonActions() {
+ go = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ stateManager.gotoToken(token);
+ }
+ });
+ go.setMustBeAuthenticated(false);
+ go.setTextDescription(i18n.t("Open"));
+ go.setIconUrl("images/nav/go.png");
+ go.setEnableCondition(new ActionEnableCondition<StateToken>() {
+ public boolean mustBeEnabled(final StateToken itemToken) {
+ return !contextNavigator.isSelected(itemToken);
+ }
+ });
+
+ goGroupHome = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, ActionToolbarPosition.topbar,
+ new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ stateManager.gotoToken(token.getGroup());
+ }
+ });
+ goGroupHome.setMustBeAuthenticated(false);
+ goGroupHome.setIconUrl("images/group-home.png");
+ goGroupHome.setEnableCondition(new ActionEnableCondition<StateToken>() {
+ public boolean mustBeEnabled(final StateToken itemToken) {
+ final StateToken defContentToken = session.getCurrentState().getGroup().getDefaultContent().getStateToken();
+ return !itemToken.equals(defContentToken);
+ }
+ });
+ goGroupHome.setLeftSeparator(ActionToolbarButtonSeparator.fill);
+
+ download = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, ActionToolbarPosition.topbar,
+ new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ downloadContent(token);
+ }
+ });
+ download.setMustBeAuthenticated(false);
+ download.setTextDescription(i18n.t("Download"));
+ download.setToolTip(i18n.t("Download this file"));
+ download.setIconUrl("images/nav/download.png");
+
+ downloadCtx = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ downloadContent(token);
+ }
+ });
+ downloadCtx.setMustBeAuthenticated(false);
+ downloadCtx.setTextDescription(i18n.t("Download"));
+ downloadCtx.setIconUrl("images/nav/download.png");
+
+ translateContent = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Editor,
+ ActionToolbarPosition.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");
+ translateContent.setLeftSeparator(ActionToolbarButtonSeparator.spacer);
+
+ editContent = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Editor, ActionToolbarPosition.topbar,
+ new Listener<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ session.check(new AsyncCallbackSimple<Object>() {
+ public void onSuccess(final Object result) {
+ final TextEditor editor = textEditorProvider.get();
+ foldableContent.detach();
+ contextNavigator.detach();
+ contextPropEditorProvider.get().attach();
+ editor.editContent(session.getContentState().getContent(), new Listener<String>() {
+ public void onEvent(final String html) {
+ Site.showProgressSaving();
+ contentServiceProvider.get().save(session.getUserHash(), stateToken, html,
+ new AsyncCallback<Object>() {
+ public void onFailure(final Throwable caught) {
+ Site.hideProgress();
+ try {
+ throw caught;
+ } catch (final SessionExpiredException e) {
+ errorHandler.doSessionExpired();
+ } catch (final Throwable e) {
+ Site.error(i18n.t("Error saving document. Retrying..."));
+ errorHandler.process(caught);
+ editor.onSaveFailed();
+ }
+ }
+
+ public void onSuccess(Object param) {
+ Site.hideProgress();
+ session.getContentState().setContent(html);
+ editor.onSaved();
+ }
+ });
+ }
+ }, new Listener0() {
+ public void onEvent() {
+ // onClose
+ deferredCommandWrapper.addCommand(new Listener0() {
+ public void onEvent() {
+ foldableContent.attach();
+ contextPropEditorProvider.get().detach();
+ contextNavigator.attach();
+ if (session.getCurrentStateToken().equals(stateToken)) {
+ foldableContent.refreshState();
+ }
+ }
+ });
+ }
+ });
+ }
+ });
+ }
+ });
+ editContent.setTextDescription(i18n.tWithNT("Edit", "used in button"));
+ editContent.setIconUrl("images/content_edit.png");
+ editContent.setLeftSeparator(ActionToolbarButtonSeparator.spacer);
+
+ }
+
+ private void createCommonPostSessionInitActions() {
+ uploadMedia = createUploadAction(i18n.t("Upload media"), "images/nav/upload.png",
+ i18n.t("Upload some media (images, videos)"), session.getGalleryPermittedExtensions());
+ }
+
+ /**
+ * For future use contentActionRegistry.addAction(setGroupLogo,
+ * TYPE_UPLOADEDFILE);
+ */
+ @SuppressWarnings("unused")
+ private ActionToolbarMenuAndItemDescriptor<StateToken> createSetGroupLogoAction(String parentMenuTitle) {
+ final ActionToolbarMenuAndItemDescriptor<StateToken> setGroupLogo = new ActionToolbarMenuAndItemDescriptor<StateToken>(
+ AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() {
+ public void onEvent(final StateToken token) {
+ groupServiceProvider.get().setGroupFullLogo(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(parentMenuTitle);
+ 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 itemToken) {
+ final BasicMimeTypeDTO mime = session.getContentState().getMimeType();
+ return mime != null && mime.getType().equals("image");
+ }
+ });
+ return setGroupLogo;
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContent.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContent.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContent.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -0,0 +1,11 @@
+package org.ourproject.kune.workspace.client.cnt;
+
+public interface FoldableContent {
+
+ void attach();
+
+ void detach();
+
+ void refreshState();
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -13,7 +13,7 @@
import com.calclab.suco.client.listener.Listener;
-public abstract class FoldableContentPresenter extends AbstractContentPresenter {
+public abstract class FoldableContentPresenter extends AbstractContentPresenter implements FoldableContent {
private final String toolName;
private final ActionRegistry<StateToken> actionRegistry;
@@ -37,6 +37,10 @@
return toolName;
}
+ public void refreshState() {
+ setState(session.getContentState());
+ }
+
protected void setState(StateAbstractDTO state) {
toolbar.detach();
if (state instanceof StateContainerDTO) {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java 2008-11-24 11:49:57 UTC (rev 964)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Toolbar.java 2008-11-24 18:14:39 UTC (rev 965)
@@ -42,6 +42,10 @@
public void add(final Widget widget) {
childPanel.add(widget);
+ if (widget instanceof SimpleToolbar) {
+ widget.setWidth("100%");
+ childPanel.setCellWidth(widget, "100%");
+ }
doLayoutIfNeeded();
}
More information about the kune-commits
mailing list