[kune-commits] r1123 - in trunk: .
src/main/java/org/ourproject/kune/app/public/css
src/main/java/org/ourproject/kune/platf/client/actions
src/main/java/org/ourproject/kune/platf/client/actions/ui
src/main/java/org/ourproject/kune/platf/client/services
src/main/java/org/ourproject/kune/platf/client/shortcuts
src/main/java/org/ourproject/kune/platf/client/ui/rte
src/main/java/org/ourproject/kune/platf/client/ui/rte/basic
src/main/java/org/ourproject/kune/platf/client/ui/rte/saving
src/main/java/org/ourproject/kune/platf/public/images
src/main/java/org/ourproject/kune/platf/server/manager/file
src/main/java/org/ourproject/kune/workspace/client
src/main/java/org/ourproject/kune/workspace/client/editor
src/test/java/org/ourproject/kune/platf/client/actions
src/test/java/org/ourproject/kune/platf/client/ui/rte/saving
vjrj
vjrj at ourproject.org
Tue Jun 9 20:56:59 CEST 2009
Author: vjrj
Date: 2009-06-09 20:56:54 +0200 (Tue, 09 Jun 2009)
New Revision: 1123
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescCollection.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/AbstractRTEAction.java
trunk/src/main/java/org/ourproject/kune/platf/public/images/charfontname.png
trunk/src/main/java/org/ourproject/kune/platf/public/images/fontheight.png
trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java
Modified:
trunk/pom.xml
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/platf/client/actions/ActionManager.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBindingAdapter.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/Keyboard.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/basic/RTELinkPopup.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorNew.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java
Log:
Incomplete - task New Action class (adapted from Swing) to replace ActionDescription
Incomplete - task gwt-ext 2.0.6
Incomplete - task upgrade to gwt 1.6.4
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/pom.xml 2009-06-09 18:56:54 UTC (rev 1123)
@@ -80,7 +80,7 @@
<dependency>
<groupId>com.gwtext</groupId>
<artifactId>gwtext</artifactId>
- <version>2.0.5</version>
+ <version>2.0.6-r1872</version>
</dependency>
<dependency>
<groupId>com.gwtextux</groupId>
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-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-06-09 18:56:54 UTC (rev 1123)
@@ -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:left;padding:3px;cursor:pointer;color:#00F;}.k-tsp-cloud{line-height:1.5em;text-align:center;}.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-film-icon{background-image:url(img/film.png)!important;}.k-specialchars-icon{background-image:url(img/specialchars.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:1px;background-color:#D7FFD7;}.k-specialchar-grid{border:1px solid #ACA899;}.k-specialchar-grid table{}.k-specialchar-grid div{line-height:22px;}.k-specialchar-grid td{padding:1px;}.k-specialchar-pb{border:1px solid #EBE8D7;cursor:pointer;font-size:108%!important;text-align:center;vertical-align:middle;width:18px;height:18px;}.k-specialchar-pb-up{}.k-specialchar-big{padding:3px;line-height:22px;font-size:197%!important;}.k-specialchar-adv-label{margin-left:-10px;}.k-specialchar-popup,{border:1px px solid silver;z-index:9999!important;background-color:#FFF;}.k-specialchar-pb-down{color:#161616;}.k-specialchar-pb-up-hovering{border:thin solid #ACA899;}.k-specialchar-pb-down-hovering{color:#161616;}.k-preview-panel{border:dashed 1px gray;padding:5px;}.k-rte-changelink{white-space:nowrap;color:navy;cursor:pointer;text-decoration:underline;margin:5px;}.k-rte-changelink-popup{border:1px solid silver;z-index:9999!important;background-color:#ECECEC;}.e-ui-room{height:27px;line-height:22px;}.e-ui-room input{font-size:100%;margin-left:0;margin-top:0;}.k-def-popup{z-index:9999!important;background-color:#FFF;border:1px solid gray;}
\ 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:left;padding:3px;cursor:pointer;color:#00F;}.k-tsp-cloud{line-height:1.5em;text-align:center;}.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-film-icon{background-image:url(img/film.png)!important;}.k-specialchars-icon{background-image:url(img/specialchars.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:1px;background-color:#D7FFD7;}.k-specialchar-grid{border:1px solid #ACA899;}.k-specialchar-grid table{}.k-specialchar-grid div{line-height:22px;}.k-specialchar-grid td{padding:1px;}.k-specialchar-pb{border:1px solid #EBE8D7;cursor:pointer;font-size:108%!important;text-align:center;vertical-align:middle;width:18px;height:18px;}.k-specialchar-pb-up{}.k-specialchar-big{padding:3px;line-height:22px;font-size:197%!important;}.k-specialchar-adv-label{margin-left:-10px;}.k-specialchar-popup,{border:1px px solid silver;z-index:9999!important;background-color:#FFF;}.k-specialchar-pb-down{color:#161616;}.k-specialchar-pb-up-hovering{border:thin solid #ACA899;}.k-specialchar-pb-down-hovering{color:#161616;}.k-preview-panel{border:dashed 1px gray;padding:5px;}.k-rte-changelink{white-space:nowrap;color:navy;cursor:pointer;text-decoration:underline;margin:5px;}.k-rte-changelink-popup{border:1px solid silver;z-index:9999!important;background-color:#ECECEC;}.e-ui-room{height:27px;line-height:22px;}.e-ui-room input{font-size:100%;margin-left:0;margin-top:0;}.k-def-popup{z-index:9999!important;background-color:#FFF;border:1px solid gray;}#k-mshortcut{position:absolute;right:10px;}#k-mshortcut-hidden{visibility:hidden;}#k-mshortcut a{text-decoration:none;color:#000;}
\ 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-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/kune-new.css 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1005,4 +1005,18 @@
z-index: 9999 !important;
background-color: #FFF;
border: 1px solid gray;
+}
+
+#k-mshortcut {
+ position: absolute;
+ right: 10px;
+}
+
+#k-mshortcut-hidden {
+ visibility: hidden;
+}
+
+#k-mshortcut a {
+ text-decoration: none;
+ color: black;
}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionManager.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -28,6 +28,7 @@
public ActionManager() {
}
+ @Deprecated
public void doAction(final ActionItem<?> actionItem) {
final ActionDescriptor<?> action = actionItem.getAction();
final Object item = actionItem.getItem();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/InputMap.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -45,7 +45,7 @@
/**
* Maps {@link KeyStroke}s to arbitrary objects, usually Strings. This is used
- * in combination with {@link ActionMap}s.
+ * in combination with ActionMaps.
*
* If a component receives an input event, this is looked up in the component's
* <code>InputMap</code>. The result is an object which serves as a key to the
@@ -63,7 +63,7 @@
/**
* Storage for the KeyStroke --> Object mappings.
*/
- private Map<KeyStroke, Action> inputMap;
+ private Map<KeyStroke, AbstractAction> inputMap;
/**
* An optional parent map.
@@ -122,8 +122,8 @@
* @return The binding associated with the specified keystroke (or
* <code>null</code>).
*/
- public Action get(final KeyStroke keystroke) {
- Action result = null;
+ public AbstractAction get(final KeyStroke keystroke) {
+ AbstractAction result = null;
if (inputMap != null) {
result = inputMap.get(keystroke);
}
@@ -177,12 +177,12 @@
* @param actionMapKey
* the action (<code>null</code> permitted).
*/
- public void put(final KeyStroke keystroke, final Action actionMapKey) {
+ public void put(final KeyStroke keystroke, final AbstractAction actionMapKey) {
if (keystroke == null) {
return;
}
if (inputMap == null) {
- inputMap = new HashMap<KeyStroke, Action>();
+ inputMap = new HashMap<KeyStroke, AbstractAction>();
}
if (actionMapKey == null) {
inputMap.remove(keystroke);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -175,13 +175,18 @@
* if event is null
*/
public static KeyStroke getKeyStrokeForEvent(final Event event) {
+ final int eventModif = getKeyboardModifiers(event);
+ final int eventKeyCode = event.getKeyCode();
+ // Log.info("key: " + eventKeyCode + " modifier: " + eventModif);
switch (DOM.eventGetType(event)) {
case Event.ONKEYDOWN:
- return getKeyStroke((char) event.getKeyCode(), VK_UNDEFINED, getKeyboardModifiers(event), false);
+ return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
case Event.ONKEYPRESS:
- return getKeyStroke(CHAR_UNDEFINED, event.getKeyCode(), getKeyboardModifiers(event), false);
+ final char charac = (char) eventKeyCode;
+ return getKeyStroke(Character.isLowerCase(charac) ? Character.toUpperCase(charac) : charac, VK_UNDEFINED,
+ eventModif, false);
case Event.ONKEYUP:
- return getKeyStroke(CHAR_UNDEFINED, event.getKeyCode(), getKeyboardModifiers(event), true);
+ return getKeyStroke(CHAR_UNDEFINED, eventKeyCode, eventModif, false);
default:
return null;
}
@@ -345,7 +350,7 @@
}
@SuppressWarnings("deprecation")
- public String getKeyText(final int keyCode) {
+ public String getKeyText() {
switch (keyCode) {
case KeyCodes.KEY_BACKSPACE:
return translateKey("Backspace");
@@ -373,6 +378,8 @@
return translateKey("Tab");
case KeyCodes.KEY_UP:
return translateKey("Up");
+ case Keyboard.KEY_SPACE:
+ return translateKey("Space");
case Keyboard.KEY_F1:
case Keyboard.KEY_F2:
case Keyboard.KEY_F3:
@@ -431,8 +438,14 @@
case Keyboard.KEY_BACK_SLASH:
case Keyboard.KEY_CLOSE_BRACKET:
return ("" + (char) keyCode).toUpperCase();
+
default:
- return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode));
+ final String charS = String.valueOf(keyChar);
+ if (charS == null) {
+ return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode));
+ } else {
+ return charS;
+ }
}
}
@@ -487,16 +500,13 @@
if ((modifiers & Keyboard.MODIFIER_SHIFT) != 0) {
s += translateKey("Shift") + "+";
}
- if ((modifiers & Event.BUTTON_LEFT) != 0) {
- s += translateKey("Button1") + "+";
- }
- if ((modifiers & Event.BUTTON_RIGHT) != 0) {
- s += translateKey("Button2") + "+";
- }
- if ((modifiers & Event.BUTTON_MIDDLE) != 0) {
- s += translateKey("Button3") + "+";
- }
- s += getKeyText(keyCode) + ")";
+ /*
+ * if ((modifiers & Event.BUTTON_LEFT) != 0) { s +=
+ * translateKey("Button1") + "+"; } if ((modifiers & Event.BUTTON_RIGHT)
+ * != 0) { s += translateKey("Button2") + "+"; } if ((modifiers &
+ * Event.BUTTON_MIDDLE) != 0) { s += translateKey("Button3") + "+"; }
+ */
+ s += getKeyText() + ")";
return s;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -43,13 +43,6 @@
}
}
- @Override
- public void setIcon(final ImageResource imageResource) {
- if (imageResource != null) {
- button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName());
- }
- }
-
public void setPressed(final boolean pressed) {
if (button.isPressed() != pressed) {
button.toggle();
@@ -71,4 +64,11 @@
}
}
+ @Override
+ protected void setIcon(final ImageResource imageResource) {
+ if (imageResource != null) {
+ button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
+ }
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,47 +2,55 @@
import java.util.List;
-import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.AbstractAction;
import org.ourproject.kune.platf.client.actions.InputMap;
import org.ourproject.kune.platf.client.actions.KeyStroke;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Composite;
public abstract class AbstractComplexGuiItem extends Composite {
- private GuiActionCollection guiItems;
+ private GuiActionDescCollection guiItems;
private InputMap inputMap;
- public void add(final AbstractGuiActionDescrip... descriptors) {
- for (final AbstractGuiActionDescrip descriptor : descriptors) {
+ public void add(final GuiActionDescrip... descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
getGuiItems().add(descriptor);
}
}
- public void addAction(final KeyStroke key, final Action action) {
- getInputMap().put(key, action);
+ public void addAll(final GuiActionDescCollection items) {
+ getGuiItems().addAll(items);
}
- public void addAll(final GuiActionCollection actions) {
- getGuiItems().addAll(actions);
+ public void addAll(final List<GuiActionDescrip> items) {
+ getGuiItems().addAll(items);
}
- public void addAll(final List<AbstractGuiActionDescrip> descriptors) {
- getGuiItems().addAll(descriptors);
+ public void addShortcut(final KeyStroke key, final AbstractAction action) {
+ getInputMap().put(key, action);
}
- public GuiActionCollection getGuiItems() {
+ public AbstractAction getAction(final Event event) {
+ return getInputMap().get(KeyStroke.getKeyStrokeForEvent(event));
+ }
+
+ public GuiActionDescCollection getGuiItems() {
if (guiItems == null) {
- guiItems = new GuiActionCollection();
+ guiItems = new GuiActionDescCollection();
}
return guiItems;
}
+ public void setInputMap(final InputMap inputMap) {
+ this.inputMap = inputMap;
+ }
+
private InputMap getInputMap() {
if (inputMap == null) {
inputMap = new InputMap();
}
return inputMap;
}
-
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,215 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.AbstractAction;
-
-/**
- * The Class AbstractUIActionDescriptor.
- */
-public abstract class AbstractGuiActionDescrip {
-
- protected static final int NO_POSITION = -1;
- protected static final View NO_VIEW = null;
- protected static final AbstractGuiActionDescrip NO_PARENT = null;
-
- private GuiAddCondition addCondition = new GuiAddConditionAdapter();
- private GuiVisibleCondition visibleCondition = new GuiVisibleConditionAdapter();
-
- protected AbstractGuiActionDescrip parent;
- private final Map<String, Object> store;
-
- /** The action. */
- protected AbstractAction action;
-
- /** The position where the item will be inserted. */
- private int position;
-
- /** If the action must be confirmed. */
- private boolean confirmRequired;
-
- /** The confirmation dialog title. */
- private String confirmationTitle;
-
- /** The confirmation dialog text. */
- private String confirmationText;
-
- /** The item location. */
- private String location;
-
- /**
- * Instantiates a new abstract ui action descriptor. This is used for
- * describe UI button, menus, menu items and so on
- *
- * @param action
- * the action
- */
- public AbstractGuiActionDescrip(final AbstractAction action) {
- this.action = action;
- position = NO_POSITION;
- parent = NO_PARENT;
- store = new HashMap<String, Object>();
- }
-
- public GuiAddCondition getAddCondition() {
- return addCondition;
- }
-
- /**
- * Gets the dialog confirmation text.
- *
- * @return the confirmation text
- */
- public String getConfirmationText() {
- return confirmationText;
- }
-
- /**
- * Gets the dialog confirmation title.
- *
- * @return the confirmation title
- */
- public String getConfirmationTitle() {
- return confirmationTitle;
- }
-
- /**
- * Gets the location, a string used to group actions with locations (top
- * bar, bottom bar, user bar...).
- *
- * @return the location
- */
- public String getLocation() {
- return location;
- }
-
- public AbstractGuiActionDescrip getParent() {
- return parent;
- }
-
- /**
- * Gets the position.
- *
- * @return the position
- */
- public int getPosition() {
- return position;
- }
-
- public abstract Class<?> getType();
-
- /**
- * Returns the value associated with the specified key.
- *
- * @param key
- * the key (not <code>null</code>).
- *
- * @return The value associated with the specified key, or <code>null</code>
- * if the key is not found.
- *
- * @see #putValue(String, Object)
- */
- public Object getValue(final String key) {
- return store.get(key);
- }
-
- public GuiVisibleCondition getVisibleCondition() {
- return visibleCondition;
- }
-
- public boolean isChild() {
- // @PMD:REVIEWED:CompareObjectsWithEquals: by vjrj on 26/05/09 20:57
- return parent != NO_PARENT;
- }
-
- /**
- * Checks if is confirm required previous to do the action.
- *
- * @return true, if is confirm required
- */
- public boolean isConfirmRequired() {
- return confirmRequired;
- }
-
- /**
- * Sets the value associated with the specified key.
- *
- * Any existing value associated with the key will be overwritten.
- *
- * @param key
- * the key (not <code>null</code>).
- * @param value
- * the value (<code>null</code> permitted).
- */
- public void putValue(final String key, final Object value) {
- store.put(key, value);
- }
-
- public void setAddCondition(final GuiAddCondition addCondition) {
- this.addCondition = addCondition;
- }
-
- /**
- * Sets the confirmation text.
- *
- * @param confirmationText
- * the new confirmation text
- */
- public void setConfirmationText(final String confirmationText) {
- this.confirmationText = confirmationText;
- }
-
- /**
- * Sets the confirmation title.
- *
- * @param confirmationTitle
- * the new confirmation title
- */
- public void setConfirmationTitle(final String confirmationTitle) {
- this.confirmationTitle = confirmationTitle;
- }
-
- /**
- * Sets the confirm required.
- *
- * @param isConfirmRequired
- * the new confirm required
- */
- public void setConfirmRequired(final boolean isConfirmRequired) {
- this.confirmRequired = isConfirmRequired;
- }
-
- /**
- * If we have several toolbars, we can group with the "location" string key
- * actions that must be in the same location (ex: top bar, bottom bar, and
- * so on).
- *
- * @param location
- * the new location
- */
- public void setLocation(final String location) {
- this.location = location;
- }
-
- public void setParent(final AbstractGuiActionDescrip parent) {
- this.parent = parent;
- }
-
- /**
- * Sets the position (where the UI element will be positioned, for instance
- * in a toolbar or in a menu).
- *
- * @param position
- * the new position
- */
- public void setPosition(final int position) {
- this.position = position;
- }
-
- public void setVisibleCondition(final GuiVisibleCondition visibleCondition) {
- this.visibleCondition = visibleCondition;
- }
-
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -7,8 +7,7 @@
import com.google.gwt.libideas.resources.client.ImageResource;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.FlowPanel;
-import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.menu.BaseItem;
@@ -79,13 +78,7 @@
if (key == null) {
item.setText(text);
} else {
- final FlowPanel fpanel = new FlowPanel();
- fpanel.setWidth("100%");
- fpanel.add(new Label(text));
- final Label keyLabel = new Label(key.toString());
- keyLabel.addStyleName("kune-floatright");
- fpanel.add(keyLabel);
- item.setText(DOM.getInnerHTML(fpanel.getElement()));
+ item.setText(text + createShortCut(key, "k-mshortcut-hidden") + createShortCut(key, "k-mshortcut"));
}
}
}
@@ -102,4 +95,11 @@
checkItem.setChecked(((MenuCheckItemDescriptor) descriptor).isChecked());
return checkItem;
}
+
+ private String createShortCut(final KeyStroke key, final String style) {
+ final Element keyLabel = DOM.createSpan();
+ keyLabel.setId(style);
+ keyLabel.setInnerText(key.toString());
+ return keyLabel.getString();
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractSeparatorDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -3,7 +3,7 @@
import org.ourproject.kune.platf.client.actions.AbstractAction;
import org.ourproject.kune.platf.client.actions.ActionEvent;
-public abstract class AbstractSeparatorDescriptor extends AbstractGuiActionDescrip {
+public abstract class AbstractSeparatorDescriptor extends GuiActionDescrip {
public AbstractSeparatorDescriptor() {
super(new AbstractAction() {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -11,5 +11,6 @@
bindings.register(MenuSeparatorDescriptor.class, new MenuSeparatorBinding());
bindings.register(ButtonDescriptor.class, new ButtonBinding());
bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
+ bindings.register(ToolbarSeparatorDescriptor.class, new ToolbarSeparatorBinding());
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -3,7 +3,7 @@
public class ButtonBinding extends GuiBindingAdapter {
@Override
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
return new ButtonGui((ButtonDescriptor) descriptor);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ButtonDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,7 +2,7 @@
import org.ourproject.kune.platf.client.actions.AbstractAction;
-public class ButtonDescriptor extends AbstractGuiActionDescrip {
+public class ButtonDescriptor extends GuiActionDescrip {
public ButtonDescriptor(final AbstractAction action) {
super(action);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,49 +2,76 @@
import java.util.List;
-import org.ourproject.kune.platf.client.ui.SimpleToolbar;
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.errors.UIException;
+import org.ourproject.kune.platf.client.ui.FlowToolbar;
-public class ComplexToolbar extends AbstractComplexGuiItem {
+public class ComplexToolbar extends AbstractComplexGuiItem implements View {
- private final SimpleToolbar toolbar;
+ private final FlowToolbar toolbar;
private final GuiBindingsRegister bindings;
public ComplexToolbar(final GuiBindingsRegister bindings) {
super();
this.bindings = bindings;
- toolbar = new SimpleToolbar();
+ toolbar = new FlowToolbar();
initWidget(toolbar);
}
@Override
- public void add(final AbstractGuiActionDescrip... descriptors) {
- for (final AbstractGuiActionDescrip descrip : descriptors) {
+ public void add(final GuiActionDescrip... descriptors) {
+ for (final GuiActionDescrip descrip : descriptors) {
super.add(descrip);
addWidget(descrip);
}
}
@Override
- public void addAll(final List<AbstractGuiActionDescrip> descriptors) {
+ public void addAll(final List<GuiActionDescrip> descriptors) {
super.addAll(descriptors);
- for (final AbstractGuiActionDescrip descritor : descriptors) {
+ for (final GuiActionDescrip descritor : descriptors) {
addWidget(descritor);
}
}
- private void addWidget(final AbstractGuiActionDescrip descrip) {
+ public void addFill() {
+ toolbar.addFill();
+ }
+
+ public void addSeparator() {
+ toolbar.addSeparator();
+ }
+
+ public void addSpacer() {
+ toolbar.addSpacer();
+ }
+
+ public void setCleanStyle() {
+ toolbar.setCleanStyle();
+ }
+
+ public void setNormalStyle() {
+ toolbar.setNormalStyle();
+ }
+
+ private void addWidget(final GuiActionDescrip descrip) {
if (descrip.getAddCondition().mustBeAdded()) {
final boolean visible = descrip.getVisibleCondition().mustBeVisible();
final GuiBinding binding = bindings.get(descrip.getType());
- final AbstractGuiItem item = binding.create(descrip);
- if (binding.isAttachable()) {
- final int position = descrip.getPosition();
- if (position == AbstractGuiActionDescrip.NO_POSITION) {
- toolbar.add(item);
- } else {
- toolbar.insert(item, position);
+ if (binding == null) {
+ throw new UIException("Unknown binding for: " + descrip);
+ } else {
+ final AbstractGuiItem item = binding.create(descrip);
+ if (binding.isAttachable()) {
+ item.addStyleName("kune-floatleft");
+ final int position = descrip.getPosition();
+ if (position == GuiActionDescrip.NO_POSITION) {
+ toolbar.add(item);
+ } else {
+ toolbar.insert(item, position);
+ }
+ item.setVisible(visible);
}
- item.setVisible(visible);
}
}
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,16 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-import java.util.ArrayList;
-
-// @PMD:REVIEWED:AtLeastOneConstructor: by vjrj on 26/05/09 12:31
-public class GuiActionCollection extends ArrayList<AbstractGuiActionDescrip> {
-
- private static final long serialVersionUID = 6759723760404227737L;
-
- public void add(final AbstractGuiActionDescrip... descriptors) {
- for (AbstractGuiActionDescrip descriptor : descriptors) {
- super.add(descriptor);
- }
- }
-
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescCollection.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionCollection.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescCollection.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -0,0 +1,16 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.ArrayList;
+
+// @PMD:REVIEWED:AtLeastOneConstructor: by vjrj on 26/05/09 12:31
+public class GuiActionDescCollection extends ArrayList<GuiActionDescrip> {
+
+ private static final long serialVersionUID = 6759723760404227737L;
+
+ public void add(final GuiActionDescrip... descriptors) {
+ for (GuiActionDescrip descriptor : descriptors) {
+ super.add(descriptor);
+ }
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiActionDescrip.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -0,0 +1,158 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.Action;
+
+/**
+ * The Class AbstractUIActionDescriptor.
+ */
+public abstract class GuiActionDescrip { // NOPMD by vjrj on 9/06/09 2:00
+
+ protected static final int NO_POSITION = -1;
+ protected static final View NO_VIEW = null;
+ protected static final GuiActionDescrip NO_PARENT = null;
+
+ private GuiAddCondition addCondition = new GuiAddConditionAdapter();
+ private GuiVisibleCondition visibleCondition = new GuiVisibleConditionAdapter();
+
+ protected GuiActionDescrip parent;
+ private final Map<String, Object> store;
+
+ /** The action. */
+ protected AbstractAction action;
+
+ /** The position where the item will be inserted. */
+ private int position;
+
+ /** The item location. */
+ private String location;
+
+ /**
+ * Instantiates a new abstract ui action descriptor. This is used for
+ * describe UI button, menus, menu items and so on
+ *
+ * @param action
+ * the action
+ */
+ public GuiActionDescrip(final AbstractAction action) {
+ this.action = action;
+ position = NO_POSITION;
+ parent = NO_PARENT;
+ store = new HashMap<String, Object>();
+ }
+
+ public GuiAddCondition getAddCondition() {
+ return addCondition;
+ }
+
+ /**
+ * Gets the location, a string used to group actions with locations (top
+ * bar, bottom bar, user bar...).
+ *
+ * @return the location
+ */
+ public String getLocation() {
+ return location;
+ }
+
+ public GuiActionDescrip getParent() {
+ return parent;
+ }
+
+ /**
+ * Gets the position.
+ *
+ * @return the position
+ */
+ public int getPosition() {
+ return position;
+ }
+
+ public abstract Class<?> getType();
+
+ /**
+ * Returns the value associated with the specified key.
+ *
+ * @param key
+ * the key (not <code>null</code>).
+ *
+ * @return The value associated with the specified key, or <code>null</code>
+ * if the key is not found.
+ *
+ * @see #putValue(String, Object)
+ */
+ public Object getValue(final String key) {
+ return store.get(key);
+ }
+
+ public GuiVisibleCondition getVisibleCondition() {
+ return visibleCondition;
+ }
+
+ public boolean isChild() {
+ // @PMD:REVIEWED:CompareObjectsWithEquals: by vjrj on 26/05/09 20:57
+ return parent != NO_PARENT;
+ }
+
+ /**
+ * Sets the value associated with the specified key.
+ *
+ * Any existing value associated with the key will be overwritten.
+ *
+ * @param key
+ * the key (not <code>null</code>).
+ * @param value
+ * the value (<code>null</code> permitted).
+ */
+ public void putValue(final String key, final Object value) {
+ store.put(key, value);
+ }
+
+ public void setAddCondition(final GuiAddCondition addCondition) {
+ this.addCondition = addCondition;
+ }
+
+ /**
+ * If we have several toolbars, we can group with the "location" string key
+ * actions that must be in the same location (ex: top bar, bottom bar, and
+ * so on).
+ *
+ * @param location
+ * the new location
+ */
+ public void setLocation(final String location) {
+ this.location = location;
+ }
+
+ public void setParent(final GuiActionDescrip parent) {
+ this.parent = parent;
+ }
+
+ /**
+ * Sets the position (where the UI element will be positioned, for instance
+ * in a toolbar or in a menu).
+ *
+ * @param position
+ * the new position
+ */
+ public void setPosition(final int position) {
+ this.position = position;
+ }
+
+ public void setVisibleCondition(final GuiVisibleCondition visibleCondition) {
+ this.visibleCondition = visibleCondition;
+ }
+
+ @Override
+ public String toString() {
+ final String name = (String) action.getValue(Action.NAME);
+ final String tooltip = (String) action.getValue(Action.SHORT_DESCRIPTION);
+ return "[GuiActionDescrip: " + action.getClass() + (name == null ? "" : " " + name)
+ + (tooltip == null ? "" : " " + tooltip) + "]";
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,7 +2,7 @@
public interface GuiBinding {
- AbstractGuiItem create(AbstractGuiActionDescrip descriptor);
+ AbstractGuiItem create(GuiActionDescrip descriptor);
boolean isAttachable();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBindingAdapter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBindingAdapter.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiBindingAdapter.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,7 +2,7 @@
public class GuiBindingAdapter implements GuiBinding {
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
return null;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -9,13 +9,13 @@
private Boolean isSubmenu;
@Override
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
AbstractGuiItem item;
if (descriptor.isChild()) {
final SubMenuGui submenu = new SubMenuGui(descriptor);
final AbstractMenuGui parentMenu = ((AbstractMenuGui) descriptor.getParent().getValue(UI_MENU));
final int position = descriptor.getPosition();
- if (position == AbstractGuiActionDescrip.NO_POSITION) {
+ if (position == GuiActionDescrip.NO_POSITION) {
parentMenu.add(submenu.getMenuItem());
} else {
parentMenu.insert(position, submenu.getMenuItem());
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -5,13 +5,15 @@
import com.google.gwt.libideas.resources.client.ImageResource;
-public class MenuDescriptor extends AbstractGuiActionDescrip {
+public class MenuDescriptor extends GuiActionDescrip {
+ public static final String MENU_HIDE = "hidemenu";
+
public MenuDescriptor(final AbstractAction action) {
this(NO_PARENT, action);
}
- public MenuDescriptor(final AbstractGuiActionDescrip parent, final AbstractAction action) {
+ public MenuDescriptor(final GuiActionDescrip parent, final AbstractAction action) {
super(action);
setParent(parent);
}
@@ -33,6 +35,10 @@
return MenuDescriptor.class;
}
+ public void hide() {
+ action.putValue(MENU_HIDE, true);
+ }
+
public void setText(final String text) {
action.putValue(Action.NAME, text);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,5 +1,7 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
+import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
import org.ourproject.kune.platf.client.ui.img.ImgConstants;
import com.google.gwt.libideas.resources.client.ImageResource;
@@ -9,12 +11,20 @@
private final ToolbarButton button;
- public MenuGui(final AbstractGuiActionDescrip descriptor) {
+ public MenuGui(final GuiActionDescrip descriptor) {
super();
button = new ToolbarButton();
button.setMenu(menu);
setAction(descriptor.action);
initWidget(button);
+ descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(final PropertyChangeEvent e) {
+ if (e.getPropertyName().equals(MenuDescriptor.MENU_HIDE) && e.getNewValue().equals(true)) {
+ menu.hide(true);
+ descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
+ }
+ }
+ });
}
public void add(final SubMenuGui submenu) {
@@ -37,7 +47,7 @@
@Override
public void setIcon(final ImageResource imageResource) {
if (imageResource != null) {
- button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName());
+ button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,16 +1,21 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.errors.UIException;
+
import com.gwtext.client.widgets.menu.Item;
public class MenuItemBinding extends GuiBindingAdapter {
@Override
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
final MenuItemGui item = new MenuItemGui((MenuItemDescriptor) descriptor);
final int position = descriptor.getPosition();
final Item menuItem = (Item) item.getWidget();
final AbstractMenuGui menu = ((AbstractMenuGui) descriptor.getParent().getValue(MenuBinding.UI_MENU));
- if (position == AbstractGuiActionDescrip.NO_POSITION) {
+ if (menu == null) {
+ throw new UIException("To add a menu item you need to add the menu before. Item: " + descriptor);
+ }
+ if (position == GuiActionDescrip.NO_POSITION) {
menu.add(menuItem);
} else {
menu.insert(position, menuItem);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,7 +2,7 @@
import org.ourproject.kune.platf.client.actions.AbstractAction;
-public class MenuItemDescriptor extends AbstractGuiActionDescrip {
+public class MenuItemDescriptor extends GuiActionDescrip {
public MenuItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
super(action);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuSeparatorBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,10 +1,15 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.errors.UIException;
+
public class MenuSeparatorBinding extends GuiBindingAdapter {
@Override
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
final AbstractMenuGui menu = ((AbstractMenuGui) descriptor.getParent().getValue(MenuBinding.UI_MENU));
+ if (menu == null) {
+ throw new UIException("To add a menu separator you need to add the menu before. Item: " + descriptor);
+ }
menu.addSeparator();
return menu;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -3,7 +3,7 @@
public class PushButtonBinding extends GuiBindingAdapter {
@Override
- public AbstractGuiItem create(final AbstractGuiActionDescrip descriptor) {
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
return new ButtonGui((ButtonDescriptor) descriptor, true);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -9,7 +9,7 @@
private final MenuItem item;
- public SubMenuGui(final AbstractGuiActionDescrip descriptor) {
+ public SubMenuGui(final GuiActionDescrip descriptor) {
super();
item = new MenuItem();
item.setMenu(menu);
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorBinding.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorBinding.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorBinding.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -0,0 +1,29 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public class ToolbarSeparatorBinding extends GuiBindingAdapter {
+ @Override
+ public AbstractGuiItem create(final GuiActionDescrip descriptor) {
+ final ToolbarSeparatorDescriptor sepDescrip = (ToolbarSeparatorDescriptor) descriptor;
+ final ComplexToolbar toolbar = (ComplexToolbar) sepDescrip.getToolbar();
+ switch (sepDescrip.getSeparatorType()) {
+ case fill:
+ toolbar.addFill();
+ break;
+ case separator:
+ toolbar.addSeparator();
+ break;
+ case spacer:
+ toolbar.addSpacer();
+ break;
+ default:
+ break;
+ }
+ return super.create(descriptor);
+ }
+
+ @Override
+ public boolean isAttachable() {
+ return false;
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ToolbarSeparatorDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,5 +1,6 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.View;
public class ToolbarSeparatorDescriptor extends AbstractSeparatorDescriptor {
@@ -8,17 +9,22 @@
}
private final Type type;
+ private final View toolbar;
- public ToolbarSeparatorDescriptor(final Type type) {
+ public ToolbarSeparatorDescriptor(final Type type, final View toolbar) {
super();
- // setParent(parent);
this.type = type;
+ this.toolbar = toolbar;
}
public Type getSeparatorType() {
return type;
}
+ public View getToolbar() {
+ return toolbar;
+ }
+
@Override
public Class<?> getType() {
return ToolbarSeparatorDescriptor.class;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -60,8 +60,11 @@
import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionSndToolbar;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbar;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenterNew;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPresenter;
@@ -348,10 +351,22 @@
presenter.init(panel);
return presenter;
}
+ },new Factory<RTEditorNew>(RTEditorNew.class) {
+ @Override
+ public RTEditorNew create() {
+ final RTEditorPresenterNew presenter = new RTEditorPresenterNew($(I18nTranslationService.class),
+ $(Session.class), $(RTEImgResources.class), $$(InsertLinkDialog.class),
+ $$(ColorWebSafePalette.class), $$(EditHtmlDialog.class), $$(InsertImageDialog.class),
+ $$(InsertMediaDialog.class), $$(InsertTableDialog.class), $$(InsertSpecialCharDialog.class), $(DeferredCommandWrapper.class));
+ final RTEditorPanelNew panel = new RTEditorPanelNew(presenter, $(I18nUITranslationService.class),
+ $(GlobalShortcutRegister.class), $(GuiBindingsRegister.class));
+ presenter.init(panel);
+ return presenter;
+ }
}, new Factory<RTESavingEditor>(RTESavingEditor.class) {
@Override
public RTESavingEditor create() {
- final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
+ final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditorNew.class), true,
$(I18nTranslationService.class), $(StateManager.class), $(DeferredCommandWrapper.class),
$(RTEImgResources.class), $(TimerWrapper.class));
final RTESavingEditorPanel panel = new RTESavingEditorPanel();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/Keyboard.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/Keyboard.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/Keyboard.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -66,6 +66,7 @@
public final static int KEY_X = 'X';
public final static int KEY_Y = 'Y';
public final static int KEY_Z = 'Z';
+ public final static int KEY_SPACE = ' ';
public final static int KEY_OPEN_BRACKET = '[';
public final static int KEY_BACK_SLASH = '\\';
public final static int KEY_CLOSE_BRACKET = ']';
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-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,13 +1,12 @@
package org.ourproject.kune.platf.client.ui.rte;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
+import org.ourproject.kune.platf.client.actions.ui.ComplexToolbar;
import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.Window;
import com.gwtext.client.widgets.event.WindowListenerAdapter;
@@ -16,14 +15,14 @@
private final RTESavingEditor editor;
private final BasicDialog dialog;
- public TestRTEDialog(RTESavingEditor editor) {
+ public TestRTEDialog(final RTESavingEditor editor) {
this.editor = editor;
dialog = new BasicDialog("Testing RTE", false, false, 650, 200);
final VerticalPanel vp = new VerticalPanel();
- RTEditor basicEditor = editor.getBasicEditor();
- vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar());
- vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar());
+ final RTEditorNew basicEditor = editor.getBasicEditor();
+ vp.add((ComplexToolbar) basicEditor.getTopBar());
+ vp.add((ComplexToolbar) basicEditor.getSndBar());
final RTEditorPanel editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
vp.add(editorPanel);
basicEditor.setExtended(true);
@@ -31,15 +30,15 @@
dialog.add(vp);
dialog.addListener(new WindowListenerAdapter() {
@Override
- public void onResize(Window source, int width, int height) {
- int newHeight = height - 26 * 2 - 40;
+ public void onResize(final Window source, final int width, final int height) {
+ final int newHeight = height - 26 * 2 - 40;
editorPanel.adjustSize(newHeight);
vp.setCellHeight(editorPanel, "" + newHeight);
}
});
}
- public void setExtended(boolean extended) {
+ public void setExtended(final boolean extended) {
editor.getBasicEditor().setExtended(extended);
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/AbstractRTEAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/AbstractRTEAction.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/AbstractRTEAction.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -0,0 +1,30 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.Action;
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public abstract class AbstractRTEAction extends AbstractAction {
+ public static final String NO_TEXT = null;
+ public static final ImageResource NO_ICON = null;
+
+ public AbstractRTEAction() {
+ super();
+ }
+
+ public AbstractRTEAction(final String text) {
+ this(text, null, null);
+ }
+
+ public AbstractRTEAction(final String text, final ImageResource icon) {
+ this(text, null, icon);
+ }
+
+ public AbstractRTEAction(final String text, final String tooltip, final ImageResource icon) {
+ super();
+ super.putValue(Action.NAME, text);
+ super.putValue(Action.SHORT_DESCRIPTION, tooltip);
+ super.putValue(Action.SMALL_ICON, icon);
+ }
+}
\ No newline at end of file
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,6 +1,7 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
import org.ourproject.kune.platf.client.services.Images;
import org.ourproject.kune.platf.client.ui.KuneUiUtils;
import org.ourproject.kune.platf.client.ui.dialogs.AbstractPopupPanel;
@@ -30,6 +31,11 @@
hpanel.add(close);
}
+ public void add(final GuiActionDescrip item) {
+ // TODO
+ }
+
+ @Deprecated
public void addAction(final ActionItem<Object> item, final Listener0 onClick) {
final Label actionLabel = new Label();
actionLabel.setText(item.getAction().getText());
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorNew.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorNew.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,9 +1,10 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.actions.ui.AbstractGuiActionDescrip;
-import org.ourproject.kune.platf.client.actions.ui.GuiActionCollection;
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.KeyStroke;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
import org.ourproject.kune.platf.client.actions.ui.GuiAddCondition;
import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
@@ -15,9 +16,9 @@
String SNDBAR = "rte-sndbar";
String LINKCTX = "rte-linkctx";
- void addAction(AbstractGuiActionDescrip action);
+ void addAction(GuiActionDescrip action);
- void addActions(GuiActionCollection actions);
+ void addActions(GuiActionDescCollection actions);
void addOnEditListener(Listener0 listener);
@@ -33,6 +34,8 @@
GuiAddCondition getExtendedAddCondition();
+ MenuDescriptor getFileMenu();
+
MenuDescriptor getFormatMenu();
String getHtml();
@@ -41,14 +44,18 @@
MenuDescriptor getLinkCtxMenu();
- ActionToolbar<Object> getSndBar();
+ View getSndBar();
String getText();
- ActionToolbar<Object> getTopBar();
+ View getTopBar();
void reset();
+ void setActionShortcut(KeyStroke key, AbstractAction action);
+
+ void setActionShortcut(KeyStroke key, AbstractAction mainAction, AbstractAction... actions);
+
void setExtended(boolean extended);
void setFocus(boolean focus);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -2,16 +2,17 @@
import java.util.Date;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.ui.AbstractComplexGuiItem;
-import org.ourproject.kune.platf.client.actions.ui.GuiActionCollection;
+import org.ourproject.kune.platf.client.actions.ui.ComplexToolbar;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.errors.UIException;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
-import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
-import org.ourproject.kune.platf.client.shortcuts.ShortcutRegister;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea.BasicFormatter;
@@ -25,7 +26,6 @@
import org.xwiki.gwt.dom.client.Selection;
import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Listener0;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
@@ -37,73 +37,57 @@
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
-public class RTEditorPanelNew extends AbstractComplexGuiItem implements RTEditorViewNew {
+public class RTEditorPanelNew extends AbstractComplexGuiItem implements RTEditorViewNew, FocusHandler, BlurHandler {
- private class EventListener implements FocusHandler, BlurHandler {
- public void onBlur(final BlurEvent event) {
- presenter.onLostFocus();
- }
-
- public void onFocus(final FocusEvent event) {
- presenter.onEditorFocus();
- }
- }
private final I18nUITranslationService i18n;
private final BasicFormatter basic;
private final ExtendedFormatter extended;
- private final RTEditorPresenter presenter;
- private final ActionManager actionManager;
- private final ShortcutRegister shortcutRegister;
+ private final RTEditorPresenterNew presenter;
private final GlobalShortcutRegister globalShortcutReg;
private final RTELinkPopup linkCtxMenu;
private final RichTextArea rta;
+ private final ComplexToolbar topBar;
+ private final ComplexToolbar sndBar;
- public RTEditorPanelNew(final RTEditorPresenter presenter, final I18nUITranslationService i18n,
- final ActionManager actionManager, final GlobalShortcutRegister globalShortcutReg) {
+ public RTEditorPanelNew(final RTEditorPresenterNew presenter, final I18nUITranslationService i18n,
+ final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
super();
this.presenter = presenter;
this.i18n = i18n;
- this.actionManager = actionManager;
this.globalShortcutReg = globalShortcutReg;
rta = new RichTextArea();
basic = rta.getBasicFormatter();
extended = rta.getExtendedFormatter();
- shortcutRegister = new ShortcutRegister();
- final EventListener handler = new EventListener();
- rta.addFocusHandler(handler);
- rta.addBlurHandler(handler);
+ topBar = new ComplexToolbar(bindReg);
+ sndBar = new ComplexToolbar(bindReg);
+ sndBar.setNormalStyle();
+ rta.addFocusHandler(this);
+ rta.addBlurHandler(this);
+ linkCtxMenu = new RTELinkPopup();
+ initWidget(rta);
setWidth("96%");
setHeight("100%");
- linkCtxMenu = new RTELinkPopup();
- initWidget(rta);
}
- public void addActions(final ActionItemCollection<Object> actionItems) {
- for (final ActionItem<Object> actionItem : actionItems) {
- final ActionDescriptor<Object> action = actionItem.getAction();
- if (action.hasShortcut() && action.mustBeAdded(null)) {
- final ShortcutDescriptor shortcut = action.getShortcut();
- shortcutRegister.put(shortcut, actionItem);
+ public void addActions(final GuiActionDescCollection items) {
+ super.addAll(items);
+ for (final GuiActionDescrip item : items) {
+ final String location = item.getLocation();
+ if (location == null) {
+ throw new UIException("Unknown location in action item: " + item);
}
+ if (location.equals(RTEditorNew.TOPBAR)) {
+ topBar.add(item);
+ } else if (location.equals(RTEditorNew.SNDBAR)) {
+ sndBar.add(item);
+ } else if (location.equals(RTEditorNew.LINKCTX)) {
+ linkCtxMenu.add(item);
+ } else {
+ throw new UIException("Unknown location in action item: " + item);
+ }
}
}
- public void addActions(final GuiActionCollection actions) {
- super.addAll(actions);
- }
-
- public void addCtxAction(final ActionItem<Object> actionItem) {
- linkCtxMenu.addAction(actionItem, new Listener0() {
- public void onEvent() {
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- actionManager.doAction(actionItem);
- }
- });
- }
- });
- }
-
public void adjustSize(final int height) {
setHeight(Integer.toString(height));
}
@@ -168,10 +152,18 @@
return getFstRange().cloneContents().getInnerText();
}
+ public View getSndBar() {
+ return sndBar;
+ }
+
public String getText() {
return rta.getText();
}
+ public View getTopBar() {
+ return topBar;
+ }
+
public void hideLinkCtxMenu() {
linkCtxMenu.hide();
}
@@ -281,7 +273,10 @@
extended.leftIndent();
}
- @SuppressWarnings("unchecked")
+ public void onBlur(final BlurEvent event) {
+ presenter.onLostFocus();
+ }
+
@Override
public void onBrowserEvent(final Event event) {
switch (DOM.eventGetType(event)) {
@@ -290,10 +285,14 @@
updateLinkInfo();
super.onBrowserEvent(event);
break;
- case Event.ONKEYDOWN:
- final ActionItem rtaActionItem = shortcutRegister.get(event);
- final ActionItem actionItem = rtaActionItem == null ? globalShortcutReg.get(event) : rtaActionItem;
+ case Event.ONKEYPRESS:
+ final AbstractAction rtaActionItem = super.getAction(event);
+ // FIXME
+ // final Action actionItem = rtaActionItem == null ?
+ // globalShortcutReg.get(event) : rtaActionItem;
+ final AbstractAction actionItem = rtaActionItem == null ? null : rtaActionItem;
if (actionItem == null) {
+ Log.warn("rte action key null");
super.onBrowserEvent(event);
updateStatus();
updateLinkInfo();
@@ -305,7 +304,7 @@
fireEdit();
event.stopPropagation();
event.preventDefault();
- actionManager.doAction(actionItem);
+ actionItem.actionPerformed(new ActionEvent(this, event));
updateStatus();
}
break;
@@ -316,6 +315,10 @@
}
}
+ public void onFocus(final FocusEvent event) {
+ presenter.onEditorFocus();
+ }
+
public void paste() {
extended.paste();
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,15 +1,20 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_ICON;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_TEXT;
+
+import java.util.ArrayList;
+import java.util.List;
+
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.actions.AbstractAction;
import org.ourproject.kune.platf.client.actions.Action;
import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.InputMap;
import org.ourproject.kune.platf.client.actions.KeyStroke;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.actions.ui.AbstractGuiActionDescrip;
import org.ourproject.kune.platf.client.actions.ui.ButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.GuiActionCollection;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
import org.ourproject.kune.platf.client.actions.ui.GuiAddCondition;
import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
@@ -44,28 +49,6 @@
public class RTEditorPresenterNew implements RTEditorNew {
- public abstract class AbstractRTEAction extends AbstractAction {
-
- public AbstractRTEAction() {
- super();
- }
-
- public AbstractRTEAction(final String text) {
- this(text, null, null);
- }
-
- public AbstractRTEAction(final String text, final ImageResource icon) {
- this(text, null, icon);
- }
-
- public AbstractRTEAction(final String text, final String tooltip, final ImageResource icon) {
- super();
- super.putValue(Action.NAME, text);
- super.putValue(Action.SHORT_DESCRIPTION, tooltip);
- super.putValue(Action.SMALL_ICON, icon);
- }
- }
-
public class BackgroundColorAction extends AbstractRTEAction {
public BackgroundColorAction(final String text, final String tooltip, final ImageResource icon) {
@@ -641,16 +624,11 @@
RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
RichTextArea.FontSize.XX_LARGE };
- private static final String NONE = null;
- private static final ImageResource NO_ICON = null;
-
private RTEditorViewNew view;
private boolean extended;
private final I18nTranslationService i18n;
private final Session session;
private final RTEImgResources imgResources;
- private final RTEActionTopToolbar topBar;
- private final RTEActionSndToolbar sndBar;
private final Event0 onEdit;
private final DeferredCommandWrapper deferred;
private final Provider<ColorWebSafePalette> paletteProvider;
@@ -678,20 +656,21 @@
private MenuDescriptor insertMenu;
private MenuDescriptor formatMenu;
private MenuDescriptor linkCtxMenu;
- private GuiActionCollection actions;
+ private GuiActionDescCollection actions;
private MenuDescriptor fontMenu;
private MenuDescriptor fontSizeMenu;
+ private MenuDescriptor fileMenu;
+ private final List<MenuDescriptor> menus;
+ private boolean attached;
public RTEditorPresenterNew(final I18nTranslationService i18n, final Session session,
- final RTEActionTopToolbar topBar, final RTEActionSndToolbar sndBar, final RTEImgResources imgResources,
- final Provider<InsertLinkDialog> insLinkDialog, final Provider<ColorWebSafePalette> palette,
- final Provider<EditHtmlDialog> editHtmlDialog, final Provider<InsertImageDialog> insertImageDialog,
- final Provider<InsertMediaDialog> insertMediaDialog, final Provider<InsertTableDialog> insertTableDialog,
- final Provider<InsertSpecialCharDialog> insCharDialog, final DeferredCommandWrapper deferred) {
+ final RTEImgResources imgResources, final Provider<InsertLinkDialog> insLinkDialog,
+ final Provider<ColorWebSafePalette> palette, final Provider<EditHtmlDialog> editHtmlDialog,
+ final Provider<InsertImageDialog> insertImageDialog, final Provider<InsertMediaDialog> insertMediaDialog,
+ final Provider<InsertTableDialog> insertTableDialog, final Provider<InsertSpecialCharDialog> insCharDialog,
+ final DeferredCommandWrapper deferred) {
this.i18n = i18n;
this.session = session;
- this.topBar = topBar;
- this.sndBar = sndBar;
this.insLinkDialogPv = insLinkDialog;
this.paletteProvider = palette;
this.editHtmlDialogPv = editHtmlDialog;
@@ -701,9 +680,8 @@
this.insCharDialogProv = insCharDialog;
this.deferred = deferred;
inputMap = new InputMap();
+ menus = new ArrayList<MenuDescriptor>();
- styleToolbar(sndBar);
- sndBar.attach();
this.imgResources = imgResources;
extended = true;
this.onEdit = new Event0("onRTEEdit");
@@ -717,14 +695,19 @@
return view.canBeBasic();
}
};
+ attached = false;
}
- public void addAction(final AbstractGuiActionDescrip descriptor) {
+ public void addAction(final GuiActionDescrip descriptor) {
actions.add(descriptor);
+ checkForMenus(descriptor);
}
- public void addActions(final GuiActionCollection actioncollection) {
- actions.addAll(actioncollection);
+ public void addActions(final GuiActionDescCollection descriptors) {
+ actions.addAll(descriptors);
+ for (final GuiActionDescrip descriptor : descriptors) {
+ checkForMenus(descriptor);
+ }
}
public void addOnEditListener(final Listener0 listener) {
@@ -736,18 +719,16 @@
}
public void attach() {
- topBar.clear();
- sndBar.clear();
- view.addActions(actions);
- // FIXME
- // topBar.addActions(actions, TOPBAR);
- // sndBar.addActions(actions, SNDBAR);
- // view.addActions(actions);
+ if (!attached) {
+ attached = true;
+ view.addActions(actions);
+ view.setInputMap(inputMap);
+ }
}
public void detach() {
- topBar.clear();
- sndBar.clear();
+ // topBar.clear();
+ // sndBar.clear();
}
public void fireOnEdit() {
@@ -770,6 +751,10 @@
return extendedAddCond;
}
+ public MenuDescriptor getFileMenu() {
+ return fileMenu;
+ }
+
public MenuDescriptor getFormatMenu() {
return formatMenu;
}
@@ -786,16 +771,16 @@
return linkCtxMenu;
}
- public ActionToolbar<Object> getSndBar() {
- return sndBar;
+ public View getSndBar() {
+ return view.getSndBar();
}
public String getText() {
return view.getText();
}
- public ActionToolbar<Object> getTopBar() {
- return topBar;
+ public View getTopBar() {
+ return view.getTopBar();
}
public void init(final RTEditorViewNew view) {
@@ -817,6 +802,18 @@
hideLinkCtxMenu();
}
+ public void setActionShortcut(final KeyStroke key, final AbstractAction action) {
+ inputMap.put(key, action);
+ action.putValue(Action.ACCELERATOR_KEY, key);
+ }
+
+ public void setActionShortcut(final KeyStroke key, final AbstractAction mainAction, final AbstractAction... actions) {
+ setActionShortcut(key, mainAction);
+ for (final AbstractAction action : actions) {
+ action.putValue(Action.ACCELERATOR_KEY, key);
+ }
+ }
+
public void setExtended(final boolean extended) {
this.extended = extended;
}
@@ -858,12 +855,10 @@
}
}
- private void crateFontAction(final MenuDescriptor fontMenu, final String fontName) {
- final FontAction fontAction = new FontAction(fontName, NONE, NO_ICON);
- final MenuItemDescriptor font = new MenuItemDescriptor(fontMenu, fontAction);
- font.setAddCondition(basicAddCond);
- font.setLocation(SNDBAR);
- actions.add(font);
+ private void checkForMenus(final GuiActionDescrip descriptor) {
+ if (descriptor instanceof MenuDescriptor) {
+ menus.add((MenuDescriptor) descriptor);
+ }
}
private void createBasicActions() {
@@ -872,139 +867,140 @@
final MenuSeparatorDescriptor insertMenuSep = new MenuSeparatorDescriptor(insertMenu);
final MenuSeparatorDescriptor formatMenuSep = new MenuSeparatorDescriptor(formatMenu);
- final ToolbarSeparatorDescriptor separator = new ToolbarSeparatorDescriptor(Type.separator);
+ final ToolbarSeparatorDescriptor sndbarSep = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
- final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), NONE,
+ final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractRTEAction.NO_TEXT,
imgResources.selectall());
final MenuItemDescriptor select = new MenuItemDescriptor(editMenu, selectAllAction);
- setActionShortcut(KeyStroke.getKeyStroke('A', Keyboard.MODIFIER_CTRL), selectAllAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('A'), Keyboard.MODIFIER_CTRL), selectAllAction);
- final BoldAction boldAction = new BoldAction(NONE, i18n.t("Bold"), imgResources.bold());
+ final BoldAction boldAction = new BoldAction(NO_TEXT, i18n.t("Bold"), imgResources.bold());
bold = new PushButtonDescriptor(boldAction);
- setActionShortcut(KeyStroke.getKeyStroke('B', Keyboard.MODIFIER_CTRL), boldAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_CTRL), boldAction);
- final ItalicAction italicAction = new ItalicAction(NONE, i18n.t("Italic"), imgResources.italic());
+ final ItalicAction italicAction = new ItalicAction(NO_TEXT, i18n.t("Italic"), imgResources.italic());
italic = new PushButtonDescriptor(italicAction);
- setActionShortcut(KeyStroke.getKeyStroke('I', Keyboard.MODIFIER_CTRL), italicAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_CTRL), italicAction);
- final UnderlineAction underlineAction = new UnderlineAction(NONE, i18n.t("Underline"), imgResources.underline());
+ final UnderlineAction underlineAction = new UnderlineAction(NO_TEXT, i18n.t("Underline"),
+ imgResources.underline());
underline = new PushButtonDescriptor(underlineAction);
- setActionShortcut(KeyStroke.getKeyStroke('U', Keyboard.MODIFIER_CTRL), underlineAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('U'), Keyboard.MODIFIER_CTRL), underlineAction);
- final SubscriptAction subscriptAction = new SubscriptAction(i18n.t("Subscript"), NONE, imgResources.subscript());
+ final SubscriptAction subscriptAction = new SubscriptAction(i18n.t("Subscript"), NO_TEXT,
+ imgResources.subscript());
final MenuItemDescriptor subscript = new MenuItemDescriptor(formatMenu, subscriptAction);
setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_COMMA, Keyboard.MODIFIER_CTRL), subscriptAction);
- final SuperscriptAction superscriptAction = new SuperscriptAction(i18n.t("Superscript"), NONE,
+ final SuperscriptAction superscriptAction = new SuperscriptAction(i18n.t("Superscript"), NO_TEXT,
imgResources.superscript());
final MenuItemDescriptor superscript = new MenuItemDescriptor(formatMenu, superscriptAction);
setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_PERIOD, Keyboard.MODIFIER_CTRL), superscriptAction);
- final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NONE, i18n.t("Left Justify"),
+ final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NO_TEXT, i18n.t("Left Justify"),
imgResources.alignleft());
final ButtonDescriptor justifyLeft = new ButtonDescriptor(jfyLeftAction);
- setActionShortcut(KeyStroke.getKeyStroke('L', Keyboard.MODIFIER_CTRL), jfyLeftAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('L'), Keyboard.MODIFIER_CTRL), jfyLeftAction);
- final JustifyCentreAction jfyCentreAction = new JustifyCentreAction(NONE, i18n.t("Centre Justify"),
+ final JustifyCentreAction jfyCentreAction = new JustifyCentreAction(NO_TEXT, i18n.t("Centre Justify"),
imgResources.centerpara());
final ButtonDescriptor justifyCentre = new ButtonDescriptor(jfyCentreAction);
- setActionShortcut(KeyStroke.getKeyStroke('E', Keyboard.MODIFIER_CTRL), jfyCentreAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('E'), Keyboard.MODIFIER_CTRL), jfyCentreAction);
- final JustifyRightAction jfyRightAction = new JustifyRightAction(NONE, i18n.t("Right Justify"),
+ final JustifyRightAction jfyRightAction = new JustifyRightAction(NO_TEXT, i18n.t("Right Justify"),
imgResources.alignright());
final ButtonDescriptor justifyRight = new ButtonDescriptor(jfyRightAction);
- setActionShortcut(KeyStroke.getKeyStroke('R', Keyboard.MODIFIER_CTRL), jfyRightAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('R'), Keyboard.MODIFIER_CTRL), jfyRightAction);
- final UndoAction undoAction = new UndoAction(i18n.t("Undo"), NONE, imgResources.undo());
- final UndoAction undoActionBtn = new UndoAction(NONE, i18n.t("Undo"), imgResources.undo());
+ final UndoAction undoAction = new UndoAction(i18n.t("Undo"), NO_TEXT, imgResources.undo());
+ final UndoAction undoActionBtn = new UndoAction(NO_TEXT, i18n.t("Undo"), imgResources.undo());
final MenuItemDescriptor undo = new MenuItemDescriptor(editMenu, undoAction);
final ButtonDescriptor undoBtn = new ButtonDescriptor(undoActionBtn);
undoBtn.setPosition(0);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_Z, Keyboard.MODIFIER_CTRL), undoAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('Z'), Keyboard.MODIFIER_CTRL), undoAction);
- final RedoAction redoAction = new RedoAction(i18n.t("Redo"), NONE, imgResources.redo());
- final RedoAction redoActionBtn = new RedoAction(NONE, i18n.t("Redo"), imgResources.redo());
+ final RedoAction redoAction = new RedoAction(i18n.t("Redo"), NO_TEXT, imgResources.redo());
+ final RedoAction redoActionBtn = new RedoAction(NO_TEXT, i18n.t("Redo"), imgResources.redo());
final MenuItemDescriptor redo = new MenuItemDescriptor(editMenu, redoAction);
final ButtonDescriptor redoBtn = new ButtonDescriptor(redoActionBtn);
redoBtn.setPosition(1);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_Y, Keyboard.MODIFIER_CTRL), redoAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('Y'), Keyboard.MODIFIER_CTRL), redoAction);
- final CopyAction copyAction = new CopyAction(i18n.t("Copy"), NONE, imgResources.copy());
+ final CopyAction copyAction = new CopyAction(i18n.t("Copy"), NO_TEXT, imgResources.copy());
final MenuItemDescriptor copy = new MenuItemDescriptor(editMenu, copyAction);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_C, Keyboard.MODIFIER_CTRL), copyAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('C'), Keyboard.MODIFIER_CTRL), copyAction);
- final CutAction cutAction = new CutAction(i18n.t("Cut"), NONE, imgResources.cut());
+ final CutAction cutAction = new CutAction(i18n.t("Cut"), NO_TEXT, imgResources.cut());
final MenuItemDescriptor cut = new MenuItemDescriptor(editMenu, cutAction);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_X, Keyboard.MODIFIER_CTRL), cutAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('X'), Keyboard.MODIFIER_CTRL), cutAction);
- final PasteAction pasteAction = new PasteAction(i18n.t("Paste"), NONE, imgResources.paste());
+ final PasteAction pasteAction = new PasteAction(i18n.t("Paste"), NO_TEXT, imgResources.paste());
final MenuItemDescriptor paste = new MenuItemDescriptor(editMenu, pasteAction);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_V, Keyboard.MODIFIER_CTRL), pasteAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('V'), Keyboard.MODIFIER_CTRL), pasteAction);
- final EditHtmlAction editHtmlAction = new EditHtmlAction(i18n.t("Edit HTML"), NONE, imgResources.edithtml());
+ final EditHtmlAction editHtmlAction = new EditHtmlAction(i18n.t("Edit HTML"), NO_TEXT, imgResources.edithtml());
final MenuItemDescriptor editHtml = new MenuItemDescriptor(editMenu, editHtmlAction);
editHtml.setAddCondition(extendedAddCond);
- final CommentAction commentAction = new CommentAction(i18n.t("Comment"), NONE, NO_ICON);
+ final CommentAction commentAction = new CommentAction(i18n.t("Comment"), NO_TEXT, NO_ICON);
final MenuItemDescriptor comment = new MenuItemDescriptor(insertMenu, commentAction);
comment.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_M, Keyboard.MODIFIER_CTRL), commentAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('M'), Keyboard.MODIFIER_CTRL), commentAction);
- final HrAction hlineAction = new HrAction(i18n.t("Horizontal line"), NONE, imgResources.hfixedline());
- final HrAction hlineBtnAction = new HrAction(NONE, i18n.t("Horizontal line"), imgResources.hfixedline());
+ final HrAction hlineAction = new HrAction(i18n.t("Horizontal line"), NO_TEXT, imgResources.hfixedline());
+ final HrAction hlineBtnAction = new HrAction(NO_TEXT, i18n.t("Horizontal line"), imgResources.hfixedline());
final MenuItemDescriptor hline = new MenuItemDescriptor(insertMenu, hlineAction);
final ButtonDescriptor hlineBtn = new ButtonDescriptor(hlineBtnAction);
hline.setAddCondition(extendedAddCond);
hlineBtn.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(' ', Keyboard.MODIFIER_CTRL & Keyboard.MODIFIER_SHIFT), hlineAction);
+ setActionShortcut(KeyStroke.getKeyStroke(' ', Keyboard.MODIFIER_CTRL + Keyboard.MODIFIER_SHIFT), hlineAction);
- final BlockquoteAction blockquoteAction = new BlockquoteAction(i18n.t("Block Quotation"), NONE,
- imgResources.hfixedline());
+ final BlockquoteAction blockquoteAction = new BlockquoteAction(i18n.t("Block Quotation"), NO_TEXT, NO_ICON);
final MenuItemDescriptor blockquote = new MenuItemDescriptor(formatMenu, blockquoteAction);
blockquote.setAddCondition(extendedAddCond);
- final StrikethroughAction strikeAction = new StrikethroughAction(NONE, i18n.t("Strikethrough"),
+ final StrikethroughAction strikeAction = new StrikethroughAction(NO_TEXT, i18n.t("Strikethrough"),
imgResources.strikeout());
strikethrough = new PushButtonDescriptor(strikeAction);
strikethrough.setAddCondition(extendedAddCond);
- final DecreaseIndentAction decreIndentAction = new DecreaseIndentAction(NONE, i18n.t("Decrease Indent"),
+ final DecreaseIndentAction decreIndentAction = new DecreaseIndentAction(NO_TEXT, i18n.t("Decrease Indent"),
imgResources.decrementindent());
final ButtonDescriptor decreaseIndent = new ButtonDescriptor(decreIndentAction);
decreaseIndent.setAddCondition(extendedAddCond);
- final IncreaseIndentAction increIndentAction = new IncreaseIndentAction(NONE, i18n.t("Increase Indent"),
+ final IncreaseIndentAction increIndentAction = new IncreaseIndentAction(NO_TEXT, i18n.t("Increase Indent"),
imgResources.incrementindent());
final ButtonDescriptor increaseIndent = new ButtonDescriptor(increIndentAction);
increaseIndent.setAddCondition(extendedAddCond);
- final OlAction olistAction = new OlAction(NONE, i18n.t("Numbered List"), imgResources.defaultnumbering());
+ final OlAction olistAction = new OlAction(NO_TEXT, i18n.t("Numbered List"), imgResources.defaultnumbering());
final ButtonDescriptor olist = new ButtonDescriptor(olistAction);
olist.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_7, Keyboard.MODIFIER_CTRL), olistAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('7'), Keyboard.MODIFIER_CTRL), olistAction);
- final UlAction ulistAction = new UlAction(NONE, i18n.t("Bullet List"), imgResources.defaultbullet());
+ final UlAction ulistAction = new UlAction(NO_TEXT, i18n.t("Bullet List"), imgResources.defaultbullet());
final ButtonDescriptor ulist = new ButtonDescriptor(ulistAction);
ulist.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_8, Keyboard.MODIFIER_CTRL), ulistAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('8'), Keyboard.MODIFIER_CTRL), ulistAction);
- final ImgAction imgAction = new ImgAction(i18n.t("Image..."), NONE, imgResources.images());
- final ImgAction imgBtnAction = new ImgAction(NONE, i18n.t("Insert Image"), imgResources.images());
+ final ImgAction imgAction = new ImgAction(i18n.t("Image..."), NO_TEXT, imgResources.images());
+ final ImgAction imgBtnAction = new ImgAction(NO_TEXT, i18n.t("Insert Image"), imgResources.images());
final MenuItemDescriptor img = new MenuItemDescriptor(insertMenu, imgAction);
final ButtonDescriptor imgBtn = new ButtonDescriptor(imgBtnAction);
img.setAddCondition(extendedAddCond);
imgBtn.setAddCondition(extendedAddCond);
- final InsertMediaAction insertMediaAction = new InsertMediaAction(i18n.t("Audio/Video..."), NONE,
+ final InsertMediaAction insertMediaAction = new InsertMediaAction(i18n.t("Audio/Video..."), NO_TEXT,
imgResources.film());
final MenuItemDescriptor insertMedia = new MenuItemDescriptor(insertMenu, insertMediaAction);
insertMedia.setAddCondition(extendedAddCond);
- final CreateOrEditLinkAction editLinkAction = new CreateOrEditLinkAction(i18n.t("Link..."), NONE,
+ final CreateOrEditLinkAction editLinkAction = new CreateOrEditLinkAction(i18n.t("Link..."), NO_TEXT,
imgResources.link());
- final CreateOrEditLinkAction editLinkBtnAction = new CreateOrEditLinkAction(NONE,
+ final CreateOrEditLinkAction editLinkBtnAction = new CreateOrEditLinkAction(NO_TEXT,
i18n.t("Create or Edit Link"), imgResources.link());
- final CreateOrEditLinkAction editLinkCtxAction = new CreateOrEditLinkAction(i18n.t("Change"), NONE,
+ final CreateOrEditLinkAction editLinkCtxAction = new CreateOrEditLinkAction(i18n.t("Change"), NO_TEXT,
imgResources.link());
final MenuItemDescriptor editLink = new MenuItemDescriptor(insertMenu, editLinkAction);
final MenuItemDescriptor editLinkCtx = new MenuItemDescriptor(linkCtxMenu, editLinkCtxAction);
@@ -1012,83 +1008,84 @@
editLink.setAddCondition(extendedAddCond);
editLinkBtn.setAddCondition(extendedAddCond);
editLinkCtx.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_K, Keyboard.MODIFIER_CTRL), editLinkAction,
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL), editLinkAction,
editLinkBtnAction);
- final KeyStroke key_K = KeyStroke.getKeyStroke(Keyboard.KEY_K, Keyboard.MODIFIER_CTRL & Keyboard.MODIFIER_SHIFT);
- final RemoveLinkAction delLinkBtnAction = new RemoveLinkAction(NONE, i18n.t("Remove Link"),
+ final KeyStroke key_SK = KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL
+ + Keyboard.MODIFIER_SHIFT);
+ final RemoveLinkAction delLinkBtnAction = new RemoveLinkAction(NO_TEXT, i18n.t("Remove Link"),
imgResources.linkbreak());
- final RemoveLinkAction delLinkCtxAction = new RemoveLinkAction(i18n.t("Remove"), NONE, imgResources.linkbreak());
+ final RemoveLinkAction delLinkCtxAction = new RemoveLinkAction(i18n.t("Remove"), NO_TEXT,
+ imgResources.linkbreak());
final MenuItemDescriptor removeLinkCtx = new MenuItemDescriptor(linkCtxMenu, delLinkCtxAction);
final ButtonDescriptor removeLinkBtn = new ButtonDescriptor(delLinkBtnAction);
removeLinkBtn.setAddCondition(extendedAddCond);
removeLinkCtx.setAddCondition(extendedAddCond);
- setActionShortcut(key_K, delLinkBtnAction);
+ setActionShortcut(key_SK, delLinkBtnAction);
- final RemoveFormatAction remFormatAction = new RemoveFormatAction(i18n.t("Clear Formatting..."), NONE,
+ final RemoveFormatAction remFormatAction = new RemoveFormatAction(i18n.t("Clear Formatting..."), NO_TEXT,
imgResources.removeFormat());
- final RemoveFormatAction remFormatBtnAc = new RemoveFormatAction(NONE, i18n.t("Clear Formatting..."),
+ final RemoveFormatAction remFormatBtnAc = new RemoveFormatAction(NO_TEXT, i18n.t("Clear Formatting..."),
imgResources.removeFormat());
final MenuItemDescriptor removeFormat = new MenuItemDescriptor(formatMenu, remFormatAction);
final ButtonDescriptor removeFormatBtn = new ButtonDescriptor(remFormatBtnAc);
removeFormat.setAddCondition(extendedAddCond);
removeFormatBtn.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(' ', Keyboard.MODIFIER_CTRL), remFormatAction, remFormatBtnAc);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(' '), Keyboard.MODIFIER_CTRL), remFormatAction,
+ remFormatBtnAc);
final InsertSpecialCharAction insCharAction = new InsertSpecialCharAction(i18n.t("Special characters..."),
- NONE, imgResources.specialchars());
+ NO_TEXT, imgResources.specialchars());
final MenuItemDescriptor insertSpecialChar = new MenuItemDescriptor(insertMenu, insCharAction);
insertSpecialChar.setAddCondition(extendedAddCond);
- final InsertTableAction insTableAction = new InsertTableAction(i18n.t("Table..."), NONE,
+ final InsertTableAction insTableAction = new InsertTableAction(i18n.t("Table..."), NO_TEXT,
imgResources.inserttable());
- final InsertTableAction insTableBtnAction = new InsertTableAction(NONE, i18n.t("Insert Table"),
+ final InsertTableAction insTableBtnAction = new InsertTableAction(NO_TEXT, i18n.t("Insert Table"),
imgResources.inserttable());
final MenuItemDescriptor insertTable = new MenuItemDescriptor(insertMenu, insTableAction);
final ButtonDescriptor insertTableBtn = new ButtonDescriptor(insTableBtnAction);
insertTable.setAddCondition(extendedAddCond);
insertTableBtn.setAddCondition(extendedAddCond);
- final FontColorAction fontColorAction = new FontColorAction(NONE, i18n.t("Text Colour"),
+ final FontColorAction fontColorAction = new FontColorAction(NO_TEXT, i18n.t("Text Colour"),
imgResources.fontcolor());
final ButtonDescriptor fontColor = new ButtonDescriptor(fontColorAction);
fontColor.setAddCondition(extendedAddCond);
- final BackgroundColorAction backColorAction = new BackgroundColorAction(NONE, i18n.t("Text Background Colour"),
- imgResources.backcolor());
+ final BackgroundColorAction backColorAction = new BackgroundColorAction(NO_TEXT,
+ i18n.t("Text Background Colour"), imgResources.backcolor());
final ButtonDescriptor backgroundColor = new ButtonDescriptor(backColorAction);
backgroundColor.setAddCondition(basicAddCond);
- final DevInfoAction devInfoAction = new DevInfoAction(i18n.t("Developers info"), NONE,
+ final DevInfoAction devInfoAction = new DevInfoAction(i18n.t("Developers info"), NO_TEXT,
imgResources.specialchars());
final MenuItemDescriptor devInfo = new MenuItemDescriptor(formatMenu, devInfoAction);
devInfo.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Keyboard.KEY_I, Keyboard.MODIFIER_ALT), devInfoAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_ALT), devInfoAction);
- fontMenu = new MenuDescriptor(NONE, i18n.t("Font"), imgResources.charfontname());
- fontSizeMenu = new MenuDescriptor(NONE, i18n.t("Font size"), imgResources.fontheight());
+ actions = new GuiActionDescCollection();
+ actions.add(fileMenu, editMenu, formatMenu, insertMenu, undo, redo, editMenuSep, copy, cut, paste, editMenuSep,
+ select, editMenuSep, editHtml, editLink, img, insertTable, insertMedia, insertMenuSep,
+ insertSpecialChar, comment, hline, removeFormat, formatMenuSep, insertMenuSep, undoBtn, redoBtn,
+ sndbarSep, bold, italic, underline, strikethrough, sndbarSep, justifyLeft, justifyCentre, justifyRight,
+ decreaseIndent, increaseIndent, olist, ulist, sndbarSep, removeFormatBtn, sndbarSep, hlineBtn, imgBtn,
+ editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSep, subscript, superscript, blockquote, fontMenu,
+ fontSizeMenu, fontColor, backgroundColor);
+ // actions.add(devInfo);
- actions = new GuiActionCollection();
- actions.add(editMenuSep, subscript, superscript, undo, redo, editMenuSep, copy, cut, paste, editMenuSep,
- select, editHtml, comment, hline, blockquote, img, insertTable, insertMedia, editLink, removeFormat,
- formatMenuSep, insertMenuSep, insertSpecialChar, insertTable, devInfo, undoBtn, redoBtn, separator,
- bold, italic, underline, strikethrough, justifyLeft, justifyCentre, justifyRight, undoBtn, redoBtn,
- hlineBtn, separator, decreaseIndent, increaseIndent, olist, ulist, separator, hlineBtn, imgBtn,
- editLinkBtn, removeLinkBtn, removeFormatBtn, separator, insertTableBtn, separator, fontColor,
- backgroundColor);
+ setLocation(TOPBAR, new GuiActionDescrip[] { fileMenu, editMenu, insertMenu, formatMenu, editMenuSep,
+ subscript, superscript, undo, redo, editMenuSep, copy, cut, paste, editMenuSep, select, editMenuSep,
+ editHtml, comment, hline, blockquote, img, insertTable, insertMedia, editLink, removeFormat,
+ formatMenuSep, insertMenuSep, insertSpecialChar, insertTable, devInfo });
+ setLocation(SNDBAR, new GuiActionDescrip[] { undoBtn, redoBtn, sndbarSep, bold, italic, underline,
+ strikethrough, justifyLeft, justifyCentre, justifyRight, undoBtn, redoBtn, hlineBtn, decreaseIndent,
+ increaseIndent, olist, ulist, hlineBtn, imgBtn, editLinkBtn, removeLinkBtn, removeFormatBtn,
+ insertTableBtn, fontColor, backgroundColor, fontMenu, fontSizeMenu });
+ setLocation(LINKCTX, new GuiActionDescrip[] { editLinkCtx, removeLinkCtx });
- setLocation(TOPBAR, new AbstractGuiActionDescrip[] { editMenuSep, subscript, superscript, undo, redo,
- editMenuSep, copy, cut, paste, editMenuSep, select, editHtml, comment, hline, blockquote, img,
- insertTable, insertMedia, editLink, removeFormat, formatMenuSep, insertMenuSep, insertSpecialChar,
- insertTable, devInfo });
- setLocation(SNDBAR, new AbstractGuiActionDescrip[] { undoBtn, redoBtn, separator, bold, italic, underline,
- strikethrough, justifyLeft, justifyCentre, justifyRight, undoBtn, redoBtn, hlineBtn, separator,
- decreaseIndent, increaseIndent, olist, ulist, separator, hlineBtn, imgBtn, editLinkBtn, removeLinkBtn,
- removeFormatBtn, separator, insertTableBtn, separator, fontColor, backgroundColor });
- setLocation(LINKCTX, new AbstractGuiActionDescrip[] { editLinkCtx, removeLinkCtx });
-
for (final String fontName : FONT_NAMES) {
- crateFontAction(fontMenu, fontName);
+ createFontAction(fontMenu, fontName);
}
for (int fontSize = 0; fontSize < FONT_SIZE_NAMES.length; fontSize++) {
@@ -1096,21 +1093,35 @@
}
}
+ private void createFontAction(final MenuDescriptor fontMenu, final String fontName) {
+ final FontAction fontAction = new FontAction(fontName, NO_TEXT, NO_ICON);
+ final MenuItemDescriptor font = new MenuItemDescriptor(fontMenu, fontAction);
+ font.setAddCondition(basicAddCond);
+ font.setLocation(SNDBAR);
+ fontMenu.setText(fontName);
+ actions.add(font);
+ }
+
private void createFontSizeAction(final MenuDescriptor fontSizeMenu, final int fontSize) {
- final FontSizeAction fontSizeAction = new FontSizeAction(i18n.t(FONT_SIZE_NAMES[fontSize]), fontSize, NONE,
- NO_ICON);
+ final String fontSizeName = i18n.t(FONT_SIZE_NAMES[fontSize]);
+ final FontSizeAction fontSizeAction = new FontSizeAction(fontSizeName, fontSize, NO_TEXT, NO_ICON);
final MenuItemDescriptor fontSizeItem = new MenuItemDescriptor(fontSizeMenu, fontSizeAction);
fontSizeItem.setAddCondition(basicAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(48 + fontSize, Keyboard.MODIFIER_CTRL), fontSizeAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char) (48 + fontSize))), Keyboard.MODIFIER_CTRL),
+ fontSizeAction);
fontSizeItem.setLocation(SNDBAR);
+ fontSizeMenu.setText(fontSizeName);
actions.add(fontSizeItem);
}
private void createMainMenus() {
- editMenu = new MenuDescriptor(i18n.t("Edit"));
- insertMenu = new MenuDescriptor(i18n.t("Insert"));
- formatMenu = new MenuDescriptor(i18n.t("Format"));
- linkCtxMenu = new MenuDescriptor(i18n.t("Change Link"));
+ menus.add(fileMenu = new MenuDescriptor(i18n.t("File")));
+ menus.add(editMenu = new MenuDescriptor(i18n.t("Edit")));
+ menus.add(insertMenu = new MenuDescriptor(i18n.t("Insert")));
+ menus.add(formatMenu = new MenuDescriptor(i18n.t("Format")));
+ menus.add(linkCtxMenu = new MenuDescriptor(i18n.t("Change Link")));
+ menus.add(fontMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font"), imgResources.charfontname()));
+ menus.add(fontSizeMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font size"), imgResources.fontheight()));
}
private void createPalette() {
@@ -1126,8 +1137,9 @@
}
private void hideMenus() {
- topBar.hideAllMenus();
- sndBar.hideAllMenus();
+ for (final MenuDescriptor menu : menus) {
+ menu.hide();
+ }
if (palette != null) {
palette.hide();
}
@@ -1137,22 +1149,10 @@
return extended && view.canBeExtended();
}
- private void setActionShortcut(final KeyStroke key, final AbstractAction mainAction,
- final AbstractAction... actions) {
- inputMap.put(key, mainAction);
- mainAction.putValue(Action.ACCELERATOR_KEY, key);
- for (final AbstractAction action : actions) {
- action.putValue(Action.ACCELERATOR_KEY, key);
- }
- }
-
- private void setLocation(final String location, final AbstractGuiActionDescrip[] descripts) {
- for (final AbstractGuiActionDescrip descript : descripts) {
+ private void setLocation(final String location, final GuiActionDescrip[] descripts) {
+ for (final GuiActionDescrip descript : descripts) {
descript.setLocation(location);
}
}
- private void styleToolbar(final ActionToolbar<Object> bar) {
- bar.setNormalStyle();
- }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,13 +1,14 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ui.GuiActionCollection;
+import org.ourproject.kune.platf.client.actions.InputMap;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
public interface RTEditorViewNew extends View {
- void addActions(GuiActionCollection actions);
+ void addActions(GuiActionDescCollection actions);
void adjustSize(int height);
@@ -33,8 +34,12 @@
String getSelectionText();
+ View getSndBar();
+
String getText();
+ View getTopBar();
+
void hideLinkCtxMenu();
void insertBlockquote();
@@ -107,6 +112,8 @@
void setHTML(String html);
+ void setInputMap(InputMap inputMap);
+
void setText(String text);
void showLinkCtxMenu();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,7 +1,7 @@
package org.ourproject.kune.platf.client.ui.rte.saving;
import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
@@ -20,7 +20,7 @@
*/
void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
- RTEditor getBasicEditor();
+ RTEditorNew getBasicEditor();
/**
* This is used for listen to changes that affect the edition as url
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,31 +1,84 @@
package org.ourproject.kune.platf.client.ui.rte.saving;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_ICON;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_TEXT;
-import org.ourproject.kune.platf.client.actions.ActionCheckedCondition;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuCheckItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.actions.KeyStroke;
+import org.ourproject.kune.platf.client.actions.ui.ButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuCheckItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
+import org.ourproject.kune.platf.client.shortcuts.Keyboard;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.img.ImgConstants;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
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 com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.libideas.resources.client.ImageResource;
public class RTESavingEditorPresenter implements RTESavingEditor {
- public static final String FILE_DEF_MENU_OPTION = "File";
- public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
- public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
+ public class AutoSaveAction extends AbstractRTEAction {
+ public AutoSaveAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
- private final RTEditor editor;
+ public void actionPerformed(final ActionEvent actionEvent) {
+ autoSave = !autoSave;
+ if (autoSave) {
+ timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+ } else {
+ timer.cancel();
+ }
+ }
+ }
+
+ public class CloseAction extends AbstractRTEAction {
+ public CloseAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ onCancelImpl();
+ }
+ }
+ public class SaveAction extends AbstractRTEAction {
+ public SaveAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ onDoSaveImpl();
+ }
+ }
+
+
+
+ public class SaveCloseAction extends AbstractRTEAction {
+ public SaveCloseAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ if (savePending) {
+ timer.cancel();
+ onDoSaveAndCloseImpl();
+ } else {
+ onCancelConfirmedImpl();
+ }
+ }
+ }
+
+ public static final String FILE_DEF_MENU_OPTION = "File";
+
+ public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
+ public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
+ private final RTEditorNew editor;
private boolean autoSave;
private boolean savePending;
private boolean saveAndCloseConfirmed;
@@ -37,10 +90,12 @@
private final I18nTranslationService i18n;
private final StateManager stateManager;
private final BeforeActionListener beforeStateChangeListener;
- ActionToolbarButtonDescriptor<Object> saveBtn;
private RTESavingEditorView view;
- public RTESavingEditorPresenter(final RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
+ SaveAction saveAction;
+ private SaveAction saveMenuAction;
+
+ public RTESavingEditorPresenter(final RTEditorNew editor, final boolean autoSave, final I18nTranslationService i18n,
final StateManager stateManager, final DeferredCommandWrapper deferredCommandWrapper,
final RTEImgResources imgResources, final TimerWrapper timer) {
this.editor = editor;
@@ -80,7 +135,7 @@
enableSaveBtn(false);
}
- public RTEditor getBasicEditor() {
+ public RTEditorNew getBasicEditor() {
return editor;
}
@@ -156,84 +211,51 @@
}
private void createActions() {
- Listener0 onPerformSaveCall = new Listener0() {
- public void onEvent() {
- onDoSaveImpl();
- }
- };
- saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.SNDBAR, onPerformSaveCall);
- saveBtn.setIconCls(ImgConstants.CSS_SUFFIX + imgResources.save().getName());
- saveBtn.setToolTip(i18n.t("Save"));
- ShortcutDescriptor ctrl_S = new ShortcutDescriptor(true, 'S');
- saveBtn.setShortcut(ctrl_S);
+
+ saveAction = new SaveAction(NO_TEXT, i18n.t("Save"),imgResources.save());
+
+ final ButtonDescriptor saveBtn = new ButtonDescriptor(saveAction);
+ final KeyStroke key_S = KeyStroke.getKeyStroke(Keyboard.KEY_S, Keyboard.MODIFIER_CTRL);
saveBtn.setPosition(0);
+ saveBtn.setLocation(RTEditorNew.SNDBAR);
- ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.TOPBAR, onPerformSaveCall);
- save.setIconCls(ImgConstants.CSS_SUFFIX + imgResources.save().getName());
- save.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION));
- save.setTextDescription(i18n.t("Save") + (ctrl_S.toString()));
- save.setPosition(0);
+ saveMenuAction = new SaveAction(i18n.t("Save"),NO_TEXT, imgResources.save());
+ final MenuItemDescriptor saveMenu = new MenuItemDescriptor(editor.getFileMenu(), saveMenuAction);
+ saveMenu.setPosition(0);
+ saveMenu.setLocation(RTEditorNew.TOPBAR);
- ActionToolbarMenuCheckItemDescriptor<Object> autoSaveMenuItem = new ActionToolbarMenuCheckItemDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.TOPBAR, new Listener0() {
- public void onEvent() {
- autoSave = !autoSave;
- if (autoSave) {
- timer.schedule(AUTOSAVE_IN_MILLISECONDS);
- } else {
- timer.cancel();
- }
- }}
- , new ActionCheckedCondition() {
- public boolean mustBeChecked() {
- return autoSave;
- }});
- autoSaveMenuItem.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION));
- autoSaveMenuItem.setTextDescription(i18n.t("Autosave"));
+ editor.setActionShortcut(key_S, saveAction, saveMenuAction);
- ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.TOPBAR, new Listener<Object>() {
- public void onEvent(final Object parameter) {
- onCancelImpl();
- }
- });
- close.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION));
- close.setTextDescription(i18n.t("Close"));
+ final AutoSaveAction autoSaveAction = new AutoSaveAction(i18n.t("Autosave"), NO_TEXT, NO_ICON);
+ final MenuCheckItemDescriptor autoSaveItem = new MenuCheckItemDescriptor(editor.getFileMenu(), autoSaveAction) { @Override
+ public boolean isChecked() {
+ //autoSaveItem.setChecked(autoSave);
+ return autoSave;
+ }};
+ autoSaveItem.setLocation(RTEditorNew.TOPBAR);
- Listener0 onPerformSaveAndCloseCall = new Listener0() {
- public void onEvent() {
- if (savePending) {
- timer.cancel();
- onDoSaveAndCloseImpl();
- } else {
- onCancelConfirmedImpl();
- }
- }
- };
- ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.TOPBAR, onPerformSaveAndCloseCall);
- saveclose.setParentMenuTitle(i18n.t(FILE_DEF_MENU_OPTION));
- saveclose.setTextDescription(i18n.t("Save & Close"));
+ final CloseAction closeAction = new CloseAction(i18n.t("Close"), NO_TEXT, NO_ICON);
+ final MenuItemDescriptor closeItem = new MenuItemDescriptor(editor.getFileMenu(), closeAction);
+ closeItem.setLocation(RTEditorNew.TOPBAR);
- ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>(
- AccessRolDTO.Editor, RTEditor.TOPBAR, onPerformSaveAndCloseCall);
- // saveCloseBtn.setIconCls(ImgConstants.CSS_SUFFIX +
- // imgResources.save().getName());
- saveCloseBtn.setTextDescription(i18n.t("Save & Close"));
- saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
+ final SaveCloseAction saveCloseAction = new SaveCloseAction(i18n.t("Save & Close"), NO_TEXT, NO_ICON);
+ final MenuItemDescriptor saveClose = new MenuItemDescriptor(editor.getFileMenu(), saveCloseAction);
+ final ButtonDescriptor saveCloseBtn = new ButtonDescriptor(saveCloseAction);
+ saveClose.setLocation(RTEditorNew.TOPBAR);
+ saveCloseBtn.setLocation(RTEditorNew.TOPBAR);
- editor.addAction(save);
- editor.addAction(autoSaveMenuItem);
- editor.addAction(saveclose);
- editor.addAction(close);
-
+ editor.addAction(saveMenu);
editor.addAction(saveBtn);
+ editor.addAction(autoSaveItem);
+ editor.addAction(saveClose);
editor.addAction(saveCloseBtn);
+ //FIXME editor.addAction(new ToolbarSeparatorDescriptor(Type.fill));
+ editor.addAction(closeItem);
}
- private void enableSaveBtn(final boolean enable) {
- editor.getSndBar().setButtonEnable(saveBtn, enable);
+ private void enableSaveBtn(final boolean enabled) {
+ saveAction.setEnabled(enabled);
+ saveMenuAction.setEnabled(enabled);
}
private void onCancelConfirmedImpl() {
@@ -247,12 +269,12 @@
private void onCancelImpl() {
if (savePending) {
timer.cancel();
- Listener0 onYes = new Listener0() {
+ final Listener0 onYes = new Listener0() {
public void onEvent() {
onDoSaveAndCloseImpl();
}
};
- Listener0 onCancel = new Listener0() {
+ final Listener0 onCancel = new Listener0() {
public void onEvent() {
onCancelConfirmedImpl();
}
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/charfontname.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/charfontname.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/fontheight.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/fontheight.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/platf/server/manager/file/FileDownloadManager.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -78,14 +78,14 @@
final String userHash = req.getParameter(FileConstants.HASH);
final StateToken stateToken = new StateToken(req.getParameter(FileConstants.TOKEN));
final String downloadS = req.getParameter(FileConstants.DOWNLOAD);
- String imageSizeS = req.getParameter(FileConstants.IMGSIZE);
+ final String imageSizeS = req.getParameter(FileConstants.IMGSIZE);
try {
- Content cnt = getContentForDownload(userHash, stateToken);
- String absFilename = buildResponse(cnt, stateToken, downloadS, imageSizeS, resp, fileUtils);
+ final Content cnt = getContentForDownload(userHash, stateToken);
+ final String absFilename = buildResponse(cnt, stateToken, downloadS, imageSizeS, resp, fileUtils);
final OutputStream out = resp.getOutputStream();
FileDownloadManagerUtils.returnFile(absFilename, out);
- } catch (ContentNotFoundException e) {
+ } catch (final ContentNotFoundException e) {
FileDownloadManagerUtils.returnNotFound(resp);
return;
}
@@ -98,15 +98,15 @@
final boolean download = downloadS != null && downloadS.equals("true") ? true : false;
final String absDir = kuneProperties.get(KuneProperties.UPLOAD_LOCATION) + FileUtils.toDir(stateToken);
String filename = cnt.getFilename();
- String title = cnt.getTitle();
+ final String title = cnt.getTitle();
String extension = FileUtils.getFileNameExtension(filename, true);
BasicMimeType mimeType = cnt.getMimeType();
- boolean isPdfAndNotDownload = mimeType != null && mimeType.isPdf() && !download;
+ final boolean isPdfAndNotDownload = mimeType != null && mimeType.isPdf() && !download;
if (mimeType != null && (mimeType.isImage() || isPdfAndNotDownload)) {
- String imgsizePrefix = imgsize == null ? "" : "." + imgsize;
- String filenameWithoutExtension = FileUtils.getFileNameWithoutExtension(filename, extension);
- String filenameResized = filenameWithoutExtension + imgsizePrefix
+ final String imgsizePrefix = imgsize == null ? "" : "." + imgsize;
+ final String filenameWithoutExtension = FileUtils.getFileNameWithoutExtension(filename, extension);
+ final String filenameResized = filenameWithoutExtension + imgsizePrefix
+ (isPdfAndNotDownload ? ".png" : extension);
if (fileUtils.exist(absDir + filenameResized)) {
filename = filenameResized;
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -49,7 +49,7 @@
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.rte.TestRTEDialog;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
@@ -874,7 +874,7 @@
register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) {
@Override
public ContentEditor create() {
- return new ContentEditor($(RTEditor.class), true, $(I18nTranslationService.class),
+ return new ContentEditor($(RTEditorNew.class), true, $(I18nTranslationService.class),
$(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
$(RTEImgResources.class), $(WorkspaceSkeleton.class), $(TimerWrapper.class),
new RTESavingEditorPanel(), $(EntityTitle.class));
Modified: 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-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -1,15 +1,19 @@
package org.ourproject.kune.workspace.client.editor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_ICON;
+import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_TEXT;
+
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+import org.ourproject.kune.platf.client.actions.KeyStroke;
+import org.ourproject.kune.platf.client.actions.ui.ComplexToolbar;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.shortcuts.Keyboard;
-import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.AbstractToolbar;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorView;
@@ -22,28 +26,37 @@
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.libideas.resources.client.ImageResource;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.ClosingEvent;
import com.google.gwt.user.client.Window.ClosingHandler;
import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.BoxComponent;
import com.gwtext.client.widgets.event.ContainerListenerAdapter;
public class ContentEditor extends RTESavingEditorPresenter {
+ public class RenameAction extends AbstractRTEAction {
+ public RenameAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ entityTitle.edit();
+ }
+ }
+
private final WorkspaceSkeleton ws;
private final VerticalPanel vp;
- private final RTEditor basicEditor;
- private final RTEditorPanel editorPanel;
- private final AbstractToolbar topbar;
+ private final RTEditorNew basicEditor;
+ private final RTEditorPanelNew editorPanel;
+ private final ComplexToolbar topbar;
private final SiteSignOutLink siteSignOutLink;
private final I18nTranslationService i18n;
private final EntityTitle entityTitle;
- private final String fileMenuTitle;
- private final AbstractToolbar sndbar;
+ private final ComplexToolbar sndbar;
- public ContentEditor(final RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
+ public ContentEditor(final RTEditorNew editor, final boolean autoSave, final I18nTranslationService i18n,
final StateManager stateManager, final SiteSignOutLink siteSignOutLink,
final DeferredCommandWrapper deferredCommandWrapper, final RTEImgResources imgResources,
final WorkspaceSkeleton ws, final TimerWrapper timer, final RTESavingEditorView view,
@@ -54,7 +67,6 @@
this.entityTitle = entityTitle;
super.init(view);
this.ws = ws;
- fileMenuTitle = i18n.t(RTESavingEditorPresenter.FILE_DEF_MENU_OPTION);
Window.addWindowClosingHandler(new ClosingHandler() {
public void onWindowClosing(final ClosingEvent event) {
if (isSavePending()) {
@@ -66,8 +78,10 @@
vp = new VerticalPanel();
basicEditor = super.getBasicEditor();
addContentActions();
- vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar());
- editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
+ editorPanel = (RTEditorPanelNew) basicEditor.getEditorArea();
+ topbar = ((ComplexToolbar) basicEditor.getTopBar());
+ sndbar = ((ComplexToolbar) basicEditor.getSndBar());
+ vp.add(sndbar);
vp.add(editorPanel);
basicEditor.setExtended(true);
vp.setWidth("100%");
@@ -78,15 +92,14 @@
adjHeight(adjHeight);
}
});
- topbar = ((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar();
- sndbar = ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar();
+
}
@Override
public void edit(final String html, final Listener<String> onSave, final Listener0 onEditCancelled) {
final Toolbar contentTopBar = ws.getEntityWorkspace().getContentTopBar();
contentTopBar.removeAll();
- contentTopBar.add((Widget) topbar);
+ contentTopBar.add(topbar);
ws.getEntityWorkspace().setContent(vp);
super.edit(html, onSave, onEditCancelled);
adjHeight(ws.getEntityWorkspace().getContentHeight());
@@ -94,7 +107,7 @@
}
public void setFileMenuTitle(final String fileMenuTitleNew) {
- basicEditor.getTopBar().setParentMenuTitle(RTEditor.TOPBAR, fileMenuTitle, null, fileMenuTitleNew);
+ basicEditor.getFileMenu().setText(fileMenuTitleNew);
}
@Override
@@ -105,17 +118,13 @@
}
private void addContentActions() {
- final ActionToolbarMenuDescriptor<Object> rename = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.TOPBAR, new Listener0() {
- public void onEvent() {
- entityTitle.edit();
- // basicEditor.setFocus(false);
- }
- });
- rename.setParentMenuTitle(fileMenuTitle);
- rename.setShortcut(new ShortcutDescriptor(false, Keyboard.KEY_F2, i18n.tWithNT("F2", "The F2 Function key")));
- rename.setTextDescription(i18n.t("Rename"));
- basicEditor.addAction(rename);
+ final RenameAction renameAction = new RenameAction(i18n.t("Rename"), NO_TEXT, NO_ICON);
+ final MenuItemDescriptor renameItem = new MenuItemDescriptor(basicEditor.getFileMenu(), renameAction);
+ renameItem.setLocation(RTEditorNew.TOPBAR);
+ final KeyStroke key = KeyStroke.getKeyStroke(Keyboard.KEY_F2, 0);
+ renameAction.putValue(Action.ACCELERATOR_KEY, key);
+ basicEditor.setActionShortcut(key, renameAction);
+ basicEditor.addAction(renameItem);
}
private void adjHeight(final int height) {
Added: trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -0,0 +1,69 @@
+package org.ourproject.kune.platf.client.actions;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
+import org.ourproject.kune.platf.client.i18n.Resources;
+import org.ourproject.kune.platf.client.shortcuts.Keyboard;
+import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
+
+public class KeyStrokeTest {
+
+ @Test
+ public void altS() {
+ final KeyStroke key = KeyStroke.getKeyStroke('S', Keyboard.MODIFIER_ALT);
+ assertEquals(" (Alt+S)", key.toString());
+ }
+
+ @Before
+ public void before() {
+ new Resources(new I18nTranslationServiceMocked());
+ }
+
+ @Test
+ public void ctrlComa() {
+ final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, ',');
+ assertEquals(" (Ctrl+,)", shortcut.toString());
+ assertTrue(shortcut.is(',', Keyboard.MODIFIER_CTRL));
+ assertTrue(!shortcut.is(',', Keyboard.MODIFIER_ALT));
+ assertTrue(!shortcut.is(',', Keyboard.MODIFIER_SHIFT));
+ }
+
+ @Test
+ public void ctrlS() {
+ final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, 's');
+ assertEquals(" (Ctrl+S)", shortcut.toString());
+ assertTrue(shortcut.is('s', Keyboard.MODIFIER_CTRL));
+ assertTrue(!shortcut.is('s', Keyboard.MODIFIER_ALT));
+ assertTrue(!shortcut.is('s', Keyboard.MODIFIER_SHIFT));
+ }
+
+ @Test
+ public void ctrlSCapital() {
+ final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, 'S');
+ assertEquals(" (Ctrl+S)", shortcut.toString());
+ assertTrue(shortcut.is('S', Keyboard.MODIFIER_CTRL));
+ assertTrue(!shortcut.is('S', Keyboard.MODIFIER_ALT));
+ assertTrue(!shortcut.is('S', Keyboard.MODIFIER_SHIFT));
+ }
+
+ @Test
+ public void ctrlShiftS() {
+ final ShortcutDescriptor shortcut = new ShortcutDescriptor(true, false, true, 'S', null);
+ assertEquals(" (Ctrl+Shift+S)", shortcut.toString());
+ assertTrue(!shortcut.is('S', Keyboard.MODIFIER_ALT));
+ assertTrue(shortcut.is('S', Keyboard.MODIFIER_SHIFT | Keyboard.MODIFIER_CTRL));
+ }
+
+ @Test
+ public void equalsTest() {
+ final KeyStroke key1 = KeyStroke.getKeyStroke(new Character('B'), Keyboard.MODIFIER_ALT);
+ final KeyStroke key2 = KeyStroke.getKeyStroke(new Character('B'), Keyboard.MODIFIER_ALT);
+ final KeyStroke key3 = KeyStroke.getKeyStroke(new Character('b'), Keyboard.MODIFIER_ALT);
+ assertEquals(key1, key2);
+ assertEquals(key1, key3);
+ }
+}
\ No newline at end of file
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-06-08 14:37:50 UTC (rev 1122)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-06-09 18:56:54 UTC (rev 1123)
@@ -7,12 +7,12 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.internal.verification.api.VerificationMode;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+import org.ourproject.kune.platf.client.actions.ui.ComplexToolbar;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
import org.ourproject.kune.platf.client.i18n.Resources;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
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;
@@ -29,25 +29,23 @@
private MockedListener0 cancelListener;
private StateManager stateManager;
private DeferredCommandWrapper deferredCommandWrapper;
- private RTEditor rteEditor;
+ private RTEditorNew rteEditor;
private TimerWrapper timer;
- @SuppressWarnings("unchecked")
- private ActionToolbar sndbar;
+ private ComplexToolbar sndbar;
private RTESavingEditorView view;
- @SuppressWarnings("unchecked")
@Before
public void createObjects() {
- I18nTranslationService i18n = new I18nTranslationServiceMocked();
+ final I18nTranslationService i18n = new I18nTranslationServiceMocked();
new Resources(i18n);
stateManager = Mockito.mock(StateManager.class);
deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.class);
- rteEditor = Mockito.mock(RTEditor.class);
- RTEImgResources imgResources = Mockito.mock(RTEImgResources.class);
- ImageResource imageResource = Mockito.mock(ImageResource.class);
+ rteEditor = Mockito.mock(RTEditorNew.class);
+ final RTEImgResources imgResources = Mockito.mock(RTEImgResources.class);
+ final ImageResource imageResource = Mockito.mock(ImageResource.class);
Mockito.when(imageResource.getName()).thenReturn("save");
Mockito.when(imgResources.save()).thenReturn(imageResource);
- sndbar = Mockito.mock(ActionToolbar.class);
+ sndbar = Mockito.mock(ComplexToolbar.class);
Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
timer = Mockito.mock(TimerWrapper.class);
view = Mockito.mock(RTESavingEditorView.class);
@@ -61,7 +59,7 @@
@Test
public void historyChangeWithoutPendingMustAccept() {
presenter.edit("Text to edit", saveListener, cancelListener);
- boolean change = presenter.beforeTokenChange();
+ final boolean change = presenter.beforeTokenChange();
assertTrue(change);
verifyAskConfirmationCalled(Mockito.never());
Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
@@ -95,7 +93,7 @@
@Test
public void initialEditWithEditionAndSave() {
presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
+ final String textModified = "Text modified";
Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onDoSave();
@@ -116,7 +114,7 @@
@Test
public void testSavePendingAndCancel() {
presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
+ final String textModified = "Text modified";
Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onCancel();
@@ -128,7 +126,7 @@
@Test
public void testSavePendingAndSaveFails() {
presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
+ final String textModified = "Text modified";
Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onDoSave();
@@ -139,16 +137,15 @@
assertTrue(saveListener.isCalled(2));
}
- @SuppressWarnings("unchecked")
private void checkSaveBtnDisabled() {
- Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
+ Mockito.verify(presenter.saveAction, Mockito.times(1)).setEnabled(false);
}
private String editAndChangeHistoryToken() {
presenter.edit("Text to edit", saveListener, cancelListener);
presenter.onEdit();
- String newToken = "somegroup";
- boolean change = presenter.beforeTokenChange();
+ final String newToken = "somegroup";
+ final boolean change = presenter.beforeTokenChange();
assertFalse(change);
verifyAskConfirmationCalled(Mockito.times(1));
return newToken;
More information about the kune-commits
mailing list