r1064 - in trunk/src: main/java/org/ourproject/kune/app/public/css main/java/org/ourproject/kune/blogs/client main/java/org/ourproject/kune/chat/client main/java/org/ourproject/kune/docs/client main/java/org/ourproject/kune/gallery/client main/java/org/ourproject/kune/platf main/java/org/ourproject/kune/platf/client/actions main/java/org/ourproject/kune/platf/client/actions/toolbar main/java/org/ourproject/kune/platf/client/i18n main/java/org/ourproject/kune/platf/client/services main/java/or
Author: vjrj Date: 2009-03-10 01:05:50 +0100 (Tue, 10 Mar 2009) New Revision: 1064 Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java trunk/src/main/java/org/ourproject/kune/platf/client/i18n/Resources.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextBottomToolbar.java trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextTopToolBar.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java Removed: trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbar.java trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java 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/gallery/client/GalleryClientActions.java trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarPosition.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/i18n/I18nTranslationService.java trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/SimpleToolbar.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java trunk/src/main/java/org/ourproject/kune/workspace/Kune-Workspace.gwt.xml trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java trunk/src/main/java/org/ourproject/kune/workspace/client/skel/ActionCntCtxToolbarPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummary.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/ParticipationSummaryPanel.java trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java Log: Incomplete - task Better RTE (Rich Text Editor) support Incomplete - task ContextNav refactoring (less bussiness logic in view) and tests Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-03-10 00:05:50 UTC (rev 1064) @@ -41,4 +41,4 @@ padding: 1px 0px 1px 1px; text-decoration:none; } -*/.x-tree-node .k-ctn-status-normal a span{}.x-tree-node .k-ctn-status-deleted a span{text-decoration:line-through;color:gray;}.x-tree-node .k-ctn-status-rejected a span{text-decoration:line-through;/* color: #FF6633; */color:#F30;}.x-tree-node .k-ctn-status-editing a span{font-style:italic;color:gray;}.x-tree-node .k-ctn-status-submitted a span{color:green;}.k-info-links{text-decoration:underline;color:gray;cursor:pointer;}.x-tool-kmenu{background-position:0 -75px;}.x-tool-kmenu-over{background-position:-15px -75px;}.k-border-openbox{border-bottom:1px #D0D0D0 solid;border-right:1px #D0D0D0 solid;border-left:1px #D0D0D0 solid;}/* SiteToastMessages */.k-stm-info-icon{background-image:url(img/info.gif)!important;}.k-stm-imp-icon{background-image:url(img/alert.gif)!important;}.k-stm-verimp-icon{background-image:url(img/important.gif)!important;}.k-stm-error-icon{background-image:url(img/error.gif)!important;}.k-error-tb{background:#FFB380 none repeat scroll 0 50%;color:#250;}.k-infod-head{font-size:108%;margin-bottom:10px;}.gwt-DisclosurePanel{}.gwt-DisclosurePanel-open{}.gwt-DisclosurePanel-closed{}.gwt-DisclosurePanel .header,.gwt-DisclosurePanel .header a,.gwt-DisclosurePanel .header td{text-decoration:none;/* Remove underline from header */color:#000;cursor:pointer;cursor:hand;}.gwt-DisclosurePanel .content{border-left:3px solid #e8eef7;padding:4px 0 4px 8px;margin-left:6px;}.k-basic-thumb{background:#FAFAFA none repeat scroll 0 50%;border:1px solid #EBEBEB;padding:3px;margin:3px;}.k-basic-thumb td{padding:2px 3px;border:none;}.k-text-gray{color:gray;}.k-elp-limg{margin-top:4px;margin-left:5px;cursor:pointer;overflow:hidden;}.k-tsp-tag{float:right;margin-right:5px;cursor:pointer;color:#00F;}.k-tsp-cloud{vertical-align:bottom;}.k-link-icon{background-image:url(img/link.gif)!important;}.k-options-icon{background-image:url(img/emblem-system.gif)!important;}.k-copyleft-icon{background-image:url(img/copyleft.png)!important;}.k-picture-icon{background-image:url(img/picture.png)!important;}.k-info-icon{background-image:url(img/info.gif)!important;}.k-newgroup-icon{background-image:url(img/kune-icon16.png)!important;}.k-colors-icon{background-image:url(img/colors.gif)!important;}.x-toolbar-body table{/* width: 100%; */}.k-preview-msg{background:#FCA;}.k-preview-msg-lab{background:#FCA;padding:0 5px;}.k-eil-edit{border:thin solid #000;} \ No newline at end of file +*/.x-tree-node .k-ctn-status-normal a span{}.x-tree-node .k-ctn-status-deleted a span{text-decoration:line-through;color:gray;}.x-tree-node .k-ctn-status-rejected a span{text-decoration:line-through;/* color: #FF6633; */color:#F30;}.x-tree-node .k-ctn-status-editing a span{font-style:italic;color:gray;}.x-tree-node .k-ctn-status-submitted a span{color:green;}.k-info-links{text-decoration:underline;color:gray;cursor:pointer;}.x-tool-kmenu{background-position:0 -75px;}.x-tool-kmenu-over{background-position:-15px -75px;}.k-border-openbox{border-bottom:1px #D0D0D0 solid;border-right:1px #D0D0D0 solid;border-left:1px #D0D0D0 solid;}/* SiteToastMessages */.k-stm-info-icon{background-image:url(img/info.gif)!important;}.k-stm-imp-icon{background-image:url(img/alert.gif)!important;}.k-stm-verimp-icon{background-image:url(img/important.gif)!important;}.k-stm-error-icon{background-image:url(img/error.gif)!important;}.k-error-tb{background:#FFB380 none repeat scroll 0 50%;color:#250;}.k-infod-head{font-size:108%;margin-bottom:10px;}.gwt-DisclosurePanel{}.gwt-DisclosurePanel-open{}.gwt-DisclosurePanel-closed{}.gwt-DisclosurePanel .header,.gwt-DisclosurePanel .header a,.gwt-DisclosurePanel .header td{text-decoration:none;/* Remove underline from header */color:#000;cursor:pointer;cursor:hand;}.gwt-DisclosurePanel .content{border-left:3px solid #e8eef7;padding:4px 0 4px 8px;margin-left:6px;}.k-basic-thumb{background:#FAFAFA none repeat scroll 0 50%;border:1px solid #EBEBEB;padding:3px;margin:3px;}.k-basic-thumb td{padding:2px 3px;border:none;}.k-text-gray{color:gray;}.k-elp-limg{margin-top:4px;margin-left:5px;cursor:pointer;overflow:hidden;}.k-tsp-tag{float:right;margin-right:5px;cursor:pointer;color:#00F;}.k-tsp-cloud{vertical-align:bottom;}.k-link-icon{background-image:url(img/link.gif)!important;}.k-options-icon{background-image:url(img/emblem-system.gif)!important;}.k-copyleft-icon{background-image:url(img/copyleft.png)!important;}.k-picture-icon{background-image:url(img/picture.png)!important;}.k-info-icon{background-image:url(img/info.gif)!important;}.k-newgroup-icon{background-image:url(img/kune-icon16.png)!important;}.k-colors-icon{background-image:url(img/colors.gif)!important;}.x-toolbar-body table{/* width: 100%; */}.k-preview-msg{background:#FCA;}.k-preview-msg-lab{background:#FCA;padding:0 5px;}.k-eil-edit{border:thin solid #000;}/* duplicated in rte.css */.k-rte-comment{border:1px dashed silver;line-height:1.4;padding:3px;background-color:#D7FFD7;} \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css =================================================================== --- trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2009-03-10 00:05:50 UTC (rev 1064) @@ -872,3 +872,11 @@ .k-eil-edit { border: thin solid black; } + +/* duplicated in rte.css */ +.k-rte-comment { + border:1px dashed #C0C0C0; + line-height:1.4; + padding:3px; + background-color:#D7FFD7; +} \ No newline at end of file Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -38,7 +38,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -53,7 +53,7 @@ final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry, final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo, - final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler, + final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler, final BlogViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider, final SitePublicSpaceLink publicLink) { super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider, Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -45,7 +45,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -78,7 +78,7 @@ $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class), $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class), - $(EntityHeader.class), $$(TextEditor.class), $(KuneErrorHandler.class), $(BlogViewer.class), + $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), $(BlogViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class)); } }); Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -26,13 +26,13 @@ import org.ourproject.kune.platf.client.actions.ActionEnableCondition; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.dto.AccessRolDTO; import org.ourproject.kune.platf.client.dto.ContentStatusDTO; import org.ourproject.kune.platf.client.dto.StateToken; import org.ourproject.kune.platf.client.i18n.I18nUITranslationService; import org.ourproject.kune.platf.client.state.Session; import org.ourproject.kune.wiki.client.WikiClientTool; +import org.ourproject.kune.workspace.client.AbstractFoldableContentActions; import org.ourproject.kune.workspace.client.cnt.ContentActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; @@ -62,7 +62,7 @@ private void createActions() { final ActionToolbarButtonDescriptor<StateToken> chatAbout = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, AbstractFoldableContentActions.CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { chatEngineProvider.get().joinRoom(token.toString().replaceAll("\\.", "-"), session.getCurrentUserInfo().getShortName()); @@ -76,7 +76,7 @@ chatAbout.setEnableCondition(notDeleted()); ActionToolbarButtonDescriptor<StateToken> joinRoom = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, AbstractFoldableContentActions.CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(StateToken token) { ChatEngine chatEngine = chatEngineProvider.get(); chatEngine.joinRoom(session.getContainerState().getContainer().getName(), @@ -89,7 +89,7 @@ joinRoom.setMustBeAuthenticated(true); ActionToolbarButtonDescriptor<StateToken> addRoom = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Administrator, AbstractFoldableContentActions.CONTEXT_TOPBAR, new Listener<StateToken>() { public void onEvent(StateToken token) { addRoomProvider.get().show(); } Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -38,7 +38,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -53,7 +53,7 @@ final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry, final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo, - final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler, + final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler, final DocumentViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider, final SitePublicSpaceLink publicLink) { super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider, Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -45,7 +45,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -78,7 +78,7 @@ $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class), $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class), - $(EntityHeader.class), $$(TextEditor.class), $(KuneErrorHandler.class), + $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), $(DocumentViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class)); } }); Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -37,7 +37,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -52,7 +52,7 @@ final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry, final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo, - final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler, + final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler, final GalleryViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider, final SitePublicSpaceLink publicLink) { super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider, Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -45,7 +45,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -78,8 +78,8 @@ $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class), $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class), - $(EntityHeader.class), $$(TextEditor.class), $(KuneErrorHandler.class), $(GalleryViewer.class), - $$(ContextPropEditor.class), $(SitePublicSpaceLink.class)); + $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), + $(GalleryViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class)); } }); Modified: trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-10 00:05:50 UTC (rev 1064) @@ -11,4 +11,48 @@ <public path="public" /> + <inherits name="com.google.gwt.user.UserAgent" /> + <!-- RTE css inject --> + <!-- See gwt-user: com/google/gwt/user/RichText.gwt.xml --> + + <!-- IE-specific implementation --> + <replace-with + class="org.ourproject.kune.platf.client.ui.rte.WrappedRichTextAreaImplIE6"> + <when-type-is + class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> + <when-property-is name="user.agent" value="ie6" /> + </replace-with> + + <!-- Mozilla-specific implementation --> + <replace-with + class="org.ourproject.kune.platf.client.ui.rte.WrappedRichTextAreaImplMozilla"> + <when-type-is + class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> + <any> + <when-property-is name="user.agent" value="gecko1_8" /> + <when-property-is name="user.agent" value="gecko" /> + </any> + </replace-with> + + <!-- Safari-specific implementation --> + <replace-with + class="org.ourproject.kune.platf.client.ui.rte.WrappedRichTextAreaImplSafari"> + <when-type-is + class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> + <any> + <when-property-is name="user.agent" value="safari" /> + </any> + </replace-with> + + <!-- Opera-specific implementation --> + <replace-with + class="org.ourproject.kune.platf.client.ui.rte.WrappedRichTextAreaImplOpera"> + <when-type-is + class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> + <any> + <when-property-is name="user.agent" value="opera" /> + </any> + </replace-with> + + </module> Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -20,7 +20,6 @@ package org.ourproject.kune.platf.client.actions; import org.ourproject.kune.platf.client.dto.AccessRolDTO; -import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.services.ImageDescriptor; import com.calclab.suco.client.events.Listener; @@ -31,6 +30,8 @@ */ public abstract class ActionDescriptor<T> { + public static final int NO_POSITION = -1; + /** The icon url. */ private String iconUrl; @@ -78,6 +79,8 @@ private ActionShortcut shortcut; + private int position = NO_POSITION; + public ActionDescriptor(final AccessRolDTO accessRolDTO, final Listener<T> onPerformCall) { this.accessRol = accessRolDTO; this.onPerformCall = onPerformCall; @@ -219,12 +222,21 @@ return id; } + /** + * Get the index position where this action will be inserted + * + * @param position + */ + public int getPosition() { + return position; + } + public ActionShortcut getShortcut() { return shortcut; } - public String getShortcutToS(I18nTranslationService i18n) { - return shortcut == null ? "" : shortcut.toString(i18n); + public String getShortcutToS() { + return shortcut == null ? "" : shortcut.toString(); } /** @@ -379,6 +391,15 @@ this.mustBeConfirmed = mustBeConfirmed; } + /** + * Index position where this action will be inserted + * + * @param position + */ + public void setPosition(int position) { + this.position = position; + } + public void setShortcut(ActionShortcut shortcut) { this.shortcut = shortcut; } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItem.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -19,6 +19,8 @@ \*/ package org.ourproject.kune.platf.client.actions; +import com.allen_sauer.gwt.log.client.Log; + /** * And action description and a item (for instance a StateToken, a XmmpURI) over * the action takes place @@ -50,4 +52,14 @@ public boolean mustBeEnabled() { return action.mustBeEnabled(getItem()); } + + public boolean mustBePressed() { + if (!(action instanceof ActionToolbarPushButtonDescriptor)) { + Log.error("This action is not a push button"); + return false; + } else { + ActionPressedCondition<T> mustInitialyPressed = ((ActionToolbarPushButtonDescriptor<T>) action).getMustInitialyPressed(); + return mustInitialyPressed != null ? mustInitialyPressed.mustBePressed(getItem()) : false; + } + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionItemCollection.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -20,9 +20,37 @@ package org.ourproject.kune.platf.client.actions; import java.util.ArrayList; +import java.util.Collection; +import com.allen_sauer.gwt.log.client.Log; + public class ActionItemCollection<T> extends ArrayList<ActionItem<T>> { private static final long serialVersionUID = 1L; + @Override + public boolean add(ActionItem<T> actionItem) { + ActionDescriptor<T> action = actionItem.getAction(); + int position = action.getPosition(); + if (position == ActionDescriptor.NO_POSITION) { + super.add(actionItem); + } else { + try { + super.add(position, actionItem); + return true; + } catch (IndexOutOfBoundsException e) { + Log.error("Trying to add an action in a position out of bounds"); + super.add(actionItem); + } + } + return false; + } + + @Override + public boolean addAll(Collection<? extends ActionItem<T>> actionItems) { + for (ActionItem<T> actionItem : actionItems) { + add(actionItem); + } + return true; + } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,6 +1,6 @@ package org.ourproject.kune.platf.client.actions; -import org.ourproject.kune.platf.client.i18n.I18nTranslationService; +import org.ourproject.kune.platf.client.i18n.Resources; import com.google.gwt.user.client.ui.KeyboardListener; @@ -98,21 +98,22 @@ return (has(modifiers, modifier) == keyValue); } - public String toString(I18nTranslationService i18n) { + @Override + public String toString() { String s = " ("; - s += sKey(alt, "Alt", i18n); - s += sKey(ctrl, "Ctrl", i18n); - s += sKey(shift, "Shift", i18n); - s += keyName != null ? translateKey(keyName, i18n) + ")" : String.valueOf(key).toUpperCase() + ")"; + s += sKey(alt, "Alt"); + s += sKey(ctrl, "Ctrl"); + s += sKey(shift, "Shift"); + s += keyName != null ? translateKey(keyName) + ")" : String.valueOf(key).toUpperCase() + ")"; return s; } - private String sKey(boolean key, String specialKeyName, I18nTranslationService i18n) { - return key ? translateKey(specialKeyName, i18n) + "+" : ""; + private String sKey(boolean key, String specialKeyName) { + return key ? translateKey(specialKeyName) + "+" : ""; } - private String translateKey(String keyNameToTranslate, I18nTranslationService i18n) { - return i18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key"); + private String translateKey(String keyNameToTranslate) { + return Resources.i18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key"); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarDescriptor.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -26,11 +26,8 @@ public abstract class ActionToolbarDescriptor<T> extends ActionDescriptor<T> { - public static final int NO_POSITION = -1; private ActionToolbarPosition actionToolbarPosition; - private int position = NO_POSITION; - public ActionToolbarDescriptor(final AccessRolDTO accessRolDTO, final ActionToolbarPosition actionToolbarPosition, final Listener<T> onPerformCall) { super(accessRolDTO, onPerformCall); @@ -71,26 +68,8 @@ return actionToolbarPosition; } - /** - * Get the index position where this action will be inserted - * - * @param position - */ - public int getPosition() { - return position; - } - public void setActionPosition(final ActionToolbarPosition actionToolbarPosition) { this.actionToolbarPosition = actionToolbarPosition; } - /** - * Index position where this action will be inserted - * - * @param position - */ - public void setPosition(int position) { - this.position = position; - } - } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarPosition.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarPosition.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionToolbarPosition.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,24 +1,41 @@ -/* - * - * Copyright (C) 2007-2009 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.platf.client.actions; -public enum ActionToolbarPosition { - topbar, bottombar +public class ActionToolbarPosition { + + private final String id; + + public ActionToolbarPosition(String id) { + this.id = id; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + ActionToolbarPosition other = (ActionToolbarPosition) obj; + if (id == null) { + if (other.id != null) { + return false; + } + } else if (!id.equals(other.id)) { + return false; + } + return true; + } + + public String getId() { + return id; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((id == null) ? 0 : id.hashCode()); + return result; + } } 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbar.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -22,11 +22,14 @@ import org.ourproject.kune.platf.client.actions.ActionDescriptor; import org.ourproject.kune.platf.client.actions.ActionItemCollection; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; public interface ActionToolbar<T> { - void addActions(ActionItemCollection<T> actionItemCollection); + ActionToolbarPosition IN_ANY = new ActionToolbarPosition("in-all"); + void addActions(ActionItemCollection<T> actionItemCollection, ActionToolbarPosition actionToolbarPosition); + void attach(); void clear(); @@ -45,6 +48,10 @@ void setButtonEnable(ActionDescriptor<T> action, boolean enable); + void setCleanStyle(); + + void setNormalStyle(); + void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle); void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed); Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,55 @@ +package org.ourproject.kune.platf.client.actions.toolbar; + +import org.ourproject.kune.platf.client.actions.ActionShortcut; +import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor; + +import com.calclab.suco.client.events.Listener0; +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 ActionToolbarButton<T> extends ToolbarButton { + + public ActionToolbarButton(ActionToolbarDescriptor<T> action, final String id, boolean enabled, + boolean isPushButton, boolean pressed, final Listener0 onclick) { + final String text = action.getText(); + final String iconUrl = action.getIconUrl(); + final String iconCls = action.getIconCls(); + if (text != null) { + super.setText(text); + } + if (isPushButton) { + super.setEnableToggle(true); + super.setPressed(pressed); + } + super.addListener(new ButtonListenerAdapter() { + @Override + public void onClick(final Button button, final EventObject e) { + e.stopEvent(); + onclick.onEvent(); + } + }); + if (iconUrl != null) { + super.setIcon(iconUrl); + } + if (iconCls != null) { + super.setIconCls(iconCls); + } + String toolTip = action.getToolTip(); + ActionShortcut shortcut = action.getShortcut(); + super.setTooltip((toolTip == null ? "" : toolTip) + (shortcut != null ? shortcut.toString() : "")); + setEnableButton(enabled); + // Waring: If you put set Id above click listener fires twice + super.setId(id); + } + + private void setEnableButton(final boolean enabled) { + if (enabled) { + super.enable(); + } else { + super.disable(); + } + } + +} 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -24,27 +24,21 @@ import org.ourproject.kune.platf.client.actions.ActionDescriptor; import org.ourproject.kune.platf.client.actions.ActionItem; import org.ourproject.kune.platf.client.actions.ActionManager; -import org.ourproject.kune.platf.client.actions.ActionPressedCondition; -import org.ourproject.kune.platf.client.actions.ActionShortcut; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; -import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuCheckItemDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; -import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor; -import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.ui.SimpleToolbar; import com.allen_sauer.gwt.log.client.Log; +import com.calclab.suco.client.events.Listener0; import com.calclab.suco.client.ioc.Provider; import com.google.gwt.user.client.ui.Widget; import com.gwtext.client.core.EventObject; import com.gwtext.client.core.Ext; -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.CheckItem; import com.gwtext.client.widgets.menu.Item; @@ -54,76 +48,41 @@ public class ActionToolbarPanel<T> implements ActionToolbarView<T> { - private final HashMap<String, Menu> toolbarMenus; - private final HashMap<String, ToolbarButton> toolbarButtons; + private final HashMap<String, Menu> menus; private final HashMap<String, Item> menuItems; + private final HashMap<String, ToolbarButton> buttons; private final Provider<ActionManager> actionManagerProvider; - protected final SimpleToolbar topbar; - protected final SimpleToolbar bottombar; - private final I18nTranslationService i18n; + protected final SimpleToolbar toolbar; - public ActionToolbarPanel(final Provider<ActionManager> actionManagerProvider, I18nTranslationService i18n) { - this.i18n = i18n; - topbar = new SimpleToolbar(); - bottombar = new SimpleToolbar(); - topbar.setWidth("100%"); - bottombar.setWidth("100%"); + public ActionToolbarPanel(final Provider<ActionManager> actionManagerProvider) { + toolbar = new SimpleToolbar(); + toolbar.setWidth("100%"); this.actionManagerProvider = actionManagerProvider; - toolbarMenus = new HashMap<String, Menu>(); - toolbarButtons = new HashMap<String, ToolbarButton>(); + menus = new HashMap<String, Menu>(); menuItems = new HashMap<String, Item>(); + buttons = new HashMap<String, ToolbarButton>(); } - public void addButtonAction(final ActionItem<T> actionItem, final boolean enable) { - final ToolbarButton button = new ToolbarButton(); + public ActionToolbarButton<T> addButtonAction(final ActionItem<T> actionItem, final boolean enable, + final boolean isPushButton, final boolean pressed) { final ActionToolbarButtonDescriptor<T> action = (ActionToolbarButtonDescriptor<T>) actionItem.getAction(); - T item = actionItem.getItem(); - final ActionToolbarPosition pos = action.getActionPosition(); - final String text = action.getText(); - final String iconUrl = action.getIconUrl(); - final String iconCls = action.getIconCls(); - if (text != null) { - button.setText(text); - } - String id = generateIdIfEmpty(action); - button.setId(id); - if (action instanceof ActionToolbarPushButtonDescriptor) { - button.setEnableToggle(true); - ActionPressedCondition<T> mustInitialyPressed = ((ActionToolbarPushButtonDescriptor<T>) action).getMustInitialyPressed(); - button.setPressed(mustInitialyPressed != null && mustInitialyPressed.mustBePressed(item)); - } - button.addListener(new ButtonListenerAdapter() { - @Override - public void onClick(final Button button, final EventObject e) { - actionManagerProvider.get().doAction(actionItem); - } - }); - if (iconUrl != null) { - button.setIcon(iconUrl); - } - if (iconCls != null) { - button.setIconCls(iconCls); - } - String toolTip = action.getToolTip(); - ActionShortcut shortcut = action.getShortcut(); - button.setTooltip((toolTip == null ? "" : toolTip) + (shortcut != null ? shortcut.toString(i18n) : "")); - - setEnableButton(button, enable); - final SimpleToolbar toolbar = getToolbar(pos); + String id = generateId(action); + ActionToolbarButton<T> button = new ActionToolbarButton<T>(action, id, enable, isPushButton, pressed, + new Listener0() { + public void onEvent() { + actionManagerProvider.get().doAction(actionItem); + } + }); if (action.hasLeftSeparator()) { add(toolbar, action.getLeftSeparator()); } - int position = action.getPosition(); - if (position != ActionToolbarDescriptor.NO_POSITION) { - toolbar.insert(button, position); - } else { - toolbar.add(button); - } + toolbar.add(button); if (action.hasRightSeparator()) { add(toolbar, action.getRightSeparator()); } - toolbarButtons.put(genButtonKey(pos, id), button); + buttons.put(genButtonKey(id), button); + return button; } public void addMenuAction(final ActionItem<T> actionItem, final boolean enable) { @@ -135,7 +94,7 @@ final String itemKey = genMenuKey(pos, menuTitle, action.getParentMenuTooltip(), menuSubTitle, action.getText()); Item item = menuItems.get(itemKey); if (item == null) { - item = createToolbarMenu(pos, menuTitle, menuTooltip, menuSubTitle, actionItem, generateIdIfEmpty(action)); + item = createToolbarMenu(pos, menuTitle, menuTooltip, menuSubTitle, actionItem, generateId(action)); menuItems.put(itemKey, item); } setEnableMenuItem(item, enable); @@ -145,24 +104,15 @@ } public void clear() { - toolbarMenus.clear(); + menus.clear(); menuItems.clear(); - toolbarButtons.clear(); - topbar.removeAll(); - bottombar.removeAll(); - getToolbar(ActionToolbarPosition.topbar).removeAll(); - getToolbar(ActionToolbarPosition.bottombar).removeAll(); + buttons.clear(); + toolbar.removeAll(); } public void detach() { } - public void disableAllMenuItems() { - for (final Item item : menuItems.values()) { - item.disable(); - } - } - public int getLeftPosition(ActionDescriptor<T> action) { final ToolbarButton button = findButton(action); if (button != null) { @@ -171,14 +121,8 @@ return 0; } - public SimpleToolbar getToolbar(final ActionToolbarPosition pos) { - switch (pos) { - case bottombar: - return bottombar; - case topbar: - default: - return topbar; - } + public SimpleToolbar getToolbar() { + return toolbar; } public int getTopPosition(ActionDescriptor<T> action) { @@ -190,7 +134,7 @@ } public void hideAllMenus() { - for (Menu menu : toolbarMenus.values()) { + for (Menu menu : menus.values()) { menu.hide(true); } } @@ -204,10 +148,18 @@ } } + public void setCleanStyle() { + toolbar.setCleanStyle(); + } + + public void setNormalStyle() { + toolbar.setNormalStyle(); + } + public void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle) { final String menuKey = genMenuKey(action.getActionPosition(), origTitle, origTooltip, null, null); - Menu menu = toolbarMenus.get(menuKey); + Menu menu = menus.get(menuKey); if (menu != null) { menu.setTitle(newTitle); } else { @@ -217,18 +169,18 @@ public void setPushButtonPressed(final ActionDescriptor<T> action, final boolean pressed) { final ToolbarButton button = findButton(action); - if (button != null && button.isEnableToggle()) { - // Log.debug("Setting button pressed: " + pressed); - button.toggle(pressed); + if (button != null) { + if (button.isEnableToggle()) { + // Log.debug("Setting button pressed: " + pressed); + button.toggle(pressed); + } else { + Log.error("Tryng to set pressed a toolbar button not of type push button"); + } } else { Log.error("Tryng to set pressed a non existent toolbar push button"); } } - private void add(final ActionToolbarPosition toolbar, final Widget widget) { - getToolbar(toolbar).add(widget); - } - private Widget add(final SimpleToolbar toolbar, final ActionToolbarButtonSeparator separator) { switch (separator) { case fill: @@ -241,6 +193,10 @@ } } + private void add(final Widget widget) { + toolbar.add(widget); + } + private void addSeparator(Menu menu, boolean separator) { if (separator) { menu.addSeparator(); @@ -291,18 +247,18 @@ final String menuKey = genMenuKey(toolBarPos, menuTitle, menuTooltip, null, null); final String subMenuKey = genMenuKey(toolBarPos, menuTitle, menuTooltip, menuSubTitle, null); - Menu menu = toolbarMenus.get(menuKey); - Menu subMenu = toolbarMenus.get(subMenuKey); + Menu menu = menus.get(menuKey); + Menu subMenu = menus.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(), action.getParentMenuIconCls(), - menuTitle, menuKey, ""); + menuTitle, menuKey, "", action.getPosition()); } menu.addItem(subMenuItem); - toolbarMenus.put(subMenuKey, subMenu); + menus.put(subMenuKey, subMenu); } addSeparator(subMenu, action.hasTopSeparator()); subMenu.addItem(item); @@ -311,7 +267,7 @@ // Menu action without submenu if (menu == null) { menu = createToolbarMenu(toolBarPos, action.getParentMenuIconUrl(), action.getParentMenuIconCls(), - menuTitle, menuKey, action.getParentMenuTooltip()); + menuTitle, menuKey, action.getParentMenuTooltip(), action.getPosition()); } addSeparator(menu, action.hasTopSeparator()); menu.addItem(item); @@ -321,7 +277,7 @@ } private Menu createToolbarMenu(final ActionToolbarPosition barPosition, final String iconUrl, final String iconCls, - final String menuTitle, final String menuKey, final String menuTooltip) { + final String menuTitle, final String menuKey, final String menuTooltip, int position) { final Menu menu = new Menu(); menu.setShadow(true); final ToolbarButton toolbarMenu = new ToolbarButton(menuTitle); @@ -335,28 +291,24 @@ if (menuTooltip != null) { toolbarMenu.setTooltip(menuTooltip); } - toolbarMenus.put(menuKey, menu); - add(barPosition, toolbarMenu); + menus.put(menuKey, menu); + add(toolbarMenu); return menu; } private ToolbarButton findButton(final ActionDescriptor<T> action) { - final ActionToolbarPosition pos = ((ActionToolbarDescriptor<T>) action).getActionPosition(); - final ToolbarButton button = toolbarButtons.get(genButtonKey(pos, action.getId())); + final ToolbarButton button = buttons.get(genButtonKey(action.getId())); return button; } - private String genButtonKey(final ActionToolbarPosition pos, final String id) { - final String basePart = "km-act-btn-" + pos.toString().substring(0, 2) + "-" + id; + private String genButtonKey(final String id) { + final String basePart = "km-act-btn-" + id; return basePart; } - private String generateIdIfEmpty(final ActionDescriptor<T> action) { - String id = action.getId(); - if (id == null) { - id = Ext.generateId(); - action.setId(id); - } + private String generateId(final ActionDescriptor<T> action) { + String id = Ext.generateId(); + action.setId(id); return id; } @@ -365,9 +317,9 @@ // Label title = new Label(action.getText()); // hp.add(title); // hp.setCellWidth(title, "100%"); - // hp.add(new Label(action.getShortcutToS(i18n))); + // hp.add(new Label(action.getShortcutToS(i 18n))); // return hp.getElement().getInnerHTML(); - return action.getText() + action.getShortcutToS(i18n); + return action.getText() + action.getShortcutToS(); } private String genMenuKey(final ActionToolbarPosition pos, final String menuTitle, final String menuTooltip, 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -24,8 +24,11 @@ import org.ourproject.kune.platf.client.actions.ActionItemCollection; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonAndItemDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuAndItemDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; +import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor; import com.allen_sauer.gwt.log.client.Log; @@ -36,15 +39,24 @@ this.view = toolbar; } - public void addActions(final ActionItemCollection<T> actions) { + public void addActions(final ActionItemCollection<T> actions, ActionToolbarPosition position) { for (final ActionItem<T> actionItem : actions) { final ActionDescriptor<T> action = actionItem.getAction(); if (actionItem.mustBeAdded()) { if (isToolbarMenu(action)) { - view.addMenuAction(actionItem, actionItem.mustBeEnabled()); + if (addInPosition(action, position)) { + view.addMenuAction(actionItem, actionItem.mustBeEnabled()); + } } else { - if (isToolbarButton(action)) { - view.addButtonAction(actionItem, actionItem.mustBeEnabled()); + if (isToolbarPushButton(action)) { + if (addInPosition(action, position)) { + view.addButtonAction(actionItem, actionItem.mustBeEnabled(), true, + actionItem.mustBePressed()); + } + } else if (isToolbarButton(action)) { + if (addInPosition(action, position)) { + view.addButtonAction(actionItem, actionItem.mustBeEnabled(), false, false); + } } else { Log.error("Code error: Not an ActionMenuDescriptor or ActionButtonDescriptor: " + action.getText()); @@ -90,6 +102,14 @@ view.setButtonEnable(action, enable); } + public void setCleanStyle() { + view.setCleanStyle(); + } + + public void setNormalStyle() { + view.setNormalStyle(); + } + public void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle) { view.setParentMenuTitle(action, origTitle, origTooltip, newTitle); @@ -99,6 +119,13 @@ view.setPushButtonPressed(action, pressed); } + private boolean addInPosition(ActionDescriptor<T> action, ActionToolbarPosition position) { + if (position.equals(IN_ANY) || ((ActionToolbarDescriptor<T>) action).getActionPosition().equals(position)) { + return true; + } + return false; + } + private boolean isToolbarButton(final ActionDescriptor<T> action) { return action instanceof ActionToolbarButtonDescriptor || action instanceof ActionToolbarButtonAndItemDescriptor; @@ -107,4 +134,8 @@ private boolean isToolbarMenu(final ActionDescriptor<T> action) { return action instanceof ActionToolbarMenuDescriptor || action instanceof ActionToolbarMenuAndItemDescriptor; } + + private boolean isToolbarPushButton(ActionDescriptor<T> action) { + return action instanceof ActionToolbarPushButtonDescriptor; + } } 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarView.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -26,7 +26,8 @@ public interface ActionToolbarView<T> extends View { - void addButtonAction(ActionItem<T> actionItem, boolean enable); + ActionToolbarButton<T> addButtonAction(ActionItem<T> actionItem, boolean enabled, boolean isPushButton, + boolean pressed); void addMenuAction(ActionItem<T> actionItem, boolean enable); @@ -36,8 +37,6 @@ void detach(); - void disableAllMenuItems(); - int getLeftPosition(ActionDescriptor<T> action); int getTopPosition(ActionDescriptor<T> action); @@ -46,6 +45,10 @@ void setButtonEnable(ActionDescriptor<T> action, boolean enable); + void setCleanStyle(); + + void setNormalStyle(); + void setParentMenuTitle(ActionToolbarMenuDescriptor<T> action, String origTitle, String origTooltip, String newTitle); void setPushButtonPressed(ActionDescriptor<T> action, boolean pressed); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nTranslationService.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nTranslationService.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/i18n/I18nTranslationService.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -19,7 +19,6 @@ */ package org.ourproject.kune.platf.client.i18n; -import java.util.Date; public abstract class I18nTranslationService { protected static final String TRANSLATION_NOTE_REGEXP = " (\\[)%NT (.*)(\\])$"; @@ -34,31 +33,6 @@ return text; } - public String formatDate(final String format, final Date date) { - // TODO: 18n dates - return null; - // cc = c.sub(/^%[EO]?(.)$/o, '%\\1') - // case cc - // when '%A'; o << "#{::Date::DAYNAMES[wday]} - // [weekday]".t(::Date::DAYNAMES[wday]) - // when '%a'; o << "#{::Date::ABBR_DAYNAMES[wday]} [abbreviated - // weekday]".t(::Date::ABBR_DAYNAMES[wday]) - // when '%B'; o << "#{::Date::MONTHNAMES[mon]} - // [month]".t(::Date::MONTHNAMES[mon]) - // when '%b'; o << "#{::Date::ABBR_MONTHNAMES[mon]} [abbreviated - // month]".t(::Date::ABBR_MONTHNAMES[mon]) - // when '%c'; o << ((Locale.active? && !Locale.active.date_format.nil?) - // ? - // localize(Locale.active.date_format) : strftime('%Y-%m-%d')) - // when '%p'; o << if hour < 12 then 'AM [Ante Meridiem]'.t("am") else - // 'PM [Post - // Meridiem]'.t("am") end - // when '%P'; o << if hour < 12 then 'AM [Ante Meridiem]'.t("AM") else - // 'PM [Post - // Meridiem]'.t("PM") end - // else; o << c - } - public String removeNT(final String string) { return string.replaceAll(TRANSLATION_NOTE_REGEXP, ""); } Added: trunk/src/main/java/org/ourproject/kune/platf/client/i18n/Resources.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/i18n/Resources.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/i18n/Resources.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,11 @@ +package org.ourproject.kune.platf.client.i18n; + +public class Resources { + + public static I18nTranslationService i18n; + + public Resources(I18nTranslationService i18n) { + Resources.i18n = i18n; + } + +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -124,7 +124,7 @@ if (showException) { Log.debug("Exception in KuneErrorHandler", e); } else { - Log.debug(e.getMessage()); + Log.debug("Exception in KuneErrorHandler: " + e.getMessage()); } } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -29,6 +29,7 @@ import org.ourproject.kune.platf.client.app.ToolGroup; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.i18n.I18nUITranslationService; +import org.ourproject.kune.platf.client.i18n.Resources; import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple; import org.ourproject.kune.platf.client.rpc.ContentServiceAsync; import org.ourproject.kune.platf.client.rpc.I18nService; @@ -51,6 +52,8 @@ import org.ourproject.kune.platf.client.ui.rte.RTEActionSndToolbarPresenter; import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbar; import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbarPresenter; +import org.ourproject.kune.platf.client.ui.rte.RTESavingEditor; +import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter; import org.ourproject.kune.platf.client.ui.rte.RTEditor; import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel; import org.ourproject.kune.platf.client.ui.rte.RTEditorPresenter; @@ -58,6 +61,7 @@ import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources; import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper; import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement; +import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink; import com.calclab.suco.client.events.Listener0; import com.calclab.suco.client.ioc.decorator.NoDecoration; @@ -155,6 +159,15 @@ container.removeProvider(I18nTranslationService.class); } + register(Singleton.class, new Factory<Resources>(Resources.class) { + @Override + public Resources create() { + return new Resources(i18n); + } + }); + + $(Resources.class); + register(Singleton.class, new Factory<I18nTranslationService>(I18nTranslationService.class) { @Override public I18nTranslationService create() { @@ -214,14 +227,14 @@ register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) { @Override public RTEActionTopToolbar create() { - final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class), i18n); + final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class)); final RTEActionTopToolbarPresenter toolbar = new RTEActionTopToolbarPresenter(panel); return toolbar; } }, new Factory<RTEActionSndToolbar>(RTEActionSndToolbar.class) { @Override public RTEActionSndToolbar create() { - final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class), i18n); + final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class)); final RTEActionSndToolbarPresenter toolbar = new RTEActionSndToolbarPresenter(panel); return toolbar; } @@ -240,11 +253,19 @@ presenter.init(panel); return presenter; } + }, new Factory<RTESavingEditor>(RTESavingEditor.class) { + @Override + public RTESavingEditor create() { + return new RTESavingEditorPresenter($(RTEditor.class), true, $(I18nTranslationService.class), + $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class), + $(RTEImgResources.class)); + } }); + register(NoDecoration.class, new Factory<TestRTEDialog>(TestRTEDialog.class) { @Override public TestRTEDialog create() { - return new TestRTEDialog($(RTEditor.class)); + return new TestRTEDialog($(RTESavingEditor.class)); } }); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/SimpleToolbar.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/SimpleToolbar.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/SimpleToolbar.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -94,8 +94,7 @@ } public void setCleanStyle() { - setStyleName("x-toolbar"); - addStyleName("x-panel"); + setBasicStyle(); addStyleName("k-blank-toolbar"); } @@ -104,4 +103,14 @@ mainPanel.setHeight(height); mainPanel.setCellHeight(childPanel, height); } + + public void setNormalStyle() { + setBasicStyle(); + addStyleName("k-toolbar-bottom-line"); + } + + private void setBasicStyle() { + setStyleName("x-toolbar"); + addStyleName("x-panel"); + } } \ No newline at end of file Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,16 @@ +package org.ourproject.kune.platf.client.ui.rte; + +import com.calclab.suco.client.events.Listener; +import com.calclab.suco.client.events.Listener0; + +public interface RTESavingEditor { + + void edit(String html, Listener<String> onSave, Listener0 onEditCancelled); + + RTEditor getBasicEditor(); + + void onSavedSuccessful(); + + void onSaveFailed(); + +} Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,234 @@ +package org.ourproject.kune.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.actions.ActionShortcut; +import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; +import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; +import org.ourproject.kune.platf.client.actions.BeforeActionListener; +import org.ourproject.kune.platf.client.dto.AccessRolDTO; +import org.ourproject.kune.platf.client.i18n.I18nTranslationService; +import org.ourproject.kune.platf.client.state.StateManager; +import org.ourproject.kune.platf.client.ui.noti.NotifyUser; +import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources; +import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper; +import org.ourproject.kune.platf.client.utils.TimerWrapper; +import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink; + +import com.calclab.suco.client.events.Listener; +import com.calclab.suco.client.events.Listener0; + +public class RTESavingEditorPresenter implements RTESavingEditor { + + @Deprecated + private static final String FILE_MENU_OPTION = "File"; + public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000; + public static final int AUTOSAVE_IN_MILLISECONDS = 10000; + + private final RTEditor editor; + private final boolean autoSave; + private boolean savePending; + private boolean saveAndCloseConfirmed; + private Listener<String> onSave; + private Listener0 onEditCancelled; + private final RTEImgResources imgResources; + private final TimerWrapper timer; + private final DeferredCommandWrapper deferredCommandWrapper; + private final I18nTranslationService i18n; + private final StateManager stateManager; + private final BeforeActionListener beforeStateChangeListener; + @Deprecated + private final SiteSignOutLink siteSignOutLink; + private ActionToolbarButtonDescriptor<Object> saveBtn; + + public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n, + StateManager stateManager, SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper, + RTEImgResources imgResources) { + this.editor = editor; + this.autoSave = autoSave; + this.i18n = i18n; + this.stateManager = stateManager; + this.siteSignOutLink = siteSignOutLink; + this.deferredCommandWrapper = deferredCommandWrapper; + this.imgResources = imgResources; + this.savePending = false; + this.saveAndCloseConfirmed = false; + createActions(); + this.timer = new TimerWrapper(new Listener0() { + public void onEvent() { + onAutoSave(); + } + }); + editor.addOnEditListener(new Listener0() { + public void onEvent() { + onEdit(); + } + }); + beforeStateChangeListener = new BeforeActionListener() { + public boolean beforeAction() { + return beforeTokenChange(); + } + }; + } + + public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) { + this.onSave = onSave; + this.onEditCancelled = onEditCancelled; + editor.setHtml(html); + editor.attach(); + stateManager.addBeforeStateChangeListener(beforeStateChangeListener); + siteSignOutLink.addBeforeSignOut(beforeStateChangeListener); + enableSaveBtn(false); + } + + public RTEditor getBasicEditor() { + return editor; + } + + public void onDoSaveAndClose() { + saveAndCloseConfirmed = true; + onDoSave(); + } + + public void onSavedSuccessful() { + if (saveAndCloseConfirmed) { + onCancelConfirmed(); + } else { + reset(); + } + } + + public void onSaveFailed() { + timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS); + if (saveAndCloseConfirmed) { + saveAndCloseConfirmed = false; + } + } + + protected void onAutoSave() { + onDoSave(); + } + + protected void onCancel() { + if (savePending) { + timer.cancel(); + Listener0 onYes = new Listener0() { + public void onEvent() { + onDoSaveAndClose(); + } + }; + Listener0 onCancel = new Listener0() { + public void onEvent() { + onCancelConfirmed(); + } + }; + NotifyUser.askConfirmation(i18n.t("Save confirmation"), + i18n.t("Do you want to save before closing the editor?"), onYes, onCancel); + } else { + onCancelConfirmed(); + } + } + + protected void onCancelConfirmed() { + stateManager.removeBeforeStateChangeListener(beforeStateChangeListener); + siteSignOutLink.removeBeforeSignOut(beforeStateChangeListener); + stateManager.resumeTokenChange(); + reset(); + editor.reset(); + onDoEditCancelled(); + } + + protected void onDoSave() { + onSave.onEvent(editor.getHtml()); + } + + boolean beforeTokenChange() { + if (savePending) { + onCancel(); + return false; + } else { + deferredCommandWrapper.addCommand(new Listener0() { + public void onEvent() { + onCancelConfirmed(); + } + }); + return true; + } + } + + private void createActions() { + Listener0 onPerformSaveCall = new Listener0() { + public void onEvent() { + onDoSave(); + } + }; + saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveCall); + saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName()); + saveBtn.setToolTip(i18n.t("Save")); + saveBtn.setShortcut(new ActionShortcut(true, 'S')); + saveBtn.setPosition(20); + + ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor, + RTEditor.topbar, onPerformSaveCall); + save.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName()); + save.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + save.setTextDescription(i18n.t("Save")); + save.setPosition(0); + + ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor, + RTEditor.topbar, new Listener<Object>() { + public void onEvent(Object parameter) { + onCancel(); + } + }); + close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + close.setTextDescription(i18n.t("Close")); + + Listener0 onPerformSaveAndCloseCall = new Listener0() { + public void onEvent() { + onDoSaveAndClose(); + } + }; + ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor, + RTEditor.topbar, onPerformSaveAndCloseCall); + saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION)); + saveclose.setTextDescription(i18n.t("Save & Close")); + + ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>( + AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall); + // saveCloseBtn.setIconCls(RTEImgResources.SUFFIX + + // imgResources.save().getName()); + saveCloseBtn.setTextDescription(i18n.t("Save & Close")); + saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill); + + editor.addAction(save); + editor.addAction(saveclose); + editor.addAction(close); + editor.addAction(saveBtn); + editor.addAction(saveCloseBtn); + } + + private void enableSaveBtn(boolean enable) { + editor.getTopBar().setButtonEnable(saveBtn, enable); + } + + private void onDoEditCancelled() { + onEditCancelled.onEvent(); + } + + private void onEdit() { + if (!savePending) { + savePending = true; + if (autoSave) { + timer.schedule(AUTOSAVE_IN_MILLISECONDS); + } + enableSaveBtn(true); + } + } + + private void reset() { + timer.cancel(); + savePending = false; + saveAndCloseConfirmed = false; + enableSaveBtn(false); + } +} Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,10 @@ +package org.ourproject.kune.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.actions.ActionAddCondition; + +public class RTEcanBeBasic implements ActionAddCondition<Object> { + public boolean mustBeAdded(Object param) { + // TODO Auto-generated method stub + return false; + } +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,31 +1,46 @@ package org.ourproject.kune.platf.client.ui.rte; import org.ourproject.kune.platf.client.View; +import org.ourproject.kune.platf.client.actions.ActionAddCondition; import org.ourproject.kune.platf.client.actions.ActionCollection; import org.ourproject.kune.platf.client.actions.ActionDescriptor; +import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; -import org.ourproject.kune.platf.client.ui.rte.RTEditorPresenter.ActionPosition; import com.calclab.suco.client.events.Listener0; public interface RTEditor { - void addAction(ActionDescriptor<Object> action, ActionPosition position); + public final ActionToolbarPosition topbar = new ActionToolbarPosition("rte-topbar"); + public final ActionToolbarPosition sndbar = new ActionToolbarPosition("rte-sndbar");; - void addActions(ActionCollection<Object> actions, ActionPosition position); + void addAction(ActionDescriptor<Object> action); + void addActions(ActionCollection<Object> actions); + void addOnEditListener(Listener0 listener); void attach(); - void editContent(String content); + ActionAddCondition<Object> canBeBasic(); + ActionAddCondition<Object> canBeExtended(); + View getEditorArea(); + String getHtml(); + ActionToolbar<Object> getSndBar(); + String getText(); + ActionToolbar<Object> getTopBar(); + void reset(); + void setExtended(boolean extended); + void setHtml(String html); + + void setText(String text); } Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -17,6 +17,7 @@ import com.allen_sauer.gwt.log.client.Log; import com.google.gwt.dom.client.Element; import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.ui.ChangeListener; import com.google.gwt.user.client.ui.ClickListener; import com.google.gwt.user.client.ui.FocusListener; import com.google.gwt.user.client.ui.KeyboardListener; @@ -24,6 +25,59 @@ public class RTEditorPanel implements RTEditorView { + private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener { + + public void onChange(Widget sender) { + presenter.fireOnEdit(); + } + + public void onClick(Widget sender) { + if (sender == rta) { + // We use the RichTextArea's onKeyUp event to update the + // toolbar status. This will catch any cases where the user + // moves the cursor using the keyboard, or uses one of the + // browser's built-in keyboard shortcuts. + updateStatus(); + } + } + + public void onFocus(Widget sender) { + presenter.onEditorFocus(); + } + + public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) { + } + + public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) { + } + + public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) { + if (sender == rta) { + // We use the RichTextArea's onKeyUp event to update the + // toolbar status. + // This will catch any cases where the user moves the cursor + // using the keyboard, or uses one of the browser's built-in + // keyboard shortcuts. + + updateStatus(); + fireEdit(); + if (modifiers != 0) { + Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")"); + ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers)); + if (actionItem != null) { + actionManager.doAction(actionItem); + updateStatus(); + } else { + Log.debug("...but not mapped to any action"); + } + } + } + } + + public void onLostFocus(Widget sender) { + + } + } private final I18nUITranslationService i18n; private final RichTextArea rta; private final BasicFormatter basic; @@ -40,7 +94,10 @@ basic = rta.getBasicFormatter(); extended = rta.getExtendedFormatter(); shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>(); - createListeners(); + EventListener listener = new EventListener(); + rta.addClickListener(listener); + rta.addKeyboardListener(listener); + rta.addFocusListener(listener); rta.setWidth("96%"); rta.setHeight("100%"); } @@ -58,7 +115,7 @@ public void addComment(String userName) { String time = i18n.formatDateWithLocale(new Date(), true); Element span = DOM.createSpan(); - span.setInnerHTML("<em>" + i18n.t("type here") + "</em> -" + userName + " " + time); + span.setInnerHTML("<em>" + i18n.t("type your commment here") + "</em> -" + userName + " " + time); DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment"); insertHtml(" " + span.getString() + " "); } @@ -95,10 +152,18 @@ rta.setFocus(true); } + public String getHtml() { + return rta.getHTML(); + } + public Widget getRTE() { return rta; } + public String getText() { + return rta.getText(); + } + public void insertHorizontalRule() { extended.insertHorizontalRule(); } @@ -199,6 +264,14 @@ basic.setForeColor(color); } + public void setHtml(String html) { + rta.setHTML(html); + } + + public void setText(String text) { + rta.setText(text); + } + public void toggleBold() { basic.toggleBold(); } @@ -235,59 +308,6 @@ presenter.fireOnEdit(); } - private void createListeners() { - rta.addFocusListener(new FocusListener() { - public void onFocus(Widget sender) { - presenter.onEditorFocus(); - } - - public void onLostFocus(Widget sender) { - } - }); - rta.addClickListener(new ClickListener() { - public void onClick(Widget sender) { - if (sender == rta) { - // We use the RichTextArea's onKeyUp event to update the - // toolbar status. This will catch any cases where the user - // moves the cursor using the keyboard, or uses one of the - // browser's built-in keyboard shortcuts. - updateStatus(); - } - } - }); - rta.addKeyboardListener(new KeyboardListener() { - - public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) { - } - - public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) { - } - - public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) { - if (sender == rta) { - // We use the RichTextArea's onKeyUp event to update the - // toolbar status. - // This will catch any cases where the user moves the cursor - // using the keyboard, or uses one of the browser's built-in - // keyboard shortcuts. - - updateStatus(); - fireEdit(); - if (modifiers != 0) { - Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")"); - ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers)); - if (actionItem != null) { - actionManager.doAction(actionItem); - updateStatus(); - } else { - Log.debug("...but not mapped to any action"); - } - } - } - } - }); - } - /** * Updates the status of all the stateful buttons. */ Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -11,14 +11,11 @@ import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; -import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.dto.AccessRolDTO; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.state.Session; -import org.ourproject.kune.platf.client.ui.SimpleToolbar; import org.ourproject.kune.platf.client.ui.TextUtils; import org.ourproject.kune.platf.client.ui.noti.NotifyUser; import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette; @@ -34,10 +31,6 @@ public class RTEditorPresenter implements RTEditor { - public enum ActionPosition { - top, snd - }; - private final String fontNames[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" }; private final String fontSizes[] = { "Extra small", "Very small", "Small", "Medium", "Large", "Very large", "Extra large" }; @@ -54,8 +47,7 @@ private final AccessRolDTO accessRol; private final I18nTranslationService i18n; private final Session session; - private final ActionItemCollection<Object> topActions; - private final ActionItemCollection<Object> sndActions; + private final ActionItemCollection<Object> actions; private final RTEImgResources imgResources; private final RTEActionTopToolbar topBar; private final RTEActionSndToolbar sndBar; @@ -67,6 +59,8 @@ private final TextEditorInsertElement insertElement; private final ColorWebSafePalette palette; private final DeferredCommandWrapper deferred; + private final ActionAddCondition<Object> canBeBasic; + private final ActionAddCondition<Object> canBeExtended; public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar, RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement, @@ -78,37 +72,31 @@ this.insertElement = textEditorInsertElement; this.palette = palette; this.deferred = deferred; - styleToolbar(topBar); styleToolbar(sndBar); sndBar.attach(); this.imgResources = imgResources; extended = true; accessRol = AccessRolDTO.Editor; - topActions = new ActionItemCollection<Object>(); - sndActions = new ActionItemCollection<Object>(); + actions = new ActionItemCollection<Object>(); this.onEdit = new Event0("onRTEEdit"); + canBeBasic = new ActionAddCondition<Object>() { + public boolean mustBeAdded(Object param) { + return view.canBeBasic(); + } + }; + canBeExtended = new ActionAddCondition<Object>() { + public boolean mustBeAdded(Object param) { + return isExtended(); + } + }; } - public void addAction(ActionDescriptor<Object> action, ActionPosition position) { - switch (position) { - case top: - topActions.add(withNoItem(action)); - break; - case snd: - sndActions.add(withNoItem(action)); - break; - } + public void addAction(ActionDescriptor<Object> action) { + actions.add(withNoItem(action)); } - public void addActions(ActionCollection<Object> actions, ActionPosition position) { - switch (position) { - case top: - topActions.addAll(withNoItem(actions)); - break; - case snd: - sndActions.addAll(withNoItem(actions)); - break; - } + public void addActions(ActionCollection<Object> actioncollection) { + actions.addAll(withNoItem(actioncollection)); } public void addOnEditListener(final Listener0 listener) { @@ -122,15 +110,19 @@ public void attach() { topBar.clear(); sndBar.clear(); - view.addActions(topActions); - view.addActions(sndActions); - topBar.addActions(topActions); - sndBar.addActions(sndActions); + topBar.addActions(actions, topbar); + sndBar.addActions(actions, sndbar); + view.addActions(actions); } - public void editContent(String content) { + public ActionAddCondition<Object> canBeBasic() { + return canBeBasic(); } + public ActionAddCondition<Object> canBeExtended() { + return canBeExtended(); + } + public void fireOnEdit() { onEdit.fire(); } @@ -139,10 +131,18 @@ return view; } + public String getHtml() { + return view.getHtml(); + } + public ActionToolbar<Object> getSndBar() { return sndBar; } + public String getText() { + return view.getText(); + } + public ActionToolbar<Object> getTopBar() { return topBar; } @@ -158,10 +158,25 @@ palette.hide(); } + public void reset() { + topBar.clear(); + sndBar.clear(); + } + public void setExtended(boolean extended) { this.extended = extended; } + public void setHtml(String html) { + view.setHtml(html); + view.focus(); + } + + public void setText(String text) { + view.setText(text); + view.focus(); + } + public void updateStatus() { if (view.canBeBasic()) { sndBar.setPushButtonPressed(bold, view.isBold()); @@ -174,19 +189,8 @@ } private void createBasicActions() { - ActionAddCondition<Object> canBeBasic = new ActionAddCondition<Object>() { - public boolean mustBeAdded(Object param) { - return view.canBeBasic(); - } - }; - ActionAddCondition<Object> canBeExtended = new ActionAddCondition<Object>() { - public boolean mustBeAdded(Object param) { - return isExtended(); - } - }; - - ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.selectAll(); } @@ -199,9 +203,10 @@ selectAll.setTopSeparator(true); selectAll.setBottomSeparator(true); - bold = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar, new Listener0() { + bold = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() { public void onEvent() { view.toggleBold(); + fireOnEdit(); } }); bold.setIconCls(getCssName(imgResources.bold())); @@ -209,33 +214,34 @@ bold.setShortcut(new ActionShortcut(true, 'B')); bold.setAddCondition(canBeBasic); - italic = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar, - new Listener0() { - public void onEvent() { - view.toggleItalic(); - } - }); + italic = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() { + public void onEvent() { + view.toggleItalic(); + fireOnEdit(); + } + }); italic.setIconCls(getCssName(imgResources.italic())); italic.setToolTip(i18n.t("Italic")); italic.setShortcut(new ActionShortcut(true, 'I')); italic.setAddCondition(canBeBasic); italic.setAddCondition(canBeBasic); - underline = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar, - new Listener0() { - public void onEvent() { - view.toggleUnderline(); - } - }); + underline = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() { + public void onEvent() { + view.toggleUnderline(); + fireOnEdit(); + } + }); underline.setIconCls(getCssName(imgResources.underline())); underline.setToolTip(i18n.t("Underline")); underline.setShortcut(new ActionShortcut(true, 'U')); underline.setAddCondition(canBeBasic); - ActionToolbarMenuDescriptor<Object> subscript = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> subscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.toggleSubscript(); + fireOnEdit(); } }); subscript.setParentMenuTitle(i18n.t(FORMAT_MENU)); @@ -244,10 +250,11 @@ subscript.setShortcut(new ActionShortcut(true, '0')); subscript.setAddCondition(canBeBasic); - ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.toggleSuperscript(); + fireOnEdit(); } }); superscript.setParentMenuTitle(i18n.t(FORMAT_MENU)); @@ -257,9 +264,10 @@ superscript.setAddCondition(canBeBasic); ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { view.justifyLeft(); + fireOnEdit(); } }); justifyLeft.setIconCls(getCssName(imgResources.alignleft())); @@ -268,9 +276,10 @@ justifyLeft.setAddCondition(canBeBasic); ActionToolbarButtonDescriptor<Object> justifyCentre = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { view.justifyCenter(); + fireOnEdit(); } }); justifyCentre.setIconCls(getCssName(imgResources.centerpara())); @@ -279,21 +288,23 @@ justifyCentre.setAddCondition(canBeBasic); ActionToolbarButtonDescriptor<Object> justifyRight = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { view.justifyRight(); + fireOnEdit(); } }); justifyRight.setIconCls(getCssName(imgResources.alignright())); justifyRight.setToolTip(i18n.t("Right Justify")); justifyRight.setShortcut(new ActionShortcut(true, 'R')); - justifyRight.setRightSeparator(ActionToolbarButtonSeparator.spacer); + // justifyRight.setRightSeparator(ActionToolbarButtonSeparator.spacer); justifyRight.setAddCondition(canBeBasic); - ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.undo(); + fireOnEdit(); } }); undo.setShortcut(new ActionShortcut(true, 'Z')); @@ -302,10 +313,11 @@ undo.setAddCondition(canBeExtended); undo.setIconCls(getCssName(imgResources.undo())); - ActionToolbarMenuDescriptor<Object> redo = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> redo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.redo(); + fireOnEdit(); } }); redo.setShortcut(new ActionShortcut(true, 'Y')); @@ -315,20 +327,22 @@ redo.setBottomSeparator(true); redo.setIconCls(getCssName(imgResources.redo())); - ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.undo(); + fireOnEdit(); } }); undoBtn.setToolTip(i18n.t("Undo")); undoBtn.setAddCondition(canBeExtended); undoBtn.setIconCls(getCssName(imgResources.undo())); - ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.redo(); + fireOnEdit(); } }); redoBtn.setToolTip(i18n.t("Redo")); @@ -336,8 +350,8 @@ redoBtn.setIconCls(getCssName(imgResources.redo())); redoBtn.setRightSeparator(ActionToolbarButtonSeparator.separator); - ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.copy(); } @@ -348,10 +362,11 @@ copy.setAddCondition(canBeExtended); copy.setIconCls(getCssName(imgResources.copy())); - ActionToolbarMenuDescriptor<Object> cut = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> cut = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.cut(); + fireOnEdit(); } }); cut.setShortcut(new ActionShortcut(true, 'X')); @@ -360,10 +375,11 @@ cut.setAddCondition(canBeExtended); cut.setIconCls(getCssName(imgResources.cut())); - ActionToolbarMenuDescriptor<Object> paste = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> paste = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.paste(); + fireOnEdit(); } }); paste.setShortcut(new ActionShortcut(true, 'V')); @@ -372,8 +388,8 @@ paste.setAddCondition(canBeExtended); paste.setIconCls(getCssName(imgResources.paste())); - ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { NotifyUser.info("In dev"); } @@ -383,11 +399,14 @@ editHtml.setParentMenuTitle(i18n.t(EDIT_MENU)); editHtml.setAddCondition(canBeExtended); - ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.focus(); - view.addComment(session.getCurrentUser().getShortName()); + String author = session.isLogged() ? session.getCurrentUser().getShortName() + : i18n.t("anonymous user"); + view.addComment(author); + fireOnEdit(); } }); comment.setEnableCondition(new ActionEnableCondition<Object>() { @@ -401,45 +420,48 @@ comment.setEnableCondition(isInsertHtmlSupported()); comment.setAddCondition(canBeExtended); - ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar, + new Listener0() { public void onEvent() { view.focus(); view.insertHorizontalRule(); + fireOnEdit(); } }); hr.setTextDescription(i18n.t("Horizontal line")); + hr.setShortcut(new ActionShortcut(true, true, ' ', "Space")); hr.setIconCls(getCssName(imgResources.hfixedline())); hr.setParentMenuTitle(i18n.t(INSERT_MENU)); hr.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.focus(); view.insertHorizontalRule(); + fireOnEdit(); } }); hrButton.setIconCls(getCssName(imgResources.hfixedline())); hrButton.setToolTip(i18n.t("Horizontal line")); - hrButton.setShortcut(new ActionShortcut(true, true, ' ', "Space")); hrButton.setAddCondition(canBeExtended); - strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, ActionToolbarPosition.topbar, - new Listener0() { - public void onEvent() { - view.toggleStrikethrough(); - } - }); + strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, sndbar, new Listener0() { + public void onEvent() { + view.toggleStrikethrough(); + fireOnEdit(); + } + }); strikethrough.setIconCls(getCssName(imgResources.strikeout())); strikethrough.setToolTip(i18n.t("Strikethrough")); - strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator); + // strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator); strikethrough.setAddCondition(canBeExtended); ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { view.leftIndent(); + fireOnEdit(); } }); decreaseIndent.setIconCls(getCssName(imgResources.decrementindent())); @@ -447,20 +469,22 @@ decreaseIndent.setAddCondition(canBeExtended); ActionToolbarButtonDescriptor<Object> increaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { view.rightIndent(); + fireOnEdit(); } }); increaseIndent.setIconCls(getCssName(imgResources.incrementindent())); increaseIndent.setToolTip(i18n.t("Increase Indent")); - increaseIndent.setRightSeparator(ActionToolbarButtonSeparator.spacer); + // increaseIndent.setRightSeparator(ActionToolbarButtonSeparator.spacer); increaseIndent.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.insertOrderedList(); + fireOnEdit(); } }); ol.setIconCls(getCssName(imgResources.defaultnumbering())); @@ -468,20 +492,21 @@ ol.setShortcut(new ActionShortcut(true, '7')); ol.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.insertUnorderedList(); + fireOnEdit(); } }); ul.setIconCls(getCssName(imgResources.defaultbullet())); ul.setToolTip(i18n.t("Bullet List")); ul.setShortcut(new ActionShortcut(true, '8')); - ul.setRightSeparator(ActionToolbarButtonSeparator.separator); + // ul.setRightSeparator(ActionToolbarButtonSeparator.separator); ul.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { NotifyUser.info(TextUtils.IN_DEVELOPMENT); } @@ -490,8 +515,8 @@ img.setToolTip(i18n.t("Insert Image")); img.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { deferred.addCommand(new Listener0() { public void onEvent() { @@ -507,13 +532,15 @@ insertElement.addOnCreateLink(new Listener2<String, String>() { public void onEvent(String name, String url) { view.createLink(url); + fireOnEdit(); } }); - ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.unlink(); + fireOnEdit(); } }); removeLink.setIconCls(getCssName(imgResources.linkbreak())); @@ -521,41 +548,44 @@ removeLink.setShortcut(new ActionShortcut(true, true, 'K')); removeLink.setAddCondition(canBeExtended); - ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + final ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol, + sndbar, new Listener0() { public void onEvent() { view.removeFormat(); + fireOnEdit(); } }); removeFormat.setIconCls(getCssName(imgResources.removeFormat())); removeFormat.setToolTip(i18n.t("Clear Formatting")); removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space")); removeFormat.setAddCondition(canBeExtended); - removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator); + // removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator); - final ActionToolbarButtonDescriptor<Object> insertTable = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol, + topbar, new Listener0() { public void onEvent() { view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "</tr>\n</tbody>\n</table>"); + fireOnEdit(); } }); insertTable.setIconCls(getCssName(imgResources.inserttable())); - insertTable.setToolTip(i18n.t("Insert Table ...")); + insertTable.setTextDescription(i18n.t("Insert Table ...")); insertTable.setAddCondition(canBeExtended); - insertTable.setRightSeparator(ActionToolbarButtonSeparator.separator); + insertTable.setParentMenuTitle(i18n.t(INSERT_MENU)); final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { - palette.show(getActionLeftPosition(sndBar, insertTable), getActionTopPosition(sndBar, - insertTable), new Listener<String>() { + palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar, + removeFormat), new Listener<String>() { public void onEvent(String color) { palette.hide(); view.setForeColor(color); + fireOnEdit(); } }); } @@ -565,13 +595,14 @@ fontColor.setAddCondition(canBeBasic); ActionToolbarButtonDescriptor<Object> backgroundColor = new ActionToolbarButtonDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + sndbar, new Listener0() { public void onEvent() { palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor), new Listener<String>() { public void onEvent(String color) { palette.hide(); view.setBackColor(color); + fireOnEdit(); } }); } @@ -580,56 +611,56 @@ backgroundColor.setToolTip(i18n.t("Text Background Colour")); backgroundColor.setAddCondition(canBeBasic); - sndActions.add(withNoItem(undoBtn)); - sndActions.add(withNoItem(redoBtn)); - sndActions.add(withNoItem(bold)); - sndActions.add(withNoItem(italic)); - sndActions.add(withNoItem(underline)); - sndActions.add(withNoItem(strikethrough)); + actions.add(withNoItem(bold)); + actions.add(withNoItem(italic)); + actions.add(withNoItem(underline)); + actions.add(withNoItem(strikethrough)); - sndActions.add(withNoItem(justifyLeft)); - sndActions.add(withNoItem(justifyCentre)); - sndActions.add(withNoItem(justifyRight)); + actions.add(withNoItem(justifyLeft)); + actions.add(withNoItem(justifyCentre)); + actions.add(withNoItem(justifyRight)); - topActions.add(withNoItem(undo)); - topActions.add(withNoItem(redo)); - topActions.add(withNoItem(copy)); - topActions.add(withNoItem(cut)); - topActions.add(withNoItem(paste)); - topActions.add(withNoItem(selectAll)); - topActions.add(withNoItem(editHtml)); - topActions.add(withNoItem(hr)); - topActions.add(withNoItem(subscript)); - topActions.add(withNoItem(superscript)); - sndActions.add(withNoItem(decreaseIndent)); - sndActions.add(withNoItem(increaseIndent)); - sndActions.add(withNoItem(ol)); - sndActions.add(withNoItem(ul)); - sndActions.add(withNoItem(removeFormat)); - sndActions.add(withNoItem(hrButton)); - sndActions.add(withNoItem(img)); - sndActions.add(withNoItem(createLink)); - sndActions.add(withNoItem(removeLink)); - sndActions.add(withNoItem(insertTable)); - topActions.add(withNoItem(comment)); + actions.add(withNoItem(undo)); + actions.add(withNoItem(redo)); + actions.add(withNoItem(copy)); + actions.add(withNoItem(cut)); + actions.add(withNoItem(paste)); + actions.add(withNoItem(selectAll)); + actions.add(withNoItem(editHtml)); + actions.add(withNoItem(hr)); + actions.add(withNoItem(subscript)); + actions.add(withNoItem(superscript)); + actions.add(withNoItem(decreaseIndent)); + actions.add(withNoItem(increaseIndent)); + actions.add(withNoItem(ol)); + actions.add(withNoItem(ul)); + actions.add(withNoItem(removeFormat)); + // topActions.add(withNoItem(hrButton)); + actions.add(withNoItem(img)); + actions.add(withNoItem(createLink)); + actions.add(withNoItem(removeLink)); + actions.add(withNoItem(insertTable)); + actions.add(withNoItem(comment)); + actions.add(withNoItem(undoBtn)); + actions.add(withNoItem(redoBtn)); for (String fontName : this.fontNames) { ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName); - sndActions.add(withNoItem(fontNameAction)); + actions.add(withNoItem(fontNameAction)); } for (int fontSize = 0; fontSize < fontSizes.length; fontSize++) { ActionToolbarMenuDescriptor<Object> fontSizeAction = createFontSizeAction(canBeBasic, fontSize, fontSizes[fontSize]); - sndActions.add(withNoItem(fontSizeAction)); + actions.add(withNoItem(fontSizeAction)); } - sndActions.add(withNoItem(fontColor)); - sndActions.add(withNoItem(backgroundColor)); + actions.add(withNoItem(fontColor)); + actions.add(withNoItem(backgroundColor)); } private ActionToolbarMenuDescriptor<Object> createFontNameAction(ActionAddCondition<Object> canBeBasic, final String fontName) { - final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.setFontName(fontName); fireOnEdit(); @@ -644,8 +675,8 @@ private ActionToolbarMenuDescriptor<Object> createFontSizeAction(ActionAddCondition<Object> canBeBasic, final int fontSize, String fontSizeName) { - final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, - ActionToolbarPosition.topbar, new Listener0() { + final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar, + new Listener0() { public void onEvent() { view.setFontSize(fontSizesConstants[fontSize]); fireOnEdit(); @@ -667,7 +698,7 @@ } private String getCssName(ImageResource imageResource) { - return "k-rte-" + imageResource.getName(); + return RTEImgResources.SUFFIX + imageResource.getName(); } private boolean isExtended() { @@ -682,11 +713,8 @@ }; } - private void styleToolbar(ActionToolbar<Object> topBar) { - SimpleToolbar toolbar = ((ActionToolbarPanel<Object>) topBar.getView()).getToolbar(ActionToolbarPosition.topbar); - toolbar.setStyleName("x-toolbar"); - toolbar.addStyleName("x-panel"); - toolbar.addStyleName("k-toolbar-bottom-line"); + private void styleToolbar(ActionToolbar<Object> bar) { + bar.setNormalStyle(); } private ActionItemCollection<Object> withNoItem(ActionCollection<Object> actions) { Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -6,7 +6,7 @@ public interface RTEditorView extends View { - void addActions(ActionItemCollection<Object> extendedTopActions); + void addActions(ActionItemCollection<Object> actions); void addComment(String userName); @@ -26,6 +26,10 @@ void focus(); + String getHtml(); + + String getText(); + void insertHorizontalRule(); void insertHtml(String html); @@ -76,6 +80,10 @@ void setForeColor(String color); + void setHtml(String html); + + void setText(String text); + void toggleBold(); void toggleItalic(); Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,6 +1,5 @@ package org.ourproject.kune.platf.client.ui.rte; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog; @@ -10,19 +9,20 @@ public class TestRTEDialog { - private final RTEditor editor; + private final RTESavingEditor editor; private final BasicDialog dialog; - public TestRTEDialog(RTEditor editor) { + public TestRTEDialog(RTESavingEditor editor) { this.editor = editor; dialog = new BasicDialog("Testing RTE", false, false, 650, 200); final VerticalPanel vp = new VerticalPanel(); - vp.add(((ActionToolbarPanel<Object>) editor.getTopBar().getView()).getToolbar(ActionToolbarPosition.topbar)); - vp.add(((ActionToolbarPanel<Object>) editor.getSndBar().getView()).getToolbar(ActionToolbarPosition.topbar)); - final RTEditorPanel editorPanel = (RTEditorPanel) editor.getEditorArea(); + RTEditor basicEditor = editor.getBasicEditor(); + vp.add(((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar()); + vp.add(((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar()); + final RTEditorPanel editorPanel = (RTEditorPanel) basicEditor.getEditorArea(); vp.add(editorPanel.getRTE()); - editor.setExtended(true); + basicEditor.setExtended(true); vp.setWidth("100%"); dialog.add(vp); dialog.addListener(new WindowListenerAdapter() { @@ -36,11 +36,11 @@ } public void setExtended(boolean extended) { - editor.setExtended(extended); + editor.getBasicEditor().setExtended(extended); } public void show() { - editor.attach(); + editor.getBasicEditor().attach(); dialog.show(); } } Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java (from rev 1054, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java 2009-03-02 19:32:02 UTC (rev 1054) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,67 @@ +/* + * + * Copyright (C) 2007-2009 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.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplIE6; + +/** + * A wrapper used to inject css into RTA. As published in: + * + * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ + * f64c0024d8676a66 + * /d5f26a54145fc5d4?lnk=st&q=richtextarea+style#d5f26a54145fc5d4 + * + * FIXME: Only for IE and Mozilla + * + */ +public class WrappedRichTextAreaImplIE6 extends RichTextAreaImplIE6 { + + @Override + public native void initElement() /*-{ + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + + setTimeout(function() { + if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) { + return; + } + + // Attempt to set the iframe document's body to 'contentEditable' mode. + // There's no way to know when the body will actually be available, so + // keep trying every so often until it is. + // Note: The body seems to be missing only rarely, so please don't remove + // this retry loop just because it's hard to reproduce. + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + if (!doc.body) { + // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower + // would increase the probability of a user-visible delay. + setTimeout(arguments.callee, 50); + return; + } + var ct = "<html><head><style>@import url('" + $wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + doc.body.contentEditable = true; + + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; +} Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java (from rev 1060, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java 2009-03-06 01:07:03 UTC (rev 1060) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,76 @@ +/* + * + * Copyright (C) 2007-2009 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.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplMozilla; + +/** + * A wrapper used to inject css into RTA. As published in: + * + * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ + * f64c0024d8676a66 + * /d5f26a54145fc5d4?lnk=st&q=richtextarea+style#d5f26a54145fc5d4 + * + * FIXME: Only for IE and Mozilla + * + */ +public class WrappedRichTextAreaImplMozilla extends RichTextAreaImplMozilla { + + @Override + public native void initElement() /*-{ + // Mozilla doesn't allow designMode to be set reliably until the iframe is + // fully loaded. + var _this = this; + var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + + iframe.onload = function() { + // Some Mozillae have the nasty habit of calling onload again when you set + // designMode, so let's avoid doing it more than once. + iframe.onload = null; + + // patch ccs inject: + + var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; + head=doc.getElementsByTagName('head')[0]; + link=document.createElement('link'); + link.setAttribute('rel',"stylesheet"); + link.setAttribute('type',"text/css"); + link.setAttribute('href',$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" ); + head.appendChild(link); + + // -- patch + + // Send notification that the iframe has finished loading. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + + // Don't set designMode until the RTA actually gets focused. This is + // necessary because editing won't work on Mozilla if the iframe is + // *hidden, but attached*. Waiting for focus gets around this issue. + // + // Note: This onfocus will not conflict with the addEventListener('focus', + // ...) // in RichTextAreaImplStandard. + iframe.contentWindow.onfocus = function() { + iframe.contentWindow.onfocus = null; + iframe.contentWindow.document.designMode = 'On'; + }; + }; + }-*/; +} Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java (from rev 1060, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java 2009-03-06 01:07:03 UTC (rev 1060) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,48 @@ +/* + * + * Copyright (C) 2007-2009 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.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplOpera; + +public class WrappedRichTextAreaImplOpera extends RichTextAreaImplOpera { + + @Override + public native void initElement() /*-{ + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch + + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; + +} Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java (from rev 1060, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java 2009-03-06 01:07:03 UTC (rev 1060) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,49 @@ +/* + * + * Copyright (C) 2007-2009 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.platf.client.ui.rte; + +import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplSafari; + +public class WrappedRichTextAreaImplSafari extends RichTextAreaImplSafari { + + @Override + public native void initElement() /*-{ + // Most browsers don't like setting designMode until slightly _after_ + // the iframe becomes attached to the DOM. Any non-zero timeout will do + // just fine. + var _this = this; + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; + setTimeout(function() { + // Turn on design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; + + // patch css inject: + var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; + var doc = elem.contentWindow.document; + var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; + doc.write( ct ); + // -- patch + + // Send notification that the iframe has reached design mode. + _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); + }, 1); + }-*/; + +} Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -6,6 +6,8 @@ public interface RTEImgResources extends ImmutableResourceBundle { + String SUFFIX = "k-rte-"; + @Resource("alignleft.png") public ImageResource alignleft(); Added: trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/platf/client/utils/TimerWrapper.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,33 @@ +package org.ourproject.kune.platf.client.utils; + +import com.calclab.suco.client.events.Listener0; +import com.google.gwt.user.client.Timer; + +public class TimerWrapper { + private final Timer timer; + + public TimerWrapper(final Listener0 onTime) { + timer = new Timer() { + @Override + public void run() { + onTime.onEvent(); + } + }; + } + + public void cancel() { + timer.cancel(); + } + + public void run() { + timer.run(); + } + + public void schedule(final int delayMillis) { + timer.schedule(delayMillis); + } + + public void scheduleRepeating(final int delayMillis) { + timer.scheduleRepeating(delayMillis); + } +} Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -38,7 +38,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -53,7 +53,7 @@ final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider, final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry, final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo, - final Provider<TextEditor> textEditorProvider, final KuneErrorHandler errorHandler, + final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler, final WikiViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider, final SitePublicSpaceLink publicLink) { super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider, Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -45,7 +45,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; @@ -78,7 +78,7 @@ $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class), $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class), $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class), - $(EntityHeader.class), $$(TextEditor.class), $(KuneErrorHandler.class), $(WikiViewer.class), + $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), $(WikiViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class)); } }); Modified: trunk/src/main/java/org/ourproject/kune/workspace/Kune-Workspace.gwt.xml =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/Kune-Workspace.gwt.xml 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/Kune-Workspace.gwt.xml 2009-03-10 00:05:50 UTC (rev 1064) @@ -2,47 +2,5 @@ <module> <inherits name='org.ourproject.kune.platf.Kune-Platform' /> <inherits name="com.google.gwt.core.Core" /> - <inherits name="com.google.gwt.user.UserAgent" /> - <!-- RTE css inject --> - <!-- See gwt-user: com/google/gwt/user/RichText.gwt.xml --> - <!-- IE-specific implementation --> - <replace-with - class="org.ourproject.kune.workspace.client.editor.WrappedRichTextAreaImplIE6"> - <when-type-is - class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> - <when-property-is name="user.agent" value="ie6" /> - </replace-with> - - <!-- Mozilla-specific implementation --> - <replace-with - class="org.ourproject.kune.workspace.client.editor.WrappedRichTextAreaImplMozilla"> - <when-type-is - class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> - <any> - <when-property-is name="user.agent" value="gecko1_8" /> - <when-property-is name="user.agent" value="gecko" /> - </any> - </replace-with> - - <!-- Safari-specific implementation --> - <replace-with - class="org.ourproject.kune.workspace.client.editor.WrappedRichTextAreaImplSafari"> - <when-type-is - class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> - <any> - <when-property-is name="user.agent" value="safari" /> - </any> - </replace-with> - - <!-- Opera-specific implementation --> - <replace-with - class="org.ourproject.kune.workspace.client.editor.WrappedRichTextAreaImplOpera"> - <when-type-is - class="org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl" /> - <any> - <when-property-is name="user.agent" value="opera" /> - </any> - </replace-with> - </module> Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -57,7 +57,7 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; -import org.ourproject.kune.workspace.client.editor.TextEditor; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.entityheader.EntityHeader; import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -75,6 +75,11 @@ private static final String PUBLICATION_MENU = "Publication"; + public static final ActionToolbarPosition CONTENT_TOPBAR = new ActionToolbarPosition("afca-ctn-top"); + public static final ActionToolbarPosition CONTENT_BOTTOMBAR = new ActionToolbarPosition("afca-ctn-bottom"); + public static final ActionToolbarPosition CONTEXT_TOPBAR = new ActionToolbarPosition("afca-ctx-top"); + public static final ActionToolbarPosition CONTEXT_BOTTOMBAR = new ActionToolbarPosition("afca-ctx-bottom"); + protected final Session session; protected final StateManager stateManager; protected final I18nUITranslationService i18n; @@ -86,7 +91,7 @@ protected final ContentActionRegistry contentActionRegistry; protected final ContextActionRegistry contextActionRegistry; protected final Provider<FileDownloadUtils> fileDownloadProvider; - protected final Provider<TextEditor> textEditorProvider; + protected final Provider<ContentEditor> textEditorProvider; protected final Provider<ContextPropEditor> contextPropEditorProvider; protected final FoldableContent foldableContent; protected final DeferredCommandWrapper deferredCommandWrapper; @@ -98,7 +103,7 @@ Provider<GroupServiceAsync> groupServiceProvider, Provider<ContentServiceAsync> contentServiceProvider, Provider<FileUploader> fileUploaderProvider, ContextNavigator contextNavigator, ContentActionRegistry contentActionRegistry, ContextActionRegistry contextActionRegistry, - Provider<FileDownloadUtils> fileDownloadProvider, Provider<TextEditor> textEditorProvider, + Provider<FileDownloadUtils> fileDownloadProvider, Provider<ContentEditor> textEditorProvider, Provider<ContextPropEditor> contextPropEditorProvider, FoldableContent foldableContent, EntityHeader entityLogo, SitePublicSpaceLink publicLink) { this.session = session; @@ -144,7 +149,7 @@ protected void createContentRenameAction(String parentMenuTitle, String textDescription, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtn = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { contextNavigator.editItem(stateToken); } @@ -157,7 +162,7 @@ protected void createDelContainerAction(String text, String parentMenuTitle, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> delContainer = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Administrator, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { NotifyUser.info("Sorry, in development"); } @@ -172,7 +177,7 @@ protected void createDelContentAction(String parentMenuTitle, String textDescription, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> delContent = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Administrator, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { contentServiceProvider.get().delContent(session.getUserHash(), token, new AsyncCallbackSimple<StateContentDTO>() { @@ -197,7 +202,7 @@ protected void createDownloadActions(String typeUploadedfile) { ActionToolbarButtonDescriptor<StateToken> download = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { downloadContent(token); } @@ -223,15 +228,16 @@ protected ActionToolbarButtonDescriptor<StateToken> createEditAction(String... registerInTypes) { ActionToolbarButtonDescriptor<StateToken> editContent = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { + NotifyUser.showProgressProcessing(); session.check(new AsyncCallbackSimple<Object>() { public void onSuccess(final Object result) { - final TextEditor editor = textEditorProvider.get(); + final ContentEditor editor = textEditorProvider.get(); foldableContent.detach(); contextNavigator.detach(); contextPropEditorProvider.get().attach(); - editor.editContent(session.getContentState().getContent(), new Listener<String>() { + editor.edit(session.getContentState().getContent(), new Listener<String>() { public void onEvent(final String html) { NotifyUser.showProgressSaving(); contentServiceProvider.get().save(session.getUserHash(), stateToken, html, @@ -272,6 +278,7 @@ }); } }); + NotifyUser.hideProgress(); } }); } @@ -300,7 +307,7 @@ protected ActionToolbarButtonDescriptor<StateToken> createGoHomeAction(String... registerInTypes) { ActionToolbarButtonDescriptor<StateToken> goGroupHome = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, CONTEXT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { stateManager.gotoToken(token.getGroup()); } @@ -322,8 +329,8 @@ final String textDescription, final String parentMenuTitle, final String parentMenuSubtitle, final String defaultName, Position position, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> addFolder; - addFolder = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, - ActionToolbarPosition.topbar, new Listener<StateToken>() { + addFolder = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, CONTENT_TOPBAR, + new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { NotifyUser.showProgressProcessing(); contentServiceProvider.get().addFolder(session.getUserHash(), stateToken, defaultName, @@ -346,7 +353,7 @@ String iconUrl, final String description, final String parentMenuTitle, Position position, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> addContent = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener0() { + AccessRolDTO.Editor, CONTEXT_TOPBAR, new Listener0() { public void onEvent() { NotifyUser.showProgressProcessing(); contentServiceProvider.get().addContent(session.getUserHash(), @@ -373,7 +380,7 @@ protected ActionToolbarMenuDescriptor<StateToken> createRefreshCntAction(String parentMenuTitle, String... registerInTypes) { final ActionToolbarMenuDescriptor<StateToken> refreshCnt = new ActionToolbarMenuDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { stateManager.reload(); contextNavigator.selectItem(stateToken); @@ -390,7 +397,7 @@ protected ActionToolbarMenuDescriptor<StateToken> createRefreshCxtAction(String parentMenuTitleCtx, String... registerInTypes) { final ActionToolbarMenuDescriptor<StateToken> refreshCtx = new ActionToolbarMenuDescriptor<StateToken>( - AccessRolDTO.Viewer, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Viewer, CONTEXT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { stateManager.reload(); contextNavigator.selectItem(stateToken); @@ -407,7 +414,7 @@ protected ActionToolbarMenuAndItemDescriptor<StateToken> createRenameContentInCtxAction(String parentMenuTitleCtx, String textDescription, String... registerInTypes) { final ActionToolbarMenuAndItemDescriptor<StateToken> renameCtx = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Editor, CONTEXT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { contextNavigator.editItem(stateToken); } @@ -421,8 +428,8 @@ protected ActionToolbarMenuDescriptor<StateToken> createSetAsDefContent(String parentMenuTitle, String... registerInTypes) { final ActionToolbarMenuDescriptor<StateToken> setAsDefGroupContent; - setAsDefGroupContent = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Administrator, - ActionToolbarPosition.topbar, new Listener<StateToken>() { + setAsDefGroupContent = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Administrator, CONTENT_TOPBAR, + new Listener<StateToken>() { public void onEvent(final StateToken token) { NotifyUser.showProgressProcessing(); contentServiceProvider.get().setAsDefaultContent(session.getUserHash(), token, @@ -446,7 +453,7 @@ protected void createSetStatusAction(final AccessRolDTO rol, final String textDescription, final ContentStatusDTO status, String[] contentsModerated) { final ActionToolbarMenuRadioDescriptor<StateToken> action = new ActionToolbarMenuRadioDescriptor<StateToken>( - rol, ActionToolbarPosition.topbar, new Listener<StateToken>() { + rol, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { setContentStatus(status, stateToken); } @@ -467,7 +474,7 @@ protected void createShowDeletedItems(String parentMenuTitle, String... registerInTypes) { ActionToolbarMenuCheckItemDescriptor<StateToken> showDeletedItems = new ActionToolbarMenuCheckItemDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener0() { + AccessRolDTO.Editor, CONTEXT_TOPBAR, new Listener0() { public void onEvent() { boolean mustShow = !session.getCurrentUserInfo().getShowDeletedContent(); session.getCurrentUserInfo().setShowDeletedContent(mustShow); @@ -491,7 +498,7 @@ protected ActionToolbarButtonDescriptor<StateToken> createTranslateAction(String... registerInTypes) { ActionToolbarButtonDescriptor<StateToken> translateContent = new ActionToolbarButtonDescriptor<StateToken>( - AccessRolDTO.Editor, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken stateToken) { NotifyUser.important(i18n.t("Sorry, this functionality is currently in development")); } @@ -508,8 +515,8 @@ protected ActionToolbarButtonAndItemDescriptor<StateToken> createUploadAction(final String textDescription, final String iconUrl, final String toolTip, final String permitedExtensions, String... registerInTypes) { final ActionToolbarButtonAndItemDescriptor<StateToken> uploadFile; - uploadFile = new ActionToolbarButtonAndItemDescriptor<StateToken>(AccessRolDTO.Editor, - ActionToolbarPosition.bottombar, new Listener0() { + uploadFile = new ActionToolbarButtonAndItemDescriptor<StateToken>(AccessRolDTO.Editor, CONTEXT_BOTTOMBAR, + new Listener0() { public void onEvent() { if (permitedExtensions != null) { // FIXME: can't be reset ... @@ -547,7 +554,7 @@ @SuppressWarnings("unused") private ActionToolbarMenuAndItemDescriptor<StateToken> createSetGroupLogoAction(String parentMenuTitle) { final ActionToolbarMenuAndItemDescriptor<StateToken> setGroupLogo = new ActionToolbarMenuAndItemDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.topbar, new Listener<StateToken>() { + AccessRolDTO.Administrator, CONTENT_TOPBAR, new Listener<StateToken>() { public void onEvent(final StateToken token) { groupServiceProvider.get().setGroupFullLogo(session.getUserHash(), token, new AsyncCallbackSimple<GroupDTO>() { Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -21,9 +21,7 @@ import org.ourproject.kune.chat.client.ChatEngine; import org.ourproject.kune.platf.client.actions.ActionManager; -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.ApplicationComponentGroup; import org.ourproject.kune.platf.client.app.EntityOptionsGroup; import org.ourproject.kune.platf.client.dto.StateToken; @@ -48,8 +46,9 @@ import org.ourproject.kune.platf.client.state.StateManager; import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils; import org.ourproject.kune.platf.client.ui.noti.NotifyUser; -import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette; +import org.ourproject.kune.platf.client.ui.rte.RTEditor; import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog; +import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources; import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper; import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar; import org.ourproject.kune.workspace.client.cnt.ActionContentToolbarPresenter; @@ -57,16 +56,14 @@ import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator; import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPanel; import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPresenter; -import org.ourproject.kune.workspace.client.cxt.ActionContextToolbar; -import org.ourproject.kune.workspace.client.cxt.ActionContextToolbarPresenter; +import org.ourproject.kune.workspace.client.cxt.ActionContextBottomToolbar; +import org.ourproject.kune.workspace.client.cxt.ActionContextTopToolBar; import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry; import org.ourproject.kune.workspace.client.cxt.ContextPropEditor; import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPanel; import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter; import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView; -import org.ourproject.kune.workspace.client.editor.TextEditor; -import org.ourproject.kune.workspace.client.editor.TextEditorPanel; -import org.ourproject.kune.workspace.client.editor.TextEditorPresenter; +import org.ourproject.kune.workspace.client.editor.ContentEditor; import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElement; import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElementGroup; import org.ourproject.kune.workspace.client.editor.insert.TextEditorInsertElementPanel; @@ -481,16 +478,14 @@ register(Singleton.class, new Factory<ActionGroupSummaryToolbar>(ActionGroupSummaryToolbar.class) { @Override public ActionGroupSummaryToolbar create() { - final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>( - $$(ActionManager.class), $(I18nTranslationService.class)); + final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class)); final ActionGroupSummaryToolbarPresenter toolbar = new ActionGroupSummaryToolbarPresenter(panel); return toolbar; } }, new Factory<ActionParticipationToolbar>(ActionParticipationToolbar.class) { @Override public ActionParticipationToolbar create() { - final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>( - $$(ActionManager.class), $(I18nTranslationService.class)); + final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class)); final ActionParticipationSummaryToolbarPresenter toolbar = new ActionParticipationSummaryToolbarPresenter( panel); return toolbar; @@ -499,7 +494,7 @@ @Override public ActionBuddiesSummaryToolbar create() { final ActionToolbarPanel<UserSimpleDTO> panel = new ActionToolbarPanel<UserSimpleDTO>( - $$(ActionManager.class), $(I18nTranslationService.class)); + $$(ActionManager.class)); final ActionBuddiesSummaryToolbarPresenter toolbar = new ActionBuddiesSummaryToolbarPresenter(panel); return toolbar; } @@ -866,26 +861,6 @@ } }); - register(Singleton.class, new Factory<TextEditor>(TextEditor.class) { - @Override - public TextEditor create() { - final ActionCntCtxToolbarPanel<StateToken> contentNavigatorToolbar = new ActionCntCtxToolbarPanel<StateToken>( - ActionCntCtxToolbarPanel.Position.content, $$(ActionManager.class), $(WorkspaceSkeleton.class), - $(I18nTranslationService.class)); - final ActionToolbar<StateToken> toolbar = new ActionToolbarPresenter<StateToken>( - contentNavigatorToolbar); - - final TextEditorPresenter presenter = new TextEditorPresenter(true, toolbar, - $(I18nUITranslationService.class), $(StateManager.class), $(SiteSignOutLink.class), - $(DeferredCommandWrapper.class)); - final TextEditorPanel panel = new TextEditorPanel(presenter, $(I18nTranslationService.class), - $(WorkspaceSkeleton.class), $(ColorWebSafePalette.class), $(TextEditorInsertElement.class), - false); - presenter.init(panel); - return presenter; - } - }); - register(Singleton.class, new Factory<LanguageSelector>(LanguageSelector.class) { @Override public LanguageSelector create() { @@ -924,32 +899,52 @@ register(NoDecoration.class, new Factory<ActionContentToolbar>(ActionContentToolbar.class) { @Override public ActionContentToolbar create() { - final ActionCntCtxToolbarPanel<StateToken> contentNavigatorToolbar = new ActionCntCtxToolbarPanel<StateToken>( - ActionCntCtxToolbarPanel.Position.content, $$(ActionManager.class), $(WorkspaceSkeleton.class), - $(I18nTranslationService.class)); - final ActionContentToolbar toolbar = new ActionContentToolbarPresenter(contentNavigatorToolbar); + final ActionCntCtxToolbarPanel<StateToken> tbar = new ActionCntCtxToolbarPanel<StateToken>( + AbstractFoldableContentActions.CONTENT_TOPBAR, $$(ActionManager.class), + $(WorkspaceSkeleton.class)); + final ActionContentToolbar toolbar = new ActionContentToolbarPresenter(tbar); return toolbar; } }); - register(NoDecoration.class, new Factory<ActionContextToolbar>(ActionContextToolbar.class) { + register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) { @Override - public ActionContextToolbar create() { - final ActionCntCtxToolbarPanel<StateToken> contentNavigatorToolbar = new ActionCntCtxToolbarPanel<StateToken>( - ActionCntCtxToolbarPanel.Position.context, $$(ActionManager.class), $(WorkspaceSkeleton.class), - $(I18nTranslationService.class)); - final ActionContextToolbar toolbar = new ActionContextToolbarPresenter(contentNavigatorToolbar); + public ContentEditor create() { + return new ContentEditor($(RTEditor.class), true, $(I18nTranslationService.class), + $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class), + $(RTEImgResources.class), $(WorkspaceSkeleton.class)); + } + }); + register(NoDecoration.class, new Factory<ActionContextTopToolBar>(ActionContextTopToolBar.class) { + @Override + public ActionContextTopToolBar create() { + final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>( + AbstractFoldableContentActions.CONTEXT_TOPBAR, $$(ActionManager.class), + $(WorkspaceSkeleton.class)); + final ActionContextTopToolBar toolbar = new ActionContextTopToolBar(panel); return toolbar; } }); + register(NoDecoration.class, new Factory<ActionContextBottomToolbar>(ActionContextBottomToolbar.class) { + @Override + public ActionContextBottomToolbar create() { + final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>( + AbstractFoldableContentActions.CONTEXT_BOTTOMBAR, $$(ActionManager.class), + $(WorkspaceSkeleton.class)); + final ActionContextBottomToolbar toolbar = new ActionContextBottomToolbar(panel); + return toolbar; + } + }); + register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) { @Override public ContextNavigator create() { final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class), $(Session.class), $(I18nTranslationService.class), $(ContentIconsRegistry.class), - $(ContentCapabilitiesRegistry.class), $(ActionContextToolbar.class), - $(ContextActionRegistry.class), $$(FileDownloadUtils.class), true, $(RenameAction.class)); + $(ContentCapabilitiesRegistry.class), $(ActionContextTopToolBar.class), + $(ActionContextBottomToolbar.class), $(ContextActionRegistry.class), + $$(FileDownloadUtils.class), true, $(RenameAction.class)); final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter, $(I18nTranslationService.class), $(WorkspaceSkeleton.class), $(ActionManager.class)); presenter.init(panel); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/cnt/FoldableContentPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -32,6 +32,7 @@ import org.ourproject.kune.platf.client.state.StateManager; import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils; import org.ourproject.kune.platf.client.ui.download.ImageSize; +import org.ourproject.kune.workspace.client.AbstractFoldableContentActions; import com.calclab.suco.client.events.Listener; import com.calclab.suco.client.ioc.Provider; @@ -138,7 +139,8 @@ private void setToolbar(ActionItemCollection<StateToken> collection) { toolbar.disableMenusAndClearButtons(); - toolbar.addActions(collection); + toolbar.addActions(collection, AbstractFoldableContentActions.CONTENT_TOPBAR); + ; toolbar.attach(); } 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -44,7 +44,9 @@ import org.ourproject.kune.platf.client.ui.KuneUiUtils; import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils; import org.ourproject.kune.platf.client.ui.download.ImageSize; +import org.ourproject.kune.workspace.client.AbstractFoldableContentActions; import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry; +import org.ourproject.kune.workspace.client.cxt.ActionContextBottomToolbar; import org.ourproject.kune.workspace.client.title.RenameAction; import org.ourproject.kune.workspace.client.upload.FileUploader; @@ -63,24 +65,26 @@ private boolean editOnNextStateChange; private final ContentIconsRegistry contentIconsRegistry; private final ActionRegistry<StateToken> actionRegistry; - private final ActionToolbar<StateToken> toolbar; + private final ActionToolbar<StateToken> topToolbar; private final Provider<FileDownloadUtils> downloadUtilsProvider; private final boolean useGenericImageIcon; private final ContentCapabilitiesRegistry capabilitiesRegistry; private final RenameAction renameAction; + private final ActionContextBottomToolbar bottomToolbar; public ContextNavigatorPresenter(final StateManager stateManager, final Session session, final I18nTranslationService i18n, final ContentIconsRegistry contentIconsRegistry, ContentCapabilitiesRegistry capabilitiesRegistry, final ActionToolbar<StateToken> toolbar, - final ActionRegistry<StateToken> actionRegistry, Provider<FileDownloadUtils> downloadUtilsProvider, - boolean useGenericImageIcon, RenameAction renameAction) { + ActionContextBottomToolbar bottomToolbar, final ActionRegistry<StateToken> actionRegistry, + Provider<FileDownloadUtils> downloadUtilsProvider, boolean useGenericImageIcon, RenameAction renameAction) { this.stateManager = stateManager; this.session = session; this.i18n = i18n; this.contentIconsRegistry = contentIconsRegistry; this.capabilitiesRegistry = capabilitiesRegistry; + this.topToolbar = toolbar; + this.bottomToolbar = bottomToolbar; this.actionRegistry = actionRegistry; - this.toolbar = toolbar; this.downloadUtilsProvider = downloadUtilsProvider; this.useGenericImageIcon = useGenericImageIcon; this.renameAction = renameAction; @@ -103,18 +107,21 @@ // FIXME At the moment detach (removeFromParent) destroy the gwt-ext // TreePanel and the widget must be recreated (cannot be attached again // like in gwt) - toolbar.attach(); + topToolbar.attach(); + bottomToolbar.attach(); } public void clear() { - toolbar.clear(); + topToolbar.clear(); + bottomToolbar.clear(); view.clear(); actionsByItem.clear(); } public void detach() { view.detach(); - toolbar.detach(); + topToolbar.detach(); + bottomToolbar.detach(); } public void editItem(final StateToken stateToken) { @@ -139,8 +146,11 @@ public void selectItem(final StateToken stateToken) { view.selectItem(genId(stateToken)); - toolbar.disableMenusAndClearButtons(); - toolbar.addActions(actionsByItem.get(stateToken)); + topToolbar.disableMenusAndClearButtons(); + bottomToolbar.disableMenusAndClearButtons(); + ActionItemCollection<StateToken> itemCollection = actionsByItem.get(stateToken); + topToolbar.addActions(itemCollection, AbstractFoldableContentActions.CONTEXT_TOPBAR); + bottomToolbar.addActions(itemCollection, AbstractFoldableContentActions.CONTEXT_BOTTOMBAR); } public void setEditOnNextStateChange(final boolean edit) { @@ -324,7 +334,8 @@ selectOrEditNode(select, stateToken); - toolbar.attach(); + topToolbar.attach(); + bottomToolbar.attach(); } private void showRootFolder(final StateContainerDTO state, final AccessRightsDTO containerRights) { Added: trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextBottomToolbar.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextBottomToolbar.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextBottomToolbar.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,32 @@ +/* + * + * Copyright (C) 2007-2009 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.workspace.client.cxt; + +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; +import org.ourproject.kune.platf.client.dto.StateToken; + +public class ActionContextBottomToolbar extends ActionToolbarPresenter<StateToken> implements ActionToolbar<StateToken> { + + public ActionContextBottomToolbar(ActionToolbarView<StateToken> toolbar) { + super(toolbar); + } +} \ No newline at end of file Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbar.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbar.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbar.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,27 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.cxt; - -import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; -import org.ourproject.kune.platf.client.dto.StateToken; - -public interface ActionContextToolbar extends ActionToolbar<StateToken> { - -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,32 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.cxt; - -import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter; -import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; -import org.ourproject.kune.platf.client.dto.StateToken; - -public class ActionContextToolbarPresenter extends ActionToolbarPresenter<StateToken> implements ActionContextToolbar { - - public ActionContextToolbarPresenter(ActionToolbarView<StateToken> toolbar) { - super(toolbar); - } - -} Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextTopToolBar.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java) =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextToolbarPresenter.java 2009-03-03 01:35:36 UTC (rev 1055) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/cxt/ActionContextTopToolBar.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,33 @@ +/* + * + * Copyright (C) 2007-2009 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.workspace.client.cxt; + +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; +import org.ourproject.kune.platf.client.dto.StateToken; + +public class ActionContextTopToolBar extends ActionToolbarPresenter<StateToken> implements ActionToolbar<StateToken> { + + public ActionContextTopToolBar(ActionToolbarView<StateToken> toolbar) { + super(toolbar); + } + +} Added: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -0,0 +1,74 @@ +package org.ourproject.kune.workspace.client.editor; + +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; +import org.ourproject.kune.platf.client.i18n.I18nTranslationService; +import org.ourproject.kune.platf.client.state.StateManager; +import org.ourproject.kune.platf.client.ui.SimpleToolbar; +import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter; +import org.ourproject.kune.platf.client.ui.rte.RTEditor; +import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel; +import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources; +import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper; +import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink; +import org.ourproject.kune.workspace.client.skel.Toolbar; +import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; + +import com.calclab.suco.client.events.Listener; +import com.calclab.suco.client.events.Listener0; +import com.google.gwt.user.client.ui.VerticalPanel; +import com.gwtext.client.widgets.BoxComponent; +import com.gwtext.client.widgets.event.ContainerListenerAdapter; + +public class ContentEditor extends RTESavingEditorPresenter { + + private final WorkspaceSkeleton ws; + private final VerticalPanel vp; + private final RTEditor basicEditor; + private final RTEditorPanel editorPanel; + private final SimpleToolbar topbar; + + public ContentEditor(RTEditor editor, boolean autoSave, I18nTranslationService i18n, StateManager stateManager, + SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper, + RTEImgResources imgResources, WorkspaceSkeleton ws) { + super(editor, autoSave, i18n, stateManager, siteSignOutLink, deferredCommandWrapper, imgResources); + this.ws = ws; + + vp = new VerticalPanel(); + basicEditor = super.getBasicEditor(); + vp.add(((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar()); + editorPanel = (RTEditorPanel) basicEditor.getEditorArea(); + vp.add(editorPanel.getRTE()); + basicEditor.setExtended(true); + vp.setWidth("100%"); + adjHeight(ws.getEntityWorkspace().getContentHeight()); + ws.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() { + @Override + public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight, + final int rawWidth, final int rawHeight) { + adjHeight(adjHeight); + } + }); + topbar = ((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar(); + } + + @Override + public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) { + Toolbar contentTopBar = ws.getEntityWorkspace().getContentTopBar(); + contentTopBar.removeAll(); + contentTopBar.add(topbar); + ws.getEntityWorkspace().setContent(vp); + super.edit(html, onSave, onEditCancelled); + } + + @Override + protected void onCancelConfirmed() { + ws.getEntityWorkspace().clearContent(); + super.onCancelConfirmed(); + } + + private void adjHeight(final int height) { + int newHeight = height - WorkspaceSkeleton.DEF_TOOLBAR_HEIGHT - 27; + editorPanel.adjustSize(newHeight); + vp.setCellHeight(editorPanel.getRTE(), "" + newHeight); + } +} Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -23,7 +23,6 @@ import org.ourproject.kune.platf.client.actions.ActionItemCollection; import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.BeforeActionListener; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; import org.ourproject.kune.platf.client.dto.AccessRolDTO; @@ -48,7 +47,7 @@ private boolean saveAndCloseConfirmed; private Listener<String> onSave; private Listener0 onEditCancelled; - private final ActionToolbar<StateToken> toolbar; + private final ActionToolbar<StateToken> topToolbar; private ActionToolbarMenuDescriptor<StateToken> save; private ActionToolbarButtonDescriptor<StateToken> close; private final I18nUITranslationService i18n; @@ -57,10 +56,10 @@ private final SiteSignOutLink siteSignOutLink; private final DeferredCommandWrapper deferredCommandWrapper; - public TextEditorPresenter(final boolean isAutoSave, final ActionToolbar<StateToken> toolbar, + public TextEditorPresenter(final boolean isAutoSave, final ActionToolbar<StateToken> topToolbar, final I18nUITranslationService i18n, StateManager stateManager, SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper) { - this.toolbar = toolbar; + this.topToolbar = topToolbar; this.autoSave = isAutoSave; this.i18n = i18n; this.stateManager = stateManager; @@ -81,7 +80,7 @@ public void editContent(final String content, final Listener<String> onSave, final Listener0 onEditCancelled) { this.onSave = onSave; this.onEditCancelled = onEditCancelled; - toolbar.attach(); + topToolbar.attach(); view.attach(); setContent(content); stateManager.addBeforeStateChangeListener(beforeStateChangeListener); @@ -137,7 +136,7 @@ stateManager.resumeTokenChange(); reset(); view.detach(); - toolbar.detach(); + topToolbar.detach(); onEditCancelled.onEvent(); } @@ -176,23 +175,21 @@ } private void createActions() { - save = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Viewer, ActionToolbarPosition.topbar, - new Listener<StateToken>() { - public void onEvent(final StateToken token) { - onSave(); - } - }); + save = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() { + public void onEvent(final StateToken token) { + onSave(); + } + }); save.setTextDescription(i18n.tWithNT("Save", "used in button")); save.setParentMenuTitle(i18n.t("File")); save.setId(SAVE_ID); // save.setIconUrl("images/"); - close = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, ActionToolbarPosition.topbar, - new Listener<StateToken>() { - public void onEvent(final StateToken token) { - onCancel(); - } - }); + close = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() { + public void onEvent(final StateToken token) { + onCancel(); + } + }); close.setTextDescription(i18n.tWithNT("Close", "used in button")); close.setId(CLOSE_ID); // close.setIconUrl("images/"); @@ -200,7 +197,7 @@ final ActionItemCollection<StateToken> collection = new ActionItemCollection<StateToken>(); collection.add(new ActionItem<StateToken>(save, null)); collection.add(new ActionItem<StateToken>(close, null)); - toolbar.addActions(collection); + topToolbar.addActions(collection, null); } private void reset() { Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplIE6.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,67 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.editor; - -import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplIE6; - -/** - * A wrapper used to inject css into RTA. As published in: - * - * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ - * f64c0024d8676a66 - * /d5f26a54145fc5d4?lnk=st&q=richtextarea+style#d5f26a54145fc5d4 - * - * FIXME: Only for IE and Mozilla - * - */ -public class WrappedRichTextAreaImplIE6 extends RichTextAreaImplIE6 { - - @Override - public native void initElement() /*-{ - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - - setTimeout(function() { - if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) { - return; - } - - // Attempt to set the iframe document's body to 'contentEditable' mode. - // There's no way to know when the body will actually be available, so - // keep trying every so often until it is. - // Note: The body seems to be missing only rarely, so please don't remove - // this retry loop just because it's hard to reproduce. - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - if (!doc.body) { - // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower - // would increase the probability of a user-visible delay. - setTimeout(arguments.callee, 50); - return; - } - var ct = "<html><head><style>@import url('" + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - doc.body.contentEditable = true; - - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplMozilla.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,76 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.editor; - -import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplMozilla; - -/** - * A wrapper used to inject css into RTA. As published in: - * - * http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ - * f64c0024d8676a66 - * /d5f26a54145fc5d4?lnk=st&q=richtextarea+style#d5f26a54145fc5d4 - * - * FIXME: Only for IE and Mozilla - * - */ -public class WrappedRichTextAreaImplMozilla extends RichTextAreaImplMozilla { - - @Override - public native void initElement() /*-{ - // Mozilla doesn't allow designMode to be set reliably until the iframe is - // fully loaded. - var _this = this; - var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - - iframe.onload = function() { - // Some Mozillae have the nasty habit of calling onload again when you set - // designMode, so let's avoid doing it more than once. - iframe.onload = null; - - // patch ccs inject: - - var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document; - head=doc.getElementsByTagName('head')[0]; - link=document.createElement('link'); - link.setAttribute('rel',"stylesheet"); - link.setAttribute('type',"text/css"); - link.setAttribute('href',$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" ); - head.appendChild(link); - - // -- patch - - // Send notification that the iframe has finished loading. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - - // Don't set designMode until the RTA actually gets focused. This is - // necessary because editing won't work on Mozilla if the iframe is - // *hidden, but attached*. Waiting for focus gets around this issue. - // - // Note: This onfocus will not conflict with the addEventListener('focus', - // ...) // in RichTextAreaImplStandard. - iframe.contentWindow.onfocus = function() { - iframe.contentWindow.onfocus = null; - iframe.contentWindow.document.designMode = 'On'; - }; - }; - }-*/; -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplOpera.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,48 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.editor; - -import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplOpera; - -public class WrappedRichTextAreaImplOpera extends RichTextAreaImplOpera { - - @Override - public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch - - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; - -} Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/WrappedRichTextAreaImplSafari.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -1,49 +0,0 @@ -/* - * - * Copyright (C) 2007-2009 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.workspace.client.editor; - -import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplSafari; - -public class WrappedRichTextAreaImplSafari extends RichTextAreaImplSafari { - - @Override - public native void initElement() /*-{ - // Most browsers don't like setting designMode until slightly _after_ - // the iframe becomes attached to the DOM. Any non-zero timeout will do - // just fine. - var _this = this; - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true; - setTimeout(function() { - // Turn on design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On'; - - // patch css inject: - var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem; - var doc = elem.contentWindow.document; - var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ; - doc.write( ct ); - // -- patch - - // Send notification that the iframe has reached design mode. - _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()(); - }, 1); - }-*/; - -} Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -21,12 +21,12 @@ import org.ourproject.kune.platf.client.View; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.dto.AccessRolDTO; import org.ourproject.kune.platf.client.dto.UserSimpleDTO; import org.ourproject.kune.platf.client.i18n.I18nTranslationService; import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked; import org.ourproject.kune.platf.client.ui.noti.NotifyUser; +import org.ourproject.kune.workspace.client.AbstractFoldableContentActions; import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton; import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry; @@ -108,7 +108,7 @@ **/ private void createActions() { ActionToolbarMenuDescriptor<UserSimpleDTO> helloWorldBuddiesAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>( - AccessRolDTO.Viewer, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() { + AccessRolDTO.Viewer, AbstractFoldableContentActions.CONTENT_TOPBAR, new Listener<UserSimpleDTO>() { public void onEvent(UserSimpleDTO parameter) { // We clicked: view.showMessage(); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/ActionCntCtxToolbarPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/ActionCntCtxToolbarPanel.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/ActionCntCtxToolbarPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -20,58 +20,44 @@ package org.ourproject.kune.workspace.client.skel; import org.ourproject.kune.platf.client.actions.ActionManager; +import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; -import org.ourproject.kune.platf.client.i18n.I18nTranslationService; +import org.ourproject.kune.workspace.client.AbstractFoldableContentActions; import com.calclab.suco.client.ioc.Provider; public class ActionCntCtxToolbarPanel<T> extends ActionToolbarPanel<T> { - public enum Position { - content, context - } + Toolbar wsToolbar; - private final Position position; - private final WorkspaceSkeleton ws; + public ActionCntCtxToolbarPanel(ActionToolbarPosition position, + final Provider<ActionManager> actionManagerProvider, final WorkspaceSkeleton ws) { + super(actionManagerProvider); + EntityWorkspace entityWorkspace = ws.getEntityWorkspace(); + if (position.equals(AbstractFoldableContentActions.CONTENT_TOPBAR)) { + wsToolbar = entityWorkspace.getContentTopBar(); + } else if (position.equals(AbstractFoldableContentActions.CONTENT_BOTTOMBAR)) { + wsToolbar = entityWorkspace.getContentBottomBar(); + } else if (position.equals(AbstractFoldableContentActions.CONTEXT_TOPBAR)) { + wsToolbar = entityWorkspace.getContextTopBar(); + } else if (position.equals(AbstractFoldableContentActions.CONTEXT_BOTTOMBAR)) { + wsToolbar = entityWorkspace.getContextBottomBar(); + } - public ActionCntCtxToolbarPanel(final Position position, final Provider<ActionManager> actionManagerProvider, - final WorkspaceSkeleton ws, I18nTranslationService i18n) { - super(actionManagerProvider, i18n); - this.position = position; - this.ws = ws; } @Override public void attach() { - if (!topbar.isAttached()) { - switch (position) { - case content: - ws.getEntityWorkspace().getContentTopBar().removeAll(); - ws.getEntityWorkspace().getContentTopBar().add(topbar); - ws.getEntityWorkspace().getContentBottomBar().add(bottombar); - break; - case context: - default: - ws.getEntityWorkspace().getContextTopBar().removeAll(); - ws.getEntityWorkspace().getContextTopBar().add(topbar); - ws.getEntityWorkspace().getContextBottomBar().add(bottombar); - } + if (!toolbar.isAttached()) { + wsToolbar.removeAll(); + wsToolbar.add(toolbar); } } @Override public void detach() { - if (topbar.isAttached()) { - switch (position) { - case content: - ws.getEntityWorkspace().getContentTopBar().remove(topbar); - ws.getEntityWorkspace().getContentBottomBar().remove(bottombar); - break; - case context: - default: - ws.getEntityWorkspace().getContextTopBar().remove(topbar); - ws.getEntityWorkspace().getContextBottomBar().remove(bottombar); - } + if (toolbar.isAttached()) { + wsToolbar.remove(toolbar); } } } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -157,6 +157,14 @@ cntCtxBorderLayout.addListener(containerListenerAdapter); } + public void clearContent() { + content.clear(); + } + + public void clearContext() { + content.clear(); + } + public SimpleToolbar getBottomTitle() { return bottom; } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummary.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummary.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummary.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -19,6 +19,6 @@ \*/ package org.ourproject.kune.workspace.client.socialnet; + public interface BuddiesSummary { - } Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPanel.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -23,7 +23,6 @@ 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.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.MenuItemsContainer; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; @@ -64,7 +63,7 @@ otherBuddiesLabel.addStyleName("kune-Margin-Small-trbl"); vp.add(flowPanel); vp.add(otherBuddiesLabel); - toolbar = ((ActionToolbarPanel<UserSimpleDTO>) actionToolbarView).getToolbar(ActionToolbarPosition.bottombar); + toolbar = ((ActionToolbarPanel<UserSimpleDTO>) actionToolbarView).getToolbar(); toolbar.setCleanStyle(); vp.add(toolbar); super.add(vp); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/BuddiesSummaryPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -27,8 +27,8 @@ import org.ourproject.kune.platf.client.actions.ActionMenuItemDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.RadioMustBeChecked; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; import org.ourproject.kune.platf.client.dto.AccessRightsDTO; import org.ourproject.kune.platf.client.dto.AccessRolDTO; import org.ourproject.kune.platf.client.dto.SocialNetworkDataDTO; @@ -134,7 +134,7 @@ } toolbar.disableMenusAndClearButtons(); toolbar.addActions(actionRegistry.getCurrentActions(session.getCurrentUser(), session.isLogged(), - state.getGroupRights(), true)); + state.getGroupRights(), true), ActionToolbar.IN_ANY); toolbar.attach(); view.show(); } else { @@ -148,7 +148,7 @@ private void createAddNewBuddiesAction() { ActionToolbarMenuDescriptor<UserSimpleDTO> addNewBuddiesAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>( - AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() { + AccessRolDTO.Administrator, buddiesBottom, new Listener<UserSimpleDTO>() { public void onEvent(UserSimpleDTO parameter) { NotifyUser.info("In development"); } @@ -161,7 +161,7 @@ private void createSetBuddiesVisibilityAction(String textDescription, final UserBuddiesVisibilityDTO visibility) { ActionToolbarMenuRadioDescriptor<UserSimpleDTO> buddiesVisibilityAction = new ActionToolbarMenuRadioDescriptor<UserSimpleDTO>( - AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<UserSimpleDTO>() { + AccessRolDTO.Administrator, buddiesBottom, new Listener<UserSimpleDTO>() { public void onEvent(UserSimpleDTO parameter) { userServiceAsync.get().setBuddiesVisibility(session.getUserHash(), session.getCurrentState().getGroup().getStateToken(), visibility, Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPanel.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -20,7 +20,6 @@ package org.ourproject.kune.workspace.client.socialnet; import org.ourproject.kune.platf.client.PlatfMessages; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; import org.ourproject.kune.platf.client.dto.GroupDTO; @@ -78,7 +77,7 @@ noMembersPublic.setVisible(false); super.add(noMembersPublic); - toolbar = ((ActionToolbarPanel<StateToken>) actionToolbarView).getToolbar(ActionToolbarPosition.bottombar); + toolbar = ((ActionToolbarPanel<StateToken>) actionToolbarView).getToolbar(); toolbar.setCleanStyle(); super.add(toolbar); super.addInSummary(); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/GroupMembersSummaryPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -24,8 +24,8 @@ import org.ourproject.kune.chat.client.ChatEngine; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor; import org.ourproject.kune.platf.client.actions.ActionToolbarMenuRadioDescriptor; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.RadioMustBeChecked; +import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar; import org.ourproject.kune.platf.client.dto.AccessListsDTO; import org.ourproject.kune.platf.client.dto.AccessRightsDTO; import org.ourproject.kune.platf.client.dto.AccessRolDTO; @@ -97,7 +97,7 @@ setState(state); toolbar.disableMenusAndClearButtons(); toolbar.addActions(groupActionRegistry.getCurrentActions(state.getGroup().getStateToken(), - session.isLogged(), state.getGroupRights(), true)); + session.isLogged(), state.getGroupRights(), true), ActionToolbar.IN_ANY); toolbar.attach(); } }; @@ -157,7 +157,7 @@ private void createActions() { ActionToolbarMenuDescriptor<StateToken> addMember = new ActionToolbarMenuDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<StateToken>() { + AccessRolDTO.Administrator, membersBottom, new Listener<StateToken>() { public void onEvent(StateToken parameter) { liveSearcherProvider.get().onSelection(new Listener<LinkDTO>() { public void onEvent(final LinkDTO link) { @@ -185,7 +185,7 @@ private void createNewMembersPolicyAction(String textDescription, final AdmissionTypeDTO admissionPolicy) { ActionToolbarMenuRadioDescriptor<StateToken> newMembersPolicy = new ActionToolbarMenuRadioDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<StateToken>() { + AccessRolDTO.Administrator, membersBottom, new Listener<StateToken>() { public void onEvent(StateToken parameter) { groupServiceProvider.get().setGroupNewMembersJoiningPolicy(session.getUserHash(), session.getCurrentState().getGroup().getStateToken(), admissionPolicy, @@ -209,7 +209,7 @@ private void createSetMembersVisibilityAction(String textDescription, final SocialNetworkVisibilityDTO visibility) { ActionToolbarMenuRadioDescriptor<StateToken> showMembers = new ActionToolbarMenuRadioDescriptor<StateToken>( - AccessRolDTO.Administrator, ActionToolbarPosition.bottombar, new Listener<StateToken>() { + AccessRolDTO.Administrator, membersBottom, new Listener<StateToken>() { public void onEvent(StateToken parameter) { groupServiceProvider.get().setSocialNetworkVisibility(session.getUserHash(), session.getCurrentState().getGroup().getStateToken(), visibility, Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/ParticipationSummaryPanel.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/ParticipationSummaryPanel.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/ParticipationSummaryPanel.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -19,7 +19,6 @@ */ package org.ourproject.kune.workspace.client.socialnet; -import org.ourproject.kune.platf.client.actions.ActionToolbarPosition; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel; import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView; import org.ourproject.kune.platf.client.dto.GroupDTO; @@ -54,7 +53,7 @@ // gridMenuPanel.onClick(go); gridMenuPanel.onDoubleClick(go); super.add(gridMenuPanel); - toolbar = ((ActionToolbarPanel<StateToken>) actionToolbarView).getToolbar(ActionToolbarPosition.bottombar); + toolbar = ((ActionToolbarPanel<StateToken>) actionToolbarView).getToolbar(); toolbar.setCleanStyle(); super.add(toolbar); addInSummary(); Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java =================================================================== --- trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/main/java/org/ourproject/kune/workspace/client/socialnet/SocialNetworkPresenter.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -48,6 +48,9 @@ public class SocialNetworkPresenter { + protected final ActionToolbarPosition membersBottom = new ActionToolbarPosition("sn-bottomtoolbar"); + protected final ActionToolbarPosition buddiesBottom = new ActionToolbarPosition("sn-bottomtoolbar"); + protected MenuItem<GroupDTO> changeToCollabMenuItem; protected MenuItem<GroupDTO> removeMemberMenuItem; protected MenuItem<GroupDTO> changeToAdminMenuItem; @@ -139,8 +142,8 @@ } private void createButtons() { - participate = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, - ActionToolbarPosition.bottombar, new Listener<StateToken>() { + participate = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, membersBottom, + new Listener<StateToken>() { public void onEvent(StateToken parameter) { NotifyUser.showProgressProcessing(); snServiceProvider.get().requestJoinGroup(session.getUserHash(), @@ -174,7 +177,7 @@ } }); - unJoin = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Editor, ActionToolbarPosition.bottombar, + unJoin = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Editor, membersBottom, new Listener<StateToken>() { public void onEvent(StateToken parameter) { removeMemberAction(); 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 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionRegistryTest.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -15,6 +15,7 @@ public class ActionRegistryTest { private static final String DEF_CONTENT_TYPE_ID = "test"; + private static final ActionToolbarPosition SOME_ID = new ActionToolbarPosition("some-id"); private ActionRegistry<StateToken> registry; private ActionToolbarMenuAndItemDescriptor<StateToken> adminAction; private ActionToolbarMenuAndItemDescriptor<StateToken> editorAction; @@ -36,13 +37,13 @@ public void before() { session = Mockito.mock(Session.class); registry = new ActionRegistry<StateToken>(); - adminAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Administrator, - ActionToolbarPosition.topbar, new Listener<StateToken>() { + adminAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Administrator, SOME_ID, + new Listener<StateToken>() { public void onEvent(final StateToken parameter) { } }); - editorAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, - ActionToolbarPosition.topbar, new Listener<StateToken>() { + editorAction = new ActionToolbarMenuAndItemDescriptor<StateToken>(AccessRolDTO.Editor, SOME_ID, + new Listener<StateToken>() { public void onEvent(final StateToken parameter) { } }); Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java =================================================================== --- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-09 23:32:38 UTC (rev 1063) +++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-10 00:05:50 UTC (rev 1064) @@ -5,18 +5,15 @@ import org.junit.Before; import org.junit.Test; -import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked; import com.google.gwt.user.client.ui.KeyboardListener; public class ActionShortcutTest { - private I18nTranslationServiceMocked i18n; - @Test public void altS() { ActionShortcut shortcut = new ActionShortcut(true, false, false, 'S', null); - assertEquals(" (Alt+S)", shortcut.toString(i18n)); + assertEquals(" (Alt+S)", shortcut.toString()); assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_ALT)); assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_CTRL)); assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_SHIFT)); @@ -24,13 +21,12 @@ @Before public void before() { - i18n = new I18nTranslationServiceMocked(); } @Test public void ctrl_coma() { ActionShortcut shortcut = new ActionShortcut(true, ','); - assertEquals(" (Ctrl+,)", shortcut.toString(i18n)); + assertEquals(" (Ctrl+,)", shortcut.toString()); assertTrue(shortcut.is(',', KeyboardListener.MODIFIER_CTRL)); assertTrue(!shortcut.is(',', KeyboardListener.MODIFIER_ALT)); assertTrue(!shortcut.is(',', KeyboardListener.MODIFIER_SHIFT)); @@ -39,7 +35,7 @@ @Test public void ctrl_s() { ActionShortcut shortcut = new ActionShortcut(true, 's'); - assertEquals(" (Ctrl+S)", shortcut.toString(i18n)); + assertEquals(" (Ctrl+S)", shortcut.toString()); assertTrue(shortcut.is('s', KeyboardListener.MODIFIER_CTRL)); assertTrue(!shortcut.is('s', KeyboardListener.MODIFIER_ALT)); assertTrue(!shortcut.is('s', KeyboardListener.MODIFIER_SHIFT)); @@ -48,7 +44,7 @@ @Test public void ctrlS() { ActionShortcut shortcut = new ActionShortcut(true, 'S'); - assertEquals(" (Ctrl+S)", shortcut.toString(i18n)); + assertEquals(" (Ctrl+S)", shortcut.toString()); assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_CTRL)); assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT)); assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_SHIFT)); @@ -57,7 +53,7 @@ @Test public void ctrlShiftS() { ActionShortcut shortcut = new ActionShortcut(false, true, true, 'S', null); - assertEquals(" (Ctrl+Shift+S)", shortcut.toString(i18n)); + assertEquals(" (Ctrl+Shift+S)", shortcut.toString()); assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT)); assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_SHIFT | KeyboardListener.MODIFIER_CTRL)); }
participants (1)
-
vjrj