Author: vjrj Date: 2008-09-30 03:49:58 +0200 (Tue, 30 Sep 2008) New Revision: 897 Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 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/DocumentContentPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentActionRegistry.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java Log: Complete - task 62: ContextNav tree scroll problem Actions now has an option to enable/disble it if the user is logged or not Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2008-09-30 01:49:58 UTC (rev 897) @@ -3171,30 +3171,36 @@ text-decoration: underline; } -.k-entity-context-default div { +.k-entity-context-default div, .k-entity-context-default .x-tree .x-panel-body { background: #FFD09D none repeat scroll 0% 50%; } -.k-entity-context-green div { +.k-entity-context-green div, .k-entity-context-green .x-tree .x-panel-body { background: #CFA none repeat scroll 0% 50%; } -.k-entity-context-blue div { +.k-entity-context-blue div, .k-entity-context-blue .x-tree .x-panel-body { background: #AACCFF none repeat scroll 0% 50%; } -.k-entity-context-grey div { +.k-entity-context-grey div, .k-entity-context-grey .x-tree .x-panel-body { background: #B3B3B3 none repeat scroll 0% 50%; } -.k-entity-context-purple div { +.k-entity-context-purple div, .k-entity-context-purple .x-tree .x-panel-body { background: #DDAFE9 none repeat scroll 0% 50%; } -.k-entity-context-red div { +.k-entity-context-red div, .k-entity-context-purple .x-tree .x-panel-body { background: #FFAAAA none repeat scroll 0% 50%; } + +.k-entity-context-purple .x-tree .x-panel-body { + background: #DDAFE9 none repeat scroll 0% 50%; +} + + .k-entity-bottom div { line-height: 2em; color: #FFF; Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2008-09-30 01:49:58 UTC (rev 897) @@ -336,30 +336,36 @@ text-decoration: underline; } -.k-entity-context-default div { +.k-entity-context-default div, .k-entity-context-default .x-tree .x-panel-body { background: #FFD09D none repeat scroll 0% 50%; } -.k-entity-context-green div { +.k-entity-context-green div, .k-entity-context-green .x-tree .x-panel-body { background: #CFA none repeat scroll 0% 50%; } -.k-entity-context-blue div { +.k-entity-context-blue div, .k-entity-context-blue .x-tree .x-panel-body { background: #AACCFF none repeat scroll 0% 50%; } -.k-entity-context-grey div { +.k-entity-context-grey div, .k-entity-context-grey .x-tree .x-panel-body { background: #B3B3B3 none repeat scroll 0% 50%; } -.k-entity-context-purple div { +.k-entity-context-purple div, .k-entity-context-purple .x-tree .x-panel-body { background: #DDAFE9 none repeat scroll 0% 50%; } -.k-entity-context-red div { +.k-entity-context-red div, .k-entity-context-red .x-tree .x-panel-body { background: #FFAAAA none repeat scroll 0% 50%; } + +.k-entity-context-purple .x-tree .x-panel-body { + background: #DDAFE9 none repeat scroll 0% 50%; +} + + .k-entity-bottom div { line-height: 2em; color: #FFF; 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-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-09-30 01:49:58 UTC (rev 897) @@ -148,6 +148,7 @@ stateManager.gotoToken(token); } }); + go.setMustBeAuthenticated(false); go.setTextDescription(i18n.t("Open")); go.setIconUrl("images/nav/go.png"); go.setEnableCondition(new ActionEnableCondition<StateToken>() { @@ -180,6 +181,7 @@ stateManager.gotoToken(token.getGroup()); } }); + goGroupHome.setMustBeAuthenticated(false); goGroupHome.setIconUrl("images/group-home.png"); goGroupHome.setEnableCondition(new ActionEnableCondition<StateToken>() { public boolean mustBeEnabled(final StateToken currentStateToken) { @@ -204,6 +206,7 @@ contextNavigator.selectItem(stateToken); } }); + refreshCtx.setMustBeAuthenticated(false); refreshCtx.setParentMenuTitle(i18n.t("Folder")); refreshCtx.setTextDescription(i18n.t("Refresh")); refreshCtx.setIconUrl("images/nav/refresh.png"); @@ -215,6 +218,7 @@ contextNavigator.selectItem(stateToken); } }); + refreshCnt.setMustBeAuthenticated(false); refreshCnt.setParentMenuTitle(i18n.t("File")); refreshCnt.setTextDescription(i18n.t("Refresh")); refreshCnt.setIconUrl("images/nav/refresh.png"); @@ -237,6 +241,7 @@ downloadContent(token); } }); + download.setMustBeAuthenticated(false); download.setTextDescription(i18n.t("Download")); download.setToolTip(i18n.t("Download this file")); download.setIconUrl("images/nav/download.png"); @@ -247,6 +252,7 @@ downloadContent(token); } }); + downloadCtx.setMustBeAuthenticated(false); downloadCtx.setTextDescription(i18n.t("Download")); downloadCtx.setIconUrl("images/nav/download.png"); @@ -322,12 +328,12 @@ 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); + contentActionRegistry.addAction(renameCtn, contents); contextActionRegistry.addAction(renameCtx, containersNoRoot); - contentActionRegistry.addAction(renameCtn, contents); contextActionRegistry.addAction(refreshCtx, containers); contentActionRegistry.addAction(refreshCnt, contents); + contextActionRegistry.addAction(uploadFile, TYPE_ROOT, TYPE_FOLDER, TYPE_BLOG); + contentActionRegistry.addAction(download, TYPE_UPLOADEDFILE); contentActionRegistry.addAction(delContent, contents); contextActionRegistry.addAction(delContainer, containersNoRoot); contentActionRegistry.addAction(setAsDefGroupCnt, TYPE_DOCUMENT, TYPE_UPLOADEDFILE); 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-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-09-30 01:49:58 UTC (rev 897) @@ -27,6 +27,7 @@ import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter; import org.ourproject.kune.platf.client.app.ToolGroup; +import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.platf.client.rpc.ContentServiceAsync; import org.ourproject.kune.platf.client.rpc.GroupServiceAsync; import org.ourproject.kune.platf.client.services.KuneErrorHandler; @@ -79,10 +80,10 @@ register(ToolGroup.class, new Factory<DocumentContent>(DocumentContent.class) { public DocumentContent create() { - final ActionToolbarPanel contentNavigatorToolbar = new ActionToolbarPanel( + final ActionToolbarPanel<StateToken> contentNavigatorToolbar = new ActionToolbarPanel<StateToken>( ActionToolbarPanel.Position.content, $$(ActionManager.class), $(WorkspaceSkeleton.class)); - final ActionToolbar toolbar = new ActionToolbarPresenter(contentNavigatorToolbar, - $(ContentActionRegistry.class)); + final ActionToolbar<StateToken> toolbar = new ActionToolbarPresenter<StateToken>( + contentNavigatorToolbar, $(ContentActionRegistry.class)); final DocumentContentPresenter presenter = new DocumentContentPresenter($(StateManager.class), $(I18nUITranslationService.class), $(KuneErrorHandler.class), $(Session.class), Modified: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java 2008-09-30 01:49:58 UTC (rev 897) @@ -61,14 +61,14 @@ private final Provider<ContentServiceAsync> contentServiceProvider; private final I18nUITranslationService i18n; private final KuneErrorHandler errorHandler; - private final ActionToolbar toolbar; + private final ActionToolbar<StateToken> toolbar; private final ActionRegistry<StateToken> actionRegistry; public DocumentContentPresenter(final StateManager stateManager, final I18nUITranslationService i18n, final KuneErrorHandler errorHandler, final Session session, final RateIt rateIt, final Provider<DocumentReader> docReaderProvider, final Provider<TextEditor> textEditorProvider, final Provider<FolderViewer> folderViewerProvider, - final Provider<ContentServiceAsync> contentServiceProvider, final ActionToolbar toolbar, + final Provider<ContentServiceAsync> contentServiceProvider, final ActionToolbar<StateToken> toolbar, final ActionRegistry<StateToken> actionRegistry) { this.stateManager = stateManager; this.i18n = i18n; @@ -192,11 +192,11 @@ final String typeId = content.getTypeId(); ActionItemCollection<StateToken> collection; if (content.hasDocument()) { - collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId, content.getContentRights(), - true); + collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId, session.isLogged(), content + .getContentRights(), true); } else { - collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId, - content.getContainerRights(), true); + collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId, session.isLogged(), content + .getContainerRights(), true); } toolbar.disableMenusAndClearButtons(); toolbar.showActions(collection, true); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2008-09-30 01:49:58 UTC (rev 897) @@ -19,23 +19,26 @@ private final Listener<T> onPerformCall; private final Listener<T> onNotConfirmed; + private boolean mustBeAuthenticated; + private AccessRolDTO accessRol; private ActionEnableCondition<T> enableCondition; + public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener<T> onPerformCall) { + this.accessRol = accessRolDTO; + this.onPerformCall = onPerformCall; + this.mustBeConfirmed = false; + this.onNotConfirmed = null; + this.mustBeAuthenticated = true; + } + public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener<T> onPerformCall, final ActionEnableCondition<T> enableCondition) { this(accessRolDTO, onPerformCall); this.enableCondition = enableCondition; } - public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener<T> onPerformCall) { - accessRol = accessRolDTO; - this.onPerformCall = onPerformCall; - mustBeConfirmed = false; - onNotConfirmed = null; - } - @SuppressWarnings("unchecked") public void fireOnNotConfirmed(final Object parameter) { if (onNotConfirmed != null) { @@ -84,6 +87,10 @@ return mustBeConfirmed; } + public boolean mustBeAuthenticated() { + return mustBeAuthenticated; + } + public void setAccessRol(final AccessRolDTO accessRol) { this.accessRol = accessRol; } @@ -108,6 +115,10 @@ this.iconUrl = iconUrl; } + public void setMustBeAuthenticated(final boolean mustBeAuthenticated) { + this.mustBeAuthenticated = mustBeAuthenticated; + } + public void setMustBeConfirmed(final boolean mustBeConfirmed) { this.mustBeConfirmed = mustBeConfirmed; } 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-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java 2008-09-30 01:49:58 UTC (rev 897) @@ -24,18 +24,20 @@ return enableCondition != null ? enableCondition.mustBeEnabled(T) : true; } - public ActionItemCollection<T> getCurrentActions(final T item, final String contentTypeId, + public ActionItemCollection<T> getCurrentActions(final T item, final String contentTypeId, final boolean isLogged, final AccessRightsDTO rights, final boolean toolbarItems) { final ActionItemCollection<T> collection = new ActionItemCollection<T>(); for (final ActionDescriptor<T> action : getActions(contentTypeId)) { - if (mustAdd(rights, action)) { + if (mustAdd(isLogged, rights, action)) { if (toolbarItems) { - if (action instanceof ActionToolbarButtonDescriptor<?> || action instanceof ActionToolbarMenuDescriptor<?>) { + if (action instanceof ActionToolbarButtonDescriptor<?> + || action instanceof ActionToolbarMenuDescriptor<?>) { collection.add(new ActionItem<T>(action, item)); } } else { - if (action instanceof ActionMenuItemDescriptor<?> || action instanceof ActionToolbarMenuAndItemDescriptor<?> + if (action instanceof ActionMenuItemDescriptor<?> + || action instanceof ActionToolbarMenuAndItemDescriptor<?> || action instanceof ActionToolbarButtonAndItemDescriptor<?>) { collection.add(new ActionItem<T>(action, item)); } @@ -58,7 +60,12 @@ return actionColl; } - private boolean mustAdd(final AccessRightsDTO rights, final ActionDescriptor<T> action) { + private boolean mustAdd(final boolean isLogged, final AccessRightsDTO rights, final ActionDescriptor<T> action) { + if (action.mustBeAuthenticated()) { + if (!isLogged) { + return false; + } + } switch (action.getAccessRol()) { case Administrator: return rights.isAdministrable(); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentActionRegistry.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentActionRegistry.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentActionRegistry.java 2008-09-30 01:49:58 UTC (rev 897) @@ -3,5 +3,4 @@ import org.ourproject.kune.platf.client.dto.StateToken; public class ContentActionRegistry extends ActionRegistry<StateToken> { - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2008-09-30 01:49:58 UTC (rev 897) @@ -1,9 +1,8 @@ package org.ourproject.kune.platf.client.actions.toolbar; import org.ourproject.kune.platf.client.actions.ActionItemCollection; -import org.ourproject.kune.platf.client.dto.StateToken; -public interface ActionToolbar { +public interface ActionToolbar<T> { void attach(); @@ -13,6 +12,6 @@ void disableMenusAndClearButtons(); - void showActions(ActionItemCollection<StateToken> actionItemCollection, boolean isItemSelected); + void showActions(ActionItemCollection<T> actionItemCollection, boolean isItemSelected); } 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-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-09-30 01:49:58 UTC (rev 897) @@ -3,13 +3,12 @@ import java.util.ArrayList; import java.util.HashMap; -import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; import org.ourproject.kune.platf.client.actions.ActionItem; import org.ourproject.kune.platf.client.actions.ActionManager; +import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; -import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.workspace.client.skel.SimpleToolbar; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -25,7 +24,7 @@ import com.gwtext.client.widgets.menu.MenuItem; import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter; -public class ActionToolbarPanel implements ActionToolbarView { +public class ActionToolbarPanel<T> implements ActionToolbarView<T> { public enum Position { content, context @@ -53,8 +52,8 @@ menuItems = new HashMap<String, Item>(); } - public void addButtonAction(final ActionItem<StateToken> actionItem) { - final ActionToolbarButtonDescriptor<StateToken> action = (ActionToolbarButtonDescriptor<StateToken>) actionItem.getAction(); + public void addButtonAction(final ActionItem<T> actionItem) { + final ActionToolbarButtonDescriptor<T> action = (ActionToolbarButtonDescriptor<T>) actionItem.getAction(); final ActionToolbarPosition pos = action.getActionPosition(); final ToolbarButton button = new ToolbarButton(); final String text = action.getText(); @@ -84,8 +83,8 @@ removableToolbarItems.add(button); } - public void addMenuAction(final ActionItem<StateToken> actionItem, final boolean enable) { - final ActionToolbarMenuDescriptor<StateToken> action = (ActionToolbarMenuDescriptor<StateToken>) actionItem.getAction(); + public void addMenuAction(final ActionItem<T> actionItem, final boolean enable) { + final ActionToolbarMenuDescriptor<T> action = (ActionToolbarMenuDescriptor<T>) actionItem.getAction(); final String menuTitle = action.getParentMenuTitle(); final String menuSubTitle = action.getParentSubMenuTitle(); final ActionToolbarPosition pos = action.getActionPosition(); @@ -171,9 +170,9 @@ } } - private Item createToolbarMenu(final ActionToolbarPosition toolBarPos, final String menuTitle, final String menuSubTitle, - final ActionItem<StateToken> actionItem) { - final ActionToolbarMenuDescriptor<StateToken> action = (ActionToolbarMenuDescriptor<StateToken>) actionItem.getAction(); + private Item createToolbarMenu(final ActionToolbarPosition toolBarPos, final String menuTitle, + final String menuSubTitle, final ActionItem<T> actionItem) { + final ActionToolbarMenuDescriptor<T> action = (ActionToolbarMenuDescriptor<T>) actionItem.getAction(); final Item item = new Item(action.getText(), new BaseItemListenerAdapter() { @Override public void onClick(BaseItem item, EventObject e) { @@ -208,8 +207,8 @@ return item; } - private Menu createToolbarMenu(final ActionToolbarPosition barPosition, final String iconUrl, final String menuTitle, - final String menuKey) { + private Menu createToolbarMenu(final ActionToolbarPosition barPosition, final String iconUrl, + final String menuTitle, final String menuKey) { final Menu menu = new Menu(); final ToolbarButton toolbarMenu = new ToolbarButton(menuTitle); toolbarMenu.setMenu(menu); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2008-09-30 01:49:58 UTC (rev 897) @@ -8,15 +8,14 @@ import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; -import org.ourproject.kune.platf.client.dto.StateToken; import com.allen_sauer.gwt.log.client.Log; -public class ActionToolbarPresenter implements ActionToolbar { - private final ActionToolbarView toolbar; - private final ActionRegistry<StateToken> actionRegistry; +public class ActionToolbarPresenter<T> implements ActionToolbar<T> { + private final ActionToolbarView<T> toolbar; + private final ActionRegistry<T> actionRegistry; - public ActionToolbarPresenter(final ActionToolbarView toolbar, final ActionRegistry<StateToken> actionRegistry) { + public ActionToolbarPresenter(final ActionToolbarView<T> toolbar, final ActionRegistry<T> actionRegistry) { this.toolbar = toolbar; this.actionRegistry = actionRegistry; } @@ -40,9 +39,9 @@ // toolbar.disableAllMenuItems(); } - public void showActions(final ActionItemCollection<StateToken> actions, final boolean isItemSelected) { - for (final ActionItem<StateToken> actionItem : actions) { - final ActionDescriptor<StateToken> action = actionItem.getAction(); + public void showActions(final ActionItemCollection<T> actions, final boolean isItemSelected) { + for (final ActionItem<T> actionItem : actions) { + final ActionDescriptor<T> action = actionItem.getAction(); if (action instanceof ActionToolbarMenuDescriptor || action instanceof ActionToolbarMenuAndItemDescriptor) { toolbar.addMenuAction(actionItem, isItemSelected && actionRegistry.checkEnabling(action, actionItem.getItem())); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2008-09-30 01:49:58 UTC (rev 897) @@ -1,13 +1,12 @@ package org.ourproject.kune.platf.client.actions.toolbar; import org.ourproject.kune.platf.client.actions.ActionItem; -import org.ourproject.kune.platf.client.dto.StateToken; -public interface ActionToolbarView { +public interface ActionToolbarView<T> { - void addButtonAction(ActionItem<StateToken> action); + void addButtonAction(ActionItem<T> action); - void addMenuAction(ActionItem<StateToken> action, boolean enable); + void addMenuAction(ActionItem<T> action, boolean enable); void attach(); 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-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-09-30 01:49:58 UTC (rev 897) @@ -331,17 +331,17 @@ register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) { public ContextNavigator create() { - final ActionToolbarPanel contextNavigatorToolbar = new ActionToolbarPanel( + final ActionToolbarPanel<StateToken> contextNavigatorToolbar = new ActionToolbarPanel<StateToken>( ActionToolbarPanel.Position.context, $$(ActionManager.class), $(WorkspaceSkeleton.class)); - final ActionToolbar toolbar = new ActionToolbarPresenter(contextNavigatorToolbar, - $(ContextActionRegistry.class)); + final ActionToolbar<StateToken> toolbar = new ActionToolbarPresenter<StateToken>( + contextNavigatorToolbar, $(ContentActionRegistry.class)); final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class), $(Session.class), $$(ContentServiceAsync.class), i18n, $(EntityTitle.class), - $(ContentIconsRegistry.class), $(DragDropContentRegistry.class), - $(ContextActionRegistry.class), toolbar); + $(ContentIconsRegistry.class), $(DragDropContentRegistry.class), toolbar, + $(ContextActionRegistry.class)); final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter, i18n, - $(WorkspaceSkeleton.class), $(ActionManager.class)); + $(WorkspaceSkeleton.class), $(ActionManager.class), $(WsThemePresenter.class)); presenter.init(panel); return presenter; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-30 01:49:58 UTC (rev 897) @@ -30,17 +30,21 @@ import org.ourproject.kune.platf.client.services.I18nTranslationService; import org.ourproject.kune.workspace.client.site.Site; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; +import org.ourproject.kune.workspace.client.themes.WsTheme; +import org.ourproject.kune.workspace.client.themes.WsThemePresenter; import com.allen_sauer.gwt.log.client.Log; +import com.calclab.suco.client.listener.Listener2; import com.google.gwt.user.client.Command; import com.google.gwt.user.client.DeferredCommand; -import com.google.gwt.user.client.ui.ScrollPanel; import com.gwtext.client.core.EventObject; import com.gwtext.client.core.ExtElement; import com.gwtext.client.data.Node; import com.gwtext.client.dd.DragData; import com.gwtext.client.dd.DragDrop; +import com.gwtext.client.widgets.BoxComponent; import com.gwtext.client.widgets.Editor; +import com.gwtext.client.widgets.event.ContainerListenerAdapter; import com.gwtext.client.widgets.event.EditorListenerAdapter; import com.gwtext.client.widgets.form.TextField; import com.gwtext.client.widgets.menu.BaseItem; @@ -67,14 +71,20 @@ private final ContextNavigatorPresenter presenter; public ContextNavigatorPanel(final ContextNavigatorPresenter presenter, final I18nTranslationService i18n, - final WorkspaceSkeleton ws, final ActionManager actionManager) { + final WorkspaceSkeleton ws, final ActionManager actionManager, final WsThemePresenter wsTheme) { this.presenter = presenter; this.ws = ws; this.actionManager = actionManager; + wsTheme.onThemeChanged(new Listener2<WsTheme, WsTheme>() { + public void onEvent(final WsTheme oldTheme, final WsTheme newTheme) { + setTheme(oldTheme, newTheme); + } + }); contextMenus = new HashMap<String, Menu>(); fireOnTextChange = true; isEditable = false; + } public void addItem(final ContextNavigatorItem item) { @@ -193,6 +203,16 @@ } } + public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) { + if (treePanel != null) { + if (oldTheme != null) { + final String previousThemeS = oldTheme.toString(); + treePanel.removeStyleName("k-entity-context-" + previousThemeS); + } + treePanel.addStyleName("k-entity-context-" + newTheme); + } + } + private void createItemMenu(final String nodeId, final ActionItemCollection<StateToken> actionCollection) { DeferredCommand.addCommand(new Command() { public void execute() { @@ -222,11 +242,16 @@ clear(); } treePanel = new TreePanel(); + treePanel.setHeight("100%"); + treePanel.setAutoScroll(true); + treePanel.setRootVisible(false); + treePanel.setContainerScroll(true); treePanel.setAnimate(true); treePanel.setBorder(false); - treePanel.setRootVisible(false); treePanel.setUseArrows(true); treePanel.setSelectionModel(new MultiSelectionModel()); + // treePanel.setBufferResize(true;) + // treePanel.setId(CTX_NAVIGATOR_TREEPANEL); final TreeNode root = new TreeNode(); root.setAllowDrag(false); root.setExpanded(true); @@ -254,9 +279,7 @@ treePanel.setLines(false); treePanel.setEnableDD(isEditable); treePanel.setRootNode(root); - // treePanel.setAutoScroll(true); - treePanel.setContainerScroll(true); - treePanel.setAutoWidth(true); + // treePanel.expand(); final TextField field = new TextField(); treeEditor = new TreeEditor(treePanel, field); @@ -265,18 +288,27 @@ return isEditable; } }); + // test !? + treeEditor.setAutosize(false); - final ScrollPanel panel = new ScrollPanel(); - // final Panel panel = new Panel(); - // panel.setLayout(new FitLayout()); - // panel.setBorder(false); - // panel.setAutoScroll(true); - // new ScrollPanel - panel.setWidth("100%"); - panel.setHeight("100%"); - panel.add(treePanel); + treePanel.addListener(new ContainerListenerAdapter() { + public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight, + final int rawWidth, final int rawHeight) { + // Log.debug("tree-------w: " + adjWidth + " h: " + adjHeight); + treePanel.doLayout(false); + } + }); - ws.getEntityWorkspace().setContext(panel); + ws.getEntityWorkspace().addContextListener(new ContainerListenerAdapter() { + @Override + public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight, + final int rawWidth, final int rawHeight) { + // Log.debug("-------w: " + adjWidth + " h: " + adjHeight); + // Log.debug("---r---w: " + rawWidth + " h: " + rawHeight); + } + }); + + ws.getEntityWorkspace().setContext(treePanel); } private void doAction(final ActionItem<StateToken> actionItem) { Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-30 01:49:58 UTC (rev 897) @@ -65,13 +65,13 @@ private final ContentIconsRegistry contentIconsRegistry; private final DragDropContentRegistry dragDropContentRegistry; private final ActionRegistry<StateToken> actionRegistry; - private final ActionToolbar toolbar; + private final ActionToolbar<StateToken> toolbar; public ContextNavigatorPresenter(final StateManager stateManager, final Session session, final Provider<ContentServiceAsync> contentServiceProvider, final I18nUITranslationService i18n, final EntityTitle entityTitle, final ContentIconsRegistry contentIconsRegistry, - final DragDropContentRegistry dragDropContentRegistry, final ActionRegistry<StateToken> actionRegistry, - final ActionToolbar toolbar) { + final DragDropContentRegistry dragDropContentRegistry, final ActionToolbar<StateToken> toolbar, + final ActionRegistry<StateToken> actionRegistry) { this.stateManager = stateManager; this.session = session; this.contentServiceProvider = contentServiceProvider; @@ -205,7 +205,7 @@ final ActionItemCollection<StateToken> contentActions = addItem(state.getTitle(), state.getTypeId(), state .getMimeType(), state.getStatus(), stateToken, container.getStateToken(), rights, false); final ActionItemCollection<StateToken> containerActions = actionRegistry.getCurrentActions(container - .getStateToken(), container.getTypeId(), containerRights, true); + .getStateToken(), container.getTypeId(), session.isLogged(), containerRights, true); actionItems.addAll(containerActions); actionItems.addAll(contentActions); @@ -246,14 +246,15 @@ final StateToken parentStateToken, final AccessRightsDTO rights, final boolean isNodeSelected) { final ActionItemCollection<StateToken> toolbarActions = actionRegistry.getCurrentActions(stateToken, - contentTypeId, rights, true); + contentTypeId, session.isLogged(), rights, true); final String contentTypeIcon = contentTypeId.equals(TYPE_FOLDER) ? "" : contentIconsRegistry .getContentTypeIcon(contentTypeId, mimeType); final ContextNavigatorItem item = new ContextNavigatorItem(genId(stateToken), genId(parentStateToken), contentTypeIcon, title, status, stateToken, dragDropContentRegistry.isDraggable(contentTypeId, rights .isAdministrable()), dragDropContentRegistry.isDroppable(contentTypeId, rights - .isAdministrable()), actionRegistry.getCurrentActions(stateToken, contentTypeId, rights, false)); + .isAdministrable()), actionRegistry.getCurrentActions(stateToken, contentTypeId, session + .isLogged(), rights, false)); view.addItem(item); return toolbarActions; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2008-09-30 01:49:58 UTC (rev 897) @@ -6,8 +6,10 @@ import com.google.gwt.user.client.ui.Widget; import com.gwtext.client.widgets.Panel; +import com.gwtext.client.widgets.event.ContainerListener; import com.gwtext.client.widgets.layout.AnchorLayout; import com.gwtext.client.widgets.layout.AnchorLayoutData; +import com.gwtext.client.widgets.layout.FitLayout; public class EntityWorkspace extends DefaultBorderLayout { private static final String ENTITY_TITLE = "k-entity-title"; @@ -63,12 +65,13 @@ context = new Panel(); content.setCls(ENTITY_CONTENT); context.setCls(ENTITY_CONTEXT); + context.setLayout(new FitLayout()); content.setBorder(false); context.setBorder(false); context.setCollapsible(true); content.setPaddings(7); content.setAutoScroll(true); - context.setAutoScroll(true); + // context.setAutoScroll(true); contentTopBar = new Toolbar(); contentBottomBar = new Toolbar(); @@ -80,8 +83,8 @@ contextBottomBar.addStyleName("k-toolbar-top-line"); contentWrap.add(contentTopBar.getPanel(), Position.NORTH, false, DEF_TOOLBAR_HEIGHT); contextWrap.add(contextTopBar.getPanel(), Position.NORTH, false, DEF_TOOLBAR_HEIGHT); - contentWrap.add(content, Position.CENTER); - contextWrap.add(context, Position.CENTER); + contentWrap.add(content, Position.CENTER, -1); + contextWrap.add(context, Position.CENTER, -1); contentWrap.add(contentBottomBar.getPanel(), Position.SOUTH, false, DEF_TOOLBAR_HEIGHT); contextWrap.add(contextBottomBar.getPanel(), Position.SOUTH, false, DEF_TOOLBAR_HEIGHT); @@ -91,6 +94,14 @@ add(bottomPanel, DefaultBorderLayout.Position.SOUTH, DEF_TOOLBAR_HEIGHT + 2); } + public void addContentListener(final ContainerListener listener) { + content.addListener(listener); + } + + public void addContextListener(final ContainerListener listener) { + context.addListener(listener); + } + public SimpleToolbar getBottomTitle() { return bottom; } Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java 2008-09-29 11:58:55 UTC (rev 896) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java 2008-09-30 01:49:58 UTC (rev 897) @@ -5,9 +5,11 @@ import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import org.ourproject.kune.platf.client.dto.AccessRightsDTO; import org.ourproject.kune.platf.client.dto.AccessRolDTO; import org.ourproject.kune.platf.client.dto.StateToken; +import org.ourproject.kune.platf.client.state.Session; import com.calclab.suco.client.listener.Listener; @@ -17,10 +19,12 @@ private ActionRegistry<StateToken> registry; private ActionToolbarMenuAndItemDescriptor<StateToken> adminAction; private ActionToolbarMenuAndItemDescriptor<StateToken> editorAction; - private ActionToolbarMenuAndItemDescriptor<StateToken> viewerAction; + private ActionMenuItemDescriptor<StateToken> viewerAction; + private Session session; @Test public void actionsEmptyButNeverNull() { + Mockito.stub(session.isLogged()).toReturn(true); checkActionLists(0, new AccessRightsDTO(true, true, true), true); checkActionLists(0, new AccessRightsDTO(true, true, true), false); checkActionLists(0, new AccessRightsDTO(false, true, true), true); @@ -31,48 +35,61 @@ @Before public void before() { + session = Mockito.mock(Session.class); registry = new ActionRegistry<StateToken>(); - adminAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Administrator, ActionToolbarPosition.topbar, - new Listener<StateToken>() { + adminAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Administrator, + ActionToolbarPosition.topbar, new Listener<StateToken>() { public void onEvent(final StateToken parameter) { } }); - editorAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, ActionToolbarPosition.topbar, - new Listener<StateToken>() { + editorAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, + ActionToolbarPosition.topbar, new Listener<StateToken>() { public void onEvent(final StateToken parameter) { } }); - viewerAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Viewer, ActionToolbarPosition.topbar, - new Listener<StateToken>() { - public void onEvent(final StateToken parameter) { - } - }); + viewerAction = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer, new Listener<StateToken>() { + public void onEvent(final StateToken parameter) { + } + }); + viewerAction.setMustBeAuthenticated(false); } @Test + public void mustBeAuthFalse() { + Mockito.stub(session.isLogged()).toReturn(false); + addDefActions(); + checkActionLists(0, new AccessRightsDTO(false, true, true), true); + checkActionLists(1, new AccessRightsDTO(false, true, true), false); + } + + @Test public void testAddWhenAdmin() { + Mockito.stub(session.isLogged()).toReturn(true); addDefActions(); - checkActionLists(3, new AccessRightsDTO(true, true, true), true); + checkActionLists(2, new AccessRightsDTO(true, true, true), true); checkActionLists(3, new AccessRightsDTO(true, true, true), false); } @Test public void testAddWhenEditor() { + Mockito.stub(session.isLogged()).toReturn(true); addDefActions(); - checkActionLists(2, new AccessRightsDTO(false, true, true), true); + checkActionLists(1, new AccessRightsDTO(false, true, true), true); checkActionLists(2, new AccessRightsDTO(false, true, true), false); } @Test public void testAddWhenViewer() { + Mockito.stub(session.isLogged()).toReturn(true); addDefActions(); - checkActionLists(1, new AccessRightsDTO(false, false, true), true); + checkActionLists(0, new AccessRightsDTO(false, false, true), true); checkActionLists(1, new AccessRightsDTO(false, false, true), false); } @Test public void testEnablingFalse() { + Mockito.stub(session.isLogged()).toReturn(true); adminAction.setEnableCondition(new ActionEnableCondition<StateToken>() { public boolean mustBeEnabled(final StateToken param) { return false; @@ -84,6 +101,7 @@ @Test public void testEnablingTrue() { + Mockito.stub(session.isLogged()).toReturn(true); adminAction.setEnableCondition(new ActionEnableCondition<StateToken>() { public boolean mustBeEnabled(final StateToken param) { return true; @@ -102,6 +120,6 @@ private void checkActionLists(final int expectedActions, final AccessRightsDTO accessRightsDTO, final boolean toolbarActions) { assertEquals(expectedActions, registry.getCurrentActions(new StateToken(), DEF_CONTENT_TYPE_ID, - accessRightsDTO, toolbarActions).size()); + session.isLogged(), accessRightsDTO, toolbarActions).size()); } }