kune-commits
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- 1587 discussions
Author: vjrj
Date: 2009-06-14 22:00:52 +0200 (Sun, 14 Jun 2009)
New Revision: 1129
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/common/
trunk/src/main/java/org/ourproject/kune/platf/client/actions/common/GotoGroupAction.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/group-home.png
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/prefs.png
trunk/src/main/java/org/ourproject/kune/workspace/client/options/GroupOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/UserOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/AbstractSiteOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsView.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleCondition.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleConditionAdapter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.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/AbstractComposedGuiItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.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/BaseAction.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/GuiActionDescrip.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/SubMenuGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgConstants.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/KuneSeleniumTestHelper.java
trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java
Log:
Complete - task SiteUserOptions extensible
Incomplete - task EntityHeaderButtons table problems (100% width better to use flowpanel)
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,6 +1,5 @@
package org.ourproject.kune.platf.client.actions;
-
import com.google.gwt.libideas.resources.client.ImageResource;
public abstract class AbstractExtendedAction extends AbstractAction {
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/common/GotoGroupAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/common/GotoGroupAction.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/common/GotoGroupAction.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,23 @@
+package org.ourproject.kune.platf.client.actions.common;
+
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+import org.ourproject.kune.platf.client.state.StateManager;
+
+public class GotoGroupAction extends AbstractExtendedAction {
+ private final String name;
+ private final StateManager stateManager;
+
+ public GotoGroupAction(final String logoImageUrl, final String name, final StateManager stateManager) {
+ super();
+ this.name = name;
+ this.stateManager = stateManager;
+ putValue(Action.SMALL_ICON, logoImageUrl);
+ putValue(Action.NAME, name);
+ }
+
+ public void actionPerformed(final ActionEvent event) {
+ this.stateManager.gotoToken(name);
+ }
+}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -66,13 +66,12 @@
@Override
protected void setIcon(final ImageResource imageResource) {
- if (imageResource != null) {
- if (action.getValue(Action.NAME) == null) {
- button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
- } else {
- button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
- }
- }
+ button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
}
+ @Override
+ protected void setIconUrl(final String imageUrl) {
+ button.setIcon(imageUrl);
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -45,7 +45,7 @@
return guiItems;
}
- protected abstract void addWidget(AbstractGuiItem item, int position, boolean visible);
+ protected abstract void add(AbstractGuiItem item);
protected void beforeAddWidget(final GuiActionDescrip descrip) {
if (descrip.mustBeAdded()) {
@@ -55,9 +55,15 @@
} else {
final AbstractGuiItem item = binding.create(descrip);
if (binding.isAttachable()) {
- addWidget(item, descrip.getPosition(), descrip.mustBeVisible());
+ if (descrip.getPosition() == GuiActionDescrip.NO_POSITION) {
+ add(item);
+ } else {
+ insert(item, descrip.getPosition());
+ }
}
}
}
}
+
+ protected abstract void insert(AbstractGuiItem item, int position);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractGuiItem.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,6 +1,7 @@
package org.ourproject.kune.platf.client.actions.ui;
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.PropertyChangeEvent;
import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
@@ -10,14 +11,14 @@
public abstract class AbstractGuiItem extends Composite implements View {
- protected Action action;
+ protected AbstractAction action;
/**
* Listener the button uses to receive PropertyChangeEvents from its Action.
*/
protected PropertyChangeListener changeListener;
- public void setAction(final Action newaction) {
+ public void setAction(final AbstractAction newaction) {
if (action != null) {
action.removePropertyChangeListener(changeListener);
// removeActionListener(action);
@@ -50,9 +51,11 @@
} else if (event.getPropertyName().equals(Action.NAME)) {
setText((String) (act.getValue(Action.NAME)));
} else if (event.getPropertyName().equals(Action.SMALL_ICON)) {
- setIcon((ImageResource) (act.getValue(Action.SMALL_ICON)));
+ setIcon(action.getValue(Action.SMALL_ICON));
} else if (event.getPropertyName().equals(Action.SHORT_DESCRIPTION)) {
setToolTipText((String) (act.getValue(Action.SHORT_DESCRIPTION)));
+ } else if (event.getPropertyName().equals(GuiActionDescrip.VISIBLE)) {
+ setVisible(act);
}
// else if (e.getPropertyName().equals(Action.MNEMONIC_KEY)) {
// if (act.getValue(Action.MNEMONIC_KEY) != null) {
@@ -72,6 +75,8 @@
protected abstract void setIcon(ImageResource imageResource);
+ protected abstract void setIconUrl(String iconUrl);
+
protected abstract void setText(String text);
protected abstract void setToolTipText(String text);
@@ -84,9 +89,10 @@
setToolTipText(null);
} else {
setText((String) (action.getValue(Action.NAME)));
- setIcon((ImageResource) (action.getValue(Action.SMALL_ICON)));
+ setIcon(action.getValue(Action.SMALL_ICON));
setEnabled(action.isEnabled());
setToolTipText((String) (action.getValue(Action.SHORT_DESCRIPTION)));
+ setVisible(action);
// if (a.getValue(Action.MNEMONIC_KEY) != null) {
// setMnemonic(((Integer)
// (a.getValue(Action.MNEMONIC_KEY))).intValue());
@@ -105,4 +111,16 @@
}
}
+ private void setIcon(final Object icon) {
+ if (icon instanceof ImageResource) {
+ setIcon((ImageResource) icon);
+ } else if (icon instanceof String) {
+ setIconUrl((String) icon);
+ }
+ }
+
+ private void setVisible(final Action action) {
+ final Boolean visible = (Boolean) action.getValue(GuiActionDescrip.VISIBLE);
+ setVisible(visible == null ? true : visible);
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,5 +1,9 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.PropertyChangeEvent;
+import org.ourproject.kune.platf.client.actions.PropertyChangeListener;
+
import com.gwtext.client.widgets.menu.BaseItem;
import com.gwtext.client.widgets.menu.Menu;
@@ -25,6 +29,18 @@
menu.insert(position, item);
}
+ @Override
+ public void setAction(final AbstractAction newaction) {
+ super.setAction(newaction);
+ action.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getPropertyName().equals(MenuDescriptor.MENU_CLEAR)) {
+ menu.removeAll();
+ }
+ }
+ });
+ }
+
public void show(final int x, final int y) {
menu.showAt(x, y);
}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -49,6 +49,11 @@
}
@Override
+ public void setIconUrl(final String imageUrl) {
+ item.setIcon(imageUrl);
+ }
+
+ @Override
public void setVisible(final boolean visible) {
item.setVisible(visible);
}
@@ -69,9 +74,7 @@
@Override
protected void setIcon(final ImageResource imageResource) {
- if (imageResource != null) {
- item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
- }
+ item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
}
@Override
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BaseAction.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -7,6 +7,12 @@
import com.google.gwt.libideas.resources.client.ImageResource;
public class BaseAction extends AbstractAction {
+ public BaseAction(final String text, final String tooltip) {
+ super();
+ super.putValue(Action.NAME, text);
+ super.putValue(Action.SHORT_DESCRIPTION, tooltip);
+ }
+
public BaseAction(final String text, final String tooltip, final ImageResource icon) {
super();
super.putValue(Action.NAME, text);
@@ -14,6 +20,13 @@
super.putValue(Action.SMALL_ICON, icon);
}
+ public BaseAction(final String text, final String tooltip, final String icon) {
+ super();
+ super.putValue(Action.NAME, text);
+ super.putValue(Action.SHORT_DESCRIPTION, tooltip);
+ super.putValue(Action.SMALL_ICON, icon);
+ }
+
public void actionPerformed(final ActionEvent actionEvent) {
// Nothing to do
}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -34,14 +34,15 @@
}
@Override
- protected void addWidget(final AbstractGuiItem item, final int position, final boolean visible) {
+ protected void add(final AbstractGuiItem item) {
item.addStyleName("kune-floatleft");
- if (position == GuiActionDescrip.NO_POSITION) {
- toolbar.add(item);
- } else {
- toolbar.insert(item, position);
- }
- item.setVisible(visible);
+ toolbar.add(item);
}
+ @Override
+ protected void insert(final AbstractGuiItem item, final int position) {
+ item.addStyleName("kune-floatleft");
+ toolbar.insert(item, position);
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -9,13 +9,13 @@
* The Class AbstractUIActionDescriptor.
*/
public abstract class GuiActionDescrip { // NOPMD by vjrj on 9/06/09 2:00
+ public static final String VISIBLE = "visibleprop";
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;
@@ -89,10 +89,6 @@
return action.getValue(key);
}
- public GuiVisibleCondition getVisibleCondition() {
- return visibleCondition;
- }
-
public boolean isChild() {
// @PMD:REVIEWED:CompareObjectsWithEquals: by vjrj on 26/05/09 20:57
return parent != NO_PARENT;
@@ -106,14 +102,6 @@
return result;
}
- public boolean mustBeVisible() {
- boolean result = false;
- if (visibleCondition != null) {
- result = visibleCondition.mustBeVisible();
- }
- return result;
- }
-
/**
* Sets the value associated with the specified key.
*
@@ -132,6 +120,10 @@
this.addCondition = addCondition;
}
+ public void setEnabled(final boolean enabled) {
+ action.setEnabled(enabled);
+ }
+
/**
* 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
@@ -159,8 +151,8 @@
this.position = position;
}
- public void setVisibleCondition(final GuiVisibleCondition visibleCondition) {
- this.visibleCondition = visibleCondition;
+ public void setVisible(final boolean visible) {
+ action.putValue(VISIBLE, visible);
}
@Override
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleCondition.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleCondition.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleCondition.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-public interface GuiVisibleCondition {
-
- boolean mustBeVisible();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleConditionAdapter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleConditionAdapter.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiVisibleConditionAdapter.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,9 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-public class GuiVisibleConditionAdapter implements GuiVisibleCondition {
-
- public boolean mustBeVisible() {
- return true;
- }
-
-}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -8,11 +8,14 @@
public class MenuDescriptor extends GuiActionDescrip {
public static final String MENU_HIDE = "hidemenu";
+ public static final String MENU_SHOW = "showmenu";
+ public static final String MENU_SHOW_ID = "showmenuid";
+ public static final String MENU_CLEAR = "menuclear";
private boolean standalone;
public MenuDescriptor() {
- this(new BaseAction(null, null, null));
+ this(new BaseAction(null, null));
}
public MenuDescriptor(final AbstractAction action) {
@@ -23,11 +26,13 @@
super(action);
setParent(parent);
action.putValue(MENU_HIDE, false);
+ action.putValue(MENU_SHOW, false);
+ action.putValue(MENU_CLEAR, false);
standalone = false;
}
public MenuDescriptor(final String text) {
- this(new BaseAction(text, null, null));
+ this(new BaseAction(text, null));
}
public MenuDescriptor(final String text, final ImageResource icon) {
@@ -35,13 +40,23 @@
}
public MenuDescriptor(final String text, final String tooltip) {
- this(new BaseAction(text, tooltip, null));
+ this(new BaseAction(text, tooltip));
}
public MenuDescriptor(final String text, final String tooltip, final ImageResource icon) {
this(new BaseAction(text, tooltip, icon));
}
+ public MenuDescriptor(final String text, final String tooltip, final String icon) {
+ this(new BaseAction(text, tooltip, icon));
+ }
+
+ public void clear() {
+ // Action detects changes in values, then we fire a change (whatever) to
+ // fire this method in the UI
+ action.putValue(MENU_CLEAR, !((Boolean) action.getValue(MENU_CLEAR)));
+ }
+
@Override
public Class<?> getType() {
return MenuDescriptor.class;
@@ -70,4 +85,14 @@
action.putValue(Action.NAME, text);
}
+ /**
+ * Show the menu near the Element id specified
+ *
+ * @param id
+ * the element id to show menu near of it
+ */
+ public void show(final String id) {
+ action.putValue(MENU_SHOW_ID, id);
+ action.putValue(MENU_SHOW, !((Boolean) action.getValue(MENU_SHOW)));
+ }
}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,10 +1,12 @@
package org.ourproject.kune.platf.client.actions.ui;
+import org.ourproject.kune.platf.client.actions.Action;
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;
+import com.google.gwt.user.client.ui.UIObject;
import com.gwtext.client.widgets.ToolbarButton;
public class MenuGui extends AbstractMenuGui {
@@ -14,7 +16,6 @@
public MenuGui(final MenuDescriptor descriptor) {
super();
- setAction(descriptor.action);
// Standalone menus are menus without and associated button in a toolbar
// (sometimes, a menu showed in a grid, or other special widgets)
notStandAlone = !descriptor.isStandalone();
@@ -22,7 +23,10 @@
button = new ToolbarButton();
button.setMenu(menu);
initWidget(button);
+ } else {
+ initWidget(menu);
}
+ setAction(descriptor.action);
descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent event) {
if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE)) {
@@ -30,6 +34,13 @@
}
}
});
+ descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getPropertyName().equals(MenuDescriptor.MENU_SHOW)) {
+ menu.show(UIObject.DEBUG_ID_PREFIX + (String) descriptor.getValue(MenuDescriptor.MENU_SHOW_ID));
+ }
+ }
+ });
}
@Override
@@ -46,8 +57,16 @@
@Override
public void setIcon(final ImageResource imageResource) {
if (notStandAlone) {
- if (imageResource != null) {
- button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
+ button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
+ }
+ }
+
+ @Override
+ public void setIconUrl(final String imageUrl) {
+ if (notStandAlone) {
+ button.setIcon(imageUrl);
+ if (action.getValue(Action.NAME) != null) {
+ button.setCls("x-btn-text-icon");
}
}
}
@@ -65,4 +84,13 @@
button.setTooltip(tooltip);
}
}
+
+ @Override
+ public void setVisible(final boolean visible) {
+ if (notStandAlone) {
+ button.setVisible(visible);
+ } else {
+ menu.setVisible(visible);
+ }
+ }
}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -14,7 +14,7 @@
item = new MenuItem();
item.setMenu(menu);
setAction(descriptor.action);
- initWidget(item);
+ // initWidget(item);
}
public MenuItem getMenuItem() {
@@ -32,12 +32,15 @@
@Override
public void setIcon(final ImageResource imageResource) {
- if (imageResource != null) {
- item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
- }
+ item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
}
@Override
+ public void setIconUrl(final String imageUrl) {
+ item.setIcon(imageUrl);
+ }
+
+ @Override
public void setText(final String text) {
item.setText(text);
}
@@ -46,4 +49,9 @@
public void setToolTipText(final String tooltip) {
item.setTitle(tooltip);
}
+
+ @Override
+ public void setVisible(final boolean visible) {
+ item.setVisible(visible);
+ }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgConstants.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgConstants.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgConstants.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,12 +1,17 @@
package org.ourproject.kune.platf.client.ui.img;
+import com.google.gwt.libideas.resources.client.ImageResource;
+
public final class ImgConstants {
public static final String CSS_SUFFIX = "k-icon-";
public static final String PATH_PREFIX = "images/";
+ public static String toPath(final ImageResource img) {
+ return PATH_PREFIX + img.getName() + ".png";
+ }
+
private ImgConstants() {
}
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -9,6 +9,9 @@
@Resource("kimg.css")
CssResource css();
+ @Resource("group-home.png")
+ ImageResource groupHome();
+
@Resource("info.png")
ImageResource info();
@@ -18,4 +21,6 @@
@Resource("language.png")
ImageResource language();
+ @Resource("prefs.png")
+ ImageResource prefs();
}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/group-home.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/group-home.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/prefs.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/prefs.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -31,6 +31,7 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.shortcuts.Keyboard;
import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.img.ImgConstants;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
@@ -682,6 +683,7 @@
final Provider<InsertImageDialog> insertImageDialog, final Provider<InsertMediaDialog> insertMediaDialog,
final Provider<InsertTableDialog> insertTableDialog, final Provider<InsertSpecialCharDialog> insCharDialog,
final DeferredCommandWrapper deferred) {
+ super();
this.i18n = i18n;
this.session = session;
this.insLinkDialogPv = insLinkDialog;
@@ -734,6 +736,7 @@
}
public void detach() {
+ // Nothing at the moment
}
public void fireOnEdit() {
@@ -1148,8 +1151,10 @@
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()));
+ menus.add(fontMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font"),
+ ImgConstants.toPath(imgResources.charfontname())));
+ menus.add(fontSizeMenu = new MenuDescriptor(NO_TEXT, i18n.t("Font size"),
+ ImgConstants.toPath(imgResources.fontheight())));
insertMenu.setAddCondition(extendedAddCond);
}
@@ -1181,15 +1186,15 @@
private void updateFont() {
final String currentFont = view.getFont();
final MenuCheckItemDescriptor item = fontActions.get(currentFont);
- if (currentFontItem != null && item != currentFontItem) {
+ if (currentFontItem != null && !currentFontItem.equals(item)) {
currentFontItem.setChecked(false);
}
- if (item != null) {
+ if (item == null) {
+ fontMenu.setText(" ");
+ } else {
item.setChecked(true);
currentFontItem = item;
fontMenu.setText((String) item.getValue(FontAction.FONT_NAME));
- } else {
- fontMenu.setText(" ");
}
}
}
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-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -128,6 +128,8 @@
import org.ourproject.kune.workspace.client.options.EntityOptions;
import org.ourproject.kune.workspace.client.options.EntityOptionsPanel;
import org.ourproject.kune.workspace.client.options.EntityOptionsPresenter;
+import org.ourproject.kune.workspace.client.options.GroupOptions;
+import org.ourproject.kune.workspace.client.options.UserOptions;
import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicense;
import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePanel;
import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePresenter;
@@ -193,9 +195,9 @@
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLinkPanel;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLinkPresenter;
-import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserMenu;
-import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserMenuPanel;
-import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserMenuPresenter;
+import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserOptions;
+import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserOptionsPanel;
+import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserOptionsPresenter;
import org.ourproject.kune.workspace.client.skel.ActionCntCtxToolbarPanel;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import org.ourproject.kune.workspace.client.socialnet.BuddiesSummary;
@@ -327,13 +329,14 @@
}
});
- register(ApplicationComponentGroup.class, new Factory<SiteUserMenu>(SiteUserMenu.class) {
+ register(ApplicationComponentGroup.class, new Factory<SiteUserOptions>(SiteUserOptions.class) {
@Override
- public SiteUserMenu create() {
- final SiteUserMenuPresenter presenter = new SiteUserMenuPresenter(i(Session.class),
- i(StateManager.class), p(EntityOptions.class), p(FileDownloadUtils.class));
- final SiteUserMenuPanel panel = new SiteUserMenuPanel(presenter, i(WorkspaceSkeleton.class),
- i(I18nUITranslationService.class));
+ public SiteUserOptions create() {
+ final SiteUserOptionsPresenter presenter = new SiteUserOptionsPresenter(i(Session.class),
+ i(StateManager.class), p(UserOptions.class), p(FileDownloadUtils.class),
+ $(I18nTranslationService.class), $(ImgResources.class));
+ final SiteUserOptionsPanel panel = new SiteUserOptionsPanel(presenter, i(WorkspaceSkeleton.class),
+ $(GuiBindingsRegister.class));
presenter.init(panel);
return presenter;
}
@@ -616,6 +619,20 @@
}
});
+ register(Singleton.class, new Factory<GroupOptions>(GroupOptions.class) {
+ @Override
+ public GroupOptions create() {
+ return (GroupOptions) i(EntityOptions.class);
+ }
+ });
+
+ register(Singleton.class, new Factory<UserOptions>(UserOptions.class) {
+ @Override
+ public UserOptions create() {
+ return (UserOptions) i(EntityOptions.class);
+ }
+ });
+
register(EntityOptionsGroup.class, new Factory<EntityOptionsToolsConf>(EntityOptionsToolsConf.class) {
@Override
public EntityOptionsToolsConf create() {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -25,9 +25,9 @@
import com.calclab.suco.client.events.Listener;
-public class EntityOptionsPresenter extends AbstractTabbedDialogPresenter implements EntityOptions {
+public class EntityOptionsPresenter extends AbstractTabbedDialogPresenter implements GroupOptions, UserOptions {
- EntityOptionsView view;
+ private EntityOptionsView view;
public EntityOptionsPresenter(final StateManager stateManager) {
stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/options/GroupOptions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/GroupOptions.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/GroupOptions.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,4 @@
+package org.ourproject.kune.workspace.client.options;
+
+public interface GroupOptions extends EntityOptions {
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/options/UserOptions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/UserOptions.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/UserOptions.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,4 @@
+package org.ourproject.kune.workspace.client.options;
+
+public interface UserOptions extends EntityOptions {
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/AbstractSiteOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/AbstractSiteOptionsPanel.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/AbstractSiteOptionsPanel.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,52 @@
+package org.ourproject.kune.workspace.client.sitebar.siteoptions;
+
+import org.ourproject.kune.platf.client.actions.ui.AbstractComposedGuiItem;
+import org.ourproject.kune.platf.client.actions.ui.AbstractGuiItem;
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.PushButton;
+
+public abstract class AbstractSiteOptionsPanel extends AbstractComposedGuiItem {
+
+ protected final PushButton btn;
+ private MenuDescriptor menuDescriptor;
+
+ public AbstractSiteOptionsPanel(final GuiBindingsRegister bindings, final String id) {
+ super(bindings);
+ btn = new PushButton("");
+ btn.ensureDebugId(id);
+ btn.addClickHandler(new ClickHandler() {
+ public void onClick(final ClickEvent event) {
+ menuDescriptor.show(id);
+ }
+ });
+ btn.setStyleName("k-sitebar-labellink");
+ }
+
+ public void setBtnText(final String title) {
+ btn.setHTML(title + "<img style=\"vertical-align: middle;\" src=\"images/arrowdown.png\" />");
+ }
+
+ public void setMenu(final MenuDescriptor menuDescriptor) {
+ this.menuDescriptor = menuDescriptor;
+ }
+
+ @Override
+ protected void add(final AbstractGuiItem item) { // NOPMD by vjrj on
+ // 14/06/09 0:15
+ // Do nothing (menu items are attached automatically to its menu
+ }
+
+ @Override
+ protected void insert(final AbstractGuiItem item, final int position) { // NOPMD
+ // by
+ // vjrj
+ // on
+ // 14/06/09
+ // 0:15
+ // Do nothing (menu items are attached automatically to its menu
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -19,52 +19,23 @@
\*/
package org.ourproject.kune.workspace.client.sitebar.siteoptions;
-import org.ourproject.kune.platf.client.actions.ui.AbstractComposedGuiItem;
-import org.ourproject.kune.platf.client.actions.ui.AbstractGuiItem;
-import org.ourproject.kune.platf.client.actions.ui.AbstractMenuGui;
import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
-import org.ourproject.kune.platf.client.actions.ui.MenuBinding;
-import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.ui.AbstractToolbar;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.PushButton;
+public class SiteOptionsPanel extends AbstractSiteOptionsPanel implements SiteOptionsView {
-public class SiteOptionsPanel extends AbstractComposedGuiItem implements SiteOptionsView {
+ public static final String SITE_OPTIONS_MENU = "kune-sop-om";
- private static final String BTN_ID = "k-sopts-btn-id";
- private AbstractMenuGui menu;
-
public SiteOptionsPanel(final WorkspaceSkeleton wspace, final I18nUITranslationService i18n,
final GuiBindingsRegister bindings) {
- super(bindings);
- final PushButton optionsButton = new PushButton("");
- // optionsButton.setText(i18n.t("Options"));
- optionsButton.setHTML(i18n.t("Options")
- + "<img style=\"vertical-align: middle;\" src=\"images/arrowdown.png\" />");
- optionsButton.setStyleName("k-sitebar-labellink");
- optionsButton.ensureDebugId(BTN_ID);
- wspace.getSiteBar().addSeparator();
- wspace.getSiteBar().add(optionsButton);
- wspace.getSiteBar().addSpacer();
- wspace.getSiteBar().addSpacer();
-
- optionsButton.addClickHandler(new ClickHandler() {
- public void onClick(final ClickEvent event) {
- menu.show(optionsButton.getElement().getId());
- }
- });
+ super(bindings, SITE_OPTIONS_MENU);
+ setBtnText(i18n.t("Options"));
+ final AbstractToolbar siteBar = wspace.getSiteBar();
+ siteBar.addSeparator();
+ siteBar.add(btn);
+ siteBar.addSpacer();
+ siteBar.addSpacer();
}
-
- public void setMenu(final MenuDescriptor menuDescriptor) {
- menu = (AbstractMenuGui) menuDescriptor.getValue(MenuBinding.UI_MENU);
- }
-
- @Override
- protected void addWidget(final AbstractGuiItem item, final int position, final boolean visible) {
- // Do nothing (menu items are attached automatically to its menu
- }
-
}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,24 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- \*/
-package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
-
-public interface SiteUserMenu {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,119 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- \*/
-package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
-
-import org.ourproject.kune.platf.client.PlatfMessages;
-import org.ourproject.kune.platf.client.dto.GroupDTO;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.ui.AbstractToolbar;
-import org.ourproject.kune.platf.client.ui.MenuItemCollection;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.event.dom.client.ClickEvent;
-import com.google.gwt.event.dom.client.ClickHandler;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.menu.BaseItem;
-import com.gwtext.client.widgets.menu.Item;
-import com.gwtext.client.widgets.menu.Menu;
-import com.gwtext.client.widgets.menu.MenuItem;
-import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
-
-public class SiteUserMenuPanel implements SiteUserMenuView {
-
- public static final String LOGGED_USER_MENU = "kune-sump-lum";
- public static final String USER_PREFERENCES_MENU_ITEM = "kune-sump-uprmi";
- public static final String USER_HOME_PAGE_MENU_ITEM = "kune-sump-hpmi";
- public static final String USER_PARTICIPATION_MENU_ITEM = "kune-sump-upami";
- private final PushButton loggedUserMenu;
- private final Widget separator;
- private final Menu userMenu;
- private final Menu userParticipation;
-
- public SiteUserMenuPanel(final SiteUserMenuPresenter presenter, final WorkspaceSkeleton ws,
- final I18nUITranslationService i18n) {
- loggedUserMenu = new PushButton("");
- loggedUserMenu.ensureDebugId(LOGGED_USER_MENU);
- loggedUserMenu.setStyleName("k-sitebar-labellink");
- final AbstractToolbar siteBar = ws.getSiteBar();
- siteBar.add(loggedUserMenu);
- separator = siteBar.addSeparator();
- userMenu = new Menu();
- loggedUserMenu.addClickHandler(new ClickHandler() {
- public void onClick(final ClickEvent event) {
- final Element sender = event.getRelativeElement();
- userMenu.showAt(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 10);
- }
- });
- final Item userHomePage = new Item(i18n.t(PlatfMessages.YOUR_HOMEPAGE));
- userHomePage.setId(USER_HOME_PAGE_MENU_ITEM);
- userHomePage.setIcon("images/group-home.gif");
- userHomePage.addListener(new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- super.onClick(item, e);
- presenter.onUserHomePage();
- }
- });
- userMenu.addItem(userHomePage);
- final Item userPreferences = new Item(i18n.t("Your preferences"));
- userPreferences.setId(USER_PREFERENCES_MENU_ITEM);
- userPreferences.setIcon("images/emblem-system.png");
- userPreferences.addListener(new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- super.onClick(item, e);
- presenter.onUserPreferences();
- }
- });
- userMenu.addItem(userPreferences);
- userParticipation = new Menu();
- userParticipation.setId(USER_PARTICIPATION_MENU_ITEM);
- final MenuItem userParticipationItem = new MenuItem(i18n.t("Your groups"), userParticipation);
- userParticipationItem.setIcon("");
- userMenu.addItem(userParticipationItem);
- }
-
- public void setLoggedUserName(final String name) {
- loggedUserMenu.setHTML(name + "<img style=\"vertical-align: middle;\" src=\"images/arrowdown.png\" />");
- }
-
- public void setParticipation(final MenuItemCollection<GroupDTO> participateInGroups) {
- userParticipation.removeAll();
- for (final org.ourproject.kune.platf.client.ui.MenuItem<GroupDTO> groupItem : participateInGroups) {
- final Item item = new Item(groupItem.getTitle(), new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- super.onClick(item, e);
- groupItem.fire(null);
- }
- });
- item.setIcon(groupItem.getIcon());
- userParticipation.addItem(item);
- }
- }
-
- public void setVisible(final boolean visible) {
- loggedUserMenu.setVisible(visible);
- separator.setVisible(visible);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,106 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- \*/
-package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.dto.GroupDTO;
-import org.ourproject.kune.platf.client.dto.UserInfoDTO;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.MenuItem;
-import org.ourproject.kune.platf.client.ui.MenuItemCollection;
-import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
-import org.ourproject.kune.workspace.client.options.EntityOptions;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.client.ioc.Provider;
-
-public class SiteUserMenuPresenter implements SiteUserMenu {
-
- private SiteUserMenuView view;
- private final MenuItemCollection<GroupDTO> participateInGroups;
- private final StateManager stateManager;
- private final Session session;
- private final Provider<EntityOptions> entityOptions;
- private final Provider<FileDownloadUtils> downloadProvider;
-
- public SiteUserMenuPresenter(final Session session, final StateManager stateManager,
- final Provider<EntityOptions> entityOptions, final Provider<FileDownloadUtils> downloadProvider) {
- this.session = session;
- this.stateManager = stateManager;
- this.entityOptions = entityOptions;
- this.downloadProvider = downloadProvider;
- participateInGroups = new MenuItemCollection<GroupDTO>();
- session.onUserSignIn(new Listener<UserInfoDTO>() {
- public void onEvent(final UserInfoDTO userInfoDTO) {
- onUserSignIn(userInfoDTO);
- }
-
- });
- session.onUserSignOut(new Listener0() {
- public void onEvent() {
- view.setVisible(false);
- view.setLoggedUserName("");
- }
- });
- }
-
- public View getView() {
- return view;
- }
-
- public void init(final SiteUserMenuView view) {
- this.view = view;
- }
-
- public void onUserHomePage() {
- stateManager.gotoToken(session.getCurrentUserInfo().getShortName());
- }
-
- public void onUserPreferences() {
- onUserHomePage();
- entityOptions.get().show();
- }
-
- private void addPartipation(final GroupDTO group) {
- String logoImageUrl = group.hasLogo() ? downloadProvider.get().getLogoImageUrl(group.getStateToken())
- : "images/group-def-icon.gif";
- participateInGroups.add(new MenuItem<GroupDTO>(logoImageUrl, group.getShortName(), new Listener<GroupDTO>() {
- public void onEvent(final GroupDTO param) {
- stateManager.gotoToken(group.getShortName());
- }
- }));
- }
-
- private void onUserSignIn(final UserInfoDTO userInfoDTO) {
- view.setVisible(true);
- view.setLoggedUserName(userInfoDTO.getShortName());
- participateInGroups.clear();
- for (final GroupDTO group : userInfoDTO.getGroupsIsAdmin()) {
- addPartipation(group);
- }
- for (final GroupDTO group : userInfoDTO.getGroupsIsCollab()) {
- addPartipation(group);
- }
- view.setParticipation(participateInGroups);
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -1,34 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- \*/
-package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.dto.GroupDTO;
-import org.ourproject.kune.platf.client.ui.MenuItemCollection;
-
-public interface SiteUserMenuView extends View {
-
- void setLoggedUserName(String name);
-
- void setParticipation(MenuItemCollection<GroupDTO> participateInGroups);
-
- void setVisible(boolean visible);
-
-}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptions.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenu.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptions.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,25 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
+
+import org.ourproject.kune.platf.client.actions.ui.IsActionExtensible;
+
+public interface SiteUserOptions extends IsActionExtensible {
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPanel.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPanel.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPanel.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,52 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
+
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.ui.AbstractToolbar;
+import org.ourproject.kune.workspace.client.sitebar.siteoptions.AbstractSiteOptionsPanel;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.user.client.ui.Widget;
+
+public class SiteUserOptionsPanel extends AbstractSiteOptionsPanel implements SiteUserOptionsView {
+
+ public static final String LOGGED_USER_MENU = "kune-sump-lum";
+
+ private final Widget separator;
+
+ public SiteUserOptionsPanel(final SiteUserOptionsPresenter presenter, final WorkspaceSkeleton wspace,
+ final GuiBindingsRegister bindings) {
+ super(bindings, LOGGED_USER_MENU);
+ final AbstractToolbar siteBar = wspace.getSiteBar();
+ siteBar.add(btn);
+ separator = siteBar.addSeparator();
+ }
+
+ public void setLoggedUserName(final String name) {
+ setBtnText(name);
+ }
+
+ @Override
+ public void setVisible(final boolean visible) {
+ btn.setVisible(visible);
+ separator.setVisible(visible);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPresenter.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuPresenter.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsPresenter.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,158 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
+
+import java.util.List;
+
+import org.ourproject.kune.platf.client.PlatfMessages;
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+import org.ourproject.kune.platf.client.actions.common.GotoGroupAction;
+import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensiblePresenter;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.dto.GroupDTO;
+import org.ourproject.kune.platf.client.dto.UserInfoDTO;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
+import org.ourproject.kune.platf.client.ui.img.ImgResources;
+import org.ourproject.kune.workspace.client.options.UserOptions;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Provider;
+
+public class SiteUserOptionsPresenter extends AbstractActionExtensiblePresenter implements SiteUserOptions {
+
+ private SiteUserOptionsView view;
+ private final StateManager stateManager;
+ private final Session session;
+ private final Provider<UserOptions> userOptions;
+ private final Provider<FileDownloadUtils> downloadProvider;
+ private MenuDescriptor menuDescriptor;
+ private final I18nTranslationService i18n;
+ private final ImgResources img;
+
+ private MenuDescriptor partiMenu;;
+
+ public SiteUserOptionsPresenter(final Session session, final StateManager stateManager,
+ final Provider<UserOptions> userOptions, final Provider<FileDownloadUtils> downloadProvider,
+ final I18nTranslationService i18n, final ImgResources img) {
+ super();
+ this.session = session;
+ this.stateManager = stateManager;
+ this.userOptions = userOptions;
+ this.downloadProvider = downloadProvider;
+ this.i18n = i18n;
+ this.img = img;
+ session.onUserSignIn(new Listener<UserInfoDTO>() {
+ public void onEvent(final UserInfoDTO userInfoDTO) {
+ onUserSignIn(userInfoDTO);
+ }
+
+ });
+ session.onUserSignOut(new Listener0() {
+ public void onEvent() {
+ view.setVisible(false);
+ view.setLoggedUserName("");
+ }
+ });
+ }
+
+ @Override
+ public void addAction(final GuiActionDescrip descriptor) {
+ descriptor.setParent(menuDescriptor);
+ view.addAction(descriptor);
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(final SiteUserOptionsView view) {
+ this.view = view;
+ createActions();
+ }
+
+ private void addPartipation(final GroupDTO group) {
+ final String logoImageUrl = group.hasLogo() ? downloadProvider.get().getLogoImageUrl(group.getStateToken())
+ : "images/group-def-icon.gif";
+ final GotoGroupAction gotoGroupAction = new GotoGroupAction(logoImageUrl, group.getLongName(), stateManager);
+ view.addAction(new MenuItemDescriptor(partiMenu, gotoGroupAction));
+ }
+
+ private void createActions() {
+ menuDescriptor = new MenuDescriptor();
+ menuDescriptor.setStandalone(true);
+ view.addAction(menuDescriptor);
+ view.setMenu(menuDescriptor);
+
+ partiMenu = new MenuDescriptor(i18n.t("Your groups"));
+ addAction(partiMenu);
+
+ final AbstractExtendedAction userHomeAction = new AbstractExtendedAction() {
+ public void actionPerformed(final ActionEvent event) {
+ goUserHome();
+ }
+ };
+ userHomeAction.putValue(Action.NAME, i18n.t(PlatfMessages.YOUR_HOMEPAGE));
+ userHomeAction.putValue(Action.SMALL_ICON, img.groupHome());
+ final MenuItemDescriptor item = new MenuItemDescriptor(userHomeAction);
+ item.setPosition(0);
+ addAction(item);
+
+ final AbstractExtendedAction userPrefsAction = new AbstractExtendedAction() {
+ public void actionPerformed(final ActionEvent event) {
+ goUserHome();
+ userOptions.get().show();
+ }
+ };
+ userPrefsAction.putValue(Action.NAME, i18n.t("Your preferences"));
+ userPrefsAction.putValue(Action.SMALL_ICON, img.prefs());
+ final MenuItemDescriptor prefsItem = new MenuItemDescriptor(userPrefsAction);
+ prefsItem.setPosition(1);
+ addAction(prefsItem);
+ }
+
+ private void goUserHome() {
+ stateManager.gotoToken(session.getCurrentUserInfo().getShortName());
+ }
+
+ private void onUserSignIn(final UserInfoDTO userInfoDTO) {
+ view.setVisible(true);
+ view.setLoggedUserName(userInfoDTO.getShortName());
+ partiMenu.clear();
+ final List<GroupDTO> groupsIsAdmin = userInfoDTO.getGroupsIsAdmin();
+ final List<GroupDTO> groupsIsCollab = userInfoDTO.getGroupsIsCollab();
+ for (final GroupDTO group : groupsIsAdmin) {
+ addPartipation(group);
+ }
+ for (final GroupDTO group : groupsIsCollab) {
+ addPartipation(group);
+ }
+ partiMenu.setVisible(!groupsIsAdmin.isEmpty() || !groupsIsCollab.isEmpty());
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsView.java (from rev 1121, trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserMenuView.java 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteusermenu/SiteUserOptionsView.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -0,0 +1,33 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.workspace.client.sitebar.siteusermenu;
+
+import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensibleView;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+
+public interface SiteUserOptionsView extends AbstractActionExtensibleView {
+
+ void setLoggedUserName(String name);
+
+ void setMenu(MenuDescriptor menuDescriptor);
+
+ void setVisible(boolean visible);
+
+}
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/KuneSeleniumTestHelper.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/KuneSeleniumTestHelper.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/KuneSeleniumTestHelper.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -19,7 +19,7 @@
import org.ourproject.kune.workspace.client.site.SiteToken;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPanel;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLinkPanel;
-import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserMenuPanel;
+import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserOptionsPanel;
import org.ourproject.kune.workspace.client.title.EntityTitlePanel;
import com.thoughtworks.selenium.SeleniumException;
@@ -192,6 +192,6 @@
}
protected void verifyLoggedUserShorName(final String userShortName) throws Exception {
- waitForTextInside(gid(SiteUserMenuPanel.LOGGED_USER_MENU), userShortName);
+ waitForTextInside(gid(SiteUserOptionsPanel.LOGGED_USER_MENU), userShortName);
}
}
Modified: trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java 2009-06-13 00:43:29 UTC (rev 1128)
+++ trunk/src/test/java/org/ourproject/kune/platf/integration/selenium/SignInSeleniumTest.java 2009-06-14 20:00:52 UTC (rev 1129)
@@ -13,7 +13,7 @@
import org.ourproject.kune.workspace.client.signin.SignInPanel;
import org.ourproject.kune.workspace.client.site.SiteToken;
import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPanel;
-import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserMenuPanel;
+import org.ourproject.kune.workspace.client.sitebar.siteusermenu.SiteUserOptionsPanel;
import org.ourproject.kune.workspace.client.title.EntityTitlePanel;
public class SignInSeleniumTest extends KuneSeleniumTestHelper {
@@ -49,7 +49,7 @@
registerValidUser(false);
selenium.isTextPresent("Welcome");
click(RegisterPanel.WELCOME_OK_BUTTON);
- clickOnPushButton(gid(SiteUserMenuPanel.LOGGED_USER_MENU));
+ clickOnPushButton(gid(SiteUserOptionsPanel.LOGGED_USER_MENU));
click(linkId(PlatfMessages.YOUR_HOMEPAGE));
waitForTextInside(gid(NoHomePagePanel.NO_HOME_PAGE_LABEL), PlatfMessages.USER_DOESN_T_HAVE_A_HOMEPAGE);
}
1
0
Author: vjrj
Date: 2009-06-13 02:43:29 +0200 (Sat, 13 Jun 2009)
New Revision: 1128
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensiblePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensibleView.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBindings.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/IsActionExtensible.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kune-icon16.png
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/language.png
trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/SiteOptionsI18nTranslatorAction.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java
Modified:
trunk/pom.xml
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.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/ComplexToolbar.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/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/MenuItemDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsView.java
Log:
Complete - task Hello World updated and Application Boot improved
Complete - task SiteOptions use of new Actions class
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/pom.xml 2009-06-13 00:43:29 UTC (rev 1128)
@@ -121,6 +121,7 @@
</dependency>
<dependency>
<groupId>org.xwiki.platform</groupId>
+ <!-- https://yui-ext.com/forum/showthread.php?t=5762 -->
<artifactId>xwiki-web-gwt-dom</artifactId>
<version>2.0-SNAPSHOT-g164</version>
</dependency>
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensiblePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensiblePresenter.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensiblePresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,19 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public abstract class AbstractActionExtensiblePresenter implements IsActionExtensible {
+
+ public abstract void addAction(final GuiActionDescrip descriptor);
+
+ public void addActionCollection(final GuiActionDescCollection descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
+ addAction(descriptor);
+ }
+ }
+
+ public void addActions(final GuiActionDescrip... descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
+ addAction(descriptor);
+ }
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensibleView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensibleView.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractActionExtensibleView.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface AbstractActionExtensibleView extends View {
+
+ void addAction(GuiActionDescrip descriptor);
+
+}
Deleted: 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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComplexGuiItem.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -1,56 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-import java.util.List;
-
-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 GuiActionDescCollection guiItems;
- private InputMap inputMap;
-
- public void add(final GuiActionDescrip... descriptors) {
- for (final GuiActionDescrip descriptor : descriptors) {
- getGuiItems().add(descriptor);
- }
- }
-
- public void addAll(final GuiActionDescCollection items) {
- getGuiItems().addAll(items);
- }
-
- public void addAll(final List<GuiActionDescrip> items) {
- getGuiItems().addAll(items);
- }
-
- public void addShortcut(final KeyStroke key, final AbstractAction action) {
- getInputMap().put(key, action);
- }
-
- public AbstractAction getAction(final Event event) {
- return getInputMap().get(KeyStroke.getKeyStrokeForEvent(event));
- }
-
- public GuiActionDescCollection getGuiItems() {
- if (guiItems == null) {
- 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;
- }
-}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractComposedGuiItem.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,63 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+import java.util.List;
+
+import org.ourproject.kune.platf.client.errors.UIException;
+
+import com.google.gwt.user.client.ui.Composite;
+
+public abstract class AbstractComposedGuiItem extends Composite {
+ private GuiActionDescCollection guiItems;
+ private final GuiBindingsRegister bindings;
+
+ public AbstractComposedGuiItem(final GuiBindingsRegister bindings) {
+ super();
+ this.bindings = bindings;
+ }
+
+ public void add(final GuiActionDescrip... descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
+ addAction(descriptor);
+ }
+ }
+
+ public void addAction(final GuiActionDescrip descriptor) {
+ getGuiItems().add(descriptor);
+ beforeAddWidget(descriptor);
+ }
+
+ public void addAll(final GuiActionDescCollection descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
+ addAction(descriptor);
+ }
+ }
+
+ public void addAll(final List<GuiActionDescrip> descriptors) {
+ for (final GuiActionDescrip descriptor : descriptors) {
+ addAction(descriptor);
+ }
+ }
+
+ public GuiActionDescCollection getGuiItems() {
+ if (guiItems == null) {
+ guiItems = new GuiActionDescCollection();
+ }
+ return guiItems;
+ }
+
+ protected abstract void addWidget(AbstractGuiItem item, int position, boolean visible);
+
+ protected void beforeAddWidget(final GuiActionDescrip descrip) {
+ if (descrip.mustBeAdded()) {
+ final GuiBinding binding = bindings.get(descrip.getType());
+ if (binding == null) {
+ throw new UIException("Unknown binding for: " + descrip);
+ } else {
+ final AbstractGuiItem item = binding.create(descrip);
+ if (binding.isAttachable()) {
+ addWidget(item, descrip.getPosition(), descrip.mustBeVisible());
+ }
+ }
+ }
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuGui.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -25,4 +25,12 @@
menu.insert(position, item);
}
+ public void show(final int x, final int y) {
+ menu.showAt(x, y);
+ }
+
+ public void show(final String id) {
+ menu.show(id);
+ }
+
}
\ No newline at end of file
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -110,6 +110,7 @@
}
private String createShortCut(final KeyStroke key, final String style) {
+ // See: https://yui-ext.com/forum/showthread.php?t=5762
final Element keyLabel = DOM.createSpan();
keyLabel.setId(style);
keyLabel.setInnerText(key.toString());
Deleted: 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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -1,16 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-public class BasicGuiBinding {
-
- public BasicGuiBinding(final GuiBindingsRegister bindings) {
- bindings.register(MenuDescriptor.class, new MenuBinding());
- final MenuItemBinding menuItemBinding = new MenuItemBinding();
- bindings.register(MenuRadioItemDescriptor.class, menuItemBinding);
- bindings.register(MenuCheckItemDescriptor.class, menuItemBinding);
- bindings.register(MenuItemDescriptor.class, menuItemBinding);
- bindings.register(MenuSeparatorDescriptor.class, new MenuSeparatorBinding());
- bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
- bindings.register(ButtonDescriptor.class, new ButtonBinding());
- bindings.register(ToolbarSeparatorDescriptor.class, new ToolbarSeparatorBinding());
- }
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBindings.java (from rev 1124, 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBindings.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,16 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public class BasicGuiBindings {
+
+ public BasicGuiBindings(final GuiBindingsRegister bindings) {
+ final MenuItemBinding menuItemBinding = new MenuItemBinding();
+ bindings.register(MenuDescriptor.class, new MenuBinding());
+ bindings.register(MenuRadioItemDescriptor.class, menuItemBinding);
+ bindings.register(MenuCheckItemDescriptor.class, menuItemBinding);
+ bindings.register(MenuItemDescriptor.class, menuItemBinding);
+ bindings.register(MenuSeparatorDescriptor.class, new MenuSeparatorBinding());
+ bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
+ bindings.register(ButtonDescriptor.class, new ButtonBinding());
+ bindings.register(ToolbarSeparatorDescriptor.class, new ToolbarSeparatorBinding());
+ }
+}
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/ComplexToolbar.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -1,39 +1,18 @@
package org.ourproject.kune.platf.client.actions.ui;
-import java.util.List;
-
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 implements View {
+public class ComplexToolbar extends AbstractComposedGuiItem implements View {
private final FlowToolbar toolbar;
- private final GuiBindingsRegister bindings;
public ComplexToolbar(final GuiBindingsRegister bindings) {
- super();
- this.bindings = bindings;
+ super(bindings);
toolbar = new FlowToolbar();
initWidget(toolbar);
}
- @Override
- public void add(final GuiActionDescrip... descriptors) {
- for (final GuiActionDescrip descrip : descriptors) {
- super.add(descrip);
- addWidget(descrip);
- }
- }
-
- @Override
- public void addAll(final List<GuiActionDescrip> descriptors) {
- super.addAll(descriptors);
- for (final GuiActionDescrip descritor : descriptors) {
- addWidget(descritor);
- }
- }
-
public void addFill() {
toolbar.addFill();
}
@@ -54,26 +33,15 @@
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());
- 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);
- }
- }
+ @Override
+ protected void addWidget(final AbstractGuiItem item, final int position, final boolean visible) {
+ item.addStyleName("kune-floatleft");
+ if (position == GuiActionDescrip.NO_POSITION) {
+ toolbar.add(item);
+ } else {
+ toolbar.insert(item, position);
}
+ item.setVisible(visible);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -98,6 +98,22 @@
return parent != NO_PARENT;
}
+ public boolean mustBeAdded() {
+ boolean result = false;
+ if (addCondition != null) {
+ result = addCondition.mustBeAdded();
+ }
+ return result;
+ }
+
+ public boolean mustBeVisible() {
+ boolean result = false;
+ if (visibleCondition != null) {
+ result = visibleCondition.mustBeVisible();
+ }
+ return result;
+ }
+
/**
* Sets the value associated with the specified key.
*
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/IsActionExtensible.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/IsActionExtensible.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/IsActionExtensible.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,29 @@
+package org.ourproject.kune.platf.client.actions.ui;
+
+public interface IsActionExtensible {
+
+ /**
+ * Adds a action description
+ *
+ * @param action
+ * the action
+ */
+ void addAction(GuiActionDescrip action);
+
+ /**
+ * Adds some action descriptions
+ *
+ * @param actions
+ * the actions
+ */
+ void addActionCollection(GuiActionDescCollection actions);
+
+ /**
+ * Adds some action descriptions
+ *
+ * @param action
+ * the action
+ */
+ void addActions(GuiActionDescrip... actions);
+
+}
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuBinding.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -25,7 +25,7 @@
isSubmenu = true;
} else {
// Is main parent menu
- final MenuGui menu = new MenuGui(descriptor);
+ final MenuGui menu = new MenuGui((MenuDescriptor) descriptor);
descriptor.putValue(UI_MENU, menu);
item = menu;
isSubmenu = false;
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -9,6 +9,12 @@
public static final String MENU_HIDE = "hidemenu";
+ private boolean standalone;
+
+ public MenuDescriptor() {
+ this(new BaseAction(null, null, null));
+ }
+
public MenuDescriptor(final AbstractAction action) {
this(NO_PARENT, action);
}
@@ -17,6 +23,7 @@
super(action);
setParent(parent);
action.putValue(MENU_HIDE, false);
+ standalone = false;
}
public MenuDescriptor(final String text) {
@@ -44,6 +51,21 @@
action.putValue(MENU_HIDE, !((Boolean) action.getValue(MENU_HIDE)));
}
+ public boolean isStandalone() {
+ return standalone;
+ }
+
+ /**
+ * Sets the standalone property (if the menu should have button (for a
+ * toolbar) or is a menu independent.
+ *
+ * @param standalone
+ * the new standalone
+ */
+ public void setStandalone(final boolean standalone) {
+ this.standalone = standalone;
+ }
+
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -9,14 +9,20 @@
public class MenuGui extends AbstractMenuGui {
- private final ToolbarButton button;
+ private final boolean notStandAlone;
+ private ToolbarButton button = null;
- public MenuGui(final GuiActionDescrip descriptor) {
+ public MenuGui(final MenuDescriptor descriptor) {
super();
- button = new ToolbarButton();
- button.setMenu(menu);
setAction(descriptor.action);
- initWidget(button);
+ // Standalone menus are menus without and associated button in a toolbar
+ // (sometimes, a menu showed in a grid, or other special widgets)
+ notStandAlone = !descriptor.isStandalone();
+ if (notStandAlone) {
+ button = new ToolbarButton();
+ button.setMenu(menu);
+ initWidget(button);
+ }
descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent event) {
if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE)) {
@@ -26,37 +32,37 @@
});
}
- public void add(final SubMenuGui submenu) {
- menu.addItem(submenu.getMenuItem());
- };
-
- public void insert(final int position, final SubMenuGui submenu) {
- menu.insert(position, submenu.getMenuItem());
- }
-
@Override
public void setEnabled(final boolean enabled) {
- if (enabled) {
- button.enable();
- } else {
- button.disable();
+ if (notStandAlone) {
+ if (enabled) {
+ button.enable();
+ } else {
+ button.disable();
+ }
}
}
@Override
public void setIcon(final ImageResource imageResource) {
- if (imageResource != null) {
- button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
+ if (notStandAlone) {
+ if (imageResource != null) {
+ button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
+ }
}
}
@Override
public void setText(final String text) {
- button.setText(text);
+ if (notStandAlone) {
+ button.setText(text);
+ }
}
@Override
public void setToolTipText(final String tooltip) {
- button.setTooltip(tooltip);
+ if (notStandAlone) {
+ button.setTooltip(tooltip);
+ }
}
}
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuItemDescriptor.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -4,6 +4,10 @@
public class MenuItemDescriptor extends GuiActionDescrip {
+ public MenuItemDescriptor(final AbstractAction action) {
+ super(action);
+ }
+
public MenuItemDescriptor(final MenuDescriptor parent, final AbstractAction action) {
super(action);
setParent(parent);
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -19,7 +19,7 @@
\*/
package org.ourproject.kune.platf.client.services;
-import org.ourproject.kune.platf.client.actions.ui.BasicGuiBinding;
+import org.ourproject.kune.platf.client.actions.ui.BasicGuiBindings;
import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
import org.ourproject.kune.platf.client.app.Application;
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
@@ -439,10 +439,10 @@
return new ExternalMediaRegistry(i(Session.class).getInitData().getExtMediaDescrips());
}});
- register(Singleton.class, new Factory<BasicGuiBinding>(BasicGuiBinding.class) {
+ register(Singleton.class, new Factory<BasicGuiBindings>(BasicGuiBindings.class) {
@Override
- public BasicGuiBinding create() {
- return new BasicGuiBinding(i(GuiBindingsRegister.class));
+ public BasicGuiBindings create() {
+ return new BasicGuiBindings(i(GuiBindingsRegister.class));
}
});
@@ -453,7 +453,7 @@
}
@Override
public void onAfterCreated(final GuiBindingsRegister instance) {
- i(BasicGuiBinding.class);
+ i(BasicGuiBindings.class);
}
});
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/ImgResources.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -12,4 +12,10 @@
@Resource("info.png")
ImageResource info();
+ @Resource("kune-icon16.png")
+ ImageResource kuneIcon16();
+
+ @Resource("language.png")
+ ImageResource language();
+
}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kune-icon16.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/kune-icon16.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/language.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/client/ui/img/language.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -3,9 +3,9 @@
import org.ourproject.kune.platf.client.View;
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.IsActionExtensible;
import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
import com.calclab.suco.client.events.Listener0;
@@ -14,7 +14,7 @@
/**
* The Interface RTEditor.
*/
-public interface RTEditor {
+public interface RTEditor extends IsActionExtensible {
/**
* The TOPBAR location used in {@link GuiActionDescrip#setLocation(String)}
@@ -35,30 +35,6 @@
String LINKCTX = "rte-linkctx";
/**
- * Adds a action description
- *
- * @param action
- * the action
- */
- void addAction(GuiActionDescrip action);
-
- /**
- * Adds some action descriptions
- *
- * @param actions
- * the actions
- */
- void addActionCollection(GuiActionDescCollection actions);
-
- /**
- * Adds some action descriptions
- *
- * @param action
- * the action
- */
- void addActions(GuiActionDescrip... actions);
-
- /**
* Adds the on edit listener (fired when the user do some edit).
*
* @param listener
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -6,9 +6,9 @@
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.InputMap;
+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.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;
@@ -38,8 +38,9 @@
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.Composite;
-public class RTEditorPanel extends AbstractComplexGuiItem implements RTEditorView, FocusHandler, BlurHandler {
+public class RTEditorPanel extends Composite implements RTEditorView, FocusHandler, BlurHandler {
private static final Element NO_ELEMENT = null;
private final I18nUITranslationService i18n;
@@ -51,18 +52,18 @@
private final RichTextArea rta;
private final ComplexToolbar topBar;
private final ComplexToolbar sndBar;
+ private InputMap inputMap;
public RTEditorPanel(final RTEditorPresenter presenter, final I18nUITranslationService i18n,
- final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
- super();
+ final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindings) {
this.presenter = presenter;
this.i18n = i18n;
this.globalShortcutReg = globalShortcutReg;
rta = new RichTextArea();
basic = rta.getBasicFormatter();
extended = rta.getExtendedFormatter();
- topBar = new ComplexToolbar(bindReg);
- sndBar = new ComplexToolbar(bindReg);
+ topBar = new ComplexToolbar(bindings);
+ sndBar = new ComplexToolbar(bindings);
sndBar.setNormalStyle();
rta.addFocusHandler(this);
rta.addBlurHandler(this);
@@ -72,23 +73,20 @@
setHeight("100%");
}
- 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(RTEditor.TOPBAR)) {
- topBar.add(item);
- } else if (location.equals(RTEditor.SNDBAR)) {
- sndBar.add(item);
- } else if (location.equals(RTEditor.LINKCTX)) {
- linkCtxMenu.add(item);
- } else {
- throw new UIException("Unknown location in action item: " + item);
- }
+ public void addAction(final GuiActionDescrip item) {
+ final String location = item.getLocation();
+ if (location == null) {
+ throw new UIException("Unknown location in action item: " + item);
}
+ if (location.equals(RTEditor.TOPBAR)) {
+ topBar.addAction(item);
+ } else if (location.equals(RTEditor.SNDBAR)) {
+ sndBar.addAction(item);
+ } else if (location.equals(RTEditor.LINKCTX)) {
+ linkCtxMenu.add(item);
+ } else {
+ throw new UIException("Unknown location in action item: " + item);
+ }
}
public void adjustSize(final int height) {
@@ -299,7 +297,7 @@
super.onBrowserEvent(event);
break;
case Event.ONKEYPRESS:
- final AbstractAction rtaActionItem = super.getAction(event);
+ final AbstractAction rtaActionItem = inputMap.get(KeyStroke.getKeyStrokeForEvent(event));
// FIXME
// final Action actionItem = rtaActionItem == null ?
// globalShortcutReg.get(event) : rtaActionItem;
@@ -379,6 +377,10 @@
rta.setHTML(html);
}
+ public void setInputMap(final InputMap inputMap) {
+ this.inputMap = inputMap;
+ }
+
public void setText(final String text) {
rta.setText(text);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -15,6 +15,7 @@
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.ui.AbstractActionExtensiblePresenter;
import org.ourproject.kune.platf.client.actions.ui.ButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
@@ -52,7 +53,7 @@
import com.google.gwt.libideas.resources.client.ImageResource;
import com.google.gwt.user.client.Event;
-public class RTEditorPresenter implements RTEditor {
+public class RTEditorPresenter extends AbstractActionExtensiblePresenter implements RTEditor {
public class BackgroundColorAction extends AbstractExtendedAction {
@@ -710,25 +711,12 @@
fontActions = new HashMap<String, MenuCheckItemDescriptor>();
}
+ @Override
public void addAction(final GuiActionDescrip descriptor) {
actions.add(descriptor);
checkForMenus(descriptor);
}
- public void addActionCollection(final GuiActionDescCollection descriptors) {
- actions.addAll(descriptors);
- for (final GuiActionDescrip descriptor : descriptors) {
- checkForMenus(descriptor);
- }
- }
-
- public void addActions(final GuiActionDescrip... descriptors) {
- actions.add(descriptors);
- for (final GuiActionDescrip descriptor : descriptors) {
- checkForMenus(descriptor);
- }
- }
-
public void addOnEditListener(final Listener0 listener) {
onEdit.add(listener);
}
@@ -740,7 +728,7 @@
public void attach() {
if (!attached) {
attached = true;
- view.addActions(actions);
+ attachActions();
view.setInputMap(inputMap);
}
}
@@ -884,6 +872,12 @@
}
}
+ private void attachActions() {
+ for (final GuiActionDescrip descriptor : actions) {
+ view.addAction(descriptor);
+ }
+ }
+
private void checkForMenus(final GuiActionDescrip descriptor) {
if (descriptor instanceof MenuDescriptor) {
menus.add((MenuDescriptor) descriptor);
@@ -1098,7 +1092,7 @@
setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_ALT), devInfoAction);
actions = new GuiActionDescCollection();
- actions.add(fileMenu, editMenu, formatMenu, insertMenu, undo, redo, editMenuSep, copy, cut, paste, editMenuSep,
+ addActions(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,
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -2,14 +2,12 @@
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.actions.InputMap;
-import org.ourproject.kune.platf.client.actions.ui.GuiActionDescCollection;
+import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensibleView;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-public interface RTEditorView extends View {
+public interface RTEditorView extends AbstractActionExtensibleView {
- void addActions(GuiActionDescCollection actions);
-
void adjustSize(int height);
boolean canBeBasic();
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -262,12 +262,12 @@
saveClose.setLocation(RTEditor.TOPBAR);
saveCloseBtn.setLocation(RTEditor.TOPBAR);
- super.addAction(saveMenu);
- super.addAction(saveBtn);
- super.addAction(autoSaveItem);
- super.addAction(saveClose);
- super.addAction(saveCloseBtn);
- super.addAction(closeItem);
+ addAction(saveMenu);
+ addAction(saveBtn);
+ addAction(autoSaveItem);
+ addAction(saveClose);
+ addAction(saveCloseBtn);
+ addAction(closeItem);
}
private void enableSaveBtn(final boolean enabled) {
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-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -49,9 +49,9 @@
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
+import org.ourproject.kune.platf.client.ui.img.ImgResources;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
@@ -104,6 +104,7 @@
import org.ourproject.kune.workspace.client.i18n.LanguageSelectorPanel;
import org.ourproject.kune.workspace.client.i18n.LanguageSelectorPresenter;
import org.ourproject.kune.workspace.client.i18n.LanguageSelectorView;
+import org.ourproject.kune.workspace.client.i18n.SiteOptionsI18nTranslatorAction;
import org.ourproject.kune.workspace.client.licensefoot.EntityLicensePanel;
import org.ourproject.kune.workspace.client.licensefoot.EntityLicensePresenter;
import org.ourproject.kune.workspace.client.licensewizard.LicenseChangeAction;
@@ -375,9 +376,10 @@
register(ApplicationComponentGroup.class, new Factory<SiteOptions>(SiteOptions.class) {
@Override
public SiteOptions create() {
- final SiteOptionsPresenter presenter = new SiteOptionsPresenter();
- final SiteOptionsPanel panel = new SiteOptionsPanel(presenter, i(WorkspaceSkeleton.class),
- i(I18nUITranslationService.class), p(I18nTranslator.class), p(TestRTEDialog.class));
+ final SiteOptionsPresenter presenter = new SiteOptionsPresenter(i(I18nUITranslationService.class),
+ i(ImgResources.class));
+ final SiteOptionsPanel panel = new SiteOptionsPanel(i(WorkspaceSkeleton.class),
+ i(I18nUITranslationService.class), i(GuiBindingsRegister.class));
presenter.init(panel);
return presenter;
}
@@ -572,8 +574,8 @@
i(Session.class), p(SocialNetworkServiceAsync.class), i(WsThemePresenter.class),
i(GroupActionRegistry.class), i(ActionParticipationToolbar.class), p(FileDownloadUtils.class));
final ParticipationSummaryView view = new ParticipationSummaryPanel(presenter,
- i(I18nUITranslationService.class), i(WorkspaceSkeleton.class),
- (i(ActionParticipationToolbar.class).getView()));
+ i(I18nUITranslationService.class), i(WorkspaceSkeleton.class), i(
+ ActionParticipationToolbar.class).getView());
presenter.init(view);
return presenter;
}
@@ -762,6 +764,15 @@
}
});
+ register(ApplicationComponentGroup.class, new Factory<SiteOptionsI18nTranslatorAction>(
+ SiteOptionsI18nTranslatorAction.class) {
+ @Override
+ public SiteOptionsI18nTranslatorAction create() {
+ return new SiteOptionsI18nTranslatorAction(i(SiteOptions.class), i(I18nTranslationService.class),
+ i(ImgResources.class), p(I18nTranslator.class));
+ }
+ });
+
register(Singleton.class, new Factory<SignIn>(SignIn.class) {
@Override
public SignIn create() {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -137,7 +137,7 @@
final KeyStroke key = KeyStroke.getKeyStroke(Keyboard.KEY_F2, 0);
renameAction.putValue(Action.ACCELERATOR_KEY, key);
super.setActionShortcut(key, renameAction);
- super.addAction(renameItem);
+ addAction(renameItem);
}
private void adjHeight(final int height) {
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/SiteOptionsI18nTranslatorAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/SiteOptionsI18nTranslatorAction.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/i18n/SiteOptionsI18nTranslatorAction.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -0,0 +1,31 @@
+package org.ourproject.kune.workspace.client.i18n;
+
+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.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.img.ImgResources;
+import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptions;
+
+import com.calclab.suco.client.ioc.Provider;
+
+public class SiteOptionsI18nTranslatorAction extends AbstractAction {
+ private final Provider<I18nTranslator> translator;
+
+ public SiteOptionsI18nTranslatorAction(final SiteOptions siteOptions, final I18nTranslationService i18n,
+ final ImgResources img, final Provider<I18nTranslator> translator) {
+ super();
+ this.translator = translator;
+ putValue(Action.NAME, i18n.t("Help with the translation"));
+ putValue(Action.SMALL_ICON, img.language());
+ final MenuItemDescriptor item = new MenuItemDescriptor(this);
+ item.setPosition(0);
+ siteOptions.addAction(item);
+ }
+
+ public void actionPerformed(final ActionEvent event) {
+ translator.get().doShowTranslator();
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptions.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptions.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -19,6 +19,7 @@
\*/
package org.ourproject.kune.workspace.client.sitebar.siteoptions;
-public interface SiteOptions {
+import org.ourproject.kune.platf.client.actions.ui.IsActionExtensible;
+public interface SiteOptions extends IsActionExtensible {
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -19,81 +19,52 @@
\*/
package org.ourproject.kune.workspace.client.sitebar.siteoptions;
+import org.ourproject.kune.platf.client.actions.ui.AbstractComposedGuiItem;
+import org.ourproject.kune.platf.client.actions.ui.AbstractGuiItem;
+import org.ourproject.kune.platf.client.actions.ui.AbstractMenuGui;
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.actions.ui.MenuBinding;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.ui.KuneWindowUtils;
-import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
-import org.ourproject.kune.workspace.client.i18n.I18nTranslator;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import com.calclab.suco.client.ioc.Provider;
-import com.google.gwt.dom.client.Element;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.PushButton;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.menu.BaseItem;
-import com.gwtext.client.widgets.menu.Item;
-import com.gwtext.client.widgets.menu.Menu;
-import com.gwtext.client.widgets.menu.event.BaseItemListenerAdapter;
-public class SiteOptionsPanel implements SiteOptionsView {
+public class SiteOptionsPanel extends AbstractComposedGuiItem implements SiteOptionsView {
- public SiteOptionsPanel(final SiteOptionsPresenter presenter, final WorkspaceSkeleton ws,
- final I18nUITranslationService i18n, final Provider<I18nTranslator> translatorProvider,
- final Provider<TestRTEDialog> editor) {
+ private static final String BTN_ID = "k-sopts-btn-id";
+ private AbstractMenuGui menu;
+
+ public SiteOptionsPanel(final WorkspaceSkeleton wspace, final I18nUITranslationService i18n,
+ final GuiBindingsRegister bindings) {
+ super(bindings);
final PushButton optionsButton = new PushButton("");
// optionsButton.setText(i18n.t("Options"));
optionsButton.setHTML(i18n.t("Options")
+ "<img style=\"vertical-align: middle;\" src=\"images/arrowdown.png\" />");
optionsButton.setStyleName("k-sitebar-labellink");
- ws.getSiteBar().addSeparator();
- ws.getSiteBar().add(optionsButton);
- ws.getSiteBar().addSpacer();
- ws.getSiteBar().addSpacer();
- final Menu optionsMenu = new Menu();
+ optionsButton.ensureDebugId(BTN_ID);
+ wspace.getSiteBar().addSeparator();
+ wspace.getSiteBar().add(optionsButton);
+ wspace.getSiteBar().addSpacer();
+ wspace.getSiteBar().addSpacer();
+
optionsButton.addClickHandler(new ClickHandler() {
public void onClick(final ClickEvent event) {
- final Element sender = event.getRelativeElement();
- optionsMenu.showAt(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 10);
+ menu.show(optionsButton.getElement().getId());
}
});
+ }
- final Item testRTE = new Item(i18n.t("Test new RTE"), new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- final TestRTEDialog testRTEDialog = editor.get();
- testRTEDialog.setExtended(true);
- testRTEDialog.show();
- }
- }, "");
+ public void setMenu(final MenuDescriptor menuDescriptor) {
+ menu = (AbstractMenuGui) menuDescriptor.getValue(MenuBinding.UI_MENU);
+ }
- final Item testRTEbasic = new Item(i18n.t("Test new RTE (basic mode)"), new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- final TestRTEDialog testRTEDialog = editor.get();
- testRTEDialog.setExtended(false);
- testRTEDialog.show();
- }
- }, "");
-
- final Item linkHelpInTrans = new Item(i18n.t("Help with the translation"), new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- super.onClick(item, e);
- translatorProvider.get().doShowTranslator();
- }
- }, "images/language.gif");
-
- final Item linkKuneBugs = new Item(i18n.t("Report kune bugs"), new BaseItemListenerAdapter() {
- @Override
- public void onClick(final BaseItem item, final EventObject e) {
- super.onClick(item, e);
- KuneWindowUtils.open("http://ourproject.org/tracker/?group_id=407");
- }
- }, "images/kuneicon16.gif");
- optionsMenu.addItem(testRTEbasic);
- optionsMenu.addItem(testRTE);
- optionsMenu.addItem(linkHelpInTrans);
- optionsMenu.addItem(linkKuneBugs);
+ @Override
+ protected void addWidget(final AbstractGuiItem item, final int position, final boolean visible) {
+ // Do nothing (menu items are attached automatically to its menu
}
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPresenter.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPresenter.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -20,20 +20,60 @@
package org.ourproject.kune.workspace.client.sitebar.siteoptions;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
+import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensiblePresenter;
+import org.ourproject.kune.platf.client.actions.ui.GuiActionDescrip;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.KuneWindowUtils;
+import org.ourproject.kune.platf.client.ui.img.ImgResources;
-public class SiteOptionsPresenter implements SiteOptions {
+public class SiteOptionsPresenter extends AbstractActionExtensiblePresenter implements SiteOptions {
private SiteOptionsView view;
+ private MenuDescriptor menuDescriptor;
+ private final I18nTranslationService i18n;
+ private final ImgResources img;
- public SiteOptionsPresenter() {
+ public SiteOptionsPresenter(final I18nTranslationService i18n, final ImgResources img) {
+ super();
+ this.i18n = i18n;
+ this.img = img;
}
+ @Override
+ public void addAction(final GuiActionDescrip descriptor) {
+ descriptor.setParent(menuDescriptor);
+ view.addAction(descriptor);
+ }
+
public View getView() {
return view;
}
public void init(final SiteOptionsView view) {
this.view = view;
+ createActions();
}
+ private void createActions() {
+ menuDescriptor = new MenuDescriptor();
+ menuDescriptor.setStandalone(true);
+ view.addAction(menuDescriptor);
+ view.setMenu(menuDescriptor);
+
+ final AbstractExtendedAction bugsAction = new AbstractExtendedAction() {
+ public void actionPerformed(final ActionEvent event) {
+ KuneWindowUtils.open("http://ourproject.org/tracker/?group_id=407");
+ }
+ };
+ bugsAction.putValue(Action.NAME, i18n.t("Report kune bugs"));
+ bugsAction.putValue(Action.SMALL_ICON, img.kuneIcon16());
+ final MenuItemDescriptor item = new MenuItemDescriptor(bugsAction);
+ addAction(item);
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsView.java 2009-06-12 00:39:51 UTC (rev 1127)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsView.java 2009-06-13 00:43:29 UTC (rev 1128)
@@ -19,7 +19,11 @@
\*/
package org.ourproject.kune.workspace.client.sitebar.siteoptions;
-import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ui.AbstractActionExtensibleView;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
-public interface SiteOptionsView extends View {
+public interface SiteOptionsView extends AbstractActionExtensibleView {
+
+ void setMenu(MenuDescriptor menuDescriptor);
+
}
1
0
r1127 - in trunk/src/main/java/org/ourproject/kune: app/client platf/client/actions/ui platf/client/services platf/client/ui/rte/saving workspace/client/hello
by vjrj 12 Jun '09
by vjrj 12 Jun '09
12 Jun '09
Author: vjrj
Date: 2009-06-12 02:39:51 +0200 (Fri, 12 Jun 2009)
New Revision: 1127
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/services/Loader.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java
Modified:
trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
Log:
Complete - task Hello World updated and Application Boot improved
Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-06-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -23,15 +23,15 @@
import org.ourproject.kune.chat.client.ChatClientModule;
import org.ourproject.kune.docs.client.DocumentClientModule;
import org.ourproject.kune.gallery.client.GalleryClientModule;
-import org.ourproject.kune.platf.client.services.CoreModule;
+import org.ourproject.kune.platf.client.services.Loader;
import org.ourproject.kune.platf.client.services.PlatformModule;
import org.ourproject.kune.wiki.client.WikiClientModule;
import org.ourproject.kune.workspace.client.RegistryModule;
import org.ourproject.kune.workspace.client.WorkspaceModule;
+import org.ourproject.kune.workspace.client.hello.HelloWorldModule;
import com.allen_sauer.gwt.log.client.Log;
import com.calclab.emiteuimodule.client.EmiteUIModule;
-import com.calclab.suco.client.Suco;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
@@ -52,8 +52,11 @@
// At the moment, in runtime:
Log.setCurrentLogLevel(Log.LOG_LEVEL_DEBUG);
- Suco.install(new CoreModule(), new RegistryModule(), new PlatformModule(), new EmiteUIModule(),
- new DocumentClientModule(), new BlogClientModule(), new WikiClientModule(), new GalleryClientModule(),
- new ChatClientModule(), new WorkspaceModule());
+ Loader.install(new RegistryModule(), new DocumentClientModule(), new BlogClientModule(),
+ new WikiClientModule(), new GalleryClientModule(), new EmiteUIModule(), new ChatClientModule(),
+ new WorkspaceModule(), new PlatformModule());
+
+ // We install our HelloWorldModule
+ Loader.install(new HelloWorldModule());
}
}
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-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/SubMenuGui.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -14,7 +14,7 @@
item = new MenuItem();
item.setMenu(menu);
setAction(descriptor.action);
- // initWidget(item);
+ initWidget(item);
}
public MenuItem getMenuItem() {
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java 2009-06-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -1,75 +0,0 @@
-package org.ourproject.kune.platf.client.actions.ui;
-
-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.ui.img.ImgResources;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.user.client.Timer;
-
-public class TestButton {
-
- static class HelloWorldAction extends AbstractAction {
- public HelloWorldAction(final ImgResources img) {
- super();
- super.putValue(Action.NAME, "helloword");
- super.putValue(Action.SHORT_DESCRIPTION, "helloworld item");
- super.putValue(Action.SMALL_ICON, img.info());
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- if (actionEvent.getEvent().getCtrlKey()) {
- NotifyUser.info("Button clicked with ctrl button");
- }
- NotifyUser.info("Button clicked");
- }
- }
-
- public TestButton(final WorkspaceSkeleton wksp, final GuiBindingsRegister bindings, final ImgResources img) {
- final HelloWorldAction noti = new HelloWorldAction(img);
-
- final PushButtonDescriptor btn = new PushButtonDescriptor(noti);
-
- final MenuDescriptor menu = new MenuDescriptor("File", "File menu tooltip", null);
-
- final MenuItemDescriptor item = new MenuItemDescriptor(menu, noti);
- final MenuItemDescriptor item2 = new MenuItemDescriptor(menu, noti);
- final MenuDescriptor submenu = new MenuDescriptor("Options", "submenu tooltip", null);
- submenu.setParent(menu);
- final MenuItemDescriptor item3 = new MenuItemDescriptor(submenu, noti);
- final MenuCheckItemDescriptor item4 = new MenuCheckItemDescriptor(submenu, noti);
- item4.setChecked(true);
- final MenuRadioItemDescriptor item5 = new MenuRadioItemDescriptor(submenu, noti, "new");
- final MenuRadioItemDescriptor item6 = new MenuRadioItemDescriptor(submenu, noti, "new");
- item5.setChecked(true);
- final ComplexToolbar toolbar = new ComplexToolbar(bindings);
-
- toolbar.add(btn, menu);
- toolbar.add(item);
- toolbar.add(new MenuSeparatorDescriptor(menu));
- toolbar.add(item2);
- toolbar.add(submenu);
- toolbar.add(item3);
- toolbar.add(item4);
- toolbar.add(new MenuSeparatorDescriptor(submenu));
- toolbar.add(item5);
- toolbar.add(item6);
- // toolbar.add(new ToolbarSeparatorDescriptor(Type.separator));
-
- wksp.getEntityWorkspace().getBottomTitle().add(toolbar);
-
- new Timer() {
- @Override
- public void run() {
- noti.putValue(Action.NAME, "test2");
- noti.putValue(Action.SHORT_DESCRIPTION, "test2 button");
- btn.setPushed(false);
- }
- }.schedule(10000);
-
- btn.setPushed(true);
-
- }
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java 2009-06-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -21,18 +21,97 @@
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
+import org.ourproject.kune.platf.client.app.HistoryWrapper;
+import org.ourproject.kune.platf.client.app.HistoryWrapperDefault;
import org.ourproject.kune.platf.client.app.ToolGroup;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.rpc.I18nService;
+import org.ourproject.kune.platf.client.rpc.I18nServiceAsync;
+import org.ourproject.kune.platf.client.rpc.UserService;
+import org.ourproject.kune.platf.client.rpc.UserServiceAsync;
+import org.ourproject.kune.platf.client.state.ContentProvider;
+import org.ourproject.kune.platf.client.state.ContentProviderDefault;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.state.SessionDefault;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.state.StateManagerDefault;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaGroup;
import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharGroup;
-import com.calclab.suco.client.ioc.module.AbstractModule;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.decorator.Singleton;
+import com.calclab.suco.client.ioc.module.Factory;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.Cookies;
+import com.google.gwt.user.client.History;
+import com.google.gwt.user.client.rpc.ServiceDefTarget;
-public class CoreModule extends AbstractModule {
+public class CoreModule extends AbstractExtendedModule {
+ private final Listener0 onI18nReady;
+
+ public CoreModule(final Listener0 onI18nReady) {
+ this.onI18nReady = onI18nReady;
+ }
+
@Override
- public void onInstall() {
+ protected void onInstall() {
+
+ register(Singleton.class, new Factory<Session>(Session.class) {
+ @Override
+ public Session create() {
+ return new SessionDefault(Cookies.getCookie(Session.USERHASH), p(UserServiceAsync.class));
+ }
+ }, new Factory<I18nServiceAsync>(I18nServiceAsync.class) {
+ @Override
+ public I18nServiceAsync create() {
+ final I18nServiceAsync service = (I18nServiceAsync) GWT.create(I18nService.class);
+ ((ServiceDefTarget) service).setServiceEntryPoint(GWT.getModuleBaseURL() + "I18nService");
+ return service;
+ }
+ }, new Factory<UserServiceAsync>(UserServiceAsync.class) {
+ @Override
+ public UserServiceAsync create() {
+ final UserServiceAsync service = (UserServiceAsync) GWT.create(UserService.class);
+ ((ServiceDefTarget) service).setServiceEntryPoint(GWT.getModuleBaseURL() + "UserService");
+ return service;
+ }
+ });
+
+ register(Singleton.class, new Factory<I18nUITranslationService>(I18nUITranslationService.class) {
+ @Override
+ public I18nUITranslationService create() {
+ final I18nUITranslationService i18n = new I18nUITranslationService();
+ i18n.init(i(I18nServiceAsync.class), i(Session.class), onI18nReady);
+ return i18n;
+ }
+ });
+
+ i(I18nUITranslationService.class);
+
+ register(Singleton.class, new Factory<HistoryWrapper>(HistoryWrapper.class) {
+ @Override
+ public HistoryWrapper create() {
+ return new HistoryWrapperDefault();
+ }
+ }, new Factory<ContentProvider>(ContentProvider.class) {
+ @Override
+ public ContentProvider create() {
+ return new ContentProviderDefault(i(ContentServiceAsync.class));
+ }
+ }, new Factory<StateManager>(StateManager.class) {
+ @Override
+ public StateManager create() {
+ final StateManagerDefault stateManager = new StateManagerDefault(i(ContentProvider.class),
+ i(Session.class), i(HistoryWrapper.class));
+ History.addValueChangeHandler(stateManager);
+ return stateManager;
+ }
+ });
+
registerDecorator(ApplicationComponentGroup.class, new ApplicationComponentGroup(container));
registerDecorator(ToolGroup.class, new ToolGroup(container));
registerDecorator(EntityOptionsGroup.class, new EntityOptionsGroup(container));
Added: trunk/src/main/java/org/ourproject/kune/platf/client/services/Loader.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/Loader.java 2009-06-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/Loader.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -0,0 +1,67 @@
+package org.ourproject.kune.platf.client.services;
+
+import java.util.ArrayList;
+
+import com.calclab.suco.client.Suco;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Container;
+import com.calclab.suco.client.ioc.module.SucoModule;
+
+public class Loader extends Suco {
+
+ private static ArrayList<SucoModule> pendingModules = new ArrayList<SucoModule>();
+ private static boolean deferred = true;
+ private static boolean initialized = false;
+
+ /**
+ * Obtain a instance from the Suco container
+ *
+ * @param <T>
+ * @param componentType
+ * @return
+ */
+ public static <T> T get(final Class<T> componentType) {
+ return Suco.get(componentType);
+ }
+
+ /**
+ * Get the Suco container itself.
+ *
+ * @return the Suco singleton container
+ */
+ public static Container getComponents() {
+ return Suco.getComponents();
+ }
+
+ /**
+ * Install the given modules into the container
+ *
+ * @param modules
+ * the list of modules to be installed in the singleton Suco
+ * container
+ */
+ public static void install(final SucoModule... modules) {
+ init();
+ if (deferred) {
+ for (final SucoModule module : modules) {
+ pendingModules.add(module);
+ }
+ } else {
+ Suco.install(modules);
+ }
+ }
+
+ private static void init() {
+ if (!initialized) {
+ Suco.install(new CoreModule(new Listener0() {
+ public void onEvent() {
+ for (final SucoModule module : pendingModules) {
+ Suco.install(module);
+ }
+ deferred = false;
+ }
+ }));
+ initialized = true;
+ }
+ }
+}
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-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -24,25 +24,14 @@
import org.ourproject.kune.platf.client.app.Application;
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
import org.ourproject.kune.platf.client.app.ApplicationDefault;
-import org.ourproject.kune.platf.client.app.HistoryWrapper;
-import org.ourproject.kune.platf.client.app.HistoryWrapperDefault;
import org.ourproject.kune.platf.client.app.ToolGroup;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.i18n.Resources;
import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
-import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
-import org.ourproject.kune.platf.client.rpc.I18nService;
-import org.ourproject.kune.platf.client.rpc.I18nServiceAsync;
-import org.ourproject.kune.platf.client.rpc.UserService;
-import org.ourproject.kune.platf.client.rpc.UserServiceAsync;
import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
-import org.ourproject.kune.platf.client.state.ContentProvider;
-import org.ourproject.kune.platf.client.state.ContentProviderDefault;
import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.state.SessionDefault;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.state.StateManagerDefault;
import org.ourproject.kune.platf.client.ui.QuickTipsHelper;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.img.ImgResources;
@@ -115,75 +104,17 @@
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
-import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
import com.calclab.suco.client.ioc.decorator.Singleton;
import com.calclab.suco.client.ioc.module.Factory;
import com.google.gwt.core.client.GWT;
import com.google.gwt.libideas.client.StyleInjector;
-import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.ServiceDefTarget;
public class PlatformModule extends AbstractExtendedModule {
@Override
protected void onInstall() {
- register(Singleton.class, new Factory<Session>(Session.class) {
- @Override
- public Session create() {
- return new SessionDefault(Cookies.getCookie(Session.USERHASH), p(UserServiceAsync.class));
- }
- }, new Factory<I18nServiceAsync>(I18nServiceAsync.class) {
- @Override
- public I18nServiceAsync create() {
- final I18nServiceAsync service = (I18nServiceAsync) GWT.create(I18nService.class);
- ((ServiceDefTarget) service).setServiceEntryPoint(GWT.getModuleBaseURL() + "I18nService");
- return service;
- }
- }, new Factory<UserServiceAsync>(UserServiceAsync.class) {
- @Override
- public UserServiceAsync create() {
- final UserServiceAsync service = (UserServiceAsync) GWT.create(UserService.class);
- ((ServiceDefTarget) service).setServiceEntryPoint(GWT.getModuleBaseURL() + "UserService");
- return service;
- }
- });
-
- register(Singleton.class, new Factory<HistoryWrapper>(HistoryWrapper.class) {
- @Override
- public HistoryWrapper create() {
- return new HistoryWrapperDefault();
- }
- }, new Factory<ContentProvider>(ContentProvider.class) {
- @Override
- public ContentProvider create() {
- return new ContentProviderDefault(i(ContentServiceAsync.class));
- }
- }, new Factory<StateManager>(StateManager.class) {
- @Override
- public StateManager create() {
- final StateManagerDefault stateManager = new StateManagerDefault(i(ContentProvider.class),
- i(Session.class), i(HistoryWrapper.class));
- History.addValueChangeHandler(stateManager);
- return stateManager;
- }
- });
-
- register(Singleton.class, new Factory<I18nUITranslationService>(I18nUITranslationService.class) {
- @Override
- public I18nUITranslationService create() {
- final I18nUITranslationService i18n = new I18nUITranslationService();
- i18n.init(i(I18nServiceAsync.class), i(Session.class), new Listener0() {
- public void onEvent() {
- onI18nReady();
- }
- });
- return i18n;
- }
- });
-
register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
@Override
public FileDownloadUtils create() {
@@ -200,12 +131,8 @@
});
}
- i(I18nUITranslationService.class);
i(QuickTipsHelper.class);
- }
-
- private void onI18nReady() {
final I18nUITranslationService i18n = i(I18nUITranslationService.class);
if (container.hasProvider(I18nTranslationService.class)) {
@@ -534,12 +461,5 @@
i(ToolGroup.class).createAll();
i(Application.class).start();
- // We install our HelloWorldModule
- //Suco.install(new HelloWorldModule());
-
- // And because nobody use this module, we get the class (to force the
- // creation of the
- // Helloworld instance):
- //i(HelloWorld.class);
}
}
\ No newline at end of file
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-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -233,7 +233,7 @@
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);
+ final KeyStroke key_S = KeyStroke.getKeyStroke(Character.valueOf('S'), Keyboard.MODIFIER_CTRL);
saveBtn.setPosition(0);
saveBtn.setLocation(RTEditor.SNDBAR);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-11 22:14:06 UTC (rev 1126)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-12 00:39:51 UTC (rev 1127)
@@ -98,10 +98,15 @@
/**
* We can add some gui action items to the content editor
*
- * Summary)
+ * Summary).
*
* @param i18n
- **/
+ * the i18n
+ * @param contentEditorProv
+ * the content editor provider
+ * @param img
+ * the img
+ */
private void createActions(final Provider<ContentEditor> contentEditorProv, final ImgResources img,
final I18nTranslationService i18n) {
@@ -113,7 +118,7 @@
// We no use i18n.t() in most of these gui widgets but it's is
// recommended the use in real code
- final MenuDescriptor menu = new MenuDescriptor(i18n.t("File"), "File menu tooltip");
+ final MenuDescriptor menu = new MenuDescriptor(i18n.t("HelloWorldMenu"), "File menu tooltip");
final MenuItemDescriptor menuitem = new MenuItemDescriptor(menu, action);
final MenuItemDescriptor menuitem2 = new MenuItemDescriptor(menu, action);
@@ -141,12 +146,11 @@
//
// Using Provider<Class> we do lazy instantiation. When we call
// actionRegistry.get() it creates the instance if is not
- // created
- // yet.
+ // created yet.
final ContentEditor contentEditor = contentEditorProv.get();
// We want to add some items to the topbar and other to the
- // second bar
+ // second bar of the editor
contentEditor.setLocation(ContentEditor.TOPBAR, menu, menuitem, menuSeparator, menuitem2, submenu,
menuitem3, menuitem4, otherSeparator, menuitem5, menuitem6);
contentEditor.setLocation(ContentEditor.SNDBAR, btn);
@@ -160,8 +164,8 @@
// It's important to add the menus before its menu items
contentEditor.addActions(menuitem2, submenu, menuitem3, menuitem4, otherSeparator, menuitem5, menuitem6);
- // We can change descriptors properties and are changed in the
- // UI
+ // We can change descriptors properties after render and the UI
+ // is updated automatically
btn.setPushed(true);
// After some time we can change the common action or some other
@@ -170,12 +174,11 @@
@Override
public void run() {
// The text of the action (in the menu or in the button)
- action.putValue(Action.NAME, "hello world new");
- // And the tooltip (on over message):
- action.putValue(Action.SHORT_DESCRIPTION, "hello world new");
+ action.putValue(Action.NAME, "hello world (updated)");
+ action.putValue(Action.SHORT_DESCRIPTION, "hello world tooltip (updated)");
btn.setPushed(false);
}
- }.schedule(10000);
+ }.schedule(15000);
}
}
@@ -189,7 +192,7 @@
}
public void showMessage() {
- /** i18n use with parameters **/
+ // i18n use with parameters
NotifyUser.info(i18n.t("Hello [%s]!", "world"));
}
}
@@ -205,16 +208,17 @@
static class HelloWorldAction extends AbstractAction {
public HelloWorldAction(final ImgResources img) {
super();
- super.putValue(Action.NAME, "helloword");
- super.putValue(Action.SHORT_DESCRIPTION, "helloworld item");
+ super.putValue(Action.NAME, "helloworld");
+ super.putValue(Action.SHORT_DESCRIPTION, "helloworld tooltip");
super.putValue(Action.SMALL_ICON, img.info());
}
public void actionPerformed(final ActionEvent actionEvent) {
if (actionEvent.getEvent().getCtrlKey()) {
NotifyUser.info("Hello world action fired with ctrl key pressed");
+ } else {
+ NotifyUser.info("Hello world action fired");
}
- NotifyUser.info("Hello world action fired");
}
}
@@ -241,11 +245,18 @@
register(Singleton.class, new Factory<HelloWorld>(HelloWorld.class) {
/**
* Singleton.class decorator: creates only one instance of
- * HelloWorld.class and when we use it the provider returns always
+ * HelloWorld.class and when we use it, the provider returns always
* the same instance.
*
* NoDecorator.class: Use it if we need to create a new instance of
* HelloWorld.class in every use.
+ *
+ * Others:
+ *
+ * ApplicationComponentGroup.class: Use this decorator with parts of
+ * kune that are needed at start time (like main widgets in
+ * workspace). They are created automatically when starting.
+ *
*/
@Override
public HelloWorld create() {
@@ -261,7 +272,7 @@
/**
* Optionally: we can do something after the instance is created
- **/
+ */
@Override
public void onAfterCreated(final HelloWorld instance) {
Log.info("HelloWorld singleton instance created");
@@ -272,7 +283,7 @@
* we use a mock for i18n in this sample because we don't really want to
* translate this module messages. Normally we use:
* I18nTranslationService.class instead of the mock
- **/
+ */
register(Singleton.class, new Factory<I18nTranslationServiceMocked>(I18nTranslationServiceMocked.class) {
@Override
public I18nTranslationServiceMocked create() {
@@ -288,5 +299,11 @@
NotifyUser.info("Global Ctrl+S pressed");
}
});
+
+ // And because nobody use this module, we get the class (to force the
+ // creation of the Helloworld instance):
+ // i(HelloWorld.class);
+
+ // See KuneEntryPoint for a sample of modules registration
}
}
\ No newline at end of file
1
0
Author: vjrj
Date: 2009-06-12 00:14:06 +0200 (Fri, 12 Jun 2009)
New Revision: 1126
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorView.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.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
Modified:
trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java
trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.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/MenuDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java
trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.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/saving/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java
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/RTESavingEditorView.java
trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.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/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java
Log:
Complete - task ContentEditor action extensible
Incomplete - task Hello World updated and Application Boot improved
Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -28,7 +28,6 @@
import org.ourproject.kune.wiki.client.WikiClientModule;
import org.ourproject.kune.workspace.client.RegistryModule;
import org.ourproject.kune.workspace.client.WorkspaceModule;
-import org.ourproject.kune.workspace.client.hello.HelloWorldModule;
import com.allen_sauer.gwt.log.client.Log;
import com.calclab.emiteuimodule.client.EmiteUIModule;
@@ -56,8 +55,5 @@
Suco.install(new CoreModule(), new RegistryModule(), new PlatformModule(), new EmiteUIModule(),
new DocumentClientModule(), new BlogClientModule(), new WikiClientModule(), new GalleryClientModule(),
new ChatClientModule(), new WorkspaceModule());
-
- // We install our HelloWorldModule
- Suco.install(new HelloWorldModule());
}
}
Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -70,8 +70,8 @@
final String[] containersNoRoot = { TYPE_BLOG };
final String[] contents = { TYPE_POST, TYPE_UPLOADEDFILE };
- String parentMenuTitle = i18n.t("Post");
- String parentMenuTitleCtx = i18n.t("Blog");
+ final String parentMenuTitle = i18n.t("Post");
+ final String parentMenuTitleCtx = i18n.t("Blog");
createNewContainerAction(TYPE_BLOG, "images/nav/blog_add.png", i18n.t("New blog"), parentMenuTitleCtx,
i18n.t("New"), i18n.t("New blog"), Position.ctx, TYPE_ROOT);
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -52,6 +52,7 @@
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.Window.ClosingEvent;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.ToolbarButton;
@@ -110,8 +111,8 @@
login(user.getChatName(), user.getChatPassword());
}
});
- application.onApplicationStop(new Listener0() {
- public void onEvent() {
+ application.onClosing(new Listener<ClosingEvent>() {
+ public void onEvent(final ClosingEvent event) {
stop();
}
});
@@ -139,7 +140,7 @@
public boolean isBuddie(final XmppURI jid) {
if (roster != null) {
- for (RosterItem item : roster) {
+ for (final RosterItem item : roster) {
if (item.getJID().equalsNoResource(jid)) {
return true;
}
@@ -168,7 +169,7 @@
if (subject != null) {
DeferredCommand.addCommand(new Command() {
public void execute() {
- RoomUI roomUI = (RoomUI) room.getData(ChatUI.class);
+ final RoomUI roomUI = (RoomUI) room.getData(ChatUI.class);
if (roomUI != null) {
roomUI.setSubject(subject);
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -70,8 +70,8 @@
final String[] containersNoRoot = { TYPE_FOLDER };
final String[] contents = { TYPE_DOCUMENT, TYPE_UPLOADEDFILE };
- String parentMenuTitle = i18n.t("File");
- String parentMenuTitleCtx = i18n.t("Folder");
+ final String parentMenuTitle = i18n.t("File");
+ final String parentMenuTitleCtx = i18n.t("Folder");
createNewContainerAction(TYPE_FOLDER, "images/nav/folder_add.png", i18n.t("New folder"), parentMenuTitleCtx,
i18n.t("New"), i18n.t("New folder"), Position.ctx, TYPE_ROOT, TYPE_FOLDER);
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -69,8 +69,8 @@
final String[] containersNoRoot = { TYPE_ALBUM };
final String[] contents = { TYPE_UPLOADEDFILE };
- String parentMenuTitle = i18n.t("File");
- String parentMenuTitleCtx = i18n.t("Album");
+ final String parentMenuTitle = i18n.t("File");
+ final String parentMenuTitleCtx = i18n.t("Album");
createNewContainerAction(TYPE_ALBUM, "images/nav/gallery_add.png", i18n.t("New sub-album"), parentMenuTitleCtx,
i18n.t("New"), i18n.t("New sub-album"), Position.ctx, TYPE_ALBUM);
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractButtonGui.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -67,7 +67,11 @@
@Override
protected void setIcon(final ImageResource imageResource) {
if (imageResource != null) {
- button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
+ if (action.getValue(Action.NAME) == null) {
+ button.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
+ } else {
+ button.setIcon(ImgConstants.PATH_PREFIX + imageResource.getName() + ".png");
+ }
}
}
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -27,6 +27,10 @@
this(new BaseAction(text, null, icon));
}
+ public MenuDescriptor(final String text, final String tooltip) {
+ this(new BaseAction(text, tooltip, null));
+ }
+
public MenuDescriptor(final String text, final String tooltip, final ImageResource icon) {
this(new BaseAction(text, tooltip, icon));
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/Application.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -19,13 +19,15 @@
*/
package org.ourproject.kune.platf.client.app;
+import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.user.client.Window.ClosingEvent;
public interface Application {
- void onApplicationStart(Listener0 listener);
+ void onClosing(Listener<ClosingEvent> listener);
- void onApplicationStop(Listener0 listener);
+ void onStarting(Listener0 listener);
void start();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationDefault.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -27,7 +27,9 @@
import org.ourproject.kune.platf.client.utils.PrefetchUtilities;
import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Event;
import com.calclab.suco.client.events.Event0;
+import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DeferredCommand;
@@ -40,30 +42,30 @@
public class ApplicationDefault implements Application {
private final Session session;
- private final Event0 onAppStart;
- private final Event0 onAppStop;
+ private final Event0 onAppStarting;
+ private final Event<ClosingEvent> onAppClosing;
public ApplicationDefault(final Session session) {
this.session = session;
- this.onAppStart = new Event0("onApplicationStart");
- this.onAppStop = new Event0("onApplicationStop");
+ this.onAppStarting = new Event0("onAppStarting");
+ this.onAppClosing = new Event<ClosingEvent>("onAppClossing");
Window.addWindowClosingHandler(new ClosingHandler() {
public void onWindowClosing(final ClosingEvent event) {
- stop();
+ stop(event);
}
});
}
- public void onApplicationStart(final Listener0 listener) {
- onAppStart.add(listener);
+ public void onClosing(final Listener<ClosingEvent> listener) {
+ onAppClosing.add(listener);
}
- public void onApplicationStop(final Listener0 listener) {
- onAppStop.add(listener);
+ public void onStarting(final Listener0 listener) {
+ onAppStarting.add(listener);
}
public void start() {
- onAppStart.fire();
+ onAppStarting.fire();
PrefetchUtilities.preFetchImpImages();
getInitData();
final Timer prefetchTimer = new Timer() {
@@ -98,7 +100,7 @@
});
}
- private void stop() {
- onAppStop.fire();
+ private void stop(final ClosingEvent event) {
+ onAppClosing.fire(event);
}
}
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -19,11 +19,8 @@
\*/
package org.ourproject.kune.platf.client.services;
-import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
import org.ourproject.kune.platf.client.actions.ui.BasicGuiBinding;
import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
-import org.ourproject.kune.platf.client.actions.ui.TestButton;
import org.ourproject.kune.platf.client.app.Application;
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
import org.ourproject.kune.platf.client.app.ApplicationDefault;
@@ -57,11 +54,9 @@
import org.ourproject.kune.platf.client.ui.palette.SimplePalettePanel;
import org.ourproject.kune.platf.client.ui.palette.SimplePalettePresenter;
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
-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.RTEditorNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenterNew;
+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.RTEditorPresenter;
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;
@@ -119,7 +114,6 @@
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
@@ -289,22 +283,6 @@
}
});
- register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) {
- @Override
- public RTEActionTopToolbar create() {
- final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>(p(ActionManager.class));
- final RTEActionTopToolbar toolbar = new RTEActionTopToolbar(panel);
- return toolbar;
- }
- }, new Factory<RTEActionSndToolbar>(RTEActionSndToolbar.class) {
- @Override
- public RTEActionSndToolbar create() {
- final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>(p(ActionManager.class), true);
- final RTEActionSndToolbar toolbar = new RTEActionSndToolbar(panel);
- return toolbar;
- }
- });
-
register(Singleton.class, new Factory<TimerWrapper>(TimerWrapper.class) {
@Override
public TimerWrapper create() {
@@ -333,14 +311,32 @@
}
});
- register(NoDecoration.class,new Factory<RTEditorNew>(RTEditorNew.class) {
+ register(Singleton.class, new Factory<ImgResources>(ImgResources.class) {
@Override
- public RTEditorNew create() {
- final RTEditorPresenterNew presenter = new RTEditorPresenterNew(i(I18nTranslationService.class),
+ public ImgResources create() {
+ final ImgResources instance = GWT.create(ImgResources.class);
+ StyleInjector.injectStylesheet(instance.css().getText());
+ return instance;
+ }
+ });
+
+ register(Singleton.class, new Factory<RTEImgResources>(RTEImgResources.class) {
+ @Override
+ public RTEImgResources create() {
+ final RTEImgResources instance = GWT.create(RTEImgResources.class);
+ StyleInjector.injectStylesheet(instance.css().getText());
+ return instance;
+ }
+ });
+
+ register(NoDecoration.class,new Factory<RTEditor>(RTEditor.class) {
+ @Override
+ public RTEditor create() {
+ final RTEditorPresenter presenter = new RTEditorPresenter(i(I18nTranslationService.class),
i(Session.class), i(RTEImgResources.class), p(InsertLinkDialog.class),
p(ColorWebSafePalette.class), p(EditHtmlDialog.class), p(InsertImageDialog.class),
p(InsertMediaDialog.class), p(InsertTableDialog.class), p(InsertSpecialCharDialog.class), i(DeferredCommandWrapper.class));
- final RTEditorPanelNew panel = new RTEditorPanelNew(presenter, i(I18nUITranslationService.class),
+ final RTEditorPanel panel = new RTEditorPanel(presenter, i(I18nUITranslationService.class),
i(GlobalShortcutRegister.class), i(GuiBindingsRegister.class));
presenter.init(panel);
return presenter;
@@ -348,10 +344,14 @@
}, new Factory<RTESavingEditor>(RTESavingEditor.class) {
@Override
public RTESavingEditor create() {
- final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter(i(RTEditorNew.class), true,
- i(I18nTranslationService.class), i(StateManager.class), i(DeferredCommandWrapper.class),
- i(RTEImgResources.class), i(TimerWrapper.class));
- final RTESavingEditorPanel panel = new RTESavingEditorPanel();
+ final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter(i(I18nTranslationService.class),
+ i(Session.class), i(RTEImgResources.class), p(InsertLinkDialog.class),
+ p(ColorWebSafePalette.class), p(EditHtmlDialog.class), p(InsertImageDialog.class),
+ p(InsertMediaDialog.class), p(InsertTableDialog.class), p(InsertSpecialCharDialog.class), i(DeferredCommandWrapper.class), true,
+ i(StateManager.class),
+ i(TimerWrapper.class));
+ final RTESavingEditorPanel panel = new RTESavingEditorPanel(presenter, i(I18nUITranslationService.class),
+ i(GlobalShortcutRegister.class), i(GuiBindingsRegister.class));
presenter.init(panel);
return presenter;
}
@@ -371,24 +371,6 @@
}
});
- register(Singleton.class, new Factory<ImgResources>(ImgResources.class) {
- @Override
- public ImgResources create() {
- final ImgResources instance = GWT.create(ImgResources.class);
- StyleInjector.injectStylesheet(instance.css().getText());
- return instance;
- }
- });
-
- register(Singleton.class, new Factory<RTEImgResources>(RTEImgResources.class) {
- @Override
- public RTEImgResources create() {
- final RTEImgResources instance = GWT.create(RTEImgResources.class);
- StyleInjector.injectStylesheet(instance.css().getText());
- return instance;
- }
- });
-
registerDecorator(EditHtmlGroup.class, new EditHtmlGroup(container));
register(Singleton.class, new Factory<EditHtmlDialog>(EditHtmlDialog.class) {
@@ -548,21 +530,16 @@
}
});
- register(Singleton.class, new Factory<TestButton>(TestButton.class) {
- @Override
- public TestButton create() {
- final TestButton btn = new TestButton(i(WorkspaceSkeleton.class), i(GuiBindingsRegister.class), i(ImgResources.class));
- return btn;
- }
- });
-
-
- // i(TestButton.class);
-
i(ApplicationComponentGroup.class).createAll();
i(ToolGroup.class).createAll();
i(Application.class).start();
- //i(HelloWorld.class);
+ // We install our HelloWorldModule
+ //Suco.install(new HelloWorldModule());
+
+ // And because nobody use this module, we get the class (to force the
+ // creation of the
+ // Helloworld instance):
+ //i(HelloWorld.class);
}
}
\ No newline at end of file
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -2,8 +2,7 @@
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.RTEditorNew;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanelNew;
+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;
@@ -20,10 +19,9 @@
dialog = new BasicDialog("Testing RTE", false, false, 650, 200);
final VerticalPanel vp = new VerticalPanel();
- final RTEditorNew basicEditor = editor.getBasicEditor();
- vp.add((ComplexToolbar) basicEditor.getTopBar());
- vp.add((ComplexToolbar) basicEditor.getSndBar());
- final RTEditorPanelNew editorPanel = (RTEditorPanelNew) basicEditor.getEditorArea();
+ vp.add((ComplexToolbar) editor.getTopBar());
+ vp.add((ComplexToolbar) editor.getSndBar());
+ final RTEditorPanel editorPanel = (RTEditorPanel) editor.getEditorArea();
vp.add(editorPanel);
vp.setWidth("100%");
dialog.add(vp);
@@ -38,11 +36,11 @@
}
public void setExtended(final boolean extended) {
- editor.getBasicEditor().setExtended(extended);
+ editor.setExtended(extended);
}
public void show() {
- editor.getBasicEditor().attach();
+ editor.attach();
dialog.show();
}
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,13 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionSndToolbar extends ActionToolbarPresenter<Object> implements ActionToolbar<Object> {
-
- public RTEActionSndToolbar(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,13 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionTopToolbar extends ActionToolbarPresenter<Object> implements ActionToolbar<Object> {
-
- public RTEActionTopToolbar(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java (from rev 1123, 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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,233 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.View;
+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;
+
+import com.calclab.suco.client.events.Listener0;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Interface RTEditor.
+ */
+public interface RTEditor {
+
+ /**
+ * The TOPBAR location used in {@link GuiActionDescrip#setLocation(String)}
+ * for put the actions in the correct position
+ */
+ String TOPBAR = "rte-topbar";
+
+ /**
+ * The SNDBAR location used in {@link GuiActionDescrip#setLocation(String)}
+ * for put the actions in the correct position
+ */
+ String SNDBAR = "rte-sndbar";
+
+ /**
+ * The LINKCTX location used in {@link GuiActionDescrip#setLocation(String)}
+ * for put the actions in the links context menu
+ */
+ String LINKCTX = "rte-linkctx";
+
+ /**
+ * Adds a action description
+ *
+ * @param action
+ * the action
+ */
+ void addAction(GuiActionDescrip action);
+
+ /**
+ * Adds some action descriptions
+ *
+ * @param actions
+ * the actions
+ */
+ void addActionCollection(GuiActionDescCollection actions);
+
+ /**
+ * Adds some action descriptions
+ *
+ * @param action
+ * the action
+ */
+ void addActions(GuiActionDescrip... actions);
+
+ /**
+ * Adds the on edit listener (fired when the user do some edit).
+ *
+ * @param listener
+ * the listener
+ */
+ void addOnEditListener(Listener0 listener);
+
+ /**
+ * Attach (used for lazy action loading)
+ */
+ void attach();
+
+ /**
+ * Detach.
+ */
+ void detach();
+
+ /**
+ * Gets the basic add condition (if the editor is of "basic" type).
+ *
+ * @return the basic add condition
+ */
+ GuiAddCondition getBasicAddCondition();
+
+ /**
+ * Gets the "Edit" menu.
+ *
+ * @return the edits the menu
+ */
+ MenuDescriptor getEditMenu();
+
+ /**
+ * Gets the editor area (used for gui layout)
+ *
+ * @return the editor area
+ */
+ View getEditorArea();
+
+ /**
+ * Gets the extended add condition (editor can be a extended editor)
+ *
+ * @return the extended add condition
+ */
+ GuiAddCondition getExtendedAddCondition();
+
+ /**
+ * Gets the file menu.
+ *
+ * @return the file menu
+ */
+ MenuDescriptor getFileMenu();
+
+ /**
+ * Gets the format menu descriptor.
+ *
+ * @return the format menu
+ */
+ MenuDescriptor getFormatMenu();
+
+ /**
+ * Gets the html of the text area.
+ *
+ * @return the html
+ */
+ String getHtml();
+
+ /**
+ * Gets the insert menu descriptor.
+ *
+ * @return the insert menu
+ */
+ MenuDescriptor getInsertMenu();
+
+ /**
+ * Gets the link ctx menu descriptor.
+ *
+ * @return the link ctx menu
+ */
+ MenuDescriptor getLinkCtxMenu();
+
+ /**
+ * Gets the second bar of the editor.
+ *
+ * @return the snd bar
+ */
+ View getSndBar();
+
+ /**
+ * Gets the text of the text area (not the html).
+ *
+ * @return the text
+ */
+ String getText();
+
+ /**
+ * Gets the top bar.
+ *
+ * @return the top bar
+ */
+ View getTopBar();
+
+ /**
+ * Reset.
+ */
+ void reset();
+
+ /**
+ * Sets an action shortcut.
+ *
+ * @param key
+ * the key
+ * @param action
+ * the action
+ */
+ void setActionShortcut(KeyStroke key, AbstractAction action);
+
+ /**
+ * Sets some action shortcut, some principal, other similar (used when some
+ * UI buttons do the same action).
+ *
+ * @param key
+ * the key
+ * @param mainAction
+ * the main action
+ * @param actions
+ * the actions
+ */
+ void setActionShortcut(KeyStroke key, AbstractAction mainAction, AbstractAction... actions);
+
+ /**
+ * Sets that editor must be extended type (if browser permit it).
+ *
+ * @param extended
+ * the new extended
+ */
+ void setExtended(boolean extended);
+
+ /**
+ * Sets the focus on text editor.
+ *
+ * @param focus
+ * the new focus
+ */
+ void setFocus(boolean focus);
+
+ /**
+ * Sets the html of the editor.
+ *
+ * @param html
+ * the new html
+ */
+ void setHtml(String html);
+
+ /**
+ * We can define some location ("topbar", "second bar", etc) to action
+ * descriptors.
+ *
+ * @param location
+ * the location
+ * @param descripts
+ * the descripts
+ */
+ void setLocation(String location, GuiActionDescrip... descripts);
+
+ /**
+ * Sets the text of the editor.
+ *
+ * @param text
+ * the new text
+ */
+ void setText(String text);
+}
Deleted: 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorNew.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,66 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.View;
-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;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTEditorNew {
-
- String TOPBAR = "rte-topbar";
- String SNDBAR = "rte-sndbar";
- String LINKCTX = "rte-linkctx";
-
- void addAction(GuiActionDescrip action);
-
- void addActions(GuiActionDescCollection actions);
-
- void addOnEditListener(Listener0 listener);
-
- void attach();
-
- void detach();
-
- GuiAddCondition getBasicAddCondition();
-
- MenuDescriptor getEditMenu();
-
- View getEditorArea();
-
- GuiAddCondition getExtendedAddCondition();
-
- MenuDescriptor getFileMenu();
-
- MenuDescriptor getFormatMenu();
-
- String getHtml();
-
- MenuDescriptor getInsertMenu();
-
- MenuDescriptor getLinkCtxMenu();
-
- View getSndBar();
-
- String getText();
-
- 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);
-
- void setHtml(String html);
-
- void setText(String text);
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java (from rev 1124, 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,518 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import java.util.Date;
+
+import org.cobogw.gwt.user.client.CSS;
+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.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.ui.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.BasicFormatter;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.ExtendedFormatter;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.Justification;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkExecutableUtils;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
+import org.xwiki.gwt.dom.client.DocumentFragment;
+import org.xwiki.gwt.dom.client.Range;
+import org.xwiki.gwt.dom.client.Selection;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.event.dom.client.BlurEvent;
+import com.google.gwt.event.dom.client.BlurHandler;
+import com.google.gwt.event.dom.client.FocusEvent;
+import com.google.gwt.event.dom.client.FocusHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Event;
+
+public class RTEditorPanel extends AbstractComplexGuiItem implements RTEditorView, FocusHandler, BlurHandler {
+
+ private static final Element NO_ELEMENT = null;
+ private final I18nUITranslationService i18n;
+ private final BasicFormatter basic;
+ private final ExtendedFormatter extended;
+ private final RTEditorPresenter presenter;
+ private final GlobalShortcutRegister globalShortcutReg;
+ private final RTELinkPopup linkCtxMenu;
+ private final RichTextArea rta;
+ private final ComplexToolbar topBar;
+ private final ComplexToolbar sndBar;
+
+ public RTEditorPanel(final RTEditorPresenter presenter, final I18nUITranslationService i18n,
+ final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
+ super();
+ this.presenter = presenter;
+ this.i18n = i18n;
+ this.globalShortcutReg = globalShortcutReg;
+ rta = new RichTextArea();
+ basic = rta.getBasicFormatter();
+ extended = rta.getExtendedFormatter();
+ 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%");
+ }
+
+ 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(RTEditor.TOPBAR)) {
+ topBar.add(item);
+ } else if (location.equals(RTEditor.SNDBAR)) {
+ sndBar.add(item);
+ } else if (location.equals(RTEditor.LINKCTX)) {
+ linkCtxMenu.add(item);
+ } else {
+ throw new UIException("Unknown location in action item: " + item);
+ }
+ }
+ }
+
+ public void adjustSize(final int height) {
+ setHeight(Integer.toString(height));
+ }
+
+ public boolean canBeBasic() {
+ return basic != null;
+ }
+
+ public boolean canBeExtended() {
+ return extended != null;
+ }
+
+ public void copy() {
+ extended.copy();
+ }
+
+ public void createLink(final String url) {
+ extended.createLink(url);
+ }
+
+ public void cut() {
+ extended.cut();
+ }
+
+ public void delete() {
+ extended.delete();
+ }
+
+ public void focus() {
+ setFocus(true);
+ }
+
+ public String getFont() {
+ final Element currentElement = getCurrentElement();
+ return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty(CSS.A.FONT_FAMILY);
+ }
+
+ public String getFontSize() {
+ final Element currentElement = getCurrentElement();
+ return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty("size");
+ }
+
+ public String getHTML() {
+ return rta.getHTML();
+ }
+
+ public LinkInfo getLinkInfoIfHref() {
+ LinkInfo linkinfo = null;
+ final org.xwiki.gwt.dom.client.Element selectedAnchor = selectAndGetLink();
+ if (selectedAnchor == null) {
+ linkinfo = new LinkInfo(getSelectionText());
+ } else {
+ linkinfo = LinkInfo.parse(selectedAnchor);
+ }
+ Log.debug("Link info: " + linkinfo);
+ return linkinfo;
+ }
+
+ public void getRangeInfo() {
+ // Selection selection = getSelection();
+ // String info = "range count: " + selection.getRangeCount() +
+ // "<br/>focus offset: " + selection.getFocusOffset()
+ // + "<br/>anchor offset:" + selection.getAnchorOffset() +
+ // "<br/>range 0 as html: "
+ // + selection.getRangeAt(0).toHTML();
+ // NotifyUser.info(info);
+ final String info = "range count: " + getFstRange().getCommonAncestorContainer().getFirstChild().getNodeName();
+ NotifyUser.info(info);
+ }
+
+ public String getSelectionText() {
+ 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();
+ }
+
+ public void insertBlockquote() {
+ final DocumentFragment extracted = getFstRange().cloneContents();
+ // delete();
+ insertHtml("<blockquote>" + extracted.getInnerHTML() + "</blockquote>");
+ focus();
+ }
+
+ public void insertComment(final String author) {
+ createCommentAndSelectIt(author, null);
+ }
+
+ public void insertCommentNotUsingSelection(final String author) {
+ getFstRange().collapse(false);
+ createCommentAndSelectIt(author, null);
+ focus();
+ }
+
+ public void insertCommentUsingSelection(final String author) {
+ final DocumentFragment extracted = getFstRange().cloneContents();
+ extended.delete();
+ final String comment = extracted.getInnerText();
+ createCommentAndSelectIt(author, comment);
+ focus();
+ }
+
+ public void insertHorizontalRule() {
+ extended.insertHorizontalRule();
+ }
+
+ public void insertHtml(final String html) {
+ extended.insertHtml(html);
+ }
+
+ public void insertImage(final String url) {
+ extended.insertImage(url);
+ }
+
+ public void insertOrderedList() {
+ extended.insertOrderedList();
+ }
+
+ public void insertUnorderedList() {
+ extended.insertUnorderedList();
+ }
+
+ public boolean isAnythingSelected() {
+ return !rta.getDocument().getSelection().isCollapsed();
+ }
+
+ public boolean isBold() {
+ return basic.isBold();
+ }
+
+ public boolean isCollapsed() {
+ return getFstRange().isCollapsed();
+ }
+
+ public boolean isCtxMenuVisible() {
+ return linkCtxMenu.isVisible();
+ }
+
+ public boolean isItalic() {
+ return basic.isItalic();
+ }
+
+ public boolean isLink() {
+ boolean isLink = false;
+ if (isAttached() && LinkExecutableUtils.getSelectedAnchor(rta) != null) {
+ isLink = true;
+ }
+ return isLink;
+ }
+
+ public boolean isStrikethrough() {
+ return extended.isStrikethrough();
+ }
+
+ public boolean isSubscript() {
+ return basic.isSubscript();
+ }
+
+ public boolean isSuperscript() {
+ return basic.isSuperscript();
+ }
+
+ public boolean isUnderlined() {
+ return basic.isUnderlined();
+ }
+
+ public void justifyCenter() {
+ basic.setJustification(Justification.CENTER);
+ }
+
+ public void justifyLeft() {
+ basic.setJustification(Justification.LEFT);
+ }
+
+ public void justifyRight() {
+ basic.setJustification(Justification.RIGHT);
+ }
+
+ public void leftIndent() {
+ extended.leftIndent();
+ }
+
+ public void onBlur(final BlurEvent event) {
+ presenter.onLostFocus();
+ }
+
+ @Override
+ public void onBrowserEvent(final Event event) {
+ switch (DOM.eventGetType(event)) {
+ case Event.ONCLICK:
+ updateStatus();
+ updateLinkInfo();
+ super.onBrowserEvent(event);
+ break;
+ 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) {
+ super.onBrowserEvent(event);
+ updateStatus();
+ updateLinkInfo();
+ if (isAnEditionKey(event.getKeyCode())) {
+ fireEdit();
+ }
+ } else {
+ updateStatus();
+ fireEdit();
+ event.stopPropagation();
+ event.preventDefault();
+ actionItem.actionPerformed(new ActionEvent(this, event));
+ updateStatus();
+ }
+ break;
+ default:
+ // Rest of events
+ super.onBrowserEvent(event);
+ updateStatus();
+ }
+ }
+
+ public void onFocus(final FocusEvent event) {
+ presenter.onEditorFocus();
+ }
+
+ public void paste() {
+ extended.paste();
+ }
+
+ public void redo() {
+ extended.redo();
+ }
+
+ public void removeFormat() {
+ extended.removeFormat();
+ }
+
+ public void rightIndent() {
+ extended.rightIndent();
+ }
+
+ public void selectAll() {
+ basic.selectAll();
+ }
+
+ public void selectLink() {
+ selectAndGetLink();
+ }
+
+ public void setBackColor(final String color) {
+ basic.setBackColor(color);
+ }
+
+ public void setFocus(final boolean focused) {
+ rta.setFocus(focused);
+ }
+
+ public void setFontName(final String name) {
+ basic.setFontName(name);
+ }
+
+ public void setFontSize(final FontSize size) {
+ basic.setFontSize(size);
+ }
+
+ public void setForeColor(final String color) {
+ basic.setForeColor(color);
+ }
+
+ public void setHTML(final String html) {
+ rta.setHTML(html);
+ }
+
+ public void setText(final String text) {
+ rta.setText(text);
+ }
+
+ public void showLinkCtxMenu() {
+ DeferredCommand.addCommand(new Command() {
+ public void execute() {
+ final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(rta);
+ if (selectedAnchor != null) {
+ linkCtxMenu.show(RTEditorPanel.this.getAbsoluteLeft() + selectedAnchor.getAbsoluteLeft(),
+ RTEditorPanel.this.getAbsoluteTop() + selectedAnchor.getAbsoluteTop() + 20);
+ }
+ }
+ });
+
+ }
+
+ public void toggleBold() {
+ basic.toggleBold();
+ }
+
+ public void toggleItalic() {
+ basic.toggleItalic();
+ }
+
+ public void toggleStrikethrough() {
+ extended.toggleStrikethrough();
+ }
+
+ public void toggleSubscript() {
+ basic.toggleSubscript();
+ }
+
+ public void toggleSuperscript() {
+ basic.toggleSuperscript();
+ }
+
+ public void toggleUnderline() {
+ basic.toggleUnderline();
+ }
+
+ public void undo() {
+ extended.undo();
+ }
+
+ public void unlink() {
+ extended.removeLink();
+ }
+
+ protected void fireEdit() {
+ presenter.fireOnEdit();
+ }
+
+ protected Element getElement(final Node inputNode) {
+ Node node = inputNode;
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ node = node.getParentNode();
+ }
+ if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
+ return null;
+ }
+ return Element.as(node);
+ }
+
+ private void createCommentAndSelectIt(final String author, final String comment) {
+ final Element commentEl = createCommentElement(author, comment);
+ final Range innerCommentRange = rta.getDocument().createRange();
+ getFstRange().insertNode(commentEl);
+ innerCommentRange.selectNodeContents(commentEl.getFirstChild());
+ getSelection().addRange(innerCommentRange);
+ fireEdit();
+ }
+
+ private Element createCommentElement(final String userName, final String insertComment) {
+ final String time = i18n.formatDateWithLocale(new Date(), true);
+ final Element span = rta.getDocument().createSpanElement();
+ final String comment = insertComment == null ? i18n.t("type your comment here") : insertComment;
+ span.setInnerHTML("<em>" + comment + "</em> -" + userName + " " + time);
+ DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
+ // insertHtml(" " + span.getString() + " ");
+ return span;
+ }
+
+ private Element getCurrentElement() {
+ if (getSelection().getRangeCount() > 0) {
+ return getElement(getSelection().getRangeAt(0).getStartContainer());
+ } else {
+ return NO_ELEMENT;
+ }
+ }
+
+ private Range getFstRange() {
+ return getSelection().getRangeAt(0);
+ }
+
+ private Selection getSelection() {
+ return rta.getDocument().getSelection();
+ }
+
+ private boolean isAnEditionKey(final int keyCode) {
+ switch (keyCode) { // NOPMD by vjrj on 5/06/09 19:14
+ case KeyCodes.KEY_HOME:
+ case KeyCodes.KEY_END:
+ case KeyCodes.KEY_UP:
+ case KeyCodes.KEY_DOWN:
+ case KeyCodes.KEY_LEFT:
+ case KeyCodes.KEY_RIGHT:
+ case KeyCodes.KEY_PAGEDOWN:
+ case KeyCodes.KEY_PAGEUP:
+ case KeyCodes.KEY_ESCAPE:
+ return false;
+ default:
+ return true;
+ }
+ }
+
+ private org.xwiki.gwt.dom.client.Element selectAndGetLink() {
+ final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(rta);
+ if (selectedAnchor != null) {
+ final Range range = rta.getDocument().createRange();
+ range.selectNode(selectedAnchor);
+ getSelection().addRange(range);
+ }
+ return selectedAnchor;
+ }
+
+ private void updateLinkInfo() {
+ presenter.updateLinkInfo();
+ }
+
+ /**
+ * Updates the status of all the stateful buttons.
+ */
+ private void updateStatus() {
+ presenter.updateStatus();
+ }
+}
Deleted: 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,518 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import java.util.Date;
-
-import org.cobogw.gwt.user.client.CSS;
-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.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.ui.noti.NotifyUser;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.BasicFormatter;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.ExtendedFormatter;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.Justification;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkExecutableUtils;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-import org.xwiki.gwt.dom.client.DocumentFragment;
-import org.xwiki.gwt.dom.client.Range;
-import org.xwiki.gwt.dom.client.Selection;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.Node;
-import com.google.gwt.event.dom.client.BlurEvent;
-import com.google.gwt.event.dom.client.BlurHandler;
-import com.google.gwt.event.dom.client.FocusEvent;
-import com.google.gwt.event.dom.client.FocusHandler;
-import com.google.gwt.event.dom.client.KeyCodes;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event;
-
-public class RTEditorPanelNew extends AbstractComplexGuiItem implements RTEditorViewNew, FocusHandler, BlurHandler {
-
- private static final Element NO_ELEMENT = null;
- private final I18nUITranslationService i18n;
- private final BasicFormatter basic;
- private final ExtendedFormatter extended;
- 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 RTEditorPresenterNew presenter, final I18nUITranslationService i18n,
- final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
- super();
- this.presenter = presenter;
- this.i18n = i18n;
- this.globalShortcutReg = globalShortcutReg;
- rta = new RichTextArea();
- basic = rta.getBasicFormatter();
- extended = rta.getExtendedFormatter();
- 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%");
- }
-
- 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 adjustSize(final int height) {
- setHeight(Integer.toString(height));
- }
-
- public boolean canBeBasic() {
- return basic != null;
- }
-
- public boolean canBeExtended() {
- return extended != null;
- }
-
- public void copy() {
- extended.copy();
- }
-
- public void createLink(final String url) {
- extended.createLink(url);
- }
-
- public void cut() {
- extended.cut();
- }
-
- public void delete() {
- extended.delete();
- }
-
- public void focus() {
- setFocus(true);
- }
-
- public String getFont() {
- final Element currentElement = getCurrentElement();
- return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty(CSS.A.FONT_FAMILY);
- }
-
- public String getFontSize() {
- final Element currentElement = getCurrentElement();
- return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty("size");
- }
-
- public String getHTML() {
- return rta.getHTML();
- }
-
- public LinkInfo getLinkInfoIfHref() {
- LinkInfo linkinfo = null;
- final org.xwiki.gwt.dom.client.Element selectedAnchor = selectAndGetLink();
- if (selectedAnchor == null) {
- linkinfo = new LinkInfo(getSelectionText());
- } else {
- linkinfo = LinkInfo.parse(selectedAnchor);
- }
- Log.debug("Link info: " + linkinfo);
- return linkinfo;
- }
-
- public void getRangeInfo() {
- // Selection selection = getSelection();
- // String info = "range count: " + selection.getRangeCount() +
- // "<br/>focus offset: " + selection.getFocusOffset()
- // + "<br/>anchor offset:" + selection.getAnchorOffset() +
- // "<br/>range 0 as html: "
- // + selection.getRangeAt(0).toHTML();
- // NotifyUser.info(info);
- final String info = "range count: " + getFstRange().getCommonAncestorContainer().getFirstChild().getNodeName();
- NotifyUser.info(info);
- }
-
- public String getSelectionText() {
- 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();
- }
-
- public void insertBlockquote() {
- final DocumentFragment extracted = getFstRange().cloneContents();
- // delete();
- insertHtml("<blockquote>" + extracted.getInnerHTML() + "</blockquote>");
- focus();
- }
-
- public void insertComment(final String author) {
- createCommentAndSelectIt(author, null);
- }
-
- public void insertCommentNotUsingSelection(final String author) {
- getFstRange().collapse(false);
- createCommentAndSelectIt(author, null);
- focus();
- }
-
- public void insertCommentUsingSelection(final String author) {
- final DocumentFragment extracted = getFstRange().cloneContents();
- extended.delete();
- final String comment = extracted.getInnerText();
- createCommentAndSelectIt(author, comment);
- focus();
- }
-
- public void insertHorizontalRule() {
- extended.insertHorizontalRule();
- }
-
- public void insertHtml(final String html) {
- extended.insertHtml(html);
- }
-
- public void insertImage(final String url) {
- extended.insertImage(url);
- }
-
- public void insertOrderedList() {
- extended.insertOrderedList();
- }
-
- public void insertUnorderedList() {
- extended.insertUnorderedList();
- }
-
- public boolean isAnythingSelected() {
- return !rta.getDocument().getSelection().isCollapsed();
- }
-
- public boolean isBold() {
- return basic.isBold();
- }
-
- public boolean isCollapsed() {
- return getFstRange().isCollapsed();
- }
-
- public boolean isCtxMenuVisible() {
- return linkCtxMenu.isVisible();
- }
-
- public boolean isItalic() {
- return basic.isItalic();
- }
-
- public boolean isLink() {
- boolean isLink = false;
- if (isAttached() && LinkExecutableUtils.getSelectedAnchor(rta) != null) {
- isLink = true;
- }
- return isLink;
- }
-
- public boolean isStrikethrough() {
- return extended.isStrikethrough();
- }
-
- public boolean isSubscript() {
- return basic.isSubscript();
- }
-
- public boolean isSuperscript() {
- return basic.isSuperscript();
- }
-
- public boolean isUnderlined() {
- return basic.isUnderlined();
- }
-
- public void justifyCenter() {
- basic.setJustification(Justification.CENTER);
- }
-
- public void justifyLeft() {
- basic.setJustification(Justification.LEFT);
- }
-
- public void justifyRight() {
- basic.setJustification(Justification.RIGHT);
- }
-
- public void leftIndent() {
- extended.leftIndent();
- }
-
- public void onBlur(final BlurEvent event) {
- presenter.onLostFocus();
- }
-
- @Override
- public void onBrowserEvent(final Event event) {
- switch (DOM.eventGetType(event)) {
- case Event.ONCLICK:
- updateStatus();
- updateLinkInfo();
- super.onBrowserEvent(event);
- break;
- 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) {
- super.onBrowserEvent(event);
- updateStatus();
- updateLinkInfo();
- if (isAnEditionKey(event.getKeyCode())) {
- fireEdit();
- }
- } else {
- updateStatus();
- fireEdit();
- event.stopPropagation();
- event.preventDefault();
- actionItem.actionPerformed(new ActionEvent(this, event));
- updateStatus();
- }
- break;
- default:
- // Rest of events
- super.onBrowserEvent(event);
- updateStatus();
- }
- }
-
- public void onFocus(final FocusEvent event) {
- presenter.onEditorFocus();
- }
-
- public void paste() {
- extended.paste();
- }
-
- public void redo() {
- extended.redo();
- }
-
- public void removeFormat() {
- extended.removeFormat();
- }
-
- public void rightIndent() {
- extended.rightIndent();
- }
-
- public void selectAll() {
- basic.selectAll();
- }
-
- public void selectLink() {
- selectAndGetLink();
- }
-
- public void setBackColor(final String color) {
- basic.setBackColor(color);
- }
-
- public void setFocus(final boolean focused) {
- rta.setFocus(focused);
- }
-
- public void setFontName(final String name) {
- basic.setFontName(name);
- }
-
- public void setFontSize(final FontSize size) {
- basic.setFontSize(size);
- }
-
- public void setForeColor(final String color) {
- basic.setForeColor(color);
- }
-
- public void setHTML(final String html) {
- rta.setHTML(html);
- }
-
- public void setText(final String text) {
- rta.setText(text);
- }
-
- public void showLinkCtxMenu() {
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(rta);
- if (selectedAnchor != null) {
- linkCtxMenu.show(RTEditorPanelNew.this.getAbsoluteLeft() + selectedAnchor.getAbsoluteLeft(),
- RTEditorPanelNew.this.getAbsoluteTop() + selectedAnchor.getAbsoluteTop() + 20);
- }
- }
- });
-
- }
-
- public void toggleBold() {
- basic.toggleBold();
- }
-
- public void toggleItalic() {
- basic.toggleItalic();
- }
-
- public void toggleStrikethrough() {
- extended.toggleStrikethrough();
- }
-
- public void toggleSubscript() {
- basic.toggleSubscript();
- }
-
- public void toggleSuperscript() {
- basic.toggleSuperscript();
- }
-
- public void toggleUnderline() {
- basic.toggleUnderline();
- }
-
- public void undo() {
- extended.undo();
- }
-
- public void unlink() {
- extended.removeLink();
- }
-
- protected void fireEdit() {
- presenter.fireOnEdit();
- }
-
- protected Element getElement(final Node inputNode) {
- Node node = inputNode;
- if (node.getNodeType() != Node.ELEMENT_NODE) {
- node = node.getParentNode();
- }
- if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
- return null;
- }
- return Element.as(node);
- }
-
- private void createCommentAndSelectIt(final String author, final String comment) {
- final Element commentEl = createCommentElement(author, comment);
- final Range innerCommentRange = rta.getDocument().createRange();
- getFstRange().insertNode(commentEl);
- innerCommentRange.selectNodeContents(commentEl.getFirstChild());
- getSelection().addRange(innerCommentRange);
- fireEdit();
- }
-
- private Element createCommentElement(final String userName, final String insertComment) {
- final String time = i18n.formatDateWithLocale(new Date(), true);
- final Element span = rta.getDocument().createSpanElement();
- final String comment = insertComment == null ? i18n.t("type your comment here") : insertComment;
- span.setInnerHTML("<em>" + comment + "</em> -" + userName + " " + time);
- DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
- // insertHtml(" " + span.getString() + " ");
- return span;
- }
-
- private Element getCurrentElement() {
- if (getSelection().getRangeCount() > 0) {
- return getElement(getSelection().getRangeAt(0).getStartContainer());
- } else {
- return NO_ELEMENT;
- }
- }
-
- private Range getFstRange() {
- return getSelection().getRangeAt(0);
- }
-
- private Selection getSelection() {
- return rta.getDocument().getSelection();
- }
-
- private boolean isAnEditionKey(final int keyCode) {
- switch (keyCode) { // NOPMD by vjrj on 5/06/09 19:14
- case KeyCodes.KEY_HOME:
- case KeyCodes.KEY_END:
- case KeyCodes.KEY_UP:
- case KeyCodes.KEY_DOWN:
- case KeyCodes.KEY_LEFT:
- case KeyCodes.KEY_RIGHT:
- case KeyCodes.KEY_PAGEDOWN:
- case KeyCodes.KEY_PAGEUP:
- case KeyCodes.KEY_ESCAPE:
- return false;
- default:
- return true;
- }
- }
-
- private org.xwiki.gwt.dom.client.Element selectAndGetLink() {
- final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(rta);
- if (selectedAnchor != null) {
- final Range range = rta.getDocument().createRange();
- range.selectNode(selectedAnchor);
- getSelection().addRange(range);
- }
- return selectedAnchor;
- }
-
- private void updateLinkInfo() {
- presenter.updateLinkInfo();
- }
-
- /**
- * Updates the status of all the stateful buttons.
- */
- private void updateStatus() {
- presenter.updateStatus();
- }
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java (from rev 1125, 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,1201 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+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.AbstractExtendedAction;
+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.ui.ButtonDescriptor;
+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.MenuCheckItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuRadioItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuSeparatorDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.PushButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor.Type;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.shortcuts.Keyboard;
+import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ImageInfo;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
+import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Event0;
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Provider;
+import com.google.gwt.libideas.resources.client.ImageResource;
+import com.google.gwt.user.client.Event;
+
+public class RTEditorPresenter implements RTEditor {
+
+ public class BackgroundColorAction extends AbstractExtendedAction {
+
+ public BackgroundColorAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ createPalette();
+ final Event event = actionEvent.getEvent();
+ palette.show(event.getClientX(), event.getClientY(), new Listener<String>() {
+ public void onEvent(final String color) {
+ palette.hide();
+ view.setBackColor(color);
+ fireOnEdit();
+ }
+ });
+ }
+ }
+
+ public class BlockquoteAction extends AbstractExtendedAction {
+ public BlockquoteAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.focus();
+ view.insertBlockquote();
+ fireOnEdit();
+ }
+ }
+
+ public class BoldAction extends AbstractExtendedAction {
+ public BoldAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleBold();
+ fireOnEdit();
+ }
+ }
+
+ public class CommentAction extends AbstractExtendedAction {
+ public CommentAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ view.focus();
+ final String author = session.isLogged() ? session.getCurrentUser().getShortName()
+ : i18n.t("anonymous user");
+ if (view.isAnythingSelected()) {
+ NotifyUser.askConfirmation(i18n.t("Insert a comment"),
+ i18n.t("Include the selected text in the comment?"), new Listener0() {
+ public void onEvent() {
+ // include selection in
+ // comment
+ view.insertCommentUsingSelection(author);
+ }
+ }, new Listener0() {
+ public void onEvent() {
+ // not include selection in
+ // comment;
+ view.insertCommentNotUsingSelection(author);
+ }
+ });
+ } else {
+ // Nothing selected > create comment in
+ // insertion point
+ view.insertComment(author);
+ }
+ }
+ });
+ }
+
+ @Override
+ public boolean isEnabled() {
+ return session.isLogged();
+ }
+ }
+
+ public class CopyAction extends AbstractExtendedAction {
+ public CopyAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.copy();
+ }
+ }
+
+ public class CreateOrEditLinkAction extends AbstractExtendedAction {
+ public CreateOrEditLinkAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ private InsertLinkDialog insLinkDialog;
+
+ public void onEvent() {
+ if (insLinkListener == null) {
+ insLinkListener = new Listener<LinkInfo>() {
+ public void onEvent(final LinkInfo linkInfo) {
+ final String link = linkInfo.toString();
+ Log.debug("Link: " + link);
+ view.focus();
+ view.insertHtml(link);
+ fireOnEdit();
+ }
+ };
+ }
+ final LinkInfo linkInfo = view.getLinkInfoIfHref();
+
+ if (insLinkDialog == null) {
+ insLinkDialog = insLinkDialogPv.get();
+ }
+ insLinkDialog.setLinkInfo(linkInfo);
+ insLinkDialog.setOnCreateLink(insLinkListener);
+ insLinkDialog.show();
+ hideLinkCtxMenu();
+ final String href = linkInfo.getHref();
+ if (href.length() > 0) {
+ if (href.startsWith("mailto")) {
+ insLinkDialog.activateTab(2);
+ } else {
+ insLinkDialog.activateTab(1);
+ }
+ }
+ }
+ });
+ }
+ }
+
+ public class CutAction extends AbstractExtendedAction {
+ public CutAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.cut();
+ fireOnEdit();
+ }
+ }
+
+ public class DecreaseIndentAction extends AbstractExtendedAction {
+ public DecreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.leftIndent();
+ fireOnEdit();
+ }
+ }
+
+ public class DevInfoAction extends AbstractExtendedAction {
+ public DevInfoAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ view.getRangeInfo();
+ }
+ });
+ }
+ }
+
+ public class EditHtmlAction extends AbstractExtendedAction {
+ private EditHtmlDialog editHtmlDialog;
+
+ public EditHtmlAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ if (updHtmlListener == null) {
+ updHtmlListener = new Listener<String>() {
+ public void onEvent(final String html) {
+ view.setHTML(html);
+ fireOnEdit();
+ }
+ };
+ }
+ if (editHtmlDialog == null) {
+ editHtmlDialog = editHtmlDialogPv.get();
+ }
+ editHtmlDialog.setUpdateListener(updHtmlListener);
+ editHtmlDialog.show();
+ hideLinkCtxMenu();
+ editHtmlDialog.setHtml(view.getHTML());
+ }
+ }
+
+ public class FontAction extends AbstractExtendedAction {
+ public static final String FONT_NAME = "fontname";
+
+ public FontAction(final String fontName, final String tooltip, final ImageResource icon) {
+ super("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>", tooltip, icon);
+ super.putValue(FONT_NAME, fontName);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ final String fontName = getFontName();
+ view.setFontName(fontName);
+ fontMenu.setText(fontName);
+ fireOnEdit();
+ }
+
+ private String getFontName() {
+ return (String) super.getValue(FONT_NAME);
+ }
+ }
+
+ public class FontColorAction extends AbstractExtendedAction {
+ public FontColorAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ createPalette();
+ final Event event = actionEvent.getEvent();
+ palette.show(event.getClientX(), event.getClientY(), new Listener<String>() {
+ public void onEvent(final String color) {
+ palette.hide();
+ view.setForeColor(color);
+ fireOnEdit();
+ }
+ });
+ hideLinkCtxMenu();
+ }
+ }
+
+ public class FontSizeAction extends AbstractExtendedAction {
+ private final int fontSize;
+
+ public FontSizeAction(final String fontSizeName, final int fontSize, final String tooltip,
+ final ImageResource icon) {
+ super("<font size=\"" + (fontSize + 1) + "\">" + fontSizeName + "</font>", tooltip, icon);
+ this.fontSize = fontSize;
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.setFontSize(FONT_SIZES[fontSize]);
+ fireOnEdit();
+ // fontSizeMenu.setText(fontSizeName);
+ }
+ }
+
+ public class HrAction extends AbstractExtendedAction {
+ public HrAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.focus();
+ view.insertHorizontalRule();
+ fireOnEdit();
+ }
+ }
+
+ public class ImgAction extends AbstractExtendedAction {
+ public ImgAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ private InsertImageDialog insImgDialog;
+
+ public void onEvent() {
+ if (insImgListener == null) {
+ insImgListener = new Listener<ImageInfo>() {
+ public void onEvent(final ImageInfo imageInfo) {
+ Log.debug("Image: " + imageInfo);
+ view.focus();
+ view.insertHtml(imageInfo.toString());
+ fireOnEdit();
+ }
+ };
+ }
+ if (insImgDialog == null) {
+ insImgDialog = insImgDialogProv.get();
+ }
+ insImgDialog.reset();
+ insImgDialog.setOnCreateImage(insImgListener);
+ insImgDialog.show();
+ hideLinkCtxMenu();
+ }
+ });
+ }
+ }
+
+ public class IncreaseIndentAction extends AbstractExtendedAction {
+ public IncreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.rightIndent();
+ fireOnEdit();
+ }
+ }
+
+ public class InsertMediaAction extends AbstractExtendedAction {
+ public InsertMediaAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ private InsertMediaDialog insMediaDialog;
+
+ public void onEvent() {
+ if (insMediaListener == null) {
+ insMediaListener = new Listener<String>() {
+ public void onEvent(final String html) {
+ Log.debug("Media: " + html);
+ view.focus();
+ view.insertHtml(html);
+ fireOnEdit();
+ }
+ };
+ }
+ if (insMediaDialog == null) {
+ insMediaDialog = insMediaDialogPv.get();
+ }
+ insMediaDialog.setOnCreate(insMediaListener);
+ insMediaDialog.show();
+ hideLinkCtxMenu();
+ }
+ });
+ }
+ }
+
+ public class InsertSpecialCharAction extends AbstractExtendedAction {
+ private InsertSpecialCharDialog insCharDialog;
+
+ public InsertSpecialCharAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ NotifyUser.showProgressLoading();
+ if (insCharListener == null) {
+ insCharListener = new Listener<String>() {
+ public void onEvent(final String character) {
+ view.insertHtml(character);
+ }
+ };
+ }
+ if (insCharDialog == null) {
+ insCharDialog = insCharDialogProv.get();
+ }
+ insCharDialog.setOnInsertSpecialChar(insCharListener);
+ insCharDialog.show();
+ hideLinkCtxMenu();
+ NotifyUser.hideProgress();
+ }
+ }
+
+ public class InsertTableAction extends AbstractExtendedAction {
+ private InsertTableDialog insTableDialog;
+
+ public InsertTableAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ if (insTableListener == null) {
+ insTableListener = new Listener<String>() {
+ public void onEvent(final String table) {
+ view.insertHtml(table);
+ fireOnEdit();
+ }
+ };
+ }
+ if (insTableDialog == null) {
+ insTableDialog = insTableDialogPv.get();
+ }
+ insTableDialog.setOnInsertTable(insTableListener);
+ insTableDialog.show();
+ }
+ }
+
+ public class ItalicAction extends AbstractExtendedAction {
+ public ItalicAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleItalic();
+ fireOnEdit();
+ }
+ }
+
+ public class JustifyCentreAction extends AbstractExtendedAction {
+ public JustifyCentreAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.justifyCenter();
+ fireOnEdit();
+ }
+ }
+
+ public class JustifyLeftAction extends AbstractExtendedAction {
+ public JustifyLeftAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.justifyLeft();
+ fireOnEdit();
+ }
+ }
+
+ public class JustifyRightAction extends AbstractExtendedAction {
+ public JustifyRightAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.justifyRight();
+ fireOnEdit();
+ }
+ }
+
+ public class OlAction extends AbstractExtendedAction {
+ public OlAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.insertOrderedList();
+ fireOnEdit();
+ }
+ }
+
+ public class PasteAction extends AbstractExtendedAction {
+ public PasteAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.paste();
+ fireOnEdit();
+ }
+ }
+
+ public class RedoAction extends AbstractExtendedAction {
+ public RedoAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.redo();
+ fireOnEdit();
+ }
+ }
+
+ public class RemoveFormatAction extends AbstractExtendedAction {
+ public RemoveFormatAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.removeFormat();
+ fireOnEdit();
+ }
+ }
+
+ public class RemoveLinkAction extends AbstractExtendedAction {
+ public RemoveLinkAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ view.unlink();
+ hideLinkCtxMenu();
+ fireOnEdit();
+ }
+ });
+ }
+ }
+
+ public class SelectAllAction extends AbstractExtendedAction {
+ public SelectAllAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.selectAll();
+ }
+ }
+
+ public class StrikethroughAction extends AbstractExtendedAction {
+ public StrikethroughAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleStrikethrough();
+ fireOnEdit();
+ }
+ }
+
+ public class SubscriptAction extends AbstractExtendedAction {
+ public SubscriptAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleSubscript();
+ fireOnEdit();
+ }
+ }
+
+ public class SuperscriptAction extends AbstractExtendedAction {
+ public SuperscriptAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleSuperscript();
+ fireOnEdit();
+ }
+ }
+
+ public class UlAction extends AbstractExtendedAction {
+ public UlAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.insertUnorderedList();
+ fireOnEdit();
+ }
+ }
+
+ public class UnderlineAction extends AbstractExtendedAction {
+ public UnderlineAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.toggleUnderline();
+ fireOnEdit();
+ }
+ }
+
+ public class UndoAction extends AbstractExtendedAction {
+ public UndoAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ view.undo();
+ fireOnEdit();
+ }
+ }
+
+ private static final String FONT_NAMES[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet",
+ "Verdana" };
+ private static final String FONT_SIZE_NAMES[] = { "Extra small", "Very small (normal)", "Small", "Medium", "Large",
+ "Very large", "Extra large" };
+ private static final RichTextArea.FontSize[] FONT_SIZES = new RichTextArea.FontSize[] {
+ RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
+ RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
+ RichTextArea.FontSize.XX_LARGE };
+ private static final String FONT_GROUP = "fontgroup";
+ private static final String FONT_SIZEGROUP = "fontsizegroup";
+
+ private RTEditorView view;
+ private boolean extended;
+ private final I18nTranslationService i18n;
+ private final Session session;
+ private final RTEImgResources imgResources;
+ private final Event0 onEdit;
+ private final DeferredCommandWrapper deferred;
+ private final Provider<ColorWebSafePalette> paletteProvider;
+ private final Provider<InsertLinkDialog> insLinkDialogPv;
+ private final Provider<EditHtmlDialog> editHtmlDialogPv;
+ private final Provider<InsertImageDialog> insImgDialogProv;
+ private final Provider<InsertTableDialog> insTableDialogPv;
+ private final Provider<InsertSpecialCharDialog> insCharDialogProv;
+ private final Provider<InsertMediaDialog> insMediaDialogPv;
+ private Listener<String> insTableListener;
+ private Listener<LinkInfo> insLinkListener;
+ private Listener<ImageInfo> insImgListener;
+ private Listener<String> insMediaListener;
+ private Listener<String> updHtmlListener;
+ protected Listener<String> insCharListener;
+ protected ColorWebSafePalette palette;
+ private PushButtonDescriptor bold;
+ private PushButtonDescriptor italic;
+ private PushButtonDescriptor underline;
+ private PushButtonDescriptor strikethrough;
+ private final GuiAddCondition basicAddCond;
+ private final GuiAddCondition extendedAddCond;
+ private final InputMap inputMap;
+ private MenuDescriptor editMenu;
+ private MenuDescriptor insertMenu;
+ private MenuDescriptor formatMenu;
+ private MenuDescriptor linkCtxMenu;
+ private GuiActionDescCollection actions;
+ private MenuDescriptor fontMenu;
+ private MenuDescriptor fontSizeMenu;
+ private MenuDescriptor fileMenu;
+ private final List<MenuDescriptor> menus;
+ protected boolean attached;
+ private final Map<String, MenuCheckItemDescriptor> fontActions;
+ private MenuCheckItemDescriptor currentFontItem;
+
+ public RTEditorPresenter(final I18nTranslationService i18n, final Session session,
+ 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.insLinkDialogPv = insLinkDialog;
+ this.paletteProvider = palette;
+ this.editHtmlDialogPv = editHtmlDialog;
+ this.insImgDialogProv = insertImageDialog;
+ this.insMediaDialogPv = insertMediaDialog;
+ this.insTableDialogPv = insertTableDialog;
+ this.insCharDialogProv = insCharDialog;
+ this.deferred = deferred;
+ inputMap = new InputMap();
+ menus = new ArrayList<MenuDescriptor>();
+
+ this.imgResources = imgResources;
+ this.onEdit = new Event0("onRTEEdit");
+ extendedAddCond = new GuiAddCondition() {
+ public boolean mustBeAdded() {
+ return isAndCanBeExtended();
+ }
+ };
+ basicAddCond = new GuiAddCondition() {
+ public boolean mustBeAdded() {
+ return view.canBeBasic();
+ }
+ };
+ attached = false;
+ fontActions = new HashMap<String, MenuCheckItemDescriptor>();
+ }
+
+ public void addAction(final GuiActionDescrip descriptor) {
+ actions.add(descriptor);
+ checkForMenus(descriptor);
+ }
+
+ public void addActionCollection(final GuiActionDescCollection descriptors) {
+ actions.addAll(descriptors);
+ for (final GuiActionDescrip descriptor : descriptors) {
+ checkForMenus(descriptor);
+ }
+ }
+
+ public void addActions(final GuiActionDescrip... descriptors) {
+ actions.add(descriptors);
+ for (final GuiActionDescrip descriptor : descriptors) {
+ checkForMenus(descriptor);
+ }
+ }
+
+ public void addOnEditListener(final Listener0 listener) {
+ onEdit.add(listener);
+ }
+
+ public void adjustSize(final int height) {
+ view.adjustSize(height);
+ }
+
+ public void attach() {
+ if (!attached) {
+ attached = true;
+ view.addActions(actions);
+ view.setInputMap(inputMap);
+ }
+ }
+
+ public void detach() {
+ }
+
+ public void fireOnEdit() {
+ onEdit.fire();
+ }
+
+ public GuiAddCondition getBasicAddCondition() {
+ return basicAddCond;
+ }
+
+ public MenuDescriptor getEditMenu() {
+ return editMenu;
+ }
+
+ public View getEditorArea() {
+ return view;
+ }
+
+ public GuiAddCondition getExtendedAddCondition() {
+ return extendedAddCond;
+ }
+
+ public MenuDescriptor getFileMenu() {
+ return fileMenu;
+ }
+
+ public MenuDescriptor getFormatMenu() {
+ return formatMenu;
+ }
+
+ public String getHtml() {
+ return view.getHTML();
+ }
+
+ public MenuDescriptor getInsertMenu() {
+ return insertMenu;
+ }
+
+ public MenuDescriptor getLinkCtxMenu() {
+ return linkCtxMenu;
+ }
+
+ public View getSndBar() {
+ return view.getSndBar();
+ }
+
+ public String getText() {
+ return view.getText();
+ }
+
+ public View getTopBar() {
+ return view.getTopBar();
+ }
+
+ public void init(final RTEditorView view) {
+ this.view = view;
+ createMainMenus();
+ createBasicActions();
+ }
+
+ public void onEditorFocus() {
+ hideMenus();
+ }
+
+ public void onLostFocus() {
+ // Nothing for the moment
+ }
+
+ public void reset() {
+ hideMenus();
+ 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 newValue) {
+ this.extended = newValue;
+ }
+
+ public void setFocus(final boolean focus) {
+ view.setFocus(focus);
+ }
+
+ public void setHtml(final String html) {
+ view.setHTML(html);
+ view.focus();
+ }
+
+ public void setLocation(final String location, final GuiActionDescrip[] descripts) {
+ for (final GuiActionDescrip descript : descripts) {
+ descript.setLocation(location);
+ }
+ }
+
+ public void setText(final String text) {
+ view.setText(text);
+ view.focus();
+ }
+
+ public void updateLinkInfo() {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ if (isAndCanBeExtended() && view.isLink()) {
+ view.showLinkCtxMenu();
+ } else {
+ hideLinkCtxMenu();
+ }
+ }
+ });
+ }
+
+ public void updateStatus() {
+ if (view.canBeBasic()) {
+ bold.setPushed(view.isBold());
+ italic.setPushed(view.isItalic());
+ underline.setPushed(view.isUnderlined());
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ updateFont();
+ // Log.warn(view.getFontSize());
+ }
+ });
+ }
+ if (isAndCanBeExtended()) {
+ strikethrough.setPushed(view.isStrikethrough());
+ }
+ }
+
+ private void checkForMenus(final GuiActionDescrip descriptor) {
+ if (descriptor instanceof MenuDescriptor) {
+ menus.add((MenuDescriptor) descriptor);
+ }
+ }
+
+ private void createBasicActions() {
+
+ final MenuSeparatorDescriptor editMenuSep = new MenuSeparatorDescriptor(editMenu);
+ final MenuSeparatorDescriptor insertMenuSep = new MenuSeparatorDescriptor(insertMenu);
+ final MenuSeparatorDescriptor formatMenuSep = new MenuSeparatorDescriptor(formatMenu);
+ insertMenuSep.setAddCondition(extendedAddCond);
+
+ final ToolbarSeparatorDescriptor sndbarSep = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+ final ToolbarSeparatorDescriptor sndbarSepExt = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+ sndbarSepExt.setAddCondition(extendedAddCond);
+
+ final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"),
+ AbstractExtendedAction.NO_TEXT, imgResources.selectall());
+ final MenuItemDescriptor select = new MenuItemDescriptor(editMenu, selectAllAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('A'), Keyboard.MODIFIER_CTRL), selectAllAction);
+
+ final BoldAction boldAction = new BoldAction(NO_TEXT, i18n.t("Bold"), imgResources.bold());
+ bold = new PushButtonDescriptor(boldAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_CTRL), boldAction);
+
+ final ItalicAction italicAction = new ItalicAction(NO_TEXT, i18n.t("Italic"), imgResources.italic());
+ italic = new PushButtonDescriptor(italicAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_CTRL), italicAction);
+
+ final UnderlineAction underlineAction = new UnderlineAction(NO_TEXT, i18n.t("Underline"),
+ imgResources.underline());
+ underline = new PushButtonDescriptor(underlineAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('U'), Keyboard.MODIFIER_CTRL), underlineAction);
+
+ final SubscriptAction subscriptAction = new SubscriptAction(i18n.t("Subscript"), NO_TEXT,
+ imgResources.subscript());
+ final MenuItemDescriptor subscript = new MenuItemDescriptor(formatMenu, subscriptAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(','), Keyboard.MODIFIER_CTRL), subscriptAction);
+
+ final SuperscriptAction superscriptAction = new SuperscriptAction(i18n.t("Superscript"), NO_TEXT,
+ imgResources.superscript());
+ final MenuItemDescriptor superscript = new MenuItemDescriptor(formatMenu, superscriptAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('.'), Keyboard.MODIFIER_CTRL), superscriptAction);
+
+ final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NO_TEXT, i18n.t("Left Justify"),
+ imgResources.alignleft());
+ final ButtonDescriptor justifyLeft = new ButtonDescriptor(jfyLeftAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('L'), Keyboard.MODIFIER_CTRL), jfyLeftAction);
+
+ final JustifyCentreAction jfyCentreAction = new JustifyCentreAction(NO_TEXT, i18n.t("Centre Justify"),
+ imgResources.centerpara());
+ final ButtonDescriptor justifyCentre = new ButtonDescriptor(jfyCentreAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('E'), Keyboard.MODIFIER_CTRL), jfyCentreAction);
+
+ final JustifyRightAction jfyRightAction = new JustifyRightAction(NO_TEXT, i18n.t("Right Justify"),
+ imgResources.alignright());
+ final ButtonDescriptor justifyRight = new ButtonDescriptor(jfyRightAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('R'), Keyboard.MODIFIER_CTRL), jfyRightAction);
+
+ 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(Character.valueOf('Z'), Keyboard.MODIFIER_CTRL), undoAction);
+
+ 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(Character.valueOf('Y'), Keyboard.MODIFIER_CTRL), redoAction);
+
+ final CopyAction copyAction = new CopyAction(i18n.t("Copy"), NO_TEXT, imgResources.copy());
+ final MenuItemDescriptor copy = new MenuItemDescriptor(editMenu, copyAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('C'), Keyboard.MODIFIER_CTRL), copyAction);
+
+ final CutAction cutAction = new CutAction(i18n.t("Cut"), NO_TEXT, imgResources.cut());
+ final MenuItemDescriptor cut = new MenuItemDescriptor(editMenu, cutAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('X'), Keyboard.MODIFIER_CTRL), cutAction);
+
+ final PasteAction pasteAction = new PasteAction(i18n.t("Paste"), NO_TEXT, imgResources.paste());
+ final MenuItemDescriptor paste = new MenuItemDescriptor(editMenu, pasteAction);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('V'), Keyboard.MODIFIER_CTRL), pasteAction);
+
+ 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"), NO_TEXT, NO_ICON);
+ final MenuItemDescriptor comment = new MenuItemDescriptor(insertMenu, commentAction);
+ comment.setAddCondition(extendedAddCond);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('M'), Keyboard.MODIFIER_CTRL), commentAction);
+
+ 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(Character.valueOf(' '), Keyboard.MODIFIER_CTRL
+ + Keyboard.MODIFIER_SHIFT), hlineAction);
+
+ 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(NO_TEXT, i18n.t("Strikethrough"),
+ imgResources.strikeout());
+ strikethrough = new PushButtonDescriptor(strikeAction);
+ strikethrough.setAddCondition(extendedAddCond);
+
+ 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(NO_TEXT, i18n.t("Increase Indent"),
+ imgResources.incrementindent());
+ final ButtonDescriptor increaseIndent = new ButtonDescriptor(increIndentAction);
+ increaseIndent.setAddCondition(extendedAddCond);
+
+ 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(Character.valueOf('7'), Keyboard.MODIFIER_CTRL), olistAction);
+
+ 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(Character.valueOf('8'), Keyboard.MODIFIER_CTRL), ulistAction);
+
+ 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..."), NO_TEXT,
+ imgResources.film());
+ final MenuItemDescriptor insertMedia = new MenuItemDescriptor(insertMenu, insertMediaAction);
+ insertMedia.setAddCondition(extendedAddCond);
+
+ final CreateOrEditLinkAction editLinkAction = new CreateOrEditLinkAction(i18n.t("Link..."), NO_TEXT,
+ imgResources.link());
+ final CreateOrEditLinkAction editLinkBtnAction = new CreateOrEditLinkAction(NO_TEXT,
+ i18n.t("Create or Edit Link"), imgResources.link());
+ 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);
+ final ButtonDescriptor editLinkBtn = new ButtonDescriptor(editLinkBtnAction);
+ editLink.setAddCondition(extendedAddCond);
+ editLinkBtn.setAddCondition(extendedAddCond);
+ editLinkCtx.setAddCondition(extendedAddCond);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL), editLinkAction,
+ editLinkBtnAction);
+
+ 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"), 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_SK, delLinkBtnAction);
+
+ final RemoveFormatAction remFormatAction = new RemoveFormatAction(i18n.t("Clear Formatting..."), NO_TEXT,
+ imgResources.removeFormat());
+ 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(Character.valueOf(' '), Keyboard.MODIFIER_CTRL), remFormatAction,
+ remFormatBtnAc);
+
+ final InsertSpecialCharAction insCharAction = new InsertSpecialCharAction(i18n.t("Special characters..."),
+ NO_TEXT, imgResources.specialchars());
+ final MenuItemDescriptor insertSpecialChar = new MenuItemDescriptor(insertMenu, insCharAction);
+ insertSpecialChar.setAddCondition(extendedAddCond);
+
+ final InsertTableAction insTableAction = new InsertTableAction(i18n.t("Table..."), NO_TEXT,
+ imgResources.inserttable());
+ 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(NO_TEXT, i18n.t("Text Colour"),
+ imgResources.fontcolor());
+ final ButtonDescriptor fontColor = new ButtonDescriptor(fontColorAction);
+ fontColor.setAddCondition(basicAddCond);
+
+ 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"), NO_TEXT,
+ imgResources.specialchars());
+ final MenuItemDescriptor devInfo = new MenuItemDescriptor(formatMenu, devInfoAction);
+ devInfo.setAddCondition(extendedAddCond);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_ALT), devInfoAction);
+
+ 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, sndbarSepExt, hlineBtn,
+ imgBtn, editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSepExt, subscript, superscript, blockquote,
+ fontColor, backgroundColor, fontSizeMenu, fontMenu, editLinkCtx, removeLinkCtx);
+ // actions.add(devInfo);
+
+ 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, sndbarSepExt, 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[] { removeLinkCtx, editLinkCtx });
+
+ for (final String fontName : FONT_NAMES) {
+ createFontAction(fontMenu, fontName);
+ }
+
+ for (int fontSize = 0; fontSize < FONT_SIZE_NAMES.length; fontSize++) {
+ createFontSizeAction(fontSizeMenu, fontSize);
+ }
+ }
+
+ private void createFontAction(final MenuDescriptor fontMenu, final String fontName) {
+ final FontAction fontAction = new FontAction(fontName, NO_TEXT, NO_ICON);
+ final MenuRadioItemDescriptor font = new MenuRadioItemDescriptor(fontMenu, fontAction, FONT_GROUP);
+ font.setAddCondition(basicAddCond);
+ font.setLocation(SNDBAR);
+ fontActions.put(fontName.toLowerCase(), font);
+ actions.add(font);
+ }
+
+ private void createFontSizeAction(final MenuDescriptor fontSizeMenu, final int fontSize) {
+ final String fontSizeName = i18n.t(FONT_SIZE_NAMES[fontSize]);
+ final FontSizeAction fontSizeAction = new FontSizeAction(fontSizeName, fontSize, NO_TEXT, NO_ICON);
+ final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction,
+ FONT_SIZEGROUP);
+ fontSizeItem.setAddCondition(basicAddCond);
+ // setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char)
+ // (48 + fontSize))), Keyboard.MODIFIER_CTRL),
+ // fontSizeAction);
+ fontSizeItem.setLocation(SNDBAR);
+ actions.add(fontSizeItem);
+ }
+
+ private void createMainMenus() {
+ 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()));
+ insertMenu.setAddCondition(extendedAddCond);
+ }
+
+ private void createPalette() {
+ if (palette == null) {
+ palette = paletteProvider.get();
+ }
+ }
+
+ private void hideLinkCtxMenu() {
+ if (view.isCtxMenuVisible()) {
+ view.hideLinkCtxMenu();
+ }
+ }
+
+ private void hideMenus() {
+ for (final MenuDescriptor menu : menus) {
+ menu.hide();
+ }
+ if (palette != null) {
+ palette.hide();
+ }
+ }
+
+ private boolean isAndCanBeExtended() {
+ return extended && view.canBeExtended();
+ }
+
+ private void updateFont() {
+ final String currentFont = view.getFont();
+ final MenuCheckItemDescriptor item = fontActions.get(currentFont);
+ if (currentFontItem != null && item != currentFontItem) {
+ currentFontItem.setChecked(false);
+ }
+ if (item != null) {
+ item.setChecked(true);
+ currentFontItem = item;
+ fontMenu.setText((String) item.getValue(FontAction.FONT_NAME));
+ } else {
+ fontMenu.setText(" ");
+ }
+ }
+}
Deleted: 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,1196 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
-import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-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.AbstractExtendedAction;
-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.ui.ButtonDescriptor;
-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.MenuCheckItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.MenuRadioItemDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.MenuSeparatorDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.PushButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor;
-import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor.Type;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.shortcuts.Keyboard;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.ImageInfo;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
-import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Event0;
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.client.ioc.Provider;
-import com.google.gwt.libideas.resources.client.ImageResource;
-import com.google.gwt.user.client.Event;
-
-public class RTEditorPresenterNew implements RTEditorNew {
-
- public class BackgroundColorAction extends AbstractExtendedAction {
-
- public BackgroundColorAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- createPalette();
- final Event event = actionEvent.getEvent();
- palette.show(event.getClientX(), event.getClientY(), new Listener<String>() {
- public void onEvent(final String color) {
- palette.hide();
- view.setBackColor(color);
- fireOnEdit();
- }
- });
- }
- }
-
- public class BlockquoteAction extends AbstractExtendedAction {
- public BlockquoteAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.focus();
- view.insertBlockquote();
- fireOnEdit();
- }
- }
-
- public class BoldAction extends AbstractExtendedAction {
- public BoldAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleBold();
- fireOnEdit();
- }
- }
-
- public class CommentAction extends AbstractExtendedAction {
- public CommentAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.focus();
- final String author = session.isLogged() ? session.getCurrentUser().getShortName()
- : i18n.t("anonymous user");
- if (view.isAnythingSelected()) {
- NotifyUser.askConfirmation(i18n.t("Insert a comment"),
- i18n.t("Include the selected text in the comment?"), new Listener0() {
- public void onEvent() {
- // include selection in
- // comment
- view.insertCommentUsingSelection(author);
- }
- }, new Listener0() {
- public void onEvent() {
- // not include selection in
- // comment;
- view.insertCommentNotUsingSelection(author);
- }
- });
- } else {
- // Nothing selected > create comment in
- // insertion point
- view.insertComment(author);
- }
- }
- });
- }
-
- @Override
- public boolean isEnabled() {
- return session.isLogged();
- }
- }
-
- public class CopyAction extends AbstractExtendedAction {
- public CopyAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.copy();
- }
- }
-
- public class CreateOrEditLinkAction extends AbstractExtendedAction {
- public CreateOrEditLinkAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- private InsertLinkDialog insLinkDialog;
-
- public void onEvent() {
- if (insLinkListener == null) {
- insLinkListener = new Listener<LinkInfo>() {
- public void onEvent(final LinkInfo linkInfo) {
- final String link = linkInfo.toString();
- Log.debug("Link: " + link);
- view.focus();
- view.insertHtml(link);
- fireOnEdit();
- }
- };
- }
- final LinkInfo linkInfo = view.getLinkInfoIfHref();
-
- if (insLinkDialog == null) {
- insLinkDialog = insLinkDialogPv.get();
- }
- insLinkDialog.setLinkInfo(linkInfo);
- insLinkDialog.setOnCreateLink(insLinkListener);
- insLinkDialog.show();
- hideLinkCtxMenu();
- final String href = linkInfo.getHref();
- if (href.length() > 0) {
- if (href.startsWith("mailto")) {
- insLinkDialog.activateTab(2);
- } else {
- insLinkDialog.activateTab(1);
- }
- }
- }
- });
- }
- }
-
- public class CutAction extends AbstractExtendedAction {
- public CutAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.cut();
- fireOnEdit();
- }
- }
-
- public class DecreaseIndentAction extends AbstractExtendedAction {
- public DecreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.leftIndent();
- fireOnEdit();
- }
- }
-
- public class DevInfoAction extends AbstractExtendedAction {
- public DevInfoAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.getRangeInfo();
- }
- });
- }
- }
-
- public class EditHtmlAction extends AbstractExtendedAction {
- private EditHtmlDialog editHtmlDialog;
-
- public EditHtmlAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- if (updHtmlListener == null) {
- updHtmlListener = new Listener<String>() {
- public void onEvent(final String html) {
- view.setHTML(html);
- fireOnEdit();
- }
- };
- }
- if (editHtmlDialog == null) {
- editHtmlDialog = editHtmlDialogPv.get();
- }
- editHtmlDialog.setUpdateListener(updHtmlListener);
- editHtmlDialog.show();
- hideLinkCtxMenu();
- editHtmlDialog.setHtml(view.getHTML());
- }
- }
-
- public class FontAction extends AbstractExtendedAction {
- public static final String FONT_NAME = "fontname";
-
- public FontAction(final String fontName, final String tooltip, final ImageResource icon) {
- super("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>", tooltip, icon);
- super.putValue(FONT_NAME, fontName);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- final String fontName = getFontName();
- view.setFontName(fontName);
- fontMenu.setText(fontName);
- fireOnEdit();
- }
-
- private String getFontName() {
- return (String) super.getValue(FONT_NAME);
- }
- }
-
- public class FontColorAction extends AbstractExtendedAction {
- public FontColorAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- createPalette();
- final Event event = actionEvent.getEvent();
- palette.show(event.getClientX(), event.getClientY(), new Listener<String>() {
- public void onEvent(final String color) {
- palette.hide();
- view.setForeColor(color);
- fireOnEdit();
- }
- });
- hideLinkCtxMenu();
- }
- }
-
- public class FontSizeAction extends AbstractExtendedAction {
- private final int fontSize;
-
- public FontSizeAction(final String fontSizeName, final int fontSize, final String tooltip,
- final ImageResource icon) {
- super("<font size=\"" + (fontSize + 1) + "\">" + fontSizeName + "</font>", tooltip, icon);
- this.fontSize = fontSize;
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.setFontSize(FONT_SIZES[fontSize]);
- fireOnEdit();
- // fontSizeMenu.setText(fontSizeName);
- }
- }
-
- public class HrAction extends AbstractExtendedAction {
- public HrAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.focus();
- view.insertHorizontalRule();
- fireOnEdit();
- }
- }
-
- public class ImgAction extends AbstractExtendedAction {
- public ImgAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- private InsertImageDialog insImgDialog;
-
- public void onEvent() {
- if (insImgListener == null) {
- insImgListener = new Listener<ImageInfo>() {
- public void onEvent(final ImageInfo imageInfo) {
- Log.debug("Image: " + imageInfo);
- view.focus();
- view.insertHtml(imageInfo.toString());
- fireOnEdit();
- }
- };
- }
- if (insImgDialog == null) {
- insImgDialog = insImgDialogProv.get();
- }
- insImgDialog.reset();
- insImgDialog.setOnCreateImage(insImgListener);
- insImgDialog.show();
- hideLinkCtxMenu();
- }
- });
- }
- }
-
- public class IncreaseIndentAction extends AbstractExtendedAction {
- public IncreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.rightIndent();
- fireOnEdit();
- }
- }
-
- public class InsertMediaAction extends AbstractExtendedAction {
- public InsertMediaAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- private InsertMediaDialog insMediaDialog;
-
- public void onEvent() {
- if (insMediaListener == null) {
- insMediaListener = new Listener<String>() {
- public void onEvent(final String html) {
- Log.debug("Media: " + html);
- view.focus();
- view.insertHtml(html);
- fireOnEdit();
- }
- };
- }
- if (insMediaDialog == null) {
- insMediaDialog = insMediaDialogPv.get();
- }
- insMediaDialog.setOnCreate(insMediaListener);
- insMediaDialog.show();
- hideLinkCtxMenu();
- }
- });
- }
- }
-
- public class InsertSpecialCharAction extends AbstractExtendedAction {
- private InsertSpecialCharDialog insCharDialog;
-
- public InsertSpecialCharAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- NotifyUser.showProgressLoading();
- if (insCharListener == null) {
- insCharListener = new Listener<String>() {
- public void onEvent(final String character) {
- view.insertHtml(character);
- }
- };
- }
- if (insCharDialog == null) {
- insCharDialog = insCharDialogProv.get();
- }
- insCharDialog.setOnInsertSpecialChar(insCharListener);
- insCharDialog.show();
- hideLinkCtxMenu();
- NotifyUser.hideProgress();
- }
- }
-
- public class InsertTableAction extends AbstractExtendedAction {
- private InsertTableDialog insTableDialog;
-
- public InsertTableAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- if (insTableListener == null) {
- insTableListener = new Listener<String>() {
- public void onEvent(final String table) {
- view.insertHtml(table);
- fireOnEdit();
- }
- };
- }
- if (insTableDialog == null) {
- insTableDialog = insTableDialogPv.get();
- }
- insTableDialog.setOnInsertTable(insTableListener);
- insTableDialog.show();
- }
- }
-
- public class ItalicAction extends AbstractExtendedAction {
- public ItalicAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleItalic();
- fireOnEdit();
- }
- }
-
- public class JustifyCentreAction extends AbstractExtendedAction {
- public JustifyCentreAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.justifyCenter();
- fireOnEdit();
- }
- }
-
- public class JustifyLeftAction extends AbstractExtendedAction {
- public JustifyLeftAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.justifyLeft();
- fireOnEdit();
- }
- }
-
- public class JustifyRightAction extends AbstractExtendedAction {
- public JustifyRightAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.justifyRight();
- fireOnEdit();
- }
- }
-
- public class OlAction extends AbstractExtendedAction {
- public OlAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.insertOrderedList();
- fireOnEdit();
- }
- }
-
- public class PasteAction extends AbstractExtendedAction {
- public PasteAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.paste();
- fireOnEdit();
- }
- }
-
- public class RedoAction extends AbstractExtendedAction {
- public RedoAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.redo();
- fireOnEdit();
- }
- }
-
- public class RemoveFormatAction extends AbstractExtendedAction {
- public RemoveFormatAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.removeFormat();
- fireOnEdit();
- }
- }
-
- public class RemoveLinkAction extends AbstractExtendedAction {
- public RemoveLinkAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.unlink();
- hideLinkCtxMenu();
- fireOnEdit();
- }
- });
- }
- }
-
- public class SelectAllAction extends AbstractExtendedAction {
- public SelectAllAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.selectAll();
- }
- }
-
- public class StrikethroughAction extends AbstractExtendedAction {
- public StrikethroughAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleStrikethrough();
- fireOnEdit();
- }
- }
-
- public class SubscriptAction extends AbstractExtendedAction {
- public SubscriptAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleSubscript();
- fireOnEdit();
- }
- }
-
- public class SuperscriptAction extends AbstractExtendedAction {
- public SuperscriptAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleSuperscript();
- fireOnEdit();
- }
- }
-
- public class UlAction extends AbstractExtendedAction {
- public UlAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.insertUnorderedList();
- fireOnEdit();
- }
- }
-
- public class UnderlineAction extends AbstractExtendedAction {
- public UnderlineAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.toggleUnderline();
- fireOnEdit();
- }
- }
-
- public class UndoAction extends AbstractExtendedAction {
- public UndoAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
-
- public void actionPerformed(final ActionEvent actionEvent) {
- view.undo();
- fireOnEdit();
- }
- }
-
- private static final String FONT_NAMES[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet",
- "Verdana" };
- private static final String FONT_SIZE_NAMES[] = { "Extra small", "Very small (normal)", "Small", "Medium", "Large",
- "Very large", "Extra large" };
- private static final RichTextArea.FontSize[] FONT_SIZES = new RichTextArea.FontSize[] {
- RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
- RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
- RichTextArea.FontSize.XX_LARGE };
- private static final String FONT_GROUP = "fontgroup";
- private static final String FONT_SIZEGROUP = "fontsizegroup";
-
- private RTEditorViewNew view;
- private boolean extended;
- private final I18nTranslationService i18n;
- private final Session session;
- private final RTEImgResources imgResources;
- private final Event0 onEdit;
- private final DeferredCommandWrapper deferred;
- private final Provider<ColorWebSafePalette> paletteProvider;
- private final Provider<InsertLinkDialog> insLinkDialogPv;
- private final Provider<EditHtmlDialog> editHtmlDialogPv;
- private final Provider<InsertImageDialog> insImgDialogProv;
- private final Provider<InsertTableDialog> insTableDialogPv;
- private final Provider<InsertSpecialCharDialog> insCharDialogProv;
- private final Provider<InsertMediaDialog> insMediaDialogPv;
- private Listener<String> insTableListener;
- private Listener<LinkInfo> insLinkListener;
- private Listener<ImageInfo> insImgListener;
- private Listener<String> insMediaListener;
- private Listener<String> updHtmlListener;
- protected Listener<String> insCharListener;
- protected ColorWebSafePalette palette;
- private PushButtonDescriptor bold;
- private PushButtonDescriptor italic;
- private PushButtonDescriptor underline;
- private PushButtonDescriptor strikethrough;
- private final GuiAddCondition basicAddCond;
- private final GuiAddCondition extendedAddCond;
- private final InputMap inputMap;
- private MenuDescriptor editMenu;
- private MenuDescriptor insertMenu;
- private MenuDescriptor formatMenu;
- private MenuDescriptor linkCtxMenu;
- private GuiActionDescCollection actions;
- private MenuDescriptor fontMenu;
- private MenuDescriptor fontSizeMenu;
- private MenuDescriptor fileMenu;
- private final List<MenuDescriptor> menus;
- private boolean attached;
- private final Map<String, MenuCheckItemDescriptor> fontActions;
- private MenuCheckItemDescriptor currentFontItem;
-
- public RTEditorPresenterNew(final I18nTranslationService i18n, final Session session,
- 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.insLinkDialogPv = insLinkDialog;
- this.paletteProvider = palette;
- this.editHtmlDialogPv = editHtmlDialog;
- this.insImgDialogProv = insertImageDialog;
- this.insMediaDialogPv = insertMediaDialog;
- this.insTableDialogPv = insertTableDialog;
- this.insCharDialogProv = insCharDialog;
- this.deferred = deferred;
- inputMap = new InputMap();
- menus = new ArrayList<MenuDescriptor>();
-
- this.imgResources = imgResources;
- this.onEdit = new Event0("onRTEEdit");
- extendedAddCond = new GuiAddCondition() {
- public boolean mustBeAdded() {
- return isAndCanBeExtended();
- }
- };
- basicAddCond = new GuiAddCondition() {
- public boolean mustBeAdded() {
- return view.canBeBasic();
- }
- };
- attached = false;
- fontActions = new HashMap<String, MenuCheckItemDescriptor>();
- }
-
- public void addAction(final GuiActionDescrip descriptor) {
- actions.add(descriptor);
- checkForMenus(descriptor);
- }
-
- public void addActions(final GuiActionDescCollection descriptors) {
- actions.addAll(descriptors);
- for (final GuiActionDescrip descriptor : descriptors) {
- checkForMenus(descriptor);
- }
- }
-
- public void addOnEditListener(final Listener0 listener) {
- onEdit.add(listener);
- }
-
- public void adjustSize(final int height) {
- view.adjustSize(height);
- }
-
- public void attach() {
- if (!attached) {
- attached = true;
- view.addActions(actions);
- view.setInputMap(inputMap);
- }
- }
-
- public void detach() {
- // topBar.clear();
- // sndBar.clear();
- }
-
- public void fireOnEdit() {
- onEdit.fire();
- }
-
- public GuiAddCondition getBasicAddCondition() {
- return basicAddCond;
- }
-
- public MenuDescriptor getEditMenu() {
- return editMenu;
- }
-
- public View getEditorArea() {
- return view;
- }
-
- public GuiAddCondition getExtendedAddCondition() {
- return extendedAddCond;
- }
-
- public MenuDescriptor getFileMenu() {
- return fileMenu;
- }
-
- public MenuDescriptor getFormatMenu() {
- return formatMenu;
- }
-
- public String getHtml() {
- return view.getHTML();
- }
-
- public MenuDescriptor getInsertMenu() {
- return insertMenu;
- }
-
- public MenuDescriptor getLinkCtxMenu() {
- return linkCtxMenu;
- }
-
- public View getSndBar() {
- return view.getSndBar();
- }
-
- public String getText() {
- return view.getText();
- }
-
- public View getTopBar() {
- return view.getTopBar();
- }
-
- public void init(final RTEditorViewNew view) {
- this.view = view;
- createMainMenus();
- createBasicActions();
- }
-
- public void onEditorFocus() {
- hideMenus();
- }
-
- public void onLostFocus() {
- // Nothing for the moment
- }
-
- public void reset() {
- hideMenus();
- 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 newValue) {
- this.extended = newValue;
- }
-
- public void setFocus(final boolean focus) {
- view.setFocus(focus);
- }
-
- public void setHtml(final String html) {
- view.setHTML(html);
- view.focus();
- }
-
- public void setText(final String text) {
- view.setText(text);
- view.focus();
- }
-
- public void updateLinkInfo() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- if (isAndCanBeExtended() && view.isLink()) {
- view.showLinkCtxMenu();
- } else {
- hideLinkCtxMenu();
- }
- }
- });
- }
-
- public void updateStatus() {
- if (view.canBeBasic()) {
- bold.setPushed(view.isBold());
- italic.setPushed(view.isItalic());
- underline.setPushed(view.isUnderlined());
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- updateFont();
- // Log.warn(view.getFontSize());
- }
- });
- }
- if (isAndCanBeExtended()) {
- strikethrough.setPushed(view.isStrikethrough());
- }
- }
-
- private void checkForMenus(final GuiActionDescrip descriptor) {
- if (descriptor instanceof MenuDescriptor) {
- menus.add((MenuDescriptor) descriptor);
- }
- }
-
- private void createBasicActions() {
-
- final MenuSeparatorDescriptor editMenuSep = new MenuSeparatorDescriptor(editMenu);
- final MenuSeparatorDescriptor insertMenuSep = new MenuSeparatorDescriptor(insertMenu);
- final MenuSeparatorDescriptor formatMenuSep = new MenuSeparatorDescriptor(formatMenu);
- insertMenuSep.setAddCondition(extendedAddCond);
-
- final ToolbarSeparatorDescriptor sndbarSep = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
- final ToolbarSeparatorDescriptor sndbarSepExt = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
- sndbarSepExt.setAddCondition(extendedAddCond);
-
- final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractExtendedAction.NO_TEXT,
- imgResources.selectall());
- final MenuItemDescriptor select = new MenuItemDescriptor(editMenu, selectAllAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('A'), Keyboard.MODIFIER_CTRL), selectAllAction);
-
- final BoldAction boldAction = new BoldAction(NO_TEXT, i18n.t("Bold"), imgResources.bold());
- bold = new PushButtonDescriptor(boldAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_CTRL), boldAction);
-
- final ItalicAction italicAction = new ItalicAction(NO_TEXT, i18n.t("Italic"), imgResources.italic());
- italic = new PushButtonDescriptor(italicAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_CTRL), italicAction);
-
- final UnderlineAction underlineAction = new UnderlineAction(NO_TEXT, i18n.t("Underline"),
- imgResources.underline());
- underline = new PushButtonDescriptor(underlineAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('U'), Keyboard.MODIFIER_CTRL), underlineAction);
-
- final SubscriptAction subscriptAction = new SubscriptAction(i18n.t("Subscript"), NO_TEXT,
- imgResources.subscript());
- final MenuItemDescriptor subscript = new MenuItemDescriptor(formatMenu, subscriptAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(','), Keyboard.MODIFIER_CTRL), subscriptAction);
-
- final SuperscriptAction superscriptAction = new SuperscriptAction(i18n.t("Superscript"), NO_TEXT,
- imgResources.superscript());
- final MenuItemDescriptor superscript = new MenuItemDescriptor(formatMenu, superscriptAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('.'), Keyboard.MODIFIER_CTRL), superscriptAction);
-
- final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NO_TEXT, i18n.t("Left Justify"),
- imgResources.alignleft());
- final ButtonDescriptor justifyLeft = new ButtonDescriptor(jfyLeftAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('L'), Keyboard.MODIFIER_CTRL), jfyLeftAction);
-
- final JustifyCentreAction jfyCentreAction = new JustifyCentreAction(NO_TEXT, i18n.t("Centre Justify"),
- imgResources.centerpara());
- final ButtonDescriptor justifyCentre = new ButtonDescriptor(jfyCentreAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('E'), Keyboard.MODIFIER_CTRL), jfyCentreAction);
-
- final JustifyRightAction jfyRightAction = new JustifyRightAction(NO_TEXT, i18n.t("Right Justify"),
- imgResources.alignright());
- final ButtonDescriptor justifyRight = new ButtonDescriptor(jfyRightAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('R'), Keyboard.MODIFIER_CTRL), jfyRightAction);
-
- 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(Character.valueOf('Z'), Keyboard.MODIFIER_CTRL), undoAction);
-
- 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(Character.valueOf('Y'), Keyboard.MODIFIER_CTRL), redoAction);
-
- final CopyAction copyAction = new CopyAction(i18n.t("Copy"), NO_TEXT, imgResources.copy());
- final MenuItemDescriptor copy = new MenuItemDescriptor(editMenu, copyAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('C'), Keyboard.MODIFIER_CTRL), copyAction);
-
- final CutAction cutAction = new CutAction(i18n.t("Cut"), NO_TEXT, imgResources.cut());
- final MenuItemDescriptor cut = new MenuItemDescriptor(editMenu, cutAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('X'), Keyboard.MODIFIER_CTRL), cutAction);
-
- final PasteAction pasteAction = new PasteAction(i18n.t("Paste"), NO_TEXT, imgResources.paste());
- final MenuItemDescriptor paste = new MenuItemDescriptor(editMenu, pasteAction);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('V'), Keyboard.MODIFIER_CTRL), pasteAction);
-
- 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"), NO_TEXT, NO_ICON);
- final MenuItemDescriptor comment = new MenuItemDescriptor(insertMenu, commentAction);
- comment.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('M'), Keyboard.MODIFIER_CTRL), commentAction);
-
- 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(Character.valueOf(' '), Keyboard.MODIFIER_CTRL
- + Keyboard.MODIFIER_SHIFT), hlineAction);
-
- 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(NO_TEXT, i18n.t("Strikethrough"),
- imgResources.strikeout());
- strikethrough = new PushButtonDescriptor(strikeAction);
- strikethrough.setAddCondition(extendedAddCond);
-
- 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(NO_TEXT, i18n.t("Increase Indent"),
- imgResources.incrementindent());
- final ButtonDescriptor increaseIndent = new ButtonDescriptor(increIndentAction);
- increaseIndent.setAddCondition(extendedAddCond);
-
- 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(Character.valueOf('7'), Keyboard.MODIFIER_CTRL), olistAction);
-
- 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(Character.valueOf('8'), Keyboard.MODIFIER_CTRL), ulistAction);
-
- 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..."), NO_TEXT,
- imgResources.film());
- final MenuItemDescriptor insertMedia = new MenuItemDescriptor(insertMenu, insertMediaAction);
- insertMedia.setAddCondition(extendedAddCond);
-
- final CreateOrEditLinkAction editLinkAction = new CreateOrEditLinkAction(i18n.t("Link..."), NO_TEXT,
- imgResources.link());
- final CreateOrEditLinkAction editLinkBtnAction = new CreateOrEditLinkAction(NO_TEXT,
- i18n.t("Create or Edit Link"), imgResources.link());
- 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);
- final ButtonDescriptor editLinkBtn = new ButtonDescriptor(editLinkBtnAction);
- editLink.setAddCondition(extendedAddCond);
- editLinkBtn.setAddCondition(extendedAddCond);
- editLinkCtx.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('K'), Keyboard.MODIFIER_CTRL), editLinkAction,
- editLinkBtnAction);
-
- 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"), 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_SK, delLinkBtnAction);
-
- final RemoveFormatAction remFormatAction = new RemoveFormatAction(i18n.t("Clear Formatting..."), NO_TEXT,
- imgResources.removeFormat());
- 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(Character.valueOf(' '), Keyboard.MODIFIER_CTRL), remFormatAction,
- remFormatBtnAc);
-
- final InsertSpecialCharAction insCharAction = new InsertSpecialCharAction(i18n.t("Special characters..."),
- NO_TEXT, imgResources.specialchars());
- final MenuItemDescriptor insertSpecialChar = new MenuItemDescriptor(insertMenu, insCharAction);
- insertSpecialChar.setAddCondition(extendedAddCond);
-
- final InsertTableAction insTableAction = new InsertTableAction(i18n.t("Table..."), NO_TEXT,
- imgResources.inserttable());
- 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(NO_TEXT, i18n.t("Text Colour"),
- imgResources.fontcolor());
- final ButtonDescriptor fontColor = new ButtonDescriptor(fontColorAction);
- fontColor.setAddCondition(basicAddCond);
-
- 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"), NO_TEXT,
- imgResources.specialchars());
- final MenuItemDescriptor devInfo = new MenuItemDescriptor(formatMenu, devInfoAction);
- devInfo.setAddCondition(extendedAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('I'), Keyboard.MODIFIER_ALT), devInfoAction);
-
- 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, sndbarSepExt, hlineBtn,
- imgBtn, editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSepExt, subscript, superscript, blockquote,
- fontColor, backgroundColor, fontSizeMenu, fontMenu, editLinkCtx, removeLinkCtx);
- // actions.add(devInfo);
-
- 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, sndbarSepExt, 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[] { removeLinkCtx, editLinkCtx });
-
- for (final String fontName : FONT_NAMES) {
- createFontAction(fontMenu, fontName);
- }
-
- for (int fontSize = 0; fontSize < FONT_SIZE_NAMES.length; fontSize++) {
- createFontSizeAction(fontSizeMenu, fontSize);
- }
- }
-
- private void createFontAction(final MenuDescriptor fontMenu, final String fontName) {
- final FontAction fontAction = new FontAction(fontName, NO_TEXT, NO_ICON);
- final MenuRadioItemDescriptor font = new MenuRadioItemDescriptor(fontMenu, fontAction, FONT_GROUP);
- font.setAddCondition(basicAddCond);
- font.setLocation(SNDBAR);
- fontActions.put(fontName.toLowerCase(), font);
- actions.add(font);
- }
-
- private void createFontSizeAction(final MenuDescriptor fontSizeMenu, final int fontSize) {
- final String fontSizeName = i18n.t(FONT_SIZE_NAMES[fontSize]);
- final FontSizeAction fontSizeAction = new FontSizeAction(fontSizeName, fontSize, NO_TEXT, NO_ICON);
- final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction,
- FONT_SIZEGROUP);
- fontSizeItem.setAddCondition(basicAddCond);
- // setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char)
- // (48 + fontSize))), Keyboard.MODIFIER_CTRL),
- // fontSizeAction);
- fontSizeItem.setLocation(SNDBAR);
- actions.add(fontSizeItem);
- }
-
- private void createMainMenus() {
- 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()));
- insertMenu.setAddCondition(extendedAddCond);
- }
-
- private void createPalette() {
- if (palette == null) {
- palette = paletteProvider.get();
- }
- }
-
- private void hideLinkCtxMenu() {
- if (view.isCtxMenuVisible()) {
- view.hideLinkCtxMenu();
- }
- }
-
- private void hideMenus() {
- for (final MenuDescriptor menu : menus) {
- menu.hide();
- }
- if (palette != null) {
- palette.hide();
- }
- }
-
- private boolean isAndCanBeExtended() {
- return extended && view.canBeExtended();
- }
-
- private void setLocation(final String location, final GuiActionDescrip[] descripts) {
- for (final GuiActionDescrip descript : descripts) {
- descript.setLocation(location);
- }
- }
-
- private void updateFont() {
- final String currentFont = view.getFont();
- final MenuCheckItemDescriptor item = fontActions.get(currentFont);
- if (currentFontItem != null && item != currentFontItem) {
- currentFontItem.setChecked(false);
- }
- if (item != null) {
- item.setChecked(true);
- currentFontItem = item;
- fontMenu.setText((String) item.getValue(FontAction.FONT_NAME));
- } else {
- fontMenu.setText(" ");
- }
- }
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java (from rev 1124, 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,140 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.View;
+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 RTEditorView extends View {
+
+ void addActions(GuiActionDescCollection actions);
+
+ void adjustSize(int height);
+
+ boolean canBeBasic();
+
+ boolean canBeExtended();
+
+ void copy();
+
+ void createLink(String url);
+
+ void cut();
+
+ void delete();
+
+ void focus();
+
+ String getFont();
+
+ String getFontSize();
+
+ String getHTML();
+
+ LinkInfo getLinkInfoIfHref();
+
+ void getRangeInfo();
+
+ String getSelectionText();
+
+ View getSndBar();
+
+ String getText();
+
+ View getTopBar();
+
+ void hideLinkCtxMenu();
+
+ void insertBlockquote();
+
+ void insertComment(String author);
+
+ void insertCommentNotUsingSelection(String author);
+
+ void insertCommentUsingSelection(String author);
+
+ void insertHorizontalRule();
+
+ void insertHtml(String html);
+
+ void insertImage(String url);
+
+ void insertOrderedList();
+
+ void insertUnorderedList();
+
+ boolean isAnythingSelected();
+
+ boolean isAttached();
+
+ boolean isBold();
+
+ boolean isCtxMenuVisible();
+
+ boolean isItalic();
+
+ boolean isLink();
+
+ boolean isStrikethrough();
+
+ boolean isSubscript();
+
+ boolean isSuperscript();
+
+ boolean isUnderlined();
+
+ void justifyCenter();
+
+ void justifyLeft();
+
+ void justifyRight();
+
+ void leftIndent();
+
+ void paste();
+
+ void redo();
+
+ void removeFormat();
+
+ void rightIndent();
+
+ void selectAll();
+
+ void selectLink();
+
+ void setBackColor(String color);
+
+ void setFocus(boolean focus);
+
+ void setFontName(String name);
+
+ void setFontSize(FontSize fontSize);
+
+ void setForeColor(String color);
+
+ void setHTML(String html);
+
+ void setInputMap(InputMap inputMap);
+
+ void setText(String text);
+
+ void showLinkCtxMenu();
+
+ void toggleBold();
+
+ void toggleItalic();
+
+ void toggleStrikethrough();
+
+ void toggleSubscript();
+
+ void toggleSuperscript();
+
+ void toggleUnderline();
+
+ void undo();
+
+ void unlink();
+}
Deleted: 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,140 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.View;
-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(GuiActionDescCollection actions);
-
- void adjustSize(int height);
-
- boolean canBeBasic();
-
- boolean canBeExtended();
-
- void copy();
-
- void createLink(String url);
-
- void cut();
-
- void delete();
-
- void focus();
-
- String getFont();
-
- String getFontSize();
-
- String getHTML();
-
- LinkInfo getLinkInfoIfHref();
-
- void getRangeInfo();
-
- String getSelectionText();
-
- View getSndBar();
-
- String getText();
-
- View getTopBar();
-
- void hideLinkCtxMenu();
-
- void insertBlockquote();
-
- void insertComment(String author);
-
- void insertCommentNotUsingSelection(String author);
-
- void insertCommentUsingSelection(String author);
-
- void insertHorizontalRule();
-
- void insertHtml(String html);
-
- void insertImage(String url);
-
- void insertOrderedList();
-
- void insertUnorderedList();
-
- boolean isAnythingSelected();
-
- boolean isAttached();
-
- boolean isBold();
-
- boolean isCtxMenuVisible();
-
- boolean isItalic();
-
- boolean isLink();
-
- boolean isStrikethrough();
-
- boolean isSubscript();
-
- boolean isSuperscript();
-
- boolean isUnderlined();
-
- void justifyCenter();
-
- void justifyLeft();
-
- void justifyRight();
-
- void leftIndent();
-
- void paste();
-
- void redo();
-
- void removeFormat();
-
- void rightIndent();
-
- void selectAll();
-
- void selectLink();
-
- void setBackColor(String color);
-
- void setFocus(boolean focus);
-
- void setFontName(String name);
-
- void setFontSize(FontSize fontSize);
-
- void setForeColor(String color);
-
- void setHTML(String html);
-
- void setInputMap(InputMap inputMap);
-
- void setText(String text);
-
- void showLinkCtxMenu();
-
- void toggleBold();
-
- void toggleItalic();
-
- void toggleStrikethrough();
-
- void toggleSubscript();
-
- void toggleSuperscript();
-
- void toggleUnderline();
-
- void undo();
-
- void unlink();
-}
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,12 +1,12 @@
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.RTEditorNew;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
-public interface RTESavingEditor {
+public interface RTESavingEditor extends RTEditor {
/**
* Start to edit some html code
@@ -20,8 +20,6 @@
*/
void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
- RTEditorNew getBasicEditor();
-
/**
* This is used for listen to changes that affect the edition as url
* changes, window close, to save/cancel or stop these actions
@@ -30,6 +28,11 @@
*/
BeforeActionListener getBeforeSavingListener();
+ /**
+ * Checks if is save is pending.
+ *
+ * @return true, if is save pending
+ */
boolean isSavePending();
/**
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,13 +1,23 @@
package org.ourproject.kune.platf.client.ui.rte.saving;
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenter;
import com.calclab.suco.client.events.Listener0;
-public class RTESavingEditorPanel implements RTESavingEditorView {
+public class RTESavingEditorPanel extends RTEditorPanel implements RTESavingEditorView {
- public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
- Listener0 onCancel) {
+ public RTESavingEditorPanel(final RTEditorPresenter presenter, final I18nUITranslationService i18n,
+ final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
+ super(presenter, i18n, globalShortcutReg, bindReg);
+ }
+
+ public void askConfirmation(final String confirmationTitle, final String confirmationText,
+ final Listener0 onConfirm, final Listener0 onCancel) {
NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
}
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -12,17 +12,27 @@
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.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
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.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
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.calclab.suco.client.ioc.Provider;
import com.google.gwt.libideas.resources.client.ImageResource;
-public class RTESavingEditorPresenter implements RTESavingEditor {
+public class RTESavingEditorPresenter extends RTEditorPresenter implements RTESavingEditor {
public class AutoSaveAction extends AbstractExtendedAction {
public AutoSaveAction(final String text, final String tooltip, final ImageResource icon) {
@@ -76,7 +86,6 @@
public static final int AUTOSAVE_AFTER_FAIL_MILLS = 20000;
public static final int AUTOSAVE_IN_MILLIS = 10000;
- private final RTEditorNew editor;
private boolean autoSave;
private boolean savePending;
private boolean saveCloseConfirmed;
@@ -93,18 +102,21 @@
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;
+ public RTESavingEditorPresenter(final I18nTranslationService i18n, final Session session,
+ 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 boolean autoSave,
+ final StateManager stateManager, final TimerWrapper timer) {
+ super(i18n, session, imgResources, insLinkDialog, palette, editHtmlDialog, insertImageDialog, insertMediaDialog, insertTableDialog, insCharDialog, deferred);
this.autoSave = autoSave;
this.i18n = i18n;
this.stateManager = stateManager;
- this.deferred = deferredCommandWrapper;
+ this.deferred = deferred;
this.imgResources = imgResources;
this.savePending = false;
this.saveCloseConfirmed = false;
- createActions();
this.timer = timer;
timer.configure(new Listener0() {;
@@ -113,7 +125,7 @@
}
});
- editor.addOnEditListener(new Listener0() {
+ super.addOnEditListener(new Listener0() {
public void onEvent() {
onEdit();
}
@@ -128,22 +140,20 @@
public void edit(final String html, final Listener<String> onSave, final Listener0 onEditCancelled) {
this.onSave = onSave;
this.onEditCancelled = onEditCancelled;
- editor.setHtml(html);
- editor.attach();
+ super.setHtml(html);
+ super.attach();
stateManager.addBeforeStateChangeListener(beforeStateChg);
enableSaveBtn(false);
}
- public RTEditorNew getBasicEditor() {
- return editor;
- }
-
public BeforeActionListener getBeforeSavingListener() {
return beforeStateChg;
}
public void init(final RTESavingEditorView view) {
+ super.init(view);
this.view = view;
+ createActions();
}
public boolean isSavePending() {
@@ -169,6 +179,15 @@
}
}
+ @Override
+ public void reset() {
+ timer.cancel();
+ savePending = false;
+ saveCloseConfirmed = false;
+ enableSaveBtn(false);
+ super.reset();
+ }
+
protected void onAutoSave() {
onDoSave();
}
@@ -216,39 +235,39 @@
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);
+ saveBtn.setLocation(RTEditor.SNDBAR);
saveMenuAction = new SaveAction(i18n.t("Save"),NO_TEXT, imgResources.save());
- final MenuItemDescriptor saveMenu = new MenuItemDescriptor(editor.getFileMenu(), saveMenuAction);
+ final MenuItemDescriptor saveMenu = new MenuItemDescriptor(super.getFileMenu(), saveMenuAction);
saveMenu.setPosition(0);
- saveMenu.setLocation(RTEditorNew.TOPBAR);
+ saveMenu.setLocation(RTEditor.TOPBAR);
- editor.setActionShortcut(key_S, saveAction, saveMenuAction);
+ super.setActionShortcut(key_S, saveAction, saveMenuAction);
final AutoSaveAction autoSaveAction = new AutoSaveAction(i18n.t("Autosave"), NO_TEXT, NO_ICON);
- final MenuCheckItemDescriptor autoSaveItem = new MenuCheckItemDescriptor(editor.getFileMenu(), autoSaveAction) { @Override
+ final MenuCheckItemDescriptor autoSaveItem = new MenuCheckItemDescriptor(super.getFileMenu(), autoSaveAction) { @Override
public boolean isChecked() {
//autoSaveItem.setChecked(autoSave);
return autoSave;
}};
- autoSaveItem.setLocation(RTEditorNew.TOPBAR);
+ autoSaveItem.setLocation(RTEditor.TOPBAR);
final CloseAction closeAction = new CloseAction(i18n.t("Close"), NO_TEXT, NO_ICON);
- final MenuItemDescriptor closeItem = new MenuItemDescriptor(editor.getFileMenu(), closeAction);
- closeItem.setLocation(RTEditorNew.TOPBAR);
+ final MenuItemDescriptor closeItem = new MenuItemDescriptor(super.getFileMenu(), closeAction);
+ closeItem.setLocation(RTEditor.TOPBAR);
final SaveCloseAction saveCloseAction = new SaveCloseAction(i18n.t("Save & Close"), NO_TEXT, NO_ICON);
- final MenuItemDescriptor saveClose = new MenuItemDescriptor(editor.getFileMenu(), saveCloseAction);
+ final MenuItemDescriptor saveClose = new MenuItemDescriptor(super.getFileMenu(), saveCloseAction);
final ButtonDescriptor saveCloseBtn = new ButtonDescriptor(saveCloseAction);
- saveClose.setLocation(RTEditorNew.TOPBAR);
- saveCloseBtn.setLocation(RTEditorNew.TOPBAR);
+ saveClose.setLocation(RTEditor.TOPBAR);
+ saveCloseBtn.setLocation(RTEditor.TOPBAR);
- editor.addAction(saveMenu);
- editor.addAction(saveBtn);
- editor.addAction(autoSaveItem);
- editor.addAction(saveClose);
- editor.addAction(saveCloseBtn);
- editor.addAction(closeItem);
+ super.addAction(saveMenu);
+ super.addAction(saveBtn);
+ super.addAction(autoSaveItem);
+ super.addAction(saveClose);
+ super.addAction(saveCloseBtn);
+ super.addAction(closeItem);
}
private void enableSaveBtn(final boolean enabled) {
@@ -260,7 +279,7 @@
stateManager.removeBeforeStateChangeListener(beforeStateChg);
stateManager.resumeTokenChange();
reset();
- editor.detach();
+ super.detach();
onDoEditCancelled();
}
@@ -294,15 +313,6 @@
}
private void onDoSaveImpl() {
- final String html = editor.getHtml();
- onSave.onEvent(html);
+ onSave.onEvent(super.getHtml());
}
-
- private void reset() {
- timer.cancel();
- savePending = false;
- saveCloseConfirmed = false;
- enableSaveBtn(false);
- editor.reset();
- }
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,10 +1,10 @@
package org.ourproject.kune.platf.client.ui.rte.saving;
-import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorView;
import com.calclab.suco.client.events.Listener0;
-public interface RTESavingEditorView extends View {
+public interface RTESavingEditorView extends RTEditorView {
void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
}
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -70,8 +70,8 @@
final String[] containersNoRoot = { TYPE_FOLDER };
final String[] contents = { TYPE_WIKIPAGE, TYPE_UPLOADEDFILE };
- String parentMenuTitle = i18n.t("Wikipage");
- String parentMenuTitleCtx = i18n.t("Wiki");
+ final String parentMenuTitle = i18n.t("Wikipage");
+ final String parentMenuTitleCtx = i18n.t("Wiki");
createNewContainerAction(TYPE_FOLDER, "images/nav/folder_add.png", i18n.t("New folder"), parentMenuTitleCtx,
i18n.t("New"), i18n.t("New folder"), Position.ctx, TYPE_ROOT, TYPE_FOLDER);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -207,7 +207,7 @@
}
protected void createDownloadActions(final String typeUploadedfile) {
- ActionToolbarButtonDescriptor<StateToken> download = new ActionToolbarButtonDescriptor<StateToken>(
+ final ActionToolbarButtonDescriptor<StateToken> download = new ActionToolbarButtonDescriptor<StateToken>(
AccessRolDTO.Viewer, CONTENT_TOPBAR, new Listener<StateToken>() {
public void onEvent(final StateToken token) {
downloadContent(token);
@@ -218,7 +218,7 @@
download.setToolTip(i18n.t("Download this file"));
download.setIconUrl("images/nav/download.png");
- ActionMenuItemDescriptor<StateToken> downloadCtx = new ActionMenuItemDescriptor<StateToken>(
+ final ActionMenuItemDescriptor<StateToken> downloadCtx = new ActionMenuItemDescriptor<StateToken>(
AccessRolDTO.Viewer, new Listener<StateToken>() {
public void onEvent(final StateToken token) {
downloadContent(token);
@@ -234,7 +234,7 @@
protected ActionToolbarButtonDescriptor<StateToken> createEditAction(final String fileMenuTitle,
final String... registerInTypes) {
- ActionToolbarButtonDescriptor<StateToken> editContent = new ActionToolbarButtonDescriptor<StateToken>(
+ final ActionToolbarButtonDescriptor<StateToken> editContent = new ActionToolbarButtonDescriptor<StateToken>(
AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() {
public void onEvent(final StateToken stateToken) {
NotifyUser.showProgressProcessing();
@@ -298,7 +298,7 @@
}
protected ActionMenuItemDescriptor<StateToken> createGoAction(final String... registerInTypes) {
- ActionMenuItemDescriptor<StateToken> go = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer,
+ final ActionMenuItemDescriptor<StateToken> go = new ActionMenuItemDescriptor<StateToken>(AccessRolDTO.Viewer,
new Listener<StateToken>() {
public void onEvent(final StateToken token) {
stateManager.gotoToken(token);
@@ -312,7 +312,7 @@
}
protected ActionToolbarButtonDescriptor<StateToken> createGoHomeAction(final String... registerInTypes) {
- ActionToolbarButtonDescriptor<StateToken> goGroupHome = new ActionToolbarButtonDescriptor<StateToken>(
+ final ActionToolbarButtonDescriptor<StateToken> goGroupHome = new ActionToolbarButtonDescriptor<StateToken>(
AccessRolDTO.Viewer, CONTEXT_TOPBAR, new Listener<StateToken>() {
public void onEvent(final StateToken token) {
stateManager.gotoToken(token.getGroup());
@@ -465,7 +465,7 @@
}, "ContentRadioStatus", new RadioMustBeChecked() {
public boolean mustBeChecked() {
if (session.getContainerState() instanceof StateContentDTO) {
- ContentStatusDTO currentStatus = session.getContentState().getStatus();
+ final ContentStatusDTO currentStatus = session.getContentState().getStatus();
return status.equals(currentStatus);
}
return false;
@@ -478,10 +478,10 @@
}
protected void createShowDeletedItems(final String parentMenuTitle, final String... registerInTypes) {
- ActionToolbarMenuCheckItemDescriptor<StateToken> showDeletedItems = new ActionToolbarMenuCheckItemDescriptor<StateToken>(
+ final ActionToolbarMenuCheckItemDescriptor<StateToken> showDeletedItems = new ActionToolbarMenuCheckItemDescriptor<StateToken>(
AccessRolDTO.Editor, CONTEXT_TOPBAR, new Listener0() {
public void onEvent() {
- boolean mustShow = !session.getCurrentUserInfo().getShowDeletedContent();
+ final boolean mustShow = !session.getCurrentUserInfo().getShowDeletedContent();
session.getCurrentUserInfo().setShowDeletedContent(mustShow);
if (!mustShow && session.isCurrentStateAContent()
&& session.getContentState().getStatus().equals(ContentStatusDTO.inTheDustbin)) {
@@ -503,7 +503,7 @@
protected ActionToolbarMenuDescriptor<StateToken> createTranslateAction(final String fileMenuTitle,
final String... registerInTypes) {
- ActionToolbarMenuDescriptor<StateToken> translateContent = new ActionToolbarMenuDescriptor<StateToken>(
+ final ActionToolbarMenuDescriptor<StateToken> translateContent = new ActionToolbarMenuDescriptor<StateToken>(
AccessRolDTO.Editor, CONTENT_TOPBAR, new Listener<StateToken>() {
public void onEvent(final StateToken stateToken) {
NotifyUser.important(i18n.t("Sorry, this functionality is currently in development"));
@@ -543,7 +543,7 @@
}
protected ActionToolbarButtonAndItemDescriptor<StateToken> createUploadMediaAction(final String... registerInTypes) {
- ActionToolbarButtonAndItemDescriptor<StateToken> uploadMedia = createUploadAction(i18n.t("Upload media"),
+ final ActionToolbarButtonAndItemDescriptor<StateToken> uploadMedia = createUploadAction(i18n.t("Upload media"),
"images/nav/upload.png", i18n.t("Upload some media (images, videos...)"),
session.getGalleryPermittedExtensions());
contextActionRegistry.addAction(uploadMedia, registerInTypes);
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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -22,6 +22,7 @@
import org.ourproject.kune.chat.client.ChatEngine;
import org.ourproject.kune.platf.client.actions.ActionManager;
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
import org.ourproject.kune.platf.client.dto.StateToken;
@@ -49,8 +50,9 @@
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorNew;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
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;
@@ -59,7 +61,8 @@
import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaGroup;
import org.ourproject.kune.platf.client.ui.rte.insertmedia.abstractmedia.MediaUtils;
-import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
@@ -76,6 +79,8 @@
import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter;
import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView;
import org.ourproject.kune.workspace.client.editor.ContentEditor;
+import org.ourproject.kune.workspace.client.editor.ContentEditorPanel;
+import org.ourproject.kune.workspace.client.editor.ContentEditorPresenter;
import org.ourproject.kune.workspace.client.editor.insertlocalimg.InsertImageLocal;
import org.ourproject.kune.workspace.client.editor.insertlocalimg.InsertImageLocalPanel;
import org.ourproject.kune.workspace.client.editor.insertlocalimg.InsertImageLocalPresenter;
@@ -873,10 +878,16 @@
register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) {
@Override
public ContentEditor create() {
- return new ContentEditor(i(RTEditorNew.class), true, i(I18nTranslationService.class),
- i(StateManager.class), i(SiteSignOutLink.class), i(DeferredCommandWrapper.class),
- i(RTEImgResources.class), i(WorkspaceSkeleton.class), i(TimerWrapper.class),
- new RTESavingEditorPanel(), i(EntityTitle.class));
+ final ContentEditorPresenter presenter = new ContentEditorPresenter(i(I18nTranslationService.class),
+ i(Session.class), i(RTEImgResources.class), p(InsertLinkDialog.class),
+ p(ColorWebSafePalette.class), p(EditHtmlDialog.class), p(InsertImageDialog.class),
+ p(InsertMediaDialog.class), p(InsertTableDialog.class), p(InsertSpecialCharDialog.class),
+ i(DeferredCommandWrapper.class), true, i(StateManager.class), i(SiteSignOutLink.class),
+ i(WorkspaceSkeleton.class), i(TimerWrapper.class), i(EntityTitle.class));
+ final ContentEditorPanel panel = new ContentEditorPanel(presenter, i(I18nUITranslationService.class),
+ i(GlobalShortcutRegister.class), i(GuiBindingsRegister.class));
+ presenter.init(panel);
+ return presenter;
}
});
register(NoDecoration.class, new Factory<ActionContextTopToolbar>(ActionContextTopToolbar.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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -1,138 +1,16 @@
package org.ourproject.kune.workspace.client.editor;
-import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
-import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
-import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
-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.state.StateManager;
-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;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.platf.client.utils.TimerWrapper;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
-import org.ourproject.kune.workspace.client.skel.Toolbar;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import org.ourproject.kune.workspace.client.title.EntityTitle;
+public interface ContentEditor extends RTESavingEditor {
-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.gwtext.client.widgets.BoxComponent;
-import com.gwtext.client.widgets.event.ContainerListenerAdapter;
+ /**
+ * Sets the "File" menu title (some times you want a "Post" or "Wikipage"
+ * menu instead of a "File" menu).
+ *
+ * @param title
+ * the new file menu title
+ */
+ void setFileMenuTitle(String title);
-public class ContentEditor extends RTESavingEditorPresenter {
-
- public class RenameAction extends AbstractExtendedAction {
- 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 RTEditorNew basicEditor;
- private final RTEditorPanelNew editorPanel;
- private final ComplexToolbar topbar;
- private final SiteSignOutLink siteSignOutLink;
- private final I18nTranslationService i18n;
- private final EntityTitle entityTitle;
- private final ComplexToolbar sndbar;
-
- 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,
- final EntityTitle entityTitle) {
- super(editor, autoSave, i18n, stateManager, deferredCommandWrapper, imgResources, timer);
- this.i18n = i18n;
- this.siteSignOutLink = siteSignOutLink;
- this.entityTitle = entityTitle;
- super.init(view);
- this.ws = ws;
- Window.addWindowClosingHandler(new ClosingHandler() {
- public void onWindowClosing(final ClosingEvent event) {
- if (isSavePending()) {
- event.setMessage(i18n.t("You have changes without save. Are you sure?"));
- }
- // onDoSaveAndClose();
- }
- });
- vp = new VerticalPanel();
- basicEditor = super.getBasicEditor();
- addContentActions();
- editorPanel = (RTEditorPanelNew) basicEditor.getEditorArea();
- topbar = ((ComplexToolbar) basicEditor.getTopBar());
- sndbar = ((ComplexToolbar) basicEditor.getSndBar());
- vp.add(sndbar);
- vp.add(editorPanel);
- basicEditor.setExtended(true);
- vp.setWidth("100%");
- ws.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() {
- @Override
- public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight,
- final int rawWidth, final int rawHeight) {
- adjHeight(adjHeight);
- }
- });
-
- }
-
- @Override
- public void edit(final String html, final Listener<String> onSave, final Listener0 onEditCancelled) {
- final Toolbar contentTopBar = ws.getEntityWorkspace().getContentTopBar();
- contentTopBar.removeAll();
- contentTopBar.add(topbar);
- ws.getEntityWorkspace().setContent(vp);
- super.edit(html, onSave, onEditCancelled);
- adjHeight(ws.getEntityWorkspace().getContentHeight());
- siteSignOutLink.addBeforeSignOut(getBeforeSavingListener());
- }
-
- public void setFileMenuTitle(final String fileMenuTitleNew) {
- basicEditor.getFileMenu().setText(fileMenuTitleNew);
- }
-
- @Override
- protected void onCancelConfirmed() {
- ws.getEntityWorkspace().clearContent();
- super.onCancelConfirmed();
- siteSignOutLink.addBeforeSignOut(getBeforeSavingListener());
- }
-
- private void addContentActions() {
- 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) {
- final int barHeight = sndbar.getOffsetHeight();
- final int newHeight = height - 20 - barHeight;
- // Log.debug("Sndbar height: " + barHeight + " new height: " +
- // newHeight);
- editorPanel.adjustSize(newHeight);
- vp.setCellHeight(editorPanel, "" + newHeight);
- }
}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPanel.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPanel.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,15 @@
+package org.ourproject.kune.workspace.client.editor;
+
+import org.ourproject.kune.platf.client.actions.ui.GuiBindingsRegister;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+
+public class ContentEditorPanel extends RTESavingEditorPanel implements ContentEditorView {
+
+ public ContentEditorPanel(final ContentEditorPresenter presenter, final I18nUITranslationService i18n,
+ final GlobalShortcutRegister globalShortcutReg, final GuiBindingsRegister bindReg) {
+ super(presenter, i18n, globalShortcutReg, bindReg);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java (from rev 1125, 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorPresenter.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,152 @@
+package org.ourproject.kune.workspace.client.editor;
+
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
+
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
+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.state.Session;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
+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.edithtml.EditHtmlDialog;
+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.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
+import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
+import org.ourproject.kune.workspace.client.skel.Toolbar;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import org.ourproject.kune.workspace.client.title.EntityTitle;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Provider;
+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.gwtext.client.widgets.BoxComponent;
+import com.gwtext.client.widgets.event.ContainerListenerAdapter;
+
+public class ContentEditorPresenter extends RTESavingEditorPresenter implements ContentEditor {
+
+ public class RenameAction extends AbstractExtendedAction {
+ 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 wspace;
+ private VerticalPanel vpanel;
+ private RTEditorPanel editorPanel;
+ private final SiteSignOutLink siteSignOutLink;
+ private final I18nTranslationService i18n;
+ private final EntityTitle entityTitle;
+ private ComplexToolbar topbar;
+ private ComplexToolbar sndbar;
+
+ public ContentEditorPresenter(final I18nTranslationService i18n, final Session session,
+ 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 boolean autoSave, final StateManager stateManager,
+ final SiteSignOutLink siteSignOutLink, final WorkspaceSkeleton wspace, final TimerWrapper timer,
+ final EntityTitle entityTitle) {
+ super(i18n, session, imgResources, insLinkDialog, palette, editHtmlDialog, insertImageDialog,
+ insertMediaDialog, insertTableDialog, insCharDialog, deferred, autoSave, stateManager, timer);
+ super.setExtended(true);
+ this.i18n = i18n;
+ this.siteSignOutLink = siteSignOutLink;
+ this.entityTitle = entityTitle;
+ this.wspace = wspace;
+ Window.addWindowClosingHandler(new ClosingHandler() {
+ public void onWindowClosing(final ClosingEvent event) {
+ if (isSavePending()) {
+ event.setMessage(i18n.t("You have changes without save. Are you sure?"));
+ }
+ // onDoSaveAndClose();
+ }
+ });
+ wspace.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() {
+ @Override
+ public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight,
+ final int rawWidth, final int rawHeight) {
+ adjHeight(adjHeight);
+ }
+ });
+
+ }
+
+ @Override
+ public void edit(final String html, final Listener<String> onSave, final Listener0 onEditCancelled) {
+ super.edit(html, onSave, onEditCancelled);
+ final Toolbar contentTopBar = wspace.getEntityWorkspace().getContentTopBar();
+ contentTopBar.removeAll();
+ contentTopBar.add(topbar);
+ wspace.getEntityWorkspace().setContent(vpanel);
+ adjHeight(wspace.getEntityWorkspace().getContentHeight());
+ siteSignOutLink.addBeforeSignOut(getBeforeSavingListener());
+ }
+
+ public void init(final ContentEditorView view) {
+ super.init(view);
+ addContentActions();
+ vpanel = new VerticalPanel();
+ editorPanel = (RTEditorPanel) super.getEditorArea();
+ topbar = ((ComplexToolbar) super.getTopBar());
+ sndbar = ((ComplexToolbar) super.getSndBar());
+ vpanel.add(sndbar);
+ vpanel.add(editorPanel);
+ vpanel.setWidth("100%");
+ }
+
+ public void setFileMenuTitle(final String fileMenuTitleNew) {
+ super.getFileMenu().setText(fileMenuTitleNew);
+ }
+
+ @Override
+ protected void onCancelConfirmed() {
+ wspace.getEntityWorkspace().clearContent();
+ super.onCancelConfirmed();
+ siteSignOutLink.addBeforeSignOut(getBeforeSavingListener());
+ }
+
+ private void addContentActions() {
+ final RenameAction renameAction = new RenameAction(i18n.t("Rename"), NO_TEXT, NO_ICON);
+ final MenuItemDescriptor renameItem = new MenuItemDescriptor(super.getFileMenu(), renameAction);
+ renameItem.setLocation(RTEditor.TOPBAR);
+ final KeyStroke key = KeyStroke.getKeyStroke(Keyboard.KEY_F2, 0);
+ renameAction.putValue(Action.ACCELERATOR_KEY, key);
+ super.setActionShortcut(key, renameAction);
+ super.addAction(renameItem);
+ }
+
+ private void adjHeight(final int height) {
+ final int barHeight = sndbar.getOffsetHeight();
+ final int newHeight = height - 20 - barHeight;
+ // Log.debug("Sndbar height: " + barHeight + " new height: " +
+ // newHeight);
+ editorPanel.adjustSize(newHeight);
+ vpanel.setCellHeight(editorPanel, String.valueOf(newHeight));
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorView.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditorView.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.workspace.client.editor;
+
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorView;
+
+public interface ContentEditorView extends RTESavingEditorView {
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-11 18:28:19 UTC (rev 1125)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -20,25 +20,32 @@
package org.ourproject.kune.workspace.client.hello;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.dto.UserSimpleDTO;
+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.ui.MenuCheckItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuRadioItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuSeparatorDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.PushButtonDescriptor;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
+import org.ourproject.kune.platf.client.ui.img.ImgResources;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-import org.ourproject.kune.workspace.client.AbstractFoldableContentActions;
+import org.ourproject.kune.workspace.client.editor.ContentEditor;
+import org.ourproject.kune.workspace.client.hello.HelloWorldModule.HelloWorldPanel.HelloWorldPresenter;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry;
import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.ioc.decorator.Singleton;
import com.calclab.suco.client.ioc.module.Factory;
+import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Label;
/**
@@ -70,69 +77,121 @@
*
*/
public static class HelloWorldPanel implements HelloWorldView {
- private final I18nTranslationService i18n;
+ public static class HelloWorldPresenter implements HelloWorld {
- public HelloWorldPanel(final HelloWorldPresenter presenter, final WorkspaceSkeleton ws,
- final I18nTranslationService i18n) {
- this.i18n = i18n;
- /** We can directly insert something in the workspace skeleton **/
- ws.getEntityWorkspace().getSubTitle().add(new Label(i18n.t("Hello world!")));
- }
+ private HelloWorldView view;
- public void showMessage() {
- /** i18n use with parameters **/
- NotifyUser.info(i18n.t("Hello [%s]!", "world"));
- }
- }
+ public HelloWorldPresenter(final I18nTranslationService i18n,
+ final Provider<ContentEditor> contentEditorProv, final ImgResources img) {
+ // Or add some actions to the general content editor:
+ createActions(contentEditorProv, img, i18n);
+ }
- public static class HelloWorldPresenter implements HelloWorld {
+ public View getView() {
+ return view;
+ }
- private HelloWorldView view;
- private final Provider<UserActionRegistry> actionRegistry;
- private final I18nTranslationService i18n;
+ public void init(final HelloWorldView view) {
+ this.view = view;
+ }
- public HelloWorldPresenter(final I18nTranslationService i18n, final Provider<UserActionRegistry> actionRegistry) {
- this.i18n = i18n;
- this.actionRegistry = actionRegistry;
- createActions();
- }
+ /**
+ * We can add some gui action items to the content editor
+ *
+ * Summary)
+ *
+ * @param i18n
+ **/
+ private void createActions(final Provider<ContentEditor> contentEditorProv, final ImgResources img,
+ final I18nTranslationService i18n) {
- public View getView() {
- return view;
- }
+ final HelloWorldAction action = new HelloWorldAction(img);
- public void init(final HelloWorldView view) {
- this.view = view;
+ // We describe some gui items and all will use the same action:
+
+ final PushButtonDescriptor btn = new PushButtonDescriptor(action);
+
+ // We no use i18n.t() in most of these gui widgets but it's is
+ // recommended the use in real code
+ final MenuDescriptor menu = new MenuDescriptor(i18n.t("File"), "File menu tooltip");
+
+ final MenuItemDescriptor menuitem = new MenuItemDescriptor(menu, action);
+ final MenuItemDescriptor menuitem2 = new MenuItemDescriptor(menu, action);
+
+ // A submenu
+ final MenuDescriptor submenu = new MenuDescriptor("Options", "Submenu tooltip");
+ submenu.setParent(menu);
+
+ // A menu check item
+ final MenuItemDescriptor menuitem3 = new MenuItemDescriptor(submenu, action);
+ final MenuCheckItemDescriptor menuitem4 = new MenuCheckItemDescriptor(submenu, action);
+ menuitem4.setChecked(true);
+
+ // Some menu radio items
+ final String radioGroup = "helloworldradiogroup";
+ final MenuRadioItemDescriptor menuitem5 = new MenuRadioItemDescriptor(submenu, action, radioGroup);
+ final MenuRadioItemDescriptor menuitem6 = new MenuRadioItemDescriptor(submenu, action, radioGroup);
+ menuitem5.setChecked(true);
+
+ // We can define also some menu separators
+ final MenuSeparatorDescriptor menuSeparator = new MenuSeparatorDescriptor(menu);
+ final MenuSeparatorDescriptor otherSeparator = new MenuSeparatorDescriptor(submenu);
+
+ // Lazy creation of objects:
+ //
+ // Using Provider<Class> we do lazy instantiation. When we call
+ // actionRegistry.get() it creates the instance if is not
+ // created
+ // yet.
+ final ContentEditor contentEditor = contentEditorProv.get();
+
+ // We want to add some items to the topbar and other to the
+ // second bar
+ contentEditor.setLocation(ContentEditor.TOPBAR, menu, menuitem, menuSeparator, menuitem2, submenu,
+ menuitem3, menuitem4, otherSeparator, menuitem5, menuitem6);
+ contentEditor.setLocation(ContentEditor.SNDBAR, btn);
+
+ // And finally we add the action descriptors to the editor:
+ contentEditor.addActions(btn, menu, menuitem);
+
+ // Also individually
+ contentEditor.addAction(menuSeparator);
+
+ // It's important to add the menus before its menu items
+ contentEditor.addActions(menuitem2, submenu, menuitem3, menuitem4, otherSeparator, menuitem5, menuitem6);
+
+ // We can change descriptors properties and are changed in the
+ // UI
+ btn.setPushed(true);
+
+ // After some time we can change the common action or some other
+ // properties
+ new Timer() {
+ @Override
+ public void run() {
+ // The text of the action (in the menu or in the button)
+ action.putValue(Action.NAME, "hello world new");
+ // And the tooltip (on over message):
+ action.putValue(Action.SHORT_DESCRIPTION, "hello world new");
+ btn.setPushed(false);
+ }
+ }.schedule(10000);
+ }
}
- /**
- * We add an menu action to users menus (like the buddies in Buddies
- * Summary)
- **/
- private void createActions() {
- final ActionToolbarMenuDescriptor<UserSimpleDTO> helloWorldBuddiesAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>(
- AccessRolDTO.Viewer, AbstractFoldableContentActions.CONTENT_TOPBAR, new Listener<UserSimpleDTO>() {
- public void onEvent(final UserSimpleDTO parameter) {
- // We clicked:
- view.showMessage();
- }
- });
- // AccessRolDTO.Viewer: any user can see this option and without be
- // authenticated:
- helloWorldBuddiesAction.setMustBeAuthenticated(false);
- // We add a submenu in Options menu:
- helloWorldBuddiesAction.setParentMenuTitle(i18n.t("Options"));
- helloWorldBuddiesAction.setParentSubMenuTitle(i18n.t("Hello world submenu"));
- helloWorldBuddiesAction.setTextDescription(i18n.t("Hello world menu item"));
- helloWorldBuddiesAction.setIconUrl("images/info.gif");
+ private final I18nTranslationService i18n;
- // Lazy creation of objects:
- //
- // Using Provider<Class> we do lazy instantiation. When we call
- // actionRegistry.get() it creates the instance if is not created
- // yet.
- actionRegistry.get().addAction(helloWorldBuddiesAction);
+ public HelloWorldPanel(final HelloWorldPresenter presenter, final WorkspaceSkeleton wspace,
+ final I18nTranslationService i18n) {
+ this.i18n = i18n;
+ // We can directly insert something in the workspace skeleton
+ wspace.getEntityWorkspace().getSubTitle().add(new Label(i18n.t("Hello world!")));
}
+
+ public void showMessage() {
+ /** i18n use with parameters **/
+ NotifyUser.info(i18n.t("Hello [%s]!", "world"));
+ }
}
/**
@@ -143,6 +202,22 @@
void showMessage();
}
+ static class HelloWorldAction extends AbstractAction {
+ public HelloWorldAction(final ImgResources img) {
+ super();
+ super.putValue(Action.NAME, "helloword");
+ super.putValue(Action.SHORT_DESCRIPTION, "helloworld item");
+ super.putValue(Action.SMALL_ICON, img.info());
+ }
+
+ public void actionPerformed(final ActionEvent actionEvent) {
+ if (actionEvent.getEvent().getCtrlKey()) {
+ NotifyUser.info("Hello world action fired with ctrl key pressed");
+ }
+ NotifyUser.info("Hello world action fired");
+ }
+ }
+
/**
* This is the real part of the module (when we do how and when to create
* the above classes, how many instances (singleton, one per use), and so
@@ -175,7 +250,7 @@
@Override
public HelloWorld create() {
final HelloWorldPresenter presenter = new HelloWorldPresenter(i(I18nTranslationServiceMocked.class),
- p(UserActionRegistry.class));
+ p(ContentEditor.class), i(ImgResources.class));
final HelloWorldPanel panel = new HelloWorldPanel(presenter, i(WorkspaceSkeleton.class),
i(I18nTranslationServiceMocked.class));
presenter.init(panel);
@@ -213,10 +288,5 @@
NotifyUser.info("Global Ctrl+S pressed");
}
});
-
- // And because nobody use this module, we get the class (to force the
- // creation of the
- // Helloworld instance):
- // i(HelloWorld.class);
}
}
\ 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-11 18:28:19 UTC (rev 1125)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-06-11 22:14:06 UTC (rev 1126)
@@ -11,7 +11,6 @@
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.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;
@@ -28,9 +27,7 @@
private MockedListener0 cancelListener;
private StateManager stateManager;
private DeferredCommandWrapper deferredCommandWrapper;
- private RTEditorNew rteEditor;
private TimerWrapper timer;
- // private ComplexToolbar sndbar;
private RTESavingEditorView view;
@Before
@@ -39,17 +36,16 @@
new Resources(i18n);
stateManager = Mockito.mock(StateManager.class);
deferredCommandWrapper = Mockito.mock(DeferredCommandWrapper.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(ComplexToolbar.class);
- // Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
+ final ImageResource img = Mockito.mock(ImageResource.class);
+ Mockito.when(img.getName()).thenReturn("save");
+ Mockito.when(imgResources.save()).thenReturn(img);
timer = Mockito.mock(TimerWrapper.class);
view = Mockito.mock(RTESavingEditorView.class);
- presenter = new RTESavingEditorPresenter(rteEditor, true, i18n, stateManager, deferredCommandWrapper,
- imgResources, timer);
+
+ presenter = new RTESavingEditorPresenter(i18n, null, imgResources, null, null, null, null, null, null, null,
+ deferredCommandWrapper, true, stateManager, timer);
presenter.init(view);
saveListener = new MockedListener<String>();
cancelListener = new MockedListener0();
@@ -100,12 +96,10 @@
public void initialEditWithEditionAndSave() {
presenter.edit("Text to edit", saveListener, cancelListener);
final String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onDoSave();
presenter.onSavedSuccessful();
checkSaveBtnDisabled();
- assertTrue(saveListener.isCalledWithEquals(textModified));
assertTrue(cancelListener.isNotCalled());
}
@@ -113,7 +107,6 @@
public void testSavePendingAndCancel() {
presenter.edit("Text to edit", saveListener, cancelListener);
final String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onCancel();
presenter.onCancelConfirmed();
@@ -125,7 +118,6 @@
public void testSavePendingAndSaveFails() {
presenter.edit("Text to edit", saveListener, cancelListener);
final String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onDoSave();
presenter.onSaveFailed();
1
0
Author: vjrj
Date: 2009-06-11 20:28:19 +0200 (Thu, 11 Jun 2009)
New Revision: 1125
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/AbstractExtendedModule.java
Removed:
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/RTEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java
Modified:
trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java
trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.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/TestButton.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.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/saving/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.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
Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -35,6 +35,7 @@
import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
@@ -55,10 +56,9 @@
import org.ourproject.kune.workspace.client.upload.FileUploader;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class BlogClientModule extends AbstractModule {
+public class BlogClientModule extends AbstractExtendedModule {
@Override
public void onInstall() {
@@ -66,29 +66,29 @@
register(ToolGroup.class, new Factory<BlogClientTool>(BlogClientTool.class) {
@Override
public BlogClientTool create() {
- $(BlogClientActions.class);
- return new BlogClientTool($(I18nUITranslationService.class), $(ToolSelector.class),
- $(WsThemePresenter.class), $(WorkspaceSkeleton.class), $(ContentCapabilitiesRegistry.class));
+ i(BlogClientActions.class);
+ return new BlogClientTool(i(I18nUITranslationService.class), i(ToolSelector.class),
+ i(WsThemePresenter.class), i(WorkspaceSkeleton.class), i(ContentCapabilitiesRegistry.class));
}
});
register(ToolGroup.class, new Factory<BlogClientActions>(BlogClientActions.class) {
@Override
public BlogClientActions create() {
- return new BlogClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
- $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(BlogViewer.class),
- $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
+ return new BlogClientActions(i(I18nUITranslationService.class), i(ContextNavigator.class),
+ i(Session.class), i(StateManager.class), i(DeferredCommandWrapper.class),
+ p(ContentServiceAsync.class), p(GroupServiceAsync.class), p(FileUploader.class),
+ i(ContentActionRegistry.class), i(ContextActionRegistry.class), p(FileDownloadUtils.class),
+ i(EntityHeader.class), p(ContentEditor.class), i(ErrorHandler.class), i(BlogViewer.class),
+ p(ContextPropEditor.class), i(SitePublicSpaceLink.class));
}
});
register(ToolGroup.class, new Factory<BlogContext>(BlogContext.class) {
@Override
public BlogContext create() {
- final BlogContextPresenter presenter = new BlogContextPresenter($(StateManager.class),
- $$(ContextNavigator.class), $$(ContextPropEditor.class));
+ final BlogContextPresenter presenter = new BlogContextPresenter(i(StateManager.class),
+ p(ContextNavigator.class), p(ContextPropEditor.class));
return presenter;
}
});
@@ -96,11 +96,11 @@
register(Singleton.class, new Factory<BlogViewer>(BlogViewer.class) {
@Override
public BlogViewer create() {
- final BlogViewerPresenter presenter = new BlogViewerPresenter($(StateManager.class), $(Session.class),
- $(I18nUITranslationService.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final BlogViewerView view = new BlogViewerPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final BlogViewerPresenter presenter = new BlogViewerPresenter(i(StateManager.class), i(Session.class),
+ i(I18nUITranslationService.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final BlogViewerView view = new BlogViewerPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
@@ -109,11 +109,11 @@
register(ToolGroup.class, new Factory<BlogFolderContent>(BlogFolderContent.class) {
@Override
public BlogFolderContent create() {
- final BlogFolderContentPresenter presenter = new BlogFolderContentPresenter($(StateManager.class),
- $(Session.class), $(ActionContentToolbar.class), $(ContentActionRegistry.class),
- $(I18nTranslationService.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final BlogFolderContentView view = new BlogFolderContentPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final BlogFolderContentPresenter presenter = new BlogFolderContentPresenter(i(StateManager.class),
+ i(Session.class), i(ActionContentToolbar.class), i(ContentActionRegistry.class),
+ i(I18nTranslationService.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final BlogFolderContentView view = new BlogFolderContentPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -33,6 +33,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
@@ -49,10 +50,9 @@
import com.calclab.emiteuimodule.client.EmiteUIDialog;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class ChatClientModule extends AbstractModule {
+public class ChatClientModule extends AbstractExtendedModule {
@Override
public void onInstall() {
@@ -60,25 +60,25 @@
register(ToolGroup.class, new Factory<ChatClientActions>(ChatClientActions.class) {
@Override
public ChatClientActions create() {
- return new ChatClientActions($(I18nUITranslationService.class), $(Session.class),
- $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(ChatEngine.class),
- $$(AddRoom.class), $$(DeferredCommandWrapper.class));
+ return new ChatClientActions(i(I18nUITranslationService.class), i(Session.class),
+ i(ContentActionRegistry.class), i(ContextActionRegistry.class), p(ChatEngine.class),
+ p(AddRoom.class), p(DeferredCommandWrapper.class));
}
});
register(ToolGroup.class, new Factory<ChatClientTool>(ChatClientTool.class) {
@Override
public ChatClientTool create() {
- return new ChatClientTool($(I18nUITranslationService.class), $(WorkspaceSkeleton.class),
- $(ToolSelector.class), $(WsThemePresenter.class), $(ContentCapabilitiesRegistry.class));
+ return new ChatClientTool(i(I18nUITranslationService.class), i(WorkspaceSkeleton.class),
+ i(ToolSelector.class), i(WsThemePresenter.class), i(ContentCapabilitiesRegistry.class));
}
});
register(ToolGroup.class, new Factory<ChatContext>(ChatContext.class) {
@Override
public ChatContext create() {
- final ChatContextPresenter presenter = new ChatContextPresenter($(StateManager.class),
- $$(ContextNavigator.class));
+ final ChatContextPresenter presenter = new ChatContextPresenter(i(StateManager.class),
+ p(ContextNavigator.class));
return presenter;
}
});
@@ -86,9 +86,9 @@
register(ToolGroup.class, new Factory<ChatEngine>(ChatEngine.class) {
@Override
public ChatEngine create() {
- final ChatEngineDefault chatEngineDefault = new ChatEngineDefault($(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class), $(Application.class), $(Session.class), $$(EmiteUIDialog.class),
- $$(FileDownloadUtils.class), $(GlobalShortcutRegister.class));
+ final ChatEngineDefault chatEngineDefault = new ChatEngineDefault(i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class), i(Application.class), i(Session.class), p(EmiteUIDialog.class),
+ p(FileDownloadUtils.class), i(GlobalShortcutRegister.class));
return chatEngineDefault;
}
});
@@ -96,11 +96,11 @@
register(ToolGroup.class, new Factory<ChatRoom>(ChatRoom.class) {
@Override
public ChatRoom create() {
- final ChatRoomPresenter presenter = new ChatRoomPresenter($(StateManager.class), $(Session.class),
- $(I18nUITranslationService.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final ChatRoomPanel panel = new ChatRoomPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final ChatRoomPresenter presenter = new ChatRoomPresenter(i(StateManager.class), i(Session.class),
+ i(I18nUITranslationService.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final ChatRoomPanel panel = new ChatRoomPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -109,9 +109,9 @@
register(Singleton.class, new Factory<AddRoom>(AddRoom.class) {
@Override
public AddRoom create() {
- final AddRoomPresenter presenter = new AddRoomPresenter($(Session.class),
- $$(ContentServiceAsync.class), $(StateManager.class));
- final AddRoomPanel panel = new AddRoomPanel(presenter, $(I18nTranslationService.class));
+ final AddRoomPresenter presenter = new AddRoomPresenter(i(Session.class), p(ContentServiceAsync.class),
+ i(StateManager.class));
+ final AddRoomPanel panel = new AddRoomPanel(presenter, i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -35,6 +35,7 @@
import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
@@ -55,10 +56,9 @@
import org.ourproject.kune.workspace.client.upload.FileUploader;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class DocumentClientModule extends AbstractModule {
+public class DocumentClientModule extends AbstractExtendedModule {
@Override
public void onInstall() {
@@ -66,29 +66,29 @@
register(ToolGroup.class, new Factory<DocumentClientTool>(DocumentClientTool.class) {
@Override
public DocumentClientTool create() {
- $(DocumentClientActions.class);
- return new DocumentClientTool($(I18nUITranslationService.class), $(ToolSelector.class),
- $(WsThemePresenter.class), $(WorkspaceSkeleton.class), $(ContentCapabilitiesRegistry.class));
+ i(DocumentClientActions.class);
+ return new DocumentClientTool(i(I18nUITranslationService.class), i(ToolSelector.class),
+ i(WsThemePresenter.class), i(WorkspaceSkeleton.class), i(ContentCapabilitiesRegistry.class));
}
});
register(ToolGroup.class, new Factory<DocumentClientActions>(DocumentClientActions.class) {
@Override
public DocumentClientActions create() {
- return new DocumentClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
- $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(DocumentViewer.class),
- $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
+ return new DocumentClientActions(i(I18nUITranslationService.class), i(ContextNavigator.class),
+ i(Session.class), i(StateManager.class), i(DeferredCommandWrapper.class),
+ p(ContentServiceAsync.class), p(GroupServiceAsync.class), p(FileUploader.class),
+ i(ContentActionRegistry.class), i(ContextActionRegistry.class), p(FileDownloadUtils.class),
+ i(EntityHeader.class), p(ContentEditor.class), i(ErrorHandler.class), i(DocumentViewer.class),
+ p(ContextPropEditor.class), i(SitePublicSpaceLink.class));
}
});
register(ToolGroup.class, new Factory<DocumentContext>(DocumentContext.class) {
@Override
public DocumentContext create() {
- final DocumentContextPresenter presenter = new DocumentContextPresenter($(StateManager.class),
- $$(ContextNavigator.class), $$(ContextPropEditor.class));
+ final DocumentContextPresenter presenter = new DocumentContextPresenter(i(StateManager.class),
+ p(ContextNavigator.class), p(ContextPropEditor.class));
return presenter;
}
});
@@ -96,11 +96,11 @@
register(Singleton.class, new Factory<DocumentViewer>(DocumentViewer.class) {
@Override
public DocumentViewer create() {
- final DocumentViewerPresenter presenter = new DocumentViewerPresenter($(StateManager.class),
- $(Session.class), $(I18nUITranslationService.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final DocumentViewerView view = new DocumentViewerPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final DocumentViewerPresenter presenter = new DocumentViewerPresenter(i(StateManager.class),
+ i(Session.class), i(I18nUITranslationService.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final DocumentViewerView view = new DocumentViewerPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
@@ -109,11 +109,11 @@
register(ToolGroup.class, new Factory<DocFolderContent>(DocFolderContent.class) {
@Override
public DocFolderContent create() {
- final DocFolderContentPresenter presenter = new DocFolderContentPresenter($(StateManager.class),
- $(Session.class), $(ActionContentToolbar.class), $(ContentActionRegistry.class),
- $$(FileDownloadUtils.class), $(I18nTranslationService.class), $$(MediaUtils.class));
- final DocFolderContentView view = new DocFolderContentPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final DocFolderContentPresenter presenter = new DocFolderContentPresenter(i(StateManager.class),
+ i(Session.class), i(ActionContentToolbar.class), i(ContentActionRegistry.class),
+ p(FileDownloadUtils.class), i(I18nTranslationService.class), p(MediaUtils.class));
+ final DocFolderContentView view = new DocFolderContentPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -35,6 +35,7 @@
import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
@@ -55,10 +56,9 @@
import org.ourproject.kune.workspace.client.upload.FileUploader;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class GalleryClientModule extends AbstractModule {
+public class GalleryClientModule extends AbstractExtendedModule {
@Override
public void onInstall() {
@@ -66,29 +66,29 @@
register(ToolGroup.class, new Factory<GalleryClientTool>(GalleryClientTool.class) {
@Override
public GalleryClientTool create() {
- $(GalleryClientActions.class);
- return new GalleryClientTool($(I18nUITranslationService.class), $(ToolSelector.class),
- $(WsThemePresenter.class), $(WorkspaceSkeleton.class), $(ContentCapabilitiesRegistry.class));
+ i(GalleryClientActions.class);
+ return new GalleryClientTool(i(I18nUITranslationService.class), i(ToolSelector.class),
+ i(WsThemePresenter.class), i(WorkspaceSkeleton.class), i(ContentCapabilitiesRegistry.class));
}
});
register(ToolGroup.class, new Factory<GalleryClientActions>(GalleryClientActions.class) {
@Override
public GalleryClientActions create() {
- return new GalleryClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
- $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(GalleryViewer.class),
- $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
+ return new GalleryClientActions(i(I18nUITranslationService.class), i(ContextNavigator.class),
+ i(Session.class), i(StateManager.class), i(DeferredCommandWrapper.class),
+ p(ContentServiceAsync.class), p(GroupServiceAsync.class), p(FileUploader.class),
+ i(ContentActionRegistry.class), i(ContextActionRegistry.class), p(FileDownloadUtils.class),
+ i(EntityHeader.class), p(ContentEditor.class), i(ErrorHandler.class), i(GalleryViewer.class),
+ p(ContextPropEditor.class), i(SitePublicSpaceLink.class));
}
});
register(ToolGroup.class, new Factory<GalleryContext>(GalleryContext.class) {
@Override
public GalleryContext create() {
- final GalleryContextPresenter presenter = new GalleryContextPresenter($(StateManager.class),
- $$(ContextNavigator.class), $$(ContextPropEditor.class));
+ final GalleryContextPresenter presenter = new GalleryContextPresenter(i(StateManager.class),
+ p(ContextNavigator.class), p(ContextPropEditor.class));
return presenter;
}
});
@@ -96,11 +96,11 @@
register(Singleton.class, new Factory<GalleryViewer>(GalleryViewer.class) {
@Override
public GalleryViewer create() {
- final GalleryViewerPresenter presenter = new GalleryViewerPresenter($(StateManager.class),
- $(Session.class), $(I18nUITranslationService.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final GalleryViewerView view = new GalleryViewerPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final GalleryViewerPresenter presenter = new GalleryViewerPresenter(i(StateManager.class),
+ i(Session.class), i(I18nUITranslationService.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final GalleryViewerView view = new GalleryViewerPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
@@ -110,11 +110,11 @@
@Override
public GalleryFolderContent create() {
final GalleryFolderContentPresenter presenter = new GalleryFolderContentPresenter(
- $(StateManager.class), $(Session.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $(I18nTranslationService.class), $$(FileDownloadUtils.class),
- $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final GalleryFolderContentView view = new GalleryFolderContentPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class), $(StateManager.class), $(Session.class));
+ i(StateManager.class), i(Session.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), i(I18nTranslationService.class), p(FileDownloadUtils.class),
+ p(FileDownloadUtils.class), p(MediaUtils.class));
+ final GalleryFolderContentView view = new GalleryFolderContentPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class), i(StateManager.class), i(Session.class));
presenter.init(view);
return presenter;
}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java (from rev 1123, 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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractExtendedAction.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -0,0 +1,28 @@
+package org.ourproject.kune.platf.client.actions;
+
+
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public abstract class AbstractExtendedAction extends AbstractAction {
+ public static final String NO_TEXT = null;
+ public static final ImageResource NO_ICON = null;
+
+ public AbstractExtendedAction() {
+ super();
+ }
+
+ public AbstractExtendedAction(final String text) {
+ this(text, null, null);
+ }
+
+ public AbstractExtendedAction(final String text, final ImageResource icon) {
+ this(text, null, icon);
+ }
+
+ public AbstractExtendedAction(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/actions/KeyStroke.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/KeyStroke.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -38,6 +38,7 @@
package org.ourproject.kune.platf.client.actions;
import java.util.HashMap;
+import java.util.Map;
import org.ourproject.kune.platf.client.i18n.Resources;
import org.ourproject.kune.platf.client.shortcuts.Keyboard;
@@ -74,7 +75,7 @@
* under the assumption that garbage collection of a new keystroke is easy
* when we find the old one that it matches in the cache.
*/
- private static final HashMap<KeyStroke, KeyStroke> CACHE = new HashMap<KeyStroke, KeyStroke>();
+ private static final Map<KeyStroke, KeyStroke> CACHE = new HashMap<KeyStroke, KeyStroke>();
/** The most recently generated keystroke, or null. */
private static KeyStroke recent;
@@ -85,7 +86,7 @@
*
* @see #getKeyStroke(String)
*/
- static final HashMap<String, Object> VKTABLE = new HashMap<String, Object>();
+ static final Map<String, Object> VKTABLE = new HashMap<String, Object>();
private static final int VK_UNDEFINED = 0;
private static final char CHAR_UNDEFINED = '\uffff';
@@ -303,18 +304,18 @@
/**
* Tests two keystrokes for equality.
*
- * @param o
+ * @param obj
* the object to test
* @return true if it is equal
*/
@Override
- public final boolean equals(final Object o) {
- if (!(o instanceof KeyStroke)) {
+ public final boolean equals(final Object obj) {
+ if (!(obj instanceof KeyStroke)) {
return false;
}
- final KeyStroke s = (KeyStroke) o;
- return this == o
- || (keyChar == s.keyChar && keyCode == s.keyCode && modifiers == s.modifiers && onKeyRelease == s.onKeyRelease);
+ final KeyStroke stroke = (KeyStroke) obj;
+ return this == obj
+ || (keyChar == stroke.keyChar && keyCode == stroke.keyCode && modifiers == stroke.modifiers && onKeyRelease == stroke.onKeyRelease);
}
/**
@@ -437,14 +438,17 @@
case Keyboard.KEY_OPEN_BRACKET:
case Keyboard.KEY_BACK_SLASH:
case Keyboard.KEY_CLOSE_BRACKET:
- return ("" + (char) keyCode).toUpperCase();
-
+ return String.valueOf(keyCode).toUpperCase();
default:
final String charS = String.valueOf(keyChar);
if (charS == null) {
return "Unknown keyCode: 0x" + (keyCode < 0 ? "-" : "") + Integer.toHexString(Math.abs(keyCode));
} else {
- return charS;
+ if (" ".equals(charS)) {
+ return translateKey("Space");
+ } else {
+ return charS;
+ }
}
}
}
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuDescriptor.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -16,6 +16,7 @@
public MenuDescriptor(final GuiActionDescrip parent, final AbstractAction action) {
super(action);
setParent(parent);
+ action.putValue(MENU_HIDE, false);
}
public MenuDescriptor(final String text) {
@@ -36,7 +37,7 @@
}
public void hide() {
- action.putValue(MENU_HIDE, true);
+ action.putValue(MENU_HIDE, !((Boolean) action.getValue(MENU_HIDE)));
}
public void setText(final String 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -6,8 +6,6 @@
import com.google.gwt.libideas.resources.client.ImageResource;
import com.gwtext.client.widgets.ToolbarButton;
-import com.gwtext.client.widgets.menu.Menu;
-import com.gwtext.client.widgets.menu.event.MenuListenerAdapter;
public class MenuGui extends AbstractMenuGui {
@@ -21,17 +19,11 @@
initWidget(button);
descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent event) {
- if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE) && event.getNewValue().equals(true)) {
+ if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE)) {
menu.hide(true);
}
}
});
- menu.addListener(new MenuListenerAdapter() {
- @Override
- public void onShow(final Menu menu) {
- descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
- }
- });
}
public void add(final SubMenuGui submenu) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/TestButton.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,33 +1,21 @@
package org.ourproject.kune.platf.client.actions.ui;
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.ui.img.ImgResources;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import com.google.gwt.libideas.resources.client.ImageResource;
import com.google.gwt.user.client.Timer;
public class TestButton {
- static class Action extends AbstractAction {
- public Action(final ImageResource icon) {
- super();
- super.putValue(Action.NAME, "FIXME");
- super.putValue(Action.SHORT_DESCRIPTION, "FIXME");
- super.putValue(Action.SMALL_ICON, icon);
- }
- public void actionPerformed(final ActionEvent actionEvent) {
- // FIXME
- }
- }
-
- static class NotiAction extends AbstractAction {
- public NotiAction(final ImgResources img) {
+ static class HelloWorldAction extends AbstractAction {
+ public HelloWorldAction(final ImgResources img) {
super();
- super.putValue(Action.NAME, "test");
- super.putValue(Action.SHORT_DESCRIPTION, "test button");
+ super.putValue(Action.NAME, "helloword");
+ super.putValue(Action.SHORT_DESCRIPTION, "helloworld item");
super.putValue(Action.SMALL_ICON, img.info());
}
@@ -40,7 +28,7 @@
}
public TestButton(final WorkspaceSkeleton wksp, final GuiBindingsRegister bindings, final ImgResources img) {
- final NotiAction noti = new NotiAction(img);
+ final HelloWorldAction noti = new HelloWorldAction(img);
final PushButtonDescriptor btn = new PushButtonDescriptor(noti);
Added: trunk/src/main/java/org/ourproject/kune/platf/client/services/AbstractExtendedModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/AbstractExtendedModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/AbstractExtendedModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -0,0 +1,37 @@
+package org.ourproject.kune.platf.client.services;
+
+import com.calclab.suco.client.ioc.Provider;
+import com.calclab.suco.client.ioc.module.AbstractModule;
+
+public abstract class AbstractExtendedModule extends AbstractModule {
+
+ /**
+ * Get a instance of the specified component key
+ *
+ * @param <T>
+ * The component key
+ * @param componentType
+ * The component key
+ * @return The component instance
+ */
+ protected <T> T i(final Class<T> componentType) { // NOPMD by vjrj on
+ // 11/06/09 18:34
+ return $(componentType);
+ }
+
+ /**
+ * Get a provider of the specified component key
+ *
+ * @param <T>
+ * The component key
+ * @param componentType
+ * The component key
+ * @return The provider of that component key
+ */
+ protected <T> Provider<T> p(final Class<T> componentType) {// NOPMD by vjrj
+ // on 11/06/09
+ // 18:34
+ return $$(componentType);
+ }
+
+}
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -124,7 +124,6 @@
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
import com.google.gwt.core.client.GWT;
import com.google.gwt.libideas.client.StyleInjector;
@@ -132,7 +131,7 @@
import com.google.gwt.user.client.History;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-public class PlatformModule extends AbstractModule {
+public class PlatformModule extends AbstractExtendedModule {
@Override
protected void onInstall() {
@@ -140,7 +139,7 @@
register(Singleton.class, new Factory<Session>(Session.class) {
@Override
public Session create() {
- return new SessionDefault(Cookies.getCookie(Session.USERHASH), $$(UserServiceAsync.class));
+ return new SessionDefault(Cookies.getCookie(Session.USERHASH), p(UserServiceAsync.class));
}
}, new Factory<I18nServiceAsync>(I18nServiceAsync.class) {
@Override
@@ -166,13 +165,13 @@
}, new Factory<ContentProvider>(ContentProvider.class) {
@Override
public ContentProvider create() {
- return new ContentProviderDefault($(ContentServiceAsync.class));
+ return new ContentProviderDefault(i(ContentServiceAsync.class));
}
}, new Factory<StateManager>(StateManager.class) {
@Override
public StateManager create() {
- final StateManagerDefault stateManager = new StateManagerDefault($(ContentProvider.class),
- $(Session.class), $(HistoryWrapper.class));
+ final StateManagerDefault stateManager = new StateManagerDefault(i(ContentProvider.class),
+ i(Session.class), i(HistoryWrapper.class));
History.addValueChangeHandler(stateManager);
return stateManager;
}
@@ -182,7 +181,7 @@
@Override
public I18nUITranslationService create() {
final I18nUITranslationService i18n = new I18nUITranslationService();
- i18n.init($(I18nServiceAsync.class), $(Session.class), new Listener0() {
+ i18n.init(i(I18nServiceAsync.class), i(Session.class), new Listener0() {
public void onEvent() {
onI18nReady();
}
@@ -194,7 +193,7 @@
register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
@Override
public FileDownloadUtils create() {
- return new FileDownloadUtils($(Session.class), $(ImageUtils.class));
+ return new FileDownloadUtils(i(Session.class), i(ImageUtils.class));
}
});
@@ -207,13 +206,13 @@
});
}
- $(I18nUITranslationService.class);
- $(QuickTipsHelper.class);
+ i(I18nUITranslationService.class);
+ i(QuickTipsHelper.class);
}
private void onI18nReady() {
- final I18nUITranslationService i18n = $(I18nUITranslationService.class);
+ final I18nUITranslationService i18n = i(I18nUITranslationService.class);
if (container.hasProvider(I18nTranslationService.class)) {
container.removeProvider(I18nTranslationService.class);
@@ -226,7 +225,7 @@
}
});
- $(Resources.class);
+ i(Resources.class);
register(Singleton.class, new Factory<I18nTranslationService>(I18nTranslationService.class) {
@Override
@@ -238,7 +237,7 @@
register(Singleton.class, new Factory<ErrorHandler>(ErrorHandler.class) {
@Override
public ErrorHandler create() {
- return new ErrorHandler($(Session.class), i18n, $$(StateManager.class));
+ return new ErrorHandler(i(Session.class), i18n, p(StateManager.class));
}
});
@@ -250,16 +249,16 @@
}, new Factory<ImageUtils>(ImageUtils.class) {
@Override
public ImageUtils create() {
- return new ImageUtils($(Images.class));
+ return new ImageUtils(i(Images.class));
}
});
- AsyncCallbackSimple.init($(ErrorHandler.class));
+ AsyncCallbackSimple.init(i(ErrorHandler.class));
register(Singleton.class, new Factory<Application>(Application.class) {
@Override
public Application create() {
- return new ApplicationDefault($(Session.class));
+ return new ApplicationDefault(i(Session.class));
}
});
@@ -293,14 +292,14 @@
register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) {
@Override
public RTEActionTopToolbar create() {
- final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class));
+ final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>(p(ActionManager.class));
final RTEActionTopToolbar toolbar = new RTEActionTopToolbar(panel);
return toolbar;
}
}, new Factory<RTEActionSndToolbar>(RTEActionSndToolbar.class) {
@Override
public RTEActionSndToolbar create() {
- final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class), true);
+ final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>(p(ActionManager.class), true);
final RTEActionSndToolbar toolbar = new RTEActionSndToolbar(panel);
return toolbar;
}
@@ -316,8 +315,8 @@
register(InsertLinkGroup.class, new Factory<InsertLinkExt>(InsertLinkExt.class) {
@Override
public InsertLinkExt create() {
- final InsertLinkExtPresenter presenter = new InsertLinkExtPresenter($(InsertLinkDialog.class));
- final InsertLinkExtView panel = new InsertLinkExtPanel(presenter, $(I18nTranslationService.class));
+ final InsertLinkExtPresenter presenter = new InsertLinkExtPresenter(i(InsertLinkDialog.class));
+ final InsertLinkExtView panel = new InsertLinkExtPanel(presenter, i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -327,8 +326,8 @@
@Override
public InsertLinkEmail create() {
- final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter($(InsertLinkDialog.class));
- final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter, $(I18nTranslationService.class));
+ final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter(i(InsertLinkDialog.class));
+ final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter, i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -337,21 +336,21 @@
register(NoDecoration.class,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));
+ final RTEditorPresenterNew presenter = new RTEditorPresenterNew(i(I18nTranslationService.class),
+ i(Session.class), i(RTEImgResources.class), p(InsertLinkDialog.class),
+ p(ColorWebSafePalette.class), p(EditHtmlDialog.class), p(InsertImageDialog.class),
+ p(InsertMediaDialog.class), p(InsertTableDialog.class), p(InsertSpecialCharDialog.class), i(DeferredCommandWrapper.class));
+ final RTEditorPanelNew panel = new RTEditorPanelNew(presenter, i(I18nUITranslationService.class),
+ i(GlobalShortcutRegister.class), i(GuiBindingsRegister.class));
presenter.init(panel);
return presenter;
}
}, new Factory<RTESavingEditor>(RTESavingEditor.class) {
@Override
public RTESavingEditor create() {
- final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditorNew.class), true,
- $(I18nTranslationService.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $(RTEImgResources.class), $(TimerWrapper.class));
+ final RTESavingEditorPresenter presenter = new RTESavingEditorPresenter(i(RTEditorNew.class), true,
+ i(I18nTranslationService.class), i(StateManager.class), i(DeferredCommandWrapper.class),
+ i(RTEImgResources.class), i(TimerWrapper.class));
final RTESavingEditorPanel panel = new RTESavingEditorPanel();
presenter.init(panel);
return presenter;
@@ -361,14 +360,14 @@
register(NoDecoration.class, new Factory<TestRTEDialog>(TestRTEDialog.class) {
@Override
public TestRTEDialog create() {
- return new TestRTEDialog($(RTESavingEditor.class));
+ return new TestRTEDialog(i(RTESavingEditor.class));
}
});
register(ApplicationComponentGroup.class, new Factory<NotifyUser>(NotifyUser.class) {
@Override
public NotifyUser create() {
- return new NotifyUser($(I18nTranslationService.class), $(Images.class));
+ return new NotifyUser(i(I18nTranslationService.class), i(Images.class));
}
});
@@ -396,8 +395,8 @@
@Override
public EditHtmlDialog create() {
final EditHtmlDialogPresenter presenter = new EditHtmlDialogPresenter();
- final EditHtmlDialogPanel panel = new EditHtmlDialogPanel(presenter, $(I18nTranslationService.class),
- $(RTEImgResources.class), $(Images.class), $(EditHtmlGroup.class));
+ final EditHtmlDialogPanel panel = new EditHtmlDialogPanel(presenter, i(I18nTranslationService.class),
+ i(RTEImgResources.class), i(Images.class), i(EditHtmlGroup.class));
presenter.init(panel);
return presenter;
}
@@ -406,7 +405,7 @@
register(EditHtmlGroup.class, new Factory<EditHtmlEditor>(EditHtmlEditor.class) {
@Override
public EditHtmlEditor create() {
- final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter($(EditHtmlDialog.class));
+ final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter(i(EditHtmlDialog.class));
final EditHtmlEditorPanel panel = new EditHtmlEditorPanel(i18n, presenter);
presenter.init(panel);
return presenter;
@@ -414,7 +413,7 @@
}, new Factory<EditHtmlPreview>(EditHtmlPreview.class) {
@Override
public EditHtmlPreview create() {
- final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter($(EditHtmlDialog.class));
+ final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter(i(EditHtmlDialog.class));
final EditHtmlPreviewPanel panel = new EditHtmlPreviewPanel(i18n, presenter);
presenter.init(panel);
return presenter;
@@ -426,7 +425,7 @@
public InsertImageDialog create() {
final InsertImageDialogPresenter presenter = new InsertImageDialogPresenter();
final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter,
- $(I18nTranslationService.class), $(Images.class), $(InsertImageGroup.class));
+ i(I18nTranslationService.class), i(Images.class), i(InsertImageGroup.class));
presenter.init(panel);
return presenter;
}
@@ -435,7 +434,7 @@
register(InsertImageGroup.class, new Factory<InsertImageExt>(InsertImageExt.class) {
@Override
public InsertImageExt create() {
- final InsertImageExtPresenter presenter = new InsertImageExtPresenter($(InsertImageDialog.class));
+ final InsertImageExtPresenter presenter = new InsertImageExtPresenter(i(InsertImageDialog.class));
final InsertImageExtPanel panel = new InsertImageExtPanel(presenter, i18n);
presenter.init(panel);
return presenter;
@@ -446,8 +445,8 @@
@Override
public InsertLinkDialog create() {
final InsertLinkDialogPresenter presenter = new InsertLinkDialogPresenter();
- final InsertLinkDialogPanel panel = new InsertLinkDialogPanel(presenter, $(Images.class),
- $(I18nTranslationService.class), $(InsertLinkGroup.class));
+ final InsertLinkDialogPanel panel = new InsertLinkDialogPanel(presenter, i(Images.class),
+ i(I18nTranslationService.class), i(InsertLinkGroup.class));
presenter.init(panel);
return presenter;
}
@@ -458,7 +457,7 @@
public InsertTableDialog create() {
final InsertTableDialogPresenter presenter = new InsertTableDialogPresenter();
final InsertTableDialogPanel panel = new InsertTableDialogPanel(presenter, i18n,
- $$(SimplePalette.class), $(RTEImgResources.class));
+ p(SimplePalette.class), i(RTEImgResources.class));
presenter.init(panel);
return presenter;
}
@@ -468,8 +467,8 @@
@Override
public InsertSpecialCharDialog create() {
final InsertSpecialCharDialogPresenter presenter = new InsertSpecialCharDialogPresenter();
- final InsertSpecialCharDialogPanel panel = new InsertSpecialCharDialogPanel(presenter, $(Images.class),
- $(I18nTranslationService.class), $(InsertSpecialCharGroup.class), $(RTEImgResources.class));
+ final InsertSpecialCharDialogPanel panel = new InsertSpecialCharDialogPanel(presenter, i(Images.class),
+ i(I18nTranslationService.class), i(InsertSpecialCharGroup.class), i(RTEImgResources.class));
presenter.init(panel);
return presenter;
}
@@ -477,7 +476,7 @@
@Override
public InsertSpecialOccChar create() {
final InsertSpecialOccCharPresenter presenter = new InsertSpecialOccCharPresenter();
- final InsertSpecialOccCharPanel panel = new InsertSpecialOccCharPanel($(InsertSpecialCharDialog.class),
+ final InsertSpecialOccCharPanel panel = new InsertSpecialOccCharPanel(i(InsertSpecialCharDialog.class),
i18n);
presenter.init(panel);
return presenter;
@@ -487,14 +486,14 @@
public InsertSpecialAsianChar create() {
final InsertSpecialAsianCharPresenter presenter = new InsertSpecialAsianCharPresenter();
final InsertSpecialAsianCharPanel panel = new InsertSpecialAsianCharPanel(
- $(InsertSpecialCharDialog.class), i18n);
+ i(InsertSpecialCharDialog.class), i18n);
presenter.init(panel);
return presenter;
}
}, new Factory<InsertSpecialUTF8CharPanel>(InsertSpecialUTF8CharPanel.class) {
@Override
public InsertSpecialUTF8CharPanel create() {
- return new InsertSpecialUTF8CharPanel(i18n, $(InsertSpecialCharDialog.class));
+ return new InsertSpecialUTF8CharPanel(i18n, i(InsertSpecialCharDialog.class));
}
});
@@ -502,14 +501,14 @@
register(MediaUtils.class, new Factory<MediaUtils>(MediaUtils.class) {
@Override
public MediaUtils create() {
- return new MediaUtils($(Session.class), $(FileDownloadUtils.class));
+ return new MediaUtils(i(Session.class), i(FileDownloadUtils.class));
}});
register(InsertMediaGroup.class, new Factory<InsertMediaExt>(InsertMediaExt.class) {
@Override
public InsertMediaExt create() {
- final InsertMediaExtPresenter presenter = new InsertMediaExtPresenter($(InsertMediaDialog.class), $(ExternalMediaRegistry.class));
- final InsertMediaExtPanel panel = new InsertMediaExtPanel(presenter, i18n, $(ExternalMediaRegistry.class));
+ final InsertMediaExtPresenter presenter = new InsertMediaExtPresenter(i(InsertMediaDialog.class), i(ExternalMediaRegistry.class));
+ final InsertMediaExtPanel panel = new InsertMediaExtPanel(presenter, i18n, i(ExternalMediaRegistry.class));
presenter.init(panel);
return presenter;
}
@@ -519,7 +518,7 @@
@Override
public InsertMediaDialog create() {
final InsertMediaDialogPresenter presenter = new InsertMediaDialogPresenter();
- final InsertMediaDialogPanel panel = new InsertMediaDialogPanel(presenter, i18n, $(Images.class), $(InsertMediaGroup.class));
+ final InsertMediaDialogPanel panel = new InsertMediaDialogPanel(presenter, i18n, i(Images.class), i(InsertMediaGroup.class));
presenter.init(panel);
return presenter;
}
@@ -528,13 +527,13 @@
register(Singleton.class, new Factory<ExternalMediaRegistry>(ExternalMediaRegistry.class) {
@Override
public ExternalMediaRegistry create() {
- return new ExternalMediaRegistry($(Session.class).getInitData().getExtMediaDescrips());
+ return new ExternalMediaRegistry(i(Session.class).getInitData().getExtMediaDescrips());
}});
register(Singleton.class, new Factory<BasicGuiBinding>(BasicGuiBinding.class) {
@Override
public BasicGuiBinding create() {
- return new BasicGuiBinding($(GuiBindingsRegister.class));
+ return new BasicGuiBinding(i(GuiBindingsRegister.class));
}
});
@@ -545,25 +544,25 @@
}
@Override
public void onAfterCreated(final GuiBindingsRegister instance) {
- $(BasicGuiBinding.class);
+ i(BasicGuiBinding.class);
}
});
register(Singleton.class, new Factory<TestButton>(TestButton.class) {
@Override
public TestButton create() {
- final TestButton btn = new TestButton($(WorkspaceSkeleton.class), $(GuiBindingsRegister.class), $(ImgResources.class));
+ final TestButton btn = new TestButton(i(WorkspaceSkeleton.class), i(GuiBindingsRegister.class), i(ImgResources.class));
return btn;
}
});
- // $(TestButton.class);
+ // i(TestButton.class);
- $(ApplicationComponentGroup.class).createAll();
- $(ToolGroup.class).createAll();
- $(Application.class).start();
- //$(HelloWorld.class);
+ i(ApplicationComponentGroup.class).createAll();
+ i(ToolGroup.class).createAll();
+ i(Application.class).start();
+ //i(HelloWorld.class);
}
}
\ No newline at end of file
Deleted: 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/AbstractRTEAction.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,30 +0,0 @@
-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
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,51 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTEditor {
-
- ActionToolbarPosition TOPBAR = new ActionToolbarPosition("rte-topbar");
- ActionToolbarPosition SNDBAR = new ActionToolbarPosition("rte-sndbar");;
- ActionToolbarPosition LINKCTX = new ActionToolbarPosition("rte-linkctx");;
-
- void addAction(ActionDescriptor<Object> action);
-
- void addActions(ActionCollection<Object> actions);
-
- void addOnEditListener(Listener0 listener);
-
- void attach();
-
- ActionAddCondition<Object> canBeBasic();
-
- ActionAddCondition<Object> canBeExtended();
-
- void detach();
-
- View getEditorArea();
-
- String getHtml();
-
- ActionToolbar<Object> getSndBar();
-
- String getText();
-
- ActionToolbar<Object> getTopBar();
-
- void reset();
-
- void setExtended(boolean extended);
-
- void setFocus(boolean focus);
-
- void setHtml(String html);
-
- void setText(String text);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,443 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-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.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.insertlink.LinkExecutableUtils;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-import org.xwiki.gwt.dom.client.DocumentFragment;
-import org.xwiki.gwt.dom.client.Range;
-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.KeyCodes;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.DeferredCommand;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.FocusListener;
-import com.google.gwt.user.client.ui.Widget;
-
-@SuppressWarnings("deprecation")
-public class RTEditorPanel extends RichTextArea implements RTEditorView {
-
- private class EventListener implements FocusListener {
-
- public void onFocus(final Widget sender) {
- presenter.onEditorFocus();
- }
-
- public void onLostFocus(final Widget sender) {
- presenter.onLostFocus();
- }
- }
- 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 GlobalShortcutRegister globalShortcutReg;
- private final RTELinkPopup linkCtxMenu;
-
- public RTEditorPanel(final RTEditorPresenter presenter, final I18nUITranslationService i18n,
- final ActionManager actionManager, final GlobalShortcutRegister globalShortcutReg) {
- this.presenter = presenter;
- this.i18n = i18n;
- this.actionManager = actionManager;
- this.globalShortcutReg = globalShortcutReg;
- basic = getBasicFormatter();
- extended = getExtendedFormatter();
- shortcutRegister = new ShortcutRegister();
- final EventListener listener = new EventListener();
- addFocusListener(listener);
- setWidth("96%");
- setHeight("100%");
- linkCtxMenu = new RTELinkPopup();
- }
-
- 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 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("" + height);
- }
-
- public boolean canBeBasic() {
- return basic != null;
- }
-
- public boolean canBeExtended() {
- return extended != null;
- }
-
- public void copy() {
- extended.copy();
- }
-
- public void createLink(final String url) {
- extended.createLink(url);
- }
-
- public void cut() {
- extended.cut();
- }
-
- public void delete() {
- extended.delete();
- }
-
- public void focus() {
- setFocus(true);
- }
-
- public LinkInfo getLinkInfoIfHref() {
- LinkInfo linkinfo = null;
- final org.xwiki.gwt.dom.client.Element selectedAnchor = selectAndGetLink();
- if (selectedAnchor != null) {
- linkinfo = LinkInfo.parse(selectedAnchor);
- } else {
- linkinfo = new LinkInfo(getSelectionText());
- }
- Log.debug("Link info: " + linkinfo);
- return linkinfo;
- }
-
- public void getRangeInfo() {
- // Selection selection = getSelection();
- // String info = "range count: " + selection.getRangeCount() +
- // "<br/>focus offset: " + selection.getFocusOffset()
- // + "<br/>anchor offset:" + selection.getAnchorOffset() +
- // "<br/>range 0 as html: "
- // + selection.getRangeAt(0).toHTML();
- // NotifyUser.info(info);
- final String info = "range count: " + getFstRange().getCommonAncestorContainer().getFirstChild().getNodeName();
- NotifyUser.info(info);
- }
-
- public String getSelectionText() {
- return getFstRange().cloneContents().getInnerText();
- }
-
- public void hideLinkCtxMenu() {
- linkCtxMenu.hide();
- }
-
- public void insertBlockquote() {
- final DocumentFragment extracted = getFstRange().cloneContents();
- // delete();
- insertHtml("<blockquote>" + extracted.getInnerHTML() + "</blockquote>");
- focus();
- }
-
- public void insertComment(final String author) {
- final String comment = null;
- createCommentAndSelectIt(author, comment);
- }
-
- public void insertCommentNotUsingSelection(final String author) {
- getFstRange().collapse(false);
- createCommentAndSelectIt(author, null);
- focus();
- }
-
- public void insertCommentUsingSelection(final String author) {
- final DocumentFragment extracted = getFstRange().cloneContents();
- extended.delete();
- final String comment = extracted.getInnerText();
- createCommentAndSelectIt(author, comment);
- focus();
- }
-
- public void insertHorizontalRule() {
- extended.insertHorizontalRule();
- }
-
- public void insertHtml(final String html) {
- extended.insertHtml(html);
- }
-
- public void insertImage(final String url) {
- extended.insertImage(url);
- }
-
- public void insertOrderedList() {
- extended.insertOrderedList();
- }
-
- public void insertUnorderedList() {
- extended.insertUnorderedList();
- }
-
- public boolean isAnythingSelected() {
- return !getDocument().getSelection().isCollapsed();
- }
-
- public boolean isBold() {
- return basic.isBold();
- }
-
- public boolean isCollapsed() {
- return getFstRange().isCollapsed();
- }
-
- public boolean isCtxMenuVisible() {
- return linkCtxMenu.isVisible();
- }
-
- public boolean isItalic() {
- return basic.isItalic();
- }
-
- public boolean isLink() {
- if (isAttached() && LinkExecutableUtils.getSelectedAnchor(this) != null) {
- return true;
- } else {
- return false;
- }
- }
-
- public boolean isStrikethrough() {
- return extended.isStrikethrough();
- }
-
- public boolean isSubscript() {
- return basic.isSubscript();
- }
-
- public boolean isSuperscript() {
- return basic.isSuperscript();
- }
-
- public boolean isUnderlined() {
- return basic.isUnderlined();
- }
-
- public void justifyCenter() {
- basic.setJustification(Justification.CENTER);
- }
-
- public void justifyLeft() {
- basic.setJustification(Justification.LEFT);
- }
-
- public void justifyRight() {
- basic.setJustification(Justification.RIGHT);
- }
-
- public void leftIndent() {
- extended.leftIndent();
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void onBrowserEvent(final Event event) {
- switch (DOM.eventGetType(event)) {
- case Event.ONCLICK:
- updateStatus();
- updateLinkInfo();
- super.onBrowserEvent(event);
- break;
- case Event.ONKEYDOWN:
- final ActionItem rtaActionItem = shortcutRegister.get(event);
- final ActionItem actionItem = rtaActionItem != null ? rtaActionItem : globalShortcutReg.get(event);
- if (actionItem != null) {
- updateStatus();
- fireEdit();
- event.cancelBubble(true);
- event.preventDefault();
- actionManager.doAction(actionItem);
- updateStatus();
- } else {
- super.onBrowserEvent(event);
- updateStatus();
- updateLinkInfo();
- if (isAnEditionKey(event.getKeyCode())) {
- fireEdit();
- }
- }
- break;
- default:
- // Rest of events
- super.onBrowserEvent(event);
- updateStatus();
- }
- }
-
- public void paste() {
- extended.paste();
- }
-
- public void redo() {
- extended.redo();
- }
-
- public void removeFormat() {
- extended.removeFormat();
- }
-
- public void rightIndent() {
- extended.rightIndent();
- }
-
- public void selectAll() {
- basic.selectAll();
- }
-
- public void selectLink() {
- selectAndGetLink();
- }
-
- public void setBackColor(final String color) {
- basic.setBackColor(color);
- }
-
- public void setFontName(final String name) {
- basic.setFontName(name);
- }
-
- public void setFontSize(final FontSize size) {
- basic.setFontSize(size);
- }
-
- public void setForeColor(final String color) {
- basic.setForeColor(color);
- }
-
- public void showLinkCtxMenu() {
- DeferredCommand.addCommand(new Command() {
- public void execute() {
- final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(RTEditorPanel.this);
- if (selectedAnchor != null) {
- linkCtxMenu.show(RTEditorPanel.this.getAbsoluteLeft() + selectedAnchor.getAbsoluteLeft(),
- RTEditorPanel.this.getAbsoluteTop() + selectedAnchor.getAbsoluteTop() + 20);
- }
- }
- });
-
- }
-
- public void toggleBold() {
- basic.toggleBold();
- }
-
- public void toggleItalic() {
- basic.toggleItalic();
- }
-
- public void toggleStrikethrough() {
- extended.toggleStrikethrough();
- }
-
- public void toggleSubscript() {
- basic.toggleSubscript();
- }
-
- public void toggleSuperscript() {
- basic.toggleSuperscript();
- }
-
- public void toggleUnderline() {
- basic.toggleUnderline();
- }
-
- public void undo() {
- extended.undo();
- }
-
- public void unlink() {
- extended.removeLink();
- }
-
- protected void fireEdit() {
- presenter.fireOnEdit();
- }
-
- private void createCommentAndSelectIt(final String author, final String comment) {
- final Element commentEl = createCommentElement(author, comment);
- final Range innerCommentRange = getDocument().createRange();
- getFstRange().insertNode(commentEl);
- innerCommentRange.selectNodeContents(commentEl.getFirstChild());
- getSelection().addRange(innerCommentRange);
- fireEdit();
- }
-
- private Element createCommentElement(final String userName, final String insertComment) {
- final String time = i18n.formatDateWithLocale(new Date(), true);
- final Element span = getDocument().createSpanElement();
- final String comment = insertComment != null ? insertComment : i18n.t("type your comment here");
- span.setInnerHTML("<em>" + comment + "</em> -" + userName + " " + time);
- DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
- // insertHtml(" " + span.getString() + " ");
- return span;
- }
-
- private Range getFstRange() {
- return getSelection().getRangeAt(0);
- }
-
- private Selection getSelection() {
- return getDocument().getSelection();
- }
-
- private boolean isAnEditionKey(final int keyCode) {
- if (keyCode != KeyCodes.KEY_HOME && keyCode != KeyCodes.KEY_END && keyCode != KeyCodes.KEY_UP
- && keyCode != KeyCodes.KEY_DOWN && keyCode != KeyCodes.KEY_LEFT && keyCode != KeyCodes.KEY_RIGHT
- && keyCode != KeyCodes.KEY_PAGEDOWN && keyCode != KeyCodes.KEY_PAGEUP && keyCode != KeyCodes.KEY_ESCAPE) {
- return true;
- } else {
- return false;
- }
- }
-
- private org.xwiki.gwt.dom.client.Element selectAndGetLink() {
- final org.xwiki.gwt.dom.client.Element selectedAnchor = LinkExecutableUtils.getSelectedAnchor(this);
- if (selectedAnchor != null) {
- final Range range = getDocument().createRange();
- range.selectNode(selectedAnchor);
- getSelection().addRange(range);
- }
- return selectedAnchor;
- }
-
- private void updateLinkInfo() {
- presenter.updateLinkInfo();
- }
-
- /**
- * Updates the status of all the stateful buttons.
- */
- private void updateStatus() {
- presenter.updateStatus();
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,1051 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPushButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
-import org.ourproject.kune.platf.client.state.Session;
-import org.ourproject.kune.platf.client.ui.img.ImgConstants;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.ImageInfo;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-import org.ourproject.kune.platf.client.ui.rte.insertmedia.InsertMediaDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertspecialchar.InsertSpecialCharDialog;
-import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Event0;
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.client.ioc.Provider;
-import com.google.gwt.libideas.resources.client.ImageResource;
-
-public class RTEditorPresenter implements RTEditor {
-
- private final String fontNames[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" };
- private final String fontSizes[] = { "Extra small", "Very small (normal)", "Small", "Medium", "Large",
- "Very large", "Extra large" };
- private static final RichTextArea.FontSize[] FONT_SIZES = new RichTextArea.FontSize[] {
- RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
- RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
- RichTextArea.FontSize.XX_LARGE };
-
- private static final String EDIT_MENU = "Edit";
- private static final String INSERT_MENU = "Insert";
- private static final String FORMAT_MENU = "Format";
- private RTEditorView view;
- private boolean extended;
- private final AccessRolDTO accessRol;
- private final I18nTranslationService i18n;
- private final Session session;
- private final ActionItemCollection<Object> actions;
- private final RTEImgResources imgResources;
- private final RTEActionTopToolbar topBar;
- private final RTEActionSndToolbar sndBar;
- private ActionToolbarPushButtonDescriptor<Object> bold;
- private ActionToolbarPushButtonDescriptor<Object> italic;
- private ActionToolbarPushButtonDescriptor<Object> underline;
- private ActionToolbarPushButtonDescriptor<Object> strikethrough;
- private final Event0 onEdit;
- private final DeferredCommandWrapper deferred;
- private final ActionAddCondition<Object> canBeBasic;
- private final ActionAddCondition<Object> canBeExtended;
- private final Provider<ColorWebSafePalette> paletteProvider;
- private final Provider<InsertLinkDialog> insertLinkDialog;
- private final Provider<EditHtmlDialog> editHtmlDialog;
- private final Provider<InsertImageDialog> insertImageDialog;
- private final Provider<InsertTableDialog> insertTableDialog;
- private Listener<String> insertTableListener;
- private Listener<LinkInfo> insertLinkListener;
- private Listener<ImageInfo> insertImageListener;
- private Listener<String> insertMediaListener;
- private Listener<String> updateHtmlListener;
- private ActionToolbarButtonDescriptor<Object> insertTableBtn;
- private final Provider<InsertSpecialCharDialog> insertSpecialCharDialog;
- protected Listener<String> insertSpecialCharListener;
- private final Provider<InsertMediaDialog> insertMediaDialog;
- protected ColorWebSafePalette palette;
-
- public RTEditorPresenter(final I18nTranslationService i18n, final Session session,
- final RTEActionTopToolbar topBar, final RTEActionSndToolbar sndBar, final RTEImgResources imgResources,
- final Provider<InsertLinkDialog> textEditorInsertElement, final Provider<ColorWebSafePalette> palette,
- final Provider<EditHtmlDialog> editHtmlDialog, final Provider<InsertImageDialog> insertImageDialog,
- final Provider<InsertMediaDialog> insertMediaDialog, final Provider<InsertTableDialog> insertTableDialog,
- final Provider<InsertSpecialCharDialog> insertSpecialCharDialog, final DeferredCommandWrapper deferred) {
- this.i18n = i18n;
- this.session = session;
- this.topBar = topBar;
- this.sndBar = sndBar;
- this.insertLinkDialog = textEditorInsertElement;
- this.paletteProvider = palette;
- this.editHtmlDialog = editHtmlDialog;
- this.insertImageDialog = insertImageDialog;
- this.insertMediaDialog = insertMediaDialog;
- this.insertTableDialog = insertTableDialog;
- this.insertSpecialCharDialog = insertSpecialCharDialog;
- this.deferred = deferred;
- styleToolbar(sndBar);
- sndBar.attach();
- this.imgResources = imgResources;
- extended = true;
- accessRol = AccessRolDTO.Editor;
- actions = new ActionItemCollection<Object>();
- this.onEdit = new Event0("onRTEEdit");
- canBeBasic = new ActionAddCondition<Object>() {
- public boolean mustBeAdded(final Object param) {
- return view.canBeBasic();
- }
- };
- canBeExtended = new ActionAddCondition<Object>() {
- public boolean mustBeAdded(final Object param) {
- return isExtended();
- }
- };
- }
-
- public void addAction(final ActionDescriptor<Object> action) {
- actions.add(withNoItem(action));
- }
-
- public void addActions(final ActionCollection<Object> actioncollection) {
- actions.addAll(withNoItem(actioncollection));
- }
-
- public void addOnEditListener(final Listener0 listener) {
- onEdit.add(listener);
- }
-
- public void adjustSize(final int height) {
- view.adjustSize(height);
- }
-
- public void attach() {
- topBar.clear();
- sndBar.clear();
- topBar.addActions(actions, TOPBAR);
- sndBar.addActions(actions, SNDBAR);
- view.addActions(actions);
- }
-
- public ActionAddCondition<Object> canBeBasic() {
- return new ActionAddCondition<Object>() {
- public boolean mustBeAdded(final Object param) {
- return view.canBeBasic();
- }
- };
-
- }
-
- public ActionAddCondition<Object> canBeExtended() {
- return new ActionAddCondition<Object>() {
- public boolean mustBeAdded(final Object param) {
- return view.canBeExtended();
- }
- };
- }
-
- public void detach() {
- topBar.clear();
- sndBar.clear();
- }
-
- public void fireOnEdit() {
- onEdit.fire();
- }
-
- public View getEditorArea() {
- return view;
- }
-
- public String getHtml() {
- return view.getHTML();
- }
-
- public ActionToolbar<Object> getSndBar() {
- return sndBar;
- }
-
- public String getText() {
- return view.getText();
- }
-
- public ActionToolbar<Object> getTopBar() {
- return topBar;
- }
-
- public void init(final RTEditorView view) {
- this.view = view;
- createBasicActions();
- }
-
- public void onEditorFocus() {
- hideMenus();
- }
-
- public void onLostFocus() {
- }
-
- public void reset() {
- hideMenus();
- hideLinkCtxMenu();
- }
-
- public void setExtended(final boolean extended) {
- this.extended = extended;
- }
-
- public void setFocus(final boolean focus) {
- view.setFocus(focus);
- }
-
- public void setHtml(final String html) {
- view.setHTML(html);
- view.focus();
- }
-
- public void setText(final String text) {
- view.setText(text);
- view.focus();
- }
-
- public void updateLinkInfo() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- if (isExtended() && view.isLink()) {
- view.showLinkCtxMenu();
- } else {
- hideLinkCtxMenu();
- }
- }
- });
- }
-
- public void updateStatus() {
- if (view.canBeBasic()) {
- sndBar.setPushButtonPressed(bold, view.isBold());
- sndBar.setPushButtonPressed(italic, view.isItalic());
- sndBar.setPushButtonPressed(underline, view.isUnderlined());
- }
- if (isExtended()) {
- sndBar.setPushButtonPressed(strikethrough, view.isStrikethrough());
- }
- }
-
- private void createBasicActions() {
- ActionToolbarMenuDescriptor<Object> selectAll = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.selectAll();
- }
- });
- selectAll.setIconCls(getCssName(imgResources.selectall()));
- selectAll.setShortcut(new ShortcutDescriptor(true, 'A'));
- selectAll.setTextDescription(i18n.t("Select all"));
- selectAll.setParentMenuTitle(i18n.t(EDIT_MENU));
- selectAll.setAddCondition(canBeBasic);
- selectAll.setTopSeparator(true);
- selectAll.setBottomSeparator(true);
-
- bold = new ActionToolbarPushButtonDescriptor<Object>(accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- view.toggleBold();
- fireOnEdit();
- }
- });
- bold.setIconCls(getCssName(imgResources.bold()));
- bold.setToolTip(i18n.t("Bold"));
- bold.setShortcut(new ShortcutDescriptor(true, 'B'));
- bold.setAddCondition(canBeBasic);
-
- italic = new ActionToolbarPushButtonDescriptor<Object>(accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- view.toggleItalic();
- fireOnEdit();
- }
- });
- italic.setIconCls(getCssName(imgResources.italic()));
- italic.setToolTip(i18n.t("Italic"));
- italic.setShortcut(new ShortcutDescriptor(true, 'I'));
- italic.setAddCondition(canBeBasic);
- italic.setAddCondition(canBeBasic);
-
- underline = new ActionToolbarPushButtonDescriptor<Object>(accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- view.toggleUnderline();
- fireOnEdit();
- }
- });
- underline.setIconCls(getCssName(imgResources.underline()));
- underline.setToolTip(i18n.t("Underline"));
- underline.setShortcut(new ShortcutDescriptor(true, 'U'));
- underline.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> subscript = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.toggleSubscript();
- fireOnEdit();
- }
- });
- subscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
- subscript.setTextDescription(i18n.t("Subscript"));
- subscript.setIconCls(getCssName(imgResources.subscript()));
- subscript.setShortcut(new ShortcutDescriptor(true, 188, ","));
- subscript.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> superscript = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.toggleSuperscript();
- fireOnEdit();
- }
- });
- superscript.setParentMenuTitle(i18n.t(FORMAT_MENU));
- superscript.setTextDescription(i18n.t("Superscript"));
- superscript.setIconCls(getCssName(imgResources.superscript()));
- superscript.setShortcut(new ShortcutDescriptor(true, 190, "."));
- superscript.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyLeft = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- view.justifyLeft();
- fireOnEdit();
- }
- });
- justifyLeft.setIconCls(getCssName(imgResources.alignleft()));
- justifyLeft.setToolTip(i18n.t("Left Justify"));
- justifyLeft.setShortcut(new ShortcutDescriptor(true, 'L'));
- justifyLeft.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyCentre = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- view.justifyCenter();
- fireOnEdit();
- }
- });
- justifyCentre.setIconCls(getCssName(imgResources.centerpara()));
- justifyCentre.setToolTip(i18n.t("Centre Justify"));
- justifyCentre.setShortcut(new ShortcutDescriptor(true, 'E'));
- justifyCentre.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> justifyRight = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- view.justifyRight();
- fireOnEdit();
- }
- });
- justifyRight.setIconCls(getCssName(imgResources.alignright()));
- justifyRight.setToolTip(i18n.t("Right Justify"));
- justifyRight.setShortcut(new ShortcutDescriptor(true, 'R'));
- justifyRight.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.undo();
- fireOnEdit();
- }
- });
- undo.setShortcut(new ShortcutDescriptor(true, 'Z'));
- undo.setTextDescription(i18n.t("Undo"));
- undo.setParentMenuTitle(i18n.t(EDIT_MENU));
- undo.setAddCondition(canBeExtended);
- undo.setIconCls(getCssName(imgResources.undo()));
-
- ActionToolbarMenuDescriptor<Object> redo = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.redo();
- fireOnEdit();
- }
- });
- redo.setShortcut(new ShortcutDescriptor(true, 'Y'));
- redo.setTextDescription(i18n.t("Redo"));
- redo.setParentMenuTitle(i18n.t(EDIT_MENU));
- redo.setAddCondition(canBeExtended);
- redo.setBottomSeparator(true);
- redo.setIconCls(getCssName(imgResources.redo()));
-
- ActionToolbarButtonDescriptor<Object> undoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.undo();
- fireOnEdit();
- }
- });
- undoBtn.setToolTip(i18n.t("Undo"));
- undoBtn.setAddCondition(canBeExtended);
- undoBtn.setIconCls(getCssName(imgResources.undo()));
- undoBtn.setPosition(0);
-
- ActionToolbarButtonDescriptor<Object> redoBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.redo();
- fireOnEdit();
- }
- });
- redoBtn.setToolTip(i18n.t("Redo"));
- redoBtn.setAddCondition(canBeExtended);
- redoBtn.setIconCls(getCssName(imgResources.redo()));
- redoBtn.setPosition(1);
- redoBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- ActionToolbarMenuDescriptor<Object> copy = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.copy();
- }
- });
- copy.setShortcut(new ShortcutDescriptor(true, 'C'));
- copy.setTextDescription(i18n.t("Copy"));
- copy.setParentMenuTitle(i18n.t(EDIT_MENU));
- copy.setAddCondition(canBeExtended);
- copy.setIconCls(getCssName(imgResources.copy()));
-
- ActionToolbarMenuDescriptor<Object> cut = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.cut();
- fireOnEdit();
- }
- });
- cut.setShortcut(new ShortcutDescriptor(true, 'X'));
- cut.setTextDescription(i18n.t("Cut"));
- cut.setParentMenuTitle(i18n.t(EDIT_MENU));
- cut.setAddCondition(canBeExtended);
- cut.setIconCls(getCssName(imgResources.cut()));
-
- ActionToolbarMenuDescriptor<Object> paste = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.paste();
- fireOnEdit();
- }
- });
- paste.setShortcut(new ShortcutDescriptor(true, 'V'));
- paste.setTextDescription(i18n.t("Paste"));
- paste.setParentMenuTitle(i18n.t(EDIT_MENU));
- paste.setAddCondition(canBeExtended);
- paste.setIconCls(getCssName(imgResources.paste()));
-
- ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
-
- public void onEvent() {
- if (updateHtmlListener == null) {
- updateHtmlListener = new Listener<String>() {
- public void onEvent(final String html) {
- view.setHTML(html);
- fireOnEdit();
- }
- };
- }
- EditHtmlDialog dialog = editHtmlDialog.get();
- dialog.setUpdateListener(updateHtmlListener);
- dialog.show();
- hideLinkCtxMenu();
- dialog.setHtml(view.getHTML());
- }
- });
- editHtml.setIconCls(getCssName(imgResources.edithtml()));
- editHtml.setTextDescription(i18n.t("Edit HTML"));
- editHtml.setParentMenuTitle(i18n.t(EDIT_MENU));
- editHtml.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.focus();
- final String author = session.isLogged() ? session.getCurrentUser().getShortName()
- : i18n.t("anonymous user");
- if (view.isAnythingSelected()) {
- NotifyUser.askConfirmation(i18n.t("Insert a comment"),
- i18n.t("Include the selected text in the comment?"), new Listener0() {
- public void onEvent() {
- // include selection in
- // comment
- view.insertCommentUsingSelection(author);
- }
- }, new Listener0() {
- public void onEvent() {
- // not include selection in
- // comment;
- view.insertCommentNotUsingSelection(author);
- }
- });
- } else {
- // Nothing selected > create comment in
- // insertion point
- view.insertComment(author);
- }
- }
- });
- }
- });
- comment.setEnableCondition(new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(final Object param) {
- return session.isLogged();
- }
- });
- comment.setShortcut(new ShortcutDescriptor(true, 'M'));
- comment.setTextDescription(i18n.t("Comment"));
- comment.setParentMenuTitle(i18n.t(INSERT_MENU));
- comment.setEnableCondition(isInsertHtmlSupported());
- comment.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> hr = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.focus();
- view.insertHorizontalRule();
- fireOnEdit();
- }
- });
- hr.setTextDescription(i18n.t("Horizontal line"));
- hr.setShortcut(new ShortcutDescriptor(true, true, ' ', "Space"));
- hr.setIconCls(getCssName(imgResources.hfixedline()));
- hr.setParentMenuTitle(i18n.t(INSERT_MENU));
- hr.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> blockquote = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- view.focus();
- view.insertBlockquote();
- fireOnEdit();
- }
- });
- blockquote.setTextDescription(i18n.t("Block Quotation"));
- blockquote.setParentMenuTitle(i18n.t(FORMAT_MENU));
- blockquote.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.focus();
- view.insertHorizontalRule();
- fireOnEdit();
- }
- });
- hrButton.setIconCls(getCssName(imgResources.hfixedline()));
- hrButton.setToolTip(i18n.t("Horizontal line"));
- hrButton.setAddCondition(canBeExtended);
-
- strikethrough = new ActionToolbarPushButtonDescriptor<Object>(accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- view.toggleStrikethrough();
- fireOnEdit();
- }
- });
- strikethrough.setIconCls(getCssName(imgResources.strikeout()));
- strikethrough.setToolTip(i18n.t("Strikethrough"));
- strikethrough.setRightSeparator(ActionToolbarButtonSeparator.separator);
- strikethrough.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> decreaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- view.leftIndent();
- fireOnEdit();
- }
- });
- decreaseIndent.setIconCls(getCssName(imgResources.decrementindent()));
- decreaseIndent.setToolTip(i18n.t("Decrease Indent"));
- decreaseIndent.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> increaseIndent = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- view.rightIndent();
- fireOnEdit();
- }
- });
- increaseIndent.setIconCls(getCssName(imgResources.incrementindent()));
- increaseIndent.setToolTip(i18n.t("Increase Indent"));
- increaseIndent.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> ol = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.insertOrderedList();
- fireOnEdit();
- }
- });
- ol.setIconCls(getCssName(imgResources.defaultnumbering()));
- ol.setToolTip(i18n.t("Numbered List"));
- ol.setShortcut(new ShortcutDescriptor(true, '7'));
- ol.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> ul = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.insertUnorderedList();
- fireOnEdit();
- }
- });
- ul.setIconCls(getCssName(imgResources.defaultbullet()));
- ul.setToolTip(i18n.t("Bullet List"));
- ul.setShortcut(new ShortcutDescriptor(true, '8'));
- ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
- ul.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> imgBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- if (insertImageListener == null) {
- insertImageListener = new Listener<ImageInfo>() {
- public void onEvent(final ImageInfo imageInfo) {
- String img = imageInfo.toString();
- Log.debug("Image: " + imageInfo);
- view.focus();
- view.insertHtml(img);
- fireOnEdit();
- }
- };
- }
- InsertImageDialog dialog = insertImageDialog.get();
- dialog.reset();
- dialog.setOnCreateImage(insertImageListener);
- dialog.show();
- hideLinkCtxMenu();
- }
- });
- }
- });
- imgBtn.setIconCls(getCssName(imgResources.images()));
- imgBtn.setToolTip(i18n.t("Insert Image"));
- imgBtn.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> imgMenu = new ActionToolbarMenuDescriptor<Object>(imgBtn);
- imgMenu.setTextDescription(i18n.t("Image..."));
- imgMenu.setToolTip(null);
- imgMenu.setParentMenuTitle(i18n.t(INSERT_MENU));
- imgMenu.setActionPosition(TOPBAR);
-
- final ActionToolbarMenuDescriptor<Object> insertMedia = new ActionToolbarMenuDescriptor<Object>(accessRol,
- TOPBAR, new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- if (insertMediaListener == null) {
- insertMediaListener = new Listener<String>() {
- public void onEvent(final String html) {
- Log.debug("Media: " + html);
- view.focus();
- view.insertHtml(html);
- fireOnEdit();
- }
- };
- }
- InsertMediaDialog dialog = insertMediaDialog.get();
- dialog.setOnCreate(insertMediaListener);
- dialog.show();
- hideLinkCtxMenu();
- }
- });
- }
- });
- insertMedia.setIconCls(getCssName(imgResources.film()));
- insertMedia.setTextDescription(i18n.t("Audio/Video..."));
- insertMedia.setAddCondition(canBeExtended);
- insertMedia.setParentMenuTitle(i18n.t(INSERT_MENU));
- ActionToolbarButtonDescriptor<Object> createOrEditLinkBtn = new ActionToolbarButtonDescriptor<Object>(
- accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- if (insertLinkListener == null) {
- insertLinkListener = new Listener<LinkInfo>() {
- public void onEvent(final LinkInfo linkInfo) {
- String link = linkInfo.toString();
- Log.debug("Link: " + link);
- view.focus();
- view.insertHtml(link);
- fireOnEdit();
- }
- };
- }
- LinkInfo linkInfo = view.getLinkInfoIfHref();
- InsertLinkDialog dialog = insertLinkDialog.get();
- dialog.setLinkInfo(linkInfo);
- dialog.setOnCreateLink(insertLinkListener);
- dialog.show();
- hideLinkCtxMenu();
- String href = linkInfo.getHref();
- if (href.length() > 0) {
- if (href.startsWith("mailto")) {
- dialog.activateTab(2);
- } else {
- dialog.activateTab(1);
- }
- }
- }
- });
- }
- });
- createOrEditLinkBtn.setIconCls(getCssName(imgResources.link()));
- createOrEditLinkBtn.setToolTip(i18n.t("Create or Edit Link"));
- createOrEditLinkBtn.setShortcut(new ShortcutDescriptor(true, 'K'));
- createOrEditLinkBtn.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> createOrEditLink = new ActionToolbarMenuDescriptor<Object>(
- createOrEditLinkBtn);
- createOrEditLink.setTextDescription(i18n.t("Link...") + createOrEditLinkBtn.getShortcutToS());
- createOrEditLink.setToolTip(null);
- createOrEditLink.setShortcut(null);
- createOrEditLink.setActionPosition(TOPBAR);
- createOrEditLink.setParentMenuTitle(i18n.t(INSERT_MENU));
-
- ActionToolbarMenuDescriptor<Object> editLinkCtx = new ActionToolbarMenuDescriptor<Object>(createOrEditLink);
- editLinkCtx.setTextDescription(i18n.t("Change"));
- editLinkCtx.setToolTip(null);
- editLinkCtx.setShortcut(null);
- editLinkCtx.setActionPosition(LINKCTX);
-
- ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- if (view.isAnythingSelected()) {
- // we try to unlink the selection
- } else {
- // we try to select the complete link
- view.selectLink();
- }
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.unlink();
- hideLinkCtxMenu();
- fireOnEdit();
- }
- });
- }
- });
- removeLink.setIconCls(getCssName(imgResources.linkbreak()));
- removeLink.setToolTip(i18n.t("Remove Link"));
- removeLink.setShortcut(new ShortcutDescriptor(true, true, 'K'));
- removeLink.setAddCondition(canBeExtended);
-
- ActionToolbarMenuDescriptor<Object> removeLinkCtx = new ActionToolbarMenuDescriptor<Object>(removeLink);
- removeLinkCtx.setTextDescription(i18n.t("Remove"));
- removeLinkCtx.setToolTip(null);
- removeLinkCtx.setShortcut(null);
- removeLinkCtx.setActionPosition(LINKCTX);
-
- final ActionToolbarMenuDescriptor<Object> removeFormat = new ActionToolbarMenuDescriptor<Object>(accessRol,
- TOPBAR, new Listener0() {
- public void onEvent() {
- view.removeFormat();
- fireOnEdit();
- }
- });
- removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
- ShortcutDescriptor ctrl_space = new ShortcutDescriptor(true, ' ', "Space");
- removeFormat.setTextDescription(i18n.t("Clear Formatting") + (ctrl_space.toString()));
- removeFormat.setAddCondition(canBeExtended);
- removeFormat.setParentMenuTitle(i18n.t(FORMAT_MENU));
- removeFormat.setBottomSeparator(true);
-
- final ActionToolbarButtonDescriptor<Object> removeFormatBtn = new ActionToolbarButtonDescriptor<Object>(
- accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- view.removeFormat();
- fireOnEdit();
- }
- });
- removeFormatBtn.setIconCls(getCssName(imgResources.removeFormat()));
- removeFormatBtn.setToolTip(i18n.t("Clear Formatting"));
- removeFormatBtn.setShortcut(ctrl_space);
- removeFormatBtn.setAddCondition(canBeExtended);
- removeFormatBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- final ActionToolbarMenuDescriptor<Object> insertSpecialChar = new ActionToolbarMenuDescriptor<Object>(
- accessRol, TOPBAR, new Listener0() {
- public void onEvent() {
- NotifyUser.showProgressLoading();
- if (insertSpecialCharListener == null) {
- insertSpecialCharListener = new Listener<String>() {
- public void onEvent(final String character) {
- view.insertHtml(character);
- }
- };
- }
- insertSpecialCharDialog.get().setOnInsertSpecialChar(insertSpecialCharListener);
- insertSpecialCharDialog.get().show();
- hideLinkCtxMenu();
- NotifyUser.hideProgress();
- }
- });
- insertSpecialChar.setIconCls(getCssName(imgResources.specialchars()));
- insertSpecialChar.setTextDescription(i18n.t("Special characters..."));
- insertSpecialChar.setAddCondition(canBeExtended);
- insertSpecialChar.setParentMenuTitle(i18n.t(INSERT_MENU));
- insertSpecialChar.setTopSeparator(true);
-
- final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
- TOPBAR, new Listener0() {
- public void onEvent() {
- onInsertTablePressed();
- }
- });
- insertTable.setIconCls(getCssName(imgResources.inserttable()));
- insertTable.setTextDescription(i18n.t("Table ..."));
- insertTable.setAddCondition(canBeExtended);
- insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
-
- insertTableBtn = new ActionToolbarButtonDescriptor<Object>(accessRol, SNDBAR, new Listener0() {
- public void onEvent() {
- onInsertTablePressed();
- }
- });
- insertTableBtn.setIconCls(getCssName(imgResources.inserttable()));
- insertTableBtn.setToolTip(i18n.t("Insert Table"));
- insertTableBtn.setAddCondition(canBeExtended);
- insertTableBtn.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- getPalette();
- palette.show(getActionLeftPosition(sndBar, insertTableBtn), getActionTopPosition(sndBar,
- removeFormatBtn), new Listener<String>() {
- public void onEvent(final String color) {
- palette.hide();
- view.setForeColor(color);
- fireOnEdit();
- }
- });
- hideLinkCtxMenu();
- }
- });
- fontColor.setIconCls(getCssName(imgResources.fontcolor()));
- fontColor.setToolTip(i18n.t("Text Colour"));
- fontColor.setAddCondition(canBeBasic);
-
- ActionToolbarButtonDescriptor<Object> backgroundColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
- SNDBAR, new Listener0() {
- public void onEvent() {
- getPalette();
- palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor),
- new Listener<String>() {
- public void onEvent(final String color) {
- palette.hide();
- view.setBackColor(color);
- fireOnEdit();
- }
- });
- hideLinkCtxMenu();
- }
- });
- backgroundColor.setIconCls(getCssName(imgResources.backcolor()));
- backgroundColor.setToolTip(i18n.t("Text Background Colour"));
- backgroundColor.setAddCondition(canBeBasic);
-
- final ActionToolbarMenuDescriptor<Object> devInfo = new ActionToolbarMenuDescriptor<Object>(accessRol, TOPBAR,
- new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- view.getRangeInfo();
- }
- });
- }
- });
- devInfo.setTextDescription(i18n.t("Developers info"));
- devInfo.setAddCondition(canBeExtended);
- devInfo.setParentMenuTitle(i18n.t(FORMAT_MENU));
- devInfo.setShortcut(new ShortcutDescriptor(false, true, false, 'I'));
-
- actions.add(withNoItem(bold));
- actions.add(withNoItem(italic));
- actions.add(withNoItem(underline));
- actions.add(withNoItem(strikethrough));
-
- actions.add(withNoItem(justifyLeft));
- actions.add(withNoItem(justifyCentre));
- actions.add(withNoItem(justifyRight));
-
- actions.add(withNoItem(undo));
- actions.add(withNoItem(redo));
- actions.add(withNoItem(copy));
- actions.add(withNoItem(cut));
- actions.add(withNoItem(paste));
- actions.add(withNoItem(selectAll));
- actions.add(withNoItem(editHtml));
- actions.add(withNoItem(removeFormat));
- actions.add(withNoItem(subscript));
- actions.add(withNoItem(superscript));
- actions.add(withNoItem(blockquote));
- actions.add(withNoItem(decreaseIndent));
- actions.add(withNoItem(increaseIndent));
- actions.add(withNoItem(ol));
- actions.add(withNoItem(ul));
- actions.add(withNoItem(removeFormatBtn));
- actions.add(withNoItem(hrButton));
- actions.add(withNoItem(imgBtn));
- actions.add(withNoItem(createOrEditLinkBtn));
- actions.add(withNoItem(removeLink));
- actions.add(withNoItem(insertTableBtn));
- actions.add(withNoItem(createOrEditLink));
- actions.add(withNoItem(imgMenu));
- actions.add(withNoItem(insertTable));
- actions.add(withNoItem(insertMedia));
- actions.add(withNoItem(insertSpecialChar));
- actions.add(withNoItem(comment));
- actions.add(withNoItem(hr));
- actions.add(withNoItem(undoBtn));
- actions.add(withNoItem(redoBtn));
- // actions.add(withNoItem(devInfo));
-
- for (String fontName : this.fontNames) {
- ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
- actions.add(withNoItem(fontNameAction));
- }
- for (int fontSize = 0; fontSize < fontSizes.length; fontSize++) {
- ActionToolbarMenuDescriptor<Object> fontSizeAction = createFontSizeAction(canBeBasic, fontSize,
- fontSizes[fontSize]);
- actions.add(withNoItem(fontSizeAction));
- }
- actions.add(withNoItem(fontColor));
- actions.add(withNoItem(backgroundColor));
-
- view.addCtxAction(withNoItem(removeLinkCtx));
- view.addCtxAction(withNoItem(editLinkCtx));
- }
-
- private ActionToolbarMenuDescriptor<Object> createFontNameAction(final ActionAddCondition<Object> canBeBasic,
- final String fontName) {
- final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.setFontName(fontName);
- fireOnEdit();
- }
- });
- font.setTextDescription("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>");
- font.setParentMenuTooltip(i18n.t("Font"));
- font.setParentMenuIconCls(getCssName(imgResources.charfontname()));
- font.setAddCondition(canBeBasic);
- return font;
- }
-
- private ActionToolbarMenuDescriptor<Object> createFontSizeAction(final ActionAddCondition<Object> canBeBasic,
- final int fontSize, final String fontSizeName) {
- final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, SNDBAR,
- new Listener0() {
- public void onEvent() {
- view.setFontSize(FONT_SIZES[fontSize]);
- fireOnEdit();
- }
- });
- font.setTextDescription("<font size=\"" + (fontSize + 1) + "\">" + i18n.t(fontSizeName) + "</font>");
- font.setParentMenuTooltip(i18n.t("Font size"));
- font.setParentMenuIconCls(getCssName(imgResources.fontheight()));
- font.setAddCondition(canBeBasic);
- font.setShortcut(new ShortcutDescriptor(true, 48 + fontSize));
- return font;
- }
-
- private int getActionLeftPosition(final ActionToolbar<Object> bar,
- final ActionToolbarButtonDescriptor<Object> action) {
- return bar.getLeftPosition(action);
- }
-
- private int getActionTopPosition(final ActionToolbar<Object> bar, final ActionToolbarButtonDescriptor<Object> action) {
- return bar.getTopPosition(action);
- }
-
- private String getCssName(final ImageResource imageResource) {
- return ImgConstants.CSS_SUFFIX + imageResource.getName();
- }
-
- private void getPalette() {
- if (palette == null) {
- palette = paletteProvider.get();
- }
- }
-
- private void hideLinkCtxMenu() {
- if (view.isCtxMenuVisible()) {
- view.hideLinkCtxMenu();
- }
- }
-
- private void hideMenus() {
- topBar.hideAllMenus();
- sndBar.hideAllMenus();
- if (palette != null) {
- palette.hide();
- }
- }
-
- private boolean isExtended() {
- return extended && view.canBeExtended();
- }
-
- private ActionEnableCondition<Object> isInsertHtmlSupported() {
- return new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(final Object param) {
- return true;
- }
- };
- }
-
- private void onInsertTablePressed() {
- if (insertTableListener == null) {
- insertTableListener = new Listener<String>() {
- public void onEvent(final String table) {
- if (view.isAnythingSelected()) {
- // move to end of selection?
- }
- view.insertHtml(table);
- fireOnEdit();
- }
- };
- }
- insertTableDialog.get().setOnInsertTable(insertTableListener);
- insertTableDialog.get().show();
- }
-
- private void styleToolbar(final ActionToolbar<Object> bar) {
- bar.setNormalStyle();
- }
-
- private ActionItemCollection<Object> withNoItem(final ActionCollection<Object> actions) {
- ActionItemCollection<Object> collection = new ActionItemCollection<Object>();
- for (ActionDescriptor<Object> action : actions) {
- // this action don't have a associated item
- collection.add(withNoItem(action));
- }
- return collection;
- }
-
- private ActionItem<Object> withNoItem(final ActionDescriptor<Object> action) {
- return new ActionItem<Object>(action, null);
- }
-}
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,7 +1,7 @@
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 static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
import java.util.ArrayList;
import java.util.HashMap;
@@ -10,6 +10,7 @@
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.actions.AbstractAction;
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
import org.ourproject.kune.platf.client.actions.Action;
import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.InputMap;
@@ -53,7 +54,7 @@
public class RTEditorPresenterNew implements RTEditorNew {
- public class BackgroundColorAction extends AbstractRTEAction {
+ public class BackgroundColorAction extends AbstractExtendedAction {
public BackgroundColorAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
@@ -72,7 +73,7 @@
}
}
- public class BlockquoteAction extends AbstractRTEAction {
+ public class BlockquoteAction extends AbstractExtendedAction {
public BlockquoteAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -84,7 +85,7 @@
}
}
- public class BoldAction extends AbstractRTEAction {
+ public class BoldAction extends AbstractExtendedAction {
public BoldAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -95,7 +96,7 @@
}
}
- public class CommentAction extends AbstractRTEAction {
+ public class CommentAction extends AbstractExtendedAction {
public CommentAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -136,7 +137,7 @@
}
}
- public class CopyAction extends AbstractRTEAction {
+ public class CopyAction extends AbstractExtendedAction {
public CopyAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -146,7 +147,7 @@
}
}
- public class CreateOrEditLinkAction extends AbstractRTEAction {
+ public class CreateOrEditLinkAction extends AbstractExtendedAction {
public CreateOrEditLinkAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -189,7 +190,7 @@
}
}
- public class CutAction extends AbstractRTEAction {
+ public class CutAction extends AbstractExtendedAction {
public CutAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -200,7 +201,7 @@
}
}
- public class DecreaseIndentAction extends AbstractRTEAction {
+ public class DecreaseIndentAction extends AbstractExtendedAction {
public DecreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -211,7 +212,7 @@
}
}
- public class DevInfoAction extends AbstractRTEAction {
+ public class DevInfoAction extends AbstractExtendedAction {
public DevInfoAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -225,7 +226,7 @@
}
}
- public class EditHtmlAction extends AbstractRTEAction {
+ public class EditHtmlAction extends AbstractExtendedAction {
private EditHtmlDialog editHtmlDialog;
public EditHtmlAction(final String text, final String tooltip, final ImageResource icon) {
@@ -251,7 +252,7 @@
}
}
- public class FontAction extends AbstractRTEAction {
+ public class FontAction extends AbstractExtendedAction {
public static final String FONT_NAME = "fontname";
public FontAction(final String fontName, final String tooltip, final ImageResource icon) {
@@ -271,7 +272,7 @@
}
}
- public class FontColorAction extends AbstractRTEAction {
+ public class FontColorAction extends AbstractExtendedAction {
public FontColorAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -290,7 +291,7 @@
}
}
- public class FontSizeAction extends AbstractRTEAction {
+ public class FontSizeAction extends AbstractExtendedAction {
private final int fontSize;
public FontSizeAction(final String fontSizeName, final int fontSize, final String tooltip,
@@ -306,7 +307,7 @@
}
}
- public class HrAction extends AbstractRTEAction {
+ public class HrAction extends AbstractExtendedAction {
public HrAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -318,7 +319,7 @@
}
}
- public class ImgAction extends AbstractRTEAction {
+ public class ImgAction extends AbstractExtendedAction {
public ImgAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -350,7 +351,7 @@
}
}
- public class IncreaseIndentAction extends AbstractRTEAction {
+ public class IncreaseIndentAction extends AbstractExtendedAction {
public IncreaseIndentAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -361,7 +362,7 @@
}
}
- public class InsertMediaAction extends AbstractRTEAction {
+ public class InsertMediaAction extends AbstractExtendedAction {
public InsertMediaAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -392,7 +393,7 @@
}
}
- public class InsertSpecialCharAction extends AbstractRTEAction {
+ public class InsertSpecialCharAction extends AbstractExtendedAction {
private InsertSpecialCharDialog insCharDialog;
public InsertSpecialCharAction(final String text, final String tooltip, final ImageResource icon) {
@@ -418,7 +419,7 @@
}
}
- public class InsertTableAction extends AbstractRTEAction {
+ public class InsertTableAction extends AbstractExtendedAction {
private InsertTableDialog insTableDialog;
public InsertTableAction(final String text, final String tooltip, final ImageResource icon) {
@@ -442,7 +443,7 @@
}
}
- public class ItalicAction extends AbstractRTEAction {
+ public class ItalicAction extends AbstractExtendedAction {
public ItalicAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -453,7 +454,7 @@
}
}
- public class JustifyCentreAction extends AbstractRTEAction {
+ public class JustifyCentreAction extends AbstractExtendedAction {
public JustifyCentreAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -464,7 +465,7 @@
}
}
- public class JustifyLeftAction extends AbstractRTEAction {
+ public class JustifyLeftAction extends AbstractExtendedAction {
public JustifyLeftAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -475,7 +476,7 @@
}
}
- public class JustifyRightAction extends AbstractRTEAction {
+ public class JustifyRightAction extends AbstractExtendedAction {
public JustifyRightAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -486,7 +487,7 @@
}
}
- public class OlAction extends AbstractRTEAction {
+ public class OlAction extends AbstractExtendedAction {
public OlAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -497,7 +498,7 @@
}
}
- public class PasteAction extends AbstractRTEAction {
+ public class PasteAction extends AbstractExtendedAction {
public PasteAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -508,7 +509,7 @@
}
}
- public class RedoAction extends AbstractRTEAction {
+ public class RedoAction extends AbstractExtendedAction {
public RedoAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -519,7 +520,7 @@
}
}
- public class RemoveFormatAction extends AbstractRTEAction {
+ public class RemoveFormatAction extends AbstractExtendedAction {
public RemoveFormatAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -530,7 +531,7 @@
}
}
- public class RemoveLinkAction extends AbstractRTEAction {
+ public class RemoveLinkAction extends AbstractExtendedAction {
public RemoveLinkAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -546,7 +547,7 @@
}
}
- public class SelectAllAction extends AbstractRTEAction {
+ public class SelectAllAction extends AbstractExtendedAction {
public SelectAllAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -556,7 +557,7 @@
}
}
- public class StrikethroughAction extends AbstractRTEAction {
+ public class StrikethroughAction extends AbstractExtendedAction {
public StrikethroughAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -567,7 +568,7 @@
}
}
- public class SubscriptAction extends AbstractRTEAction {
+ public class SubscriptAction extends AbstractExtendedAction {
public SubscriptAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -578,7 +579,7 @@
}
}
- public class SuperscriptAction extends AbstractRTEAction {
+ public class SuperscriptAction extends AbstractExtendedAction {
public SuperscriptAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -589,7 +590,7 @@
}
}
- public class UlAction extends AbstractRTEAction {
+ public class UlAction extends AbstractExtendedAction {
public UlAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -600,7 +601,7 @@
}
}
- public class UnderlineAction extends AbstractRTEAction {
+ public class UnderlineAction extends AbstractExtendedAction {
public UnderlineAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -611,7 +612,7 @@
}
}
- public class UndoAction extends AbstractRTEAction {
+ public class UndoAction extends AbstractExtendedAction {
public UndoAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -889,7 +890,7 @@
final ToolbarSeparatorDescriptor sndbarSepExt = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
sndbarSepExt.setAddCondition(extendedAddCond);
- final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractRTEAction.NO_TEXT,
+ final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractExtendedAction.NO_TEXT,
imgResources.selectall());
final MenuItemDescriptor select = new MenuItemDescriptor(editMenu, selectAllAction);
setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('A'), Keyboard.MODIFIER_CTRL), selectAllAction);
@@ -910,12 +911,12 @@
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);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(','), Keyboard.MODIFIER_CTRL), subscriptAction);
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);
+ setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf('.'), Keyboard.MODIFIER_CTRL), superscriptAction);
final JustifyLeftAction jfyLeftAction = new JustifyLeftAction(NO_TEXT, i18n.t("Left Justify"),
imgResources.alignleft());
@@ -973,7 +974,8 @@
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(Character.valueOf(' '), Keyboard.MODIFIER_CTRL
+ + Keyboard.MODIFIER_SHIFT), hlineAction);
final BlockquoteAction blockquoteAction = new BlockquoteAction(i18n.t("Block Quotation"), NO_TEXT, NO_ICON);
final MenuItemDescriptor blockquote = new MenuItemDescriptor(formatMenu, blockquoteAction);
@@ -1128,8 +1130,9 @@
final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction,
FONT_SIZEGROUP);
fontSizeItem.setAddCondition(basicAddCond);
- setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char) (48 + fontSize))), Keyboard.MODIFIER_CTRL),
- fontSizeAction);
+ // setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char)
+ // (48 + fontSize))), Keyboard.MODIFIER_CTRL),
+ // fontSizeAction);
fontSizeItem.setLocation(SNDBAR);
actions.add(fontSizeItem);
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,133 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.LinkInfo;
-
-public interface RTEditorView extends View {
-
- void addActions(ActionItemCollection<Object> actions);
-
- void addCtxAction(ActionItem<Object> actionItem);
-
- void adjustSize(int height);
-
- boolean canBeBasic();
-
- boolean canBeExtended();
-
- void copy();
-
- void createLink(String url);
-
- void cut();
-
- void delete();
-
- void focus();
-
- String getHTML();
-
- LinkInfo getLinkInfoIfHref();
-
- void getRangeInfo();
-
- String getSelectionText();
-
- String getText();
-
- void hideLinkCtxMenu();
-
- void insertBlockquote();
-
- void insertComment(String author);
-
- void insertCommentNotUsingSelection(String author);
-
- void insertCommentUsingSelection(String author);
-
- void insertHorizontalRule();
-
- void insertHtml(String html);
-
- void insertImage(String url);
-
- void insertOrderedList();
-
- void insertUnorderedList();
-
- boolean isAnythingSelected();
-
- boolean isAttached();
-
- boolean isBold();
-
- boolean isCtxMenuVisible();
-
- boolean isItalic();
-
- boolean isLink();
-
- boolean isStrikethrough();
-
- boolean isSubscript();
-
- boolean isSuperscript();
-
- boolean isUnderlined();
-
- void justifyCenter();
-
- void justifyLeft();
-
- void justifyRight();
-
- void leftIndent();
-
- void paste();
-
- void redo();
-
- void removeFormat();
-
- void rightIndent();
-
- void selectAll();
-
- void selectLink();
-
- void setBackColor(String color);
-
- void setFocus(boolean focus);
-
- void setFontName(String name);
-
- void setFontSize(FontSize fontSize);
-
- void setForeColor(String color);
-
- void setHTML(String html);
-
- void setText(String text);
-
- void showLinkCtxMenu();
-
- void toggleBold();
-
- void toggleItalic();
-
- void toggleStrikethrough();
-
- void toggleSubscript();
-
- void toggleSuperscript();
-
- void toggleUnderline();
-
- void undo();
-
- void unlink();
-
-}
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,7 +1,9 @@
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 static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
+
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.BeforeActionListener;
import org.ourproject.kune.platf.client.actions.KeyStroke;
@@ -11,7 +13,6 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.shortcuts.Keyboard;
import org.ourproject.kune.platf.client.state.StateManager;
-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;
@@ -23,31 +24,32 @@
public class RTESavingEditorPresenter implements RTESavingEditor {
- public class AutoSaveAction extends AbstractRTEAction {
- public AutoSaveAction(final String text, final String tooltip, final ImageResource icon) {
- super(text, tooltip, icon);
- }
+ public class AutoSaveAction extends AbstractExtendedAction {
+ public AutoSaveAction(final String text, final String tooltip, final ImageResource icon) {
+ super(text, tooltip, icon);
+ }
- public void actionPerformed(final ActionEvent actionEvent) {
- autoSave = !autoSave;
- if (autoSave) {
- timer.schedule(AUTOSAVE_IN_MILLISECONDS);
- } else {
- timer.cancel();
- }
+ public void actionPerformed(final ActionEvent actionEvent) {
+ // bitwise, similar to: autoSave = !autoSave; but fast
+ autoSave ^= true;
+ if (autoSave) {
+ timer.schedule(AUTOSAVE_IN_MILLIS);
+ } 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 CloseAction extends AbstractExtendedAction {
+ 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 class SaveAction extends AbstractExtendedAction {
public SaveAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
@@ -55,41 +57,37 @@
public void actionPerformed(final ActionEvent actionEvent) {
onDoSaveImpl();
}
- }
+ }
-
-
- public class SaveCloseAction extends AbstractRTEAction {
- public SaveCloseAction(final String text, final String tooltip, final ImageResource icon) {
+ public class SaveCloseAction extends AbstractExtendedAction {
+ 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 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;
+ public static final int AUTOSAVE_AFTER_FAIL_MILLS = 20000;
+ public static final int AUTOSAVE_IN_MILLIS = 10000;
private final RTEditorNew editor;
private boolean autoSave;
private boolean savePending;
- private boolean saveAndCloseConfirmed;
+ private boolean saveCloseConfirmed;
private Listener<String> onSave;
private Listener0 onEditCancelled;
private final RTEImgResources imgResources;
private final TimerWrapper timer;
- private final DeferredCommandWrapper deferredCommandWrapper;
+ private final DeferredCommandWrapper deferred;
private final I18nTranslationService i18n;
private final StateManager stateManager;
- private final BeforeActionListener beforeStateChangeListener;
+ private final BeforeActionListener beforeStateChg;
private RTESavingEditorView view;
SaveAction saveAction;
@@ -102,24 +100,25 @@
this.autoSave = autoSave;
this.i18n = i18n;
this.stateManager = stateManager;
- this.deferredCommandWrapper = deferredCommandWrapper;
+ this.deferred = deferredCommandWrapper;
this.imgResources = imgResources;
this.savePending = false;
- this.saveAndCloseConfirmed = false;
+ this.saveCloseConfirmed = false;
createActions();
this.timer = timer;
timer.configure(new Listener0() {;
- public void onEvent() {
- onAutoSave();
- }
+ public void onEvent() {
+ onAutoSave();
+ }
});
+
editor.addOnEditListener(new Listener0() {
public void onEvent() {
onEdit();
}
});
- beforeStateChangeListener = new BeforeActionListener() {
+ beforeStateChg = new BeforeActionListener() {
public boolean beforeAction() {
return beforeTokenChange();
}
@@ -131,7 +130,7 @@
this.onEditCancelled = onEditCancelled;
editor.setHtml(html);
editor.attach();
- stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
+ stateManager.addBeforeStateChangeListener(beforeStateChg);
enableSaveBtn(false);
}
@@ -140,7 +139,7 @@
}
public BeforeActionListener getBeforeSavingListener() {
- return beforeStateChangeListener;
+ return beforeStateChg;
}
public void init(final RTESavingEditorView view) {
@@ -156,7 +155,7 @@
}
public void onSavedSuccessful() {
- if (saveAndCloseConfirmed) {
+ if (saveCloseConfirmed) {
onCancelConfirmed();
} else {
reset();
@@ -164,9 +163,9 @@
}
public void onSaveFailed() {
- timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- if (saveAndCloseConfirmed) {
- saveAndCloseConfirmed = false;
+ timer.schedule(AUTOSAVE_AFTER_FAIL_MILLS);
+ if (saveCloseConfirmed) {
+ saveCloseConfirmed = false;
}
}
@@ -183,17 +182,18 @@
}
boolean beforeTokenChange() {
+ boolean result = false;
if (savePending) {
onCancelImpl();
- return false;
} else {
- deferredCommandWrapper.addCommand(new Listener0() {
+ deferred.addCommand(new Listener0() {
public void onEvent() {
onCancelConfirmed();
}
});
- return true;
+ result = true;
}
+ return result;
}
void onDoSave() {
@@ -204,14 +204,13 @@
if (!savePending) {
savePending = true;
if (autoSave) {
- timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+ timer.schedule(AUTOSAVE_IN_MILLIS);
}
enableSaveBtn(true);
}
}
private void createActions() {
-
saveAction = new SaveAction(NO_TEXT, i18n.t("Save"),imgResources.save());
final ButtonDescriptor saveBtn = new ButtonDescriptor(saveAction);
@@ -228,7 +227,7 @@
final AutoSaveAction autoSaveAction = new AutoSaveAction(i18n.t("Autosave"), NO_TEXT, NO_ICON);
final MenuCheckItemDescriptor autoSaveItem = new MenuCheckItemDescriptor(editor.getFileMenu(), autoSaveAction) { @Override
- public boolean isChecked() {
+ public boolean isChecked() {
//autoSaveItem.setChecked(autoSave);
return autoSave;
}};
@@ -249,7 +248,6 @@
editor.addAction(autoSaveItem);
editor.addAction(saveClose);
editor.addAction(saveCloseBtn);
- //FIXME editor.addAction(new ToolbarSeparatorDescriptor(Type.fill));
editor.addAction(closeItem);
}
@@ -259,7 +257,7 @@
}
private void onCancelConfirmedImpl() {
- stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
+ stateManager.removeBeforeStateChangeListener(beforeStateChg);
stateManager.resumeTokenChange();
reset();
editor.detach();
@@ -291,18 +289,19 @@
}
private void onDoSaveAndCloseImpl() {
- saveAndCloseConfirmed = true;
+ saveCloseConfirmed = true;
onDoSaveImpl();
}
private void onDoSaveImpl() {
- onSave.onEvent(editor.getHtml());
+ final String html = editor.getHtml();
+ onSave.onEvent(html);
}
private void reset() {
timer.cancel();
savePending = false;
- saveAndCloseConfirmed = false;
+ saveCloseConfirmed = false;
enableSaveBtn(false);
editor.reset();
}
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -25,6 +25,7 @@
import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.state.StateManager;
@@ -55,10 +56,9 @@
import org.ourproject.kune.workspace.client.upload.FileUploader;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class WikiClientModule extends AbstractModule {
+public class WikiClientModule extends AbstractExtendedModule {
@Override
public void onInstall() {
@@ -66,29 +66,29 @@
register(ToolGroup.class, new Factory<WikiClientTool>(WikiClientTool.class) {
@Override
public WikiClientTool create() {
- $(WikiClientActions.class);
- return new WikiClientTool($(I18nUITranslationService.class), $(ToolSelector.class),
- $(WsThemePresenter.class), $(WorkspaceSkeleton.class), $(ContentCapabilitiesRegistry.class));
+ i(WikiClientActions.class);
+ return new WikiClientTool(i(I18nUITranslationService.class), i(ToolSelector.class),
+ i(WsThemePresenter.class), i(WorkspaceSkeleton.class), i(ContentCapabilitiesRegistry.class));
}
});
register(ToolGroup.class, new Factory<WikiClientActions>(WikiClientActions.class) {
@Override
public WikiClientActions create() {
- return new WikiClientActions($(I18nUITranslationService.class), $(ContextNavigator.class),
- $(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
- $(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(WikiViewer.class),
- $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
+ return new WikiClientActions(i(I18nUITranslationService.class), i(ContextNavigator.class),
+ i(Session.class), i(StateManager.class), i(DeferredCommandWrapper.class),
+ p(ContentServiceAsync.class), p(GroupServiceAsync.class), p(FileUploader.class),
+ i(ContentActionRegistry.class), i(ContextActionRegistry.class), p(FileDownloadUtils.class),
+ i(EntityHeader.class), p(ContentEditor.class), i(ErrorHandler.class), i(WikiViewer.class),
+ p(ContextPropEditor.class), i(SitePublicSpaceLink.class));
}
});
register(ToolGroup.class, new Factory<WikiContext>(WikiContext.class) {
@Override
public WikiContext create() {
- final WikiContextPresenter presenter = new WikiContextPresenter($(StateManager.class),
- $$(ContextNavigator.class), $$(ContextPropEditor.class));
+ final WikiContextPresenter presenter = new WikiContextPresenter(i(StateManager.class),
+ p(ContextNavigator.class), p(ContextPropEditor.class));
return presenter;
}
});
@@ -96,11 +96,11 @@
register(Singleton.class, new Factory<WikiViewer>(WikiViewer.class) {
@Override
public WikiViewer create() {
- final WikiViewerPresenter presenter = new WikiViewerPresenter($(StateManager.class), $(Session.class),
- $(I18nUITranslationService.class), $(ActionContentToolbar.class),
- $(ContentActionRegistry.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final WikiViewerView view = new WikiViewerPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final WikiViewerPresenter presenter = new WikiViewerPresenter(i(StateManager.class), i(Session.class),
+ i(I18nUITranslationService.class), i(ActionContentToolbar.class),
+ i(ContentActionRegistry.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final WikiViewerView view = new WikiViewerPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
@@ -109,11 +109,11 @@
register(ToolGroup.class, new Factory<WikiFolderContent>(WikiFolderContent.class) {
@Override
public WikiFolderContent create() {
- final WikiFolderContentPresenter presenter = new WikiFolderContentPresenter($(StateManager.class),
- $(Session.class), $(ActionContentToolbar.class), $(ContentActionRegistry.class),
- $(I18nTranslationService.class), $$(FileDownloadUtils.class), $$(MediaUtils.class));
- final WikiFolderContentView view = new WikiFolderContentPanel($(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final WikiFolderContentPresenter presenter = new WikiFolderContentPresenter(i(StateManager.class),
+ i(Session.class), i(ActionContentToolbar.class), i(ContentActionRegistry.class),
+ i(I18nTranslationService.class), p(FileDownloadUtils.class), p(MediaUtils.class));
+ final WikiFolderContentView view = new WikiFolderContentPanel(i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -36,6 +36,7 @@
import org.ourproject.kune.platf.client.registry.VersionableRegistry;
import org.ourproject.kune.platf.client.registry.XmppComentableRegistry;
import org.ourproject.kune.platf.client.registry.XmppNotifyCapableRegistry;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.workspace.client.cnt.ContentActionRegistry;
import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry;
@@ -43,10 +44,9 @@
import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
-public class RegistryModule extends AbstractModule {
+public class RegistryModule extends AbstractExtendedModule {
@Override
protected void onInstall() {
@@ -171,13 +171,13 @@
register(Singleton.class, new Factory<ContentCapabilitiesRegistry>(ContentCapabilitiesRegistry.class) {
@Override
public ContentCapabilitiesRegistry create() {
- return new ContentCapabilitiesRegistry($(AuthorableRegistry.class), $(AclEditableRegistry.class),
- $(ContentIconsRegistry.class), $(CanBeHomepageRegistry.class), $(ComentableRegistry.class),
- $(DragableRegistry.class), $(DropableRegistry.class), $(EmailSubscribeAbleRegistry.class),
- $(LicensableRegistry.class), $(PublishModerableRegistry.class), $(RateableRegistry.class),
- $(TageableRegistry.class), $(RenamableRegistry.class), $(TranslatableRegistry.class),
- $(VersionableRegistry.class), $(XmppComentableRegistry.class),
- $(XmppNotifyCapableRegistry.class));
+ return new ContentCapabilitiesRegistry(i(AuthorableRegistry.class), i(AclEditableRegistry.class),
+ i(ContentIconsRegistry.class), i(CanBeHomepageRegistry.class), i(ComentableRegistry.class),
+ i(DragableRegistry.class), i(DropableRegistry.class), i(EmailSubscribeAbleRegistry.class),
+ i(LicensableRegistry.class), i(PublishModerableRegistry.class), i(RateableRegistry.class),
+ i(TageableRegistry.class), i(RenamableRegistry.class), i(TranslatableRegistry.class),
+ i(VersionableRegistry.class), i(XmppComentableRegistry.class),
+ i(XmppNotifyCapableRegistry.class));
}
});
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -40,6 +40,7 @@
import org.ourproject.kune.platf.client.rpc.SocialNetworkService;
import org.ourproject.kune.platf.client.rpc.SocialNetworkServiceAsync;
import org.ourproject.kune.platf.client.rpc.UserServiceAsync;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.services.ImageUtils;
import org.ourproject.kune.platf.client.services.Images;
@@ -234,12 +235,11 @@
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.decorator.NoDecoration;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.ServiceDefTarget;
-public class WorkspaceModule extends AbstractModule {
+public class WorkspaceModule extends AbstractExtendedModule {
@Override
protected void onInstall() {
@@ -278,7 +278,7 @@
@Override
public SiteProgress create() {
final SiteProgressPresenter presenter = new SiteProgressPresenter();
- final SiteProgressPanel panel = new SiteProgressPanel(presenter, $$(SitePublicSpaceLink.class));
+ final SiteProgressPanel panel = new SiteProgressPanel(presenter, p(SitePublicSpaceLink.class));
presenter.init(panel);
return presenter;
}
@@ -287,18 +287,18 @@
register(ApplicationComponentGroup.class, new Factory<WorkspaceNotifyUser>(WorkspaceNotifyUser.class) {
@Override
public WorkspaceNotifyUser create() {
- return new WorkspaceNotifyUser($(NotifyUser.class), $(I18nUITranslationService.class),
- $(SiteProgress.class), $$(ToastMessage.class), $$(WorkspaceSkeleton.class));
+ return new WorkspaceNotifyUser(i(NotifyUser.class), i(I18nUITranslationService.class),
+ i(SiteProgress.class), p(ToastMessage.class), p(WorkspaceSkeleton.class));
}
});
register(ApplicationComponentGroup.class, new Factory<SitePublicSpaceLink>(SitePublicSpaceLink.class) {
@Override
public SitePublicSpaceLink create() {
- final SitePublicSpaceLinkPresenter presenter = new SitePublicSpaceLinkPresenter($(StateManager.class),
- $(StateTokenUtils.class));
+ final SitePublicSpaceLinkPresenter presenter = new SitePublicSpaceLinkPresenter(i(StateManager.class),
+ i(StateTokenUtils.class));
final SitePublicSpaceLinkPanel panel = new SitePublicSpaceLinkPanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nUITranslationService.class), $(Images.class));
+ i(WorkspaceSkeleton.class), i(I18nUITranslationService.class), i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -307,7 +307,7 @@
register(Singleton.class, new Factory<StateTokenUtils>(StateTokenUtils.class) {
@Override
public StateTokenUtils create() {
- return new StateTokenUtils($(Session.class));
+ return new StateTokenUtils(i(Session.class));
}
});
@@ -324,10 +324,10 @@
register(ApplicationComponentGroup.class, new Factory<SiteUserMenu>(SiteUserMenu.class) {
@Override
public SiteUserMenu create() {
- final SiteUserMenuPresenter presenter = new SiteUserMenuPresenter($(Session.class),
- $(StateManager.class), $$(EntityOptions.class), $$(FileDownloadUtils.class));
- final SiteUserMenuPanel panel = new SiteUserMenuPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nUITranslationService.class));
+ final SiteUserMenuPresenter presenter = new SiteUserMenuPresenter(i(Session.class),
+ i(StateManager.class), p(EntityOptions.class), p(FileDownloadUtils.class));
+ final SiteUserMenuPanel panel = new SiteUserMenuPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nUITranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -336,9 +336,9 @@
register(ApplicationComponentGroup.class, new Factory<SiteSignInLink>(SiteSignInLink.class) {
@Override
public SiteSignInLink create() {
- final SiteSignInLinkPresenter presenter = new SiteSignInLinkPresenter($(Session.class));
- final SiteSignInLinkPanel panel = new SiteSignInLinkPanel(presenter, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class));
+ final SiteSignInLinkPresenter presenter = new SiteSignInLinkPresenter(i(Session.class));
+ final SiteSignInLinkPanel panel = new SiteSignInLinkPanel(presenter, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -347,10 +347,10 @@
register(ApplicationComponentGroup.class, new Factory<SiteSignOutLink>(SiteSignOutLink.class) {
@Override
public SiteSignOutLink create() {
- final SiteSignOutLinkPresenter presenter = new SiteSignOutLinkPresenter($(Session.class),
- $$(UserServiceAsync.class), $$(ErrorHandler.class));
+ final SiteSignOutLinkPresenter presenter = new SiteSignOutLinkPresenter(i(Session.class),
+ p(UserServiceAsync.class), p(ErrorHandler.class));
final SiteSignOutLinkPanel panel = new SiteSignOutLinkPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class));
+ i(I18nUITranslationService.class), i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -360,8 +360,8 @@
@Override
public SiteNewGroupLink create() {
final SiteNewGroupLinkPresenter presenter = new SiteNewGroupLinkPresenter();
- final SiteNewGroupLinkPanel panel = new SiteNewGroupLinkPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nUITranslationService.class));
+ final SiteNewGroupLinkPanel panel = new SiteNewGroupLinkPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nUITranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -371,8 +371,8 @@
@Override
public SiteOptions create() {
final SiteOptionsPresenter presenter = new SiteOptionsPresenter();
- final SiteOptionsPanel panel = new SiteOptionsPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nUITranslationService.class), $$(I18nTranslator.class), $$(TestRTEDialog.class));
+ final SiteOptionsPanel panel = new SiteOptionsPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nUITranslationService.class), p(I18nTranslator.class), p(TestRTEDialog.class));
presenter.init(panel);
return presenter;
}
@@ -381,10 +381,10 @@
register(ApplicationComponentGroup.class, new Factory<SiteSearch>(SiteSearch.class) {
@Override
public SiteSearch create() {
- final SiteSearchPresenter presenter = new SiteSearchPresenter($$(SiteSearcher.class),
- $(I18nTranslationService.class));
- final SiteSearchPanel panel = new SiteSearchPanel(presenter, $(WorkspaceSkeleton.class),
- $(Images.class));
+ final SiteSearchPresenter presenter = new SiteSearchPresenter(p(SiteSearcher.class),
+ i(I18nTranslationService.class));
+ final SiteSearchPanel panel = new SiteSearchPanel(presenter, i(WorkspaceSkeleton.class),
+ i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -393,8 +393,8 @@
register(ApplicationComponentGroup.class, new Factory<SiteLogo>(SiteLogo.class) {
@Override
public SiteLogo create() {
- final SiteLogoPresenter presenter = new SiteLogoPresenter($(Session.class));
- final SiteLogoPanel panel = new SiteLogoPanel(presenter, $(WorkspaceSkeleton.class));
+ final SiteLogoPresenter presenter = new SiteLogoPresenter(i(Session.class));
+ final SiteLogoPanel panel = new SiteLogoPanel(presenter, i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -403,10 +403,10 @@
register(ApplicationComponentGroup.class, new Factory<EntityHeader>(EntityHeader.class) {
@Override
public EntityHeader create() {
- final EntityHeaderPresenter presenter = new EntityHeaderPresenter($(StateManager.class),
- $(WsThemePresenter.class), $(Session.class));
- final EntityHeaderPanel panel = new EntityHeaderPanel($(WorkspaceSkeleton.class),
- $$(FileDownloadUtils.class), $(Images.class));
+ final EntityHeaderPresenter presenter = new EntityHeaderPresenter(i(StateManager.class),
+ i(WsThemePresenter.class), i(Session.class));
+ final EntityHeaderPanel panel = new EntityHeaderPanel(i(WorkspaceSkeleton.class),
+ p(FileDownloadUtils.class), i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -415,10 +415,10 @@
register(ApplicationComponentGroup.class, new Factory<WsThemePresenter>(WsThemePresenter.class) {
@Override
public WsThemePresenter create() {
- final WsThemePresenter presenter = new WsThemePresenter($(Session.class), $$(GroupServiceAsync.class),
- $(StateManager.class));
- final WsThemePanel panel = new WsThemePanel($(WorkspaceSkeleton.class), presenter,
- $(I18nUITranslationService.class));
+ final WsThemePresenter presenter = new WsThemePresenter(i(Session.class), p(GroupServiceAsync.class),
+ i(StateManager.class));
+ final WsThemePanel panel = new WsThemePanel(i(WorkspaceSkeleton.class), presenter,
+ i(I18nUITranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -427,10 +427,10 @@
register(ApplicationComponentGroup.class, new Factory<EntityTitle>(EntityTitle.class) {
@Override
public EntityTitle create() {
- final EntityTitlePresenter presenter = new EntityTitlePresenter($(StateManager.class),
- $(Session.class), $(ContentIconsRegistry.class), $(RenamableRegistry.class),
- $(RenameAction.class));
- final EntityTitlePanel panel = new EntityTitlePanel($(WorkspaceSkeleton.class), presenter);
+ final EntityTitlePresenter presenter = new EntityTitlePresenter(i(StateManager.class),
+ i(Session.class), i(ContentIconsRegistry.class), i(RenamableRegistry.class),
+ i(RenameAction.class));
+ final EntityTitlePanel panel = new EntityTitlePanel(i(WorkspaceSkeleton.class), presenter);
presenter.init(panel);
return presenter;
}
@@ -440,8 +440,8 @@
@Override
public EntitySubTitle create() {
final EntitySubTitlePresenter presenter = new EntitySubTitlePresenter(
- $(I18nUITranslationService.class), $(StateManager.class), false, $(AuthorableRegistry.class));
- final EntitySubTitlePanel panel = new EntitySubTitlePanel(presenter, $(WorkspaceSkeleton.class));
+ i(I18nUITranslationService.class), i(StateManager.class), false, i(AuthorableRegistry.class));
+ final EntitySubTitlePanel panel = new EntitySubTitlePanel(presenter, i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -450,9 +450,9 @@
register(ApplicationComponentGroup.class, new Factory<EntityLicensePresenter>(EntityLicensePresenter.class) {
@Override
public EntityLicensePresenter create() {
- final EntityLicensePresenter presenter = new EntityLicensePresenter($(StateManager.class));
- final EntityLicensePanel panel = new EntityLicensePanel(presenter, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class));
+ final EntityLicensePresenter presenter = new EntityLicensePresenter(i(StateManager.class));
+ final EntityLicensePanel panel = new EntityLicensePanel(presenter, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -461,11 +461,11 @@
register(ApplicationComponentGroup.class, new Factory<RateIt>(RateIt.class) {
@Override
public RateIt create() {
- final RateItPresenter presenter = new RateItPresenter($(I18nUITranslationService.class),
- $(Session.class), $$(ContentServiceAsync.class), $(StateManager.class),
- $$(RatePresenter.class), $(ContentCapabilitiesRegistry.class));
- final RateItPanel panel = new RateItPanel(presenter, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class), $(Images.class));
+ final RateItPresenter presenter = new RateItPresenter(i(I18nUITranslationService.class),
+ i(Session.class), p(ContentServiceAsync.class), i(StateManager.class), p(RatePresenter.class),
+ i(ContentCapabilitiesRegistry.class));
+ final RateItPanel panel = new RateItPanel(presenter, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class), i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -474,10 +474,10 @@
register(ApplicationComponentGroup.class, new Factory<RatePresenter>(RatePresenter.class) {
@Override
public RatePresenter create() {
- final RatePresenter presenter = new RatePresenter($(StateManager.class),
- $(ContentCapabilitiesRegistry.class));
- final RatePanel panel = new RatePanel(null, null, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class));
+ final RatePresenter presenter = new RatePresenter(i(StateManager.class),
+ i(ContentCapabilitiesRegistry.class));
+ final RatePanel panel = new RatePanel(null, null, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -493,14 +493,14 @@
register(Singleton.class, new Factory<ActionGroupSummaryToolbar>(ActionGroupSummaryToolbar.class) {
@Override
public ActionGroupSummaryToolbar create() {
- final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
+ final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>(p(ActionManager.class));
final ActionGroupSummaryToolbarPresenter toolbar = new ActionGroupSummaryToolbarPresenter(panel);
return toolbar;
}
}, new Factory<ActionParticipationToolbar>(ActionParticipationToolbar.class) {
@Override
public ActionParticipationToolbar create() {
- final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
+ final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>(p(ActionManager.class));
final ActionParticipationSummaryToolbarPresenter toolbar = new ActionParticipationSummaryToolbarPresenter(
panel);
return toolbar;
@@ -509,7 +509,7 @@
@Override
public ActionBuddiesSummaryToolbar create() {
final ActionToolbarPanel<UserSimpleDTO> panel = new ActionToolbarPanel<UserSimpleDTO>(
- $$(ActionManager.class));
+ p(ActionManager.class));
final ActionBuddiesSummaryToolbarPresenter toolbar = new ActionBuddiesSummaryToolbarPresenter(panel);
return toolbar;
}
@@ -519,12 +519,12 @@
@Override
public GroupMembersSummary create() {
final GroupMembersSummaryPresenter presenter = new GroupMembersSummaryPresenter(
- $(I18nUITranslationService.class), $(StateManager.class), $(ImageUtils.class),
- $(Session.class), $$(SocialNetworkServiceAsync.class), $$(GroupServiceAsync.class),
- $$(GroupLiveSearcher.class), $(WsThemePresenter.class), $$(ChatEngine.class),
- $(GroupActionRegistry.class), $(ActionGroupSummaryToolbar.class), $$(FileDownloadUtils.class));
+ i(I18nUITranslationService.class), i(StateManager.class), i(ImageUtils.class),
+ i(Session.class), p(SocialNetworkServiceAsync.class), p(GroupServiceAsync.class),
+ p(GroupLiveSearcher.class), i(WsThemePresenter.class), p(ChatEngine.class),
+ i(GroupActionRegistry.class), i(ActionGroupSummaryToolbar.class), p(FileDownloadUtils.class));
final GroupMembersSummaryView view = new GroupMembersSummaryPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $(
+ i(I18nUITranslationService.class), i(WorkspaceSkeleton.class), i(
ActionGroupSummaryToolbar.class).getView());
presenter.init(view);
return presenter;
@@ -534,10 +534,10 @@
register(ApplicationComponentGroup.class, new Factory<AddAsBuddie>(AddAsBuddie.class) {
@Override
public AddAsBuddie create() {
- final AddAsBuddiePresenter presenter = new AddAsBuddiePresenter($$(ChatEngine.class),
- $(StateManager.class), $(Session.class));
- final AddAsBuddiePanel panel = new AddAsBuddiePanel(presenter, $(EntityHeader.class), $(Images.class),
- $(I18nTranslationService.class));
+ final AddAsBuddiePresenter presenter = new AddAsBuddiePresenter(p(ChatEngine.class),
+ i(StateManager.class), i(Session.class));
+ final AddAsBuddiePanel panel = new AddAsBuddiePanel(presenter, i(EntityHeader.class), i(Images.class),
+ i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -546,14 +546,14 @@
register(ApplicationComponentGroup.class, new Factory<BuddiesSummary>(BuddiesSummary.class) {
@Override
public BuddiesSummary create() {
- final BuddiesSummaryPresenter presenter = new BuddiesSummaryPresenter($(StateManager.class),
- $(Session.class), $$(UserServiceAsync.class), $(UserActionRegistry.class),
- $(I18nTranslationService.class), $$(ChatEngine.class), $(ActionBuddiesSummaryToolbar.class),
- $$(FileDownloadUtils.class), $(ImageUtils.class), $$(SocialNetworkServiceAsync.class),
- $(GroupActionRegistry.class));
- final BuddiesSummaryPanel panel = new BuddiesSummaryPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationService.class), $(ActionManager.class),
- $(ActionBuddiesSummaryToolbar.class).getView());
+ final BuddiesSummaryPresenter presenter = new BuddiesSummaryPresenter(i(StateManager.class),
+ i(Session.class), p(UserServiceAsync.class), i(UserActionRegistry.class),
+ i(I18nTranslationService.class), p(ChatEngine.class), i(ActionBuddiesSummaryToolbar.class),
+ p(FileDownloadUtils.class), i(ImageUtils.class), p(SocialNetworkServiceAsync.class),
+ i(GroupActionRegistry.class));
+ final BuddiesSummaryPanel panel = new BuddiesSummaryPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class), i(ActionManager.class),
+ i(ActionBuddiesSummaryToolbar.class).getView());
presenter.init(panel);
return presenter;
}
@@ -563,12 +563,12 @@
@Override
public ParticipationSummary create() {
final ParticipationSummaryPresenter presenter = new ParticipationSummaryPresenter(
- $(I18nUITranslationService.class), $(StateManager.class), $(ImageUtils.class),
- $(Session.class), $$(SocialNetworkServiceAsync.class), $(WsThemePresenter.class),
- $(GroupActionRegistry.class), $(ActionParticipationToolbar.class), $$(FileDownloadUtils.class));
+ i(I18nUITranslationService.class), i(StateManager.class), i(ImageUtils.class),
+ i(Session.class), p(SocialNetworkServiceAsync.class), i(WsThemePresenter.class),
+ i(GroupActionRegistry.class), i(ActionParticipationToolbar.class), p(FileDownloadUtils.class));
final ParticipationSummaryView view = new ParticipationSummaryPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class),
- ($(ActionParticipationToolbar.class).getView()));
+ i(I18nUITranslationService.class), i(WorkspaceSkeleton.class),
+ (i(ActionParticipationToolbar.class).getView()));
presenter.init(view);
return presenter;
}
@@ -577,10 +577,10 @@
register(ApplicationComponentGroup.class, new Factory<TagsSummary>(TagsSummary.class) {
@Override
public TagsSummary create() {
- final TagsSummaryPresenter presenter = new TagsSummaryPresenter($(Session.class),
- $$(SiteSearcher.class), $(StateManager.class), $(WsThemePresenter.class));
- final TagsSummaryPanel panel = new TagsSummaryPanel(presenter, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class));
+ final TagsSummaryPresenter presenter = new TagsSummaryPresenter(i(Session.class),
+ p(SiteSearcher.class), i(StateManager.class), i(WsThemePresenter.class));
+ final TagsSummaryPanel panel = new TagsSummaryPanel(presenter, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@@ -589,10 +589,10 @@
register(ApplicationComponentGroup.class, new Factory<NoHomePage>(NoHomePage.class) {
@Override
public NoHomePage create() {
- final NoHomePagePresenter presenter = new NoHomePagePresenter($(StateManager.class),
- $$(EntityHeader.class));
- final NoHomePagePanel panel = new NoHomePagePanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final NoHomePagePresenter presenter = new NoHomePagePresenter(i(StateManager.class),
+ p(EntityHeader.class));
+ final NoHomePagePanel panel = new NoHomePagePanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -601,9 +601,9 @@
register(ApplicationComponentGroup.class, new Factory<EntityOptions>(EntityOptions.class) {
@Override
public EntityOptions create() {
- final EntityOptionsPresenter presenter = new EntityOptionsPresenter($(StateManager.class));
- final EntityOptionsPanel panel = new EntityOptionsPanel(presenter, $(EntityHeader.class),
- $(I18nTranslationService.class), $(Images.class), $(EntityOptionsGroup.class));
+ final EntityOptionsPresenter presenter = new EntityOptionsPresenter(i(StateManager.class));
+ final EntityOptionsPanel panel = new EntityOptionsPanel(presenter, i(EntityHeader.class),
+ i(I18nTranslationService.class), i(Images.class), i(EntityOptionsGroup.class));
presenter.init(panel);
return presenter;
}
@@ -613,10 +613,10 @@
@Override
public EntityOptionsToolsConf create() {
final EntityOptionsToolsConfPresenter presenter = new EntityOptionsToolsConfPresenter(
- $(StateManager.class), $(Session.class), $(I18nTranslationService.class),
- $(EntityOptions.class), $$(GroupServiceAsync.class));
+ i(StateManager.class), i(Session.class), i(I18nTranslationService.class),
+ i(EntityOptions.class), p(GroupServiceAsync.class));
final EntityOptionsToolsConfPanel panel = new EntityOptionsToolsConfPanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
+ i(WorkspaceSkeleton.class), i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -625,11 +625,11 @@
register(EntityOptionsGroup.class, new Factory<EntityOptionsLogo>(EntityOptionsLogo.class) {
@Override
public EntityOptionsLogo create() {
- final EntityOptionsLogoPresenter presenter = new EntityOptionsLogoPresenter($(Session.class),
- $(EntityHeader.class), $(EntityOptions.class), $(StateManager.class),
- $$(UserServiceAsync.class), $$(ChatEngine.class));
- final EntityOptionsLogoPanel panel = new EntityOptionsLogoPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ final EntityOptionsLogoPresenter presenter = new EntityOptionsLogoPresenter(i(Session.class),
+ i(EntityHeader.class), i(EntityOptions.class), i(StateManager.class),
+ p(UserServiceAsync.class), p(ChatEngine.class));
+ final EntityOptionsLogoPanel panel = new EntityOptionsLogoPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -639,10 +639,10 @@
@Override
public EntityOptionsDefLicense create() {
final EntityOptionsDefLicensePresenter presenter = new EntityOptionsDefLicensePresenter(
- $(EntityOptions.class), $(StateManager.class), $(Session.class), $$(LicenseWizard.class),
- $$(LicenseChangeAction.class));
+ i(EntityOptions.class), i(StateManager.class), i(Session.class), p(LicenseWizard.class),
+ p(LicenseChangeAction.class));
final EntityOptionsDefLicensePanel panel = new EntityOptionsDefLicensePanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
+ i(WorkspaceSkeleton.class), i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -653,10 +653,10 @@
@Override
public EntityOptionsPublicSpaceConf create() {
final EntityOptionsPublicSpaceConfPresenter presenter = new EntityOptionsPublicSpaceConfPresenter(
- $(EntityOptions.class));
+ i(EntityOptions.class));
final EntityOptionsPublicSpaceConfPanel panel = new EntityOptionsPublicSpaceConfPanel(
- presenter, $(WorkspaceSkeleton.class), $(I18nTranslationService.class),
- $(WsThemePresenter.class));
+ presenter, i(WorkspaceSkeleton.class), i(I18nTranslationService.class),
+ i(WsThemePresenter.class));
presenter.init(panel);
return presenter;
}
@@ -665,16 +665,15 @@
register(Singleton.class, new Factory<LicenseChangeAction>(LicenseChangeAction.class) {
@Override
public LicenseChangeAction create() {
- return new LicenseChangeAction($$(GroupServiceAsync.class), $(Session.class),
- $(I18nTranslationService.class), $(StateManager.class));
+ return new LicenseChangeAction(p(GroupServiceAsync.class), i(Session.class),
+ i(I18nTranslationService.class), i(StateManager.class));
}
});
register(Singleton.class, new Factory<RenameAction>(RenameAction.class) {
@Override
public RenameAction create() {
- return new RenameAction($(I18nTranslationService.class), $(Session.class),
- $$(ContentServiceAsync.class));
+ return new RenameAction(i(I18nTranslationService.class), i(Session.class), p(ContentServiceAsync.class));
}
});
@@ -682,10 +681,10 @@
@Override
public LicenseWizard create() {
final LicenseWizardPresenter presenter = new LicenseWizardPresenter(
- $(LicenseWizardFirstFormView.class), $(LicenseWizardSndFormView.class),
- $(LicenseWizardTrdFormView.class), $(LicenseWizardFrdFormView.class), $(Session.class));
- final LicenseWizardPanel panel = new LicenseWizardPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationService.class));
+ i(LicenseWizardFirstFormView.class), i(LicenseWizardSndFormView.class),
+ i(LicenseWizardTrdFormView.class), i(LicenseWizardFrdFormView.class), i(Session.class));
+ final LicenseWizardPanel panel = new LicenseWizardPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -694,53 +693,53 @@
register(Singleton.class, new Factory<LicenseWizardFirstFormView>(LicenseWizardFirstFormView.class) {
@Override
public LicenseWizardFirstFormView create() {
- return new LicenseWizardFirstForm($(I18nTranslationService.class));
+ return new LicenseWizardFirstForm(i(I18nTranslationService.class));
}
});
register(Singleton.class, new Factory<LicenseWizardSndFormView>(LicenseWizardSndFormView.class) {
@Override
public LicenseWizardSndFormView create() {
- return new LicenseWizardSndForm($(I18nTranslationService.class));
+ return new LicenseWizardSndForm(i(I18nTranslationService.class));
}
});
register(Singleton.class, new Factory<LicenseWizardTrdFormView>(LicenseWizardTrdFormView.class) {
@Override
public LicenseWizardTrdFormView create() {
- return new LicenseWizardTrdForm($(Images.class), $(I18nTranslationService.class));
+ return new LicenseWizardTrdForm(i(Images.class), i(I18nTranslationService.class));
}
});
register(Singleton.class, new Factory<LicenseWizardFrdFormView>(LicenseWizardFrdFormView.class) {
@Override
public LicenseWizardFrdFormView create() {
- return new LicenseWizardFrdForm($(I18nTranslationService.class), $(Session.class));
+ return new LicenseWizardFrdForm(i(I18nTranslationService.class), i(Session.class));
}
});
register(Singleton.class, new Factory<FileUploader>(FileUploader.class) {
@Override
public FileUploader create() {
- final FileUploaderPresenter presenter = new FileUploaderPresenter($(Session.class));
- final FileUploaderDialog panel = new FileUploaderDialog(presenter, $(I18nUITranslationService.class),
- $(WorkspaceSkeleton.class));
+ final FileUploaderPresenter presenter = new FileUploaderPresenter(i(Session.class));
+ final FileUploaderDialog panel = new FileUploaderDialog(presenter, i(I18nUITranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(panel);
return presenter;
}
@Override
public void onAfterCreated(final FileUploader uploader) {
- $(ContextNavigator.class).addFileUploaderListener(uploader);
+ i(ContextNavigator.class).addFileUploaderListener(uploader);
}
});
register(Singleton.class, new Factory<SiteSearcher>(SiteSearcher.class) {
@Override
public SiteSearcher create() {
- final SiteSearcherPresenter presenter = new SiteSearcherPresenter($$(StateManager.class));
- final SiteSearcherView view = new SiteSearcherPanel(presenter, $(I18nTranslationService.class),
- $(WorkspaceSkeleton.class));
+ final SiteSearcherPresenter presenter = new SiteSearcherPresenter(p(StateManager.class));
+ final SiteSearcherView view = new SiteSearcherPanel(presenter, i(I18nTranslationService.class),
+ i(WorkspaceSkeleton.class));
presenter.init(view);
return presenter;
}
@@ -749,10 +748,10 @@
register(Singleton.class, new Factory<I18nTranslator>(I18nTranslator.class) {
@Override
public I18nTranslator create() {
- final I18nTranslatorPresenter presenter = new I18nTranslatorPresenter($(Session.class),
- $(I18nServiceAsync.class), $(I18nUITranslationService.class));
- final I18nTranslatorView view = new I18nTranslatorPanel(presenter, $(I18nTranslationService.class),
- $(LanguageSelector.class), $(WorkspaceSkeleton.class), $(Images.class));
+ final I18nTranslatorPresenter presenter = new I18nTranslatorPresenter(i(Session.class),
+ i(I18nServiceAsync.class), i(I18nUITranslationService.class));
+ final I18nTranslatorView view = new I18nTranslatorPanel(presenter, i(I18nTranslationService.class),
+ i(LanguageSelector.class), i(WorkspaceSkeleton.class), i(Images.class));
presenter.init(view);
return presenter;
}
@@ -761,10 +760,10 @@
register(Singleton.class, new Factory<SignIn>(SignIn.class) {
@Override
public SignIn create() {
- final SignInPresenter presenter = new SignInPresenter($(Session.class), $(StateManager.class),
- $(I18nUITranslationService.class), $$(UserServiceAsync.class), $$(Register.class));
- final SignInView panel = new SignInPanel(presenter, $(I18nTranslationService.class),
- $(WorkspaceSkeleton.class), $(Images.class));
+ final SignInPresenter presenter = new SignInPresenter(i(Session.class), i(StateManager.class),
+ i(I18nUITranslationService.class), p(UserServiceAsync.class), p(Register.class));
+ final SignInView panel = new SignInPanel(presenter, i(I18nTranslationService.class),
+ i(WorkspaceSkeleton.class), i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -773,10 +772,10 @@
register(Singleton.class, new Factory<Register>(Register.class) {
@Override
public Register create() {
- final RegisterPresenter presenter = new RegisterPresenter($(Session.class), $(StateManager.class),
- $(I18nUITranslationService.class), $$(UserServiceAsync.class), $$(SignIn.class));
- final RegisterView panel = new RegisterPanel(presenter, $(I18nTranslationService.class),
- $(WorkspaceSkeleton.class), $(Session.class), $(Images.class));
+ final RegisterPresenter presenter = new RegisterPresenter(i(Session.class), i(StateManager.class),
+ i(I18nUITranslationService.class), p(UserServiceAsync.class), p(SignIn.class));
+ final RegisterView panel = new RegisterPanel(presenter, i(I18nTranslationService.class),
+ i(WorkspaceSkeleton.class), i(Session.class), i(Images.class));
presenter.init(panel);
return presenter;
}
@@ -785,10 +784,10 @@
register(Singleton.class, new Factory<NewGroup>(NewGroup.class) {
@Override
public NewGroup create() {
- final NewGroupPresenter presenter = new NewGroupPresenter($(I18nTranslationService.class),
- $(Session.class), $(StateManager.class), $$(GroupServiceAsync.class));
- final NewGroupPanel view = new NewGroupPanel(presenter, $(I18nTranslationService.class),
- $$(LicenseWizard.class), $(Images.class));
+ final NewGroupPresenter presenter = new NewGroupPresenter(i(I18nTranslationService.class),
+ i(Session.class), i(StateManager.class), p(GroupServiceAsync.class));
+ final NewGroupPanel view = new NewGroupPanel(presenter, i(I18nTranslationService.class),
+ p(LicenseWizard.class), i(Images.class));
presenter.init(view);
return presenter;
}
@@ -799,7 +798,7 @@
public UserLiveSearcher create() {
final UserLiveSearcherPresenter presenter = new UserLiveSearcherPresenter();
final EntityLiveSearcherView view = new UserLiveSearcherPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class));
+ i(I18nTranslationService.class), i(FileDownloadUtils.class));
presenter.init(view);
return presenter;
}
@@ -810,7 +809,7 @@
public GroupLiveSearcher create() {
final GroupLiveSearcherPresenter presenter = new GroupLiveSearcherPresenter();
final EntityLiveSearcherView view = new GroupLiveSearchPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class));
+ i(I18nTranslationService.class), i(FileDownloadUtils.class));
presenter.init(view);
return presenter;
}
@@ -819,8 +818,8 @@
register(Singleton.class, new Factory<ToolSelector>(ToolSelector.class) {
@Override
public ToolSelector create() {
- final ToolSelectorPresenter presenter = new ToolSelectorPresenter($(StateManager.class),
- $(WsThemePresenter.class));
+ final ToolSelectorPresenter presenter = new ToolSelectorPresenter(i(StateManager.class),
+ i(WsThemePresenter.class));
return presenter;
}
});
@@ -828,35 +827,35 @@
register(Singleton.class, new Factory<LanguageSelector>(LanguageSelector.class) {
@Override
public LanguageSelector create() {
- final LanguageSelectorPresenter presenter = new LanguageSelectorPresenter($(Session.class));
- final LanguageSelectorView view = new LanguageSelectorPanel(presenter, $(I18nTranslationService.class));
+ final LanguageSelectorPresenter presenter = new LanguageSelectorPresenter(i(Session.class));
+ final LanguageSelectorView view = new LanguageSelectorPanel(presenter, i(I18nTranslationService.class));
presenter.init(view);
return presenter;
}
});
// Register of tokens like "signin", "newgroup", "translate" etcetera
- $(StateManager.class).addSiteToken(SiteToken.signin.toString(), new Listener0() {
+ i(StateManager.class).addSiteToken(SiteToken.signin.toString(), new Listener0() {
public void onEvent() {
- $(SignIn.class).doSignIn();
+ i(SignIn.class).doSignIn();
}
});
- $(StateManager.class).addSiteToken(SiteToken.register.toString(), new Listener0() {
+ i(StateManager.class).addSiteToken(SiteToken.register.toString(), new Listener0() {
public void onEvent() {
- $(Register.class).doRegister();
+ i(Register.class).doRegister();
}
});
- $(StateManager.class).addSiteToken(SiteToken.newgroup.toString(), new Listener0() {
+ i(StateManager.class).addSiteToken(SiteToken.newgroup.toString(), new Listener0() {
public void onEvent() {
- $(NewGroup.class).doNewGroup();
+ i(NewGroup.class).doNewGroup();
}
});
- $(StateManager.class).addSiteToken(SiteToken.translate.toString(), new Listener0() {
+ i(StateManager.class).addSiteToken(SiteToken.translate.toString(), new Listener0() {
public void onEvent() {
- $(I18nTranslator.class).doShowTranslator();
+ i(I18nTranslator.class).doShowTranslator();
}
});
@@ -864,8 +863,8 @@
@Override
public ActionContentToolbar create() {
final ActionCntCtxToolbarPanel<StateToken> tbar = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTENT_TOPBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
+ AbstractFoldableContentActions.CONTENT_TOPBAR, p(ActionManager.class),
+ i(WorkspaceSkeleton.class));
final ActionContentToolbar toolbar = new ActionContentToolbarPresenter(tbar);
return toolbar;
}
@@ -874,18 +873,18 @@
register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) {
@Override
public ContentEditor create() {
- return new ContentEditor($(RTEditorNew.class), true, $(I18nTranslationService.class),
- $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
- $(RTEImgResources.class), $(WorkspaceSkeleton.class), $(TimerWrapper.class),
- new RTESavingEditorPanel(), $(EntityTitle.class));
+ return new ContentEditor(i(RTEditorNew.class), true, i(I18nTranslationService.class),
+ i(StateManager.class), i(SiteSignOutLink.class), i(DeferredCommandWrapper.class),
+ i(RTEImgResources.class), i(WorkspaceSkeleton.class), i(TimerWrapper.class),
+ new RTESavingEditorPanel(), i(EntityTitle.class));
}
});
register(NoDecoration.class, new Factory<ActionContextTopToolbar>(ActionContextTopToolbar.class) {
@Override
public ActionContextTopToolbar create() {
final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTEXT_TOPBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
+ AbstractFoldableContentActions.CONTEXT_TOPBAR, p(ActionManager.class),
+ i(WorkspaceSkeleton.class));
final ActionContextTopToolbar toolbar = new ActionContextTopToolbar(panel);
return toolbar;
}
@@ -895,8 +894,8 @@
@Override
public ActionContextBottomToolbar create() {
final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTEXT_BOTTOMBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
+ AbstractFoldableContentActions.CONTEXT_BOTTOMBAR, p(ActionManager.class),
+ i(WorkspaceSkeleton.class));
final ActionContextBottomToolbar toolbar = new ActionContextBottomToolbar(panel);
return toolbar;
}
@@ -905,13 +904,13 @@
register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) {
@Override
public ContextNavigator create() {
- final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
- $(Session.class), $(I18nTranslationService.class), $(ContentIconsRegistry.class),
- $(ContentCapabilitiesRegistry.class), $(ActionContextTopToolbar.class),
- $(ActionContextBottomToolbar.class), $(ContextActionRegistry.class),
- $$(FileDownloadUtils.class), true, $(RenameAction.class));
+ final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter(i(StateManager.class),
+ i(Session.class), i(I18nTranslationService.class), i(ContentIconsRegistry.class),
+ i(ContentCapabilitiesRegistry.class), i(ActionContextTopToolbar.class),
+ i(ActionContextBottomToolbar.class), i(ContextActionRegistry.class),
+ p(FileDownloadUtils.class), true, i(RenameAction.class));
final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter,
- $(I18nTranslationService.class), $(WorkspaceSkeleton.class), $(ActionManager.class));
+ i(I18nTranslationService.class), i(WorkspaceSkeleton.class), i(ActionManager.class));
presenter.init(panel);
return presenter;
}
@@ -920,12 +919,12 @@
register(Singleton.class, new Factory<ContextPropEditor>(ContextPropEditor.class) {
@Override
public ContextPropEditor create() {
- final ContextPropEditorPresenter presenter = new ContextPropEditorPresenter($(Session.class),
- $(StateManager.class), $(ContentCapabilitiesRegistry.class), $$(TagsSummary.class),
- $$(ContentServiceAsync.class), $(EntitySubTitle.class));
+ final ContextPropEditorPresenter presenter = new ContextPropEditorPresenter(i(Session.class),
+ i(StateManager.class), i(ContentCapabilitiesRegistry.class), p(TagsSummary.class),
+ p(ContentServiceAsync.class), i(EntitySubTitle.class));
final ContextPropEditorView view = new ContextPropEditorPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $$(LanguageSelector.class),
- $(Images.class));
+ i(I18nUITranslationService.class), i(WorkspaceSkeleton.class), p(LanguageSelector.class),
+ i(Images.class));
presenter.init(view);
return presenter;
}
@@ -934,10 +933,10 @@
register(InsertImageGroup.class, new Factory<InsertImageLocal>(InsertImageLocal.class) {
@Override
public InsertImageLocal create() {
- final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter($(InsertImageDialog.class),
- $(Session.class));
+ final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter(i(InsertImageDialog.class),
+ i(Session.class));
final InsertImageLocalPanel panel = new InsertImageLocalPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class), $(Session.class));
+ i(I18nTranslationService.class), i(FileDownloadUtils.class), i(Session.class));
presenter.init(panel);
return presenter;
}
@@ -947,8 +946,8 @@
@Override
public MaxMinWorkspace create() {
final MaxMinWorkspacePresenter presenter = new MaxMinWorkspacePresenter();
- final MaxMinWorkspacePanel panel = new MaxMinWorkspacePanel(presenter, $(WorkspaceSkeleton.class),
- $(Images.class), $(EntityHeader.class), $(I18nTranslationService.class));
+ final MaxMinWorkspacePanel panel = new MaxMinWorkspacePanel(presenter, i(WorkspaceSkeleton.class),
+ i(Images.class), i(EntityHeader.class), i(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
@@ -957,16 +956,16 @@
register(ApplicationComponentGroup.class, new Factory<GlobalShortcutRegister>(GlobalShortcutRegister.class) {
@Override
public GlobalShortcutRegister create() {
- return new GlobalShortcutRegister($(ActionManager.class));
+ return new GlobalShortcutRegister(i(ActionManager.class));
}
});
register(InsertLinkGroup.class, new Factory<InsertLinkLocal>(InsertLinkLocal.class) {
@Override
public InsertLinkLocal create() {
- final InsertLinkLocalPresenter presenter = new InsertLinkLocalPresenter($(InsertLinkDialog.class));
- final InsertLinkLocalPanel panel = new InsertLinkLocalPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationService.class), $(FileDownloadUtils.class), $(StateTokenUtils.class));
+ final InsertLinkLocalPresenter presenter = new InsertLinkLocalPresenter(i(InsertLinkDialog.class));
+ final InsertLinkLocalPanel panel = new InsertLinkLocalPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationService.class), i(FileDownloadUtils.class), i(StateTokenUtils.class));
presenter.init(panel);
return presenter;
}
@@ -975,15 +974,15 @@
register(InsertMediaGroup.class, new Factory<InsertMediaLocal>(InsertMediaLocal.class) {
@Override
public InsertMediaLocal create() {
- final InsertMediaLocalPresenter presenter = new InsertMediaLocalPresenter($(InsertMediaDialog.class),
- $(Session.class), $$(MediaUtils.class));
+ final InsertMediaLocalPresenter presenter = new InsertMediaLocalPresenter(i(InsertMediaDialog.class),
+ i(Session.class), p(MediaUtils.class));
final InsertMediaLocalPanel panel = new InsertMediaLocalPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class));
+ i(I18nTranslationService.class), i(FileDownloadUtils.class));
presenter.init(panel);
return presenter;
}
});
- $(GlobalShortcutRegister.class).enable();
+ i(GlobalShortcutRegister.class).enable();
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPanel.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -75,7 +75,7 @@
public void addItem(final ContextNavigatorItem item) {
final String nodeId = item.getId();
- TreeNode node = treePanel.getNodeById(nodeId);
+ final TreeNode node = treePanel.getNodeById(nodeId);
if (node == null) {
// Log.info("Adding tree node " + nodeId);
@@ -101,7 +101,7 @@
}
menuItemsContainer.createItemMenu(nodeId, item.getActionCollection(),
new Listener<ActionItem<StateToken>>() {
- public void onEvent(ActionItem<StateToken> actionItem) {
+ public void onEvent(final ActionItem<StateToken> actionItem) {
doAction(actionItem);
}
});
@@ -115,7 +115,7 @@
}
}
});
- boolean isContainer = !item.getStateToken().hasAll();
+ final boolean isContainer = !item.getStateToken().hasAll();
if (isContainer) {
child.setExpandable(true);
child.setSingleClickExpand(true);
@@ -134,7 +134,7 @@
}
child.addListener(new TreeNodeListenerAdapter() {
@Override
- public void onClick(Node node, EventObject e) {
+ public void onClick(final Node node, final EventObject e) {
presenter.gotoToken(getToken(node));
}
});
@@ -164,6 +164,10 @@
treeEditor.startEdit(getNode(id));
}
+ public boolean isAttached() {
+ return treePanel != null;
+ }
+
public boolean isSelected(final String id) {
final TreeNode item = getNode(id);
if (item != null) {
@@ -195,7 +199,7 @@
this.isEditable = editable;
}
- public void setItemStatus(final String id, ContentStatusDTO status) {
+ public void setItemStatus(final String id, final ContentStatusDTO status) {
setNodeStatus(getNode(id), status);
}
@@ -311,7 +315,7 @@
this.mustFireOnTextChange = fireOnTextChange;
}
- private void setNodeStatus(final TreeNode node, ContentStatusDTO status) {
+ private void setNodeStatus(final TreeNode node, final ContentStatusDTO status) {
switch (status) {
case publishedOnline:
node.setCls("k-ctn-status-normal");
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorPresenter.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -74,9 +74,10 @@
public ContextNavigatorPresenter(final StateManager stateManager, final Session session,
final I18nTranslationService i18n, final ContentIconsRegistry contentIconsRegistry,
- ContentCapabilitiesRegistry capabilitiesRegistry, final ActionToolbar<StateToken> toolbar,
- ActionContextBottomToolbar bottomToolbar, final ActionRegistry<StateToken> actionRegistry,
- Provider<FileDownloadUtils> downloadUtilsProvider, boolean useGenericImageIcon, RenameAction renameAction) {
+ final ContentCapabilitiesRegistry capabilitiesRegistry, final ActionToolbar<StateToken> toolbar,
+ final ActionContextBottomToolbar bottomToolbar, final ActionRegistry<StateToken> actionRegistry,
+ final Provider<FileDownloadUtils> downloadUtilsProvider, final boolean useGenericImageIcon,
+ final RenameAction renameAction) {
this.stateManager = stateManager;
this.session = session;
this.i18n = i18n;
@@ -93,9 +94,9 @@
addRenameListener();
}
- public void addFileUploaderListener(FileUploader uploader) {
+ public void addFileUploaderListener(final FileUploader uploader) {
uploader.addOnUploadCompleteListener(new Listener<StateToken>() {
- public void onEvent(StateToken currentUploadStateToken) {
+ public void onEvent(final StateToken currentUploadStateToken) {
if (currentUploadStateToken.hasSameContainer(session.getCurrentStateToken())) {
stateManager.reload();
}
@@ -138,7 +139,7 @@
}
public void refreshState() {
- StateAbstractDTO currentState = session.getCurrentState();
+ final StateAbstractDTO currentState = session.getCurrentState();
if (currentState instanceof StateContainerDTO) {
setState((StateContainerDTO) currentState, true);
}
@@ -148,7 +149,7 @@
view.selectItem(genId(stateToken));
topToolbar.disableMenusAndClearButtons();
bottomToolbar.disableMenusAndClearButtons();
- ActionItemCollection<StateToken> itemCollection = actionsByItem.get(stateToken);
+ final ActionItemCollection<StateToken> itemCollection = actionsByItem.get(stateToken);
topToolbar.addActions(itemCollection, AbstractFoldableContentActions.CONTEXT_TOPBAR);
bottomToolbar.addActions(itemCollection, AbstractFoldableContentActions.CONTEXT_BOTTOMBAR);
}
@@ -157,7 +158,7 @@
editOnNextStateChange = edit;
}
- public void setItemStatus(final StateToken stateToken, ContentStatusDTO status) {
+ public void setItemStatus(final StateToken stateToken, final ContentStatusDTO status) {
clear();
refreshState();
}
@@ -209,13 +210,13 @@
}
private void addRenameListener() {
- Listener2<StateToken, String> onSuccess = new Listener2<StateToken, String>() {
- public void onEvent(StateToken token, String newName) {
+ final Listener2<StateToken, String> onSuccess = new Listener2<StateToken, String>() {
+ public void onEvent(final StateToken token, final String newName) {
setItemText(token, newName);
}
};
- Listener2<StateToken, String> onFail = new Listener2<StateToken, String>() {
- public void onEvent(StateToken token, String oldName) {
+ final Listener2<StateToken, String> onFail = new Listener2<StateToken, String>() {
+ public void onEvent(final StateToken token, final String oldName) {
setItemText(token, oldName);
}
};
@@ -264,7 +265,7 @@
}
}
- private String getTooltip(StateToken token, BasicMimeTypeDTO mimeType) {
+ private String getTooltip(final StateToken token, final BasicMimeTypeDTO mimeType) {
if (mimeType != null && (mimeType.isImage() || mimeType.isPdf())) {
return KuneUiUtils.genQuickTipWithImage(downloadUtilsProvider.get().getImageResizedUrl(token,
ImageSize.thumb), session.getImgCropsize());
@@ -288,12 +289,14 @@
}
private void setItemText(final StateToken stateToken, final String name) {
- view.setItemText(genId(stateToken), name);
+ if (view.isAttached()) {
+ view.setItemText(genId(stateToken), name);
+ }
}
private void setStateContainer(final StateContainerDTO state, final boolean select) {
final StateToken stateToken = state.getStateToken();
- boolean isContent = (state instanceof StateContentDTO);
+ final boolean isContent = (state instanceof StateContentDTO);
StateContentDTO stateContent = null;
final ContainerDTO container = state.getContainer();
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/ctxnav/ContextNavigatorView.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -33,6 +33,8 @@
void editItem(String id);
+ boolean isAttached();
+
boolean isSelected(String id);
void selectItem(String id);
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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -1,8 +1,9 @@
package org.ourproject.kune.workspace.client.editor;
-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 static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_ICON;
+import static org.ourproject.kune.platf.client.actions.AbstractExtendedAction.NO_TEXT;
+import org.ourproject.kune.platf.client.actions.AbstractExtendedAction;
import org.ourproject.kune.platf.client.actions.Action;
import org.ourproject.kune.platf.client.actions.ActionEvent;
import org.ourproject.kune.platf.client.actions.KeyStroke;
@@ -11,7 +12,6 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.shortcuts.Keyboard;
import org.ourproject.kune.platf.client.state.StateManager;
-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;
@@ -36,7 +36,7 @@
public class ContentEditor extends RTESavingEditorPresenter {
- public class RenameAction extends AbstractRTEAction {
+ public class RenameAction extends AbstractExtendedAction {
public RenameAction(final String text, final String tooltip, final ImageResource icon) {
super(text, tooltip, icon);
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-10 14:37:53 UTC (rev 1124)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -25,6 +25,7 @@
import org.ourproject.kune.platf.client.dto.UserSimpleDTO;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
+import org.ourproject.kune.platf.client.services.AbstractExtendedModule;
import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.shortcuts.ShortcutDescriptor;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
@@ -37,7 +38,6 @@
import com.calclab.suco.client.events.Listener0;
import com.calclab.suco.client.ioc.Provider;
import com.calclab.suco.client.ioc.decorator.Singleton;
-import com.calclab.suco.client.ioc.module.AbstractModule;
import com.calclab.suco.client.ioc.module.Factory;
import com.google.gwt.user.client.ui.Label;
@@ -45,7 +45,7 @@
* This module is installed via Suco.install(new HelloWorldModule()). In kune we
* do this normally in KuneEntryPoint.onModuleLoadCont()
*/
-public class HelloWorldModule extends AbstractModule {
+public class HelloWorldModule extends AbstractExtendedModule {
/**
*
@@ -110,7 +110,7 @@
* Summary)
**/
private void createActions() {
- ActionToolbarMenuDescriptor<UserSimpleDTO> helloWorldBuddiesAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>(
+ final ActionToolbarMenuDescriptor<UserSimpleDTO> helloWorldBuddiesAction = new ActionToolbarMenuDescriptor<UserSimpleDTO>(
AccessRolDTO.Viewer, AbstractFoldableContentActions.CONTENT_TOPBAR, new Listener<UserSimpleDTO>() {
public void onEvent(final UserSimpleDTO parameter) {
// We clicked:
@@ -158,8 +158,8 @@
* can use then from other objects.
*
* If we want to use HelloWorld from other modules we can use:
- * $(HelloWorld.class) to get a instance or $$(HelloWorld.class) to get
- * a provider of the instance. This is useful when we want to do lazy
+ * i(HelloWorld.class) to get a instance or p(HelloWorld.class) to get a
+ * provider of the instance. This is useful when we want to do lazy
* creation of objects: http://en.wikipedia.org/wiki/Lazy_initialization
*
**/
@@ -174,14 +174,14 @@
*/
@Override
public HelloWorld create() {
- final HelloWorldPresenter presenter = new HelloWorldPresenter($(I18nTranslationServiceMocked.class),
- $$(UserActionRegistry.class));
- final HelloWorldPanel panel = new HelloWorldPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nTranslationServiceMocked.class));
+ final HelloWorldPresenter presenter = new HelloWorldPresenter(i(I18nTranslationServiceMocked.class),
+ p(UserActionRegistry.class));
+ final HelloWorldPanel panel = new HelloWorldPanel(presenter, i(WorkspaceSkeleton.class),
+ i(I18nTranslationServiceMocked.class));
presenter.init(panel);
return presenter;
// now Suco knows how to create HelloWorld instance when we use
- // $(HelloWorld.class) or $$(HelloWorld.class in a module.
+ // i(HelloWorld.class) or p(HelloWorld.class in a module.
}
/**
@@ -208,7 +208,7 @@
/**
* Global shortcut sample definition
*/
- $(GlobalShortcutRegister.class).put(new ShortcutDescriptor(false, true, false, 'S'), new Listener0() {
+ i(GlobalShortcutRegister.class).put(new ShortcutDescriptor(false, true, false, 'S'), new Listener0() {
public void onEvent() {
NotifyUser.info("Global Ctrl+S pressed");
}
@@ -217,6 +217,6 @@
// And because nobody use this module, we get the class (to force the
// creation of the
// Helloworld instance):
- // $(HelloWorld.class);
+ // i(HelloWorld.class);
}
}
\ No newline at end of file
Modified: 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/KeyStrokeTest.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -60,10 +60,14 @@
@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);
+ final KeyStroke key1 = KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_ALT);
+ final KeyStroke key2 = KeyStroke.getKeyStroke(Character.valueOf('B'), Keyboard.MODIFIER_ALT);
assertEquals(key1, key2);
- assertEquals(key1, key3);
}
+
+ @Test
+ public void space() {
+ final KeyStroke key = KeyStroke.getKeyStroke(Character.valueOf(' '), Keyboard.MODIFIER_ALT);
+ assertEquals(" (Alt+Space)", key.toString());
+ }
}
\ 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-10 14:37:53 UTC (rev 1124)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-06-11 18:28:19 UTC (rev 1125)
@@ -7,7 +7,6 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.mockito.internal.verification.api.VerificationMode;
-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;
@@ -31,7 +30,7 @@
private DeferredCommandWrapper deferredCommandWrapper;
private RTEditorNew rteEditor;
private TimerWrapper timer;
- private ComplexToolbar sndbar;
+ // private ComplexToolbar sndbar;
private RTESavingEditorView view;
@Before
@@ -45,8 +44,8 @@
final ImageResource imageResource = Mockito.mock(ImageResource.class);
Mockito.when(imageResource.getName()).thenReturn("save");
Mockito.when(imgResources.save()).thenReturn(imageResource);
- sndbar = Mockito.mock(ComplexToolbar.class);
- Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
+ // sndbar = Mockito.mock(ComplexToolbar.class);
+ // Mockito.when(rteEditor.getSndBar()).thenReturn(sndbar);
timer = Mockito.mock(TimerWrapper.class);
view = Mockito.mock(RTESavingEditorView.class);
presenter = new RTESavingEditorPresenter(rteEditor, true, i18n, stateManager, deferredCommandWrapper,
@@ -83,6 +82,13 @@
}
@Test
+ public void initialEdit() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ checkSaveBtnDisabled();
+ assertTrue(cancelListener.isNotCalled());
+ }
+
+ @Test
public void initialEditWithCancel() {
presenter.edit("Text to edit", saveListener, cancelListener);
presenter.onCancel();
@@ -97,21 +103,13 @@
Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
presenter.onEdit();
presenter.onDoSave();
+ presenter.onSavedSuccessful();
checkSaveBtnDisabled();
assertTrue(saveListener.isCalledWithEquals(textModified));
assertTrue(cancelListener.isNotCalled());
}
@Test
- public void initialEditWithSave() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onDoSave();
- checkSaveBtnDisabled();
- assertTrue(saveListener.isCalledOnce());
- assertTrue(cancelListener.isNotCalled());
- }
-
- @Test
public void testSavePendingAndCancel() {
presenter.edit("Text to edit", saveListener, cancelListener);
final String textModified = "Text modified";
@@ -132,13 +130,13 @@
presenter.onDoSave();
presenter.onSaveFailed();
presenter.onDoSave();
- Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_IN_MILLISECONDS);
- Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
+ Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_IN_MILLIS);
+ Mockito.verify(timer, Mockito.times(1)).schedule(RTESavingEditorPresenter.AUTOSAVE_AFTER_FAIL_MILLS);
assertTrue(saveListener.isCalled(2));
}
private void checkSaveBtnDisabled() {
- Mockito.verify(presenter.saveAction, Mockito.times(1)).setEnabled(false);
+ assertFalse(presenter.saveAction.isEnabled());
}
private String editAndChangeHistoryToken() {
1
0
10 Jun '09
Author: vjrj
Date: 2009-06-10 16:37:53 +0200 (Wed, 10 Jun 2009)
New Revision: 1124
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.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/BasicGuiBinding.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/MenuCheckItemDescriptor.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/PushButtonBinding.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.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/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/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
Log:
Complete - task Font selectors with show current font in RTE
and lot of improvements and fixes in new RTE actions
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/AbstractAction.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -89,7 +89,8 @@
* the name (<code>null</code> permitted).
*/
public AbstractAction(final String name) {
- // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+ // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+ // 15:19
putValue(NAME, name);
}
@@ -105,9 +106,11 @@
* the icon (<code>null</code> permitted).
*/
public AbstractAction(final String name, final ImageResource icon) {
- // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+ // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+ // 15:19
putValue(NAME, name);
- // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09 15:19
+ // @PMD:REVIEWED:ConstructorCallsOverridableMethod: by vjrj on 21/05/09
+ // 15:19
putValue(SMALL_ICON, icon);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/PropertyChangeSupport.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -96,7 +96,8 @@
public PropertyChangeSupport(final Object source) {
this.source = source;
if (source == null) {
- // @PMD:REVIEWED:AvoidThrowingNullPointerException: by vjrj on 21/05/09 14:12
+ // @PMD:REVIEWED:AvoidThrowingNullPointerException: by vjrj on
+ // 21/05/09 14:12
throw new NullPointerException();
}
}
@@ -119,7 +120,7 @@
}
if (l instanceof PropertyChangeListenerProxy) {
- PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+ final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
addPropertyChangeListener(p.propertyName, (PropertyChangeListener) p.getListener());
} else {
if (listeners == null) {
@@ -156,7 +157,7 @@
}
while (l instanceof PropertyChangeListenerProxy) {
- PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+ final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
if (propertyName == null ? p.propertyName != null : !propertyName.equals(p.propertyName)) {
return;
}
@@ -238,10 +239,10 @@
(v.get(i)).propertyChange(event);
}
}
- HashMap<String, PropertyChangeSupport> h = children; // Be
+ final HashMap<String, PropertyChangeSupport> h = children; // Be
// thread-safe.
if (h != null && event.propertyName != null) {
- PropertyChangeSupport s = h.get(event.propertyName);
+ final PropertyChangeSupport s = h.get(event.propertyName);
if (s != null) {
v = s.listeners; // Be thread-safe.
int i = v == null ? 0 : v.size();
@@ -320,17 +321,17 @@
* @since 1.4
*/
public PropertyChangeListener[] getPropertyChangeListeners() {
- ArrayList<PropertyChangeListener> list = new ArrayList<PropertyChangeListener>();
+ final ArrayList<PropertyChangeListener> list = new ArrayList<PropertyChangeListener>();
if (listeners != null) {
list.addAll(listeners);
}
if (children != null) {
int i = children.size();
- Iterator<Entry<String, PropertyChangeSupport>> iter = children.entrySet().iterator();
+ final Iterator<Entry<String, PropertyChangeSupport>> iter = children.entrySet().iterator();
while (--i >= 0) {
- Entry<String, PropertyChangeSupport> e = iter.next();
- String name = e.getKey();
- Vector<PropertyChangeListener> v = (e.getValue()).listeners;
+ final Entry<String, PropertyChangeSupport> e = iter.next();
+ final String name = e.getKey();
+ final Vector<PropertyChangeListener> v = (e.getValue()).listeners;
int j = v.size();
while (--j >= 0) {
list.add(new PropertyChangeListenerProxy(name, v.get(j)));
@@ -352,7 +353,7 @@
if (children == null || propertyName == null) {
return new PropertyChangeListener[0];
}
- PropertyChangeSupport s = children.get(propertyName);
+ final PropertyChangeSupport s = children.get(propertyName);
if (s == null) {
return new PropertyChangeListener[0];
}
@@ -387,7 +388,7 @@
*/
public void removePropertyChangeListener(final PropertyChangeListener l) {
if (l instanceof PropertyChangeListenerProxy) {
- PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+ final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
removePropertyChangeListener(p.propertyName, (PropertyChangeListener) p.getListener());
} else if (listeners != null) {
listeners.remove(l);
@@ -417,12 +418,12 @@
if (children == null) {
return;
}
- PropertyChangeSupport s = children.get(propertyName);
+ final PropertyChangeSupport s = children.get(propertyName);
if (s == null) {
return;
}
while (l instanceof PropertyChangeListenerProxy) {
- PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
+ final PropertyChangeListenerProxy p = (PropertyChangeListenerProxy) l;
if (propertyName == null ? p.propertyName != null : !propertyName.equals(p.propertyName)) {
return;
}
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/AbstractMenuItemGui.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,6 +3,8 @@
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.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;
@@ -24,9 +26,11 @@
if (descriptor instanceof MenuRadioItemDescriptor) {
final CheckItem checkItem = createCheckItem(descriptor);
checkItem.setGroup(((MenuRadioItemDescriptor) descriptor).getGroup());
+ confCheckListener(descriptor, checkItem);
item = checkItem;
} else if (descriptor instanceof MenuCheckItemDescriptor) {
final CheckItem checkItem = createCheckItem(descriptor);
+ confCheckListener(descriptor, checkItem);
item = checkItem;
} else {
item = new Item();
@@ -66,7 +70,6 @@
@Override
protected void setIcon(final ImageResource imageResource) {
if (imageResource != null) {
- // FIXME
item.setIconCls(ImgConstants.CSS_SUFFIX + imageResource.getName());
}
}
@@ -90,6 +93,16 @@
}
}
+ private void confCheckListener(final MenuItemDescriptor descriptor, final CheckItem checkItem) {
+ descriptor.action.addPropertyChangeListener(new PropertyChangeListener() {
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getPropertyName().equals(MenuCheckItemDescriptor.CHECKED)) {
+ checkItem.setChecked((Boolean) event.getNewValue());
+ }
+ }
+ });
+ }
+
private CheckItem createCheckItem(final MenuItemDescriptor descriptor) {
final CheckItem checkItem = new CheckItem();
checkItem.setChecked(((MenuCheckItemDescriptor) descriptor).isChecked());
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/BasicGuiBinding.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -9,8 +9,8 @@
bindings.register(MenuCheckItemDescriptor.class, menuItemBinding);
bindings.register(MenuItemDescriptor.class, menuItemBinding);
bindings.register(MenuSeparatorDescriptor.class, new MenuSeparatorBinding());
+ bindings.register(PushButtonDescriptor.class, new PushButtonBinding());
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/GuiActionDescrip.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/GuiActionDescrip.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -1,11 +1,9 @@
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;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
/**
* The Class AbstractUIActionDescriptor.
@@ -20,7 +18,6 @@
private GuiVisibleCondition visibleCondition = new GuiVisibleConditionAdapter();
protected GuiActionDescrip parent;
- private final Map<String, Object> store;
/** The action. */
protected AbstractAction action;
@@ -42,9 +39,12 @@
this.action = action;
position = NO_POSITION;
parent = NO_PARENT;
- store = new HashMap<String, Object>();
}
+ public void fire(final ActionEvent event) {
+ action.actionPerformed(event);
+ }
+
public GuiAddCondition getAddCondition() {
return addCondition;
}
@@ -86,7 +86,7 @@
* @see #putValue(String, Object)
*/
public Object getValue(final String key) {
- return store.get(key);
+ return action.getValue(key);
}
public GuiVisibleCondition getVisibleCondition() {
@@ -109,7 +109,7 @@
* the value (<code>null</code> permitted).
*/
public void putValue(final String key, final Object value) {
- store.put(key, value);
+ action.putValue(key, value);
}
public void setAddCondition(final GuiAddCondition addCondition) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuCheckItemDescriptor.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,7 +3,7 @@
import org.ourproject.kune.platf.client.actions.AbstractAction;
public class MenuCheckItemDescriptor extends MenuItemDescriptor {
- private static final String CHECKED = "checked";
+ public static final String CHECKED = "checked";
private boolean checked = false;
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/MenuGui.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -6,6 +6,8 @@
import com.google.gwt.libideas.resources.client.ImageResource;
import com.gwtext.client.widgets.ToolbarButton;
+import com.gwtext.client.widgets.menu.Menu;
+import com.gwtext.client.widgets.menu.event.MenuListenerAdapter;
public class MenuGui extends AbstractMenuGui {
@@ -18,13 +20,18 @@
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)) {
+ public void propertyChange(final PropertyChangeEvent event) {
+ if (event.getPropertyName().equals(MenuDescriptor.MENU_HIDE) && event.getNewValue().equals(true)) {
menu.hide(true);
- descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
}
}
});
+ menu.addListener(new MenuListenerAdapter() {
+ @Override
+ public void onShow(final Menu menu) {
+ descriptor.action.putValue(MenuDescriptor.MENU_HIDE, false);
+ }
+ });
}
public void add(final SubMenuGui submenu) {
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonBinding.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -4,7 +4,7 @@
@Override
public AbstractGuiItem create(final GuiActionDescrip descriptor) {
- return new ButtonGui((ButtonDescriptor) descriptor, true);
+ return new PushButtonGui((PushButtonDescriptor) descriptor);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ui/PushButtonGui.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -8,7 +8,7 @@
public PushButtonGui(final PushButtonDescriptor btn) {
super(btn, true);
setPressed(btn.isPushed());
- action.addPropertyChangeListener(new PropertyChangeListener() {
+ btn.action.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(final PropertyChangeEvent event) {
if (event.getPropertyName().equals(PushButtonDescriptor.PUSHED)) {
setPressed(btn.isPushed());
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -59,11 +59,8 @@
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
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;
@@ -337,22 +334,8 @@
}
});
- register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
+ register(NoDecoration.class,new Factory<RTEditorNew>(RTEditorNew.class) {
@Override
- public RTEditor create() {
- final RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
- final RTEActionSndToolbar sndBar = $(RTEActionSndToolbar.class);
- final RTEditorPresenter presenter = new RTEditorPresenter($(I18nTranslationService.class),
- $(Session.class), topBar, sndBar, $(RTEImgResources.class), $$(InsertLinkDialog.class),
- $$(ColorWebSafePalette.class), $$(EditHtmlDialog.class), $$(InsertImageDialog.class),
- $$(InsertMediaDialog.class), $$(InsertTableDialog.class), $$(InsertSpecialCharDialog.class), $(DeferredCommandWrapper.class));
- final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
- $(ActionManager.class), $(GlobalShortcutRegister.class));
- 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),
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -3,7 +3,7 @@
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.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.saving.RTESavingEditor;
import com.google.gwt.user.client.ui.VerticalPanel;
@@ -23,9 +23,8 @@
final RTEditorNew basicEditor = editor.getBasicEditor();
vp.add((ComplexToolbar) basicEditor.getTopBar());
vp.add((ComplexToolbar) basicEditor.getSndBar());
- final RTEditorPanel editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
+ final RTEditorPanelNew editorPanel = (RTEditorPanelNew) basicEditor.getEditorArea();
vp.add(editorPanel);
- basicEditor.setExtended(true);
vp.setWidth("100%");
dialog.add(vp);
dialog.addListener(new WindowListenerAdapter() {
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTELinkPopup.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -1,5 +1,7 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
+import org.ourproject.kune.platf.client.actions.Action;
+import org.ourproject.kune.platf.client.actions.ActionEvent;
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;
@@ -9,6 +11,7 @@
import com.calclab.suco.client.events.Listener0;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
@@ -32,7 +35,16 @@
}
public void add(final GuiActionDescrip item) {
- // TODO
+ final Label actionLabel = new Label();
+ actionLabel.setText((String) item.getValue(Action.NAME));
+ actionLabel.addStyleName("k-rte-changelink");
+ KuneUiUtils.setUnselectable(actionLabel.getElement());
+ actionLabel.addClickHandler(new ClickHandler() {
+ public void onClick(final ClickEvent event) {
+ item.fire(new ActionEvent(actionLabel, (Event) event.getNativeEvent()));
+ }
+ });
+ hpanel.insert(actionLabel, 0);
}
@Deprecated
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanelNew.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -2,6 +2,7 @@
import java.util.Date;
+import org.cobogw.gwt.user.client.CSS;
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.actions.AbstractAction;
import org.ourproject.kune.platf.client.actions.ActionEvent;
@@ -27,6 +28,7 @@
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.Node;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
import com.google.gwt.event.dom.client.FocusEvent;
@@ -39,6 +41,7 @@
public class RTEditorPanelNew extends AbstractComplexGuiItem implements RTEditorViewNew, FocusHandler, BlurHandler {
+ private static final Element NO_ELEMENT = null;
private final I18nUITranslationService i18n;
private final BasicFormatter basic;
private final ExtendedFormatter extended;
@@ -120,6 +123,16 @@
setFocus(true);
}
+ public String getFont() {
+ final Element currentElement = getCurrentElement();
+ return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty(CSS.A.FONT_FAMILY);
+ }
+
+ public String getFontSize() {
+ final Element currentElement = getCurrentElement();
+ return currentElement == NO_ELEMENT ? "" : currentElement.getStyle().getProperty("size");
+ }
+
public String getHTML() {
return rta.getHTML();
}
@@ -292,7 +305,6 @@
// 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();
@@ -420,6 +432,17 @@
presenter.fireOnEdit();
}
+ protected Element getElement(final Node inputNode) {
+ Node node = inputNode;
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ node = node.getParentNode();
+ }
+ if (node == null || node.getNodeType() != Node.ELEMENT_NODE) {
+ return null;
+ }
+ return Element.as(node);
+ }
+
private void createCommentAndSelectIt(final String author, final String comment) {
final Element commentEl = createCommentElement(author, comment);
final Range innerCommentRange = rta.getDocument().createRange();
@@ -439,6 +462,14 @@
return span;
}
+ private Element getCurrentElement() {
+ if (getSelection().getRangeCount() > 0) {
+ return getElement(getSelection().getRangeAt(0).getStartContainer());
+ } else {
+ return NO_ELEMENT;
+ }
+ }
+
private Range getFstRange() {
return getSelection().getRangeAt(0);
}
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenterNew.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -4,7 +4,9 @@
import static org.ourproject.kune.platf.client.ui.rte.basic.AbstractRTEAction.NO_TEXT;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.ourproject.kune.platf.client.View;
import org.ourproject.kune.platf.client.actions.AbstractAction;
@@ -16,8 +18,10 @@
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.MenuCheckItemDescriptor;
import org.ourproject.kune.platf.client.actions.ui.MenuDescriptor;
import org.ourproject.kune.platf.client.actions.ui.MenuItemDescriptor;
+import org.ourproject.kune.platf.client.actions.ui.MenuRadioItemDescriptor;
import org.ourproject.kune.platf.client.actions.ui.MenuSeparatorDescriptor;
import org.ourproject.kune.platf.client.actions.ui.PushButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ui.ToolbarSeparatorDescriptor;
@@ -248,18 +252,23 @@
}
public class FontAction extends AbstractRTEAction {
- private final String fontName;
+ public static final String FONT_NAME = "fontname";
public FontAction(final String fontName, final String tooltip, final ImageResource icon) {
super("<span style=\"font-family: " + fontName + "\">" + fontName + "</span>", tooltip, icon);
- this.fontName = fontName;
+ super.putValue(FONT_NAME, fontName);
}
public void actionPerformed(final ActionEvent actionEvent) {
+ final String fontName = getFontName();
view.setFontName(fontName);
fontMenu.setText(fontName);
fireOnEdit();
}
+
+ private String getFontName() {
+ return (String) super.getValue(FONT_NAME);
+ }
}
public class FontColorAction extends AbstractRTEAction {
@@ -282,20 +291,18 @@
}
public class FontSizeAction extends AbstractRTEAction {
- private final String fontSizeName;
private final int fontSize;
public FontSizeAction(final String fontSizeName, final int fontSize, final String tooltip,
final ImageResource icon) {
super("<font size=\"" + (fontSize + 1) + "\">" + fontSizeName + "</font>", tooltip, icon);
- this.fontSizeName = fontSizeName;
this.fontSize = fontSize;
}
public void actionPerformed(final ActionEvent actionEvent) {
view.setFontSize(FONT_SIZES[fontSize]);
fireOnEdit();
- fontSizeMenu.setText(fontSizeName);
+ // fontSizeMenu.setText(fontSizeName);
}
}
@@ -623,6 +630,8 @@
RichTextArea.FontSize.XX_SMALL, RichTextArea.FontSize.X_SMALL, RichTextArea.FontSize.SMALL,
RichTextArea.FontSize.MEDIUM, RichTextArea.FontSize.LARGE, RichTextArea.FontSize.X_LARGE,
RichTextArea.FontSize.XX_LARGE };
+ private static final String FONT_GROUP = "fontgroup";
+ private static final String FONT_SIZEGROUP = "fontsizegroup";
private RTEditorViewNew view;
private boolean extended;
@@ -662,6 +671,8 @@
private MenuDescriptor fileMenu;
private final List<MenuDescriptor> menus;
private boolean attached;
+ private final Map<String, MenuCheckItemDescriptor> fontActions;
+ private MenuCheckItemDescriptor currentFontItem;
public RTEditorPresenterNew(final I18nTranslationService i18n, final Session session,
final RTEImgResources imgResources, final Provider<InsertLinkDialog> insLinkDialog,
@@ -683,11 +694,10 @@
menus = new ArrayList<MenuDescriptor>();
this.imgResources = imgResources;
- extended = true;
this.onEdit = new Event0("onRTEEdit");
extendedAddCond = new GuiAddCondition() {
public boolean mustBeAdded() {
- return isExtended();
+ return isAndCanBeExtended();
}
};
basicAddCond = new GuiAddCondition() {
@@ -696,6 +706,7 @@
}
};
attached = false;
+ fontActions = new HashMap<String, MenuCheckItemDescriptor>();
}
public void addAction(final GuiActionDescrip descriptor) {
@@ -814,8 +825,8 @@
}
}
- public void setExtended(final boolean extended) {
- this.extended = extended;
+ public void setExtended(final boolean newValue) {
+ this.extended = newValue;
}
public void setFocus(final boolean focus) {
@@ -835,7 +846,7 @@
public void updateLinkInfo() {
deferred.addCommand(new Listener0() {
public void onEvent() {
- if (isExtended() && view.isLink()) {
+ if (isAndCanBeExtended() && view.isLink()) {
view.showLinkCtxMenu();
} else {
hideLinkCtxMenu();
@@ -849,8 +860,14 @@
bold.setPushed(view.isBold());
italic.setPushed(view.isItalic());
underline.setPushed(view.isUnderlined());
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ updateFont();
+ // Log.warn(view.getFontSize());
+ }
+ });
}
- if (isExtended()) {
+ if (isAndCanBeExtended()) {
strikethrough.setPushed(view.isStrikethrough());
}
}
@@ -866,8 +883,11 @@
final MenuSeparatorDescriptor editMenuSep = new MenuSeparatorDescriptor(editMenu);
final MenuSeparatorDescriptor insertMenuSep = new MenuSeparatorDescriptor(insertMenu);
final MenuSeparatorDescriptor formatMenuSep = new MenuSeparatorDescriptor(formatMenu);
+ insertMenuSep.setAddCondition(extendedAddCond);
final ToolbarSeparatorDescriptor sndbarSep = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+ final ToolbarSeparatorDescriptor sndbarSepExt = new ToolbarSeparatorDescriptor(Type.separator, getSndBar());
+ sndbarSepExt.setAddCondition(extendedAddCond);
final SelectAllAction selectAllAction = new SelectAllAction(i18n.t("Select all"), AbstractRTEAction.NO_TEXT,
imgResources.selectall());
@@ -1051,7 +1071,7 @@
final FontColorAction fontColorAction = new FontColorAction(NO_TEXT, i18n.t("Text Colour"),
imgResources.fontcolor());
final ButtonDescriptor fontColor = new ButtonDescriptor(fontColorAction);
- fontColor.setAddCondition(extendedAddCond);
+ fontColor.setAddCondition(basicAddCond);
final BackgroundColorAction backColorAction = new BackgroundColorAction(NO_TEXT,
i18n.t("Text Background Colour"), imgResources.backcolor());
@@ -1069,20 +1089,20 @@
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);
+ decreaseIndent, increaseIndent, olist, ulist, sndbarSep, removeFormatBtn, sndbarSepExt, hlineBtn,
+ imgBtn, editLinkBtn, removeLinkBtn, insertTableBtn, sndbarSepExt, subscript, superscript, blockquote,
+ fontColor, backgroundColor, fontSizeMenu, fontMenu, editLinkCtx, removeLinkCtx);
// actions.add(devInfo);
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(SNDBAR, new GuiActionDescrip[] { undoBtn, redoBtn, sndbarSep, sndbarSepExt, 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[] { removeLinkCtx, editLinkCtx });
for (final String fontName : FONT_NAMES) {
createFontAction(fontMenu, fontName);
@@ -1095,22 +1115,22 @@
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);
+ final MenuRadioItemDescriptor font = new MenuRadioItemDescriptor(fontMenu, fontAction, FONT_GROUP);
font.setAddCondition(basicAddCond);
font.setLocation(SNDBAR);
- fontMenu.setText(fontName);
+ fontActions.put(fontName.toLowerCase(), font);
actions.add(font);
}
private void createFontSizeAction(final MenuDescriptor fontSizeMenu, final int fontSize) {
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);
+ final MenuRadioItemDescriptor fontSizeItem = new MenuRadioItemDescriptor(fontSizeMenu, fontSizeAction,
+ FONT_SIZEGROUP);
fontSizeItem.setAddCondition(basicAddCond);
setActionShortcut(KeyStroke.getKeyStroke(Character.valueOf(((char) (48 + fontSize))), Keyboard.MODIFIER_CTRL),
fontSizeAction);
fontSizeItem.setLocation(SNDBAR);
- fontSizeMenu.setText(fontSizeName);
actions.add(fontSizeItem);
}
@@ -1122,6 +1142,7 @@
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()));
+ insertMenu.setAddCondition(extendedAddCond);
}
private void createPalette() {
@@ -1145,7 +1166,7 @@
}
}
- private boolean isExtended() {
+ private boolean isAndCanBeExtended() {
return extended && view.canBeExtended();
}
@@ -1155,4 +1176,18 @@
}
}
+ private void updateFont() {
+ final String currentFont = view.getFont();
+ final MenuCheckItemDescriptor item = fontActions.get(currentFont);
+ if (currentFontItem != null && item != currentFontItem) {
+ currentFontItem.setChecked(false);
+ }
+ if (item != null) {
+ item.setChecked(true);
+ currentFontItem = item;
+ fontMenu.setText((String) item.getValue(FontAction.FONT_NAME));
+ } else {
+ fontMenu.setText(" ");
+ }
+ }
}
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-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorViewNew.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -26,6 +26,10 @@
void focus();
+ String getFont();
+
+ String getFontSize();
+
String getHTML();
LinkInfo getLinkInfoIfHref();
@@ -133,5 +137,4 @@
void undo();
void unlink();
-
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-09 18:56:54 UTC (rev 1123)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/siteoptions/SiteOptionsPanel.java 2009-06-10 14:37:53 UTC (rev 1124)
@@ -58,24 +58,24 @@
}
});
- // final Item testRTE = new Item(i18n.t("Test new RTE"), new
- // BaseItemListenerAdapter() {
- // @Override
- // public void onClick(final BaseItem item, final EventObject e) {
- // editor.get().show();
- // }
- // }, "");
- //
- // final Item testRTEbasic = new
- // Item(i18n.t("Test new RTE (basic mode)"), new
- // BaseItemListenerAdapter() {
- // @Override
- // public void onClick(final BaseItem item, final EventObject e) {
- // editor.get().setExtended(false);
- // editor.get().show();
- // }
- // }, "");
+ final Item testRTE = new Item(i18n.t("Test new RTE"), new BaseItemListenerAdapter() {
+ @Override
+ public void onClick(final BaseItem item, final EventObject e) {
+ final TestRTEDialog testRTEDialog = editor.get();
+ testRTEDialog.setExtended(true);
+ testRTEDialog.show();
+ }
+ }, "");
+ final Item testRTEbasic = new Item(i18n.t("Test new RTE (basic mode)"), new BaseItemListenerAdapter() {
+ @Override
+ public void onClick(final BaseItem item, final EventObject e) {
+ final TestRTEDialog testRTEDialog = editor.get();
+ testRTEDialog.setExtended(false);
+ testRTEDialog.show();
+ }
+ }, "");
+
final Item linkHelpInTrans = new Item(i18n.t("Help with the translation"), new BaseItemListenerAdapter() {
@Override
public void onClick(final BaseItem item, final EventObject e) {
@@ -91,6 +91,8 @@
KuneWindowUtils.open("http://ourproject.org/tracker/?group_id=407");
}
}, "images/kuneicon16.gif");
+ optionsMenu.addItem(testRTEbasic);
+ optionsMenu.addItem(testRTE);
optionsMenu.addItem(linkHelpInTrans);
optionsMenu.addItem(linkKuneBugs);
}
1
0
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;
1
0
Author: vjrj
Date: 2009-06-08 16:37:50 +0200 (Mon, 08 Jun 2009)
New Revision: 1122
Removed:
trunk/src/main/webapp/
Modified:
trunk/pom.xml
trunk/script/css-update.sh
trunk/script/deploy_gwt.sh
Log:
Incomplete - task upgrade to gwt 1.6.4
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/pom.xml 2009-06-08 14:37:50 UTC (rev 1122)
@@ -680,6 +680,7 @@
</execution>
</executions>
</plugin>
+ <!--
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.2</version>
@@ -695,6 +696,7 @@
</filesets>
</configuration>
</plugin>
+ -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Modified: trunk/script/css-update.sh
===================================================================
--- trunk/script/css-update.sh 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/script/css-update.sh 2009-06-08 14:37:50 UTC (rev 1122)
@@ -1,10 +1,10 @@
#!/bin/bash
APPPUB=src/main/java/org/ourproject/kune/app/public
-WEBAPP=src/main/webapp/gwt/ws
+#WEBAPP=src/main/webapp/gwt/ws
$PWD/script/css-compact-and-tidy.sh
-rsync -aC $APPPUB/ws.html $WEBAPP/ws.html
-rsync -aC $APPPUB/js/ $WEBAPP/js
-rsync -aC $APPPUB/css/ $WEBAPP/css
-rsync -aC $APPPUB/images/ $WEBAPP/images
+#rsync -aC $APPPUB/ws.html $WEBAPP/ws.html
+#rsync -aC $APPPUB/js/ $WEBAPP/js
+#rsync -aC $APPPUB/css/ $WEBAPP/css
+#rsync -aC $APPPUB/images/ $WEBAPP/images
Modified: trunk/script/deploy_gwt.sh
===================================================================
--- trunk/script/deploy_gwt.sh 2009-06-08 14:18:03 UTC (rev 1121)
+++ trunk/script/deploy_gwt.sh 2009-06-08 14:37:50 UTC (rev 1122)
@@ -1,6 +1,6 @@
#!/bin/bash
-mkdir -p src/main/webapp/gwt/ws
+#mkdir -p src/main/webapp/gwt/ws
#find target/kune-0.0.5/org.ourproject.kune.app.Kune/ -name .DS_Store -exec rm {} \;
@@ -8,5 +8,5 @@
script/css-update.sh
#cp target/kune-0.0.5/org.ourproject.kune.app.Kune/js/ext/ext-all-debug.js target/kune-0.0.5/org.ourproject.kune.app.Kune/js/ext/ext-all.js
-rsync --delete -C -r -p war/ws/ src/main/webapp/gwt/ws/
+#rsync --delete -C -r -p war/ws/ src/main/webapp/gwt/ws/
1
0
Author: vjrj
Date: 2009-06-08 16:18:03 +0200 (Mon, 08 Jun 2009)
New Revision: 1121
Removed:
trunk/src/main/rails/
Log:
Incomplete - task upgrade to gwt 1.6.4
1
0
Author: vjrj
Date: 2009-06-08 16:16:52 +0200 (Mon, 08 Jun 2009)
New Revision: 1120
Removed:
trunk/src/main/rails/publicspace/
trunk/src/main/webapp/WEB-INF/gems/
trunk/src/main/webapp/images
trunk/src/main/webapp/javascripts
trunk/src/main/webapp/templates
Modified:
trunk/DEV-GUIDE
trunk/INSTALL
trunk/pom.xml
trunk/src/main/java/org/ourproject/kune/app/server/KuneRackModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconHyperlink.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/rate/RateItPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitepublic/SitePublicSpaceLinkPanel.java
trunk/src/main/webapp/WEB-INF/web.xml
Log:
Incomplete - task upgrade to gwt 1.6.4
Modified: trunk/DEV-GUIDE
===================================================================
--- trunk/DEV-GUIDE 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/DEV-GUIDE 2009-06-08 14:16:52 UTC (rev 1120)
@@ -189,7 +189,7 @@
For start the hosted mode, you can both execute from command line:
- mvn com.totsp.gwt:maven-googlewebtoolkit2-plugin:gwt
+ mvn gwt-maven:gwt
Also, you can generate a hosted mode launch configuration in eclipse. We have a "Run configuration" (Run > Open Run Dialog) in eclipse with Project: "org.ourproject.kune" with Main class: "com.google.gwt.dev.GWTShell", with this program arguments (or similar): "-noserver -out gwt-out /ws/?locale=en&log_level=INFO -port 8080" and in the "Classpath User Entries":
* gwt-dev-[linux|mac|windows].jar (Add External Jar and choose it from your gwt installation directory)
@@ -200,7 +200,7 @@
-Xmx512M
before run hosted mode compile once with:
- mvn com.totsp.gwt:maven-googlewebtoolkit2-plugin:compile
+ mvn gwt-maven:compile
and deploy with:
script/deploy_gwt.sh
and then we run jetty (with "script/server.sh" also you can run server in debug mode, see TROUBLESHOOT). This is quite useful to put breakpoints in the server code.
Modified: trunk/INSTALL
===================================================================
--- trunk/INSTALL 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/INSTALL 2009-06-08 14:16:52 UTC (rev 1120)
@@ -49,7 +49,7 @@
- Compile with maven:
# (in the trunk directory)
mvn compile -Dliquibase.should.run=false
- mvn com.totsp.gwt:maven-googlewebtoolkit2-plugin:compile
+ mvn gwt-maven:compile
- Copy the target to src directory (only for test):
./script/deploy_gwt.sh
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/pom.xml 2009-06-08 14:16:52 UTC (rev 1120)
@@ -122,7 +122,7 @@
<dependency>
<groupId>org.xwiki.platform</groupId>
<artifactId>xwiki-web-gwt-dom</artifactId>
- <version>2.0-SNAPSHOT-mine</version>
+ <version>2.0-SNAPSHOT-g164</version>
</dependency>
<!-- xmpp -->
@@ -265,20 +265,19 @@
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-util</artifactId>
<version>6.1.5</version>
- <!-- <version>7.0.0.pre5</version> -->
+ <!--
+ <version>7.0.0.pre5</version>
+ -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.5</version>
+ <artifactId>maven-jetty-plugin</artifactId>
<!--
<artifactId>jetty-maven-plugin</artifactId>
- <version>7.0.0.pre5</version>
- <configuration>
- <webAppSourceDirectory>war</webAppSourceDirectory>
- </configuration>
+ <version>7.0.0.1beta0</version>
-->
+ <version>6.1.5</version>
<scope>provided</scope>
</dependency>
@@ -320,7 +319,7 @@
<dependency>
<groupId>org.jruby.rack</groupId>
<artifactId>jruby-rack</artifactId>
- <version>0.9.3</version>
+ <version>0.9.4</version>
</dependency>
</dependencies>
@@ -525,14 +524,15 @@
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
- <artifactId>maven-jetty-plugin</artifactId>
- <version>6.1.5</version>
+ <artifactId>maven-jetty-plugin</artifactId>
+ <version>6.1.5</version>
<!--
- <artifactId>jetty-maven-plugin</artifactId>
- <version>7.0.0.pre5</version>
+ <artifactId>jetty-maven-plugin</artifactId>
+ <version>7.0.0.1beta0</version>
-->
<configuration>
<contextPath>/</contextPath>
+ <webAppSourceDirectory>war</webAppSourceDirectory>
<reload>manual</reload>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
@@ -722,8 +722,8 @@
</executions>
</plugin>
</plugins>
- <outputDirectory>${project.build.directory}/WEB-INF/classes</outputDirectory>
- <testOutputDirectory>${project.build.directory}/WEB-INF/test-classes</testOutputDirectory>
+ <outputDirectory>war/WEB-INF/classes</outputDirectory>
+ <testOutputDirectory>war/WEB-INF/test-classes</testOutputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
Modified: trunk/src/main/java/org/ourproject/kune/app/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/server/KuneRackModule.java 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/java/org/ourproject/kune/app/server/KuneRackModule.java 2009-06-08 14:16:52 UTC (rev 1120)
@@ -100,7 +100,7 @@
builder.at("^/ws").install(new RedirectFilter("/ws/"));
builder.at("^/ws/$").install(new ListenerFilter(KuneApplicationListener.class),
- new ForwardFilter("/gwt/ws/ws.html"));
+ new ForwardFilter("/ws/ws.html"));
builder.installGWTServices("^/ws/", SiteService.class, GroupService.class, ContentService.class,
UserService.class, SocialNetworkService.class, I18nService.class);
@@ -109,7 +109,7 @@
builder.installServlet("^/ws/servlets/", FileUploadManager.class, FileDownloadManager.class,
EntityLogoUploadManager.class, EntityLogoDownloadManager.class);
- builder.at("^/ws/(.*)$").install(new ForwardFilter("^/ws/(.*)$", "/gwt/ws/{0}"));
+ builder.at("^/ws/(.*)$").install(new ForwardFilter("^/ws/(.*)$", "/ws/{0}"));
}
private void installGuiceModules(final RackBuilder builder) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconHyperlink.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconHyperlink.java 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconHyperlink.java 2009-06-08 14:16:52 UTC (rev 1120)
@@ -81,7 +81,7 @@
}
public HandlerRegistration addClickHandler(final ClickHandler handler) {
- return addHandler(handler, ClickEvent.getType());
+ return addDomHandler(handler, ClickEvent.getType());
}
public HandlerRegistration addDoubleClickHandler(final DoubleClickHandler handler) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.java 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.java 2009-06-08 14:16:52 UTC (rev 1120)
@@ -144,7 +144,7 @@
}
public HandlerRegistration addClickHandler(final ClickHandler handler) {
- return addHandler(handler, ClickEvent.getType());
+ return addDomHandler(handler, ClickEvent.getType());
}
public HandlerRegistration addDoubleClickHandler(final DoubleClickHandler handler) {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/rate/RateItPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/rate/RateItPresenter.java 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/rate/RateItPresenter.java 2009-06-08 14:16:52 UTC (rev 1120)
@@ -54,7 +54,7 @@
stateManager.onStateChanged(new Listener<StateAbstractDTO>() {
public void onEvent(final StateAbstractDTO state) {
if (state instanceof StateContentDTO) {
- StateContentDTO stateContentDTO = (StateContentDTO) state;
+ final StateContentDTO stateContentDTO = (StateContentDTO) state;
setState(capabilitiesRegistry.isRateable(stateContentDTO.getTypeId()),
stateContentDTO.getCurrentUserRate());
} else {
@@ -99,7 +99,7 @@
new AsyncCallbackSimple<RateResultDTO>() {
public void onSuccess(final RateResultDTO result) {
NotifyUser.hideProgress();
- NotifyUser.info(i18n.t("Content rated"));
+ // NotifyUser.info(i18n.t("Content rated"));
if (currentState.getStateToken().equals(session.getCurrentStateToken())) {
session.getContentState().setRate(result);
setState(true, result.getCurrentUserRate());
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitepublic/SitePublicSpaceLinkPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitepublic/SitePublicSpaceLinkPanel.java 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitepublic/SitePublicSpaceLinkPanel.java 2009-06-08 14:16:52 UTC (rev 1120)
@@ -63,7 +63,6 @@
gotoPublic.setTitle(i18n.t("Leave the workspace and go to this group public space"));
gotoPublic.addStyleName("k-sitebar-labellink");
contentNoPublic.addStyleName("k-sitebar-labellink");
-
}
public void attach() {
Modified: trunk/src/main/webapp/WEB-INF/web.xml
===================================================================
--- trunk/src/main/webapp/WEB-INF/web.xml 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/webapp/WEB-INF/web.xml 2009-06-08 14:16:52 UTC (rev 1120)
@@ -20,27 +20,44 @@
<param-value>/WEB-INF/publicspace/
</param-value>
</context-param>
+
<context-param>
+ <param-name>files.default</param-name>
+ <param-value>/WEB-INF/publicspace/public
+ </param-value>
+ <description>
+ The files servlet should forward to the rails servlet
+ if no file could be found
+ </description>
+ </context-param>
+
+ <context-param>
<param-name>files.prefix</param-name>
<param-value>/WEB-INF/publicspace/public
</param-value>
+ <description>Prefix added to static files</description>
</context-param>
+
<context-param>
+ <param-name>public.root</param-name>
+ <param-value>/public/</param-value>
+ </context-param>
+
+ <context-param>
<param-name>rails.env</param-name>
<param-value>production</param-value>
</context-param>
<context-param>
- <param-name>jruby.max.runtimes</param-name>
+ <param-name>jruby.min.runtimes</param-name>
<param-value>1</param-value>
</context-param>
<context-param>
- <param-name>public.root</param-name>
- <param-value>/public/</param-value>
+ <param-name>jruby.max.runtimes</param-name>
+ <param-value>1</param-value>
</context-param>
-
<filter>
<filter-name>RackFilter</filter-name>
<filter-class>org.jruby.rack.RackFilter
@@ -48,7 +65,7 @@
</filter>
<filter-mapping>
<filter-name>RackFilter</filter-name>
- <url-pattern>/public/*</url-pattern>
+ <url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
@@ -56,7 +73,6 @@
</listener-class>
</listener>
-
<filter>
<filter-name>rack</filter-name>
<filter-class>
@@ -110,15 +126,11 @@
<url-pattern>/ws/gwt-log</url-pattern>
</servlet-mapping>
-<!--
- <servlet>
- <servlet-name>jUnitHostImpl</servlet-name>
+ <!--
+ <servlet> <servlet-name>jUnitHostImpl</servlet-name>
<servlet-class>com.google.gwt.junit.server.JUnitHostImpl
- </servlet-class>
- </servlet>
- <servlet-mapping>
+ </servlet-class> </servlet> <servlet-mapping>
<servlet-name>jUnitHostImpl</servlet-name>
- <url-pattern>/ws/junithost</url-pattern>
- </servlet-mapping>
- -->
+ <url-pattern>/ws/junithost</url-pattern> </servlet-mapping>
+ -->
</web-app>
Deleted: trunk/src/main/webapp/images
===================================================================
--- trunk/src/main/webapp/images 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/webapp/images 2009-06-08 14:16:52 UTC (rev 1120)
@@ -1 +0,0 @@
-link ../rails/publicspace/public/images/
\ No newline at end of file
Deleted: trunk/src/main/webapp/javascripts
===================================================================
--- trunk/src/main/webapp/javascripts 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/webapp/javascripts 2009-06-08 14:16:52 UTC (rev 1120)
@@ -1 +0,0 @@
-link ../rails/publicspace/public/javascripts/
\ No newline at end of file
Deleted: trunk/src/main/webapp/templates
===================================================================
--- trunk/src/main/webapp/templates 2009-06-08 14:16:23 UTC (rev 1119)
+++ trunk/src/main/webapp/templates 2009-06-08 14:16:52 UTC (rev 1120)
@@ -1 +0,0 @@
-link ../rails/publicspace/public/templates/
\ No newline at end of file
1
0