[kune-commits] r887 - in trunk: .
src/main/java/org/ourproject/kune/docs/client
src/main/java/org/ourproject/kune/docs/client/cnt
src/main/java/org/ourproject/kune/platf/client/actions
src/main/java/org/ourproject/kune/platf/client/actions/toolbar
src/main/java/org/ourproject/kune/platf/client/services
src/main/java/org/ourproject/kune/platf/client/state
src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload
src/main/java/org/ourproject/kune/platf/server/manager
src/main/java/org/ourproject/kune/platf/server/manager/impl
src/main/java/org/ourproject/kune/workspace/client/ctxnav
src/test/java/org/ourproject/kune/platf/client/actions
src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload
vjrj
vjrj at ourproject.org
Sat Sep 27 05:22:59 CEST 2008
Author: vjrj
Date: 2008-09-27 05:22:43 +0200 (Sat, 27 Sep 2008)
New Revision: 887
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java
Modified:
trunk/pom.xml
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/ActionManager.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.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/platf/client/state/StateManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorItem.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/ctxnav/ContextNavigatorView.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java
Log:
Complete - task 67: Root can be edited / make notVisible / add Folder Actions to menu of contents
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/pom.xml 2008-09-27 03:22:43 UTC (rev 887)
@@ -252,11 +252,6 @@
<version>2.4</version>
<scope>provided</scope>
</dependency>
- <dependency>
- <groupId>jmimemagic</groupId>
- <artifactId>jmimemagic</artifactId>
- <version>0.1.2</version>
- </dependency>
<!-- testing dependencies -->
<dependency>
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -5,10 +5,10 @@
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_FOLDER;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_GALLERY;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_ROOT;
+import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_UPLOADEDFILE;
import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_WIKI;
import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
@@ -174,16 +174,16 @@
}
});
- final ActionButtonDescriptor<StateToken> refresh = new ActionButtonDescriptor<StateToken>(AccessRolDTO.Viewer,
+ final ActionMenuDescriptor<StateToken> refresh = new ActionMenuDescriptor<StateToken>(AccessRolDTO.Viewer,
ActionPosition.topbar, new Listener<StateToken>() {
public void onEvent(final StateToken stateToken) {
stateManager.reload();
contextNavigator.selectItem(stateToken);
}
});
+ refresh.setParentMenuTitle(i18n.t("Folder"));
+ refresh.setTextDescription(i18n.t("Refresh"));
refresh.setIconUrl("images/nav/refresh.png");
- refresh.setToolTip(i18n.t("Refresh"));
- refresh.setLeftSeparator(ActionButtonSeparator.fill);
final ActionDescriptor<StateToken> uploadFile = createUploadAction(i18n.t("Upload file"),
"images/nav/upload.png", i18n.t("Upload some files (images, PDFs, ...)"), null);
@@ -201,20 +201,27 @@
contextActionRegistry.addAction(TYPE_FOLDER, addDoc);
contextActionRegistry.addAction(TYPE_FOLDER, addFolder);
contextActionRegistry.addAction(TYPE_FOLDER, delContainer);
+ contextActionRegistry.addAction(TYPE_FOLDER, refresh);
contextActionRegistry.addAction(TYPE_FOLDER, rename);
contextActionRegistry.addAction(TYPE_FOLDER, goGroupHome);
- contextActionRegistry.addAction(TYPE_FOLDER, refresh);
contextActionRegistry.addAction(TYPE_FOLDER, uploadFile);
contextActionRegistry.addAction(TYPE_BLOG, go);
contextActionRegistry.addAction(TYPE_BLOG, uploadFile);
+ contextActionRegistry.addAction(TYPE_BLOG, refresh);
contextActionRegistry.addAction(TYPE_BLOG, setAsDefGroupContent);
- contextActionRegistry.addAction(TYPE_BLOG, refresh);
contextActionRegistry.addAction(TYPE_GALLERY, go);
contextActionRegistry.addAction(TYPE_GALLERY, goGroupHome);
contextActionRegistry.addAction(TYPE_GALLERY, refresh);
+ contextActionRegistry.addAction(TYPE_UPLOADEDFILE, go);
+ contextActionRegistry.addAction(TYPE_UPLOADEDFILE, delContent);
+ contextActionRegistry.addAction(TYPE_UPLOADEDFILE, rename);
+ // contextActionRegistry.addAction(TYPE_UPLOADEDFILE, goGroupHome);
+ // contextActionRegistry.addAction(TYPE_UPLOADEDFILE, refresh);
+ contextActionRegistry.addAction(TYPE_UPLOADEDFILE, setAsDefGroupContent);
+
contextActionRegistry.addAction(TYPE_WIKI, go);
contextActionRegistry.addAction(TYPE_WIKI, goGroupHome);
contextActionRegistry.addAction(TYPE_WIKI, refresh);
@@ -223,15 +230,15 @@
contextActionRegistry.addAction(TYPE_ROOT, addFolder);
contextActionRegistry.addAction(TYPE_ROOT, addGallery);
contextActionRegistry.addAction(TYPE_ROOT, addWiki);
+ contextActionRegistry.addAction(TYPE_ROOT, refresh);
contextActionRegistry.addAction(TYPE_ROOT, goGroupHome);
- contextActionRegistry.addAction(TYPE_ROOT, refresh);
contextActionRegistry.addAction(TYPE_ROOT, uploadFile);
contextActionRegistry.addAction(TYPE_DOCUMENT, go);
contextActionRegistry.addAction(TYPE_DOCUMENT, delContent);
contextActionRegistry.addAction(TYPE_DOCUMENT, rename);
- contextActionRegistry.addAction(TYPE_DOCUMENT, goGroupHome);
- contextActionRegistry.addAction(TYPE_DOCUMENT, refresh);
+ // contextActionRegistry.addAction(TYPE_DOCUMENT, goGroupHome);
+ // contextActionRegistry.addAction(TYPE_DOCUMENT, refresh);
contextActionRegistry.addAction(TYPE_DOCUMENT, setAsDefGroupContent);
}
@@ -259,16 +266,16 @@
return addFolder;
}
- private ActionDescriptor<StateToken> createUploadAction(final String textDescription, final String iconUrl,
+ private ActionButtonDescriptor<StateToken> createUploadAction(final String textDescription, final String iconUrl,
final String toolTip, final String permitedExtensions) {
final ActionButtonDescriptor<StateToken> uploadFile;
uploadFile = new ActionButtonDescriptor<StateToken>(AccessRolDTO.Editor, ActionPosition.bootombarAndItemMenu,
new Listener<StateToken>() {
public void onEvent(final StateToken token) {
if (permitedExtensions != null) {
- fileUploaderProvider.get().setPermittedExtensions(permitedExtensions);
+ // fileUploaderProvider.get().setPermittedExtensions(permitedExtensions);
} else {
- fileUploaderProvider.get().resetPermittedExtensions();
+ // fileUploaderProvider.get().resetPermittedExtensions();
}
fileUploaderProvider.get().show();
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -120,9 +120,8 @@
register(ToolGroup.class, new Factory<DocumentContent>(DocumentContent.class) {
public DocumentContent create() {
final ActionToolbarPanel contentNavigatorToolbar = new ActionToolbarPanel(
- ActionToolbarPanel.Position.content, $(Session.class), $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
- final ActionToolbar toolbar = new ActionToolbarPresenter($(Session.class), contentNavigatorToolbar,
+ ActionToolbarPanel.Position.content, $$(ActionManager.class), $(WorkspaceSkeleton.class));
+ final ActionToolbar toolbar = new ActionToolbarPresenter(contentNavigatorToolbar,
$(ContentActionRegistry.class));
final DocumentContentPresenter presenter = new DocumentContentPresenter($(StateManager.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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -23,7 +23,7 @@
import org.ourproject.kune.docs.client.DocumentClientTool;
import org.ourproject.kune.docs.client.cnt.folder.viewer.FolderViewer;
import org.ourproject.kune.docs.client.cnt.reader.DocumentReader;
-import org.ourproject.kune.platf.client.actions.ActionCollectionSet;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.actions.ActionRegistry;
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
import org.ourproject.kune.platf.client.dto.StateDTO;
@@ -188,15 +188,17 @@
private void setState(final StateDTO state) {
content = state;
- ActionCollectionSet<StateToken> set;
final String typeId = content.getTypeId();
+ ActionItemCollection<StateToken> collection;
if (content.hasDocument()) {
- set = actionRegistry.selectCurrentActions(content.getContentRights(), typeId);
+ collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId, content.getContentRights(),
+ true);
} else {
- set = actionRegistry.selectCurrentActions(content.getContainerRights(), typeId);
+ collection = actionRegistry.getCurrentActions(content.getStateToken(), typeId,
+ content.getContainerRights(), true);
}
toolbar.disableMenusAndClearButtons();
- toolbar.showActions(set.getToolbarActions(), true);
+ toolbar.showActions(collection, true);
showContent();
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -0,0 +1,26 @@
+package org.ourproject.kune.platf.client.actions;
+
+/**
+ * And action description and a item (for instance a StateToken, a XmmpURI) over
+ * the action takes place
+ *
+ * @param <T>
+ */
+public class ActionItem<T> {
+
+ ActionDescriptor<T> action;
+ T item;
+
+ public ActionItem(final ActionDescriptor<T> action, final T item) {
+ this.action = action;
+ this.item = item;
+ }
+
+ public ActionDescriptor<T> getAction() {
+ return action;
+ }
+
+ public T getItem() {
+ return item;
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.platf.client.actions;
+
+import java.util.ArrayList;
+
+public class ActionItemCollection<T> extends ArrayList<ActionItem<T>> {
+
+ private static final long serialVersionUID = 1L;
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -12,20 +12,26 @@
this.ws = ws;
}
- public void doAction(final ActionDescriptor<?> action, final Object parameter) {
+ public void doAction(final ActionItem<?> actionItem) {
+ final ActionDescriptor<?> action = actionItem.getAction();
+ final Object item = actionItem.getItem();
if (action.isMustBeConfirmed()) {
ws.askConfirmation(action.getConfirmationTitle(), action.getConfirmationText(), new Listener0() {
public void onEvent() {
- action.fireOnPerformCall(parameter);
+ fire(action, item);
}
}, new Listener0() {
public void onEvent() {
- action.fireOnNotConfirmed(parameter);
+ action.fireOnNotConfirmed(item);
}
});
} else {
- action.fireOnPerformCall(parameter);
+ fire(action, item);
}
}
+ private void fire(final ActionDescriptor<?> action, final Object parameter) {
+ action.fireOnPerformCall(parameter);
+ }
+
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -22,47 +22,39 @@
return enableCondition != null ? enableCondition.mustBeEnabled(T) : true;
}
- public void removeAction(final String contentTypeId, final ActionDescriptor<T> action) {
- actions.get(contentTypeId).remove(action);
- }
+ public ActionItemCollection<T> getCurrentActions(final T item, final String contentTypeId,
+ final AccessRightsDTO rights, final boolean toolbarItems) {
+ final ActionItemCollection<T> collection = new ActionItemCollection<T>();
- public ActionCollectionSet<T> selectCurrentActions(final AccessRightsDTO rights, final String contentTypeId) {
- final ActionCollectionSet<T> set = new ActionCollectionSet<T>();
- boolean add = false;
-
for (final ActionDescriptor<T> action : getActions(contentTypeId)) {
- switch (action.getAccessRol()) {
- case Administrator:
- add = rights.isAdministrable();
- break;
- case Editor:
- add = rights.isEditable();
- break;
- case Viewer:
- add = rights.isVisible();
- break;
- }
- if (add) {
- switch (action.getActionPosition()) {
- case topbarAndItemMenu:
- set.getItemActions().add(action);
- case topbar:
- set.getToolbarActions().add(action);
- break;
- case bootombarAndItemMenu:
- set.getItemActions().add(action);
- case bottombar:
- set.getToolbarActions().add(action);
- break;
- case itemMenu:
- set.getItemActions().add(action);
- break;
+ if (mustAdd(rights, action)) {
+ if (toolbarItems) {
+ switch (action.getActionPosition()) {
+ case topbarAndItemMenu:
+ case topbar:
+ case bootombarAndItemMenu:
+ case bottombar:
+ collection.add(new ActionItem<T>(action, item));
+ break;
+ }
+ } else {
+ switch (action.getActionPosition()) {
+ case itemMenu:
+ case topbarAndItemMenu:
+ case bootombarAndItemMenu:
+ collection.add(new ActionItem<T>(action, item));
+ break;
+ }
}
}
}
- return set;
+ return collection;
}
+ public void removeAction(final String contentTypeId, final ActionDescriptor<T> action) {
+ actions.get(contentTypeId).remove(action);
+ }
+
private ActionCollection<T> getActions(final String contentTypeId) {
ActionCollection<T> actionColl = actions.get(contentTypeId);
if (actionColl == null) {
@@ -71,4 +63,16 @@
}
return actionColl;
}
+
+ private boolean mustAdd(final AccessRightsDTO rights, final ActionDescriptor<T> action) {
+ switch (action.getAccessRol()) {
+ case Administrator:
+ return rights.isAdministrable();
+ case Editor:
+ return rights.isEditable();
+ case Viewer:
+ default:
+ return rights.isVisible();
+ }
+ }
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -1,6 +1,6 @@
package org.ourproject.kune.platf.client.actions.toolbar;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.dto.StateToken;
public interface ActionToolbar {
@@ -9,6 +9,6 @@
void disableMenusAndClearButtons();
- void showActions(ActionCollection<StateToken> actionCollection, boolean isItemSelected);
+ void showActions(ActionItemCollection<StateToken> 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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -5,11 +5,11 @@
import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ActionButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionItem;
import org.ourproject.kune.platf.client.actions.ActionManager;
import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
import org.ourproject.kune.platf.client.actions.ActionPosition;
import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.workspace.client.skel.Toolbar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
@@ -35,14 +35,12 @@
private final ArrayList<Widget> removableToolbarItems;
private final HashMap<String, Item> menuItems;
private final WorkspaceSkeleton ws;
- private final Session session;
private final Provider<ActionManager> actionManagerProvider;
private final Position position;
- public ActionToolbarPanel(final Position position, final Session session,
- final Provider<ActionManager> actionManagerProvider, final WorkspaceSkeleton ws) {
+ public ActionToolbarPanel(final Position position, final Provider<ActionManager> actionManagerProvider,
+ final WorkspaceSkeleton ws) {
this.position = position;
- this.session = session;
this.actionManagerProvider = actionManagerProvider;
this.ws = ws;
toolbarMenus = new HashMap<String, Menu>();
@@ -51,7 +49,8 @@
}
- public void addButtonAction(final ActionButtonDescriptor<StateToken> action) {
+ public void addButtonAction(final ActionItem<StateToken> actionItem) {
+ final ActionButtonDescriptor<StateToken> action = (ActionButtonDescriptor<StateToken>) actionItem.getAction();
final ActionPosition pos = action.getActionPosition();
final ToolbarButton button = new ToolbarButton();
final String text = action.getText();
@@ -62,7 +61,7 @@
button.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(final Button button, final EventObject e) {
- actionManagerProvider.get().doAction(action, session.getCurrentStateToken());
+ actionManagerProvider.get().doAction(actionItem);
}
});
if (iconUrl != null) {
@@ -81,14 +80,15 @@
removableToolbarItems.add(button);
}
- public void addMenuAction(final ActionMenuDescriptor<StateToken> action, final boolean enable) {
+ public void addMenuAction(final ActionItem<StateToken> actionItem, final boolean enable) {
+ final ActionMenuDescriptor<StateToken> action = (ActionMenuDescriptor<StateToken>) actionItem.getAction();
final String menuTitle = action.getParentMenuTitle();
final String menuSubTitle = action.getParentSubMenuTitle();
final ActionPosition pos = action.getActionPosition();
final String itemKey = genMenuKey(pos, menuTitle, menuSubTitle, action.getText());
Item item = menuItems.get(itemKey);
if (item == null) {
- item = createToolbarMenu(pos, menuTitle, menuSubTitle, action);
+ item = createToolbarMenu(pos, menuTitle, menuSubTitle, actionItem);
menuItems.put(itemKey, item);
}
if (enable) {
@@ -139,11 +139,12 @@
}
private Item createToolbarMenu(final ActionPosition toolBarPos, final String menuTitle, final String menuSubTitle,
- final ActionMenuDescriptor<StateToken> action) {
+ final ActionItem<StateToken> actionItem) {
+ final ActionMenuDescriptor<StateToken> action = (ActionMenuDescriptor<StateToken>) actionItem.getAction();
final Item item = new Item(action.getText(), new BaseItemListenerAdapter() {
@Override
public void onClick(BaseItem item, EventObject e) {
- actionManagerProvider.get().doAction(action, session.getCurrentStateToken());
+ actionManagerProvider.get().doAction(actionItem);
}
});
item.setIcon(action.getIconUrl());
@@ -199,7 +200,8 @@
private String genMenuKey(final ActionPosition pos, final String menuTitle, final String menuSubTitle,
final String actionText) {
- final String basePart = "km-" + pos.toString() + "-" + menuTitle;
+
+ final String basePart = "km-ctx-" + pos.toString().substring(0, 2) + "-" + menuTitle;
final String subMenuPart = menuSubTitle != null ? "-subm-" + menuSubTitle : "";
final String itemPart = actionText != null ? "-item-" + actionText : "";
return basePart + subMenuPart + itemPart;
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -1,23 +1,20 @@
package org.ourproject.kune.platf.client.actions.toolbar;
import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
import org.ourproject.kune.platf.client.actions.ActionRegistry;
import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.state.Session;
import com.allen_sauer.gwt.log.client.Log;
public class ActionToolbarPresenter implements ActionToolbar {
private final ActionToolbarView toolbar;
- private final Session session;
private final ActionRegistry<StateToken> actionRegistry;
- public ActionToolbarPresenter(final Session session, final ActionToolbarView toolbar,
- final ActionRegistry<StateToken> actionRegistry) {
- this.session = session;
+ public ActionToolbarPresenter(final ActionToolbarView toolbar, final ActionRegistry<StateToken> actionRegistry) {
this.toolbar = toolbar;
this.actionRegistry = actionRegistry;
}
@@ -27,23 +24,26 @@
}
public void disableMenusAndClearButtons() {
- toolbar.clearRemovableActions();
- toolbar.disableAllMenuItems();
+ toolbar.clear();
+ // With action-item, this must be redesigned
+ // toolbar.clearRemovableActions();
+ // toolbar.disableAllMenuItems();
}
- public void showActions(final ActionCollection<StateToken> actions, final boolean isItemSelected) {
- for (final ActionDescriptor<StateToken> action : actions) {
+ public void showActions(final ActionItemCollection<StateToken> actions, final boolean isItemSelected) {
+ for (final ActionItem<StateToken> actionItem : actions) {
+ final ActionDescriptor<StateToken> action = actionItem.getAction();
if (action instanceof ActionMenuDescriptor) {
- toolbar.addMenuAction((ActionMenuDescriptor<StateToken>) action, isItemSelected
- && actionRegistry.checkEnabling(action, session.getCurrentStateToken()));
+ toolbar.addMenuAction(actionItem, isItemSelected
+ && actionRegistry.checkEnabling(action, actionItem.getItem()));
} else {
if (action instanceof ActionButtonDescriptor) {
- if (isItemSelected && actionRegistry.checkEnabling(action, session.getCurrentStateToken())) {
- toolbar.addButtonAction((ActionButtonDescriptor<StateToken>) action);
+ if (isItemSelected && actionRegistry.checkEnabling(action, actionItem.getItem())) {
+ toolbar.addButtonAction(actionItem);
}
} else {
// Code smell
- Log.error("Not an ActionMenuDescriptor or ActionButtonDescriptor");
+ Log.error("Not an ActionMenuDescriptor or ActionButtonDescriptor: " + action.getText());
}
}
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -1,14 +1,13 @@
package org.ourproject.kune.platf.client.actions.toolbar;
-import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionItem;
import org.ourproject.kune.platf.client.dto.StateToken;
public interface ActionToolbarView {
- void addButtonAction(ActionButtonDescriptor<StateToken> action);
+ void addButtonAction(ActionItem<StateToken> action);
- void addMenuAction(ActionMenuDescriptor<StateToken> action, boolean enable);
+ void addMenuAction(ActionItem<StateToken> action, boolean enable);
void clear();
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -331,9 +331,8 @@
register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) {
public ContextNavigator create() {
final ActionToolbarPanel contextNavigatorToolbar = new ActionToolbarPanel(
- ActionToolbarPanel.Position.context, $(Session.class), $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
- final ActionToolbar toolbar = new ActionToolbarPresenter($(Session.class), contextNavigatorToolbar,
+ ActionToolbarPanel.Position.context, $$(ActionManager.class), $(WorkspaceSkeleton.class));
+ final ActionToolbar toolbar = new ActionToolbarPresenter(contextNavigatorToolbar,
$(ContextActionRegistry.class));
final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/state/StateManagerDefault.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -98,7 +98,7 @@
public void onHistoryChanged(final String historyToken) {
final Listener<StateToken> tokenListener = siteTokens.get(historyToken);
- Log.debug("history token: " + historyToken);
+ Log.debug("StateManager: history token changed (" + historyToken + ")");
if (tokenListener == null) {
onHistoryChanged(new StateToken(historyToken));
} else {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderDialog.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -115,8 +115,7 @@
dialog.setClosable(true);
dialog.setCloseAction(Window.HIDE);
dialog.setMinimizable(true);
- dialog.setUploadAutostart(true);
- // Here fails
+ dialog.setUploadAutostart(false);
dialog.addListener(new UploadDialogListenerAdapter() {
@Override
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenter.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -20,16 +20,16 @@
}
public boolean checkFolderChange() {
- final StateToken currentStateToken = session.getCurrentStateToken();
+ final StateToken currentFolderStateToken = session.getCurrentStateToken().clone().clearDocument();
if (sameContainer()) {
- view.setUploadParams(session.getUserHash(), currentStateToken.toString());
+ view.setUploadParams(session.getUserHash(), currentFolderStateToken.toString());
return true;
}
if (view.hasUploadingFiles()) {
return false;
} else {
- currentUploadStateToken = currentStateToken;
- view.setUploadParams(session.getUserHash(), currentStateToken.toString());
+ currentUploadStateToken = currentFolderStateToken;
+ view.setUploadParams(session.getUserHash(), currentFolderStateToken.toString());
return true;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -3,11 +3,6 @@
import java.io.File;
import java.io.IOException;
-import net.sf.jmimemagic.MagicException;
-import net.sf.jmimemagic.MagicMatch;
-import net.sf.jmimemagic.MagicMatchNotFoundException;
-import net.sf.jmimemagic.MagicParseException;
-
public interface FileManager {
/**
@@ -23,8 +18,6 @@
*/
File createFileWithSequentialName(String dir, String fileName) throws IOException;
- MagicMatch getMimeType(File file) throws MagicParseException, MagicMatchNotFoundException, MagicException;
-
/**
* @param dir
* the directory (use File.separator for dir delimiters)
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileManagerDefault.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -3,12 +3,6 @@
import java.io.File;
import java.io.IOException;
-import net.sf.jmimemagic.Magic;
-import net.sf.jmimemagic.MagicException;
-import net.sf.jmimemagic.MagicMatch;
-import net.sf.jmimemagic.MagicMatchNotFoundException;
-import net.sf.jmimemagic.MagicParseException;
-
import org.ourproject.kune.platf.server.manager.FileManager;
import com.google.inject.Singleton;
@@ -27,11 +21,6 @@
return file;
}
- public MagicMatch getMimeType(final File file) throws MagicParseException, MagicMatchNotFoundException,
- MagicException {
- return Magic.getMagicMatch(file, true);
- }
-
public boolean mkdir(final String dir) {
return (new File(dir)).mkdirs();
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/impl/FileUploadManager.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -12,10 +12,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import net.sf.jmimemagic.MagicException;
-import net.sf.jmimemagic.MagicMatch;
-import net.sf.jmimemagic.MagicMatchNotFoundException;
-import net.sf.jmimemagic.MagicParseException;
import net.sf.json.JSONObject;
import org.apache.commons.fileupload.FileItem;
@@ -145,23 +141,9 @@
file = fileManager.createFileWithSequentialName(absDir, filenameUTF8);
fileUploadItem.write(file);
- log.info("fileItem mime type: " + fileUploadItem.getContentType());
+ final String mimetype = fileUploadItem.getContentType();
+ final String extension = FileUtils.getFileNameExtension(filenameUTF8, false);
- String mimetype = "unknown/unknown";
- String extension = "";
- try {
- final MagicMatch magicMatch = fileManager.getMimeType(file);
-
- extension = magicMatch.getExtension();
- mimetype = magicMatch.getMimeType();
- } catch (final MagicParseException e) {
- log.info("Exception: " + e.getCause());
- } catch (final MagicMatchNotFoundException e) {
- log.info("Exception: " + e.getCause());
- } catch (final MagicException e) {
- log.info("Exception: " + e.getCause());
- }
-
// Persist
final User user = userSession.getUser();
final Container container = accessService.accessToContainer(ContentUtils.parseId(stateToken.getFolder()),
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorItem.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorItem.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -1,6 +1,6 @@
package org.ourproject.kune.workspace.client.ctxnav;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.dto.ContentStatusDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
@@ -11,13 +11,13 @@
private final String text;
private final ContentStatusDTO contentStatusDTO;
private final StateToken token;
- private final ActionCollection<StateToken> actionCollection;
+ private final ActionItemCollection<StateToken> actionCollection;
private final boolean allowDrag;
private final boolean allowDrop;
public ContextNavigatorItem(final String id, final String parentId, final String iconUrl, final String text,
final ContentStatusDTO contentStatusDTO, final StateToken token, final boolean allowDrag,
- final boolean allowDrop, final ActionCollection<StateToken> actionCollection) {
+ final boolean allowDrop, final ActionItemCollection<StateToken> actionCollection) {
this.id = id;
this.parentId = parentId;
this.iconUrl = iconUrl;
@@ -29,7 +29,7 @@
this.actionCollection = actionCollection;
}
- public ActionCollection<StateToken> getActionCollection() {
+ public ActionItemCollection<StateToken> getActionCollection() {
return actionCollection;
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -22,8 +22,9 @@
import java.util.HashMap;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.actions.ActionManager;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
@@ -47,6 +48,7 @@
import com.gwtext.client.widgets.menu.Menu;
import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
import com.gwtext.client.widgets.tree.DropNodeCallback;
+import com.gwtext.client.widgets.tree.MultiSelectionModel;
import com.gwtext.client.widgets.tree.TreeEditor;
import com.gwtext.client.widgets.tree.TreeNode;
import com.gwtext.client.widgets.tree.TreePanel;
@@ -87,7 +89,7 @@
child.setHref("#" + item.getStateToken().toString());
child.setAllowDrag(item.isDraggable());
child.setAllowDrop(item.isDroppable());
- createItemMenu(nodeId, item.getActionCollection(), item.getStateToken());
+ createItemMenu(nodeId, item.getActionCollection());
final TreeNode parent = treePanel.getNodeById(item.getParentId());
if (parent != null) {
// Log.info("Adding child node: " + nodeId + " to folder: " +
@@ -185,32 +187,27 @@
node.setText(text);
}
- public void setRootItem(final String id, final String text, final StateToken stateToken,
- final ActionCollection<StateToken> actions) {
+ public void setRootItem(final String id, final String text, final StateToken stateToken) {
if (treePanel == null || treePanel.getNodeById(id) == null) {
- createTreePanel(id, text, stateToken, actions);
+ createTreePanel(id, text, stateToken);
}
}
- private void createItemMenu(final String nodeId, final ActionCollection<StateToken> actionCollection,
- final StateToken stateToken) {
+ private void createItemMenu(final String nodeId, final ActionItemCollection<StateToken> actionCollection) {
DeferredCommand.addCommand(new Command() {
public void execute() {
Menu menu = null;
if (actionCollection != null) {
menu = new Menu();
// Remove if when retrieved rights of siblings
- for (final ActionDescriptor<StateToken> action : actionCollection) {
+ for (final ActionItem<StateToken> actionItem : actionCollection) {
+ final ActionDescriptor<StateToken> action = actionItem.getAction();
final Item item = new Item(action.getText());
item.setIcon(action.getIconUrl());
menu.addItem(item);
item.addListener(new BaseItemListenerAdapter() {
public void onClick(final BaseItem item, final EventObject e) {
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- doAction(action, stateToken);
- }
- });
+ doAction(actionItem);
}
});
}
@@ -220,17 +217,16 @@
});
}
- private void createTreePanel(final String rootId, final String text, final StateToken stateToken,
- final ActionCollection<StateToken> actions) {
+ private void createTreePanel(final String rootId, final String text, final StateToken stateToken) {
if (treePanel != null) {
clear();
}
treePanel = new TreePanel();
treePanel.setAnimate(true);
treePanel.setBorder(false);
- treePanel.setRootVisible(true);
+ treePanel.setRootVisible(false);
treePanel.setUseArrows(true);
- // treePanel.setSelectionModel(new MultiSelectionModel());
+ treePanel.setSelectionModel(new MultiSelectionModel());
final TreeNode root = new TreeNode();
root.setAllowDrag(false);
root.setExpanded(true);
@@ -238,7 +234,6 @@
root.setText(text);
root.setHref("#" + stateToken);
root.expand();
- createItemMenu(rootId, actions, stateToken);
treePanel.addListener(new TreePanelListenerAdapter() {
public boolean doBeforeNodeDrop(final TreePanel treePanel, final TreeNode target, final DragData dragData,
final String point, final DragDrop source, final TreeNode dropNode,
@@ -284,8 +279,8 @@
ws.getEntityWorkspace().setContext(panel);
}
- private void doAction(final ActionDescriptor<StateToken> action, final StateToken stateToken) {
- actionManager.doAction(action, stateToken);
+ private void doAction(final ActionItem<StateToken> actionItem) {
+ actionManager.doAction(actionItem);
}
private TreeNode getNode(final String id) {
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -20,11 +20,12 @@
package org.ourproject.kune.workspace.client.ctxnav;
+import static org.ourproject.kune.docs.client.DocumentClientTool.TYPE_FOLDER;
+
import java.util.HashMap;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionCollectionSet;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.actions.ActionRegistry;
import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
@@ -58,7 +59,7 @@
private final Session session;
private final Provider<ContentServiceAsync> contentServiceProvider;
private final I18nUITranslationService i18n;
- private final HashMap<StateToken, ActionCollection<StateToken>> actionsByItem;
+ private final HashMap<StateToken, ActionItemCollection<StateToken>> actionsByItem;
private final EntityTitle entityTitle;
private boolean editOnNextStateChange;
private final ContentIconsRegistry contentIconsRegistry;
@@ -80,7 +81,7 @@
this.dragDropContentRegistry = dragDropContentRegistry;
this.actionRegistry = actionRegistry;
this.toolbar = toolbar;
- actionsByItem = new HashMap<StateToken, ActionCollection<StateToken>>();
+ actionsByItem = new HashMap<StateToken, ActionItemCollection<StateToken>>();
editOnNextStateChange = false;
}
@@ -190,30 +191,33 @@
// childs to view)
final ContainerDTO root = state.getRootContainer();
if (root != null) {
- final ActionCollectionSet<StateToken> set = actionRegistry.selectCurrentActions(containerRights, root
- .getTypeId());
- view.setRootItem(genId(root.getStateToken()), i18n.t(root.getName()), root.getStateToken(), set
- .getItemActions());
- toolbar.showActions(set.getToolbarActions(), false);
+ view.setRootItem(genId(root.getStateToken()), i18n.t(root.getName()), root.getStateToken());
createChildItems(root, containerRights);
- actionsByItem.put(root.getStateToken(), set.getToolbarActions());
}
// Do the path to our current content
createTreePath(stateToken, container.getAbsolutePath(), containerRights);
// Process our current content/container
+ final ActionItemCollection<StateToken> actionItems = new ActionItemCollection<StateToken>();
if (state.hasDocument()) {
rights = state.getContentRights();
- addItem(state.getTitle(), state.getTypeId(), state.getMimeType(), state.getStatus(), stateToken, container
- .getStateToken(), rights, false);
+ 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);
+ actionItems.addAll(containerActions);
+ actionItems.addAll(contentActions);
+
} else {
rights = containerRights;
- addItem(container.getName(), container.getTypeId(), null, ContentStatusDTO.publishedOnline, container
- .getStateToken(), container.getStateToken().clone().setFolder(container.getParentFolderId()),
- containerRights, false);
+ final ActionItemCollection<StateToken> containerActions = addItem(container.getName(), container
+ .getTypeId(), null, ContentStatusDTO.publishedOnline, container.getStateToken(), container
+ .getStateToken().clone().setFolder(container.getParentFolderId()), containerRights, false);
+ actionItems.addAll(containerActions);
}
+ actionsByItem.put(stateToken, actionItems);
// Process container childs
createChildItems(container, containerRights);
@@ -227,7 +231,6 @@
if (select) {
selectItem(stateToken);
}
-
}
}
@@ -237,20 +240,21 @@
actionsByItem.clear();
}
- private void addItem(final String title, final String contentTypeId, final BasicMimeTypeDTO mimeType,
- final ContentStatusDTO status, final StateToken stateToken, final StateToken parentStateToken,
- final AccessRightsDTO rights, final boolean isNodeSelected) {
+ private ActionItemCollection<StateToken> addItem(final String title, final String contentTypeId,
+ final BasicMimeTypeDTO mimeType, final ContentStatusDTO status, final StateToken stateToken,
+ final StateToken parentStateToken, final AccessRightsDTO rights, final boolean isNodeSelected) {
- final ActionCollectionSet<StateToken> set = actionRegistry.selectCurrentActions(rights, contentTypeId);
- toolbar.showActions(set.getToolbarActions(), isNodeSelected);
+ final ActionItemCollection<StateToken> toolbarActions = actionRegistry.getCurrentActions(stateToken,
+ contentTypeId, rights, true);
- final String contentTypeIcon = contentIconsRegistry.getContentTypeIcon(contentTypeId, mimeType);
+ 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()), set.getItemActions());
+ .isAdministrable()), actionRegistry.getCurrentActions(stateToken, contentTypeId, rights, false));
view.addItem(item);
- actionsByItem.put(stateToken, set.getToolbarActions());
+ return toolbarActions;
}
private void createChildItems(final ContainerDTO container, final AccessRightsDTO containerRights) {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -21,7 +21,6 @@
package org.ourproject.kune.workspace.client.ctxnav;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.dto.StateToken;
public interface ContextNavigatorView extends View {
@@ -42,6 +41,6 @@
void setItemText(String id, String text);
- void setRootItem(String id, String text, StateToken stateToken, ActionCollection<StateToken> actions);
+ void setRootItem(String id, String text, StateToken stateToken);
}
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-26 14:56:55 UTC (rev 886)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -21,9 +21,12 @@
@Test
public void actionsEmptyButNeverNull() {
- checkActionLists(0, 0, new AccessRightsDTO(true, true, true));
- checkActionLists(0, 0, new AccessRightsDTO(false, true, true));
- checkActionLists(0, 0, new AccessRightsDTO(false, false, 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);
+ checkActionLists(0, new AccessRightsDTO(false, true, true), false);
+ checkActionLists(0, new AccessRightsDTO(false, false, true), true);
+ checkActionLists(0, new AccessRightsDTO(false, false, true), false);
}
@Before
@@ -50,19 +53,22 @@
@Test
public void testAddWhenAdmin() {
addDefActions();
- checkActionLists(3, 3, new AccessRightsDTO(true, true, true));
+ checkActionLists(3, new AccessRightsDTO(true, true, true), true);
+ checkActionLists(3, new AccessRightsDTO(true, true, true), false);
}
@Test
public void testAddWhenEditor() {
addDefActions();
- checkActionLists(2, 2, new AccessRightsDTO(false, true, true));
+ checkActionLists(2, new AccessRightsDTO(false, true, true), true);
+ checkActionLists(2, new AccessRightsDTO(false, true, true), false);
}
@Test
public void testAddWhenViewer() {
addDefActions();
- checkActionLists(1, 1, new AccessRightsDTO(false, false, true));
+ checkActionLists(1, new AccessRightsDTO(false, false, true), true);
+ checkActionLists(1, new AccessRightsDTO(false, false, true), false);
}
@Test
@@ -93,11 +99,9 @@
registry.addAction(DEF_CONTENT_TYPE_ID, viewerAction);
}
- private void checkActionLists(final int expectedToolActions, final int expectedItemActions,
- final AccessRightsDTO accessRightsDTO) {
- assertEquals(expectedItemActions, registry.selectCurrentActions(accessRightsDTO, DEF_CONTENT_TYPE_ID)
- .getToolbarActions().size());
- assertEquals(expectedItemActions, registry.selectCurrentActions(accessRightsDTO, DEF_CONTENT_TYPE_ID)
- .getItemActions().size());
+ 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());
}
}
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java 2008-09-26 14:56:55 UTC (rev 886)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/dialogs/upload/FileUploaderPresenterTest.java 2008-09-27 03:22:43 UTC (rev 887)
@@ -26,6 +26,13 @@
}
@Test
+ public void testFirstAddFromDocInSameContainer() {
+ Mockito.stub(session.getCurrentStateToken()).toReturn(new StateToken("group.tool.1.1"));
+ assertTrue(presenter.checkFolderChange());
+ Mockito.verify(view, Mockito.times(1)).setUploadParams(SOMEUSER_HASH, "group.tool.1");
+ }
+
+ @Test
public void testFirstAddInSameContainer() {
Mockito.stub(session.getCurrentStateToken()).toReturn(new StateToken("group.tool.1"));
assertTrue(presenter.checkFolderChange());
More information about the kune-commits
mailing list