[kune-commits] r874 - in trunk/src/main/java/org/ourproject/kune:
docs/client docs/client/cnt docs/client/cnt/folder
docs/client/cnt/reader docs/client/cnt/reader/ui
platf/client/actions platf/client/actions/toolbar
platf/client/services platf/client/state platf/server/manager
workspace/client/component workspace/client/ctxnav
vjrj
vjrj at ourproject.org
Thu Sep 18 17:37:29 CEST 2008
Author: vjrj
Date: 2008-09-18 17:37:09 +0200 (Thu, 18 Sep 2008)
New Revision: 874
Added:
trunk/src/main/java/org/ourproject/kune/docs/client/ContentEditAction.java
trunk/src/main/java/org/ourproject/kune/docs/client/ContentTranslationAction.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/ContentIconsRegistry.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContextActionRegistry.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/DragDropContentRegistry.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/
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
Removed:
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditor.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorView.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/ui/
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControl.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlPresenter.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlView.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/ui/DocumentReaderControlPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbarView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorToolbar.java
Modified:
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/state/Session.java
trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.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
Log:
Content/ContextNav refactoring, Content toolbar actions
Added: trunk/src/main/java/org/ourproject/kune/docs/client/ContentEditAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ContentEditAction.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ContentEditAction.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,21 @@
+package org.ourproject.kune.docs.client;
+
+import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionPosition;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+
+import com.calclab.suco.client.signal.Slot;
+
+public class ContentEditAction extends ActionButtonDescriptor<StateToken> {
+
+ public ContentEditAction(final I18nUITranslationService i18n) {
+ super(AccessRolDTO.Editor, ActionPosition.topbar, new Slot<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ }
+ });
+ this.setTextDescription(i18n.tWithNT("Edit", "used in button"));
+ // this.setIconUrl("images/");
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/docs/client/ContentTranslationAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/ContentTranslationAction.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/ContentTranslationAction.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,24 @@
+package org.ourproject.kune.docs.client;
+
+import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionPosition;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.workspace.client.site.Site;
+
+import com.calclab.suco.client.signal.Slot;
+
+public class ContentTranslationAction extends ActionButtonDescriptor<StateToken> {
+
+ public ContentTranslationAction(final I18nUITranslationService i18n) {
+ super(AccessRolDTO.Editor, ActionPosition.topbar, new Slot<StateToken>() {
+ public void onEvent(final StateToken stateToken) {
+ Site.important(i18n.t("Sorry, this functionality is currently in development"));
+ }
+ });
+ this.setTextDescription(i18n.tWithNT("Translate", "used in button"));
+ this.setToolTip(i18n.t("Translate this document to other languages"));
+ // this.setIconUrl("images/");
+ }
+}
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -3,20 +3,13 @@
import org.ourproject.kune.docs.client.cnt.DocumentContent;
import org.ourproject.kune.docs.client.cnt.DocumentContentPanel;
import org.ourproject.kune.docs.client.cnt.DocumentContentPresenter;
-import org.ourproject.kune.docs.client.cnt.folder.FolderEditor;
-import org.ourproject.kune.docs.client.cnt.folder.FolderEditorPresenter;
-import org.ourproject.kune.docs.client.cnt.folder.ui.FolderEditorPanel;
import org.ourproject.kune.docs.client.cnt.folder.viewer.FolderViewer;
import org.ourproject.kune.docs.client.cnt.folder.viewer.FolderViewerPresenter;
import org.ourproject.kune.docs.client.cnt.folder.viewer.FolderViewerView;
import org.ourproject.kune.docs.client.cnt.folder.viewer.ui.FolderViewerPanel;
import org.ourproject.kune.docs.client.cnt.reader.DocumentReader;
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControl;
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControlPresenter;
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControlView;
import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderPresenter;
import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderView;
-import org.ourproject.kune.docs.client.cnt.reader.ui.DocumentReaderControlPanel;
import org.ourproject.kune.docs.client.cnt.reader.ui.DocumentReaderPanel;
import org.ourproject.kune.docs.client.ctx.DocumentContext;
import org.ourproject.kune.docs.client.ctx.DocumentContextPanel;
@@ -25,6 +18,14 @@
import org.ourproject.kune.docs.client.ctx.admin.AdminContextPresenter;
import org.ourproject.kune.docs.client.ctx.admin.AdminContextView;
import org.ourproject.kune.docs.client.ctx.admin.ui.AdminContextPanel;
+import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
+import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
+import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.services.KuneErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
@@ -59,33 +60,53 @@
public DocumentClientTool create() {
return new DocumentClientTool(i18n, $(ToolSelector.class), $(WsThemePresenter.class),
$(WorkspaceSkeleton.class), $$(DocumentContext.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $$(ContentServiceAsync.class), $$(FileUploader.class));
+ $(Session.class), $(StateManager.class), $$(ContentServiceAsync.class), $$(FileUploader.class),
+ $(ContentActionRegistry.class), $(ContextActionRegistry.class),
+ $(DragDropContentRegistry.class), $(ContentIconsRegistry.class));
}
});
- register(SingletonScope.class, new Factory<AdminContext>(AdminContext.class) {
- public AdminContext create() {
- final AdminContextPresenter presenter = new AdminContextPresenter($(Session.class),
- $(StateManager.class), $$(TagsSummary.class), $$(ContentServiceAsync.class),
- $(EntityTitle.class), $(EntitySubTitle.class));
- final AdminContextView view = new AdminContextPanel(presenter, i18n);
- presenter.init(view);
- return presenter;
+ register(SingletonScope.class, new Factory<ContentEditAction>(ContentEditAction.class) {
+ public ContentEditAction create() {
+ return new ContentEditAction(i18n);
}
+ }, new Factory<ContentTranslationAction>(ContentTranslationAction.class) {
+ public ContentTranslationAction create() {
+ return new ContentTranslationAction(i18n);
+ }
});
register(SingletonScope.class, new Factory<DocumentContent>(DocumentContent.class) {
public DocumentContent create() {
+ final ActionToolbarPanel contentNavigatorToolbar = new ActionToolbarPanel(
+ ActionToolbarPanel.Position.content, $(Session.class), $$(ActionManager.class), ws);
+ final ActionToolbar toolbar = new ActionToolbarPresenter($(Session.class), contentNavigatorToolbar,
+ $(ContentActionRegistry.class));
+
final DocumentContentPresenter presenter = new DocumentContentPresenter($(StateManager.class),
$(I18nUITranslationService.class), $(KuneErrorHandler.class), $(Session.class),
- $(RateIt.class), $$(DocumentReader.class), $$(DocumentReaderControl.class),
- $$(TextEditor.class), $$(FolderViewer.class), $$(FolderEditor.class),
- $$(ContentServiceAsync.class));
+ $(RateIt.class), $$(DocumentReader.class), $$(TextEditor.class), $$(FolderViewer.class),
+ $$(ContentServiceAsync.class), toolbar, $(ContentActionRegistry.class));
final DocumentContentPanel panel = new DocumentContentPanel($(WorkspaceSkeleton.class));
+ $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT, $(ContentEditAction.class));
+ $(ContentActionRegistry.class).addAction(DocumentClientTool.TYPE_DOCUMENT,
+ $(ContentTranslationAction.class));
presenter.init(panel);
return presenter;
}
});
+
+ register(SingletonScope.class, new Factory<AdminContext>(AdminContext.class) {
+ public AdminContext create() {
+ final AdminContextPresenter presenter = new AdminContextPresenter($(Session.class),
+ $(StateManager.class), $$(TagsSummary.class), $$(ContentServiceAsync.class),
+ $(EntityTitle.class), $(EntitySubTitle.class));
+ final AdminContextView view = new AdminContextPanel(presenter, i18n);
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
register(SingletonScope.class, new Factory<DocumentContext>(DocumentContext.class) {
public DocumentContext create() {
final DocumentContextPresenter presenter = new DocumentContextPresenter($(StateManager.class),
@@ -104,24 +125,6 @@
}
});
- register(SingletonScope.class, new Factory<DocumentReaderControl>(DocumentReaderControl.class) {
- public DocumentReaderControl create() {
- final DocumentReaderControlPresenter presenter = new DocumentReaderControlPresenter(
- $(DocumentContent.class));
- final DocumentReaderControlView view = new DocumentReaderControlPanel(presenter, i18n, ws);
- presenter.init(view);
- return presenter;
- }
- });
-
- register(SingletonScope.class, new Factory<FolderEditor>(FolderEditor.class) {
- public FolderEditor create() {
- final FolderEditorPanel view = new FolderEditorPanel();
- final FolderEditorPresenter presenter = new FolderEditorPresenter(view);
- return presenter;
- }
- });
-
register(SingletonScope.class, new Factory<FolderViewer>(FolderViewer.class) {
public FolderViewer create() {
final FolderViewerView view = new FolderViewerPanel();
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientTool.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -27,6 +27,10 @@
import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
import org.ourproject.kune.platf.client.actions.ActionPosition;
+import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
+import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
+import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.dto.ContentDTO;
import org.ourproject.kune.platf.client.dto.InitDataDTO;
@@ -67,13 +71,19 @@
private final Session session;
private final Provider<ContentServiceAsync> contentServiceProvider;
private final Provider<FileUploader> fileUploaderProvider;
+ private final ContentActionRegistry contentActionRegistry;
+ private final ContextActionRegistry contextActionRegistry;
+ private final DragDropContentRegistry dragDropContentRegistry;
+ private final ContentIconsRegistry contentIconsRegistry;
public DocumentClientTool(final I18nUITranslationService i18n, final ToolSelector toolSelector,
final WsThemePresenter wsThemePresenter, final WorkspaceSkeleton ws,
final Provider<DocumentContext> documentContextProvider, final ContextNavigator contextNavigator,
final Session session, final StateManager stateManager,
final Provider<ContentServiceAsync> contentServiceProvider,
- final Provider<FileUploader> fileUploaderProvider) {
+ final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry,
+ final ContextActionRegistry contextActionRegistry, final DragDropContentRegistry dragDropContentRegistry,
+ final ContentIconsRegistry contentIconsRegistry) {
super(NAME, i18n.t("documents"), toolSelector, wsThemePresenter, ws);
this.i18n = i18n;
this.documentContextProvider = documentContextProvider;
@@ -82,6 +92,10 @@
this.stateManager = stateManager;
this.contentServiceProvider = contentServiceProvider;
this.fileUploaderProvider = fileUploaderProvider;
+ this.contentActionRegistry = contentActionRegistry;
+ this.contextActionRegistry = contextActionRegistry;
+ this.dragDropContentRegistry = dragDropContentRegistry;
+ this.contentIconsRegistry = contentIconsRegistry;
createActions();
registerDragDropTypes();
registerImageTypes();
@@ -102,6 +116,7 @@
}
private void createActions() {
+
final ActionMenuDescriptor<StateToken> addFolder = createFolderAction(TYPE_FOLDER, "images/nav/folder_add.png",
i18n.t("New folder"), i18n.t("File"), i18n.t("New"));
final ActionMenuDescriptor<StateToken> addGallery = createFolderAction(TYPE_GALLERY,
@@ -236,41 +251,43 @@
final ActionDescriptor<StateToken> uploadMedia = createUploadAction(i18n.t("Upload media"),
"images/nav/upload.png", i18n.t("Upload some media (images, videos)"), session
.getGalleryPermittedExtensions());
- contextNavigator.addAction(TYPE_GALLERY, uploadMedia);
+ contextActionRegistry.addAction(TYPE_GALLERY, uploadMedia);
}
});
- contextNavigator.addAction(TYPE_FOLDER, go);
- contextNavigator.addAction(TYPE_FOLDER, addDoc);
- contextNavigator.addAction(TYPE_FOLDER, addFolder);
- contextNavigator.addAction(TYPE_FOLDER, delContainer);
- contextNavigator.addAction(TYPE_FOLDER, rename);
- contextNavigator.addAction(TYPE_FOLDER, goGroupHome);
- contextNavigator.addAction(TYPE_FOLDER, refresh);
- contextNavigator.addAction(TYPE_FOLDER, uploadFile);
+ contextActionRegistry.addAction(TYPE_FOLDER, go);
+ contextActionRegistry.addAction(TYPE_FOLDER, addDoc);
+ contextActionRegistry.addAction(TYPE_FOLDER, addFolder);
+ contentActionRegistry.addAction(TYPE_FOLDER, delContainer);
+ contextActionRegistry.addAction(TYPE_FOLDER, delContainer);
+ contextActionRegistry.addAction(TYPE_FOLDER, rename);
+ contextActionRegistry.addAction(TYPE_FOLDER, goGroupHome);
+ contextActionRegistry.addAction(TYPE_FOLDER, refresh);
+ contextActionRegistry.addAction(TYPE_FOLDER, uploadFile);
- contextNavigator.addAction(TYPE_BLOG, go);
- contextNavigator.addAction(TYPE_BLOG, uploadFile);
- contextNavigator.addAction(TYPE_BLOG, setAsDefGroupContent);
- contextNavigator.addAction(TYPE_BLOG, refresh);
+ contextActionRegistry.addAction(TYPE_BLOG, go);
+ contextActionRegistry.addAction(TYPE_BLOG, uploadFile);
+ contextActionRegistry.addAction(TYPE_BLOG, setAsDefGroupContent);
+ contextActionRegistry.addAction(TYPE_BLOG, refresh);
- contextNavigator.addAction(TYPE_GALLERY, go);
- contextNavigator.addAction(TYPE_GALLERY, goGroupHome);
- contextNavigator.addAction(TYPE_GALLERY, refresh);
+ contextActionRegistry.addAction(TYPE_GALLERY, go);
+ contextActionRegistry.addAction(TYPE_GALLERY, goGroupHome);
+ contextActionRegistry.addAction(TYPE_GALLERY, refresh);
- contextNavigator.addAction(TYPE_ROOT, addDoc);
- contextNavigator.addAction(TYPE_ROOT, addFolder);
- contextNavigator.addAction(TYPE_ROOT, addGallery);
- contextNavigator.addAction(TYPE_ROOT, goGroupHome);
- contextNavigator.addAction(TYPE_ROOT, refresh);
- contextNavigator.addAction(TYPE_ROOT, uploadFile);
+ contextActionRegistry.addAction(TYPE_ROOT, addDoc);
+ contextActionRegistry.addAction(TYPE_ROOT, addFolder);
+ contextActionRegistry.addAction(TYPE_ROOT, addGallery);
+ contextActionRegistry.addAction(TYPE_ROOT, goGroupHome);
+ contextActionRegistry.addAction(TYPE_ROOT, refresh);
+ contextActionRegistry.addAction(TYPE_ROOT, uploadFile);
- contextNavigator.addAction(TYPE_DOCUMENT, go);
- contextNavigator.addAction(TYPE_DOCUMENT, delContent);
- contextNavigator.addAction(TYPE_DOCUMENT, rename);
- contextNavigator.addAction(TYPE_DOCUMENT, goGroupHome);
- contextNavigator.addAction(TYPE_DOCUMENT, refresh);
- contextNavigator.addAction(TYPE_DOCUMENT, setAsDefGroupContent);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, go);
+ contentActionRegistry.addAction(TYPE_DOCUMENT, delContent);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, delContent);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, rename);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, goGroupHome);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, refresh);
+ contextActionRegistry.addAction(TYPE_DOCUMENT, setAsDefGroupContent);
}
private ActionMenuDescriptor<StateToken> createFolderAction(final String contentTypeId, final String iconUrl,
@@ -317,20 +334,20 @@
}
private void registerDragDropTypes() {
- contextNavigator.registerDraggableType(TYPE_DOCUMENT);
- contextNavigator.registerDraggableType(TYPE_FOLDER);
- contextNavigator.registerDraggableType(TYPE_UPLOADEDFILE);
+ dragDropContentRegistry.registerDraggableType(TYPE_DOCUMENT);
+ dragDropContentRegistry.registerDraggableType(TYPE_FOLDER);
+ dragDropContentRegistry.registerDraggableType(TYPE_UPLOADEDFILE);
- contextNavigator.registerDroppableType(TYPE_ROOT);
- contextNavigator.registerDroppableType(TYPE_FOLDER);
- contextNavigator.registerDroppableType(TYPE_GALLERY);
+ dragDropContentRegistry.registerDroppableType(TYPE_ROOT);
+ dragDropContentRegistry.registerDroppableType(TYPE_FOLDER);
+ dragDropContentRegistry.registerDroppableType(TYPE_GALLERY);
}
private void registerImageTypes() {
- contextNavigator.registerContentTypeIcon(TYPE_BLOG, "images/nav/blog.png");
- contextNavigator.registerContentTypeIcon(TYPE_GALLERY, "images/nav/gallery.png");
- contextNavigator.registerContentTypeIcon(TYPE_DOCUMENT, "images/nav/page.png");
- contextNavigator.registerContentTypeIcon(TYPE_POST, "images/nav/post.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_BLOG, "images/nav/blog.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_GALLERY, "images/nav/gallery.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_DOCUMENT, "images/nav/page.png");
+ contentIconsRegistry.registerContentTypeIcon(TYPE_POST, "images/nav/post.png");
}
}
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/DocumentContentPresenter.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -21,11 +21,13 @@
package org.ourproject.kune.docs.client.cnt;
import org.ourproject.kune.docs.client.DocumentClientTool;
-import org.ourproject.kune.docs.client.cnt.folder.FolderEditor;
import org.ourproject.kune.docs.client.cnt.folder.viewer.FolderViewer;
import org.ourproject.kune.docs.client.cnt.reader.DocumentReader;
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControl;
+import org.ourproject.kune.platf.client.actions.ActionCollectionSet;
+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;
+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;
@@ -51,9 +53,7 @@
private StateDTO content;
private final Session session;
private final RateIt rateIt;
- private final Provider<DocumentReaderControl> docReaderControlProvider;
private final Provider<DocumentReader> docReaderProvider;
- private final Provider<FolderEditor> folderEditorProvider;
private final Provider<TextEditor> textEditorProvider;
private final Provider<FolderViewer> folderViewerProvider;
private final Signal0 onEditing;
@@ -61,32 +61,32 @@
private final Provider<ContentServiceAsync> contentServiceProvider;
private final I18nUITranslationService i18n;
private final KuneErrorHandler errorHandler;
+ private final ActionToolbar toolbar;
+ private final ActionRegistry actionRegistry;
public DocumentContentPresenter(final StateManager stateManager, final I18nUITranslationService i18n,
final KuneErrorHandler errorHandler, final Session session, final RateIt rateIt,
- final Provider<DocumentReader> docReaderProvider,
- final Provider<DocumentReaderControl> docReaderControlProvider,
- final Provider<TextEditor> textEditorProvider, final Provider<FolderViewer> folderViewerProvider,
- final Provider<FolderEditor> folderEditorProvider,
- final Provider<ContentServiceAsync> contentServiceProvider) {
+ final Provider<DocumentReader> docReaderProvider, final Provider<TextEditor> textEditorProvider,
+ final Provider<FolderViewer> folderViewerProvider,
+ final Provider<ContentServiceAsync> contentServiceProvider, final ActionToolbar toolbar,
+ final ActionRegistry actionRegistry) {
this.stateManager = stateManager;
this.i18n = i18n;
this.errorHandler = errorHandler;
this.session = session;
this.rateIt = rateIt;
this.docReaderProvider = docReaderProvider;
- this.docReaderControlProvider = docReaderControlProvider;
this.textEditorProvider = textEditorProvider;
this.folderViewerProvider = folderViewerProvider;
- this.folderEditorProvider = folderEditorProvider;
this.contentServiceProvider = contentServiceProvider;
+ this.toolbar = toolbar;
+ this.actionRegistry = actionRegistry;
this.onEditing = new Signal0("onEditing");
this.onEditCancelled = new Signal0("onEditCancelled");
stateManager.onStateChanged(new Slot<StateDTO>() {
public void onEvent(final StateDTO state) {
if (state.getToolName().equals(DocumentClientTool.NAME)) {
- content = state;
- showContent();
+ setState(state);
}
}
});
@@ -137,9 +137,9 @@
editor.setToolbarVisible(true);
view.setContent(editor.getView());
} else {
- final FolderEditor editor = folderEditorProvider.get();
- editor.setFolder(content.getContainer());
- view.setContent(editor.getView());
+ // final FolderEditor editor = folderEditorProvider.get();
+ // editor.setFolder(content.getContainer());
+ // view.setContent(editor.getView());
}
onEditing.fire();
}
@@ -186,13 +186,25 @@
public void onTranslate() {
}
+ private void setState(final StateDTO state) {
+ content = state;
+ ActionCollectionSet<StateToken> set;
+ final String typeId = content.getTypeId();
+ if (content.hasDocument()) {
+ set = actionRegistry.selectCurrentActions(content.getContentRights(), typeId);
+ } else {
+ set = actionRegistry.selectCurrentActions(content.getContainerRights(), typeId);
+ }
+ toolbar.disableMenusAndClearButtons();
+ toolbar.setActions(set.getToolbarActions(), true);
+ showContent();
+ }
+
private void showContent() {
textEditorProvider.get().setToolbarVisible(false);
if (content.hasDocument()) {
docReaderProvider.get().showDocument(content.getContent());
textEditorProvider.get().reset();
- docReaderControlProvider.get().setRights(content.getContentRights());
- docReaderControlProvider.get().show();
docReaderProvider.get().show();
} else {
final FolderViewer viewer = folderViewerProvider.get();
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditor.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditor.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,30 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.folder;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.dto.ContainerDTO;
-
-public interface FolderEditor {
- View getView();
-
- void setFolder(ContainerDTO folder);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorPresenter.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorPresenter.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,41 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.folder;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.dto.ContainerDTO;
-
-public class FolderEditorPresenter implements FolderEditor {
-
- private final FolderEditorView view;
-
- public FolderEditorPresenter(final FolderEditorView view) {
- this.view = view;
- }
-
- public View getView() {
- return view;
- }
-
- public void setFolder(final ContainerDTO folder) {
-
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorView.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/folder/FolderEditorView.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,27 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.folder;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface FolderEditorView extends View {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControl.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControl.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControl.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,31 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.reader;
-
-import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
-
-public interface DocumentReaderControl {
-
- void setRights(AccessRightsDTO accessRights);
-
- void show();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlPresenter.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlPresenter.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,70 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.reader;
-
-import org.ourproject.kune.docs.client.cnt.DocumentContent;
-import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
-
-import com.calclab.suco.client.signal.Slot0;
-
-public class DocumentReaderControlPresenter implements DocumentReaderControl {
- private DocumentReaderControlView view;
- private final DocumentContent docContent;
-
- public DocumentReaderControlPresenter(final DocumentContent docContent) {
- this.docContent = docContent;
- docContent.onEditing(new Slot0() {
- public void onEvent() {
- view.hide();
- }
- });
- docContent.onEditCancelled(new Slot0() {
- public void onEvent() {
- view.show();
- }
- });
- }
-
- public void init(final DocumentReaderControlView view) {
- this.view = view;
- }
-
- public void onDeleteClicked() {
- // docContent.onDeleteClicked();
- }
-
- public void onEditClicked() {
- // docContent.onEditClicked();
- }
-
- public void onTranslateClicked() {
- }
-
- public void setRights(final AccessRightsDTO accessRights) {
- view.setEditEnabled(accessRights.isEditable());
- view.setDeleteEnabled(accessRights.isAdministrable());
- view.setTranslateEnabled(accessRights.isEditable());
- }
-
- public void show() {
- view.show();
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlView.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/DocumentReaderControlView.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,37 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.reader;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface DocumentReaderControlView extends View {
-
- void hide();
-
- void setDeleteEnabled(boolean isEnabled);
-
- void setEditEnabled(boolean isEnabled);
-
- void setTranslateEnabled(boolean isEnabled);
-
- void show();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/ui/DocumentReaderControlPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/ui/DocumentReaderControlPanel.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/cnt/reader/ui/DocumentReaderControlPanel.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,102 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2008 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-package org.ourproject.kune.docs.client.cnt.reader.ui;
-
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControlPresenter;
-import org.ourproject.kune.docs.client.cnt.reader.DocumentReaderControlView;
-import org.ourproject.kune.workspace.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.workspace.client.skel.Toolbar;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.ToolbarButton;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-
-public class DocumentReaderControlPanel implements DocumentReaderControlView {
- private final ToolbarButton editBtn;
- private final ToolbarButton deleteBtn;
- private final ToolbarButton translateBtn;
- private final Widget space1;
- private final Widget space2;
-
- public DocumentReaderControlPanel(final DocumentReaderControlPresenter presenter,
- final I18nUITranslationService i18n, final WorkspaceSkeleton ws) {
- editBtn = new ToolbarButton(i18n.tWithNT("Edit", "used in button"), new ButtonListenerAdapter() {
- public void onClick(final Button button, final EventObject e) {
- presenter.onEditClicked();
- }
- });
-
- deleteBtn = new ToolbarButton(i18n.tWithNT("Delete", "used in button"), new ButtonListenerAdapter() {
- public void onClick(final Button button, final EventObject e) {
- presenter.onDeleteClicked();
- }
- });
-
- translateBtn = new ToolbarButton(i18n.tWithNT("Translate", "used in button"), new ButtonListenerAdapter() {
- public void onClick(final Button button, final EventObject e) {
- presenter.onTranslateClicked();
- ws.showAlertMessage(i18n.t("Alert"), i18n.t("Sorry, this functionality is currently in development"));
- }
- });
-
- final Toolbar contentTopBar = ws.getEntityWorkspace().getContentTopBar();
- contentTopBar.add(editBtn);
- space1 = contentTopBar.addSpacer();
- contentTopBar.add(deleteBtn);
- space2 = contentTopBar.addSpacer();
- contentTopBar.add(translateBtn);
- setEditEnabled(false);
- setDeleteEnabled(false);
- setTranslateEnabled(false);
- hide();
- }
-
- public void hide() {
- this.setVisible(false);
- }
-
- public void setDeleteEnabled(final boolean isEnabled) {
- deleteBtn.setVisible(isEnabled);
- }
-
- public void setEditEnabled(final boolean isEnabled) {
- editBtn.setVisible(isEnabled);
- }
-
- public void setTranslateEnabled(final boolean isEnabled) {
- translateBtn.setVisible(isEnabled);
- }
-
- public void show() {
- this.setVisible(true);
- }
-
- private void setVisible(final boolean visible) {
- editBtn.setVisible(visible);
- deleteBtn.setVisible(visible);
- translateBtn.setVisible(visible);
- space1.setVisible(visible);
- space2.setVisible(visible);
- }
-}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionRegistry.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,75 @@
+package org.ourproject.kune.platf.client.actions;
+
+import java.util.HashMap;
+
+import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+
+public class ActionRegistry {
+
+ private final HashMap<String, ActionCollection<StateToken>> actions;
+
+ public ActionRegistry() {
+ actions = new HashMap<String, ActionCollection<StateToken>>();
+ }
+
+ public void addAction(final String contentTypeId, final ActionDescriptor<StateToken> action) {
+ final ActionCollection<StateToken> actionColl = getActions(contentTypeId);
+ actionColl.add(action);
+ }
+
+ public boolean checkEnabling(final ActionDescriptor<StateToken> action, final StateToken stateToken) {
+ final ActionEnableCondition<StateToken> enableCondition = action.getEnableCondition();
+ return enableCondition != null ? enableCondition.mustBeEnabled(stateToken) : true;
+ }
+
+ public void removeAction(final String contentTypeId, final ActionDescriptor<StateToken> action) {
+ actions.get(contentTypeId).remove(action);
+ }
+
+ public ActionCollectionSet<StateToken> selectCurrentActions(final AccessRightsDTO rights, final String contentTypeId) {
+ final ActionCollectionSet<StateToken> set = new ActionCollectionSet<StateToken>();
+ boolean add = false;
+
+ for (final ActionDescriptor<StateToken> 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;
+ }
+ }
+ }
+ return set;
+ }
+
+ private ActionCollection<StateToken> getActions(final String contentTypeId) {
+ ActionCollection<StateToken> actionColl = actions.get(contentTypeId);
+ if (actionColl == null) {
+ actionColl = new ActionCollection<StateToken>();
+ actions.put(contentTypeId, actionColl);
+ }
+ return actionColl;
+ }
+}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentActionRegistry.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.actions;
+
+public class ContentActionRegistry extends ActionRegistry {
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContentIconsRegistry.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,20 @@
+package org.ourproject.kune.platf.client.actions;
+
+import java.util.HashMap;
+
+public class ContentIconsRegistry {
+ private final HashMap<String, String> contentTypesIcons;
+
+ public ContentIconsRegistry() {
+ contentTypesIcons = new HashMap<String, String>();
+ }
+
+ public String getContentTypeIcon(final String typeId) {
+ final String icon = contentTypesIcons.get(typeId);
+ return icon == null ? "" : icon;
+ }
+
+ public void registerContentTypeIcon(final String contentTypeId, final String iconUrl) {
+ contentTypesIcons.put(contentTypeId, iconUrl);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContextActionRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContextActionRegistry.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ContextActionRegistry.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.actions;
+
+public class ContextActionRegistry extends ActionRegistry {
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/DragDropContentRegistry.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/DragDropContentRegistry.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/DragDropContentRegistry.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,31 @@
+package org.ourproject.kune.platf.client.actions;
+
+import java.util.ArrayList;
+
+public class DragDropContentRegistry {
+
+ private final ArrayList<String> draggables;
+ private final ArrayList<String> droppables;
+
+ public DragDropContentRegistry() {
+ draggables = new ArrayList<String>();
+ droppables = new ArrayList<String>();
+ }
+
+ public boolean isDraggable(final String typeId, final boolean administrable) {
+ return administrable && draggables.contains(typeId);
+ }
+
+ public boolean isDroppable(final String typeId, final boolean administrable) {
+ return administrable && droppables.contains(typeId);
+ }
+
+ public void registerDraggableType(final String type) {
+ draggables.add(type);
+ }
+
+ public void registerDroppableType(final String type) {
+ droppables.add(type);
+ }
+
+}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,14 @@
+package org.ourproject.kune.platf.client.actions.toolbar;
+
+import org.ourproject.kune.platf.client.actions.ActionCollection;
+import org.ourproject.kune.platf.client.dto.StateToken;
+
+public interface ActionToolbar {
+
+ void clear();
+
+ void disableMenusAndClearButtons();
+
+ void setActions(ActionCollection<StateToken> actionCollection, boolean isItemSelected);
+
+}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,236 @@
+package org.ourproject.kune.platf.client.actions.toolbar;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+
+import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionButtonSeparator;
+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;
+
+import com.calclab.suco.client.provider.Provider;
+import com.google.gwt.user.client.ui.Widget;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.menu.BaseItem;
+import com.gwtext.client.widgets.menu.Item;
+import com.gwtext.client.widgets.menu.Menu;
+import com.gwtext.client.widgets.menu.MenuItem;
+import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
+
+public class ActionToolbarPanel implements ActionToolbarView {
+
+ public enum Position {
+ content, context
+ }
+
+ private final HashMap<String, Menu> toolbarMenus;
+ 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) {
+ this.position = position;
+ this.session = session;
+ this.actionManagerProvider = actionManagerProvider;
+ this.ws = ws;
+ toolbarMenus = new HashMap<String, Menu>();
+ removableToolbarItems = new ArrayList<Widget>();
+ menuItems = new HashMap<String, Item>();
+
+ }
+
+ public void addButtonAction(final ActionButtonDescriptor<StateToken> action) {
+ final ActionPosition pos = action.getActionPosition();
+ final ToolbarButton button = new ToolbarButton();
+ final String text = action.getText();
+ final String iconUrl = action.getIconUrl();
+ if (text != null) {
+ button.setText(text);
+ }
+ button.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(final Button button, final EventObject e) {
+ actionManagerProvider.get().doAction(action, session.getCurrentState().getStateToken());
+ }
+ });
+ if (iconUrl != null) {
+ button.setIcon(iconUrl);
+ }
+ button.setTooltip(action.getToolTip());
+
+ final Toolbar toolbar = getToolbar(pos);
+ if (action.hasLeftSeparator()) {
+ removableToolbarItems.add(add(toolbar, action.getLeftSeparator()));
+ }
+ toolbar.add(button);
+ if (action.hasRightSeparator()) {
+ removableToolbarItems.add(add(toolbar, action.getRightSeparator()));
+ }
+ removableToolbarItems.add(button);
+ }
+
+ public void addMenuAction(final ActionMenuDescriptor<StateToken> action, final boolean enable) {
+ 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);
+ menuItems.put(itemKey, item);
+ }
+ if (enable) {
+ item.enable();
+ } else {
+ item.disable();
+ }
+ doLayoutIfNeeded(pos);
+ }
+
+ public void clear() {
+ toolbarMenus.clear();
+ menuItems.clear();
+ removableToolbarItems.clear();
+ getToolbar(ActionPosition.topbar).removeAll();
+ getToolbar(ActionPosition.bottombar).removeAll();
+ }
+
+ public void clearRemovableActions() {
+ for (final Widget widget : removableToolbarItems) {
+ widget.removeFromParent();
+ }
+ removableToolbarItems.clear();
+ doLayoutIfNeeded();
+ }
+
+ public void disableAllMenuItems() {
+ for (final Item item : menuItems.values()) {
+ item.disable();
+ }
+ doLayoutIfNeeded();
+ }
+
+ private void add(final ActionPosition toolbar, final Widget widget) {
+ getToolbar(toolbar).add(widget);
+ }
+
+ private Widget add(final Toolbar toolbar, final ActionButtonSeparator separator) {
+ switch (separator) {
+ case fill:
+ return toolbar.addFill();
+ case separator:
+ return toolbar.addSeparator();
+ case spacer:
+ default:
+ return toolbar.addSpacer();
+ }
+ }
+
+ private Item createToolbarMenu(final ActionPosition toolBarPos, final String menuTitle, final String menuSubTitle,
+ final ActionMenuDescriptor<StateToken> action) {
+ final Item item = new Item(action.getText(), new BaseItemListenerAdapter() {
+ @Override
+ public void onClick(BaseItem item, EventObject e) {
+ actionManagerProvider.get().doAction(action, session.getCurrentState().getStateToken());
+ }
+ });
+ item.setIcon(action.getIconUrl());
+
+ final String menuKey = genMenuKey(toolBarPos, menuTitle, null, null);
+ final String subMenuKey = genMenuKey(toolBarPos, menuTitle, menuSubTitle, null);
+ Menu menu = toolbarMenus.get(menuKey);
+ Menu subMenu = toolbarMenus.get(subMenuKey);
+ if (menuSubTitle != null) {
+ if (subMenu == null) {
+ subMenu = new Menu();
+ final MenuItem subMenuItem = new MenuItem(menuSubTitle, subMenu);
+ if (menu == null) {
+ menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
+ }
+ menu.addItem(subMenuItem);
+ toolbarMenus.put(subMenuKey, subMenu);
+ }
+ subMenu.addItem(item);
+
+ } else {
+ // Menu action without submenu
+ if (menu == null) {
+ menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
+ }
+ menu.addItem(item);
+ }
+ doLayoutIfNeeded(toolBarPos);
+ return item;
+ }
+
+ private Menu createToolbarMenu(final ActionPosition barPosition, final String iconUrl, final String menuTitle,
+ final String menuKey) {
+ final Menu menu = new Menu();
+ final ToolbarButton toolbarMenu = new ToolbarButton(menuTitle);
+ if (iconUrl != null) {
+ toolbarMenu.setIcon(iconUrl);
+ }
+ toolbarMenu.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(final Button button, final EventObject e) {
+ menu.showAt(e.getXY());
+ }
+ });
+ toolbarMenus.put(menuKey, menu);
+ add(barPosition, toolbarMenu);
+ return menu;
+ }
+
+ private void doLayoutIfNeeded() {
+ doLayoutIfNeeded(ActionPosition.topbar);
+ doLayoutIfNeeded(ActionPosition.bottombar);
+ }
+
+ private void doLayoutIfNeeded(final ActionPosition pos) {
+ getToolbar(pos).doLayoutIfNeeded();
+ }
+
+ private String genMenuKey(final ActionPosition pos, final String menuTitle, final String menuSubTitle,
+ final String actionText) {
+ final String basePart = "km-" + pos.toString() + "-" + menuTitle;
+ final String subMenuPart = menuSubTitle != null ? "-subm-" + menuSubTitle : "";
+ final String itemPart = actionText != null ? "-item-" + actionText : "";
+ return basePart + subMenuPart + itemPart;
+ }
+
+ private Toolbar getToolbar(final ActionPosition pos) {
+ switch (pos) {
+ case bootombarAndItemMenu:
+ case bottombar:
+ switch (position) {
+ case content:
+ return ws.getEntityWorkspace().getContentBottomBar();
+ case context:
+ default:
+ return ws.getEntityWorkspace().getContextBottomBar();
+ }
+ case topbar:
+ case topbarAndItemMenu:
+ default:
+ switch (position) {
+ case content:
+ return ws.getEntityWorkspace().getContentTopBar();
+ case context:
+ default:
+ return ws.getEntityWorkspace().getContextTopBar();
+ }
+ }
+ }
+}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,52 @@
+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.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 ActionToolbarPanel toolbar;
+ private final Session session;
+ private final ActionRegistry actionRegistry;
+
+ public ActionToolbarPresenter(final Session session, final ActionToolbarPanel actionToolbarPanel,
+ final ActionRegistry actionRegistry) {
+ this.session = session;
+ toolbar = actionToolbarPanel;
+ this.actionRegistry = actionRegistry;
+ }
+
+ public void clear() {
+ toolbar.clear();
+ }
+
+ public void disableMenusAndClearButtons() {
+ toolbar.clearRemovableActions();
+ toolbar.disableAllMenuItems();
+ }
+
+ public void setActions(final ActionCollection<StateToken> actions, final boolean isItemSelected) {
+ for (final ActionDescriptor<StateToken> action : actions) {
+ if (action instanceof ActionMenuDescriptor) {
+ toolbar.addMenuAction((ActionMenuDescriptor<StateToken>) action, isItemSelected
+ && actionRegistry.checkEnabling(action, session.getCurrentStateToken()));
+ } else {
+ if (action instanceof ActionButtonDescriptor) {
+ if (isItemSelected && actionRegistry.checkEnabling(action, session.getCurrentStateToken())) {
+ toolbar.addButtonAction((ActionButtonDescriptor<StateToken>) action);
+ }
+ } else {
+ // Code smell
+ Log.error("Not an ActionMenuDescriptor or ActionButtonDescriptor");
+ }
+ }
+ }
+ }
+
+}
Added: 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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -0,0 +1,19 @@
+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.dto.StateToken;
+
+public interface ActionToolbarView {
+
+ void addButtonAction(ActionButtonDescriptor<StateToken> action);
+
+ void addMenuAction(ActionMenuDescriptor<StateToken> action, boolean enable);
+
+ void clear();
+
+ void clearRemovableActions();
+
+ void disableAllMenuItems();
+
+}
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneModule.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -3,6 +3,13 @@
import org.ourproject.kune.chat.client.ChatClientModule;
import org.ourproject.kune.docs.client.DocumentClientModule;
import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.actions.ContentActionRegistry;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
+import org.ourproject.kune.platf.client.actions.ContextActionRegistry;
+import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+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.Application;
import org.ourproject.kune.platf.client.app.ApplicationDefault;
import org.ourproject.kune.platf.client.app.HistoryWrapper;
@@ -36,7 +43,6 @@
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.ctxnav.ContextNavigatorToolbar;
import org.ourproject.kune.workspace.client.editor.TextEditor;
import org.ourproject.kune.workspace.client.editor.TextEditorPanel;
import org.ourproject.kune.workspace.client.editor.TextEditorPresenter;
@@ -588,14 +594,43 @@
}
});
+ register(SingletonScope.class, new Factory<ContextActionRegistry>(ContextActionRegistry.class) {
+ public ContextActionRegistry create() {
+ return new ContextActionRegistry();
+ }
+ });
+
+ register(SingletonScope.class, new Factory<ContentActionRegistry>(ContentActionRegistry.class) {
+ public ContentActionRegistry create() {
+ return new ContentActionRegistry();
+ }
+ });
+
+ register(SingletonScope.class, new Factory<DragDropContentRegistry>(DragDropContentRegistry.class) {
+ public DragDropContentRegistry create() {
+ return new DragDropContentRegistry();
+ }
+ });
+
+ register(SingletonScope.class, new Factory<ContentIconsRegistry>(ContentIconsRegistry.class) {
+ public ContentIconsRegistry create() {
+ return new ContentIconsRegistry();
+ }
+ });
+
register(SingletonScope.class, new Factory<ContextNavigator>(ContextNavigator.class) {
public ContextNavigator create() {
- final ContextNavigatorToolbar contextNavigatorToolbar = new ContextNavigatorToolbar($(Session.class),
- $$(ActionManager.class), ws);
+ final ActionToolbarPanel contextNavigatorToolbar = new ActionToolbarPanel(ActionToolbarPanel.Position.context,
+ $(Session.class), $$(ActionManager.class), ws);
+ final ActionToolbar toolbar = new ActionToolbarPresenter($(Session.class),
+ contextNavigatorToolbar, $(ContextActionRegistry.class));
+
final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
$(Session.class), $$(ContentServiceAsync.class), i18n, $(EntityTitle.class),
- $$(ActionManager.class), contextNavigatorToolbar);
- final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter, i18n, ws);
+ $(ContentIconsRegistry.class), $(DragDropContentRegistry.class),
+ $(ContextActionRegistry.class), toolbar);
+ final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter, i18n, ws,
+ $(ActionManager.class));
presenter.init(panel);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/state/Session.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/state/Session.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/state/Session.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -27,6 +27,7 @@
import org.ourproject.kune.platf.client.dto.InitDataDTO;
import org.ourproject.kune.platf.client.dto.LicenseDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.dto.UserInfoDTO;
import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
@@ -50,6 +51,8 @@
public StateDTO getCurrentState();
+ public StateToken getCurrentStateToken();
+
public List<I18nLanguageSimpleDTO> getLanguages();
public Object[][] getLanguagesArray();
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-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/state/SessionDefault.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -29,6 +29,7 @@
import org.ourproject.kune.platf.client.dto.InitDataDTO;
import org.ourproject.kune.platf.client.dto.LicenseDTO;
import org.ourproject.kune.platf.client.dto.StateDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.dto.UserInfoDTO;
import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
import org.ourproject.kune.workspace.client.site.rpc.UserServiceAsync;
@@ -87,6 +88,10 @@
return currentState;
}
+ public StateToken getCurrentStateToken() {
+ return currentState == null ? null : currentState.getStateToken();
+ }
+
public UserInfoDTO getCurrentUserInfo() {
return currentUserInfo;
}
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/FileManager.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,9 +1,5 @@
package org.ourproject.kune.platf.server.manager;
-import org.ourproject.kune.platf.server.domain.Container;
-import org.ourproject.kune.platf.server.domain.Content;
-import org.ourproject.kune.platf.server.domain.User;
-
public interface FileManager {
-
+
}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbar.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbar.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,233 +0,0 @@
-package org.ourproject.kune.workspace.client.component;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionButtonSeparator;
-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;
-
-import com.calclab.suco.client.provider.Provider;
-import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.ToolbarButton;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.widgets.menu.BaseItem;
-import com.gwtext.client.widgets.menu.Item;
-import com.gwtext.client.widgets.menu.Menu;
-import com.gwtext.client.widgets.menu.MenuItem;
-import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
-
-public class EntityToolbar implements EntityToolbarView {
-
- protected enum ToolbarPosition {
- content, context
- }
-
- private final HashMap<String, Menu> toolbarMenus;
- 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 ToolbarPosition position;
-
- public EntityToolbar(final ToolbarPosition position, final Session session,
- final Provider<ActionManager> actionManagerProvider, final WorkspaceSkeleton ws) {
- this.position = position;
- this.session = session;
- this.actionManagerProvider = actionManagerProvider;
- this.ws = ws;
- toolbarMenus = new HashMap<String, Menu>();
- removableToolbarItems = new ArrayList<Widget>();
- menuItems = new HashMap<String, Item>();
-
- }
-
- public void addButtonAction(final ActionButtonDescriptor<StateToken> action) {
- final ActionPosition pos = action.getActionPosition();
- final ToolbarButton button = new ToolbarButton();
- final String text = action.getText();
- if (text != null) {
- button.setText(text);
- }
- button.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(final Button button, final EventObject e) {
- actionManagerProvider.get().doAction(action, session.getCurrentState().getStateToken());
- }
- });
- button.setIcon(action.getIconUrl());
- button.setTooltip(action.getToolTip());
-
- final Toolbar toolbar = getToolbar(pos);
- if (action.hasLeftSeparator()) {
- removableToolbarItems.add(add(toolbar, action.getLeftSeparator()));
- }
- toolbar.add(button);
- if (action.hasRightSeparator()) {
- removableToolbarItems.add(add(toolbar, action.getRightSeparator()));
- }
- removableToolbarItems.add(button);
- }
-
- public void addMenuAction(final ActionMenuDescriptor<StateToken> action, final boolean enable) {
- 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);
- menuItems.put(itemKey, item);
- }
- if (enable) {
- item.enable();
- } else {
- item.disable();
- }
- doLayoutIfNeeded(pos);
- }
-
- public void clear() {
- toolbarMenus.clear();
- menuItems.clear();
- removableToolbarItems.clear();
- getToolbar(ActionPosition.topbar).removeAll();
- getToolbar(ActionPosition.bottombar).removeAll();
- }
-
- public void clearRemovableActions() {
- for (final Widget widget : removableToolbarItems) {
- widget.removeFromParent();
- }
- removableToolbarItems.clear();
- doLayoutIfNeeded();
- }
-
- public void disableAllMenuItems() {
- for (final Item item : menuItems.values()) {
- item.disable();
- }
- doLayoutIfNeeded();
- }
-
- private void add(final ActionPosition toolbar, final Widget widget) {
- getToolbar(toolbar).add(widget);
- }
-
- private Widget add(final Toolbar toolbar, final ActionButtonSeparator separator) {
- switch (separator) {
- case fill:
- return toolbar.addFill();
- case separator:
- return toolbar.addSeparator();
- case spacer:
- default:
- return toolbar.addSpacer();
- }
- }
-
- private Item createToolbarMenu(final ActionPosition toolBarPos, final String menuTitle, final String menuSubTitle,
- final ActionMenuDescriptor<StateToken> action) {
- final Item item = new Item(action.getText(), new BaseItemListenerAdapter() {
- @Override
- public void onClick(BaseItem item, EventObject e) {
- actionManagerProvider.get().doAction(action, session.getCurrentState().getStateToken());
- }
- });
- item.setIcon(action.getIconUrl());
-
- final String menuKey = genMenuKey(toolBarPos, menuTitle, null, null);
- final String subMenuKey = genMenuKey(toolBarPos, menuTitle, menuSubTitle, null);
- Menu menu = toolbarMenus.get(menuKey);
- Menu subMenu = toolbarMenus.get(subMenuKey);
- if (menuSubTitle != null) {
- if (subMenu == null) {
- subMenu = new Menu();
- final MenuItem subMenuItem = new MenuItem(menuSubTitle, subMenu);
- if (menu == null) {
- menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
- }
- menu.addItem(subMenuItem);
- toolbarMenus.put(subMenuKey, subMenu);
- }
- subMenu.addItem(item);
-
- } else {
- // Menu action without submenu
- if (menu == null) {
- menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), menuTitle, menuKey);
- }
- menu.addItem(item);
- }
- doLayoutIfNeeded(toolBarPos);
- return item;
- }
-
- private Menu createToolbarMenu(final ActionPosition barPosition, final String iconUrl, final String menuTitle,
- final String menuKey) {
- final Menu menu = new Menu();
- final ToolbarButton toolbarMenu = new ToolbarButton(menuTitle);
- if (iconUrl != null) {
- toolbarMenu.setIcon(iconUrl);
- }
- toolbarMenu.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(final Button button, final EventObject e) {
- menu.showAt(e.getXY());
- }
- });
- toolbarMenus.put(menuKey, menu);
- add(barPosition, toolbarMenu);
- return menu;
- }
-
- private void doLayoutIfNeeded() {
- doLayoutIfNeeded(ActionPosition.topbar);
- doLayoutIfNeeded(ActionPosition.bottombar);
- }
-
- private void doLayoutIfNeeded(final ActionPosition pos) {
- getToolbar(pos).doLayoutIfNeeded();
- }
-
- private String genMenuKey(final ActionPosition pos, final String menuTitle, final String menuSubTitle,
- final String actionText) {
- final String basePart = "km-" + pos.toString() + "-" + menuTitle;
- final String subMenuPart = menuSubTitle != null ? "-subm-" + menuSubTitle : "";
- final String itemPart = actionText != null ? "-item-" + actionText : "";
- return basePart + subMenuPart + itemPart;
- }
-
- private Toolbar getToolbar(final ActionPosition pos) {
- switch (pos) {
- case bootombarAndItemMenu:
- case bottombar:
- switch (position) {
- case content:
- return ws.getEntityWorkspace().getContentBottomBar();
- case context:
- default:
- return ws.getEntityWorkspace().getContextBottomBar();
- }
- case topbar:
- case topbarAndItemMenu:
- default:
- switch (position) {
- case content:
- return ws.getEntityWorkspace().getContentTopBar();
- case context:
- default:
- return ws.getEntityWorkspace().getContextTopBar();
- }
- }
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbarView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbarView.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/component/EntityToolbarView.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,19 +0,0 @@
-package org.ourproject.kune.workspace.client.component;
-
-import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
-import org.ourproject.kune.platf.client.dto.StateToken;
-
-public interface EntityToolbarView {
-
- void addButtonAction(ActionButtonDescriptor<StateToken> action);
-
- void addMenuAction(ActionMenuDescriptor<StateToken> action, boolean enable);
-
- void clear();
-
- void clearRemovableActions();
-
- void disableAllMenuItems();
-
-}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigator.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -21,28 +21,17 @@
package org.ourproject.kune.workspace.client.ctxnav;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
import org.ourproject.kune.platf.client.dto.StateDTO;
import org.ourproject.kune.platf.client.dto.StateToken;
public interface ContextNavigator {
- void addAction(String contentTypeId, ActionDescriptor<StateToken> action);
-
void editItem(StateToken stateToken);
View getView();
boolean isSelected(StateToken stateToken);
- void registerContentTypeIcon(String contentTypeId, String iconUrl);
-
- void registerDraggableType(String typeId);
-
- void registerDroppableType(String typeId);
-
- void removeAction(String contentTypeId, ActionDescriptor<StateToken> action);
-
void selectItem(StateToken stateToken);
void setEditOnNextStateChange(boolean edit);
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -24,6 +24,7 @@
import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionManager;
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.services.I18nTranslationService;
import org.ourproject.kune.workspace.client.site.Site;
@@ -57,13 +58,15 @@
private final HashMap<String, Menu> contextMenus;
private final WorkspaceSkeleton ws;
private boolean fireOnTextChange;
+ private boolean isEditable;
+ private final ActionManager actionManager;
private final ContextNavigatorPresenter presenter;
- private boolean isEditable;
public ContextNavigatorPanel(final ContextNavigatorPresenter presenter, final I18nTranslationService i18n,
- final WorkspaceSkeleton ws) {
+ final WorkspaceSkeleton ws, final ActionManager actionManager) {
this.presenter = presenter;
this.ws = ws;
+ this.actionManager = actionManager;
contextMenus = new HashMap<String, Menu>();
fireOnTextChange = true;
@@ -279,7 +282,7 @@
}
private void doAction(final ActionDescriptor<StateToken> action, final StateToken stateToken) {
- presenter.doAction(action, stateToken);
+ actionManager.doAction(action, stateToken);
}
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-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -20,17 +20,15 @@
package org.ourproject.kune.workspace.client.ctxnav;
-import java.util.ArrayList;
import java.util.HashMap;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ActionCollection;
import org.ourproject.kune.platf.client.actions.ActionCollectionSet;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
-import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.actions.ActionMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionRegistry;
+import org.ourproject.kune.platf.client.actions.ContentIconsRegistry;
+import org.ourproject.kune.platf.client.actions.DragDropContentRegistry;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
import org.ourproject.kune.platf.client.dto.AccessRightsDTO;
import org.ourproject.kune.platf.client.dto.ContainerDTO;
import org.ourproject.kune.platf.client.dto.ContainerSimpleDTO;
@@ -58,48 +56,32 @@
private final Session session;
private final Provider<ContentServiceAsync> contentServiceProvider;
private final I18nUITranslationService i18n;
- private final HashMap<String, ActionCollection<StateToken>> actions;
private final HashMap<StateToken, ActionCollection<StateToken>> actionsByItem;
- private final ArrayList<String> draggables;
- private final ArrayList<String> droppables;
- private final HashMap<String, String> contentTypesIcons;
private final EntityTitle entityTitle;
- private final Provider<ActionManager> actionManagerProvider;
private boolean editOnNextStateChange;
- private final ContextNavigatorToolbar toolbar;
+ private final ContentIconsRegistry contentIconsRegistry;
+ private final DragDropContentRegistry dragDropContentRegistry;
+ private final ActionRegistry actionRegistry;
+ private final ActionToolbar toolbar;
public ContextNavigatorPresenter(final StateManager stateManager, final Session session,
final Provider<ContentServiceAsync> contentServiceProvider, final I18nUITranslationService i18n,
- final EntityTitle entityTitle, final Provider<ActionManager> actionManagerProvider,
- final ContextNavigatorToolbar contextNavigatorToolbar) {
+ final EntityTitle entityTitle, final ContentIconsRegistry contentIconsRegistry,
+ final DragDropContentRegistry dragDropContentRegistry, final ActionRegistry actionRegistry,
+ final ActionToolbar toolbar) {
this.stateManager = stateManager;
this.session = session;
this.contentServiceProvider = contentServiceProvider;
this.i18n = i18n;
this.entityTitle = entityTitle;
- this.actionManagerProvider = actionManagerProvider;
- this.toolbar = contextNavigatorToolbar;
- actions = new HashMap<String, ActionCollection<StateToken>>();
+ this.contentIconsRegistry = contentIconsRegistry;
+ this.dragDropContentRegistry = dragDropContentRegistry;
+ this.actionRegistry = actionRegistry;
+ this.toolbar = toolbar;
actionsByItem = new HashMap<StateToken, ActionCollection<StateToken>>();
- draggables = new ArrayList<String>();
- droppables = new ArrayList<String>();
- contentTypesIcons = new HashMap<String, String>();
editOnNextStateChange = false;
}
- public void addAction(final String contentTypeId, final ActionDescriptor<StateToken> action) {
- ActionCollection<StateToken> actionColl = actions.get(contentTypeId);
- if (actionColl == null) {
- actionColl = new ActionCollection<StateToken>();
- actions.put(contentTypeId, actionColl);
- }
- actionColl.add(action);
- }
-
- public void doAction(final ActionDescriptor<StateToken> action, final StateToken stateToken) {
- actionManagerProvider.get().doAction(action, stateToken);
- }
-
public void editItem(final StateToken stateToken) {
view.editItem(genId(stateToken));
}
@@ -167,27 +149,10 @@
}
}
- public void registerContentTypeIcon(final String contentTypeId, final String iconUrl) {
- contentTypesIcons.put(contentTypeId, iconUrl);
- }
-
- public void registerDraggableType(final String type) {
- draggables.add(type);
- }
-
- public void registerDroppableType(final String type) {
- droppables.add(type);
- }
-
- public void removeAction(final String contentTypeId, final ActionDescriptor<StateToken> action) {
- actions.get(contentTypeId).remove(action);
- }
-
public void selectItem(final StateToken stateToken) {
view.selectItem(genId(stateToken));
- toolbar.clearRemovableActions();
- toolbar.disableAllMenuItems();
- setActions(actionsByItem.get(stateToken), true);
+ toolbar.disableMenusAndClearButtons();
+ toolbar.setActions(actionsByItem.get(stateToken), true);
}
public void setEditOnNextStateChange(final boolean edit) {
@@ -215,10 +180,11 @@
// childs to view)
final ContainerDTO root = state.getRootContainer();
if (root != null) {
- final ActionCollectionSet<StateToken> set = createItemActions(containerRights, root.getTypeId());
+ final ActionCollectionSet<StateToken> set = actionRegistry.selectCurrentActions(containerRights, root
+ .getTypeId());
view.setRootItem(genId(root.getStateToken()), i18n.t(root.getName()), root.getStateToken(), set
.getItemActions());
- setActions(set.getToolbarActions(), false);
+ toolbar.setActions(set.getToolbarActions(), false);
createChildItems(root, containerRights);
actionsByItem.put(root.getStateToken(), set.getToolbarActions());
}
@@ -252,33 +218,27 @@
}
}
+ protected void clear() {
+ toolbar.clear();
+ view.clear();
+ actionsByItem.clear();
+ }
+
private void addItem(final String title, final String contentTypeId, final ContentStatusDTO status,
final StateToken stateToken, final StateToken parentStateToken, final AccessRightsDTO rights,
final boolean isNodeSelected) {
- final ActionCollectionSet<StateToken> set = createItemActions(rights, contentTypeId);
- setActions(set.getToolbarActions(), isNodeSelected);
+ final ActionCollectionSet<StateToken> set = actionRegistry.selectCurrentActions(rights, contentTypeId);
+ toolbar.setActions(set.getToolbarActions(), isNodeSelected);
final ContextNavigatorItem item = new ContextNavigatorItem(genId(stateToken), genId(parentStateToken),
- getContentTypeIcon(contentTypeId), title, status, stateToken, isDraggable(contentTypeId, rights
- .isAdministrable()), isDroppable(contentTypeId, rights.isAdministrable()), set.getItemActions());
+ contentIconsRegistry.getContentTypeIcon(contentTypeId), title, status, stateToken,
+ dragDropContentRegistry.isDraggable(contentTypeId, rights.isAdministrable()), dragDropContentRegistry
+ .isDroppable(contentTypeId, rights.isAdministrable()), set.getItemActions());
view.addItem(item);
actionsByItem.put(stateToken, set.getToolbarActions());
}
- private boolean checkEnabling(final boolean isNodeSelected, final ActionDescriptor<StateToken> action) {
- final ActionEnableCondition<StateToken> enableCondition = action.getEnableCondition();
- final boolean mustBeEnabled = enableCondition != null ? enableCondition.mustBeEnabled(getCurrentStateToken())
- : true;
- return isNodeSelected && mustBeEnabled;
- }
-
- private void clear() {
- view.clear();
- actionsByItem.clear();
- toolbar.clear();
- }
-
private void createChildItems(final ContainerDTO container, final AccessRightsDTO containerRights) {
for (final ContentDTO content : container.getContents()) {
addItem(content.getTitle(), content.getTypeId(), content.getStatus(), content.getStateToken(), content
@@ -292,43 +252,6 @@
}
}
- private ActionCollectionSet<StateToken> createItemActions(final AccessRightsDTO rights, final String contentTypeId) {
- final ActionCollectionSet<StateToken> set = new ActionCollectionSet<StateToken>();
- boolean add = false;
-
- for (final ActionDescriptor<StateToken> action : actions.get(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;
- }
- }
- }
- return set;
- }
-
private void createTreePath(final StateToken state, final ContainerSimpleDTO[] absolutePath,
final AccessRightsDTO rights) {
for (int i = 0; i < absolutePath.length; i++) {
@@ -349,28 +272,4 @@
return "k-" + token.toString().replace(StateToken.SEPARATOR, "-");
}
- private String getContentTypeIcon(final String typeId) {
- final String icon = contentTypesIcons.get(typeId);
- return icon == null ? "" : icon;
- }
-
- private boolean isDraggable(final String typeId, final boolean administrable) {
- return administrable && draggables.contains(typeId);
- }
-
- private boolean isDroppable(final String typeId, final boolean administrable) {
- return administrable && droppables.contains(typeId);
- }
-
- private void setActions(final ActionCollection<StateToken> actions, final boolean isNodeSelected) {
- for (final ActionDescriptor<StateToken> action : actions) {
- if (action instanceof ActionMenuDescriptor) {
- toolbar.addMenuAction((ActionMenuDescriptor<StateToken>) action, checkEnabling(isNodeSelected, action));
- } else {
- if (checkEnabling(isNodeSelected, action)) {
- toolbar.addButtonAction((ActionButtonDescriptor<StateToken>) action);
- }
- }
- }
- }
}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorToolbar.java 2008-09-18 02:06:07 UTC (rev 873)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorToolbar.java 2008-09-18 15:37:09 UTC (rev 874)
@@ -1,15 +0,0 @@
-package org.ourproject.kune.workspace.client.ctxnav;
-
-import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.workspace.client.component.EntityToolbar;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.calclab.suco.client.provider.Provider;
-
-public class ContextNavigatorToolbar extends EntityToolbar {
- public ContextNavigatorToolbar(final Session session, final Provider<ActionManager> actionManagerProvider,
- final WorkspaceSkeleton ws) {
- super(ToolbarPosition.context, session, actionManagerProvider, ws);
- }
-}
More information about the kune-commits
mailing list