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
March 2009
- 1 participants
- 37 discussions
Author: vjrj
Date: 2009-03-16 05:17:06 +0100 (Mon, 16 Mar 2009)
New Revision: 1079
Removed:
trunk/kune-amaterasuml-class-diagra.cld
Modified:
trunk/
Log:
Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
- screenlog.0
bin
client
public
target
Main-compile
bin
.settings
.gwt-cache
repository
derby.log
star-yellow-grey.png
run.sh
tomcat
.classpath
gwt-out
synccss.sh
.externalToolBuilders
.project
.wtpmodules
www
testRepository
kune-OLD-jcr
KuneApp.launch
KuneApp NOSERVER.launch
old_src
org.ourproject.kune.app.Kune
org.ourproject.kune.iml
org.ourproject.kune.ipr
org.ourproject.kune.iws
nbproject
hibernate.reveng.xml
.gwt-tmp
target-eclipse
.checkstyle
+ www-test
screenlog.0
bin
client
public
target
Main-compile
bin
.settings
.gwt-cache
repository
derby.log
star-yellow-grey.png
run.sh
tomcat
.classpath
gwt-out
synccss.sh
.externalToolBuilders
.project
.wtpmodules
www
testRepository
kune-OLD-jcr
KuneApp.launch
KuneApp NOSERVER.launch
old_src
org.ourproject.kune.app.Kune
org.ourproject.kune.iml
org.ourproject.kune.ipr
org.ourproject.kune.iws
nbproject
hibernate.reveng.xml
.gwt-tmp
target-eclipse
.checkstyle
Deleted: trunk/kune-amaterasuml-class-diagra.cld
===================================================================
--- trunk/kune-amaterasuml-class-diagra.cld 2009-03-16 04:13:36 UTC (rev 1078)
+++ trunk/kune-amaterasuml-class-diagra.cld 2009-03-16 04:17:06 UTC (rev 1079)
@@ -1,699 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<net.java.amateras.uml.model.RootModel>
- <sourceConnections/>
- <targetConnections/>
- <children>
- <net.java.amateras.uml.classdiagram.model.ClassModel>
- <name>org.ourproject.kune.platf.server.access.Access</name>
- <stereoType></stereoType>
- <isAbstract>false</isAbstract>
- <constraint>
- <x>10</x>
- <y>10</y>
- <width>-1</width>
- <height>-1</height>
- </constraint>
- <sourceConnections/>
- <targetConnections/>
- <children>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2"/>
- <name>content</name>
- <type>Content</type>
- <isStatic>false</isStatic>
- <backgroundColor>
- <red>255</red>
- <green>255</green>
- <blue>206</blue>
- </backgroundColor>
- <foregroundColor>
- <red>0</red>
- <green>0</green>
- <blue>0</blue>
- </foregroundColor>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>container</name>
- <type>Container</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>contentAccessLists</name>
- <type>AccessLists</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>containerAccessLists</name>
- <type>AccessLists</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>groupAccessLists</name>
- <type>AccessLists</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>contentRights</name>
- <type>AccessRights</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>containerRights</name>
- <type>AccessRights</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.AttributeModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>groupRights</name>
- <type>AccessRights</type>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.AttributeModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.AttributeModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1"/>
- <name>Access</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>descriptor</name>
- <type>Content</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>container</name>
- <type>Container</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContainer</name>
- <type>Container</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContainerAccessLists</name>
- <type>AccessLists</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContainerRights</name>
- <type>AccessRights</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContent</name>
- <type>Content</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContentAccessLists</name>
- <type>AccessLists</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getContentRights</name>
- <type>AccessRights</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getGroupAccessLists</name>
- <type>AccessLists</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>getGroupRights</name>
- <type>AccessRights</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>hasContainerRights</name>
- <type>boolean</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>hasContentRights</name>
- <type>boolean</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>hasGroupRights</name>
- <type>boolean</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setContainer</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>container</name>
- <type>Container</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setContainerRights</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>accessRights</name>
- <type>AccessRights</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setContent</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>descriptor</name>
- <type>Content</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setContentRights</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>accessRights</name>
- <type>AccessRights</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setContentWidthFolderRights</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>content</name>
- <type>Content</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-1" reference="../../net.java.amateras.uml.classdiagram.model.OperationModel/visibility"/>
- <name>setGroupRights</name>
- <type>void</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>accessRights</name>
- <type>AccessRights</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>equalsAccessLists</name>
- <type>boolean</type>
- <params/>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>getContentAccessList</name>
- <type>AccessLists</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>descriptor</name>
- <type>Content</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- <net.java.amateras.uml.classdiagram.model.OperationModel>
- <visibility class="net.java.amateras.uml.classdiagram.model.Visibility-2" reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/visibility"/>
- <name>getContainerAccessLists</name>
- <type>AccessLists</type>
- <params>
- <net.java.amateras.uml.classdiagram.model.Argument>
- <name>container</name>
- <type>Container</type>
- </net.java.amateras.uml.classdiagram.model.Argument>
- </params>
- <isAbstract>false</isAbstract>
- <isStatic>false</isStatic>
- <backgroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../../net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.OperationModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.OperationModel>
- </children>
- <filterProperty/>
- <backgroundColor reference="../children/net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../children/net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <parent class="net.java.amateras.uml.model.RootModel" reference="../../.."/>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.classdiagram.model.ClassModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
- </net.java.amateras.uml.classdiagram.model.ClassModel>
- </children>
- <filterProperty/>
- <backgroundColor reference="../children/net.java.amateras.uml.classdiagram.model.ClassModel/children/net.java.amateras.uml.classdiagram.model.AttributeModel/backgroundColor"/>
- <foregroundColor reference="../children/net.java.amateras.uml.classdiagram.model.ClassModel/children/net.java.amateras.uml.classdiagram.model.AttributeModel/foregroundColor"/>
- <showIcon>true</showIcon>
- <listeners serialization="custom">
- <java.beans.PropertyChangeSupport>
- <default>
- <propertyChangeSupportSerializedDataVersion>2</propertyChangeSupportSerializedDataVersion>
- <source class="net.java.amateras.uml.model.RootModel" reference="../../../.."/>
- </default>
- <null/>
- </java.beans.PropertyChangeSupport>
- </listeners>
-</net.java.amateras.uml.model.RootModel>
\ No newline at end of file
1
0
Author: vjrj
Date: 2009-03-16 05:13:36 +0100 (Mon, 16 Mar 2009)
New Revision: 1078
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/
trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcut.java
trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcutRegister.java
trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalette.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPaletteView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalette.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePaletteView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/film.png
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractWysiwygClientTest.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogView.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java
trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java
Modified:
trunk/TODO
trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
trunk/src/main/java/org/ourproject/kune/app/public/css/docs.css
trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/TextUtils.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalette.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePaletteView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.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/img/RTEImgResources.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/rteimg.css
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.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/hello/HelloWorldModule.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
Log:
Complete - task Insert Table Dialog
Complete - task Better RTE (Rich Text Editor) support
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/TODO 2009-03-16 04:13:36 UTC (rev 1078)
@@ -10,6 +10,45 @@
Use org-mode in emacs to easy manage this file
* SHORT-TERM (URGENT)
+** vjrj use xwiki maven repo
+ http://maven.xwiki.org/releases/com/xpn/xwiki/platform/xwiki-web-wysiwyg/1.…
+** vjrj <v> better RTE
+*** Pending
+**** W3C Range/Selection support in RTE
+ https://developer.mozilla.org/en/DOM/selection
+ http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
+ As an intro:
+ http://www.quirksmode.org/dom/range_intro.html
+ http://maven.xwiki.org/site/xwiki-web/xwiki-web-wysiwyg/apidocs/com/xpn/xwi…
+ other links:
+ http://groups.google.com/group/rocket-gwt/browse_frm/thread/e56540d4168479c…
+ http://code.google.com/p/gwt-html-editor/source/browse/branches/gwt1.4/src/…
+**** Insert/Edit link
+***** use cases
+ ^<a href="http://example.com">sample</a>^ --- Parse and edit
+ <a href="http://example.com">s^ample</a> --- Parse and edit
+ <a href="http://example.com">s^amp^le</a> --- Parse and edit
+ ^some text <a href="http://example.com">samp^le</a> --- new link with get inner content?
+**** Quite urgent: Shortcuts propagation to browser
+ http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/use…
+ http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
+ http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
+ http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/
+**** with different menus (File/Blog ...)
+**** bidi support
+**** Insert special chars (for table or from unicode).
+**** images (local/remote) with preview
+**** youtube videos/podcasts
+**** Edit HTML
+**** File > Rename (F2)
+**** Insert > Special char
+**** Insert > Page break (for printing)
+**** Shortcut to fonts (Ctrl + numbers)
+*** Links
+ http://www.ongwt.com/post/2009/01/08/XWiki-:-Wysiwyg-editor-based-on-GWT
+ http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/in…
+ http://www.mozilla.org/editor/midas-spec.html
+ http://mozilla.org/editor/midasdemo/
** vjrj <v> GWT 1.6
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/3e7e…
http://code.google.com/p/google-web-toolkit/wiki/WAR_Design_1_6
@@ -77,43 +116,6 @@
http://code.google.com/p/google-web-toolkit-doc-1-5/wiki/DevGuideHistory
http://en.wikipedia.org/wiki/Fragment_identifier
http://www.w3.org/DesignIssues/Fragment.html
-** vjrj <v> better RTE
-*** Pending
-**** W3C Range/Selection support in RTE
- https://developer.mozilla.org/en/DOM/selection
- http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
- As an intro:
- http://www.quirksmode.org/dom/range_intro.html
- http://maven.xwiki.org/site/xwiki-web/xwiki-web-wysiwyg/apidocs/com/xpn/xwi…
- other links:
- http://groups.google.com/group/rocket-gwt/browse_frm/thread/e56540d4168479c…
- http://code.google.com/p/gwt-html-editor/source/browse/branches/gwt1.4/src/…
-**** Insert/Edit link
-***** use cases
- ^<a href="http://example.com">sample</a>^ --- Parse and edit
- <a href="http://example.com">s^ample</a> --- Parse and edit
- <a href="http://example.com">s^amp^le</a> --- Parse and edit
- ^some text <a href="http://example.com">samp^le</a> --- new link with get inner content?
-**** Quite urgent: Shortcuts propagation to browser
- http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/use…
- http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
- http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
- http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/
-**** with different menus (File/Blog ...)
-**** bidi support
-**** Insert special chars (for table or from unicode).
-**** images (local/remote) with preview
-**** youtube videos/podcasts
-**** Edit HTML
-**** File > Rename (F2)
-**** Insert > Special char
-**** Insert > Page break (for printing)
-**** Shortcut to fonts (Ctrl + numbers)
-*** Links
- http://www.ongwt.com/post/2009/01/08/XWiki-:-Wysiwyg-editor-based-on-GWT
- http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/in…
- http://www.mozilla.org/editor/midas-spec.html
- http://mozilla.org/editor/midasdemo/
** vjrj <v> rails group-shortname.kune-site-domain/tool-name/folder-id/doc-id routing, maybe use:
http://agilewebdevelopment.com/plugins/request_routing
http://wiki.rubyonrails.org/rails/pages/Request+Routing
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/all.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/all.css 2009-03-16 04:13:36 UTC (rev 1078)
@@ -35,7 +35,7 @@
}
*/.kune-NavigationBar .topBar .gwt-Image{margin:0 2px 0 5px;}.kune-NavigationBar .Items{margin:2px 0;}.kune-NavigationBar .Items .gwt-Image{margin:2px 0;vertical-align:middle;}.kune-NavigationBar .Items .gwt-Hyperlink a{color:green;/* FIXME: other color */}.kune-NavigationBar .topBar .topBar-margin{margin-left:5px;}.kune-NavigationBar .pathMenu{vertical-align:middle;}.kune-NavigationBar .pathMenu .gwt-MenuItem{background:transparent url(img/button-bg-hard.gif) repeat-x 0 0;border-left:1px solid #AAA;border-right:1px solid #AAA;color:#999;cursor:pointer;white-space:nowrap;padding:3px 6px;}.kune-NavigationBar .pathMenu .gwt-MenuItem-selected{background:transparent url(img/button-bg-soft.gif) repeat-x 0 0;color:#000;}.kune-NavigationBar .kune-IconHyperlink{vertical-align:middle;margin-left:5px;}.kune-NavigationBar .kune-IconHyperlink a{color:green;text-decoration:none;}.kune-NavigationBar .kune-IconHyperlink .gwt-Image{margin-right:3px;vertical-align:middle;}/* Social Network */.kune-StackedDropDownPanel{}.kune-StackedDropDownPanel .gwt-StackPanelItem{border-top:1px solid #CCC;border-bottom:1px solid #CCC;background-color:#EFA;cursor:pointer;padding:1px 3px 0 6px;overflow:hidden;}.kune-StackedDropDownPanel .gwt-StackPanelItem img{margin:0 0 0 3px;vertical-align:middle;}.kune-StackedDropDownPanel .kune-DropDownInner table{width:100%;}.kune-StackedDropDownPanel .gwt-StackPanelItem-selected{}.kune-StackedDropDownPanelLink{background-color:#E6E6E6;border-top:1px solid #CCC;border-bottom:1px solid #F2F2F2;/* white-space: nowrap; */cursor:pointer;}.kune-StackedDropDownPanel .kune-DropDownInner{padding:0;}/* StackedDropDownPanel Members */.kune-StackSubItemLabel{overflow:hidden;}.kune-StackSubItemLabel .gwt-MenuItem{white-space:nowrap;cursor:pointer;border-bottom:1px solid #F2F2F2;}.kune-StackSubItemLabel table{width:100%;}.kune-StackSubItemLabel .gwt-MenuItem img{vertical-align:middle;margin-top:1px;margin-bottom:1px;margin-left:5px;margin-right:3px;}.kune-StackSubItemLabel .gwt-MenuItem-selected{background-color:#FFE6D5;}.kune-StackSubItemActions{background-color:#F2F2F2;border:1px solid #999;vertical-align:middle;padding:5px 0;margin-left:-120px;margin-top:-2px;}.kune-StackSubItemActions .gwt-MenuItem{cursor:pointer;padding:1px 10px;white-space:nowrap;}.kune-StackSubItemActions .gwt-MenuItem img{vertical-align:middle;margin-right:3px;}.kune-StackSubItemActions .gwt-MenuItem-selected{background-color:#FFB958;}/* AccessList */.kune-AccessListSubLabel{font-style:italic;}.kune-AccessList{margin:5px;width:100%;}.kune-AccessList .gwt-DisclosurePanel{margin:5px;width:100%;}.kune-AccessList .gwt-DisclosurePanel-open{width:100%;}.kune-AccessList .gwt-DisclosurePanel-closed{width:100%;}.kune-AccessList .header{margin:0 0 3px;text-decoration:none;width:100%;background-color:#8DD35F;}.kune-AccessList .header table{margin:0 5px 0 0;width:100%;color:#FFF;}.kune-AccessList .header img{margin:0 3px 0 0;}.kune-AccessList .content{margin:0 0 0 7px;width:100%;}.kune-AccessList .content table{margin-bottom:5px;width:100%;}/* Rate */.kune-RatePanel-Label{white-space:nowrap;vertical-align:middle;}.kune-RatePanel-Stars{margin-left:5px;vertical-align:middle;}.kune-RatePanel-Stars-RateIt{cursor:pointer;}/* Licenses */.kune-License-CC-Header{color:#15428B;font-weight:700;font-size:85%;margin-top:5px;}.kune-License-CC-Header .gwt-Label{color:#15428B;font-weight:700;font-size:85%;margin-top:5px;}/* Theme */.kune-IconBottomPanel .gwt-MenuItem{cursor:pointer;background-color:#FFF;margin:2px 2px 2px 5px;}.kune-IconBottomPanel .gwt-MenuItem-selected{background-color:#F2F2F2;}.gwt-MenuBar-bottomMenu{margin-left:-60px;margin-top:-120px;}/* i18n */.kune-I18nTranslatorCell{white-space:normal;}.kune-i18nTranslator-recommend{margin:10px;}.kune-i18nTranslator-recommend h1{font-size:131%;font-weight:700;}.kune-i18nTranslator-recommend h2{font-size:116%;font-weight:700;}.kune-i18nTranslator-recommend h3{font-size:108%;font-weight:700;font-style:italic;}.kune-i18nTranslator-recommend em{font-weight:700;}.kune-i18nTranslator-recommend strong{font-weight:700;}/* Admin Context */.kune-AdminContextPanel{margin:6px;width:100%;}.kune-AdminContextPanel .gwt-StackPanelItem{background:transparent url(img/arrow-right-white.gif) no-repeat scroll 3px 2px;cursor:pointer;padding:3px 10px 1px 20px;overflow:hidden;width:100%;}.kune-AdminContextPanel .gwt-StackPanelItem img{margin:0 0 0 3px;vertical-align:middle;}.kune-AdminContextPanel .gwt-StackPanelItem-selected{background:transparent url(img/arrow-down-white.gif) no-repeat scroll 3px 2px;background-color:#DEE3DB;}.kune-AdminContextPanelLink{background-color:#E6E6E6;border-top:1px solid #CCC;border-bottom:1px solid #F2F2F2;/* white-space: nowrap; */cursor:pointer;}.kune-AdminContextPanel-inner{background-color:#FFF;}.kune-AdminContextPanel-inner-wrap{margin:5px;}.kune-EditableLabel{}.kune-EditableLabel .kune-EditableLabel-editable{}.kune-EditableLabel-high{background-color:#FFFBC1;cursor:pointer;}.kune-EditableLabel-high span{background-color:#FFFBC1;}.kune-EditableLabel a{margin-left:5px;}.kune-EditableLabel a:link{color:green;}.kune-EditableLabel a:hover{text-decoration:underline;}.kune-EditableLabel a:visited{color:olive;}.kune-EditableLabel img{margin-right:4px;vertical-align:middle;}.kune-EditableLabel-editable img{margin-right:4px;vertical-align:middle;}.kune-EditableLabel-editable span{margin:3px;}.kune-EditableLabel span{margin:3px;}.kune-BottomIconsTrayPanel{width:165px;height:21px;vertical-align:middle;background-color:#EFEFEF;}.kune-Content-Main{margin:5px;}/* Yahoo ui base.css */.kune-Content-Main h1{font-size:138.5%;}.kune-Content-Main h2{font-size:123.099998%;}.kune-Content-Main h3{font-size:108%;}.kune-Content-Main h1{margin:1em 0;}.kune-Content-Main h2{margin:1em 0;}.kune-Content-Main h3{margin:1em 0;}.kune-Content-Main h1{font-weight:700;}.kune-Content-Main h2{font-weight:700;}.kune-Content-Main h3{font-weight:700;}.kune-Content-Main h4{font-weight:700;}.kune-Content-Main h5{font-weight:700;}.kune-Content-Main h6{font-weight:700;}.kune-Content-Main strong{font-weight:700;}.kune-Content-Main abbr{border-bottom:1px dotted #000;cursor:help;}.kune-Content-Main acronym{border-bottom:1px dotted #000;cursor:help;}.kune-Content-Main em{font-style:italic;}.kune-Content-Main blockquote{margin:1em;}.kune-Content-Main ul{margin:1em;}.kune-Content-Main ol{margin:1em;}.kune-Content-Main dl{margin:1em;}.kune-Content-Main ol{margin-left:2em;}.kune-Content-Main ul{margin-left:2em;}.kune-Content-Main dl{margin-left:2em;}.kune-Content-Main ol{list-style:decimal outside;}.kune-Content-Main li{list-style:decimal outside;}.kune-Content-Main li{list-style:disc outside;}.kune-Content-Main ul{list-style:disc outside;}.kune-Content-Main dl{margin-left:1em;}.kune-Content-Main dd{margin-left:1em;}.kune-Content-Main th{border:1px solid #000;padding:.5em;font-weight:700;text-align:center;}.kune-Content-Main td{border:1px solid #000;padding:.5em;}.kune-Content-Main caption{margin-bottom:.5em;text-align:center;}.kune-Content-Main p{margin-bottom:1em;}.kune-Content-Main fieldset{margin-bottom:1em;}.kune-Content-Main table{margin-bottom:1em;}.kune-Content-Main pre{margin-bottom:1em;}.kune-Content-Main input[type=text]{width:12.25em;width:11.9em;}.kune-Content-Main input[type=password]{width:12.25em;width:11.9em;}.kune-Content-Main textarea{width:12.25em;width:11.9em;}.search-icon{background-image:url(img/search.gif)!important;}.i18n-icon{background-image:url(img/language.gif)!important;}/* RTE Text editor */.kune-TexEditorPanel-TextArea{margin:3px;}.gwt-RichTextArea{/* border: 1px solid #000;
background-color: #FFF; */border:1px solid #4D4D4D;background-color:#FFF;margin:5px 0 5px 10px;}.gwt-RichTextToolbar{/* background-color: #F2F2F2;
- padding: 5px; */height:24px;vertical-align:middle;}.gwt-RichTextToolbar table{vertical-align:middle;}.gwt-RichTextToolbar .gwt-ToggleButton{float:left;margin-top:2px;}.gwt-RichTextToolbar .gwt-PushButton{float:left;margin-top:2px;}.gwt-RichTextToolbar .gwt-PushButton-up{margin-right:2px;border:1px solid #F2F2F2;}.gwt-RichTextToolbar .gwt-PushButton-up-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#E8F1FF #9daecd #9daecd #e8f1ff;}.gwt-RichTextToolbar .gwt-PushButton-down{margin-right:2px;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-PushButton-down-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-ToggleButton-up{margin-right:2px;border:1px solid #F2F2F2;}.gwt-RichTextToolbar .gwt-ToggleButton-up-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#E8F1FF #9daecd #9daecd #e8f1ff;}.gwt-RichTextToolbar .gwt-ToggleButton-down{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-ToggleButton-down-hovering{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .x-btn{float:left;}.gwt-RichTextToolbar .kune-Button-Large-lSpace{float:left;}.gwt-RichTextToolbar .kune-Button-Large-lrSpace{float:left;}.RichTextToolbar-menu{float:left;margin-top:2px;z-index:4;}.RichTextToolbar-menu table{border-collapse:collapse;border-spacing:0;margin:0;z-index:4;}.RichTextToolbar-menu .gwt-MenuItem{margin-right:2px;border:1px solid #F2F2F2;}.RichTextToolbar-menu .gwt-MenuItem-selected{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.RichTextToolbar-submenu{background-color:#FFFCD5;border:1px solid #D38D5F;cursor:default;z-index:4;}.RichTextToolbar-submenu .gwt-MenuItem{cursor:default;white-space:nowrap;border:1px solid #FFFCD5;padding:0 4px;}.RichTextToolbar-submenu .gwt-MenuItem-selected{background-color:#FFB958;border:1px solid #C83737;}.kune-WebSafePalette{background-color:#FFF;border:1px solid #AAA;margin:1px;}.kune-WebSafePalette-popup{z-index:9999!important;}.kune-WebSafePalette td{width:12px;height:10px;}.k-site-traybar{background:#FFF none repeat scroll 0 50%;}.k-blank-toolbar{background:#FFF none repeat scroll 0 50%;}.k-sitebar .kune-IconHyperlink{white-space:nowrap;}.k-sitebar .kune-IconHyperlink a:link{cursor:pointer;text-decoration:underline;color:#B3B3B3;}.k-sitebar .kune-IconHyperlink a:hover{text-decoration:underline;}.k-sitebar .kune-IconHyperlink a:visited{color:#B3B3B3;}.k-sitebar-labellink{white-space:nowrap;color:#B3B3B3;cursor:pointer;text-decoration:underline;}.k-sitebar{margin-right:10px;height:16px;background:#FFF;}.k-sitebar .gwt-TextBox{border:1px solid #E4A374;margin:0 15px 0 3px;padding-left:1px;color:#B3B3B3;}.k-sitebar .gwt-Hyperlink a{white-space:nowrap;color:#B3B3B3;text-decoration:underline;cursor:pointer;}.k-sitebar .gwt-PushButton{cursor:pointer;}.k-sitebar-LabelLink{white-space:nowrap;color:#B3B3B3;cursor:pointer;text-decoration:underline;}.k-entity-summary{border-left-color:#FFF;border-left-width:5px;border-bottom-color:#FFF;border-bottom-width:5px;}.k-entitytextlogo-border{border:2px solid #F2F2F2;}.k-entitytextlogo-no-border{border:none;}.k-entitytextlogo{height:60px;margin:0 0 4px;overflow:hidden;width:468px;}.k-entitytextlogo table{vertical-align:middle;}.k-elogo-l-l{font-size:272%;}.k-elogo-l-m{font-size:167%;}.k-elogo-l-s{font-size:108%;}.k-entitytextlogo .gwt-Label{font-weight:700;margin:5px;height:27px;}.k-entitytextlogo-default .gwt-Label{color:#69312F;}.k-entitytextlogo-green .gwt-Label{color:#250;}.k-entitytextlogo-blue .gwt-Label{color:navy;}.k-entitytextlogo-grey .gwt-Label{color:#1A1A1A;}.k-entitytextlogo-purple .gwt-Label{color:#405;}.k-entitytextlogo-red .gwt-Label{color:maroon;}.k-elogo-plink{color:#CCC;font-size:85%;margin:5px;text-decoration:underline;white-space:nowrap;background-color:#FFF;}.k-elogop-expand{background-color:transparent;}.k-entity-default .x-layout-split,.k-entity-default .x-layout-collapsed{background:#DD8A3D none repeat scroll 0 50%;}.k-entity-green .x-layout-split,.k-entity-green .x-layout-collapsed{background:#5FD35F none repeat scroll 0 50%;}.k-entity-blue .x-layout-split,.k-entity-blue .x-layout-collapsed{background:#06F none repeat scroll 0 50%;}.k-entity-grey .x-layout-split,.k-entity-grey .x-layout-collapsed{background:#4D4D4D none repeat scroll 0 50%;}.k-entity-purple .x-layout-split,.k-entity-purple .x-layout-collapsed{background:#660080 none repeat scroll 0 50%;}.k-entity-red .x-layout-split,.k-entity-red .x-layout-collapsed{background:#D40000 none repeat scroll 0 50%;}.k-entityworkspace .x-layout-split,.k-entityworkspace .x-layout-collapsed{background:transparent none repeat scroll 0 50%;}.k-entityworkspace-default .x-layout-split,.k-entityworkspace-default .x-layout-collapsed{background:#DEAA87 none repeat scroll 0 50%;}.k-entityworkspace-green .x-layout-split,.k-entityworkspace-green .x-layout-collapsed{background:#DCE8AB none repeat scroll 0 50%;}.k-entityworkspace-blue .x-layout-split,.k-entityworkspace-blue .x-layout-collapsed{background:#D5D5FF none repeat scroll 0 50%;}.k-entityworkspace-grey .x-layout-split,.k-entityworkspace-grey .x-layout-collapsed{background:#999 none repeat scroll 0 50%;}.k-entityworkspace-purple .x-layout-split,.k-entityworkspace-purple .x-layout-collapsed{background:#A793AC none repeat scroll 0 50%;}.k-entityworkspace-red .x-layout-split,.k-entityworkspace-red .x-layout-collapsed{background:#F55 none repeat scroll 0 50%;}.k-entity-title{border-left-style:solid;border-left-width:2px;}.k-entity-title div{line-height:22px;white-space:nowrap;}.k-entity-subtitle{}.k-entity-subtitle div{line-height:22px;white-space:nowrap;}.k-entity-title-rd-default{background:#DD8A3D;}.k-entity-title-rd-green{background:#5FD35F;}.k-entity-title-rd-blue{background:#06F;}.k-entity-title-rd-grey{background:#4D4D4D;}.k-entity-title-rd-purple{background:#660080;}.k-entity-title-rd-red{background:#D40000;}.k-entity-title-default{background:#F1BB59 none repeat scroll 0 50%;border-left-color:#DD8A3D;}.k-entity-title-green{background:#AFA none repeat scroll 0 50%;border-left-color:#5FD35F;}.k-entity-title-blue{background:#AFDDE9 none repeat scroll 0 50%;border-left-color:#06F;}.k-entity-title-grey{background:#CCC none repeat scroll 0 50%;border-left-color:#4D4D4D;}.k-entity-title-purple{background:#DDAFE9 none repeat scroll 0 50%;border-left-color:#660080;}.k-entity-title-red{background:#FF8080 none repeat scroll 0 50%;border-left-color:#D40000;}.k-entity-title-default div{color:#69312F;}.k-entity-title-green div{color:#250;}.k-entity-title-blue div{color:navy;}.k-entity-title-grey div{color:#1A1A1A;}.k-entity-title-purple div{color:#405;}.k-entity-title-red div{color:maroon;}.k-entity-subtitle-default{background:#DD8A3D none repeat scroll 0 50%;}.k-entity-subtitle-green{background:#5FD35F none repeat scroll 0 50%;}.k-entity-subtitle-blue{background:#06F none repeat scroll 0 50%;}.k-entity-subtitle-grey{background:#4D4D4D none repeat scroll 0 50%;}.k-entity-subtitle-purple{background:#660080 none repeat scroll 0 50%;}.k-entity-subtitle-red{background:#D40000 none repeat scroll 0 50%;}.k-entity-subtitle-default div{color:#FFF;}.k-entity-subtitle-green div{color:#FFF;}.k-entity-subtitle-blue div{color:#FFF;}.k-entity-subtitle-grey div{color:#FFF;}.k-entity-subtitle-purple div{color:#FFF;}.k-entity-subtitle-red div{color:#FFF;}.k-entity-bottom-rd-default,.k-entity-bottom-default,.k-toolselectoritem-sel-default{background:#DD8A3D;}.k-entity-bottom-rd-green,.k-entity-bottom-green,.k-toolselectoritem-sel-green{background:#5FD35F;}.k-entity-bottom-rd-blue,.k-entity-bottom-blue,.k-toolselectoritem-sel-blue{background:#06F;}.k-entity-bottom-rd-grey,.k-entity-bottom-grey,.k-toolselectoritem-sel-grey{background:#4D4D4D;}.k-entity-bottom-rd-purple,.k-entity-bottom-purple,.k-toolselectoritem-sel-purple{background:#660080;}.k-entity-bottom-rd-red,.k-entity-bottom-red,.k-toolselectoritem-sel-red{background:#D40000;}.k-entity-context-default div,.k-entity-context-default .x-tree .x-panel-body{background:#FFD09D none repeat scroll 0 50%;}.k-entity-context-green div,.k-entity-context-green .x-tree .x-panel-body{background:#CFA none repeat scroll 0 50%;}.k-entity-context-blue div,.k-entity-context-blue .x-tree .x-panel-body{background:#ACF none repeat scroll 0 50%;}.k-entity-context-grey div,.k-entity-context-grey .x-tree .x-panel-body{background:#B3B3B3 none repeat scroll 0 50%;}.k-entity-context-purple div,.k-entity-context-purple .x-tree .x-panel-body{background:#DDAFE9 none repeat scroll 0 50%;}.k-entity-context-red div,.k-entity-context-red .x-tree .x-panel-body{background:#FAA none repeat scroll 0 50%;}.k-entity-context-purple .x-tree .x-panel-body{background:#DDAFE9 none repeat scroll 0 50%;}.k-entity-bottom div{/* line-height: 24px; */color:#FFF;}.k-toolbar-top-line{border-top-color:#d0d0d0;border-top-style:solid;border-top-width:1px;}.k-toolbar-bottom-line{border-bottom-color:#d0d0d0;border-bottom-style:solid;border-bottom-width:1px;}.x-toolbar td,.x-toolbar span,.x-toolbar input,.x-toolbar div,.x-toolbar select,.x-toolbar label{white-space:nowrap;font:normal 100% arial, sans;line-height:19px;}.k-toolbar-sep{padding-top:4px;padding-left:5px;}/* Custom gwt-ext styles */.ytb-sep{background-image:url(../js/ext/resources/images/default/grid/grid-split.gif);background-position:center;background-repeat:no-repeat;display:block;font-size:1px;height:16px;width:4px;overflow:hidden;cursor:default;margin:0 2px;border:0;}.ytb-spacer{width:2px;}.x-grid-group-hd{border-bottom:2px solid grey;cursor:pointer;padding-top:3px;}/* Drop down */.k-dropdownouter{background-color:grey;}.k-dropdownouter-members{}.k-dropdownouter-members-default{background-color:#DF5244;}.k-dropdownouter-members-green{background-color:green;}.k-dropdownouter-members-blue{background-color:#5500D4;}.k-dropdownouter-members-grey{background-color:#4D4D4D;}.k-dropdownouter-members-purple{background-color:#672178;}.k-dropdownouter-members-red{background-color:#A02C2C;}.k-dropdownouter-part{}.k-dropdownouter-part-default{background-color:#CA5842;}.k-dropdownouter-part-green{background-color:#0A0;}.k-dropdownouter-part-blue{background-color:#60F;}.k-dropdownouter-part-grey{background-color:#666;}.k-dropdownouter-part-purple{background-color:#892CA0;}.k-dropdownouter-part-red{background-color:#C83737;}.k-dropdownouter-tags{}.k-dropdownouter-tags-default{background-color:#87501E;}.k-dropdownouter-tags-green{background-color:#00D400;}.k-dropdownouter-tags-blue{background-color:#95F;}.k-dropdownouter-tags-grey{background-color:gray;}.k-dropdownouter-tags-purple{background-color:#AB37C8;}.k-dropdownouter-tags-red{background-color:#D35F5F;}.k-dropdownouter-summary{}.k-dropdownouter-summary-default{background-color:#9F734B;}.k-dropdownouter-summary-green{background-color:#4CE14C;}.k-dropdownouter-summary-blue{background-color:#69A5FF;}.k-dropdownouter-summary-grey{background-color:#A6A6A6;}.k-dropdownouter-summary-purple{background-color:#C473D8;}.k-dropdownouter-summary-red{background-color:#E08F8F;}.k-dropdowninner{margin:0 3px 1px;background:green;background-color:#FFF;/* padding: 3px; */}.k-dropdownlabel{color:#FFF;cursor:pointer;}.k-dropdownlabel .gwt-Label{margin:0 5px 0 0;width:100%;}.k-dropdownlabel img{margin:0 3px 0 1px;}/* WsTheme */.k-wstheme-icon-default{background:#FF8C00;}.k-wstheme-icon-green{background:green;}.k-wstheme-icon-blue{background:blue;}.k-wstheme-icon-grey{background:grey;}.k-wstheme-icon-purple{background:purple;}.k-wstheme-icon-red{background:red;}/* Tool selector items */.k-toolselectoritem{width:auto;margin-bottom:5px;cursor:pointer;}.k-toolselectoritem-sel{}.k-toolselectoritem-notsel-default{background:#FFE9A5;}.k-toolselectoritem-notsel-green{background:#D6F4D6;}.k-toolselectoritem-notsel-blue{background:#D7D7F4;}.k-toolselectoritem-notsel-grey{background:#E6E6E6;}.k-toolselectoritem-notsel-purple{background:#EED7F4;}.k-toolselectoritem-notsel-red{background:#FFD5D5;}.k-toolselectoritem-sel a{color:#FFF;padding:0 9px;text-decoration:none;}.k-toolselectoritem-sel a:hover{text-decoration:none;}.k-toolselectoritem-notsel{}.k-toolselectoritem-notsel a{color:#00F;padding:0 9px;text-decoration:none;}.k-toolselectoritem-notsel a:hover{text-decoration:underline;}/* others *//*
+ padding: 5px; */height:24px;vertical-align:middle;}.gwt-RichTextToolbar table{vertical-align:middle;}.gwt-RichTextToolbar .gwt-ToggleButton{float:left;margin-top:2px;}.gwt-RichTextToolbar .gwt-PushButton{float:left;margin-top:2px;}.gwt-RichTextToolbar .gwt-PushButton-up{margin-right:2px;border:1px solid #F2F2F2;}.gwt-RichTextToolbar .gwt-PushButton-up-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#E8F1FF #9daecd #9daecd #e8f1ff;}.gwt-RichTextToolbar .gwt-PushButton-down{margin-right:2px;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-PushButton-down-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-ToggleButton-up{margin-right:2px;border:1px solid #F2F2F2;}.gwt-RichTextToolbar .gwt-ToggleButton-up-hovering{margin-right:2px;border:1px solid #C3D9FF;border-color:#E8F1FF #9daecd #9daecd #e8f1ff;}.gwt-RichTextToolbar .gwt-ToggleButton-down{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .gwt-ToggleButton-down-hovering{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.gwt-RichTextToolbar .x-btn{float:left;}.gwt-RichTextToolbar .kune-Button-Large-lSpace{float:left;}.gwt-RichTextToolbar .kune-Button-Large-lrSpace{float:left;}.RichTextToolbar-menu{float:left;margin-top:2px;z-index:4;}.RichTextToolbar-menu table{border-collapse:collapse;border-spacing:0;margin:0;z-index:4;}.RichTextToolbar-menu .gwt-MenuItem{margin-right:2px;border:1px solid #F2F2F2;}.RichTextToolbar-menu .gwt-MenuItem-selected{margin-right:2px;background-color:#E8F1FF;border:1px solid #C3D9FF;border-color:#9DAECD #e8f1ff #e8f1ff #9daecd;}.RichTextToolbar-submenu{background-color:#FFFCD5;border:1px solid #D38D5F;cursor:default;z-index:4;}.RichTextToolbar-submenu .gwt-MenuItem{cursor:default;white-space:nowrap;border:1px solid #FFFCD5;padding:0 4px;}.RichTextToolbar-submenu .gwt-MenuItem-selected{background-color:#FFB958;border:1px solid #C83737;}.kune-WebSafePalette{background-color:#FFF;border:1px solid #AAA;margin:1px;}.kune-WebSafePalette-popup{z-index:9999!important;background-color:#FFF;}.kune-WebSafePalette td{width:12px;height:10px;}.k-site-traybar{background:#FFF none repeat scroll 0 50%;}.k-blank-toolbar{background:#FFF none repeat scroll 0 50%;}.k-sitebar .kune-IconHyperlink{white-space:nowrap;}.k-sitebar .kune-IconHyperlink a:link{cursor:pointer;text-decoration:underline;color:#B3B3B3;}.k-sitebar .kune-IconHyperlink a:hover{text-decoration:underline;}.k-sitebar .kune-IconHyperlink a:visited{color:#B3B3B3;}.k-sitebar-labellink{white-space:nowrap;color:#B3B3B3;cursor:pointer;text-decoration:underline;}.k-sitebar{margin-right:10px;height:16px;background:#FFF;}.k-sitebar .gwt-TextBox{border:1px solid #E4A374;margin:0 15px 0 3px;padding-left:1px;color:#B3B3B3;}.k-sitebar .gwt-Hyperlink a{white-space:nowrap;color:#B3B3B3;text-decoration:underline;cursor:pointer;}.k-sitebar .gwt-PushButton{cursor:pointer;}.k-sitebar-LabelLink{white-space:nowrap;color:#B3B3B3;cursor:pointer;text-decoration:underline;}.k-entity-summary{border-left-color:#FFF;border-left-width:5px;border-bottom-color:#FFF;border-bottom-width:5px;}.k-entitytextlogo-border{border:2px solid #F2F2F2;}.k-entitytextlogo-no-border{border:none;}.k-entitytextlogo{height:60px;margin:0 0 4px;overflow:hidden;width:468px;}.k-entitytextlogo table{vertical-align:middle;}.k-elogo-l-l{font-size:272%;}.k-elogo-l-m{font-size:167%;}.k-elogo-l-s{font-size:108%;}.k-entitytextlogo .gwt-Label{font-weight:700;margin:5px;height:27px;}.k-entitytextlogo-default .gwt-Label{color:#69312F;}.k-entitytextlogo-green .gwt-Label{color:#250;}.k-entitytextlogo-blue .gwt-Label{color:navy;}.k-entitytextlogo-grey .gwt-Label{color:#1A1A1A;}.k-entitytextlogo-purple .gwt-Label{color:#405;}.k-entitytextlogo-red .gwt-Label{color:maroon;}.k-elogo-plink{color:#CCC;font-size:85%;margin:5px;text-decoration:underline;white-space:nowrap;background-color:#FFF;}.k-elogop-expand{background-color:transparent;}.k-entity-default .x-layout-split,.k-entity-default .x-layout-collapsed{background:#DD8A3D none repeat scroll 0 50%;}.k-entity-green .x-layout-split,.k-entity-green .x-layout-collapsed{background:#5FD35F none repeat scroll 0 50%;}.k-entity-blue .x-layout-split,.k-entity-blue .x-layout-collapsed{background:#06F none repeat scroll 0 50%;}.k-entity-grey .x-layout-split,.k-entity-grey .x-layout-collapsed{background:#4D4D4D none repeat scroll 0 50%;}.k-entity-purple .x-layout-split,.k-entity-purple .x-layout-collapsed{background:#660080 none repeat scroll 0 50%;}.k-entity-red .x-layout-split,.k-entity-red .x-layout-collapsed{background:#D40000 none repeat scroll 0 50%;}.k-entityworkspace .x-layout-split,.k-entityworkspace .x-layout-collapsed{background:transparent none repeat scroll 0 50%;}.k-entityworkspace-default .x-layout-split,.k-entityworkspace-default .x-layout-collapsed{background:#DEAA87 none repeat scroll 0 50%;}.k-entityworkspace-green .x-layout-split,.k-entityworkspace-green .x-layout-collapsed{background:#DCE8AB none repeat scroll 0 50%;}.k-entityworkspace-blue .x-layout-split,.k-entityworkspace-blue .x-layout-collapsed{background:#D5D5FF none repeat scroll 0 50%;}.k-entityworkspace-grey .x-layout-split,.k-entityworkspace-grey .x-layout-collapsed{background:#999 none repeat scroll 0 50%;}.k-entityworkspace-purple .x-layout-split,.k-entityworkspace-purple .x-layout-collapsed{background:#A793AC none repeat scroll 0 50%;}.k-entityworkspace-red .x-layout-split,.k-entityworkspace-red .x-layout-collapsed{background:#F55 none repeat scroll 0 50%;}.k-entity-title{border-left-style:solid;border-left-width:2px;}.k-entity-title div{line-height:22px;white-space:nowrap;}.k-entity-subtitle{}.k-entity-subtitle div{line-height:22px;white-space:nowrap;}.k-entity-title-rd-default{background:#DD8A3D;}.k-entity-title-rd-green{background:#5FD35F;}.k-entity-title-rd-blue{background:#06F;}.k-entity-title-rd-grey{background:#4D4D4D;}.k-entity-title-rd-purple{background:#660080;}.k-entity-title-rd-red{background:#D40000;}.k-entity-title-default{background:#F1BB59 none repeat scroll 0 50%;border-left-color:#DD8A3D;}.k-entity-title-green{background:#AFA none repeat scroll 0 50%;border-left-color:#5FD35F;}.k-entity-title-blue{background:#AFDDE9 none repeat scroll 0 50%;border-left-color:#06F;}.k-entity-title-grey{background:#CCC none repeat scroll 0 50%;border-left-color:#4D4D4D;}.k-entity-title-purple{background:#DDAFE9 none repeat scroll 0 50%;border-left-color:#660080;}.k-entity-title-red{background:#FF8080 none repeat scroll 0 50%;border-left-color:#D40000;}.k-entity-title-default div{color:#69312F;}.k-entity-title-green div{color:#250;}.k-entity-title-blue div{color:navy;}.k-entity-title-grey div{color:#1A1A1A;}.k-entity-title-purple div{color:#405;}.k-entity-title-red div{color:maroon;}.k-entity-subtitle-default{background:#DD8A3D none repeat scroll 0 50%;}.k-entity-subtitle-green{background:#5FD35F none repeat scroll 0 50%;}.k-entity-subtitle-blue{background:#06F none repeat scroll 0 50%;}.k-entity-subtitle-grey{background:#4D4D4D none repeat scroll 0 50%;}.k-entity-subtitle-purple{background:#660080 none repeat scroll 0 50%;}.k-entity-subtitle-red{background:#D40000 none repeat scroll 0 50%;}.k-entity-subtitle-default div{color:#FFF;}.k-entity-subtitle-green div{color:#FFF;}.k-entity-subtitle-blue div{color:#FFF;}.k-entity-subtitle-grey div{color:#FFF;}.k-entity-subtitle-purple div{color:#FFF;}.k-entity-subtitle-red div{color:#FFF;}.k-entity-bottom-rd-default,.k-entity-bottom-default,.k-toolselectoritem-sel-default{background:#DD8A3D;}.k-entity-bottom-rd-green,.k-entity-bottom-green,.k-toolselectoritem-sel-green{background:#5FD35F;}.k-entity-bottom-rd-blue,.k-entity-bottom-blue,.k-toolselectoritem-sel-blue{background:#06F;}.k-entity-bottom-rd-grey,.k-entity-bottom-grey,.k-toolselectoritem-sel-grey{background:#4D4D4D;}.k-entity-bottom-rd-purple,.k-entity-bottom-purple,.k-toolselectoritem-sel-purple{background:#660080;}.k-entity-bottom-rd-red,.k-entity-bottom-red,.k-toolselectoritem-sel-red{background:#D40000;}.k-entity-context-default div,.k-entity-context-default .x-tree .x-panel-body{background:#FFD09D none repeat scroll 0 50%;}.k-entity-context-green div,.k-entity-context-green .x-tree .x-panel-body{background:#CFA none repeat scroll 0 50%;}.k-entity-context-blue div,.k-entity-context-blue .x-tree .x-panel-body{background:#ACF none repeat scroll 0 50%;}.k-entity-context-grey div,.k-entity-context-grey .x-tree .x-panel-body{background:#B3B3B3 none repeat scroll 0 50%;}.k-entity-context-purple div,.k-entity-context-purple .x-tree .x-panel-body{background:#DDAFE9 none repeat scroll 0 50%;}.k-entity-context-red div,.k-entity-context-red .x-tree .x-panel-body{background:#FAA none repeat scroll 0 50%;}.k-entity-context-purple .x-tree .x-panel-body{background:#DDAFE9 none repeat scroll 0 50%;}.k-entity-bottom div{/* line-height: 24px; */color:#FFF;}.k-toolbar-top-line{border-top-color:#d0d0d0;border-top-style:solid;border-top-width:1px;}.k-toolbar-bottom-line{border-bottom-color:#d0d0d0;border-bottom-style:solid;border-bottom-width:1px;}.x-toolbar td,.x-toolbar span,.x-toolbar input,.x-toolbar div,.x-toolbar select,.x-toolbar label{white-space:nowrap;font:normal 100% arial, sans;line-height:19px;}.k-toolbar-sep{padding-top:4px;padding-left:5px;}/* Custom gwt-ext styles */.ytb-sep{background-image:url(../js/ext/resources/images/default/grid/grid-split.gif);background-position:center;background-repeat:no-repeat;display:block;font-size:1px;height:16px;width:4px;overflow:hidden;cursor:default;margin:0 2px;border:0;}.ytb-spacer{width:2px;}.x-grid-group-hd{border-bottom:2px solid grey;cursor:pointer;padding-top:3px;}/* Drop down */.k-dropdownouter{background-color:grey;}.k-dropdownouter-members{}.k-dropdownouter-members-default{background-color:#DF5244;}.k-dropdownouter-members-green{background-color:green;}.k-dropdownouter-members-blue{background-color:#5500D4;}.k-dropdownouter-members-grey{background-color:#4D4D4D;}.k-dropdownouter-members-purple{background-color:#672178;}.k-dropdownouter-members-red{background-color:#A02C2C;}.k-dropdownouter-part{}.k-dropdownouter-part-default{background-color:#CA5842;}.k-dropdownouter-part-green{background-color:#0A0;}.k-dropdownouter-part-blue{background-color:#60F;}.k-dropdownouter-part-grey{background-color:#666;}.k-dropdownouter-part-purple{background-color:#892CA0;}.k-dropdownouter-part-red{background-color:#C83737;}.k-dropdownouter-tags{}.k-dropdownouter-tags-default{background-color:#87501E;}.k-dropdownouter-tags-green{background-color:#00D400;}.k-dropdownouter-tags-blue{background-color:#95F;}.k-dropdownouter-tags-grey{background-color:gray;}.k-dropdownouter-tags-purple{background-color:#AB37C8;}.k-dropdownouter-tags-red{background-color:#D35F5F;}.k-dropdownouter-summary{}.k-dropdownouter-summary-default{background-color:#9F734B;}.k-dropdownouter-summary-green{background-color:#4CE14C;}.k-dropdownouter-summary-blue{background-color:#69A5FF;}.k-dropdownouter-summary-grey{background-color:#A6A6A6;}.k-dropdownouter-summary-purple{background-color:#C473D8;}.k-dropdownouter-summary-red{background-color:#E08F8F;}.k-dropdowninner{margin:0 3px 1px;background:green;background-color:#FFF;/* padding: 3px; */}.k-dropdownlabel{color:#FFF;cursor:pointer;}.k-dropdownlabel .gwt-Label{margin:0 5px 0 0;width:100%;}.k-dropdownlabel img{margin:0 3px 0 1px;}/* WsTheme */.k-wstheme-icon-default{background:#FF8C00;}.k-wstheme-icon-green{background:green;}.k-wstheme-icon-blue{background:blue;}.k-wstheme-icon-grey{background:grey;}.k-wstheme-icon-purple{background:purple;}.k-wstheme-icon-red{background:red;}/* Tool selector items */.k-toolselectoritem{width:auto;margin-bottom:5px;cursor:pointer;}.k-toolselectoritem-sel{}.k-toolselectoritem-notsel-default{background:#FFE9A5;}.k-toolselectoritem-notsel-green{background:#D6F4D6;}.k-toolselectoritem-notsel-blue{background:#D7D7F4;}.k-toolselectoritem-notsel-grey{background:#E6E6E6;}.k-toolselectoritem-notsel-purple{background:#EED7F4;}.k-toolselectoritem-notsel-red{background:#FFD5D5;}.k-toolselectoritem-sel a{color:#FFF;padding:0 9px;text-decoration:none;}.k-toolselectoritem-sel a:hover{text-decoration:none;}.k-toolselectoritem-notsel{}.k-toolselectoritem-notsel a{color:#00F;padding:0 9px;text-decoration:none;}.k-toolselectoritem-notsel a:hover{text-decoration:underline;}/* others *//*
.x-tree-node a span, .x-dd-drag-ghost a span {
color:#000000;
padding: 1px 0px 1px 1px;
Modified: trunk/src/main/java/org/ourproject/kune/app/public/css/docs.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/public/css/docs.css 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/app/public/css/docs.css 2009-03-16 04:13:36 UTC (rev 1078)
@@ -142,7 +142,8 @@
}
.kune-WebSafePalette-popup {
- z-index: 9999 !important;
+ z-index: 9999 !important;
+ background-color: #FFF;
}
.kune-WebSafePalette td {
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatClientModule.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -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.shortcuts.GlobalShortcutRegister;
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;
@@ -83,8 +84,10 @@
register(ToolGroup.class, new Factory<ChatEngine>(ChatEngine.class) {
@Override
public ChatEngine create() {
- return new ChatEngineDefault($(I18nUITranslationService.class), $(WorkspaceSkeleton.class),
- $(Application.class), $(Session.class), $$(EmiteUIDialog.class), $$(FileDownloadUtils.class));
+ final ChatEngineDefault chatEngineDefault = new ChatEngineDefault($(I18nUITranslationService.class),
+ $(WorkspaceSkeleton.class), $(Application.class), $(Session.class), $$(EmiteUIDialog.class),
+ $$(FileDownloadUtils.class), $(GlobalShortcutRegister.class));
+ return chatEngineDefault;
}
});
Modified: trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/chat/client/ChatEngineDefault.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -27,6 +27,8 @@
import org.ourproject.kune.platf.client.dto.StateToken;
import org.ourproject.kune.platf.client.dto.UserInfoDTO;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.ui.WindowUtils;
import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
@@ -59,15 +61,24 @@
private final Provider<FileDownloadUtils> downloadUtils;
private Collection<RosterItem> roster;
private final Event0 onRosterChanged;
+ private final ActionShortcut shortcut;
public ChatEngineDefault(final I18nTranslationService i18n, final WorkspaceSkeleton ws, Application application,
Session session, final Provider<EmiteUIDialog> emiteUIProvider,
- final Provider<FileDownloadUtils> downloadUtils) {
+ final Provider<FileDownloadUtils> downloadUtils, GlobalShortcutRegister globalShortcutRegister) {
this.i18n = i18n;
this.ws = ws;
this.emiteUIProvider = emiteUIProvider;
this.downloadUtils = downloadUtils;
this.onRosterChanged = new Event0("onRosterChanged");
+ shortcut = new ActionShortcut(false, true, false, 'C');
+ globalShortcutRegister.put(shortcut, new Listener0() {
+ public void onEvent() {
+ if (isDialogStarted()) {
+ toggleShow();
+ }
+ }
+ });
session.onInitDataReceived(new Listener<InitDataDTO>() {
public void onEvent(final InitDataDTO initData) {
checkChatDomain(initData.getChatDomain());
@@ -132,6 +143,10 @@
return false;
}
+ public boolean isDialogStarted() {
+ return !emiteUIProvider.get().isDialogNotStarted();
+ }
+
public boolean isLoggedIn() {
return emiteUIProvider.get().isLoggedIn();
}
@@ -177,16 +192,12 @@
emiteUIProvider.get().show(OwnStatus.online);
if (traybarButton == null) {
traybarButton = new ToolbarButton();
- traybarButton.setTooltip(i18n.t("Show/hide the chat window"));
+ traybarButton.setTooltip(i18n.t("Show/hide the chat window" + shortcut.toString()));
traybarButton.setIcon("images/e-icon.gif");
traybarButton.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(final Button button, final EventObject e) {
- if (emiteUIProvider.get().isVisible()) {
- emiteUIProvider.get().hide();
- } else {
- emiteUIProvider.get().show();
- }
+ toggleShow();
}
});
ws.getSiteTraybar().addButton(traybarButton);
@@ -240,6 +251,14 @@
}
}
+ public void toggleShow() {
+ if (emiteUIProvider.get().isVisible()) {
+ emiteUIProvider.get().hide();
+ } else {
+ emiteUIProvider.get().show();
+ }
+ }
+
private XmppURI getLocalUserJid(String shortName) {
return XmppURI.jid(shortName + "@" + chatOptions.domain);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -21,6 +21,7 @@
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.services.ImageDescriptor;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,125 +0,0 @@
-package org.ourproject.kune.platf.client.actions;
-
-import org.ourproject.kune.platf.client.i18n.Resources;
-
-import com.google.gwt.user.client.ui.KeyboardListener;
-
-public class ActionShortcut {
-
- private static final String NO_KEYNAME = "nokeyname";
-
- private static boolean has(int modifiers, int modifier) {
- return ((modifiers & modifier) == modifier);
- }
-
- private final boolean alt;
- private final boolean ctrl;
- private final boolean shift;
- private final char key;
- private final String keyName;
-
- public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key) {
- this(ctrl, alt, shift, key, NO_KEYNAME);
- }
-
- public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key, String keyName) {
- this.alt = alt;
- this.ctrl = ctrl;
- this.shift = shift;
- this.key = key;
- this.keyName = keyName;
- }
-
- public ActionShortcut(boolean ctrl, boolean shift, char key) {
- this(ctrl, false, shift, key, NO_KEYNAME);
- }
-
- public ActionShortcut(boolean ctrl, boolean shift, char key, String keyName) {
- this(ctrl, false, shift, key, keyName);
- }
-
- public ActionShortcut(boolean ctrl, char key) {
- this(ctrl, false, false, key, NO_KEYNAME);
- }
-
- public ActionShortcut(boolean ctrl, char key, String keyName) {
- this(ctrl, false, false, key, keyName);
- }
-
- public ActionShortcut(char key, int modifiers) {
- this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
- modifiers, KeyboardListener.MODIFIER_SHIFT), key, NO_KEYNAME);
- }
-
- public ActionShortcut(char key, int modifiers, String keyName) {
- this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
- modifiers, KeyboardListener.MODIFIER_SHIFT), key, keyName);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ActionShortcut other = (ActionShortcut) obj;
- if (alt != other.alt) {
- return false;
- }
- if (ctrl != other.ctrl) {
- return false;
- }
- if (key != other.key) {
- return false;
- }
- if (shift != other.shift) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (alt ? 1231 : 1237);
- result = prime * result + (ctrl ? 1231 : 1237);
- result = prime * result + key;
- result = prime * result + (shift ? 1231 : 1237);
- return result;
- }
-
- public boolean is(char keyCode, int modifiers) {
- return (keyCode == keyCode && same(modifiers, KeyboardListener.MODIFIER_ALT, alt)
- && same(modifiers, KeyboardListener.MODIFIER_CTRL, ctrl) && same(modifiers,
- KeyboardListener.MODIFIER_SHIFT, shift));
- }
-
- public boolean same(int modifiers, int modifier, boolean keyValue) {
- return (has(modifiers, modifier) == keyValue);
- }
-
- @Override
- public String toString() {
- String s = " (";
- s += sKey(alt, "Alt");
- s += sKey(ctrl, "Ctrl");
- s += sKey(shift, "Shift");
- s += keyName != NO_KEYNAME ? translateKey(keyName) + ")" : String.valueOf(key).toUpperCase() + ")";
- return s;
- }
-
- private String sKey(boolean key, String specialKeyName) {
- return key ? translateKey(specialKeyName) + "+" : "";
- }
-
- private String translateKey(String keyNameToTranslate) {
- return Resources.i18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key");
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,60 +0,0 @@
-package org.ourproject.kune.platf.client.actions;
-
-import java.util.HashMap;
-
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Listener0;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.ui.KeyboardListenerCollection;
-
-public class ActionShortcutRegister {
-
- @SuppressWarnings("unchecked")
- private final HashMap<ActionShortcut, ActionItem> shortcuts;
-
- @SuppressWarnings("unchecked")
- public ActionShortcutRegister() {
- shortcuts = new HashMap<ActionShortcut, ActionItem>();
- }
-
- @SuppressWarnings("unchecked")
- public ActionItem get(ActionShortcut shortcut) {
- return shortcuts.get(shortcut);
- }
-
- @SuppressWarnings("unchecked")
- public ActionItem get(Event event) {
- int modifiers = KeyboardListenerCollection.getKeyboardModifiers(event);
- if (event.getTypeInt() == Event.ONKEYDOWN && modifiers != 0) {
- ActionShortcut shortcut = new ActionShortcut((char) event.getKeyCode(), modifiers);
- Log.debug("Shortcut pressed" + shortcut.toString());
- return shortcuts.get(shortcut);
- }
- // if (modifiers != 0) {
- // Log.debug("Not action associated with this shortcut");
- // }
- return null;
- }
-
- @SuppressWarnings("unchecked")
- public void put(ActionShortcut shortcut, ActionItem actionItem) {
- if (shortcuts.get(shortcut) != null) {
- Log.warn("Shortcut" + shortcut + " already registered");
- }
- shortcuts.put(shortcut, actionItem);
- }
-
- @SuppressWarnings("unchecked")
- public void put(ActionShortcut shortcut, final Listener0 listener) {
- ActionDescriptor descriptor = new ActionDescriptor(AccessRolDTO.Viewer, new Listener0() {
- public void onEvent() {
- listener.onEvent();
- }
- });
- ActionItem item = new ActionItem(descriptor, null);
- put(shortcut, item);
- }
-
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/toolbar/ActionToolbarButton.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,7 +1,7 @@
package org.ourproject.kune.platf.client.actions.toolbar;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
import org.ourproject.kune.platf.client.actions.ActionToolbarDescriptor;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
import com.calclab.suco.client.events.Listener0;
import com.gwtext.client.core.EventObject;
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-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -36,6 +36,7 @@
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;
@@ -48,6 +49,9 @@
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
+import org.ourproject.kune.platf.client.ui.palette.SimplePalette;
+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;
@@ -55,9 +59,9 @@
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.EditHtmlGroup;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlGroup;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditor;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPresenter;
@@ -66,16 +70,16 @@
import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPresenter;
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;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPanel;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPanel;
import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmail;
import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPanel;
import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPresenter;
@@ -83,6 +87,9 @@
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPanel;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtView;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialog;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.inserttable.InsertTableDialogPresenter;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
@@ -250,6 +257,16 @@
}
});
+ register(Singleton.class, new Factory<SimplePalette>(SimplePalette.class) {
+ @Override
+ public SimplePalette create() {
+ final SimplePalettePresenter presenter = new SimplePalettePresenter();
+ final SimplePalettePanel panel = new SimplePalettePanel(presenter, i18n);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) {
@Override
public RTEActionTopToolbar create() {
@@ -281,9 +298,9 @@
final RTEditorPresenter presenter = new RTEditorPresenter($(I18nTranslationService.class),
$(Session.class), topBar, sndBar, $(RTEImgResources.class), $(InsertLinkDialog.class),
$(ColorWebSafePalette.class), $$(EditHtmlDialog.class), $$(InsertImageDialog.class),
- $(DeferredCommandWrapper.class));
+ $$(InsertTableDialog.class), $(DeferredCommandWrapper.class));
final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
- $(ActionManager.class));
+ $(ActionManager.class), $(GlobalShortcutRegister.class));
presenter.init(panel);
return presenter;
}
@@ -357,8 +374,8 @@
@Override
public InsertImageDialog create() {
final InsertImageDialogPresenter presenter = new InsertImageDialogPresenter();
- final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter, $(I18nTranslationService.class),
- $(Images.class), $(InsertImageGroup.class));
+ final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter,
+ $(I18nTranslationService.class), $(Images.class), $(InsertImageGroup.class));
presenter.init(panel);
return presenter;
}
@@ -385,32 +402,37 @@
}
});
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
- register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(
- InsertLinkEmail.class) {
+ register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(InsertLinkEmail.class) {
@Override
public InsertLinkEmail create() {
- final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter(
- $(InsertLinkDialog.class));
- final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter,
- $(I18nTranslationService.class));
+ final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter($(InsertLinkDialog.class));
+ final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter, $(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
});
+ register(Singleton.class, new Factory<InsertTableDialog>(InsertTableDialog.class) {
+ @Override
+ public InsertTableDialog create() {
+ final InsertTableDialogPresenter presenter = new InsertTableDialogPresenter();
+ final InsertTableDialogPanel panel = new InsertTableDialogPanel(presenter, i18n,
+ $$(SimplePalette.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
$(ApplicationComponentGroup.class).createAll();
$(ToolGroup.class).createAll();
$(Application.class).start();
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcut.java (from rev 1076, trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcut.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,125 @@
+package org.ourproject.kune.platf.client.shortcuts;
+
+import org.ourproject.kune.platf.client.i18n.Resources;
+
+import com.google.gwt.user.client.ui.KeyboardListener;
+
+public class ActionShortcut {
+
+ private static final String NO_KEYNAME = "nokeyname";
+
+ private static boolean has(int modifiers, int modifier) {
+ return ((modifiers & modifier) == modifier);
+ }
+
+ private final boolean alt;
+ private final boolean ctrl;
+ private final boolean shift;
+ private final char key;
+ private final String keyName;
+
+ public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key) {
+ this(ctrl, alt, shift, key, NO_KEYNAME);
+ }
+
+ public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key, String keyName) {
+ this.alt = alt;
+ this.ctrl = ctrl;
+ this.shift = shift;
+ this.key = key;
+ this.keyName = keyName;
+ }
+
+ public ActionShortcut(boolean ctrl, boolean shift, char key) {
+ this(ctrl, false, shift, key, NO_KEYNAME);
+ }
+
+ public ActionShortcut(boolean ctrl, boolean shift, char key, String keyName) {
+ this(ctrl, false, shift, key, keyName);
+ }
+
+ public ActionShortcut(boolean ctrl, char key) {
+ this(ctrl, false, false, key, NO_KEYNAME);
+ }
+
+ public ActionShortcut(boolean ctrl, char key, String keyName) {
+ this(ctrl, false, false, key, keyName);
+ }
+
+ public ActionShortcut(char key, int modifiers) {
+ this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
+ modifiers, KeyboardListener.MODIFIER_SHIFT), key, NO_KEYNAME);
+ }
+
+ public ActionShortcut(char key, int modifiers, String keyName) {
+ this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
+ modifiers, KeyboardListener.MODIFIER_SHIFT), key, keyName);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ActionShortcut other = (ActionShortcut) obj;
+ if (alt != other.alt) {
+ return false;
+ }
+ if (ctrl != other.ctrl) {
+ return false;
+ }
+ if (key != other.key) {
+ return false;
+ }
+ if (shift != other.shift) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (alt ? 1231 : 1237);
+ result = prime * result + (ctrl ? 1231 : 1237);
+ result = prime * result + key;
+ result = prime * result + (shift ? 1231 : 1237);
+ return result;
+ }
+
+ public boolean is(char keyCode, int modifiers) {
+ return (keyCode == keyCode && same(modifiers, KeyboardListener.MODIFIER_ALT, alt)
+ && same(modifiers, KeyboardListener.MODIFIER_CTRL, ctrl) && same(modifiers,
+ KeyboardListener.MODIFIER_SHIFT, shift));
+ }
+
+ public boolean same(int modifiers, int modifier, boolean keyValue) {
+ return (has(modifiers, modifier) == keyValue);
+ }
+
+ @Override
+ public String toString() {
+ String s = " (";
+ s += sKey(alt, "Alt");
+ s += sKey(ctrl, "Ctrl");
+ s += sKey(shift, "Shift");
+ s += keyName != NO_KEYNAME ? translateKey(keyName) + ")" : String.valueOf(key).toUpperCase() + ")";
+ return s;
+ }
+
+ private String sKey(boolean key, String specialKeyName) {
+ return key ? translateKey(specialKeyName) + "+" : "";
+ }
+
+ private String translateKey(String keyNameToTranslate) {
+ return Resources.i18n.tWithNT(keyNameToTranslate, "The '" + keyNameToTranslate + "' keyboard key");
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcutRegister.java (from rev 1076, trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/ActionShortcutRegister.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,62 @@
+package org.ourproject.kune.platf.client.shortcuts;
+
+import java.util.HashMap;
+
+import org.ourproject.kune.platf.client.actions.ActionDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.KeyboardListenerCollection;
+
+public class ActionShortcutRegister {
+
+ @SuppressWarnings("unchecked")
+ private final HashMap<ActionShortcut, ActionItem> shortcuts;
+
+ @SuppressWarnings("unchecked")
+ public ActionShortcutRegister() {
+ shortcuts = new HashMap<ActionShortcut, ActionItem>();
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionItem get(ActionShortcut shortcut) {
+ return shortcuts.get(shortcut);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionItem get(Event event) {
+ int modifiers = KeyboardListenerCollection.getKeyboardModifiers(event);
+ if (event.getTypeInt() == Event.ONKEYDOWN && modifiers != 0) {
+ ActionShortcut shortcut = new ActionShortcut((char) event.getKeyCode(), modifiers);
+ Log.debug("Shortcut pressed" + shortcut.toString());
+ return shortcuts.get(shortcut);
+ }
+ // if (modifiers != 0) {
+ // Log.debug("Not action associated with this shortcut");
+ // }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void put(ActionShortcut shortcut, ActionItem actionItem) {
+ if (shortcuts.get(shortcut) != null) {
+ Log.warn("Shortcut" + shortcut + " already registered");
+ }
+ shortcuts.put(shortcut, actionItem);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void put(ActionShortcut shortcut, final Listener0 listener) {
+ ActionDescriptor descriptor = new ActionDescriptor(AccessRolDTO.Viewer, new Listener0() {
+ public void onEvent() {
+ listener.onEvent();
+ }
+ });
+ ActionItem item = new ActionItem(descriptor, null);
+ put(shortcut, item);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java (from rev 1076, trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/shortcuts/GlobalShortcutRegister.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,37 @@
+package org.ourproject.kune.platf.client.shortcuts;
+
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionManager;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.EventPreview;
+
+public class GlobalShortcutRegister extends ActionShortcutRegister {
+
+ private final EventPreview eventPreview;
+
+ public GlobalShortcutRegister(final ActionManager actionManager) {
+ eventPreview = new EventPreview() {
+ @SuppressWarnings("unchecked")
+ public boolean onEventPreview(Event event) {
+ ActionItem actionItem = get(event);
+ if (actionItem != null) {
+ // Log.debug("Not propagating event");
+ DOM.eventPreventDefault(event);
+ actionManager.doAction(actionItem);
+ return false;
+ }
+ return true;
+ }
+ };
+ }
+
+ public void disable() {
+ DOM.removeEventPreview(eventPreview);
+ }
+
+ public void enable() {
+ DOM.addEventPreview(eventPreview);
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/TextUtils.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/TextUtils.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/TextUtils.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -34,6 +34,8 @@
public static final String UNIX_NAME = "^[a-z0-9_\\-]+$";
+ public static final String NUM_REGEXP = "^[0-9]+$";
+
/*
* This method escape only some dangerous html chars
*/
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/DefaultForm.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -29,10 +29,11 @@
public class DefaultForm {
- protected static final int DEF_FIELD_WIDTH = 200;
- protected static final int DEF_SMALL_FIELD_WIDTH = 100;
- protected static final int DEF_MEDIUM_FIELD_WIDTH = 150;
- protected static final int DEF_FIELD_LABEL_WITH = 75;
+ public static final int DEF_FIELD_WIDTH = 200;
+ public static final int DEF_SMALL_FIELD_WIDTH = 100;
+ public static final int DEF_XSMALL_FIELD_WIDTH = 50;
+ public static final int DEF_MEDIUM_FIELD_WIDTH = 150;
+ public static final int DEF_FIELD_LABEL_WITH = 75;
private final FormPanel form;
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalette.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalette.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalette.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,11 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import com.calclab.suco.client.events.Listener;
+
+public interface AbstractPalette {
+
+ void hide();
+
+ void show(int left, int top, Listener<String> onColorSelected);
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePanel.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePanel.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,32 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import com.google.gwt.user.client.ui.PopupPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+public abstract class AbstractPalettePanel {
+ private PopupPanel popupPalette;
+ Widget widget;
+
+ public void hide() {
+ if (popupPalette != null) {
+ popupPalette.hide();
+ }
+ }
+
+ public void show(final int left, final int top) {
+ if (widget == null) {
+ createPalette();
+ }
+ popupPalette = new PopupPanel(true, true);
+ popupPalette.addStyleName("kune-WebSafePalette-popup");
+ popupPalette.setVisible(false);
+ popupPalette.show();
+ popupPalette.setPopupPosition(left, top);
+ popupPalette.setWidget(widget);
+ popupPalette.setVisible(true);
+ }
+
+ protected void createPalette() {
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePresenter.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPalettePresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,28 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import com.calclab.suco.client.events.Listener;
+
+public abstract class AbstractPalettePresenter {
+
+ protected Listener<String> onColorSelected;
+ private AbstractPaletteView view;
+
+ public void hide() {
+ this.view.hide();
+ }
+
+ public void init(final AbstractPaletteView view) {
+ this.view = view;
+ }
+
+ public void show(final int left, final int top, final Listener<String> onColorSelected) {
+ view.show(left, top);
+ this.onColorSelected = onColorSelected;
+ }
+
+ protected void onColorSelected(final String color) {
+ onColorSelected.onEvent(color);
+ view.hide();
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPaletteView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPaletteView.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/AbstractPaletteView.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,11 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface AbstractPaletteView extends View {
+
+ void hide();
+
+ void show(int left, int top);
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalette.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalette.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalette.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -19,12 +19,7 @@
\*/
package org.ourproject.kune.platf.client.ui.palette;
-import com.calclab.suco.client.events.Listener;
-public interface ColorWebSafePalette {
+public interface ColorWebSafePalette extends AbstractPalette {
- void hide();
-
- void show(int left, int top, Listener<String> onColorSelected);
-
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePanel.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePanel.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -21,7 +21,6 @@
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Grid;
-import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.SourcesTableEvents;
import com.google.gwt.user.client.ui.TableListener;
@@ -31,38 +30,18 @@
* http://en.wikipedia.org/wiki/Web_colors#Web-safe_colors
*
*/
-public class ColorWebSafePalettePanel implements ColorWebSafePaletteView {
+public class ColorWebSafePalettePanel extends AbstractPalettePanel implements ColorWebSafePaletteView {
- Grid paletteGrid;
private final ColorWebSafePalettePresenter presenter;
- private PopupPanel popupPalette;
public ColorWebSafePalettePanel(final ColorWebSafePalettePresenter initPresenter) {
this.presenter = initPresenter;
}
- public void hide() {
- if (popupPalette != null) {
- popupPalette.hide();
- }
- }
+ @Override
+ protected void createPalette() {
+ Grid paletteGrid = new Grid(ROWS, COLS);
- public void show(final int left, final int top) {
- if (paletteGrid == null) {
- createPalette();
- }
- popupPalette = new PopupPanel(true, true);
- popupPalette.addStyleName("kune-WebSafePalette-popup");
- popupPalette.setVisible(false);
- popupPalette.show();
- popupPalette.setPopupPosition(left, top);
- popupPalette.setWidget(paletteGrid);
- popupPalette.setVisible(true);
- }
-
- private void createPalette() {
- paletteGrid = new Grid(ROWS, COLS);
-
paletteGrid.setCellSpacing(1);
// Put color values in the grid cells
@@ -88,5 +67,6 @@
presenter.onColorSelected(row, col);
}
});
+ widget = paletteGrid;
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePresenter.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePalettePresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -19,32 +19,11 @@
*/
package org.ourproject.kune.platf.client.ui.palette;
-import com.calclab.suco.client.events.Listener;
+public class ColorWebSafePalettePresenter extends AbstractPalettePresenter implements ColorWebSafePalette {
-public class ColorWebSafePalettePresenter implements ColorWebSafePalette {
-
- private Listener<String> onColorSelected;
- private ColorWebSafePaletteView view;
-
- public ColorWebSafePalettePresenter() {
- }
-
- public void hide() {
- this.view.hide();
- }
-
- public void init(final ColorWebSafePaletteView view) {
- this.view = view;
- }
-
- public void show(final int left, final int top, final Listener<String> onColorSelected) {
- view.show(left, top);
- this.onColorSelected = onColorSelected;
- }
-
protected void onColorSelected(final int row, final int col) {
final String color = getColor(row, col);
- onColorSelected.onEvent(color);
+ onColorSelected(color);
}
private String getColor(final int row, final int col) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePaletteView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePaletteView.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/ColorWebSafePaletteView.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -19,7 +19,7 @@
*/
package org.ourproject.kune.platf.client.ui.palette;
-public interface ColorWebSafePaletteView {
+public interface ColorWebSafePaletteView extends AbstractPaletteView {
int ROWS = 18;
@@ -27,8 +27,4 @@
String COLORS[] = { "0", "3", "6", "9", "C", "F" };
- void hide();
-
- void show(int left, int top);
-
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalette.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalette.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalette.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,4 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+public interface SimplePalette extends AbstractPalette {
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePanel.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePanel.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,30 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+
+import com.gwtext.client.widgets.ColorPalette;
+import com.gwtext.client.widgets.event.ColorPaletteListenerAdapter;
+
+public class SimplePalettePanel extends AbstractPalettePanel implements SimplePaletteView {
+
+ private final SimplePalettePresenter presenter;
+ private final I18nTranslationService i18n;
+
+ public SimplePalettePanel(final SimplePalettePresenter presenter, I18nTranslationService i18n) {
+ this.presenter = presenter;
+ this.i18n = i18n;
+ }
+
+ @Override
+ protected void createPalette() {
+ ColorPalette colorPalette = new ColorPalette();
+ colorPalette.setTitle(i18n.t("Pick a color"));
+ colorPalette.addListener(new ColorPaletteListenerAdapter() {
+ @Override
+ public void onSelect(ColorPalette colorPalette, String color) {
+ presenter.onColorSelected(color);
+ }
+ });
+ widget = colorPalette;
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePresenter.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePalettePresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,6 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+
+public class SimplePalettePresenter extends AbstractPalettePresenter implements SimplePalette {
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePaletteView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePaletteView.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/palette/SimplePaletteView.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.ui.palette;
+
+
+public interface SimplePaletteView extends AbstractPaletteView {
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RichTextArea.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -18,6 +18,7 @@
import org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl;
import com.google.gwt.core.client.GWT;
+import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FocusWidget;
@@ -25,6 +26,7 @@
import com.google.gwt.user.client.ui.MouseListener;
import com.google.gwt.user.client.ui.MouseListenerCollection;
import com.google.gwt.user.client.ui.SourcesMouseEvents;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
/**
* A rich text editor that allows complex styling and formatting.
@@ -391,6 +393,28 @@
}
/**
+ * NOTE: If the current browser doesn't support rich text editing this
+ * method returns <code>null</code>. You should test the returned value and
+ * fail save to an appropriate behavior!<br/>
+ * The appropriate test would be: <code><pre>
+ * if (rta.isAttached() && rta.getDocument() == null) {
+ * // The current browser doesn't support rich text editing.
+ * }
+ * </pre></code>
+ *
+ * @return The DOM document being edited with this rich text area.
+ *
+ * copied from xwiki
+ */
+ public Document getDocument() {
+ if (getElement().getTagName().equalsIgnoreCase("iframe")) {
+ return IFrameElement.as(getElement()).getContentDocument().cast();
+ } else {
+ return null;
+ }
+ }
+
+ /**
* Gets the full rich text formatting interface.
*
* @return <code>null</code> if full formatting is not supported
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-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -16,18 +16,17 @@
import org.ourproject.kune.platf.client.actions.ActionItem;
import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.actions.ActionShortcutRegister;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcutRegister;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
import com.google.gwt.dom.client.Element;
-import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FocusListener;
import com.google.gwt.user.client.ui.Widget;
-import com.xpn.xwiki.wysiwyg.client.dom.Document;
import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment;
import com.xpn.xwiki.wysiwyg.client.dom.Range;
import com.xpn.xwiki.wysiwyg.client.dom.Selection;
@@ -49,18 +48,20 @@
private final RTEditorPresenter presenter;
private final ActionManager actionManager;
private final ActionShortcutRegister shortcutRegister;
+ private final GlobalShortcutRegister globalShortcutReg;
public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n,
- final ActionManager actionManager) {
+ final ActionManager actionManager, GlobalShortcutRegister globalShortcutReg) {
this.presenter = presenter;
this.i18n = i18n;
this.actionManager = actionManager;
+ this.globalShortcutReg = globalShortcutReg;
basic = getBasicFormatter();
extended = getExtendedFormatter();
shortcutRegister = new ActionShortcutRegister();
EventListener listener = new EventListener();
addFocusListener(listener);
- setWidth("97%");
+ setWidth("96%");
setHeight("100%");
}
@@ -107,28 +108,6 @@
setFocus(true);
}
- /**
- * NOTE: If the current browser doesn't support rich text editing this
- * method returns <code>null</code>. You should test the returned value and
- * fail save to an appropriate behavior!<br/>
- * The appropriate test would be: <code><pre>
- * if (rta.isAttached() && rta.getDocument() == null) {
- * // The current browser doesn't support rich text editing.
- * }
- * </pre></code>
- *
- * @return The DOM document being edited with this rich text area.
- *
- * copied from xwiki
- */
- public Document getDocument() {
- if (getElement().getTagName().equalsIgnoreCase("iframe")) {
- return IFrameElement.as(getElement()).getContentDocument().cast();
- } else {
- return null;
- }
- }
-
public void insertComment(String author) {
String comment = null;
createCommentAndSelectIt(author, comment);
@@ -221,7 +200,8 @@
super.onBrowserEvent(event);
break;
case Event.ONKEYDOWN:
- ActionItem actionItem = shortcutRegister.get(event);
+ ActionItem rtaActionItem = shortcutRegister.get(event);
+ ActionItem actionItem = rtaActionItem != null ? rtaActionItem : globalShortcutReg.get(event);
if (actionItem != null) {
updateStatus();
fireEdit();
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-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -7,7 +7,6 @@
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.ActionShortcut;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
@@ -15,7 +14,9 @@
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.ActionShortcut;
import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
@@ -23,6 +24,7 @@
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.inserttable.InsertTableDialog;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import com.calclab.suco.client.events.Event0;
@@ -66,11 +68,17 @@
private final ActionAddCondition<Object> canBeExtended;
private final Provider<EditHtmlDialog> editHtmlDialog;
private final Provider<InsertImageDialog> insertImageDialog;
+ private final Provider<InsertTableDialog> insertTableDialog;
+ private Listener<String> insertTableListener;
+ private Listener2<String, String> insertLinkListener;
+ private Listener<String> updateHtmlListener;
+ private ActionToolbarButtonDescriptor<Object> insertTableBtn;
public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
RTEActionSndToolbar sndBar, RTEImgResources imgResources, InsertLinkDialog textEditorInsertElement,
ColorWebSafePalette palette, Provider<EditHtmlDialog> editHtmlDialog,
- Provider<InsertImageDialog> insertImageDialog, DeferredCommandWrapper deferred) {
+ Provider<InsertImageDialog> insertImageDialog, Provider<InsertTableDialog> insertTableDialog,
+ DeferredCommandWrapper deferred) {
this.i18n = i18n;
this.session = session;
this.topBar = topBar;
@@ -79,6 +87,7 @@
this.palette = palette;
this.editHtmlDialog = editHtmlDialog;
this.insertImageDialog = insertImageDialog;
+ this.insertTableDialog = insertTableDialog;
this.deferred = deferred;
styleToolbar(sndBar);
sndBar.attach();
@@ -399,14 +408,18 @@
ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
new Listener0() {
+
public void onEvent() {
+ if (updateHtmlListener == null) {
+ updateHtmlListener = new Listener<String>() {
+ public void onEvent(String html) {
+ view.setHTML(html);
+ fireOnEdit();
+ }
+ };
+ }
EditHtmlDialog dialog = editHtmlDialog.get();
- dialog.setUpdateListener(new Listener<String>() {
- public void onEvent(String html) {
- view.setHTML(html);
- fireOnEdit();
- }
- });
+ dialog.setUpdateListener(updateHtmlListener);
dialog.show();
dialog.setHtml(view.getHTML());
}
@@ -558,12 +571,15 @@
public void onEvent() {
deferred.addCommand(new Listener0() {
public void onEvent() {
- insertElement.setOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- view.createLink(url);
- fireOnEdit();
- }
- });
+ if (insertLinkListener == null) {
+ insertLinkListener = new Listener2<String, String>() {
+ public void onEvent(String name, String url) {
+ view.createLink(url);
+ fireOnEdit();
+ }
+ };
+ }
+ insertElement.setOnCreateLink(insertLinkListener);
insertElement.show();
}
});
@@ -599,10 +615,21 @@
removeFormat.setAddCondition(canBeExtended);
removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
+ final ActionToolbarMenuDescriptor<Object> insertMedia = new ActionToolbarMenuDescriptor<Object>(accessRol,
+ topbar, new Listener0() {
+ public void onEvent() {
+ NotifyUser.info(TextUtils.IN_DEVELOPMENT);
+ }
+ });
+ insertMedia.setIconCls(getCssName(imgResources.film()));
+ insertMedia.setTextDescription(i18n.t("Insert Media ..."));
+ insertMedia.setAddCondition(canBeExtended);
+ insertMedia.setParentMenuTitle(i18n.t(INSERT_MENU));
+
final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
topbar, new Listener0() {
public void onEvent() {
- insertSimpleTable();
+ onInsertTablePressed();
}
});
insertTable.setIconCls(getCssName(imgResources.inserttable()));
@@ -610,12 +637,11 @@
insertTable.setAddCondition(canBeExtended);
insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
- final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
- accessRol, sndbar, new Listener0() {
- public void onEvent() {
- insertSimpleTable();
- }
- });
+ 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);
@@ -624,7 +650,7 @@
final ActionToolbarButtonDescriptor<Object> fontColor = new ActionToolbarButtonDescriptor<Object>(accessRol,
sndbar, new Listener0() {
public void onEvent() {
- palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar,
+ palette.show(getActionLeftPosition(sndBar, insertTableBtn), getActionTopPosition(sndBar,
removeFormat), new Listener<String>() {
public void onEvent(String color) {
palette.hide();
@@ -710,6 +736,7 @@
actions.add(withNoItem(removeLink));
actions.add(withNoItem(insertTableBtn));
actions.add(withNoItem(insertTable));
+ actions.add(withNoItem(insertMedia));
actions.add(withNoItem(comment));
actions.add(withNoItem(undoBtn));
actions.add(withNoItem(redoBtn));
@@ -772,14 +799,6 @@
return RTEImgResources.SUFFIX + imageResource.getName();
}
- private void insertSimpleTable() {
- view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
- + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
- + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
- + "</td>\n" + "</tr>\n</tbody>\n</table>");
- fireOnEdit();
- }
-
private boolean isExtended() {
return extended && view.canBeExtended();
}
@@ -792,6 +811,23 @@
};
}
+ private void onInsertTablePressed() {
+ if (insertTableListener == null) {
+ insertTableListener = new Listener<String>() {
+ public void onEvent(String table) {
+ if (view.isAnythingSelected()) {
+ // FIXME
+ // move to end of selection?
+ }
+ view.insertHtml(table);
+ fireOnEdit();
+ }
+ };
+ }
+ insertTableDialog.get().setOnInsertTable(insertTableListener);
+ insertTableDialog.get().show();
+ }
+
private void styleToolbar(ActionToolbar<Object> bar) {
bar.setNormalStyle();
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/RTEImgResources.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -47,6 +47,9 @@
@Resource("edithtml.png")
public ImageResource edithtml();
+ @Resource("film.png")
+ public ImageResource film();
+
@Resource("fontcolor.png")
public ImageResource fontcolor();
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/film.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/film.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/rteimg.css
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/rteimg.css 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/img/rteimg.css 2009-03-16 04:13:36 UTC (rev 1078)
@@ -10,6 +10,10 @@
gwt-image: 'subscript';
}
+@sprite div .k-rte-film {
+ gwt-image: 'film';
+}
+
@sprite div .k-rte-strikeout {
gwt-image: 'strikeout';
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractRichTextAreaTest.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,161 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea;
+
+import com.google.gwt.user.client.Timer;
+import com.google.gwt.user.client.ui.LoadListener;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.SourcesLoadEvents;
+import com.google.gwt.user.client.ui.Widget;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
+
+/**
+ * Base class for tests running on a rich text area.
+ *
+ * @version $Id$
+ */
+public class AbstractRichTextAreaTest extends AbstractWysiwygClientTest implements LoadListener {
+ /**
+ * The number of milliseconds we delay the test finish. This delay is needed
+ * because in some browsers the rich text area is initialized after a
+ * timeout.
+ */
+ public static final int FINISH_DELAY = 400;
+
+ /**
+ * The number of milliseconds we delay the test start. This delay is needed
+ * because in some browsers the rich text area is initialized after a
+ * timeout and we want to start the test after the rich text area is fully
+ * initialized.
+ */
+ public static final int START_DELAY = 300;
+
+ /**
+ * The rich text area on which we run the tests.
+ */
+ protected RichTextArea rta;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see LoadListener#onError(Widget)
+ */
+ public void onError(Widget sender) {
+ // ignore
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see LoadListener#onLoad(Widget)
+ */
+ public void onLoad(Widget sender) {
+ // http://wiki.codetalks.org/wiki/index.php/Docs/Keyboard_navigable_JS_widgets
+ // #Use_setTimeout_with_element.focus.28.29_to_set_focus
+ (new Timer() {
+ @Override
+ public void run() {
+ rta.setFocus(true);
+ }
+ }).schedule(1);
+ }
+
+ /**
+ * Cleans the HTML input. This is needed in order to have uniform tests
+ * between Firefox and Internet Explorer.
+ *
+ * @param html
+ * The HTML fragment to be cleaned.
+ * @return The input string in lower case, stripped of new lines.
+ */
+ protected String clean(String html) {
+ return html.replaceAll("\r\n", "").toLowerCase();
+ }
+
+ /**
+ * @return The body element of the DOM document edited with the rich text
+ * area.
+ */
+ protected Element getBody() {
+ return rta.getDocument().getBody().cast();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractWysiwygClientTest#gwtSetUp()
+ */
+ @Override
+ protected void gwtSetUp() throws Exception {
+ super.gwtSetUp();
+
+ if (rta == null) {
+ rta = new RichTextArea();
+ // Workaround till GWT provides a way to detect when the rich text
+ // area has finished loading.
+ if (rta.getBasicFormatter() != null && rta.getBasicFormatter() instanceof SourcesLoadEvents) {
+ ((SourcesLoadEvents) rta.getBasicFormatter()).addLoadListener(this);
+ }
+ }
+ RootPanel.get().add(rta);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractWysiwygClientTest#gwtTearDown()
+ */
+ @Override
+ protected void gwtTearDown() throws Exception {
+ super.gwtTearDown();
+
+ RootPanel.get().remove(rta);
+ }
+
+ /**
+ * Removes the non-breaking spaces, {@code }, from the given HTML. The
+ * is method is needed because the Selection implementation for Internet
+ * Explorer adds {@code } when it cannot place the caret at the
+ * specified place.
+ *
+ * @param html
+ * the HTML fragment to be cleaned of non-breaking spaces
+ * @return the input HTML fragment without any non-breaking spaces
+ */
+ protected String removeNonBreakingSpaces(String html) {
+ return html.replace(" ", "");
+ }
+
+ /**
+ * Selects the given range.
+ *
+ * @param range
+ * The range to be selected.
+ */
+ protected void select(Range range) {
+ Selection selection = rta.getDocument().getSelection();
+ selection.removeAllRanges();
+ selection.addRange(range);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractWysiwygClientTest.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractWysiwygClientTest.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/AbstractWysiwygClientTest.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,55 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import com.google.gwt.dom.client.Document;
+import com.google.gwt.junit.client.GWTTestCase;
+
+/**
+ * Base class for all WYSIWYG client tests. It returns the name of the module in {@link #getModuleName()} so you don't
+ * have to do it in each test.
+ *
+ * @version $Id$
+ */
+public abstract class AbstractWysiwygClientTest extends GWTTestCase
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see GWTTestCase#getModuleName()
+ */
+ public String getModuleName()
+ {
+ return "com.xpn.xwiki.wysiwyg.Wysiwyg";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see GWTTestCase#gwtSetUp()
+ */
+ protected void gwtSetUp() throws Exception
+ {
+ super.gwtSetUp();
+
+ // We have to remove the default body border because it affects the range detection in IE.
+ Document.get().getBody().getStyle().setProperty("borderStyle", "none");
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,14 +1,15 @@
package org.ourproject.kune.platf.client.ui.rte.insertlink;
import com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.junit.client.GWTTestCase;
-import com.google.gwt.user.client.ui.Hyperlink;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
-public class LinkInfoTest extends GWTTestCase {
+public class LinkInfoTest extends AbstractRichTextAreaTest {
- private static final String TEXT = "some link";
+ private static final String TEXT = "somelink";
private static final String HREF = "http://example.com";
private static final String TITLE = "on over";
+ private static final String _BLANK = "_blank";
@Override
public String getModuleName() {
@@ -16,13 +17,29 @@
}
public void testSimpleLink() {
- Hyperlink link = new Hyperlink(TEXT, HREF);
- link.setTitle(TITLE);
- Log.info(link.getHTML());
- LinkInfo linkParsed = LinkInfo.parse(link.getElement());
- assertEquals(TEXT, linkParsed.getText());
- assertEquals(HREF, linkParsed.getUrl());
- assertEquals(TITLE, linkParsed.getTitle());
- assertEquals(false, linkParsed.isInNewWindow());
+ // String html = createHtmlLink(HREF, TITLE, _BLANK, TEXT);
+ rta.setHTML(TEXT);
+ Log.debug(rta.getHTML());
+
+ Range range = rta.getDocument().createRange();
+ range.setStart(getBody().getFirstChild(), 1);
+ range.setEnd(getBody().getFirstChild(), 3);
+ String selectedText = "om";
+
+ Selection selection = rta.getDocument().getSelection();
+ selection.removeAllRanges();
+ selection.addRange(range);
+ assertEquals(selectedText, selection.toString());
+ //
+ // LinkInfo linkParsed =
+ // LinkInfo.parse(getBody().getFirstChildElement());
+ // assertEquals(TEXT, linkParsed.getText());
+ // assertEquals(HREF, linkParsed.getUrl());
+ // assertEquals(TITLE, linkParsed.getTitle());
+ // assertEquals(false, linkParsed.isInNewWindow());
}
+
+ private String createHtmlLink(String href, String title, String target, String text) {
+ return "<a title=\"" + title + "\" href=\"" + href + "\" target=\"" + target + "\">" + text + "</a>";
+ }
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialog.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialog.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,13 @@
+package org.ourproject.kune.platf.client.ui.rte.inserttable;
+
+import com.calclab.suco.client.events.Listener;
+
+public interface InsertTableDialog {
+
+ void hide();
+
+ void setOnInsertTable(Listener<String> listener);
+
+ void show();
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPanel.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPanel.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,185 @@
+package org.ourproject.kune.platf.client.ui.rte.inserttable;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.TextUtils;
+import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.platf.client.ui.palette.SimplePalette;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.ioc.Provider;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.Grid;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.Checkbox;
+import com.gwtext.client.widgets.form.Field;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.event.FieldListenerAdapter;
+
+public class InsertTableDialogPanel extends BasicDialog implements InsertTableDialogView {
+
+ private static final String INSERT_LINK_ID = "itdp-diag";
+ private static final String R_FIELD = "itdp-wfield";
+ private static final String C_FIELD = "itdp-cfield";
+ private final TextField rowsField;
+ private final TextField colsField;
+ private final Checkbox sameWidth;
+ private final DefaultForm form;
+ private final TextField backColorField;
+ private final TextField borderField;
+ private final I18nTranslationService i18n;
+ private final TextField borderColorField;
+
+ public InsertTableDialogPanel(final InsertTableDialogPresenter presenter, I18nTranslationService i18n,
+ final Provider<SimplePalette> simplePalette) {
+ super(INSERT_LINK_ID, i18n.t("Insert Table"), true, false, 320, 260);
+ this.i18n = i18n;
+ form = new DefaultForm();
+ form.setAutoWidth(true);
+ form.setAutoHeight(true);
+
+ rowsField = new TextField();
+ rowsField.setTabIndex(4);
+ rowsField.setFieldLabel(i18n.t("Rows"));
+ rowsField.setWidth(DefaultForm.DEF_XSMALL_FIELD_WIDTH);
+ rowsField.setName(R_FIELD);
+ rowsField.setRegex(TextUtils.NUM_REGEXP);
+ rowsField.setRegexText(i18n.t("This must be a number"));
+ rowsField.setAllowBlank(false);
+ rowsField.setValidationEvent(false);
+ rowsField.setId(R_FIELD);
+ rowsField.setValue("2");
+
+ colsField = new TextField();
+ colsField.setTabIndex(5);
+ colsField.setFieldLabel(i18n.t("Columns"));
+ colsField.setName(C_FIELD);
+ colsField.setWidth(DefaultForm.DEF_XSMALL_FIELD_WIDTH);
+ colsField.setRegex(TextUtils.NUM_REGEXP);
+ colsField.setRegexText(i18n.t("This must be a number"));
+ colsField.setAllowBlank(false);
+ colsField.setValidationEvent(false);
+ colsField.setId(C_FIELD);
+ colsField.setValue("2");
+
+ borderField = new TextField();
+ borderField.setTabIndex(5);
+ borderField.setFieldLabel(i18n.t("Border Size"));
+ borderField.setWidth(DefaultForm.DEF_XSMALL_FIELD_WIDTH);
+ borderField.setRegex(TextUtils.NUM_REGEXP);
+ borderField.setRegexText(i18n.t("This must be a number"));
+ borderField.setAllowBlank(false);
+ borderField.setValidationEvent(false);
+ borderField.setValue("0");
+
+ sameWidth = new Checkbox(i18n.t("Columns of equal width"));
+ sameWidth.setChecked(true);
+
+ backColorField = createColorField(i18n.t("Background color"));
+ borderColorField = createColorField(i18n.t("Border color"));
+
+ FieldListenerAdapter colorListener = new FieldListenerAdapter() {
+ @Override
+ public void onFocus(final Field field) {
+ super.onFocus(field);
+ simplePalette.get().show(field.getAbsoluteLeft() + 10, field.getAbsoluteTop() + 10,
+ new Listener<String>() {
+ public void onEvent(String color) {
+ setBackgroupFieldColor(field, color);
+ field.setValue("#" + color);
+ }
+ });
+ }
+ };
+ backColorField.addListener(colorListener);
+ borderColorField.addListener(colorListener);
+
+ form.add(rowsField);
+ form.add(colsField);
+ form.add(sameWidth);
+ form.add(backColorField);
+ form.add(borderField);
+ form.add(borderColorField);
+
+ Button insert = new Button(i18n.t("Insert"));
+ insert.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ if (form.getFormPanel().getForm().isValid()) {
+ presenter.onInsert(rowsField.getValueAsString(), colsField.getValueAsString(),
+ borderField.getValueAsString());
+ }
+ }
+ });
+ Button cancel = new Button(i18n.t("Cancel"));
+ cancel.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onCancel();
+ }
+ });
+
+ super.add(form.getFormPanel());
+ super.addButton(insert);
+ super.addButton(cancel);
+ }
+
+ public String generateTable(int rows, int cols, boolean sameColWidth, String backgroundColor, int border,
+ String borderColor) {
+ Grid table = new Grid(rows, cols);
+ table.setWidth("100%");
+ if (backgroundColor != null) {
+ DOM.setElementAttribute(table.getElement(), "bgcolor", backgroundColor);
+ }
+
+ if (borderColor != null) {
+ DOM.setElementAttribute(table.getElement(), "bordercolor", borderColor);
+ }
+
+ table.setBorderWidth(border);
+ table.setCellPadding(3);
+ table.setCellSpacing(0);
+ if (sameColWidth) {
+ int colWith = 100 / cols;
+ for (int i = 0; i < cols; i++) {
+ table.getColumnFormatter().setWidth(i, colWith + "%");
+ }
+ }
+ return table.getElement().getString();
+ }
+
+ public String getBackgroundColor() {
+ return backColorField.getValueAsString();
+ }
+
+ public String getBorderColor() {
+ return borderColorField.getValueAsString();
+ }
+
+ public boolean getSameColWidth() {
+ return sameWidth.getValue();
+ }
+
+ public void reset() {
+ form.getFormPanel().getForm().reset();
+ rowsField.setValue("2");
+ colsField.setValue("2");
+ borderField.setValue("0");
+ sameWidth.setChecked(true);
+ setBackgroupFieldColor(backColorField, "FFFFFF");
+ setBackgroupFieldColor(borderColorField, "FFFFFF");
+ }
+
+ private TextField createColorField(String text) {
+ TextField field = new TextField(text);
+ field.setWidth(DefaultForm.DEF_XSMALL_FIELD_WIDTH + 15);
+ field.setTitle(i18n.t("Click to change"));
+ return field;
+ }
+
+ private void setBackgroupFieldColor(Field field, String color) {
+ field.setStyle("background-color: #" + color + ";background-image:none;");
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPresenter.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogPresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,56 @@
+package org.ourproject.kune.platf.client.ui.rte.inserttable;
+
+import com.calclab.suco.client.events.Listener;
+
+public class InsertTableDialogPresenter implements InsertTableDialog {
+
+ private static final int MAX_ROWS = 100;
+ private static final int MAX_COLS = 25;
+ private static final int MAX_BORDER = 50;
+ private InsertTableDialogView view;
+ private Listener<String> onInsertTable;
+
+ public InsertTableDialogPresenter() {
+ }
+
+ public void hide() {
+ view.hide();
+ }
+
+ public void init(InsertTableDialogView view) {
+ this.view = view;
+ }
+
+ public void onCancel() {
+ view.hide();
+ view.reset();
+ }
+
+ public void onInsert(String rowsS, String colsS, String borderS) {
+ if (onInsertTable != null) {
+ Integer rows = new Integer(rowsS);
+ Integer cols = new Integer(colsS);
+ Integer border = new Integer(borderS);
+ boolean validRows = rows < MAX_ROWS && rows > 0;
+ boolean validCols = cols < MAX_COLS && cols > 0;
+ boolean validBorder = border < MAX_BORDER && border > 0;
+ onInsertTable.onEvent(createTable(validRows ? rows : MAX_ROWS, validCols ? cols : MAX_COLS,
+ validBorder ? border : MAX_BORDER));
+ }
+ view.hide();
+ view.reset();
+ }
+
+ public void setOnInsertTable(Listener<String> listener) {
+ this.onInsertTable = listener;
+ }
+
+ public void show() {
+ view.show();
+ }
+
+ private String createTable(int rows, int cols, int border) {
+ return view.generateTable(rows, cols, view.getSameColWidth(), view.getBackgroundColor(), border,
+ view.getBorderColor());
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogView.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/inserttable/InsertTableDialogView.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -0,0 +1,21 @@
+package org.ourproject.kune.platf.client.ui.rte.inserttable;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface InsertTableDialogView extends View {
+
+ String generateTable(int rows, int cols, boolean sameColWidth, String backgroundColor, int border,
+ String borderColor);
+
+ String getBackgroundColor();
+
+ String getBorderColor();
+
+ boolean getSameColWidth();
+
+ void hide();
+
+ void reset();
+
+ void show();
+}
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-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,12 +1,12 @@
package org.ourproject.kune.platf.client.ui.rte.saving;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
import org.ourproject.kune.platf.client.actions.BeforeActionListener;
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
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.img.RTEImgResources;
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -468,7 +468,7 @@
});
action.setTextDescription(textDescription);
action.setParentMenuTitle(PUBLICATION_MENU);
- // action.setParentSubMenuTitle(i18n.t("Change the status"));
+ action.setParentMenuIconUrl("images/anybody.png");
contentActionRegistry.addAction(action, contentsModerated);
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -42,6 +42,7 @@
import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.services.ImageUtils;
import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
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;
@@ -82,7 +83,6 @@
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspace;
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePanel;
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePresenter;
-import org.ourproject.kune.workspace.client.events.GlobalShortcutRegister;
import org.ourproject.kune.workspace.client.i18n.I18nTranslator;
import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPanel;
import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPresenter;
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -1,38 +0,0 @@
-package org.ourproject.kune.workspace.client.events;
-
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionManager;
-import org.ourproject.kune.platf.client.actions.ActionShortcutRegister;
-
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Event;
-import com.google.gwt.user.client.EventPreview;
-
-public class GlobalShortcutRegister extends ActionShortcutRegister {
-
- private final EventPreview eventPreview;
-
- public GlobalShortcutRegister(final ActionManager actionManager) {
- eventPreview = new EventPreview() {
- @SuppressWarnings("unchecked")
- public boolean onEventPreview(Event event) {
- ActionItem actionItem = get(event);
- if (actionItem != null) {
- // Log.debug("Not propagating event");
- DOM.eventPreventDefault(event);
- actionManager.doAction(actionItem);
- return false;
- }
- return true;
- }
- };
- }
-
- public void disable() {
- DOM.removeEventPreview(eventPreview);
- }
-
- public void enable() {
- DOM.addEventPreview(eventPreview);
- }
-}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -20,15 +20,15 @@
package org.ourproject.kune.workspace.client.hello;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
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.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
+import org.ourproject.kune.platf.client.shortcuts.GlobalShortcutRegister;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.workspace.client.AbstractFoldableContentActions;
-import org.ourproject.kune.workspace.client.events.GlobalShortcutRegister;
import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry;
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-15 18:00:13 UTC (rev 1077)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-16 04:13:36 UTC (rev 1078)
@@ -5,6 +5,7 @@
import org.junit.Before;
import org.junit.Test;
+import org.ourproject.kune.platf.client.shortcuts.ActionShortcut;
import com.google.gwt.user.client.ui.KeyboardListener;
1
0
Author: vjrj
Date: 2009-03-15 19:00:13 +0100 (Sun, 15 Mar 2009)
New Revision: 1077
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java
Log:
Complete - RTE styling issue in non-mozilla browsers
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplIE6.java 2009-03-15 18:00:13 UTC (rev 1077)
@@ -35,33 +35,33 @@
@Override
public native void initElement() /*-{
- var _this = this;
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
+ var _this = this;
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
- setTimeout(function() {
- if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) {
- return;
- }
+ setTimeout(function() {
+ if (_this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing == false) {
+ return;
+ }
- // Attempt to set the iframe document's body to 'contentEditable' mode.
- // There's no way to know when the body will actually be available, so
- // keep trying every so often until it is.
- // Note: The body seems to be missing only rarely, so please don't remove
- // this retry loop just because it's hard to reproduce.
- var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
- var doc = elem.contentWindow.document;
- if (!doc.body) {
- // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower
- // would increase the probability of a user-visible delay.
- setTimeout(arguments.callee, 50);
- return;
- }
- var ct = "<html><head><style>@import url('" + $wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
- doc.write( ct );
- doc.body.contentEditable = true;
+ // Attempt to set the iframe document's body to 'contentEditable' mode.
+ // There's no way to know when the body will actually be available, so
+ // keep trying every so often until it is.
+ // Note: The body seems to be missing only rarely, so please don't remove
+ // this retry loop just because it's hard to reproduce.
+ var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
+ var doc = elem.contentWindow.document;
+ if (!doc.body) {
+ // Retry in 50 ms. Faster would run the risk of pegging the CPU. Slower
+ // would increase the probability of a user-visible delay.
+ setTimeout(arguments.callee, 50);
+ return;
+ }
+ var ct = "<html><head><style>@import url('" + $wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
+ doc.write( ct );
+ doc.body.contentEditable = true;
- // Send notification that the iframe has reached design mode.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
- }, 1);
- }-*/;
+ // Send notification that the iframe has reached design mode.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
+ }, 1);
+ }-*/;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplMozilla.java 2009-03-15 18:00:13 UTC (rev 1077)
@@ -35,42 +35,42 @@
@Override
public native void initElement() /*-{
- // Mozilla doesn't allow designMode to be set reliably until the iframe is
- // fully loaded.
- var _this = this;
- var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
+ // Mozilla doesn't allow designMode to be set reliably until the iframe is
+ // fully loaded.
+ var _this = this;
+ var iframe = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
- iframe.onload = function() {
- // Some Mozillae have the nasty habit of calling onload again when you set
- // designMode, so let's avoid doing it more than once.
- iframe.onload = null;
+ iframe.onload = function() {
+ // Some Mozillae have the nasty habit of calling onload again when you set
+ // designMode, so let's avoid doing it more than once.
+ iframe.onload = null;
- // patch ccs inject:
+ // patch ccs inject:
- var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document;
- head=doc.getElementsByTagName('head')[0];
- link=document.createElement('link');
- link.setAttribute('rel',"stylesheet");
- link.setAttribute('type',"text/css");
- link.setAttribute('href',$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" );
- head.appendChild(link);
+ var doc = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document;
+ head=doc.getElementsByTagName('head')[0];
+ link=document.createElement('link');
+ link.setAttribute('rel',"stylesheet");
+ link.setAttribute('type',"text/css");
+ link.setAttribute('href',$wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" );
+ head.appendChild(link);
- // -- patch
+ // -- patch
- // Send notification that the iframe has finished loading.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
+ // Send notification that the iframe has finished loading.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
- // Don't set designMode until the RTA actually gets focused. This is
- // necessary because editing won't work on Mozilla if the iframe is
- // *hidden, but attached*. Waiting for focus gets around this issue.
- //
- // Note: This onfocus will not conflict with the addEventListener('focus',
- // ...) // in RichTextAreaImplStandard.
- iframe.contentWindow.onfocus = function() {
- iframe.contentWindow.onfocus = null;
- iframe.contentWindow.document.designMode = 'On';
- };
- };
- }-*/;
+ // Don't set designMode until the RTA actually gets focused. This is
+ // necessary because editing won't work on Mozilla if the iframe is
+ // *hidden, but attached*. Waiting for focus gets around this issue.
+ //
+ // Note: This onfocus will not conflict with the addEventListener('focus',
+ // ...) // in RichTextAreaImplStandard.
+ iframe.contentWindow.onfocus = function() {
+ iframe.contentWindow.onfocus = null;
+ iframe.contentWindow.document.designMode = 'On';
+ };
+ };
+ }-*/;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplOpera.java 2009-03-15 18:00:13 UTC (rev 1077)
@@ -25,24 +25,24 @@
@Override
public native void initElement() /*-{
- // Most browsers don't like setting designMode until slightly _after_
- // the iframe becomes attached to the DOM. Any non-zero timeout will do
- // just fine.
- var _this = this;
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
- setTimeout(function() {
- // Turn on design mode.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On';
- // patch css inject:
- var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
- var doc = elem.contentWindow.document;
- var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
- doc.write( ct );
- // -- patch
+ // Most browsers don't like setting designMode until slightly _after_
+ // the iframe becomes attached to the DOM. Any non-zero timeout will do
+ // just fine.
+ var _this = this;
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
+ setTimeout(function() {
+ // Turn on design mode.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On';
+ // patch css inject:
+ var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
+ var doc = elem.contentWindow.document;
+ var ct = "<html><head><style>@import url('" + $wnd.location.protocol + "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
+ doc.write( ct );
+ // -- patch
- // Send notification that the iframe has reached design mode.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
- }, 1);
- }-*/;
+ // Send notification that the iframe has reached design mode.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
+ }, 1);
+ }-*/;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java 2009-03-15 17:29:41 UTC (rev 1076)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/WrappedRichTextAreaImplSafari.java 2009-03-15 18:00:13 UTC (rev 1077)
@@ -25,25 +25,25 @@
@Override
public native void initElement() /*-{
- // Most browsers don't like setting designMode until slightly _after_
- // the iframe becomes attached to the DOM. Any non-zero timeout will do
- // just fine.
- var _this = this;
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
- setTimeout(function() {
- // Turn on design mode.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On';
+ // Most browsers don't like setting designMode until slightly _after_
+ // the iframe becomes attached to the DOM. Any non-zero timeout will do
+ // just fine.
+ var _this = this;
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::initializing = true;
+ setTimeout(function() {
+ // Turn on design mode.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem.contentWindow.document.designMode = 'On';
- // patch css inject:
- var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
- var doc = elem.contentWindow.document;
- var ct = "<html><head><style>@import url('" +$wnd.location.protocol + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
- doc.write( ct );
- // -- patch
+ // patch css inject:
+ var elem = _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImpl::elem;
+ var doc = elem.contentWindow.document;
+ var ct = "<html><head><style>@import url('" +$wnd.location.protocol+ "//" + $wnd.location.host + $wnd.location.pathname + "css/richtext.css" + "');</style></head><body CONTENTEDITABLE='true'></body></html>" ;
+ doc.write( ct );
+ // -- patch
- // Send notification that the iframe has reached design mode.
- _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
- }, 1);
- }-*/;
+ // Send notification that the iframe has reached design mode.
+ _this.@org.ourproject.kune.platf.client.ui.rte.impl.RichTextAreaImplStandard::onElementInitialized()();
+ }, 1);
+ }-*/;
}
1
0
Author: vjrj
Date: 2009-03-15 18:29:41 +0100 (Sun, 15 Mar 2009)
New Revision: 1076
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java
trunk/src/main/java/org/ourproject/kune/workspace/client/events/
trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/insertlink/
Modified:
trunk/TODO
trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.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/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/RTESavingEditor.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/ContentEditor.java
trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
Log:
Complete - task Global shortcuts and solved not propagation of shortcuts to browser
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/TODO 2009-03-15 17:29:41 UTC (rev 1076)
@@ -88,7 +88,17 @@
other links:
http://groups.google.com/group/rocket-gwt/browse_frm/thread/e56540d4168479c…
http://code.google.com/p/gwt-html-editor/source/browse/branches/gwt1.4/src/…
-**** Quite urgent: Shortcuts propagation in Firefox
+**** Insert/Edit link
+***** use cases
+ ^<a href="http://example.com">sample</a>^ --- Parse and edit
+ <a href="http://example.com">s^ample</a> --- Parse and edit
+ <a href="http://example.com">s^amp^le</a> --- Parse and edit
+ ^some text <a href="http://example.com">samp^le</a> --- new link with get inner content?
+**** Quite urgent: Shortcuts propagation to browser
+ http://google-web-toolkit.googlecode.com/svn/javadoc/1.5/com/google/gwt/use…
+ http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
+ http://openkm.cvs.sourceforge.net/viewvc/openkm/openkm/src/es/git/openkm/fr…
+ http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/
**** with different menus (File/Blog ...)
**** bidi support
**** Insert special chars (for table or from unicode).
Modified: trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml 2009-03-15 17:29:41 UTC (rev 1076)
@@ -4,7 +4,9 @@
<inherits name="com.google.gwt.http.HTTP"/>
<inherits name="com.google.gwt.junit.JUnit"/>
+<!--
<stylesheet src="Wysiwyg.css"/>
+ -->
<define-property name="old.user.agent" values="yes,no"/>
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionDescriptor.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -28,7 +28,7 @@
/**
* The Class ActionDescriptor.
*/
-public abstract class ActionDescriptor<T> {
+public class ActionDescriptor<T> {
public static final int NO_POSITION = -1;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -18,11 +18,11 @@
private final char key;
private final String keyName;
- public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key) {
- this(alt, ctrl, shift, key, NO_KEYNAME);
+ public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key) {
+ this(ctrl, alt, shift, key, NO_KEYNAME);
}
- public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key, String keyName) {
+ public ActionShortcut(boolean ctrl, boolean alt, boolean shift, char key, String keyName) {
this.alt = alt;
this.ctrl = ctrl;
this.shift = shift;
@@ -31,28 +31,28 @@
}
public ActionShortcut(boolean ctrl, boolean shift, char key) {
- this(false, ctrl, shift, key, NO_KEYNAME);
+ this(ctrl, false, shift, key, NO_KEYNAME);
}
public ActionShortcut(boolean ctrl, boolean shift, char key, String keyName) {
- this(false, ctrl, shift, key, keyName);
+ this(ctrl, false, shift, key, keyName);
}
public ActionShortcut(boolean ctrl, char key) {
- this(false, ctrl, false, key, NO_KEYNAME);
+ this(ctrl, false, false, key, NO_KEYNAME);
}
public ActionShortcut(boolean ctrl, char key, String keyName) {
- this(false, ctrl, false, key, keyName);
+ this(ctrl, false, false, key, keyName);
}
public ActionShortcut(char key, int modifiers) {
- this(has(modifiers, KeyboardListener.MODIFIER_ALT), has(modifiers, KeyboardListener.MODIFIER_CTRL), has(
+ this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
modifiers, KeyboardListener.MODIFIER_SHIFT), key, NO_KEYNAME);
}
public ActionShortcut(char key, int modifiers, String keyName) {
- this(has(modifiers, KeyboardListener.MODIFIER_ALT), has(modifiers, KeyboardListener.MODIFIER_CTRL), has(
+ this(has(modifiers, KeyboardListener.MODIFIER_CTRL), has(modifiers, KeyboardListener.MODIFIER_ALT), has(
modifiers, KeyboardListener.MODIFIER_SHIFT), key, keyName);
}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcutRegister.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -0,0 +1,60 @@
+package org.ourproject.kune.platf.client.actions;
+
+import java.util.HashMap;
+
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.ui.KeyboardListenerCollection;
+
+public class ActionShortcutRegister {
+
+ @SuppressWarnings("unchecked")
+ private final HashMap<ActionShortcut, ActionItem> shortcuts;
+
+ @SuppressWarnings("unchecked")
+ public ActionShortcutRegister() {
+ shortcuts = new HashMap<ActionShortcut, ActionItem>();
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionItem get(ActionShortcut shortcut) {
+ return shortcuts.get(shortcut);
+ }
+
+ @SuppressWarnings("unchecked")
+ public ActionItem get(Event event) {
+ int modifiers = KeyboardListenerCollection.getKeyboardModifiers(event);
+ if (event.getTypeInt() == Event.ONKEYDOWN && modifiers != 0) {
+ ActionShortcut shortcut = new ActionShortcut((char) event.getKeyCode(), modifiers);
+ Log.debug("Shortcut pressed" + shortcut.toString());
+ return shortcuts.get(shortcut);
+ }
+ // if (modifiers != 0) {
+ // Log.debug("Not action associated with this shortcut");
+ // }
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void put(ActionShortcut shortcut, ActionItem actionItem) {
+ if (shortcuts.get(shortcut) != null) {
+ Log.warn("Shortcut" + shortcut + " already registered");
+ }
+ shortcuts.put(shortcut, actionItem);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void put(ActionShortcut shortcut, final Listener0 listener) {
+ ActionDescriptor descriptor = new ActionDescriptor(AccessRolDTO.Viewer, new Listener0() {
+ public void onEvent() {
+ listener.onEvent();
+ }
+ });
+ ActionItem item = new ActionItem(descriptor, null);
+ put(shortcut, item);
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -25,7 +25,7 @@
vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getTopBar().getView()).getToolbar());
vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar());
final RTEditorPanel editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
- vp.add(editorPanel.getRTE());
+ vp.add(editorPanel);
basicEditor.setExtended(true);
vp.setWidth("100%");
dialog.add(vp);
@@ -34,7 +34,7 @@
public void onResize(Window source, int width, int height) {
int newHeight = height - 26 * 2 - 40;
editorPanel.adjustSize(newHeight);
- vp.setCellHeight(editorPanel.getRTE(), "" + newHeight);
+ vp.setCellHeight(editorPanel, "" + newHeight);
}
});
}
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -26,6 +26,8 @@
ActionAddCondition<Object> canBeExtended();
+ void detach();
+
View getEditorArea();
String getHtml();
@@ -36,8 +38,6 @@
ActionToolbar<Object> getTopBar();
- void reset();
-
void setExtended(boolean extended);
void setHtml(String html);
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -1,111 +1,68 @@
package org.ourproject.kune.platf.client.ui.rte.basic;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_DOWN;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_END;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_ESCAPE;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_HOME;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_LEFT;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_PAGEDOWN;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_PAGEUP;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_RIGHT;
+import static com.google.gwt.user.client.ui.KeyboardListener.KEY_UP;
+
import java.util.Date;
-import java.util.HashMap;
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.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionShortcutRegister;
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
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 com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FocusListener;
-import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Widget;
import com.xpn.xwiki.wysiwyg.client.dom.Document;
import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment;
import com.xpn.xwiki.wysiwyg.client.dom.Range;
import com.xpn.xwiki.wysiwyg.client.dom.Selection;
-public class RTEditorPanel implements RTEditorView {
+public class RTEditorPanel extends RichTextArea implements RTEditorView {
- private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener {
+ private class EventListener implements FocusListener {
- public void onChange(Widget sender) {
- presenter.fireOnEdit();
- }
-
- public void onClick(Widget sender) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status. This will catch any cases where the user
- // moves the cursor using the keyboard, or uses one of the
- // browser's built-in keyboard shortcuts.
- updateStatus();
- }
- }
-
public void onFocus(Widget sender) {
presenter.onEditorFocus();
}
- public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursor
- // using the keyboard, or uses one of the browser's built-in
- // keyboard shortcuts.
-
- updateStatus();
- fireEdit();
- if (modifiers != 0) {
- Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")");
- ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
- if (actionItem != null) {
- actionManager.doAction(actionItem);
- updateStatus();
- } else {
- Log.debug("...but not mapped to any action");
- }
- }
- }
- }
-
public void onLostFocus(Widget sender) {
-
}
}
private final I18nUITranslationService i18n;
- private final RichTextArea rta;
private final BasicFormatter basic;
private final ExtendedFormatter extended;
- private final HashMap<ActionShortcut, ActionItem<Object>> shortcuts;
- private final ActionManager actionManager;
private final RTEditorPresenter presenter;
+ private final ActionManager actionManager;
+ private final ActionShortcutRegister shortcutRegister;
- public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n, ActionManager actionManager) {
+ public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n,
+ final ActionManager actionManager) {
this.presenter = presenter;
this.i18n = i18n;
this.actionManager = actionManager;
- rta = new RichTextArea();
- basic = rta.getBasicFormatter();
- extended = rta.getExtendedFormatter();
- shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>();
+ basic = getBasicFormatter();
+ extended = getExtendedFormatter();
+ shortcutRegister = new ActionShortcutRegister();
EventListener listener = new EventListener();
- rta.addClickListener(listener);
- rta.addKeyboardListener(listener);
- rta.addFocusListener(listener);
- rta.setWidth("96%");
- rta.setHeight("100%");
+ addFocusListener(listener);
+ setWidth("97%");
+ setHeight("100%");
+
}
public void addActions(ActionItemCollection<Object> actionItems) {
@@ -113,13 +70,13 @@
ActionDescriptor<Object> action = actionItem.getAction();
if (action.hasShortcut() && action.mustBeAdded(null)) {
ActionShortcut shortcut = action.getShortcut();
- shortcuts.put(shortcut, actionItem);
+ shortcutRegister.put(shortcut, actionItem);
}
}
}
public void adjustSize(int height) {
- rta.setHeight("" + height);
+ setHeight("" + height);
}
public boolean canBeBasic() {
@@ -147,7 +104,7 @@
}
public void focus() {
- rta.setFocus(true);
+ setFocus(true);
}
/**
@@ -165,25 +122,13 @@
* copied from xwiki
*/
public Document getDocument() {
- if (rta.getElement().getTagName().equalsIgnoreCase("iframe")) {
- return IFrameElement.as(rta.getElement()).getContentDocument().cast();
+ if (getElement().getTagName().equalsIgnoreCase("iframe")) {
+ return IFrameElement.as(getElement()).getContentDocument().cast();
} else {
return null;
}
}
- public String getHtml() {
- return rta.getHTML();
- }
-
- public Widget getRTE() {
- return rta;
- }
-
- public String getText() {
- return rta.getText();
- }
-
public void insertComment(String author) {
String comment = null;
createCommentAndSelectIt(author, comment);
@@ -227,10 +172,6 @@
return !getDocument().getSelection().isCollapsed();
}
- public boolean isAttached() {
- return rta.isAttached();
- }
-
public boolean isBold() {
return basic.isBold();
}
@@ -271,6 +212,38 @@
extended.leftIndent();
}
+ @SuppressWarnings("unchecked")
+ @Override
+ public void onBrowserEvent(Event event) {
+ switch (DOM.eventGetType(event)) {
+ case Event.ONCLICK:
+ updateStatus();
+ super.onBrowserEvent(event);
+ break;
+ case Event.ONKEYDOWN:
+ ActionItem actionItem = shortcutRegister.get(event);
+ if (actionItem != null) {
+ updateStatus();
+ fireEdit();
+ event.cancelBubble(true);
+ event.preventDefault();
+ actionManager.doAction(actionItem);
+ updateStatus();
+ } else {
+ super.onBrowserEvent(event);
+ updateStatus();
+ if (isAnEditionKey(event.getKeyCode())) {
+ fireEdit();
+ }
+ }
+ break;
+ default:
+ // Rest of events
+ super.onBrowserEvent(event);
+ updateStatus();
+ }
+ }
+
public void paste() {
extended.paste();
}
@@ -307,14 +280,6 @@
basic.setForeColor(color);
}
- public void setHtml(String html) {
- rta.setHTML(html);
- }
-
- public void setText(String text) {
- rta.setText(text);
- }
-
public void toggleBold() {
basic.toggleBold();
}
@@ -375,10 +340,19 @@
}
private Selection getSelection() {
- Selection selection = getDocument().getSelection();
- return selection;
+ return getDocument().getSelection();
}
+ private boolean isAnEditionKey(int keyCode) {
+ if (keyCode != KEY_HOME && keyCode != KEY_END && keyCode != KEY_UP && keyCode != KEY_DOWN
+ && keyCode != KEY_LEFT && keyCode != KEY_RIGHT && keyCode != KEY_PAGEDOWN && keyCode != KEY_PAGEUP
+ && keyCode != KEY_ESCAPE) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
/**
* Updates the status of all the stateful buttons.
*/
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -31,7 +31,6 @@
import com.calclab.suco.client.events.Listener2;
import com.calclab.suco.client.ioc.Provider;
import com.google.gwt.libideas.resources.client.ImageResource;
-import com.xpn.xwiki.wysiwyg.client.dom.Selection;
public class RTEditorPresenter implements RTEditor {
@@ -132,6 +131,11 @@
return canBeExtended();
}
+ public void detach() {
+ topBar.clear();
+ sndBar.clear();
+ }
+
public void fireOnEdit() {
onEdit.fire();
}
@@ -141,7 +145,7 @@
}
public String getHtml() {
- return view.getHtml();
+ return view.getHTML();
}
public ActionToolbar<Object> getSndBar() {
@@ -167,17 +171,12 @@
palette.hide();
}
- public void reset() {
- topBar.clear();
- sndBar.clear();
- }
-
public void setExtended(boolean extended) {
this.extended = extended;
}
public void setHtml(String html) {
- view.setHtml(html);
+ view.setHTML(html);
view.focus();
}
@@ -404,12 +403,12 @@
EditHtmlDialog dialog = editHtmlDialog.get();
dialog.setUpdateListener(new Listener<String>() {
public void onEvent(String html) {
- view.setHtml(html);
+ view.setHTML(html);
fireOnEdit();
}
});
dialog.show();
- dialog.setHtml(view.getHtml());
+ dialog.setHtml(view.getHTML());
}
});
editHtml.setIconCls(getCssName(imgResources.edithtml()));
@@ -661,12 +660,17 @@
public void onEvent() {
deferred.addCommand(new Listener0() {
public void onEvent() {
- Selection selection = view.getDocument().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);
+ // Selection selection =
+ // view.getDocument().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);
}
});
}
@@ -674,7 +678,7 @@
devInfo.setTextDescription(i18n.t("Developers info"));
devInfo.setAddCondition(canBeExtended);
devInfo.setParentMenuTitle(i18n.t(FORMAT_MENU));
- devInfo.setShortcut(new ActionShortcut(true, false, false, 'I'));
+ devInfo.setShortcut(new ActionShortcut(false, true, false, 'I'));
actions.add(withNoItem(bold));
actions.add(withNoItem(italic));
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -4,8 +4,6 @@
import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
-import com.xpn.xwiki.wysiwyg.client.dom.Document;
-
public interface RTEditorView extends View {
void addActions(ActionItemCollection<Object> actions);
@@ -26,10 +24,8 @@
void focus();
- Document getDocument();
+ String getHTML();
- String getHtml();
-
String getText();
void insertComment(String author);
@@ -90,7 +86,7 @@
void setForeColor(String color);
- void setHtml(String html);
+ void setHTML(String html);
void setText(String text);
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfo.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -0,0 +1,63 @@
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import com.google.gwt.dom.client.Element;
+
+public class LinkInfo {
+
+ private static final String HREF = "href";
+ // private static final String TITLE = "title";
+ private static final String TARGET = "target";
+ private static final String _BLANK = "_blank";
+
+ public static LinkInfo parse(Element element) {
+ String target = element.getAttribute(TARGET);
+ return new LinkInfo(element.getInnerText(), element.getTitle(), element.getAttribute(HREF), target != null
+ && target.equals(_BLANK));
+ }
+
+ private String text;
+ private String title;
+ private String url;
+
+ private boolean inNewWindow;
+
+ public LinkInfo(String text, String title, String url, boolean inNewWindow) {
+ this.text = text;
+ this.title = title;
+ this.url = url;
+ this.inNewWindow = inNewWindow;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public boolean isInNewWindow() {
+ return inNewWindow;
+ }
+
+ public void setInNewWindow(boolean inNewWindow) {
+ this.inNewWindow = inNewWindow;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/LinkInfoTest.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -0,0 +1,28 @@
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.user.client.ui.Hyperlink;
+
+public class LinkInfoTest extends GWTTestCase {
+
+ private static final String TEXT = "some link";
+ private static final String HREF = "http://example.com";
+ private static final String TITLE = "on over";
+
+ @Override
+ public String getModuleName() {
+ return "org.ourproject.kune.app.Kune";
+ }
+
+ public void testSimpleLink() {
+ Hyperlink link = new Hyperlink(TEXT, HREF);
+ link.setTitle(TITLE);
+ Log.info(link.getHTML());
+ LinkInfo linkParsed = LinkInfo.parse(link.getElement());
+ assertEquals(TEXT, linkParsed.getText());
+ assertEquals(HREF, linkParsed.getUrl());
+ assertEquals(TITLE, linkParsed.getTitle());
+ assertEquals(false, linkParsed.isInNewWindow());
+ }
+}
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -30,6 +30,8 @@
*/
BeforeActionListener getBeforeSavingListener();
+ boolean isSavePending();
+
/**
* Call this when your save action is successful
*/
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -90,6 +90,10 @@
this.view = view;
}
+ public boolean isSavePending() {
+ return savePending;
+ }
+
public void onDoSaveAndClose() {
saveAndCloseConfirmed = true;
onDoSave();
@@ -138,7 +142,7 @@
stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
stateManager.resumeTokenChange();
reset();
- editor.reset();
+ editor.detach();
onDoEditCancelled();
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -82,6 +82,7 @@
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspace;
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePanel;
import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePresenter;
+import org.ourproject.kune.workspace.client.events.GlobalShortcutRegister;
import org.ourproject.kune.workspace.client.i18n.I18nTranslator;
import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPanel;
import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPresenter;
@@ -948,5 +949,13 @@
}
});
+ register(ApplicationComponentGroup.class, new Factory<GlobalShortcutRegister>(GlobalShortcutRegister.class) {
+ @Override
+ public GlobalShortcutRegister create() {
+ return new GlobalShortcutRegister($(ActionManager.class));
+ }
+ });
+
+ $(GlobalShortcutRegister.class).enable();
}
}
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-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -17,6 +17,8 @@
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.WindowCloseListener;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.gwtext.client.widgets.BoxComponent;
@@ -31,19 +33,31 @@
private final AbstractToolbar topbar;
private final SiteSignOutLink siteSignOutLink;
- public ContentEditor(RTEditor editor, boolean autoSave, I18nTranslationService i18n, StateManager stateManager,
- SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper,
+ public ContentEditor(RTEditor editor, boolean autoSave, final I18nTranslationService i18n,
+ StateManager stateManager, SiteSignOutLink siteSignOutLink, DeferredCommandWrapper deferredCommandWrapper,
RTEImgResources imgResources, WorkspaceSkeleton ws, TimerWrapper timer, RTESavingEditorView view) {
super(editor, autoSave, i18n, stateManager, deferredCommandWrapper, imgResources, timer);
this.siteSignOutLink = siteSignOutLink;
super.init(view);
this.ws = ws;
+ Window.addWindowCloseListener(new WindowCloseListener() {
+ public void onWindowClosed() {
+ }
+ public String onWindowClosing() {
+ if (isSavePending()) {
+ return i18n.t("You have changes without save. Are you sure?");
+ }
+ // onDoSaveAndClose();
+ return null;
+ }
+
+ });
vp = new VerticalPanel();
basicEditor = super.getBasicEditor();
vp.add((Widget) ((ActionToolbarPanel<Object>) basicEditor.getSndBar().getView()).getToolbar());
editorPanel = (RTEditorPanel) basicEditor.getEditorArea();
- vp.add(editorPanel.getRTE());
+ vp.add(editorPanel);
basicEditor.setExtended(true);
vp.setWidth("100%");
ws.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() {
@@ -81,6 +95,6 @@
// Log.debug("Sndbar height: " + barHeight + " new height: " +
// newHeight);
editorPanel.adjustSize(newHeight);
- vp.setCellHeight(editorPanel.getRTE(), "" + newHeight);
+ vp.setCellHeight(editorPanel, "" + newHeight);
}
}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/events/GlobalShortcutRegister.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -0,0 +1,38 @@
+package org.ourproject.kune.workspace.client.events;
+
+import org.ourproject.kune.platf.client.actions.ActionItem;
+import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.actions.ActionShortcutRegister;
+
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.Event;
+import com.google.gwt.user.client.EventPreview;
+
+public class GlobalShortcutRegister extends ActionShortcutRegister {
+
+ private final EventPreview eventPreview;
+
+ public GlobalShortcutRegister(final ActionManager actionManager) {
+ eventPreview = new EventPreview() {
+ @SuppressWarnings("unchecked")
+ public boolean onEventPreview(Event event) {
+ ActionItem actionItem = get(event);
+ if (actionItem != null) {
+ // Log.debug("Not propagating event");
+ DOM.eventPreventDefault(event);
+ actionManager.doAction(actionItem);
+ return false;
+ }
+ return true;
+ }
+ };
+ }
+
+ public void disable() {
+ DOM.removeEventPreview(eventPreview);
+ }
+
+ public void enable() {
+ DOM.addEventPreview(eventPreview);
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/hello/HelloWorldModule.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -20,6 +20,7 @@
package org.ourproject.kune.workspace.client.hello;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.dto.UserSimpleDTO;
@@ -27,11 +28,13 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationServiceMocked;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
import org.ourproject.kune.workspace.client.AbstractFoldableContentActions;
+import org.ourproject.kune.workspace.client.events.GlobalShortcutRegister;
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.AbstractModule;
@@ -202,6 +205,15 @@
}
});
+ /**
+ * Global shortcut sample definition
+ */
+ $(GlobalShortcutRegister.class).put(new ActionShortcut(false, true, false, 'S'), new Listener0() {
+ public void onEvent() {
+ NotifyUser.info("Global Ctrl+S pressed");
+ }
+ });
+
// And because nobody use this module, we get the class (to force the
// creation of the
// Helloworld instance):
Modified: trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-13 21:36:47 UTC (rev 1075)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/actions/ActionShortcutTest.java 2009-03-15 17:29:41 UTC (rev 1076)
@@ -12,7 +12,7 @@
@Test
public void altS() {
- ActionShortcut shortcut = new ActionShortcut(true, false, false, 'S', null);
+ ActionShortcut shortcut = new ActionShortcut(false, true, false, 'S', null);
assertEquals(" (Alt+S)", shortcut.toString());
assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_ALT));
assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_CTRL));
@@ -52,7 +52,7 @@
@Test
public void ctrlShiftS() {
- ActionShortcut shortcut = new ActionShortcut(false, true, true, 'S', null);
+ ActionShortcut shortcut = new ActionShortcut(true, false, true, 'S', null);
assertEquals(" (Ctrl+Shift+S)", shortcut.toString());
assertTrue(!shortcut.is('S', KeyboardListener.MODIFIER_ALT));
assertTrue(shortcut.is('S', KeyboardListener.MODIFIER_SHIFT | KeyboardListener.MODIFIER_CTRL));
1
0
13 Mar '09
Author: vjrj
Date: 2009-03-13 22:36:47 +0100 (Fri, 13 Mar 2009)
New Revision: 1075
Modified:
trunk/TODO
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
Log:
Complete - task Comments with user selection
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2009-03-12 23:46:56 UTC (rev 1074)
+++ trunk/TODO 2009-03-13 21:36:47 UTC (rev 1075)
@@ -79,6 +79,16 @@
http://www.w3.org/DesignIssues/Fragment.html
** vjrj <v> better RTE
*** Pending
+**** W3C Range/Selection support in RTE
+ https://developer.mozilla.org/en/DOM/selection
+ http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
+ As an intro:
+ http://www.quirksmode.org/dom/range_intro.html
+ http://maven.xwiki.org/site/xwiki-web/xwiki-web-wysiwyg/apidocs/com/xpn/xwi…
+ other links:
+ http://groups.google.com/group/rocket-gwt/browse_frm/thread/e56540d4168479c…
+ http://code.google.com/p/gwt-html-editor/source/browse/branches/gwt1.4/src/…
+**** Quite urgent: Shortcuts propagation in Firefox
**** with different menus (File/Blog ...)
**** bidi support
**** Insert special chars (for table or from unicode).
@@ -89,13 +99,6 @@
**** Insert > Special char
**** Insert > Page break (for printing)
**** Shortcut to fonts (Ctrl + numbers)
-**** W3C Range support in RTE (selection)
- As an intro:
- http://www.quirksmode.org/dom/range_intro.html
- http://maven.xwiki.org/site/xwiki-web/xwiki-web-wysiwyg/apidocs/com/xpn/xwi…
- other links:
- http://groups.google.com/group/rocket-gwt/browse_frm/thread/e56540d4168479c…
- http://code.google.com/p/gwt-html-editor/source/browse/branches/gwt1.4/src/…
*** Links
http://www.ongwt.com/post/2009/01/08/XWiki-:-Wysiwyg-editor-based-on-GWT
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/in…
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-03-12 23:46:56 UTC (rev 1074)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-13 21:36:47 UTC (rev 1075)
@@ -25,6 +25,9 @@
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Widget;
import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
public class RTEditorPanel implements RTEditorView {
@@ -115,14 +118,6 @@
}
}
- public void addComment(String userName) {
- String time = i18n.formatDateWithLocale(new Date(), true);
- Element span = DOM.createSpan();
- span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
- DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
- insertHtml(" " + span.getString() + " ");
- }
-
public void adjustSize(int height) {
rta.setHeight("" + height);
}
@@ -189,6 +184,25 @@
return rta.getText();
}
+ public void insertComment(String author) {
+ String comment = null;
+ createCommentAndSelectIt(author, comment);
+ }
+
+ public void insertCommentNotUsingSelection(String author) {
+ getFstRange().collapse(false);
+ createCommentAndSelectIt(author, null);
+ focus();
+ }
+
+ public void insertCommentUsingSelection(String author) {
+ DocumentFragment extracted = getFstRange().cloneContents();
+ extended.delete();
+ String comment = extracted.getInnerText();
+ createCommentAndSelectIt(author, comment);
+ focus();
+ }
+
public void insertHorizontalRule() {
extended.insertHorizontalRule();
}
@@ -209,6 +223,10 @@
extended.insertUnorderedList();
}
+ public boolean isAnythingSelected() {
+ return !getDocument().getSelection().isCollapsed();
+ }
+
public boolean isAttached() {
return rta.isAttached();
}
@@ -333,6 +351,34 @@
presenter.fireOnEdit();
}
+ private void createCommentAndSelectIt(String author, String comment) {
+ Element commentEl = createCommentElement(author, comment);
+ Range innerCommentRange = getDocument().createRange();
+ getFstRange().insertNode(commentEl);
+ innerCommentRange.selectNodeContents(commentEl.getFirstChild());
+ getSelection().addRange(innerCommentRange);
+ fireEdit();
+ }
+
+ private Element createCommentElement(String userName, String insertComment) {
+ String time = i18n.formatDateWithLocale(new Date(), true);
+ Element span = getDocument().createSpanElement();
+ 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() {
+ Selection selection = getDocument().getSelection();
+ return selection;
+ }
+
/**
* Updates the status of all the stateful buttons.
*/
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-03-12 23:46:56 UTC (rev 1074)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-13 21:36:47 UTC (rev 1075)
@@ -420,11 +420,33 @@
ActionToolbarMenuDescriptor<Object> comment = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
new Listener0() {
public void onEvent() {
- view.focus();
- String author = session.isLogged() ? session.getCurrentUser().getShortName()
- : i18n.t("anonymous user");
- view.addComment(author);
- fireOnEdit();
+ 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>() {
@@ -637,11 +659,16 @@
final ActionToolbarMenuDescriptor<Object> devInfo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
new Listener0() {
public void onEvent() {
- Selection selection = view.getDocument().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);
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ Selection selection = view.getDocument().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);
+ }
+ });
}
});
devInfo.setTextDescription(i18n.t("Developers info"));
@@ -682,7 +709,7 @@
actions.add(withNoItem(comment));
actions.add(withNoItem(undoBtn));
actions.add(withNoItem(redoBtn));
- actions.add(withNoItem(devInfo));
+ // actions.add(withNoItem(devInfo));
for (String fontName : this.fontNames) {
ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
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-03-12 23:46:56 UTC (rev 1074)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-13 21:36:47 UTC (rev 1075)
@@ -10,8 +10,6 @@
void addActions(ActionItemCollection<Object> actions);
- void addComment(String userName);
-
void adjustSize(int height);
boolean canBeBasic();
@@ -34,6 +32,12 @@
String getText();
+ void insertComment(String author);
+
+ void insertCommentNotUsingSelection(String author);
+
+ void insertCommentUsingSelection(String author);
+
void insertHorizontalRule();
void insertHtml(String html);
@@ -44,6 +48,8 @@
void insertUnorderedList();
+ boolean isAnythingSelected();
+
boolean isAttached();
boolean isBold();
1
0
Author: vjrj
Date: 2009-03-13 00:46:56 +0100 (Fri, 13 Mar 2009)
New Revision: 1074
Added:
trunk/src/main/java/com/
trunk/src/main/java/com/xpn/
trunk/src/main/java/com/xpn/xwiki/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/AddDelta.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ChangeDelta.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Chunk.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DeleteDelta.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Delta.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Diff.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffAlgorithm.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffException.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DifferentiationFailedException.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/PatchFailedException.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Revision.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/RevisionVisitor.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/SimpleDiff.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ToString.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/DiffNode.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/MyersDiff.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/PathNode.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/Snake.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DOMUtils.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DepthFirstPreOrderIterator.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Document.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DocumentFragment.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Element.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Event.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/InnerHTMLListener.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/JavaScriptObject.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Range.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeCompare.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeFactory.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Selection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/SelectionManager.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Style.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableCellElement.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableRowElement.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Text.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TextFragment.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/AbstractSelection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultNativeRangeWrapper.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRange.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRangeFactory.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelectionManager.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/NativeRangeWrapper.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/ControlRange.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IEDOMUtils.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelectionManager.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeRange.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeSelection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/TextRange.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaDOMUtils.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelection.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelectionManager.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeRange.java
trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeSelection.java
Modified:
trunk/COPYRIGHT
trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml
trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.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
Log:
Incomplete - task Better RTE (Rich Text Editor) support. Region library added thanks to xwiki (see Alt-I action for info in RTE).
Modified: trunk/COPYRIGHT
===================================================================
--- trunk/COPYRIGHT 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/COPYRIGHT 2009-03-12 23:46:56 UTC (rev 1074)
@@ -81,13 +81,13 @@
others
--------------------------------------------------------------------------------
suco
- http://suco.googlecode.com
- Copyright: under GNU Lesser General Public License
+ http://suco.googlecode.com
+ Copyright: under GNU Lesser General Public License
http://www.gnu.org/licenses/lgpl.html
emite
- http://emite.googlecode.com
- Copyright: under GNU Lesser General Public License
+ http://emite.googlecode.com
+ Copyright: under GNU Lesser General Public License
http://www.gnu.org/licenses/lgpl.html
fonts-min.css and reset.css
@@ -109,6 +109,12 @@
Copyright: under GNU Lesser General Public License
http://www.gnu.org/licenses/lgpl.html
+dom region and diff libraries:
+ XWiki Platform
+ http://www.xwiki.org/
+ Copyright: under GNU Lesser General Public License
+ http://www.gnu.org/licenses/lgpl.html
+
some license description:
from Wikipedia
Copyright: under GFDL http://www.gnu.org/copyleft/fdl.html
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/Wysiwyg.gwt.xml 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,56 @@
+<module>
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name="com.google.gwt.i18n.I18N"/>
+ <inherits name="com.google.gwt.http.HTTP"/>
+ <inherits name="com.google.gwt.junit.JUnit"/>
+
+ <stylesheet src="Wysiwyg.css"/>
+
+ <define-property name="old.user.agent" values="yes,no"/>
+
+ <property-provider name="old.user.agent"><![CDATA[
+ var ua = navigator.userAgent.toLowerCase();
+ var makeVersion = function(result) {
+ return (parseInt(result[1]) * 1000) + parseInt(result[2]);
+ };
+ if (ua.indexOf("gecko") != -1) {
+ var result = /rv:([0-9]+)\.([0-9]+)/.exec(ua);
+ if (result && result.length == 3) {
+ if (makeVersion(result) >= 1009) {
+ return "no";
+ }
+ }
+ }
+ return "yes";
+ ]]></property-provider>
+
+ <!-- SelectionManager -->
+ <replace-with class="com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelectionManager">
+ <when-type-is class="com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelectionManager"/>
+ </replace-with>
+
+ <replace-with class="com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla.MozillaSelectionManager">
+ <when-type-is class="com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelectionManager"/>
+ <when-property-is name="old.user.agent" value="yes"/>
+ <any>
+ <when-property-is name="user.agent" value="gecko1_8"/>
+ <when-property-is name="user.agent" value="gecko"/>
+ </any>
+ </replace-with>
+
+ <replace-with class="com.xpn.xwiki.wysiwyg.client.dom.internal.ie.IESelectionManager">
+ <when-type-is class="com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelectionManager"/>
+ <when-property-is name="user.agent" value="ie6"/>
+ </replace-with>
+
+ <!-- DOMUtils -->
+ <replace-with class="com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla.MozillaDOMUtils">
+ <when-type-is class="com.xpn.xwiki.wysiwyg.client.dom.DOMUtils"/>
+ </replace-with>
+
+ <replace-with class="com.xpn.xwiki.wysiwyg.client.dom.internal.ie.IEDOMUtils">
+ <when-type-is class="com.xpn.xwiki.wysiwyg.client.dom.DOMUtils"/>
+ <when-property-is name="user.agent" value="ie6"/>
+ </replace-with>
+
+</module>
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/AddDelta.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/AddDelta.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/AddDelta.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,125 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.List;
+
+/**
+ * Holds an add-delta between to revisions of a text.
+ *
+ * @version $Id: AddDelta.java,v 1.1 2006/03/12 00:24:21 juanca Exp $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see Diff
+ * @see Chunk
+ */
+public class AddDelta extends Delta
+{
+
+ public AddDelta()
+ {
+ super();
+ }
+
+ public AddDelta(int origpos, Chunk rev)
+ {
+ init(new Chunk(origpos, 0), rev);
+ }
+
+ public void verify(List target) throws PatchFailedException
+ {
+ if (original.first() > target.size())
+ {
+ throw new PatchFailedException("original.first() > target.size()");
+ }
+ }
+
+ public void applyTo(List target)
+ {
+ revised.applyAdd(original.first(), target);
+ }
+
+ public void toString(StringBuffer s)
+ {
+ s.append(original.anchor());
+ s.append("a");
+ s.append(revised.rangeString());
+ s.append(Diff.NL);
+ revised.toString(s, "> ", Diff.NL);
+ }
+
+ public void toRCSString(StringBuffer s, String EOL)
+ {
+ s.append("a");
+ s.append(original.anchor());
+ s.append(" ");
+ s.append(revised.size());
+ s.append(EOL);
+ revised.toString(s, "", EOL);
+ }
+
+ public void Accept(RevisionVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+
+ public void accept(RevisionVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ChangeDelta.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ChangeDelta.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ChangeDelta.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,133 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.List;
+
+/**
+ * Holds an change-delta between to revisions of a text.
+ *
+ * @version $Id: ChangeDelta.java,v 1.1 2006/03/12 00:24:21 juanca Exp $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see Diff
+ * @see Chunk
+ */
+public class ChangeDelta extends Delta
+{
+
+ public ChangeDelta()
+ {
+ super();
+ }
+
+ public ChangeDelta(Chunk orig, Chunk rev)
+ {
+ init(orig, rev);
+ }
+
+ public void verify(List target) throws PatchFailedException
+ {
+ if (!original.verify(target))
+ {
+ throw new PatchFailedException();
+ }
+ if (original.first() > target.size())
+ {
+ throw new PatchFailedException("original.first() > target.size()");
+ }
+ }
+
+ public void applyTo(List target)
+ {
+ original.applyDelete(target);
+ revised.applyAdd(original.first(), target);
+ }
+
+ public void toString(StringBuffer s)
+ {
+ original.rangeString(s);
+ s.append("c");
+ revised.rangeString(s);
+ s.append(Diff.NL);
+ original.toString(s, "< ", "\n");
+ s.append("---");
+ s.append(Diff.NL);
+ revised.toString(s, "> ", "\n");
+ }
+
+ public void toRCSString(StringBuffer s, String EOL)
+ {
+ s.append("d");
+ s.append(original.rcsfrom());
+ s.append(" ");
+ s.append(original.size());
+ s.append(EOL);
+ s.append("a");
+ s.append(original.rcsto());
+ s.append(" ");
+ s.append(revised.size());
+ s.append(EOL);
+ revised.toString(s, "", EOL);
+ }
+
+ public void accept(RevisionVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Chunk.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Chunk.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Chunk.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,417 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Holds a information about a parrt of the text involved in a differencing or
+ * patching operation.
+ *
+ * @version $Id: Chunk.java,v 1.1 2006/03/12 00:24:21 juanca Exp $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Diff
+ * @see Delta
+ */
+public class Chunk extends ToString
+{
+
+ protected int anchor;
+
+ protected int count;
+
+ protected List chunk;
+
+ public Chunk() {
+ }
+
+ /**
+ * Creates a chunk that doesn't copy the original text.
+ *
+ * @param pos
+ * the start position in the text.
+ * @param count
+ * the size of the chunk.
+ */
+ public Chunk(int pos, int count)
+ {
+ this.anchor = pos;
+ this.count = (count >= 0 ? count : 0);
+ }
+
+ /**
+ * Creates a chunk and saves a copy the original chunk's text.
+ *
+ * @param iseq
+ * the original text.
+ * @param pos
+ * the start position in the text.
+ * @param count
+ * the size of the chunk.
+ */
+ public Chunk(Object[] iseq, int pos, int count)
+ {
+ this(pos, count);
+ chunk = slice(iseq, pos, count);
+ }
+
+ /**
+ * Creates a chunk that will be displaced in the resulting text, and saves a
+ * copy the original chunk's text.
+ *
+ * @param iseq
+ * the original text.
+ * @param pos
+ * the start position in the text.
+ * @param count
+ * the size of the chunk.
+ * @param offset
+ * the position the chunk should have in the resulting text.
+ */
+ public Chunk(Object[] iseq, int pos, int count, int offset)
+ {
+ this(offset, count);
+ chunk = slice(iseq, pos, count);
+ }
+
+ /**
+ * Creates a chunk and saves a copy the original chunk's text.
+ *
+ * @param iseq
+ * the original text.
+ * @param pos
+ * the start position in the text.
+ * @param count
+ * the size of the chunk.
+ */
+ public Chunk(List iseq, int pos, int count)
+ {
+ this(pos, count);
+ chunk = slice(iseq, pos, count);
+ }
+
+ /**
+ * Creates a chunk that will be displaced in the resulting text, and saves a
+ * copy the original chunk's text.
+ *
+ * @param iseq
+ * the original text.
+ * @param pos
+ * the start position in the text.
+ * @param count
+ * the size of the chunk.
+ * @param offset
+ * the position the chunk should have in the resulting text.
+ */
+ public Chunk(List iseq, int pos, int count, int offset)
+ {
+ this(offset, count);
+ chunk = slice(iseq, pos, count);
+ }
+
+ /**
+ * Returns the anchor position of the chunk.
+ *
+ * @return the anchor position.
+ */
+ public int anchor()
+ {
+ return anchor;
+ }
+
+ public void moveAnchor(int deltaPosition) {
+ anchor += deltaPosition;
+ }
+
+ /**
+ * Returns the size of the chunk.
+ *
+ * @return the size.
+ */
+ public int size()
+ {
+ return count;
+ }
+
+ /**
+ * Returns the index of the first line of the chunk.
+ */
+ public int first()
+ {
+ return anchor();
+ }
+
+ /**
+ * Returns the index of the last line of the chunk.
+ */
+ public int last()
+ {
+ return anchor() + size() - 1;
+ }
+
+ /**
+ * Returns the <i>from</i> index of the chunk in RCS terms.
+ */
+ public int rcsfrom()
+ {
+ return anchor + 1;
+ }
+
+ /**
+ * Returns the <i>to</i> index of the chunk in RCS terms.
+ */
+ public int rcsto()
+ {
+ return anchor + count;
+ }
+
+ /**
+ * Returns the text saved for this chunk.
+ *
+ * @return the text.
+ */
+ public List chunk()
+ {
+ return chunk;
+ }
+
+ /**
+ * Verifies that this chunk's saved text matches the corresponding text in
+ * the given sequence.
+ *
+ * @param target
+ * the sequence to verify against.
+ * @return true if the texts match.
+ */
+ public boolean verify(List target)
+ {
+ if (chunk == null)
+ {
+ return true;
+ }
+ if (last() > target.size())
+ {
+ return false;
+ }
+ for (int i = 0; i < count; i++)
+ {
+ if (!target.get(anchor + i).equals(chunk.get(i)))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Delete this chunk from he given text.
+ *
+ * @param target
+ * the text to delete from.
+ */
+ public void applyDelete(List target)
+ {
+ for (int i = last(); i >= first(); i--)
+ {
+ target.remove(i);
+ }
+ }
+
+ /**
+ * Add the text of this chunk to the target at the given position.
+ *
+ * @param start
+ * where to add the text.
+ * @param target
+ * the text to add to.
+ */
+ public void applyAdd(int start, List target)
+ {
+ Iterator i = chunk.iterator();
+ while (i.hasNext())
+ {
+ target.add(start++, i.next());
+ }
+ }
+
+ /**
+ * Provide a string image of the chunk using the an empty prefix and
+ * postfix.
+ */
+ public void toString(StringBuffer s)
+ {
+ toString(s, "", "");
+ }
+
+ /**
+ * Provide a string image of the chunk using the given prefix and postfix.
+ *
+ * @param s
+ * where the string image should be appended.
+ * @param prefix
+ * the text thatshould prefix each line.
+ * @param postfix
+ * the text that should end each line.
+ */
+ public StringBuffer toString(StringBuffer s, String prefix, String postfix)
+ {
+ if (chunk != null)
+ {
+ Iterator i = chunk.iterator();
+ while (i.hasNext())
+ {
+ s.append(prefix);
+ s.append(i.next());
+ s.append(postfix);
+ }
+ }
+ return s;
+ }
+
+ /**
+ * Retreives the specified part from a {@link List List}.
+ *
+ * @param seq
+ * the list to retreive a slice from.
+ * @param pos
+ * the start position.
+ * @param count
+ * the number of items in the slice.
+ * @return a {@link List List} containing the specified items.
+ */
+ public static List slice(List seq, int pos, int count)
+ {
+ ArrayList list = new ArrayList();
+ if (count <= 0)
+ {
+ if (pos<seq.size())
+ list.add(seq.get(pos));
+ return list;
+ }
+ else
+ {
+ for (int i=pos;i<pos+count;i++) {
+ if (i<seq.size())
+ list.add(seq.get(i));
+ }
+ return list;
+ }
+ }
+
+ /**
+ * Retrieves a slice from an {@link Object Object} array.
+ *
+ * @param seq
+ * the list to retreive a slice from.
+ * @param pos
+ * the start position.
+ * @param count
+ * the number of items in the slice.
+ * @return a {@link List List} containing the specified items.
+ */
+ public static List slice(Object[] seq, int pos, int count)
+ {
+ return slice(Arrays.asList(seq), pos, count);
+ }
+
+ /**
+ * Provide a string representation of the numeric range of this chunk.
+ */
+ public String rangeString()
+ {
+ StringBuffer result = new StringBuffer();
+ rangeString(result);
+ return result.toString();
+ }
+
+ /**
+ * Provide a string representation of the numeric range of this chunk.
+ *
+ * @param s
+ * where the string representation should be appended.
+ */
+ public void rangeString(StringBuffer s)
+ {
+ rangeString(s, ",");
+ }
+
+ /**
+ * Provide a string representation of the numeric range of this chunk.
+ *
+ * @param s
+ * where the string representation should be appended.
+ * @param separ
+ * what to use as line separator.
+ */
+ public void rangeString(StringBuffer s, String separ)
+ {
+ if (size() <= 1)
+ {
+ s.append(Integer.toString(rcsfrom()));
+ }
+ else
+ {
+ s.append(Integer.toString(rcsfrom()));
+ s.append(separ);
+ s.append(Integer.toString(rcsto()));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DeleteDelta.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DeleteDelta.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DeleteDelta.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,119 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.List;
+
+/**
+ * Holds a delete-delta between to revisions of a text.
+ *
+ * @version $Id: DeleteDelta.java,v 1.1 2006/03/12 00:24:21 juanca Exp $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see Diff
+ * @see Chunk
+ */
+public class DeleteDelta extends Delta
+{
+
+ public DeleteDelta()
+ {
+ super();
+ }
+
+ public DeleteDelta(Chunk orig)
+ {
+ init(orig, null);
+ }
+
+ public void verify(List target) throws PatchFailedException
+ {
+ if (!original.verify(target))
+ {
+ throw new PatchFailedException();
+ }
+ }
+
+ public void applyTo(List target)
+ {
+ original.applyDelete(target);
+ }
+
+ public void toString(StringBuffer s)
+ {
+ s.append(original.rangeString());
+ s.append("d");
+ s.append(revised.rcsto());
+ s.append(Diff.NL);
+ original.toString(s, "< ", Diff.NL);
+ }
+
+ public void toRCSString(StringBuffer s, String EOL)
+ {
+ s.append("d");
+ s.append(original.rcsfrom());
+ s.append(" ");
+ s.append(original.size());
+ s.append(EOL);
+ }
+
+ public void accept(RevisionVisitor visitor)
+ {
+ visitor.visit(this);
+ }
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Delta.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Delta.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Delta.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,257 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.List;
+
+/**
+ * Holds a "delta" difference between to revisions of a text.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ *
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @author <a href="mailto:[email protected]">Brian McBride</a>
+ * @see Diff
+ * @see Chunk
+ * @see Revision
+ *
+ * modifications
+ *
+ * 27 Apr 2003 bwm
+ *
+ * Added getOriginal() and getRevised() accessor methods Added visitor pattern
+ * accept() method
+ */
+
+public abstract class Delta extends ToString
+{
+
+ protected Chunk original;
+
+ protected Chunk revised;
+
+
+ /**
+ * Returns a Delta that corresponds to the given chunks in the original and
+ * revised text respectively.
+ *
+ * @param orig
+ * the chunk in the original text.
+ * @param rev
+ * the chunk in the revised text.
+ */
+ public static Delta newDelta(Chunk orig, Chunk rev)
+ {
+ Delta result;
+ if ((orig.size()>0)&&(rev.size()>0))
+ result = new ChangeDelta();
+ else if ((orig.size()==0)&&(rev.size()==0))
+ result = new ChangeDelta();
+ else if ((orig.size()>0)&&(rev.size()==0))
+ result = new DeleteDelta();
+ else if ((orig.size()==0)&&(rev.size()>0))
+ result = new AddDelta();
+ else
+ return null;
+
+ result.init(orig, rev);
+ return result;
+ }
+
+ /**
+ * Creates an uninitialized delta.
+ */
+ public Delta()
+ {
+ }
+
+ /**
+ * Creates a delta object with the given chunks from the original and
+ * revised texts.
+ */
+ public Delta(Chunk orig, Chunk rev)
+ {
+ init(orig, rev);
+ }
+
+ /**
+ * Initializaes the delta with the given chunks from the original and
+ * revised texts.
+ */
+ public void init(Chunk orig, Chunk rev)
+ {
+ original = orig;
+ revised = rev;
+ }
+
+ /**
+ * Verifies that this delta can be used to patch the given text.
+ *
+ * @param target
+ * the text to patch.
+ * @throws PatchFailedException
+ * if the patch cannot be applied.
+ */
+ public abstract void verify(List target) throws PatchFailedException;
+
+ /**
+ * Applies this delta as a patch to the given text.
+ *
+ * @param target
+ * the text to patch.
+ * @throws PatchFailedException
+ * if the patch cannot be applied.
+ */
+ public final void patch(List target) throws PatchFailedException
+ {
+ verify(target);
+ try
+ {
+ applyTo(target);
+ }
+ catch (Exception e)
+ {
+ throw new PatchFailedException(e.getMessage());
+ }
+ }
+
+ /**
+ * Applies this delta as a patch to the given text.
+ *
+ * @param target
+ * the text to patch.
+ * @throws PatchFailedException
+ * if the patch cannot be applied.
+ */
+ public abstract void applyTo(List target);
+
+ /**
+ * Converts this delta into its Unix diff style string representation.
+ *
+ * @param s
+ * a {@link StringBuffer StringBuffer} to which the string
+ * representation will be appended.
+ */
+ public void toString(StringBuffer s)
+ {
+ original.rangeString(s);
+ s.append("x");
+ revised.rangeString(s);
+ s.append(Diff.NL);
+ original.toString(s, "> ", "\n");
+ s.append("---");
+ s.append(Diff.NL);
+ revised.toString(s, "< ", "\n");
+ }
+
+ /**
+ * Converts this delta into its RCS style string representation.
+ *
+ * @param s
+ * a {@link StringBuffer StringBuffer} to which the string
+ * representation will be appended.
+ * @param EOL
+ * the string to use as line separator.
+ */
+ public abstract void toRCSString(StringBuffer s, String EOL);
+
+ /**
+ * Converts this delta into its RCS style string representation.
+ *
+ * @param EOL
+ * the string to use as line separator.
+ */
+ public String toRCSString(String EOL)
+ {
+ StringBuffer s = new StringBuffer();
+ toRCSString(s, EOL);
+ return s.toString();
+ }
+
+ /**
+ * Accessor method to return the chunk representing the original sequence of
+ * items
+ *
+ * @return the original sequence
+ */
+ public Chunk getOriginal()
+ {
+ return original;
+ }
+
+ /**
+ * Accessor method to return the chunk representing the updated sequence of
+ * items.
+ *
+ * @return the updated sequence
+ */
+ public Chunk getRevised()
+ {
+ return revised;
+ }
+
+ /**
+ * Accepts a visitor.
+ * <p>
+ * See the Visitor pattern in "Design Patterns" by the GOF4.
+ *
+ * @param visitor
+ * The visitor.
+ */
+ public abstract void accept(RevisionVisitor visitor);
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Diff.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Diff.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Diff.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,390 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.*;
+
+import com.xpn.xwiki.wysiwyg.client.diff.myers.MyersDiff;
+
+/**
+ * Implements a differencing engine that works on arrays of
+ * {@link Object Object}.
+ *
+ * <p>
+ * Within this library, the word <i>text</i> means a unit of information
+ * subject to version control.
+ *
+ * <p>
+ * Text is represented as <code>Object[]</code> because the diff engine is
+ * capable of handling more than plain ascci. In fact, arrays of any type that
+ * implements {@link java.lang.Object#hashCode hashCode()} and
+ * {@link java.lang.Object#equals equals()} correctly can be subject to
+ * differencing using this library.
+ * </p>
+ *
+ * <p>
+ * This library provides a framework in which different differencing algorithms
+ * may be used. If no algorithm is specififed, a default algorithm is used.
+ * </p>
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see DiffAlgorithm
+ *
+ * modifications:
+ *
+ * 27 Apr 2003 bwm
+ *
+ * Added some comments whilst trying to figure out the algorithm
+ *
+ * 03 May 2003 bwm
+ *
+ * Factored out the algorithm implementation into a separate difference
+ * algorithm class to allow pluggable algorithms.
+ */
+
+public class Diff extends ToString
+{
+ /** The standard line separator. */
+ public static final String NL = " "; // System.getProperty("line.separator");
+
+ /** The line separator to use in RCS format output. */
+ public static final String RCS_EOL = " ";
+
+ /** The original sequence. */
+ protected Object[] orig;
+
+ /** The differencing algorithm to use. */
+ protected DiffAlgorithm algorithm;
+
+ /**
+ * Create a differencing object for an empty text, using the default algorithm. This has been
+ * added to stop GWT's complains about not having a default constructor. You should use the
+ * other two constructors instead.
+ */
+ public Diff()
+ {
+ this(new Object[] {});
+ }
+
+ /**
+ * Create a differencing object using the default algorithm
+ *
+ * @param original
+ * original text that will be compared
+ */
+ public Diff(Object[] original)
+ {
+ this(original, null);
+ }
+
+ /**
+ * Create a differencing object using the given algorithm
+ *
+ * @param original
+ * the original text which will be compared against
+ * @param algorithm
+ * the difference algorithm to use.
+ */
+ public Diff(Object[] original, DiffAlgorithm algorithm)
+ {
+ if (original == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ this.orig = original;
+ if (algorithm != null)
+ this.algorithm = algorithm;
+ else
+ this.algorithm = defaultAlgorithm();
+ }
+
+ protected DiffAlgorithm defaultAlgorithm()
+ {
+ return new MyersDiff();
+ }
+
+ /**
+ * compute the difference between an original and a revision.
+ *
+ * @param orig
+ * the original
+ * @param rev
+ * the revision to compare with the original.
+ * @return a Revision describing the differences
+ */
+ public static Revision diff(Object[] orig, Object[] rev)
+ throws DifferentiationFailedException
+ {
+ if (orig == null || rev == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ return diff(orig, rev, null);
+ }
+
+ /**
+ * compute the difference between an original and a revision.
+ *
+ * @param orig
+ * the original
+ * @param rev
+ * the revision to compare with the original.
+ * @param algorithm
+ * the difference algorithm to use
+ * @return a Revision describing the differences
+ */
+ public static Revision diff(Object[] orig, Object[] rev,
+ DiffAlgorithm algorithm) throws DifferentiationFailedException
+ {
+ if (orig == null || rev == null)
+ {
+ throw new IllegalArgumentException();
+ }
+
+ return new Diff(orig, algorithm).diff(rev);
+ }
+
+ /**
+ * compute the difference between the original and a revision.
+ *
+ * @param rev
+ * the revision to compare with the original.
+ * @return a Revision describing the differences
+ */
+ public Revision diff(Object[] rev) throws DifferentiationFailedException
+ {
+ if (orig.length == 0 && rev.length == 0)
+ return new Revision();
+ else
+ return algorithm.diff(orig, rev);
+ }
+
+ /**
+ * Compares the two input sequences.
+ *
+ * @param orig
+ * The original sequence.
+ * @param rev
+ * The revised sequence.
+ * @return true if the sequences are identical. False otherwise.
+ */
+ public static boolean compare(Object[] orig, Object[] rev)
+ {
+ if (orig.length != rev.length)
+ {
+ return false;
+ }
+ else
+ {
+ for (int i = 0; i < orig.length; i++)
+ {
+ if (!orig[i].equals(rev[i]))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Converts an array of {@link Object Object} to a string using
+ * {@link Diff#NL Diff.NL} as the line separator.
+ *
+ * @param o
+ * the array of objects.
+ */
+ /* public static String arrayToString(Object[] o)
+ {
+ return arrayToString(o, Diff.NL);
+ } */
+
+ /**
+ * Edits all of the items in the input sequence.
+ *
+ * @param text
+ * The input sequence.
+ * @return A sequence of the same length with all the lines differing from
+ * the corresponding ones in the input.
+ */
+ public static Object[] editAll(Object[] text)
+ {
+ Object[] result = new String[text.length];
+
+ for (int i = 0; i < text.length; i++)
+ result[i] = text[i] + " <edited>";
+
+ return result;
+ }
+
+ /**
+ * Performs random edits on the input sequence. Useful for testing.
+ *
+ * @param text
+ * The input sequence.
+ * @return The sequence with random edits performed.
+ */
+ public static Object[] randomEdit(Object[] text)
+ {
+ return randomEdit(text, text.length);
+ }
+
+ /**
+ * Performs random edits on the input sequence. Useful for testing.
+ *
+ * @param text
+ * The input sequence.
+ * @param seed
+ * A seed value for the randomizer.
+ * @return The sequence with random edits performed.
+ */
+ public static Object[] randomEdit(Object[] text, long seed)
+ {
+ /* List result = new ArrayList(Arrays.asList(text));
+ Random r = new Random(seed);
+ int nops = r.nextInt(10);
+ for (int i = 0; i < nops; i++)
+ {
+ boolean del = r.nextBoolean();
+ int pos = r.nextInt(result.size() + 1);
+ int len = Math.min(result.size() - pos, 1 + r.nextInt(4));
+ if (del && result.size() > 0)
+ { // delete
+ result.subList(pos, pos + len).clear();
+ }
+ else
+ {
+ for (int k = 0; k < len; k++, pos++)
+ {
+ result.add(pos, "[" + i + "] random edit[" + i + "][" + i
+ + "]");
+ }
+ }
+ }
+ return result.toArray();
+ */
+ return text;
+ }
+
+ /**
+ * Shuffles around the items in the input sequence.
+ *
+ * @param text
+ * The input sequence.
+ * @return The shuffled sequence.
+ */
+ public static Object[] shuffle(Object[] text)
+ {
+ return shuffle(text, text.length);
+ }
+
+ /**
+ * Shuffles around the items in the input sequence.
+ *
+ * @param text
+ * The input sequence.
+ * @param seed
+ * A seed value for randomizing the suffle.
+ * @return The shuffled sequence.
+ */
+ public static Object[] shuffle(Object[] text, long seed)
+ {
+ List result = new ArrayList(Arrays.asList(text));
+ // Collections.shuffle(result);
+ return result.toArray();
+ }
+
+ /**
+ * Generate a random sequence of the given size.
+ *
+ * @param The
+ * size of the sequence to generate.
+ * @return The generated sequence.
+ */
+ /*
+ public static Object[] randomSequence(int size)
+ {
+ return randomSequence(size, size);
+ } */
+
+ /**
+ * Generate a random sequence of the given size.
+ *
+ * @param The
+ * size of the sequence to generate.
+ * @param seed
+ * A seed value for randomizing the generation.
+ * @return The generated sequence.
+ */
+ /*
+ public static Object[] randomSequence(int size, long seed)
+ {
+ Integer[] result = new Integer[size];
+ Random r = new Random(seed);
+ for (int i = 0; i < result.length; i++)
+ {
+ result[i] = new Integer(r.nextInt(size));
+ }
+ return result;
+ } */
+
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffAlgorithm.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffAlgorithm.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffAlgorithm.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,85 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+/**
+ * A simple interface for implementations of differencing algorithms.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ *
+ * @author <a href="mailto:[email protected]">Brian McBride</a>
+ */
+public interface DiffAlgorithm
+{
+ /**
+ * Computes the difference between the original sequence and the revised
+ * sequence and returns it as a
+ * {@link com.xpn.xwiki.wysiwyg.client.diff.Revision Revision} object.
+ * <p>
+ * The revision can be used to construct the revised sequence from the
+ * original sequence.
+ *
+ * @param rev
+ * the revised text
+ * @return the revision script.
+ * @throws DifferentiationFailedException
+ * if the diff could not be computed.
+ */
+ public abstract Revision diff(Object[] orig, Object[] rev)
+ throws DifferentiationFailedException;
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffException.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffException.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DiffException.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,78 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+/**
+ * Base class for all exceptions emanating from this package.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ *
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ */
+public class DiffException extends Exception
+{
+
+ public DiffException()
+ {
+ }
+
+ public DiffException(String msg)
+ {
+ super(msg);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DifferentiationFailedException.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DifferentiationFailedException.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/DifferentiationFailedException.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,81 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+/**
+ * Thrown whenever the differencing engine cannot produce the differences
+ * between two revisions of ta text.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ *
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Diff
+ * @see DiffAlgorithm
+ */
+public class DifferentiationFailedException extends DiffException
+{
+
+ public DifferentiationFailedException()
+ {
+ }
+
+ public DifferentiationFailedException(String msg)
+ {
+ super(msg);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/PatchFailedException.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/PatchFailedException.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/PatchFailedException.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,79 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+/**
+ * Thrown whenever a delta cannot be applied as a patch to a given text.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see Diff
+ */
+public class PatchFailedException extends DiffException
+{
+
+ public PatchFailedException()
+ {
+ }
+
+ public PatchFailedException(String msg)
+ {
+ super(msg);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Revision.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Revision.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/Revision.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,269 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
+/**
+ * A Revision holds the series of deltas that describe the differences between
+ * two sequences.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ *
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @author <a href="mailto:[email protected]">Brian McBride</a>
+ *
+ * @see Delta
+ * @see Diff
+ * @see Chunk
+ * @see Revision
+ *
+ * modifications 27 Apr 2003 bwm
+ *
+ * Added visitor pattern Visitor interface and accept() method.
+ */
+
+public class Revision extends ToString
+{
+
+ List deltas_ = new ArrayList();
+
+ /**
+ * Creates an empty Revision.
+ */
+ public Revision()
+ {
+ }
+
+ /**
+ * Adds a delta to this revision.
+ *
+ * @param delta
+ * the {@link Delta Delta} to add.
+ */
+ public synchronized void addDelta(Delta delta)
+ {
+ if (delta == null)
+ {
+ throw new IllegalArgumentException("new delta is null");
+ }
+ deltas_.add(delta);
+ }
+
+ /**
+ * Adds a delta to the start of this revision.
+ *
+ * @param delta
+ * the {@link Delta Delta} to add.
+ */
+ public synchronized void insertDelta(Delta delta)
+ {
+ if (delta == null)
+ {
+ throw new IllegalArgumentException("new delta is null");
+ }
+ deltas_.add(0, delta);
+ }
+
+ /**
+ * Retrieves a delta from this revision by position.
+ *
+ * @param i
+ * the position of the delta to retrieve.
+ * @return the specified delta
+ */
+ public Delta getDelta(int i)
+ {
+ return (Delta) deltas_.get(i);
+ }
+
+ /**
+ * Returns the number of deltas in this revision.
+ *
+ * @return the number of deltas.
+ */
+ public int size()
+ {
+ return deltas_.size();
+ }
+
+ /**
+ * Applies the series of deltas in this revision as patches to the given
+ * text.
+ *
+ * @param src
+ * the text to patch, which the method doesn't change.
+ * @return the resulting text after the patches have been applied.
+ * @throws PatchFailedException
+ * if any of the patches cannot be applied.
+ */
+ public Object[] patch(Object[] src) throws PatchFailedException
+ {
+ List target = new ArrayList(Arrays.asList(src));
+ applyTo(target);
+ return target.toArray();
+ }
+
+ /**
+ * Applies the series of deltas in this revision as patches to the given
+ * text.
+ *
+ * @param target
+ * the text to patch.
+ * @throws PatchFailedException
+ * if any of the patches cannot be applied.
+ */
+ public synchronized void applyTo(List target) throws PatchFailedException
+ {
+ ListIterator i = deltas_.listIterator(deltas_.size());
+ while (i.hasPrevious())
+ {
+ Delta delta = (Delta) i.previous();
+ delta.patch(target);
+ }
+ }
+
+ /**
+ * Converts this revision into its Unix diff style string representation.
+ *
+ * @param s
+ * a {@link StringBuffer StringBuffer} to which the string
+ * representation will be appended.
+ */
+ public synchronized void toString(StringBuffer s)
+ {
+ Iterator i = deltas_.iterator();
+ while (i.hasNext())
+ {
+ ((Delta) i.next()).toString(s);
+ }
+ }
+
+ /**
+ * Converts this revision into its RCS style string representation.
+ *
+ * @param s
+ * a {@link StringBuffer StringBuffer} to which the string
+ * representation will be appended.
+ * @param EOL
+ * the string to use as line separator.
+ */
+ public synchronized void toRCSString(StringBuffer s, String EOL)
+ {
+ Iterator i = deltas_.iterator();
+ while (i.hasNext())
+ {
+ ((Delta) i.next()).toRCSString(s, EOL);
+ }
+ }
+
+ /**
+ * Converts this revision into its RCS style string representation.
+ *
+ * @param s
+ * a {@link StringBuffer StringBuffer} to which the string
+ * representation will be appended.
+ */
+ public void toRCSString(StringBuffer s)
+ {
+ toRCSString(s, Diff.NL);
+ }
+
+ /**
+ * Converts this delta into its RCS style string representation.
+ *
+ * @param EOL
+ * the string to use as line separator.
+ */
+ public String toRCSString(String EOL)
+ {
+ StringBuffer s = new StringBuffer();
+ toRCSString(s, EOL);
+ return s.toString();
+ }
+
+ /**
+ * Converts this delta into its RCS style string representation using the
+ * default line separator.
+ */
+ public String toRCSString()
+ {
+ return toRCSString(Diff.NL);
+ }
+
+ /**
+ * Accepts a visitor.
+ *
+ * @param visitor
+ * the visitor visiting this instance
+ */
+ public void accept(RevisionVisitor visitor)
+ {
+ visitor.visit(this);
+ Iterator iter = deltas_.iterator();
+ while (iter.hasNext())
+ {
+ ((Delta) iter.next()).accept(visitor);
+ }
+ }
+
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/RevisionVisitor.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/RevisionVisitor.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/RevisionVisitor.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,73 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+/**
+ * Definition of a Visitor interface for {@link Revision Revisions} See "Design
+ * Patterns" by the Gang of Four
+ */
+public interface RevisionVisitor
+{
+ public void visit(Revision revision);
+
+ public void visit(DeleteDelta delta);
+
+ public void visit(ChangeDelta delta);
+
+ public void visit(AddDelta delta);
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/SimpleDiff.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/SimpleDiff.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/SimpleDiff.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,335 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import java.util.*;
+
+/**
+ * Implements a simple differencing algortithm.
+ * <p>
+ *
+ * @date $Date: 2006/03/12 00:24:21 $
+ * @version $Revision: 1.1 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ *
+ * <p>
+ * <b>Overview of Algorithm</b>
+ * </p>
+ *
+ * <p>
+ * <i>by <a href='http://www.topmeadow.net/bwm'> bwm</a>
+ * </p>
+ *
+ * <p>
+ * The algorithm is optimised for situations where the input sequences have few
+ * repeated objects. If it is given input with many repeated objects it will
+ * report sub-optimal changes. However, given appropriate input, it is fast, and
+ * linear in memory usage.
+ * </p>
+ *
+ * <p>
+ * The algorithm consists of the following steps:
+ * </p>
+ * <ul>
+ * <li>compute an equivalence set for the input data</li>
+ * <li>translate each element of the orginal and revised input sequences to a
+ * member of the equivalence set </li>
+ * <li>match the the input sequences to determine the deltas, i.e. the
+ * differences between the original and revised sequences.</li>
+ * </ul>
+ *
+ * <p>
+ * The first step is to compute a an equivalence set for the input data. The
+ * equivalence set is computed from objects that are in the original input
+ * sequence
+ * </p>
+ *
+ * <pre>
+ * eq(x) = the index of the first occurence of x in the original sequence.
+ * </pre>
+ *
+ * <p>
+ * With this equivalence function, the algorithm can compare integers rather
+ * than strings, which is considerably more efficient.
+ * </p>
+ *
+ * <p>
+ * The second step is to compute the datastructure on which the algorithm will
+ * operate. Having computed the equivalence function in the previous step, we
+ * can compute two arrays where indx[i] = eqs(orig[i]) and jndx[i] =
+ * eqs(rev[i]). The algorithm can now operate on indx and jndx instead of orig
+ * and rev. Thus, comparisons are then on O(int == int) instead of
+ * O(Object.equals(Object)).
+ * </p>
+ *
+ * <p>
+ * The algorithm now matches indx and jndx. Whilst indx[i] == jndx[i] it skips
+ * matching objects in the sequence. In seeking to match objects in the input
+ * sequence it assumes that each object is likely to be unique. It uses the
+ * known characteristics of the unique equivalence function. It can tell from
+ * the eq value if this object appeared in the other sequence at all. If it did
+ * not, there is no point in searching for a match.
+ * </p>
+ *
+ * <p>
+ * Recall that the eq function value is the index earliest occurrence in the
+ * orig sequence. This information is used to search efficiently for the next
+ * match. The algorithm is perfect when all input objects are unique, but
+ * degrades when input objects are not unique. When input objects are not unique
+ * an optimal match may not be found, but a correct match will be.
+ * </p>
+ *
+ * <p>
+ * Having identified common matching objects in the orig and revised sequences,
+ * the differences between them are easily computed.
+ * </p>
+ *
+ * @see Delta
+ * @see Revision Modifications:
+ *
+ * 27/Apr/2003 bwm Added some comments whilst trying to figure out the algorithm
+ *
+ * 03 May 2003 bwm Created this implementation class by refactoring it out of
+ * the Diff class to enable plug in difference algorithms
+ *
+ */
+public class SimpleDiff implements DiffAlgorithm
+{
+
+ static final int NOT_FOUND_i = -2;
+ static final int NOT_FOUND_j = -1;
+ static final int EOS = Integer.MAX_VALUE;
+
+ public SimpleDiff()
+ {
+ }
+
+ protected int scan(int[] ndx, int i, int target)
+ {
+ while (ndx[i] < target)
+ {
+ i++;
+ }
+ return i;
+ }
+
+ /**
+ * Compute the difference between original and revised sequences.
+ *
+ * @param orig
+ * The original sequence.
+ * @param rev
+ * The revised sequence to be compared with the original.
+ * @return A Revision object describing the differences.
+ * @throws DifferenciationFailedException
+ * if the diff could not be computed.
+ */
+ public Revision diff(Object[] orig, Object[] rev)
+ throws DifferentiationFailedException
+ {
+ // create map eqs, such that for each item in both orig and rev
+ // eqs(item) = firstOccurrence(item, orig);
+ Map eqs = buildEqSet(orig, rev);
+
+ // create an array such that
+ // indx[i] = NOT_FOUND_i if orig[i] is not in rev
+ // indx[i] = firstOccurrence(orig[i], orig)
+ int[] indx = buildIndex(eqs, orig, NOT_FOUND_i);
+
+ // create an array such that
+ // jndx[j] = NOT_FOUND_j if orig[j] is not in rev
+ // jndx[j] = firstOccurrence(rev[j], orig)
+ int[] jndx = buildIndex(eqs, rev, NOT_FOUND_j);
+
+ // what in effect has been done is to build a unique hash
+ // for each item that is in both orig and rev
+ // and to label each item in orig and new with that hash value
+ // or a marker that the item is not common to both.
+
+ eqs = null; // let gc know we're done with this
+
+ Revision deltas = new Revision(); // !!! new Revision()
+ int i = 0;
+ int j = 0;
+
+ // skip matching
+ // skip leading items that are equal
+ // could be written
+ // for (i=0; indx[i] != EOS && indx[i] == jndx[i]; i++);
+ // j = i;
+ for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
+ {
+ /* void */
+ }
+
+ while (indx[i] != jndx[j])
+ { // only equal if both == EOS
+ // they are different
+ int ia = i;
+ int ja = j;
+
+ // size of this delta
+ do
+ {
+ // look down rev for a match
+ // stop at a match
+ // or if the FO(rev[j]) > FO(orig[i])
+ // or at the end
+ while (jndx[j] < 0 || jndx[j] < indx[i])
+ {
+ j++;
+ }
+ // look down orig for a match
+ // stop at a match
+ // or if the FO(orig[i]) > FO(rev[j])
+ // or at the end
+ while (indx[i] < 0 || indx[i] < jndx[j])
+ {
+ i++;
+ }
+
+ // this doesn't do a compare each line with each other line
+ // so it won't find all matching lines
+ }
+ while (indx[i] != jndx[j]);
+
+ // on exit we have a match
+
+ // they are equal, reverse any exedent matches
+ // it is possible to overshoot, so count back matching items
+ while (i > ia && j > ja && indx[i - 1] == jndx[j - 1])
+ {
+ --i;
+ --j;
+ }
+
+ deltas.addDelta(Delta.newDelta(new Chunk(orig, ia, i - ia),
+ new Chunk(rev, ja, j - ja)));
+ // skip matching
+ for (; indx[i] != EOS && indx[i] == jndx[j]; i++, j++)
+ {
+ /* void */
+ }
+ }
+ return deltas;
+ }
+
+ /**
+ * create a <code>Map</code> from each common item in orig and rev to the
+ * index of its first occurrence in orig
+ *
+ * @param orig
+ * the original sequence of items
+ * @param rev
+ * the revised sequence of items
+ */
+ protected Map buildEqSet(Object[] orig, Object[] rev)
+ {
+ // construct a set of the objects that orig and rev have in common
+
+ // first construct a set containing all the elements in orig
+ Set items = new HashSet(Arrays.asList(orig));
+
+ // then remove all those not in rev
+ items.retainAll(Arrays.asList(rev));
+
+ Map eqs = new HashMap();
+ for (int i = 0; i < orig.length; i++)
+ {
+ // if its a common item and hasn't been found before
+ if (items.contains(orig[i]))
+ {
+ // add it to the map
+ eqs.put(orig[i], new Integer(i));
+ // and make sure its not considered again
+ items.remove(orig[i]);
+ }
+ }
+ return eqs;
+ }
+
+ /**
+ * build a an array such each a[i] = eqs([i]) or NF if eqs([i]) undefined
+ *
+ * @param eqs
+ * a mapping from Object to Integer
+ * @param seq
+ * a sequence of objects
+ * @param NF
+ * the not found marker
+ */
+ protected int[] buildIndex(Map eqs, Object[] seq, int NF)
+ {
+ int[] result = new int[seq.length + 1];
+ for (int i = 0; i < seq.length; i++)
+ {
+ Integer value = (Integer) eqs.get(seq[i]);
+ if (value == null || value.intValue() < 0)
+ {
+ result[i] = NF;
+ }
+ else
+ {
+ result[i] = value.intValue();
+ }
+ }
+ result[seq.length] = EOS;
+ return result;
+ }
+
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ToString.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ToString.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/ToString.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,197 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff;
+
+import com.google.gwt.user.client.rpc.IsSerializable;
+
+/**
+ * This class delegates handling of the to a StringBuffer based version.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ */
+public class ToString implements IsSerializable
+{
+ public ToString()
+ {
+ }
+
+ /**
+ * Default implementation of the
+ * {@link java.lang.Object#toString toString() } method that delegates work
+ * to a {@link java.lang.StringBuffer StringBuffer} base version.
+ */
+ public String toString()
+ {
+ StringBuffer s = new StringBuffer();
+ toString(s);
+ return s.toString();
+ }
+
+ /**
+ * Place a string image of the object in a StringBuffer.
+ *
+ * @param s
+ * the string buffer.
+ */
+ public void toString(StringBuffer s)
+ {
+ s.append(super.toString());
+ }
+
+ /**
+ * Breaks a string into an array of strings. Use the value of the
+ * <code>line.separator</code> system property as the linebreak character.
+ *
+ * @param value
+ * the string to convert.
+ */
+ /*
+ public static String[] stringToArray(String value)
+ {
+ ArrayList list = new ArrayList();
+ String[] lines = value.replaceAll("\r", "").split("\n");
+ for (int i=0;i<lines.length;i++) {
+ splitLine(list, lines[i]);
+ }
+ String[] result = new String[list.size() + 2];
+ for (int i=0;i<list.size();i++) {
+ result[i+1] = (String) list.get(i);
+ }
+ // Add placeholder strings at the beginning and end
+ result[0] = "BEGIN";
+ result[list.size()+1] = "END";
+ return result;
+
+ }
+
+ public static void splitLine(ArrayList list, String line) {
+ boolean isTag = false;
+ StringBuffer currentToken = new StringBuffer();
+ for (int i=0;i<line.length();i++) {
+ char c = line.charAt(i);
+ if (!isTag) {
+ if (c=='<') {
+ list.add(currentToken.toString());
+ currentToken = new StringBuffer();
+ currentToken.append(c);
+ isTag = true;
+ } else if (c==' ') {
+ list.add(currentToken.toString());
+ list.add(" ");
+ currentToken = new StringBuffer();
+ } else {
+ currentToken.append(c);
+ }
+ } else if (isTag && (c == '>')) {
+ currentToken.append(c);
+ list.add(currentToken.toString());
+ currentToken = new StringBuffer();
+ isTag = false;
+ } else {
+ currentToken.append(c);
+ }
+ }
+ if (currentToken.length()>0) {
+ list.add(currentToken.toString());
+ }
+ list.add("\n");
+ }
+
+ /**
+ * Converts an array of {@link Object Object} to a string using the given
+ * line separator.
+ *
+ * @param o
+ * the array of objects.
+ */
+ /*
+ public static String arrayToString(Object[] o)
+ {
+ StringBuffer buf = new StringBuffer();
+ // ignore first and last element
+ for (int i = 1; i < o.length - 1; i++)
+ {
+ buf.append(o[i]);
+ }
+ return buf.toString().replaceAll("\r", "");
+ } */
+
+ public static String[] stringToArray(String value)
+ {
+ value = value.replaceAll("\r", "");
+ String[] result = new String[value.length() + 2];
+ result[0] = "BEGIN";
+ for (int i=0;i<value.length();i++) {
+ result[i+1] = "" + value.charAt(i);
+ }
+ result[result.length-1] = "END";
+ return result;
+ }
+
+ public static String arrayToString(Object[] o)
+ {
+ StringBuffer buf = new StringBuffer();
+ // ignore first and last element
+ for (int i = 1; i < o.length - 1; i++)
+ {
+ buf.append(o[i]);
+ }
+ return buf.toString().replaceAll("\r", "");
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/DiffNode.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/DiffNode.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/DiffNode.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,59 @@
+package com.xpn.xwiki.wysiwyg.client.diff.myers;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: Copyright (c) 2002</p>
+ * <p>Company: </p>
+ * @author not attributable
+ * @version 1.0
+ */
+
+/**
+ * A diffnode in a diffpath.
+ * <p>
+ * A DiffNode and its previous node mark a delta between two input sequences,
+ * that is, two differing subsequences between (possibly zero length) matching
+ * sequences.
+ *
+ * {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression of
+ * diffpaths, as each snake is represented by a single {@link Snake Snake} node
+ * and each contiguous series of insertions and deletions is represented by a
+ * single {@link DiffNode DiffNodes}.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ *
+ */
+public final class DiffNode extends PathNode
+{
+ /**
+ * Constructs a DiffNode.
+ * <p>
+ * DiffNodes are compressed. That means that the path pointed to by the
+ * <code>prev</code> parameter will be followed using
+ * {@link PathNode#previousSnake} until a non-diff node is found.
+ *
+ * @param the
+ * position in the original sequence
+ * @param the
+ * position in the revised sequence
+ * @param prev
+ * the previous node in the path.
+ */
+ public DiffNode(int i, int j, PathNode prev)
+ {
+ super(i, j, (prev == null ? null : prev.previousSnake()));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return false, always
+ */
+ public boolean isSnake()
+ {
+ return false;
+ }
+
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/MyersDiff.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/MyersDiff.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/MyersDiff.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,235 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation. All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff.myers;
+
+import com.xpn.xwiki.wysiwyg.client.diff.*;
+
+/**
+ * A clean-room implementation of <a
+ * href="http://www.cs.arizona.edu/people/gene/"> Eugene Myers</a> differencing
+ * algorithm.
+ * <p>
+ * See the paper at <a
+ * href="http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps">
+ * http://www.cs.arizona.edu/people/gene/PAPERS/diff.ps</a>
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ * @see Delta
+ * @see Revision
+ * @see Diff
+ */
+public class MyersDiff implements DiffAlgorithm
+{
+ /**
+ * Constructs an instance of the Myers differencing algorithm.
+ */
+ public MyersDiff()
+ {
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Revision diff(Object[] orig, Object[] rev)
+ throws DifferentiationFailedException
+ {
+ PathNode path = buildPath(orig, rev);
+ return buildRevision(path, orig, rev);
+ }
+
+ /**
+ * Computes the minimum diffpath that expresses de differences between the
+ * original and revised sequences, according to Gene Myers differencing
+ * algorithm.
+ *
+ * @param orig
+ * The original sequence.
+ * @param rev
+ * The revised sequence.
+ * @return A minimum {@link PathNode Path} accross the differences graph.
+ * @throws DifferentiationFailedException
+ * if a diff path could not be found.
+ */
+ public static PathNode buildPath(Object[] orig, Object[] rev)
+ throws DifferentiationFailedException
+ {
+ if (orig == null)
+ throw new IllegalArgumentException("original sequence is null");
+ if (rev == null)
+ throw new IllegalArgumentException("revised sequence is null");
+
+ // these are local constants
+ final int N = orig.length;
+ final int M = rev.length;
+
+ final int MAX = N + M + 1;
+ final int size = 1 + 2 * MAX;
+ final int middle = (size + 1) / 2;
+ final PathNode diagonal[] = new PathNode[size];
+
+ diagonal[middle + 1] = new Snake(0, -1, null);
+ for (int d = 0; d < MAX; d++)
+ {
+ for (int k = -d; k <= d; k += 2)
+ {
+ final int kmiddle = middle + k;
+ final int kplus = kmiddle + 1;
+ final int kminus = kmiddle - 1;
+ PathNode prev = null;
+
+ int i;
+ if ((k == -d)
+ || (k != d && diagonal[kminus].i < diagonal[kplus].i))
+ {
+ i = diagonal[kplus].i;
+ prev = diagonal[kplus];
+ }
+ else
+ {
+ i = diagonal[kminus].i + 1;
+ prev = diagonal[kminus];
+ }
+
+ diagonal[kminus] = null; // no longer used
+
+ int j = i - k;
+
+ PathNode node = new DiffNode(i, j, prev);
+
+ // orig and rev are zero-based
+ // but the algorithm is one-based
+ // that's why there's no +1 when indexing the sequences
+ while (i < N && j < M && orig[i].equals(rev[j]))
+ {
+ i++;
+ j++;
+ }
+ if (i > node.i)
+ node = new Snake(i, j, node);
+
+ diagonal[kmiddle] = node;
+
+ if (i >= N && j >= M)
+ {
+ return diagonal[kmiddle];
+ }
+ }
+ diagonal[middle + d - 1] = null;
+
+ }
+ // According to Myers, this cannot happen
+ throw new DifferentiationFailedException("could not find a diff path");
+ }
+
+ /**
+ * Constructs a {@link Revision} from a difference path.
+ *
+ * @param path
+ * The path.
+ * @param orig
+ * The original sequence.
+ * @param rev
+ * The revised sequence.
+ * @return A {@link Revision} script corresponding to the path.
+ * @throws DifferentiationFailedException
+ * if a {@link Revision} could not be built from the given path.
+ */
+ public static Revision buildRevision(PathNode path, Object[] orig,
+ Object[] rev)
+ {
+ if (path == null)
+ throw new IllegalArgumentException("path is null");
+ if (orig == null)
+ throw new IllegalArgumentException("original sequence is null");
+ if (rev == null)
+ throw new IllegalArgumentException("revised sequence is null");
+
+ Revision revision = new Revision();
+ if (path.isSnake())
+ path = path.prev;
+ while (path != null && path.prev != null && path.prev.j >= 0)
+ {
+ if (path.isSnake())
+ throw new IllegalStateException(
+ "bad diffpath: found snake when looking for diff");
+ int i = path.i + 1;
+ int j = path.j + 1;
+ if (i>orig.length)
+ i--;
+ if (j>rev.length)
+ j--;
+
+ path = path.prev;
+ int ianchor = path.i - 1;
+ if (ianchor<0)
+ ianchor = 0;
+ int janchor = path.j - 1;
+ if (janchor<0)
+ janchor = 0;
+
+ Delta delta = Delta.newDelta(new Chunk(orig, ianchor, i - ianchor),
+ new Chunk(rev, janchor, j - janchor));
+ revision.insertDelta(delta);
+ if (path.isSnake())
+ path = path.prev;
+ }
+ return revision;
+ }
+
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/PathNode.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/PathNode.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/PathNode.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,150 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff.myers;
+
+/**
+ * A node in a diffpath.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ *
+ * @see DiffNode
+ * @see Snake
+ *
+ */
+public abstract class PathNode
+{
+ /** Position in the original sequence. */
+ public final int i;
+ /** Position in the revised sequence. */
+ public final int j;
+ /** The previous node in the path. */
+ public final PathNode prev;
+
+ /**
+ * Concatenates a new path node with an existing diffpath.
+ *
+ * @param i
+ * The position in the original sequence for the new node.
+ * @param j
+ * The position in the revised sequence for the new node.
+ * @param prev
+ * The previous node in the path.
+ */
+ public PathNode(int i, int j, PathNode prev)
+ {
+ this.i = i;
+ this.j = j;
+ this.prev = prev;
+ }
+
+ /**
+ * Is this node a {@link Snake Snake node}?
+ *
+ * @return true if this is a {@link Snake Snake node}
+ */
+ public abstract boolean isSnake();
+
+ /**
+ * Is this a bootstrap node?
+ * <p>
+ * In bottstrap nodes one of the two corrdinates is less than zero.
+ *
+ * @return tru if this is a bootstrap node.
+ */
+ public boolean isBootstrap()
+ {
+ return i < 0 || j < 0;
+ }
+
+ /**
+ * Skips sequences of {@link DiffNode DiffNodes} until a {@link Snake} or
+ * bootstrap node is found, or the end of the path is reached.
+ *
+ * @return The next first {@link Snake} or bootstrap node in the path, or
+ * <code>null</code> if none found.
+ */
+ public final PathNode previousSnake()
+ {
+ if (isBootstrap())
+ return null;
+ if (!isSnake() && prev != null)
+ return prev.previousSnake();
+ return this;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String toString()
+ {
+ StringBuffer buf = new StringBuffer("[");
+ PathNode node = this;
+ while (node != null)
+ {
+ buf.append("(");
+ buf.append(Integer.toString(node.i));
+ buf.append(",");
+ buf.append(Integer.toString(node.j));
+ buf.append(")");
+ node = node.prev;
+ }
+ buf.append("]");
+ return buf.toString();
+ }
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/Snake.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/Snake.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/diff/myers/Snake.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,100 @@
+/*
+ * ====================================================================
+ *
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 1999-2003 The Apache Software Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution, if
+ * any, must include the following acknowledgement:
+ * "This product includes software developed by the
+ * Apache Software Foundation (http://www.apache.org/)"
+ * Alternately, this acknowledgement may appear in the software itself,
+ * if and wherever such third-party acknowledgements normally appear.
+ *
+ * 4. The names "The Jakarta Project", "Commons", and "Apache Software
+ * Foundation" must not be used to endorse or promote products derived
+ * from this software without prior written permission. For written
+ * permission, please contact apache(a)apache.org.
+ *
+ * 5. Products derived from this software may not be called "Apache"
+ * nor may "Apache" appear in their names without prior written
+ * permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation. For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ */
+
+package com.xpn.xwiki.wysiwyg.client.diff.myers;
+
+/**
+ * Represents a snake in a diffpath.
+ * <p>
+ *
+ * {@link DiffNode DiffNodes} and {@link Snake Snakes} allow for compression of
+ * diffpaths, as each snake is represented by a single {@link Snake Snake} node
+ * and each contiguous series of insertions and deletions is represented by a
+ * single {@link DiffNode DiffNodes}.
+ *
+ * @version $Revision: 1.1 $ $Date: 2006/03/12 00:24:21 $
+ * @author <a href="mailto:[email protected]">Juanco Anez</a>
+ *
+ */
+public final class Snake extends PathNode
+{
+ /**
+ * Constructs a snake node.
+ *
+ * @param the
+ * position in the original sequence
+ * @param the
+ * position in the revised sequence
+ * @param prev
+ * the previous node in the path.
+ */
+ public Snake(int i, int j, PathNode prev)
+ {
+ super(i, j, prev);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @return true always
+ */
+ public boolean isSnake()
+ {
+ return true;
+ }
+
+}
\ No newline at end of file
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DOMUtils.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DOMUtils.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DOMUtils.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,1213 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.dom.client.Node;
+
+/**
+ * Utility class providing methods for manipulating the DOM tree. Add here only the methods that work with any kind of
+ * DOM node and the methods that have different implementation for different browsers. For specific node types see
+ * {@link Document}, {@link Element} or {@link Text}.
+ *
+ * @version $Id$
+ */
+public abstract class DOMUtils
+{
+ /**
+ * Common error message used when a particular node type is not supported by a method.
+ */
+ public static final String UNSUPPORTED_NODE_TYPE = "Unsupported node type!";
+
+ /**
+ * The list of all HTML elements that can have both in-line and block-level content, as specified by the XHTML 1.0
+ * strict DTD.
+ * <p>
+ * NOTE: We added the {@code body} and {@code blockquote} elements since the editor allows us to write text directly
+ * inside them. We also kept only the most important (used) flow containers to improve the search speed.
+ */
+ public static final String[] HTML_FLOW_CONTAINERS =
+ new String[] {"body", "li", "td", "th", "dd", "div", "blockquote"};
+
+ /**
+ * The list of all block-level HTML elements that can have only in-line content, as specified by the XHTML 1.0
+ * strict DTD.
+ * <p>
+ * NOTE: We kept only the most important (used) elements to improve the search speed.
+ */
+ public static final String[] HTML_BLOCK_LEVEL_INLINE_CONTAINERS =
+ new String[] {"p", "h1", "h2", "h3", "h4", "h5", "h6", "pre", "dt", "address"};
+
+ /**
+ * The list of all block-level HTML elements that can have only special content, or no content at all, as specified
+ * by the XHTML 1.0 strict DTD.
+ */
+ public static final String[] HTML_SPECIAL_BLOCK_LEVEL_ELEMENTS =
+ new String[] {"hr", "ul", "ol", "dl", "table", "tbody", "thead", "tfoot", "tr"};
+
+ /**
+ * The list of all HTML tags that must be empty. All of them appear as <code><tagName/></code> in the HTML
+ * code.<br/>
+ * NOTE: We had to move this array from Element because there is a problem with static field initialization for
+ * classes extending JavaScriptObject.
+ *
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3192
+ */
+ public static final String[] HTML_EMPTY_TAGS =
+ new String[] {"area", "base", "basefont", "br", "col", "frame", "hr", "img", "input", "isindex", "link",
+ "meta", "param", "nextid", "bgsound", "embed", "keygen", "spacer", "wbr"};
+
+ /**
+ * Constant for the comment node type.
+ */
+ public static final short COMMENT_NODE = 8;
+
+ /**
+ * Constant for the CDATA node type.
+ */
+ public static final short CDATA_NODE = 4;
+
+ /**
+ * Constant for the DocumentFragment node type.
+ */
+ public static final short DOCUMENT_FRAGMENT_NODE = 11;
+
+ /**
+ * The instance in use.
+ */
+ private static DOMUtils instance;
+
+ /**
+ * NOTE: We use deferred binding because some of the methods don't have cross-browser implementation and we want to
+ * load the implementation specific to the browser used.
+ *
+ * @return the instance in use.
+ */
+ public static synchronized DOMUtils getInstance()
+ {
+ if (instance == null) {
+ instance = GWT.create(DOMUtils.class);
+ }
+ return instance;
+ }
+
+ /**
+ * Returns the value of the specified CSS property for the given element as it is computed by the browser before it
+ * displays that element. The CSS property doesn't have to be applied explicitly or directly on the given element.
+ * It can be inherited or assumed by default on that element.
+ *
+ * @param el the element for which we retrieve the property value.
+ * @param propertyName the name of the CSS property whose value is returned.
+ * @return the computed value of the specified CSS property for the given element.
+ */
+ public abstract String getComputedStyleProperty(Element el, String propertyName);
+
+ /**
+ * @param node the node from where to begin the search for the next leaf.
+ * @return the next leaf node in a deep-first search, considering we already looked in the subtree whose root is the
+ * given node.
+ */
+ public Node getNextLeaf(Node node)
+ {
+ Node ancestor = node;
+ while (ancestor != null && ancestor.getNextSibling() == null) {
+ ancestor = ancestor.getParentNode();
+ }
+ if (ancestor == null) {
+ // There's no next leaf.
+ return null;
+ } else {
+ // Return the first leaf in the subtree whose root is the next sibling of the ancestor.
+ return getFirstLeaf(ancestor.getNextSibling());
+ }
+ }
+
+ /**
+ * @param range the range after which to look for a leaf
+ * @return the next leaf which is not touched by the specified range.
+ */
+ public Node getNextLeaf(Range range)
+ {
+ Node endContainer = range.getEndContainer();
+ if (endContainer.getNodeType() != Node.ELEMENT_NODE) {
+ // The node is either a text node or a comment node, return next leaf
+ return getNextLeaf(endContainer);
+ } else {
+ // the node is an element node, and the selection ends somewhere in between two child nodes. Check if it's
+ // at the end of it's parent and return the parent's next leaf or the first leaf of the next node otherwise
+ if (endContainer.hasChildNodes() && range.getEndOffset() < endContainer.getChildNodes().getLength()) {
+ // get the first leaf of the node after the end container
+ Node nodeAfter = endContainer.getChildNodes().getItem(range.getEndOffset());
+ return getFirstLeaf(nodeAfter);
+ } else {
+ return getNextLeaf(endContainer);
+ }
+ }
+ }
+
+ /**
+ * @param range the range before which to look for a leaf
+ * @return the previous leaf which is not touched by the specified range.
+ */
+ public Node getPreviousLeaf(Range range)
+ {
+ Node startContainer = range.getStartContainer();
+ if (startContainer.getNodeType() != Node.ELEMENT_NODE) {
+ return getPreviousLeaf(startContainer);
+ } else {
+ // the node is an element node and the selection begins somewhere in between two child nodes. Check if it's
+ // at the beginning of its parent and return the parent's previous leaf or the last leaf of the previous
+ // node otherwise.
+ if (startContainer.hasChildNodes() && range.getStartOffset() > 0) {
+ Node nodeBefore = startContainer.getChildNodes().getItem(range.getStartOffset() - 1);
+ return getLastLeaf(nodeBefore);
+ } else {
+ return getPreviousLeaf(startContainer);
+ }
+
+ }
+ }
+
+ /**
+ * @param node the node from where to begin the search for the previous leaf.
+ * @return the previous leaf node in a reverse deep-first search, considering we already looked in the subtree whose
+ * root is the given node.
+ */
+ public Node getPreviousLeaf(Node node)
+ {
+ Node ancestor = node;
+ while (ancestor != null && ancestor.getPreviousSibling() == null) {
+ ancestor = ancestor.getParentNode();
+ }
+ if (ancestor == null) {
+ // There's no previous leaf.
+ return null;
+ } else {
+ // Return the last leaf in the subtree whose root is the next sibling of the ancestor.
+ return getLastLeaf(ancestor.getPreviousSibling());
+ }
+ }
+
+ /**
+ * @param node the root of the DOM subtree whose first leaf is returned.
+ * @return the first leaf node of the DOM subtree whose root is the given node.
+ */
+ public Node getFirstLeaf(Node node)
+ {
+ Node descendant = node;
+ while (descendant.hasChildNodes()) {
+ descendant = descendant.getFirstChild();
+ }
+ return descendant;
+ }
+
+ /**
+ * @param node the root of the DOM subtree whose last leaf is returned.
+ * @return the last leaf node of the DOM subtree whose root is the given node.
+ */
+ public Node getLastLeaf(Node node)
+ {
+ Node descendant = node;
+ while (descendant.hasChildNodes()) {
+ descendant = descendant.getLastChild();
+ }
+ return descendant;
+ }
+
+ /**
+ * @param node the node whose index is returned.
+ * @return the index of the given node among its siblings.
+ */
+ public int getNodeIndex(Node node)
+ {
+ int count = 0;
+ Node leftSibling = node.getPreviousSibling();
+ Node rightSibling = node.getNextSibling();
+ while (leftSibling != null && rightSibling != null) {
+ count++;
+ leftSibling = leftSibling.getPreviousSibling();
+ rightSibling = rightSibling.getNextSibling();
+ }
+ if (leftSibling == null) {
+ return count;
+ } else {
+ return node.getParentNode().getChildNodes().getLength() - 1 - count;
+ }
+ }
+
+ /**
+ * Computes the index that can be used with <code>getChildNodes().getItem()</code> to retrieve the given node from
+ * its parent after the parent is serialized and deserialized.
+ *
+ * @param node a DOM node
+ * @return the index of the given DOM node among its siblings, considering successive text nodes as one single node
+ * and ignoring hidden siblings
+ */
+ public int getNormalizedNodeIndex(Node node)
+ {
+ int count = 0;
+ Node sibling = node;
+ while (sibling != null) {
+ Node left = sibling.getPreviousSibling();
+ if (sibling.getNodeType() == Node.TEXT_NODE) {
+ while (left != null && (left.getNodeType() == Node.TEXT_NODE || !isSerializable(left))) {
+ left = left.getPreviousSibling();
+ }
+ } else {
+ while (left != null && !isSerializable(left)) {
+ left = left.getPreviousSibling();
+ }
+ }
+ count += (left != null) ? 1 : 0;
+ sibling = left;
+ }
+ return count;
+ }
+
+ /**
+ * Specifies if a node's HTML serialization is included in its parent node's HTML serialization. Normally the inner
+ * HTML of an element includes the HTML representation of all of its descendants. This is not the case when one of
+ * the descendants is an element with an empty meta data associated. Associating empty meta data to an element is a
+ * way to hide that element from the inner HTML of his ancestors.
+ *
+ * @param node a DOM node
+ * @return true if the given node is represented in its parent inner HTML
+ */
+ public boolean isSerializable(Node node)
+ {
+ switch (node.getNodeType()) {
+ case Node.TEXT_NODE:
+ return node.getNodeValue().length() > 0;
+ case Node.ELEMENT_NODE:
+ Element element = (Element) node;
+ return !element.hasAttribute(Element.META_DATA_ATTR)
+ || !"".equals(element.xGetAttribute(Element.META_DATA_ATTR));
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * @param node a DOM node.
+ * @return the child count for the given DOM node, considering successive child text nodes as one single child.
+ * @see #getNormalizedNodeIndex(Node)
+ */
+ public int getNormalizedChildCount(Node node)
+ {
+ if (!node.hasChildNodes()) {
+ return 0;
+ } else {
+ Node last = node.getLastChild();
+ return (isSerializable(last) ? 1 : 0) + getNormalizedNodeIndex(last);
+ }
+ }
+
+ /**
+ * @param node a DOM node
+ * @return {@code true} if the given DOM node represents in-line content
+ */
+ public boolean isInline(Node node)
+ {
+ return !isBlock(node);
+ }
+
+ /**
+ * @param node a DOM node
+ * @return {@code true} if the given node is a block-level element, {@code false} otherwise
+ */
+ public boolean isBlock(Node node)
+ {
+ return isFlowContainer(node) || isBlockLevelInlineContainer(node) || isSpecialBlock(node);
+ }
+
+ /**
+ * @param node a DOM node
+ * @return {@code true} if the given node is a block-level element that can have only in-line content, {@code false}
+ * otherwise
+ * @see #HTML_BLOCK_LEVEL_INLINE_CONTAINERS
+ */
+ public boolean isBlockLevelInlineContainer(Node node)
+ {
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
+ String tagName = node.getNodeName().toLowerCase();
+ for (int i = 0; i < HTML_BLOCK_LEVEL_INLINE_CONTAINERS.length; i++) {
+ if (tagName.equals(HTML_BLOCK_LEVEL_INLINE_CONTAINERS[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param node a DOM node
+ * @return {@code true} if the given node is a block-level element that can have only special content, {@code false}
+ * otherwise
+ * @see #HTML_SPECIAL_BLOCK_LEVEL_ELEMENTS
+ */
+ public boolean isSpecialBlock(Node node)
+ {
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
+ String tagName = node.getNodeName().toLowerCase();
+ for (int i = 0; i < HTML_SPECIAL_BLOCK_LEVEL_ELEMENTS.length; i++) {
+ if (tagName.equals(HTML_SPECIAL_BLOCK_LEVEL_ELEMENTS[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Computes the longest text range included in the specified range. By text range we understand any range that
+ * starts and ends in a text node. The end points of a text range can be in different text nodes.
+ *
+ * @param range any range
+ * @return the longest text range included in the given range.
+ */
+ public Range getTextRange(Range range)
+ {
+ Range textRange = range.cloneRange();
+ Node firstLeaf = getFirstLeaf(range);
+ if (firstLeaf != null) {
+ Node lastLeaf = getLastLeaf(range);
+ // Find the first text node in the range and start the range there.
+ while (firstLeaf != lastLeaf && firstLeaf.getNodeType() != Node.TEXT_NODE) {
+ firstLeaf = getNextLeaf(firstLeaf);
+ }
+ if (firstLeaf.getNodeType() == Node.TEXT_NODE && firstLeaf != textRange.getStartContainer()) {
+ textRange.setStart(firstLeaf, 0);
+ }
+ // Find the last text node in the range and end the range there.
+ while (lastLeaf != firstLeaf && lastLeaf.getNodeType() != Node.TEXT_NODE) {
+ lastLeaf = getPreviousLeaf(lastLeaf);
+ }
+ if (lastLeaf.getNodeType() == Node.TEXT_NODE && lastLeaf != textRange.getEndContainer()) {
+ textRange.setEnd(lastLeaf, lastLeaf.getNodeValue().length());
+ }
+ }
+ return textRange;
+ }
+
+ /**
+ * Creates a copy of a node from an external document that can be inserted into the given document.
+ *
+ * @param doc The document in which we want to insert the returned copy.
+ * @param externalNode The node from another document to be imported.
+ * @param deep Indicates whether the children of the given node need to be imported.
+ * @return a copy of the given node that can be inserted into the specified document.
+ */
+ public abstract Node importNode(Document doc, Node externalNode, boolean deep);
+
+ /**
+ * @param element The DOM element whose attribute names are returned.
+ * @return The names of DOM attributes present on the given element.
+ */
+ public abstract JsArrayString getAttributeNames(Element element);
+
+ /**
+ * Searches for the first ancestor with the name <code>tagName</code> of the passed node, including the node itself.
+ * The search order starts with <code>node</code> and continued to the root of the tree.
+ *
+ * @param node the node to find ancestor for
+ * @param tagName the tag name to look for up in the DOM tree.
+ * @return the first node with name <code>tagName</code> found.
+ */
+ public Node getFirstAncestor(Node node, String tagName)
+ {
+ Node parent = node;
+ // While there is a parent
+ while (parent != null) {
+ // Check if this node is the needed element
+ if (parent.getNodeType() == Node.ELEMENT_NODE && parent.getNodeName().equalsIgnoreCase(tagName)) {
+ return parent;
+ }
+ parent = parent.getParentNode();
+ }
+ return null;
+ }
+
+ /**
+ * Searches for the first element descendant with the name <code>tagName</code>. Searching is done in a DFS order
+ * with node processing on first pass through them.
+ *
+ * @param node the node to start the search from
+ * @param tagName the name of the searched element
+ * @return the first descendant of type <code>tagName</code> of the passed node, in DFS order.
+ */
+ public Node getFirstDescendant(Node node, String tagName)
+ {
+ Iterator<Node> it = ((Document) node.getOwnerDocument()).getIterator(node);
+ while (it.hasNext()) {
+ Node currentNode = it.next();
+ if (currentNode.getNodeType() == Node.ELEMENT_NODE && currentNode.getNodeName().equalsIgnoreCase(tagName)) {
+ return currentNode;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Helps setting the inner HTML for an element, in a cross-browser manner, because IE seems to trim leading comments
+ * in the inner HTML.
+ *
+ * @param element element to set the inner HTML for
+ * @param html the HTML string to set
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3146
+ */
+ public abstract void setInnerHTML(Element element, String html);
+
+ /**
+ * @param alice A DOM node.
+ * @param bob A DOM node.
+ * @return The nearest common ancestor of the given nodes.
+ */
+ public Node getNearestCommonAncestor(Node alice, Node bob)
+ {
+ if (alice == bob) {
+ return alice;
+ }
+
+ // Build the chain of parents
+ List<Node> aliceAncestors = getAncestors(alice);
+ List<Node> bobAncestors = getAncestors(bob);
+
+ // Find where the parent chain differs
+ int count = Math.min(aliceAncestors.size(), bobAncestors.size());
+ int aliceIndex = aliceAncestors.size();
+ int bobIndex = bobAncestors.size();
+ Node ancestor = null;
+ while (count-- > 0 && aliceAncestors.get(--aliceIndex) == bobAncestors.get(--bobIndex)) {
+ ancestor = aliceAncestors.get(aliceIndex);
+ }
+ return ancestor;
+ }
+
+ /**
+ * @param node a DOM node
+ * @return the list of ancestors of the given node, starting with it
+ */
+ public List<Node> getAncestors(Node node)
+ {
+ if (node == null) {
+ return Collections.emptyList();
+ }
+ List<Node> ancestors = new ArrayList<Node>();
+ Node ancestor = node;
+ do {
+ ancestors.add(ancestor);
+ ancestor = ancestor.getParentNode();
+ } while (ancestor != null);
+ return ancestors;
+ }
+
+ /**
+ * Clones the contents of the given node. If node type is text, CDATA or comment then only the data between
+ * startOffset (including) and endOffset is kept. If node type is element then only the child nodes with indexes
+ * between startOffset (including) and endOffset are included in the document fragment returned.
+ *
+ * @param node The DOM node whose contents will be cloned.
+ * @param startOffset the index of the first child to clone or the first character to include in the cloned
+ * contents.
+ * @param endOffset specifies where the cloned contents end.
+ * @return the cloned contents of the given node, between start offset and end offset.
+ */
+ public DocumentFragment cloneNodeContents(Node node, int startOffset, int endOffset)
+ {
+ DocumentFragment contents = ((Document) node.getOwnerDocument()).createDocumentFragment();
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ if (startOffset < endOffset) {
+ Node clone = node.cloneNode(false);
+ clone.setNodeValue(node.getNodeValue().substring(startOffset, endOffset));
+ contents.appendChild(clone);
+ }
+ break;
+ case Node.ELEMENT_NODE:
+ for (int i = startOffset; i < endOffset; i++) {
+ contents.appendChild(node.getChildNodes().getItem(i).cloneNode(true));
+ }
+ break;
+ default:
+ // ignore
+ }
+ return contents;
+ }
+
+ /**
+ * Clones the given DOM node, keeping only the contents between start and end offset. If node type is text, CDATA or
+ * comment then both offsets represent character indexes. Otherwise they represent child indexes.
+ *
+ * @param node The DOM node to be cloned.
+ * @param startOffset specifies where to start the cloning.
+ * @param endOffset specifies where to end the cloning.
+ * @return A clone of the given node, containing only the contents between start and end offset.
+ */
+ public Node cloneNode(Node node, int startOffset, int endOffset)
+ {
+ Node clone = node.cloneNode(false);
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ clone.setNodeValue(node.getNodeValue().substring(startOffset, endOffset));
+ return clone;
+ case Node.ELEMENT_NODE:
+ for (int i = startOffset; i < endOffset; i++) {
+ clone.appendChild(node.getChildNodes().getItem(i).cloneNode(true));
+ }
+ return clone;
+ default:
+ throw new IllegalArgumentException(UNSUPPORTED_NODE_TYPE);
+ }
+ }
+
+ /**
+ * @param node A DOM node.
+ * @return the number of characters if the given node is a text, a CDATA section or a comment. Otherwise the
+ * returned value is the number of child nodes.
+ */
+ public int getLength(Node node)
+ {
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ return node.getNodeValue().length();
+ default:
+ return node.getChildNodes().getLength();
+ }
+ }
+
+ /**
+ * Clones the left or right side of the subtree rooted in the given node.
+ *
+ * @param node The root of the subtree whose left or right side will be cloned.
+ * @param offset Marks the boundary between the left and the right subtrees. It can be either a character index or a
+ * child index, depending on the type of the given node.
+ * @param left Specifies which of the subtrees to be cloned.
+ * @return The clone of the specified subtree.
+ */
+ public Node cloneNode(Node node, int offset, boolean left)
+ {
+ return left ? cloneNode(node, 0, offset) : cloneNode(node, offset, getLength(node));
+ }
+
+ /**
+ * Clones the node specified by its parent and its descendant, including only the left or right part of the tree
+ * whose separator is the path from the given descendant to the parent of the cloned node.
+ *
+ * @param parent The parent of the cloned node.
+ * @param descendant A descendant of the cloned node.
+ * @param offset The offset within the given descendant. It can be either a character index or a child index
+ * depending on the descendant node type.
+ * @param left Specifies which subtree to be cloned. Left and right subtrees are delimited by the path from the
+ * given descendant to the parent of the cloned node.
+ * @return The clone of the specified subtree.
+ */
+ public Node cloneNode(Node parent, Node descendant, int offset, boolean left)
+ {
+ int delta = left ? 0 : 1;
+ int index = getNodeIndex(descendant) + delta;
+ Node clone = cloneNode(descendant, offset, left);
+ Node node = descendant.getParentNode();
+ while (node != parent) {
+ Node child = clone;
+ clone = cloneNode(node, index, left);
+ if (left || clone.getFirstChild() == null) {
+ clone.appendChild(child);
+ } else {
+ clone.insertBefore(child, clone.getFirstChild());
+ }
+ index = getNodeIndex(node) + delta;
+ node = node.getParentNode();
+ }
+ return clone;
+ }
+
+ /**
+ * @param parent the parent node of the retrieved child
+ * @param descendant a descendant of the retrieved child
+ * @return the child of the given parent, which has the specified descendant
+ */
+ public Node getChild(Node parent, Node descendant)
+ {
+ Node child = descendant;
+ while (child != null && child.getParentNode() != parent) {
+ child = child.getParentNode();
+ }
+ return child;
+ }
+
+ /**
+ * Inserts the given child node after the reference node.
+ *
+ * @param newChild The child node to be inserted.
+ * @param refChild The reference node.
+ */
+ public void insertAfter(Node newChild, Node refChild)
+ {
+ if (refChild.getNextSibling() != null) {
+ refChild.getParentNode().insertBefore(newChild, refChild.getNextSibling());
+ } else {
+ refChild.getParentNode().appendChild(newChild);
+ }
+ }
+
+ /**
+ * Deletes the contents of the given node between the specified offsets. If node type is text, CDATA or comment then
+ * only the data between startOffset (including) and endOffset is deleted. If node type is element then only the
+ * child nodes with indexes between startOffset (including) and endOffset are deleted.
+ *
+ * @param node The DOM node whose contents will be deleted.
+ * @param startOffset the index of the first child or the first character to delete, depending on node type.
+ * @param endOffset specifies where to stop deleting content.
+ */
+ public void deleteNodeContents(Node node, int startOffset, int endOffset)
+ {
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ if (startOffset < endOffset) {
+ node.setNodeValue(node.getNodeValue().substring(0, startOffset)
+ + node.getNodeValue().substring(endOffset));
+ }
+ break;
+ case Node.ELEMENT_NODE:
+ for (int i = startOffset; i < endOffset; i++) {
+ node.removeChild(node.getChildNodes().getItem(startOffset));
+ }
+ break;
+ default:
+ // ignore
+ }
+ }
+
+ /**
+ * Deletes the left or right side of the subtree rooted in the given node.
+ *
+ * @param node The root of the subtree whose left or right side will be deleted.
+ * @param offset Marks the boundary between the left and the right subtrees. It can be either a character index or a
+ * child index, depending on the type of the given node.
+ * @param left Specifies which of the subtrees to be deleted.
+ */
+ public void deleteNodeContents(Node node, int offset, boolean left)
+ {
+ if (left) {
+ deleteNodeContents(node, 0, offset);
+ } else {
+ deleteNodeContents(node, offset, getLength(node));
+ }
+ }
+
+ /**
+ * Deletes left or right siblings of the given node.
+ *
+ * @param node The DOM node whose left or right siblings will be deleted.
+ * @param left Specifies which siblings to delete.
+ */
+ public void deleteSiblings(Node node, boolean left)
+ {
+ Node sibling = left ? node.getPreviousSibling() : node.getNextSibling();
+ while (sibling != null) {
+ node.getParentNode().removeChild(sibling);
+ sibling = left ? node.getPreviousSibling() : node.getNextSibling();
+ }
+ }
+
+ /**
+ * Given a subtree specified by its root parent and one of the inner nodes, this method deletes the left or right
+ * part delimited by the path from the given descendant (inner node) to the root parent.
+ *
+ * @param parent The parent node of the subtree's root.
+ * @param descendant An inner node within the specified subtree.
+ * @param offset The offset within the given descendant. It can be either a character index or a child index
+ * depending on the descendant node type.
+ * @param left Specifies which side of the subtree to be deleted. Left and right parts are delimited by the path
+ * from the given descendant to the parent of the subtree's root.
+ */
+ public void deleteNodeContents(Node parent, Node descendant, int offset, boolean left)
+ {
+ deleteNodeContents(descendant, offset, left);
+ Node node = descendant;
+ while (node.getParentNode() != parent) {
+ deleteSiblings(node, left);
+ node = node.getParentNode();
+ }
+ }
+
+ /**
+ * Splits the given DOM node at the specified offset.
+ *
+ * @param node The node to be split.
+ * @param offset Specifies where to split. It can be either a character index or a child index depending on node
+ * type.
+ * @return The node resulted after the split. It should be the next sibling of the given node.
+ */
+ public Node splitNode(Node node, int offset)
+ {
+ Node clone = node.cloneNode(false);
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ clone.setNodeValue(node.getNodeValue().substring(offset));
+ node.setNodeValue(node.getNodeValue().substring(0, offset));
+ break;
+ case Node.ELEMENT_NODE:
+ Element.as(clone).removeAttribute("id");
+ for (int i = node.getChildNodes().getLength(); i > offset; i--) {
+ clone.appendChild(node.getChildNodes().getItem(offset));
+ }
+ break;
+ default:
+ throw new IllegalArgumentException(UNSUPPORTED_NODE_TYPE);
+ }
+ insertAfter(clone, node);
+ return clone;
+ }
+
+ /**
+ * Given a subtree specified by its root parent and one of the inner nodes, this method splits the subtree by the
+ * path from the given descendant (inner node) to the root parent.
+ *
+ * @param parent The parent node of the subtree's root.
+ * @param descendant An inner node within the specified subtree.
+ * @param offset The offset within the given descendant. It can be either a character index or a child index
+ * depending on the descendant node type.
+ * @return The node resulted from splitting the descendant.
+ */
+ public Node splitNode(Node parent, Node descendant, int offset)
+ {
+ if (descendant == parent) {
+ return descendant;
+ }
+ Node nextLevelSibling = splitNode(descendant, offset);
+ Node node = descendant;
+ while (node.getParentNode() != parent) {
+ splitNode(node.getParentNode(), getNodeIndex(node) + 1);
+ node = node.getParentNode();
+ }
+ return nextLevelSibling;
+ }
+
+ /**
+ * Given a subtree specified by its root parent and one of the inner nodes, this method splits the subtree by the
+ * path from the given descendant (inner node) to the root parent. Additionally to what
+ * {@link #splitNode(Node, Node, int)}) does this method ensures that both subtrees are editable in design mode.
+ * This method is required because some browsers like Firefox prevent the user from placing the caret inside empty
+ * block elements such as paragraphs or headers. This empty block elements can be obtained by splitting at the
+ * beginning or at the end of such a block element.
+ *
+ * @param parent the parent node of the subtree's root
+ * @param descendant an inner node within the specified subtree
+ * @param offset the offset within the given descendant. It can be either a character index or a child index
+ * depending on the descendant node type.
+ * @return the node resulted from splitting the descendant
+ * @see #splitNode(Node, Node, int)
+ */
+ public Node splitHTMLNode(Node parent, Node descendant, int offset)
+ {
+ // By default we just do the split because browsers shouldn't require any further adjustments.
+ // Those who do require adjustments should overwrite this method.
+ return splitNode(parent, descendant, offset);
+ }
+
+ /**
+ * @param node A DOM node.
+ * @return true is the given node is an element that can have both in-line and block content.
+ */
+ public boolean isFlowContainer(Node node)
+ {
+ if (node.getNodeType() != Node.ELEMENT_NODE) {
+ return false;
+ }
+ String tagName = node.getNodeName().toLowerCase();
+ for (int i = 0; i < HTML_FLOW_CONTAINERS.length; i++) {
+ if (tagName.equals(HTML_FLOW_CONTAINERS[i])) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param innerNode A DOM node.
+ * @return The nearest ancestor of the given node that can contain both in-line and block content.
+ */
+ public Node getNearestFlowContainer(Node innerNode)
+ {
+ Node node = innerNode;
+ while (node != null && !isFlowContainer(node)) {
+ node = node.getParentNode();
+ }
+ return node;
+ }
+
+ /**
+ * Inserts a node at the specified index under the given parent.
+ *
+ * @param parent The parent node which will adopt the given node.
+ * @param newChild The node to be inserted.
+ * @param index Specifies the position inside the parent node where the new child should be placed.
+ */
+ public void insertAt(Node parent, Node newChild, int index)
+ {
+ int i = Math.max(0, index);
+ if (i >= parent.getChildNodes().getLength()) {
+ parent.appendChild(newChild);
+ } else {
+ parent.insertBefore(newChild, parent.getChildNodes().getItem(i));
+ }
+ }
+
+ /**
+ * Walks from the given node up to the root of the DOM tree as long as the ancestors represent in-line content.
+ * Returns the last node in the walk.
+ *
+ * @param node a DOM node
+ * @return the farthest ancestor of the given node that represents in-line content
+ */
+ public Node getFarthestInlineAncestor(Node node)
+ {
+ Node ancestor = node;
+ Node inlineAncestor = null;
+ while (ancestor != null && isInline(ancestor)) {
+ inlineAncestor = ancestor;
+ ancestor = ancestor.getParentNode();
+ }
+ return inlineAncestor;
+ }
+
+ /**
+ * @param range A DOM range.
+ * @return the first leaf node that is partially or entirely included in the given range.
+ */
+ public Node getFirstLeaf(Range range)
+ {
+ if (range.getStartContainer().hasChildNodes()) {
+ if (range.isCollapsed()) {
+ return null;
+ } else if (range.getStartOffset() >= range.getStartContainer().getChildNodes().getLength()) {
+ return getNextLeaf(range.getStartContainer());
+ } else {
+ return getFirstLeaf(range.getStartContainer().getChildNodes().getItem(range.getStartOffset()));
+ }
+ } else {
+ return range.getStartContainer();
+ }
+ }
+
+ /**
+ * @param range A DOM range.
+ * @return the last leaf node that is partially or entirely included in the given range.
+ */
+ public Node getLastLeaf(Range range)
+ {
+ if (range.getEndContainer().hasChildNodes()) {
+ if (range.isCollapsed()) {
+ return null;
+ } else if (range.getEndOffset() == 0) {
+ return getPreviousLeaf(range.getEndContainer());
+ } else {
+ return getLastLeaf(range.getEndContainer().getChildNodes().getItem(range.getEndOffset() - 1));
+ }
+ } else {
+ return range.getEndContainer();
+ }
+ }
+
+ /**
+ * Removes the given node from its parent.
+ *
+ * @param node A DOM node.
+ */
+ public void detach(Node node)
+ {
+ if (node != null && node.getParentNode() != null) {
+ node.getParentNode().removeChild(node);
+ }
+ }
+
+ /**
+ * @param node A DOM node
+ * @return The nearest block level ancestor of the given node.
+ */
+ public Node getNearestBlockContainer(Node node)
+ {
+ Node ancestor = DOMUtils.getInstance().getFarthestInlineAncestor(node);
+ if (ancestor == null) {
+ return node;
+ } else {
+ return ancestor.getParentNode();
+ }
+ }
+
+ /**
+ * Returns the value of the named attribute of the specified element. This method will be overwritten for internet
+ * explorer browsers to handle bug http://code.google.com/p/google-web-toolkit/issues/detail?id=3238 .
+ *
+ * @param element the element to get the attribute for
+ * @param name the name of the attribute to return
+ * @return the value of the attribute
+ */
+ public String getAttribute(Element element, String name)
+ {
+ return element.getAttribute(name);
+ }
+
+ /**
+ * Compares two points in a {@link Document}. Each point is specified by a DOM node and an offset within that node.
+ *
+ * @param alice first point's node
+ * @param aliceOffset first point's offset
+ * @param bob second point's node
+ * @param bobOffset second point's offset
+ * @return -1, 0 or 1 depending on whether the first point is respectively before, equal to, or after the second
+ * point
+ */
+ public short comparePoints(Node alice, int aliceOffset, Node bob, int bobOffset)
+ {
+ if (alice == bob) {
+ return (short) (aliceOffset < bobOffset ? -1 : aliceOffset > bobOffset ? 1 : 0);
+ }
+
+ // Build the chain of parents.
+ List<Node> aliceAncestors = getAncestors(alice);
+ List<Node> bobAncestors = getAncestors(bob);
+
+ // Test is the input nodes are disconnected.
+ int aliceIndex = aliceAncestors.size() - 1;
+ int bobIndex = bobAncestors.size() - 1;
+ if (aliceAncestors.get(aliceIndex) != bobAncestors.get(bobIndex)) {
+ throw new IllegalArgumentException();
+ }
+
+ // Find where the parent chain differs.
+ for (int count = Math.min(aliceIndex, bobIndex); count > 0; --count) {
+ Node aliceAncestor = aliceAncestors.get(--aliceIndex);
+ Node bobAncestor = bobAncestors.get(--bobIndex);
+ if (aliceAncestor != bobAncestor) {
+ return (short) (getNodeIndex(aliceAncestor) < getNodeIndex(bobAncestor) ? -1 : 1);
+ }
+ }
+
+ // The parent chains never differed, so one of the nodes is an ancestor of the other.
+ if (aliceIndex == 0) {
+ Node bobAncestor = bobAncestors.get(--bobIndex);
+ return (short) (aliceOffset <= getNodeIndex(bobAncestor) ? -1 : 1);
+ }
+
+ Node aliceAncestor = aliceAncestors.get(--aliceIndex);
+ return (short) (getNodeIndex(aliceAncestor) < bobOffset ? -1 : 1);
+ }
+
+ /**
+ * We need our own implementation because the one provided by GWT includes commented text in the output.
+ *
+ * @param element the element whose inner text to return
+ * @return the text between the start and end tags of the given element
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3275
+ */
+ public String getInnerText(Element element)
+ {
+ // To mimic IE's 'innerText' property in the W3C DOM, we need to recursively
+ // concatenate all child text nodes (depth first).
+ StringBuffer text = new StringBuffer();
+ Node child = element.getFirstChild();
+ while (child != null) {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ text.append(getInnerText((Element) child));
+ } else if (child.getNodeType() == Node.TEXT_NODE) {
+ text.append(child.getNodeValue());
+ }
+ child = child.getNextSibling();
+ }
+ return text.toString();
+ }
+
+ /**
+ * @param element a DOM element
+ * @param attrName a string representing the name of an attribute
+ * @return true is the given element has an attribute with the specified name, false otherwise
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=2852
+ */
+ public native boolean hasAttribute(Element element, String attrName)
+ /*-{
+ return element.hasAttribute(attrName);
+ }-*/;
+
+ /**
+ * Extracts the contents of the given node. If node type is text, CDATA or comment then only the data between
+ * startOffset (including) and endOffset is kept. If node type is element then only the child nodes with indexes
+ * between startOffset (including) and endOffset are included in the document fragment returned.
+ *
+ * @param node the DOM node whose contents will be extracted
+ * @param startOffset the index of the first child to extract or the first character to include in the extracted
+ * contents
+ * @param endOffset specifies where the extracted contents end
+ * @return the extracted contents of the given node, between start offset and end offset
+ */
+ public DocumentFragment extractNodeContents(Node node, int startOffset, int endOffset)
+ {
+ DocumentFragment contents = ((Document) node.getOwnerDocument()).createDocumentFragment();
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ if (startOffset < endOffset) {
+ Node clone = node.cloneNode(false);
+ clone.setNodeValue(node.getNodeValue().substring(startOffset, endOffset));
+ contents.appendChild(clone);
+ node.setNodeValue(node.getNodeValue().substring(0, startOffset)
+ + node.getNodeValue().substring(endOffset));
+ }
+ break;
+ case Node.ELEMENT_NODE:
+ for (int i = startOffset; i < endOffset; i++) {
+ contents.appendChild(node.getChildNodes().getItem(startOffset));
+ }
+ break;
+ default:
+ // ignore
+ }
+ return contents;
+ }
+
+ /**
+ * Extracts the node specified by its parent and its descendant, including only the left or right part of the tree
+ * whose separator is the path from the given descendant to the parent of the extracted node.
+ *
+ * @param parent the parent of the extracted node
+ * @param descendant a descendant of the extracted node
+ * @param offset the offset within the given descendant. It can be either a character index or a child index
+ * depending on the descendant node type.
+ * @param left specifies which subtree to be extracted. Left and right subtrees are delimited by the path from the
+ * given descendant to the parent of the extracted node.
+ * @return the extracted subtree
+ */
+ public Node extractNode(Node parent, Node descendant, int offset, boolean left)
+ {
+ int delta = left ? 0 : 1;
+ int index = getNodeIndex(descendant) + delta;
+ Node clone = extractNode(descendant, offset, left);
+ Node node = descendant.getParentNode();
+ while (node != parent) {
+ Node child = clone;
+ clone = extractNode(node, index, left);
+ if (left || clone.getFirstChild() == null) {
+ clone.appendChild(child);
+ } else {
+ clone.insertBefore(child, clone.getFirstChild());
+ }
+ index = getNodeIndex(node) + delta;
+ node = node.getParentNode();
+ }
+ return clone;
+ }
+
+ /**
+ * Extracts the left or right side of the subtree rooted in the given node.
+ *
+ * @param node the root of the subtree whose left or right side will be extracted
+ * @param offset marks the boundary between the left and the right subtrees. It can be either a character index or a
+ * child index, depending on the type of the given node.
+ * @param left specifies which of the subtrees to be extracted
+ * @return the extracted subtree
+ */
+ public Node extractNode(Node node, int offset, boolean left)
+ {
+ return left ? extractNode(node, 0, offset) : extractNode(node, offset, getLength(node));
+ }
+
+ /**
+ * Extracts the given DOM node, keeping only the contents between start and end offset. If node type is text, CDATA
+ * or comment then both offsets represent character indexes. Otherwise they represent child indexes.
+ *
+ * @param node the DOM node to be extracted
+ * @param startOffset specifies where to start the extraction
+ * @param endOffset specifies where to end the extraction
+ * @return a shallow clone of the given node, containing only the contents between start and end offset, which have
+ * been extracted from the input node
+ */
+ public Node extractNode(Node node, int startOffset, int endOffset)
+ {
+ Node clone = node.cloneNode(false);
+ switch (node.getNodeType()) {
+ case CDATA_NODE:
+ case COMMENT_NODE:
+ case Node.TEXT_NODE:
+ clone.setNodeValue(node.getNodeValue().substring(startOffset, endOffset));
+ node.setNodeValue(node.getNodeValue().substring(0, startOffset)
+ + node.getNodeValue().substring(endOffset));
+ return clone;
+ case Node.ELEMENT_NODE:
+ for (int i = startOffset; i < endOffset; i++) {
+ clone.appendChild(node.getChildNodes().getItem(startOffset));
+ }
+ return clone;
+ default:
+ throw new IllegalArgumentException(UNSUPPORTED_NODE_TYPE);
+ }
+ }
+
+ /**
+ * @param range a DOM range
+ * @return the node that follows after the end point of the given range, in a depth-first pre-order search
+ */
+ public Node getNextNode(Range range)
+ {
+ Node node = range.getEndContainer();
+ if (node.hasChildNodes() && range.getEndOffset() < node.getChildNodes().getLength()) {
+ return node.getChildNodes().getItem(range.getEndOffset());
+ }
+ while (node != null && node.getNextSibling() == null) {
+ node = node.getParentNode();
+ }
+ return node == null ? null : node.getNextSibling();
+ }
+
+ /**
+ * @param range a DOM range
+ * @return the node that precedes the start point of the given range, in a depth-first pre-order search
+ */
+ public Node getPreviousNode(Range range)
+ {
+ Node node = range.getStartContainer();
+ if (node.hasChildNodes() && range.getStartOffset() > 0) {
+ return node.getChildNodes().getItem(range.getStartOffset() - 1);
+ }
+ while (node != null && node.getPreviousSibling() == null) {
+ node = node.getParentNode();
+ }
+ return node == null ? null : node.getPreviousSibling();
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DepthFirstPreOrderIterator.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DepthFirstPreOrderIterator.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DepthFirstPreOrderIterator.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,103 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * Iterator for the depth-first pre-order strategy, starting in a specified node.
+ *
+ * @see http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html#Traversal-D…
+ * @version $Id$
+ */
+public class DepthFirstPreOrderIterator implements Iterator<Node>
+{
+ /**
+ * The current position of the iterator.
+ */
+ private Node currentNode;
+
+ /**
+ * The node where the iteration has started (the root of the subtree which we're iterating).
+ */
+ private Node startNode;
+
+ /**
+ * Creates an iterator for the subtree rooted in startNode.
+ *
+ * @param startNode root of the subtree to iterate through.
+ */
+ public DepthFirstPreOrderIterator(Node startNode)
+ {
+ this.startNode = startNode;
+ this.currentNode = startNode;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean hasNext()
+ {
+ return this.currentNode != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Node next()
+ {
+ // return the currentNode
+ Node nodeToReturn = this.currentNode;
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ // compute the next node
+ // try to go down
+ if (currentNode.getFirstChild() != null) {
+ this.currentNode = currentNode.getFirstChild();
+ } else {
+ // try to go right: from this node or any of its ancestors, until we haven't reached the startNode
+ Node ancestor = currentNode;
+ while (ancestor != startNode) {
+ if (ancestor.getNextSibling() != null) {
+ this.currentNode = ancestor.getNextSibling();
+ break;
+ }
+ ancestor = ancestor.getParentNode();
+ }
+ // if we got back to the root searching up, then we have no more options
+ if (ancestor == startNode) {
+ this.currentNode = null;
+ }
+ }
+ return nodeToReturn;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Document.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Document.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Document.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,411 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import java.util.Iterator;
+
+import com.google.gwt.dom.client.BRElement;
+import com.google.gwt.dom.client.BaseElement;
+import com.google.gwt.dom.client.ButtonElement;
+import com.google.gwt.dom.client.DivElement;
+import com.google.gwt.dom.client.HRElement;
+import com.google.gwt.dom.client.ImageElement;
+import com.google.gwt.dom.client.LIElement;
+import com.google.gwt.dom.client.LinkElement;
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.ParagraphElement;
+import com.google.gwt.dom.client.ScriptElement;
+import com.google.gwt.dom.client.SpanElement;
+
+/**
+ * Extends the document implementation provided by GWT to add support for multi-window, selection and range.
+ *
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=2772
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3006
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3053
+ * @version $Id$
+ */
+public class Document extends com.google.gwt.dom.client.Document
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected Document()
+ {
+ super();
+ }
+
+ /**
+ * Creates a new element.<br/>
+ * We've added this method because at the time of writing {@link com.google.gwt.dom.client.Document} doesn't offer
+ * support for multi-window. This means that currently, using GWT's API we can create elements only within the
+ * document of the host page. Since {@link com.google.gwt.user.client.ui.RichTextArea} is based on an in-line frame
+ * which has its own window and document we have to be able to create elements within the edited document.
+ *
+ * @param tagName the tag name of the element to be created
+ * @return the newly created element
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=2772
+ */
+ public final native Element xCreateElement(String tagName)
+ /*-{
+ return this.createElement(tagName);
+ }-*/;
+
+ /**
+ * @param data contains the data to be added to the comment.
+ * @return the created comment node.
+ */
+ public final native Node createComment(String data)
+ /*-{
+ return this.createComment(data);
+ }-*/;
+
+ /**
+ * Creates a <link> element.
+ *
+ * @return the newly created element
+ */
+ public final LinkElement xCreateLinkElement()
+ {
+ return xCreateElement("link").cast();
+ }
+
+ /**
+ * Creates a <script> element.
+ *
+ * @return the newly created element
+ */
+ public final ScriptElement xCreateScriptElement()
+ {
+ return xCreateElement("script").cast();
+ }
+
+ /**
+ * Creates a <br> element.
+ *
+ * @return the newly created element
+ */
+ public final BRElement xCreateBRElement()
+ {
+ return xCreateElement("br").cast();
+ }
+
+ /**
+ * Creates a <p> element.
+ *
+ * @return the newly created element
+ */
+ public final ParagraphElement xCreatePElement()
+ {
+ return xCreateElement("p").cast();
+ }
+
+ /**
+ * Creates a <div> element.
+ *
+ * @return the newly created element.
+ */
+ public final DivElement xCreateDivElement()
+ {
+ return xCreateElement("div").cast();
+ }
+
+ /**
+ * Creates a <span> element.
+ *
+ * @return the newly created element.
+ */
+ public final SpanElement xCreateSpanElement()
+ {
+ return xCreateElement("span").cast();
+ }
+
+ /**
+ * @return a new base element
+ */
+ public final BaseElement xCreateBaseElement()
+ {
+ return xCreateElement("base").cast();
+ }
+
+ /**
+ * Creates a <hr> element.
+ *
+ * @return the newly create element.
+ */
+ public final HRElement xCreateHRElement()
+ {
+ return xCreateElement("hr").cast();
+ }
+
+ /**
+ * Creates a <img> element.
+ *
+ * @return the newly create element.
+ */
+ public final ImageElement xCreateImageElement()
+ {
+ return xCreateElement("img").cast();
+ }
+
+ /**
+ * Creates a <li> element.
+ *
+ * @return the newly created element.
+ */
+ public final LIElement xCreateLIElement()
+ {
+ return xCreateElement("li").cast();
+ }
+
+ /**
+ * Creates a <button> element.
+ *
+ * @return the newly create element.
+ */
+ public final ButtonElement xCreateButtonElement()
+ {
+ return xCreateElement("button").cast();
+ }
+
+ /**
+ * We've added this method because at the time of writing {@link com.google.gwt.dom.client.Document} doesn't offer
+ * support for retrieving the current selection.
+ *
+ * @return The selection object associated with this document.
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3053
+ */
+ public final Selection getSelection()
+ {
+ return SelectionManager.INSTANCE.getSelection(this);
+ }
+
+ /**
+ * We've added this method because at the time of writing {@link com.google.gwt.dom.client.Document} doesn't offer
+ * support for creating a range.
+ *
+ * @return A new range for this document.
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3053
+ */
+ public final Range createRange()
+ {
+ return RangeFactory.INSTANCE.createRange(this);
+ }
+
+ /**
+ * Creates a copy of a node from an external document that can be inserted into this document.<br/>
+ * We've added this method because at time of writing
+ * {@link com.google.gwt.dom.client.Document#importNode(Node, boolean)} is not well implemented.
+ *
+ * @param externalNode The node from another document to be imported.
+ * @param deep Indicates whether the children of the given node need to be imported.
+ * @return a copy of the given node that can be inserted into this document.
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3006
+ */
+ public final Node xImportNode(Node externalNode, boolean deep)
+ {
+ return DOMUtils.getInstance().importNode(this, externalNode, deep);
+ }
+
+ /**
+ * Returns an iterator for the depth-first pre-order strategy, starting in <code>startNode</code>.
+ *
+ * @param startNode node to start iteration from
+ * @return the depth-first pre-order iterator
+ * @see {@link DepthFirstPreOrderIterator}
+ * @see http://www.w3.org/TR/DOM-Level-2-Traversal-Range/traversal.html#Traversal-D…
+ */
+ public final Iterator<Node> getIterator(Node startNode)
+ {
+ return new DepthFirstPreOrderIterator(startNode);
+ }
+
+ /**
+ * When an HTML document has been switched to designMode, the document object exposes the execCommand method which
+ * allows one to run commands to manipulate the contents of the editable region. Most commands affect the document's
+ * selection (bold, italics, etc), while others insert new elements (adding a link) or affect an entire line
+ * (indenting). When using contentEditable, calling execCommand will affect the currently active editable element.
+ *
+ * @param command The name of the command.
+ * @param parameter Some commands (such as insertimage) require an extra value argument (the image's url). Pass an
+ * argument of null if no argument is needed.
+ * @return true if the specified command has been successfully executed.
+ */
+ public final native boolean execCommand(String command, String parameter)
+ /*-{
+ try{
+ return this.execCommand(command, false, parameter);
+ } catch(e) {
+ return false;
+ }
+ }-*/;
+
+ /**
+ * @param command The name of the command to query.
+ * @return The current value of the current range for the given command. If a command value has not been explicitly
+ * set then it returns null.
+ */
+ public final native String queryCommandValue(String command)
+ /*-{
+ try{
+ return this.queryCommandValue(command);
+ } catch(e) {
+ return null;
+ }
+ }-*/;
+
+ /**
+ * @param command The name of the command to query.
+ * @return true if the given command can be executed on the current range.
+ */
+ public final native boolean queryCommandEnabled(String command)
+ /*-{
+ try{
+ return this.queryCommandEnabled(command);
+ } catch(e) {
+ return false;
+ }
+ }-*/;
+
+ /**
+ * @param command The name of the command to query.
+ * @return true if the given command has been executed on the current range.
+ */
+ public final native boolean queryCommandState(String command)
+ /*-{
+ try{
+ return this.queryCommandState(command);
+ } catch(e) {
+ return false;
+ }
+ }-*/;
+
+ /**
+ * @param command The name of the command to query.
+ * @return true if the given command is supported by the current browser.
+ */
+ public final native boolean queryCommandSupported(String command)
+ /*-{
+ try{
+ return this.queryCommandSupported(command);
+ } catch(e) {
+ return true;
+ }
+ }-*/;
+
+ /**
+ * @return the document element.
+ */
+ public final native Element getDocumentElement()
+ /*-{
+ return this.documentElement;
+ }-*/;
+
+ /**
+ * Creates an empty document fragment.<br/>
+ * A DocumentFragment is a minimal document object that has no parent. It supports the following DOM 2 methods:
+ * appendChild, cloneNode, hasAttributes, hasChildNodes, insertBefore, normalize, removeChild, replaceChild.<br/>
+ * It also supports the following DOM 2 properties: attributes, childNodes, firstChild, lastChild, localName,
+ * namespaceURI, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentNode, prefix, previousSibling,
+ * textContent.<br/>
+ * Various other methods can take a document fragment as an argument (e.g. Node interface methods such as
+ * appendChild and insertBefore), in which case the children of the fragment are appended or inserted, not the
+ * fragment itself.
+ *
+ * @return The newly created document fragment.
+ */
+ public final native DocumentFragment createDocumentFragment()
+ /*-{
+ return this.createDocumentFragment();
+ }-*/;
+
+ /**
+ * Opens a document stream for writing.
+ */
+ public final native void open()
+ /*-{
+ this.open();
+ }-*/;
+
+ /**
+ * Closes a document stream for writing.
+ */
+ public final native void close()
+ /*-{
+ this.close();
+ }-*/;
+
+ /**
+ * Writes a string of text to a document stream opened by {@link #open()}.
+ *
+ * @param html a string containing the HTML to be written to the document.
+ */
+ public final native void write(String html)
+ /*-{
+ this.write(html);
+ }-*/;
+
+ /**
+ * Registers a new listener for changes to <code>innerHTML</code> property of element within this document.
+ *
+ * @param listener The listener to be registered.
+ */
+ public final native void addInnerHTMLListener(InnerHTMLListener listener)
+ /*-{
+ if (!this.innerHTMLListeners) {
+ this.innerHTMLListeners = [];
+ }
+ this.innerHTMLListeners.push(listener);
+ }-*/;
+
+ /**
+ * Stop sending notifications to the given listener when the <code>innerHTML</code> property, of some element
+ * included in this document, changes.
+ *
+ * @param listener The listener to be unregistered.
+ */
+ public final native void removeInnerHTMLListener(InnerHTMLListener listener)
+ /*-{
+ if (this.innerHTMLListeners) {
+ for (var i = 0; i < this.innerHTMLListeners.length; i++) {
+ if (this.innerHTMLListeners[i] == listener) {
+ this.innerHTMLListeners.splice(i, 1);
+ }
+ }
+ }
+ }-*/;
+
+ /**
+ * Notify all listeners of the change to the given element's <code>innerHTML</code> property.<br/>
+ * NOTE: Keep this method accessible only from within this package because only {@link Element} should call it.
+ *
+ * @param element The element whose <code>innerHTML</code> property has changed.
+ */
+ final native void fireInnerHTMLChange(Element element)
+ /*-{
+ if (this.innerHTMLListeners) {
+ for (var i = 0; i < this.innerHTMLListeners.length; i++) {
+ this.innerHTMLListeners[i].
+ @com.xpn.xwiki.wysiwyg.client.dom.InnerHTMLListener::onInnerHTMLChange(Lcom/xpn/xwiki/wysiwyg/client/dom/Element;)
+ (element);
+ }
+ }
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DocumentFragment.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DocumentFragment.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/DocumentFragment.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,67 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * A fragment of a DOM document.<br/>
+ * We've added this class because at the time of writing GWT doesn't offer a similar implementation.
+ *
+ * @version $Id$
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=2955
+ */
+public final class DocumentFragment extends Node
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected DocumentFragment()
+ {
+ }
+
+ /**
+ * @return the HTML serialization of this document fragment
+ */
+ public String getInnerHTML()
+ {
+ Element container = ((Document) getOwnerDocument()).xCreateDivElement().cast();
+ // We avoid attaching a clone to limit the memory used.
+ container.appendChild(this);
+ String innerHTML = container.xGetInnerHTML();
+ // We restore the document fragment.
+ appendChild(container.extractContents());
+ return innerHTML;
+ }
+
+ /**
+ * @return the text, without mark-up, found within this document fragment
+ */
+ public String getInnerText()
+ {
+ Element container = ((Document) getOwnerDocument()).xCreateDivElement().cast();
+ // We avoid attaching a clone to limit the memory used.
+ container.appendChild(this);
+ String innerText = container.xGetInnerText();
+ // We restore the document fragment.
+ appendChild(container.extractContents());
+ return innerText;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Element.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Element.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Element.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,296 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.dom.client.Node;
+
+/**
+ * Extends the element implementation provided by GWT to add useful methods. All of them should be removed as soon as
+ * they make their way into GWT's API.
+ *
+ * @version $Id$
+ */
+public class Element extends com.google.gwt.dom.client.Element
+{
+ /**
+ * The text used in an element's meta data as a place holder for that element's outer HTML.
+ */
+ public static final String INNER_HTML_PLACEHOLDER = "com.xpn.xwiki.wysiwyg.client.dom.Element#placeholder";
+
+ /**
+ * The name of the JavaScript property storing the reference to the meta data.<br/>
+ * NOTE: We can't use the same name as for {@link #META_DATA_ATTR} because IE stores attribute values as JavaScript
+ * properties of DOM element objects.
+ */
+ public static final String META_DATA_REF = "metaDataRef";
+
+ /**
+ * The name of the DOM attribute storing the HTML of the meta data. This HTML is used to recreate the meta data when
+ * an element is cloned or copy&pasted.
+ */
+ public static final String META_DATA_ATTR = "metadata";
+
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected Element()
+ {
+ super();
+ }
+
+ /**
+ * Casts a {@link Node} to an instance of this type.
+ *
+ * @param node the instance to be casted to this type.
+ * @return the given object as an instance of {@link Element}.
+ */
+ public static Element as(Node node)
+ {
+ return (Element) com.google.gwt.dom.client.Element.as(node);
+ }
+
+ /**
+ * @return The names of DOM attributes present on this element.
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3054
+ */
+ public final JsArrayString getAttributeNames()
+ {
+ return DOMUtils.getInstance().getAttributeNames(this);
+ }
+
+ /**
+ * Returns the value of the specified CSS property for this element as it is computed by the browser before the
+ * element is displayed. The CSS property doesn't have to be applied explicitly or directly on this element. It can
+ * be inherited or assumed by default on this element.
+ *
+ * @param propertyName the name of the CSS property whose value is returned.
+ * @return the computed value of the specified CSS property for this element.
+ */
+ public final String getComputedStyleProperty(String propertyName)
+ {
+ return DOMUtils.getInstance().getComputedStyleProperty(this, propertyName);
+ }
+
+ /**
+ * Set inner HTML in cross browser manner and notify the owner document.
+ *
+ * @param html the html to set.
+ * @see {@link DOMUtils#setInnerHTML(Element, String)}
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3146
+ */
+ public final void xSetInnerHTML(String html)
+ {
+ DOMUtils.getInstance().setInnerHTML(this, html);
+ ((Document) getOwnerDocument()).fireInnerHTMLChange(this);
+ }
+
+ /**
+ * @return the extended inner HTML of this element, which includes meta data.
+ * @see #getInnerHTML()
+ */
+ public final String xGetInnerHTML()
+ {
+ if (getFirstChildElement() == null) {
+ return getInnerHTML();
+ } else {
+ Element container = ((Document) getOwnerDocument()).xCreateDivElement().cast();
+ StringBuffer innerHTML = new StringBuffer();
+ Node child = getFirstChild();
+ do {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ innerHTML.append(Element.as(child).xGetString());
+ } else {
+ container.appendChild(child.cloneNode(true));
+ innerHTML.append(container.getInnerHTML());
+ container.removeChild(container.getLastChild());
+ }
+ child = child.getNextSibling();
+ } while (child != null);
+ return innerHTML.toString();
+ }
+ }
+
+ /**
+ * @return the extended outer HTML of this element, which includes meta data.
+ * @see #getString()
+ */
+ public final String xGetString()
+ {
+ String outerHTML;
+ // We need to remove the meta data attribute on serialization
+ String metaDataHTML = null;
+ if (hasAttribute(META_DATA_ATTR)) {
+ metaDataHTML = xGetAttribute(META_DATA_ATTR);
+ // Remove the attribute from this element
+ removeAttribute(META_DATA_ATTR);
+ }
+ if (hasChildNodes()) {
+ Element clone = Element.as(cloneNode(false));
+ clone.appendChild(getOwnerDocument().createTextNode(INNER_HTML_PLACEHOLDER));
+ outerHTML = clone.getString();
+ outerHTML = outerHTML.replace(INNER_HTML_PLACEHOLDER, xGetInnerHTML());
+ } else {
+ outerHTML = getString();
+ }
+ // Some browsers, including IE, format the HTML returned by innerHTML and outerHTML properties by adding new
+ // lines or tabs. We have to remove leading and trailing white spaces from the outerHTML because when we reset
+ // the innerHTML or outerHTML properties these white spaces can generate additional text nodes which can, for
+ // instance, mess up the History mechanism.
+ outerHTML = outerHTML.trim();
+ if (metaDataHTML != null) {
+ // Put the meta data attribute back
+ setAttribute(META_DATA_ATTR, metaDataHTML);
+ outerHTML = metaDataHTML.replace(INNER_HTML_PLACEHOLDER, outerHTML);
+ }
+ return outerHTML;
+ }
+
+ /**
+ * Places all the children of this element in a document fragment and returns it.<br/>
+ * NOTE: The element will remain empty after this method call.
+ *
+ * @return A document fragment containing all the descendants of this element.
+ */
+ public final DocumentFragment extractContents()
+ {
+ DocumentFragment contents = ((Document) getOwnerDocument()).createDocumentFragment();
+ Node child = getFirstChild();
+ while (child != null) {
+ contents.appendChild(child);
+ child = getFirstChild();
+ }
+ return contents;
+ }
+
+ /**
+ * Replaces this element with its child nodes. In other words, all the child nodes of this element are moved to its
+ * parent node and the element is removed from its parent.
+ */
+ public final void unwrap()
+ {
+ if (getParentNode() == null || getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
+ return;
+ }
+ getParentNode().replaceChild(extractContents(), this);
+ }
+
+ /**
+ * Wraps the passed node and takes its place in its parent. In other words, it adds the passed element as a child of
+ * this element and replaces it in its parent.
+ *
+ * @param node the node to wrap
+ */
+ public final void wrap(Node node)
+ {
+ if (node.getParentNode() == null) {
+ return;
+ }
+ node.getParentNode().replaceChild(this, node);
+ appendChild(node);
+ }
+
+ /**
+ * @return the meta data associated with this element.
+ */
+ public final DocumentFragment getMetaData()
+ {
+ DocumentFragment metaData = (DocumentFragment) ((JavaScriptObject) cast()).get(META_DATA_REF);
+ if (metaData == null) {
+ // There's no saved reference to the meta data.
+ // Test if this element has stored meta data.
+ if (hasAttribute(META_DATA_ATTR)) {
+ // This element could be the result of node cloning or copy&paste.
+ // Let's update the cached meta data reference.
+ Element container = (Element) getOwnerDocument().createDivElement().cast();
+ container.xSetInnerHTML(xGetAttribute(META_DATA_ATTR));
+ metaData = container.extractContents();
+ ((JavaScriptObject) cast()).set(META_DATA_REF, metaData);
+ }
+ }
+ return metaData;
+ };
+
+ /**
+ * Sets the meta data of this element.
+ *
+ * @param metaData a document fragment with additional information regarding this element.
+ */
+ public final void setMetaData(DocumentFragment metaData)
+ {
+ // Save a reference to the meta data for fast retrieval.
+ ((JavaScriptObject) cast()).set(META_DATA_REF, metaData);
+ if (metaData != null) {
+ // We have to serialize the meta data and store it using a custom attribute to avoid loosing the meta data
+ // over node cloning or copy&paste. The custom attribute used for storing the meta data should be filtered
+ // when getting the outer HTML.
+ setAttribute(META_DATA_ATTR, metaData.getInnerHTML());
+ } else {
+ removeAttribute(META_DATA_ATTR);
+ }
+ };
+
+ /**
+ * @return true if HTML Strict DTD specifies that this element must be empty.
+ */
+ public final boolean mustBeEmpty()
+ {
+ for (int i = 0; i < DOMUtils.HTML_EMPTY_TAGS.length; i++) {
+ if (DOMUtils.HTML_EMPTY_TAGS[i].equalsIgnoreCase(getTagName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Get the value for the specified attribute in cross browser manner.
+ *
+ * @param name the name of the attribute
+ * @return the value of the attribute
+ * @see DOMUtils#getAttribute(Element, String)
+ */
+ public final String xGetAttribute(String name)
+ {
+ return DOMUtils.getInstance().getAttribute(this, name);
+ }
+
+ /**
+ * We need this method because {@link #getInnerText()} includes commented text in the output.
+ *
+ * @return the text between the start and end tags of this element
+ * @see #getInnerText()
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3275
+ */
+ public final String xGetInnerText()
+ {
+ return DOMUtils.getInstance().getInnerText(this);
+ }
+
+ /**
+ * @param attrName a string representing the name of an attribute
+ * @return true is this element has an attribute with the specified name, false otherwise
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=2852
+ */
+ public final boolean hasAttribute(String attrName)
+ {
+ return DOMUtils.getInstance().hasAttribute(this, attrName);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Event.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Event.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Event.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,63 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * DOM Event.
+ *
+ * @version $Id$
+ */
+public class Event extends com.google.gwt.user.client.Event
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected Event()
+ {
+ super();
+ }
+
+ /**
+ * @return true if this event was cancelled by calling {@link #xPreventDefault()}.
+ */
+ public final native boolean isCancelled()
+ /*-{
+ return !(!this.__cancelled);
+ }-*/;
+
+ /**
+ * Sets this event's cancelled state.
+ *
+ * @param cancelled specifies if this event should be cancelled or not.
+ */
+ protected final native void setCancelled(boolean cancelled)
+ /*-{
+ this.__cancelled = cancelled;
+ }-*/;
+
+ /**
+ * Cancel this event.
+ */
+ public final void xPreventDefault()
+ {
+ preventDefault();
+ setCancelled(true);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/InnerHTMLListener.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/InnerHTMLListener.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/InnerHTMLListener.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,36 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * Interface for listening to changes of the <code>innerHTML</code> property of a DOM element.
+ *
+ * @version $Id$
+ */
+public interface InnerHTMLListener
+{
+ /**
+ * Called whenever the <code>innerHTML</code> property, of an element within the document this listener has been
+ * registered to, changes.
+ *
+ * @param element The element whose <code>innerHTML</code> has changed.
+ */
+ void onInnerHTMLChange(Element element);
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/JavaScriptObject.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/JavaScriptObject.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/JavaScriptObject.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,82 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * Extends GWT JavaScriptObject to add a fromJson method. Usage : <code>
+ * public class MyCar extends JavaScriptObject {
+ * protected MyCar() {}
+ * public final native int getWheelNumber() / *-{ return this.wheelnb; }-* /;
+ * public final native String getColor() / *-{ return this.color; }-* /;
+ * }
+ *
+ * MyCar redcar = (MyCar) MyCar.fromJson("{ wheelnb: 4, color: 'red' }");
+ * redcar.getWheelNumber();
+ * redcar.getColor();
+ * </code>
+ *
+ * @see com.google.gwt.core.client.JavaScriptObject
+ * @version $Id$
+ */
+public class JavaScriptObject extends com.google.gwt.core.client.JavaScriptObject
+{
+ /**
+ * Default constructor. Overlay types always have protected, zero-arguments constructors.
+ */
+ protected JavaScriptObject()
+ {
+ }
+
+ /**
+ * Create a JavaScriptObject from a JSON string.
+ *
+ * @param input a valid JSON string.
+ * @return resulting JavaScriptObject
+ */
+ public static final native JavaScriptObject fromJson(String input)
+ /*-{
+ return eval('(' + input + ')')
+ }-*/;
+
+ /**
+ * Returns the reference stored in this JavaScript object for the given key.
+ *
+ * @param key the key whose value to return
+ * @return the value of the specified key
+ */
+ public final native Object get(String key)
+ /*-{
+ return this[key];
+ }-*/;
+
+ /**
+ * Saves the given reference in this JavaScript object using the specified key.
+ *
+ * @param key the string used for storing and retrieving the reference
+ * @param ref the object whose reference will be stored
+ * @return the previous reference associated with the given key
+ */
+ public final native Object set(String key, Object ref)
+ /*-{
+ var oldRef = this[key];
+ this[key] = ref;
+ return oldRef;
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Range.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Range.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Range.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,201 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * A contiguous fragment of a {@link Document} or {@link DocumentFragment} that can contain nodes and parts of text
+ * nodes.
+ *
+ * @version $Id$
+ * @see http://www.w3.org/TR/DOM-Level-2-Traversal-Range/ranges.html
+ */
+public interface Range
+{
+ /**
+ * Duplicates the contents of this range.
+ *
+ * @return a DocumentFragment that contains content equivalent to this range
+ */
+ DocumentFragment cloneContents();
+
+ /**
+ * Produces a new Range whose boundary-points are equal to the boundary-points of this range.
+ *
+ * @return the duplicated range
+ */
+ Range cloneRange();
+
+ /**
+ * Collapse this range onto one of its boundary-points.
+ *
+ * @param toStart if true, collapses this range onto its start; if false, collapses it onto its end.
+ */
+ void collapse(boolean toStart);
+
+ /**
+ * Compare the boundary-points of two Ranges in a document.
+ *
+ * @param how the type of comparison
+ * @param sourceRange the range to compared to
+ * @return -1, 0 or 1 depending on whether the corresponding boundary-point of this range is respectively before,
+ * equal to, or after the corresponding boundary-point of sourceRange
+ */
+ short compareBoundaryPoints(RangeCompare how, Range sourceRange);
+
+ /**
+ * Removes the contents of this range from the containing document or document fragment without returning a
+ * reference to the removed content.
+ */
+ void deleteContents();
+
+ /**
+ * Called to indicate that this range is no longer in use and that the implementation may relinquish any resources
+ * associated with this range.
+ */
+ void detach();
+
+ /**
+ * Moves the contents of this range from the containing document or document fragment to a new DocumentFragment.
+ *
+ * @return a DocumentFragment containing the extracted contents
+ */
+ DocumentFragment extractContents();
+
+ /**
+ * @return the deepest common ancestor container of this range's two boundary-points
+ */
+ Node getCommonAncestorContainer();
+
+ /**
+ * @return the node within which this range ends
+ */
+ Node getEndContainer();
+
+ /**
+ * @return the offset within the ending node of this range
+ */
+ int getEndOffset();
+
+ /**
+ * @return the node within which this range begins
+ */
+ Node getStartContainer();
+
+ /**
+ * @return the offset within the starting node of this range
+ */
+ int getStartOffset();
+
+ /**
+ * Inserts a node into the Document or DocumentFragment at the start of the Range. If the container is a Text node,
+ * this will be split at the start of the Range (as if the Text node's splitText method was performed at the
+ * insertion point) and the insertion will occur between the two resulting Text nodes. Adjacent Text nodes will not
+ * be automatically merged. If the node to be inserted is a DocumentFragment node, the children will be inserted
+ * rather than the DocumentFragment node itself.
+ *
+ * @param newNode the node to insert at the start of this range.
+ */
+ void insertNode(Node newNode);
+
+ /**
+ * @return true if this range is collapsed
+ */
+ boolean isCollapsed();
+
+ /**
+ * Select a node and its contents.
+ *
+ * @param refNode the node to select
+ */
+ void selectNode(Node refNode);
+
+ /**
+ * Select the contents within a node.
+ *
+ * @param refNode the node to select from
+ */
+ void selectNodeContents(Node refNode);
+
+ /**
+ * Sets the attributes describing the end of this range.
+ *
+ * @param refNode the {@link #endContainer} value. This parameter must be different from null.
+ * @param offset the {@link #endOffset} value
+ */
+ void setEnd(Node refNode, int offset);
+
+ /**
+ * Sets the end of this Range to be after the given node.
+ *
+ * @param refNode the reference node, after which this range will end
+ */
+ void setEndAfter(Node refNode);
+
+ /**
+ * Sets the end position to be before the given node.
+ *
+ * @param refNode the reference node, before which this range will end
+ */
+ void setEndBefore(Node refNode);
+
+ /**
+ * Sets the attributes describing the start of this range.
+ *
+ * @param refNode the {@link #startContainer} value. This parameter must be different from null.
+ * @param offset the {@link #startOffset} value
+ */
+ void setStart(Node refNode, int offset);
+
+ /**
+ * Sets the start position to be after the given node.
+ *
+ * @param refNode the reference node, after which this range will start
+ */
+ void setStartAfter(Node refNode);
+
+ /**
+ * Sets the start position to be before the given node.
+ *
+ * @param refNode the reference node, before which this range will start
+ */
+ void setStartBefore(Node refNode);
+
+ /**
+ * Re-parents the contents of this range to the given node and inserts the node at the position of the start of this
+ * range.
+ *
+ * @param newParent the node to surround the contents with
+ */
+ void surroundContents(Node newParent);
+
+ /**
+ * @return the HTML contents of this range
+ */
+ String toHTML();
+
+ /**
+ * Returns the contents of this range as a string. This string contains only the data characters, not any mark-up.
+ *
+ * @return the contents of this range
+ */
+ String toString();
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeCompare.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeCompare.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeCompare.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,113 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * Passed as a parameter to the compareBoundaryPoints method.
+ *
+ * @version $Id$
+ */
+public enum RangeCompare
+{
+ /**
+ * Compare start boundary-point of sourceRange to start boundary-point of Range on which compareBoundaryPoints is
+ * invoked.
+ */
+ START_TO_START("StartToStart"),
+
+ /**
+ * Compare start boundary-point of sourceRange to end boundary-point of Range on which compareBoundaryPoints is
+ * invoked.
+ */
+ START_TO_END("StartToEnd"),
+
+ /**
+ * Compare end boundary-point of sourceRange to end boundary-point of Range on which compareBoundaryPoints is
+ * invoked.
+ */
+ END_TO_END("EndToEnd"),
+
+ /**
+ * Compare end boundary-point of sourceRange to start boundary-point of Range on which compareBoundaryPoints is
+ * invoked.
+ */
+ END_TO_START("EndToStart");
+
+ /**
+ * The value of this constant, which will be passed to JNI methods. We need it in order to overwrite
+ * {@link #toString()} method.
+ */
+ private String value;
+
+ /**
+ * Creates a new RangeCompare constant based on the specified value. This value will be returned by
+ * {@link #toString()}.
+ *
+ * @param value The value of the created constant.
+ */
+ RangeCompare(String value)
+ {
+ this.value = value;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Enum#toString()
+ */
+ public String toString()
+ {
+ return this.value;
+ }
+
+ /**
+ * @return The reverse the end points that are compared.
+ */
+ public RangeCompare reverse()
+ {
+ switch (this) {
+ case START_TO_START:
+ case END_TO_END:
+ return this;
+ case START_TO_END:
+ return END_TO_START;
+ case END_TO_START:
+ return START_TO_END;
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * @param firstEndPoint true for START and false for END.
+ * @param secondEndPoint true for START and false for END.
+ * @return the value associated with the specified end points.
+ */
+ public static RangeCompare valueOf(boolean firstEndPoint, boolean secondEndPoint)
+ {
+ if (firstEndPoint) {
+ // START_TO_
+ return secondEndPoint ? START_TO_START : START_TO_END;
+ } else {
+ // END_TO_
+ return secondEndPoint ? END_TO_START : END_TO_END;
+ }
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeFactory.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeFactory.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/RangeFactory.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,43 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.core.client.GWT;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultRangeFactory;
+
+/**
+ * Defines the interface used to create range objects.
+ *
+ * @version $Id$
+ */
+public interface RangeFactory
+{
+ /**
+ * We create the singleton instance using deferred binding in order to use different implementations for different
+ * browsers.
+ */
+ RangeFactory INSTANCE = GWT.create(DefaultRangeFactory.class);
+
+ /**
+ * @param doc The DOM document for which to create the range.
+ * @return A new range bound to the specified document.
+ */
+ Range createRange(Document doc);
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Selection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Selection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Selection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,150 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * A selection object represents the ranges that the user has selected, or the cursor position when the user didn't
+ * select any range. It is the only was to get access to the current DOM nodes being edited with the WYSIWYG editor.
+ *
+ * @version $Id$
+ */
+public interface Selection
+{
+ /**
+ * @return the node in which the selection begins
+ */
+ Node getAnchorNode();
+
+ /**
+ * @return the offset within the {@link #getAnchorNode()} where the selection begins
+ */
+ int getAnchorOffset();
+
+ /**
+ * @return the node in which the selection ends
+ */
+ Node getFocusNode();
+
+ /**
+ * @return the offset within the {@link #getFocusNode()} where the selection ends.
+ */
+ int getFocusOffset();
+
+ /**
+ * @return true if the selection is collapsed
+ */
+ boolean isCollapsed();
+
+ /**
+ * @return the number of ranges in the selection
+ */
+ int getRangeCount();
+
+ /**
+ * @param index the index of the range to retrieve. Usually the selection contains just one range.
+ * @return the range at the specified index
+ */
+ Range getRangeAt(int index);
+
+ /**
+ * Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is
+ * collapsed, and the content is focused and editable, the caret will blink there.
+ *
+ * @param parentNode the DOM node where the selection will be set
+ * @param offset specifies where to place the selection in the given node
+ */
+ void collapse(Node parentNode, int offset);
+
+ /**
+ * Extends the selection by moving the selection end to the specified node and offset, preserving the selection
+ * begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless
+ * of direction.
+ *
+ * @param parentNode the node where the selection will be extended to
+ * @param offset specifies where to end the selection in the given node
+ */
+ void extend(Node parentNode, int offset);
+
+ /**
+ * Collapses the whole selection to a single point at the start of the current selection (irrespective of
+ * direction). If content is focused and editable, the caret will blink there.
+ */
+ void collapseToStart();
+
+ /**
+ * Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).
+ * If content is focused and editable, the caret will blink there.
+ */
+ void collapseToEnd();
+
+ /**
+ * Indicates whether the given node is part of the selection.
+ *
+ * @param node the DOM node to be tested
+ * @param partlyContained if false, the entire subtree rooted in the given node is tested
+ * @return true when the entire node is part of the selection
+ */
+ boolean containsNode(Node node, boolean partlyContained);
+
+ /**
+ * Adds all children of the specified node to the selection. Previous selection is lost.
+ *
+ * @param parentNode the parent of the children to be added to the selection
+ */
+ void selectAllChildren(Node parentNode);
+
+ /**
+ * Adds a range to this selection.
+ *
+ * @param range the range to be added
+ */
+ void addRange(Range range);
+
+ /**
+ * Removes the given range from the selection.
+ *
+ * @param range the range to be removed from the selection.
+ */
+ void removeRange(Range range);
+
+ /**
+ * Removes all ranges from the current selection.
+ */
+ void removeAllRanges();
+
+ /**
+ * Deletes this selection from document the nodes belong to.
+ */
+ void deleteFromDocument();
+
+ /**
+ * Modifies the cursor Bidi level after a change in keyboard direction.
+ *
+ * @param langRTL is true if the new language is right-to-left or false if the new language is left-to-right
+ */
+ void selectionLanguageChange(boolean langRTL);
+
+ /**
+ * @return the currently selected text
+ */
+ String toString();
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/SelectionManager.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/SelectionManager.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/SelectionManager.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,43 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.core.client.GWT;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelectionManager;
+
+/**
+ * Interface for retrieving the current selection.
+ *
+ * @version $Id$
+ */
+public interface SelectionManager
+{
+ /**
+ * We create the singleton instance using deferred binding in order to use different implementations for different
+ * browsers.
+ */
+ SelectionManager INSTANCE = GWT.create(DefaultSelectionManager.class);
+
+ /**
+ * @param doc The document for which to retrieve the selection.
+ * @return The selection associated with the specified document.
+ */
+ Selection getSelection(Document doc);
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Style.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Style.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Style.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,256 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * Extends the {@link com.google.gwt.dom.client.Style} to add constants for standard property names and values.
+ *
+ * @version $Id$
+ */
+public class Style extends com.google.gwt.dom.client.Style
+{
+ /**
+ * Sets how/if an element is displayed.
+ */
+ public static final String DISPLAY = "display";
+
+ /**
+ * Sets the background color of an element.
+ */
+ public static final String BACKGROUND_COLOR = "backgroundColor";
+
+ /**
+ * Sets the stack order of an element. An element with greater stack order is always in front of another element
+ * with lower stack order.<br/>
+ * Elements can have negative stack orders.<br/>
+ * Z-index only works on elements that have been positioned (eg position:absolute;)!
+ */
+ public static final String Z_INDEX = "zIndex";
+
+ /**
+ * Sets how thick or thin characters in text should be displayed.
+ */
+ public static final String FONT_WEIGHT = "font-weight";
+
+ /**
+ * Sets the style of a font.
+ */
+ public static final String FONT_STYLE = "font-style";
+
+ /**
+ * Decorates the text.
+ */
+ public static final String TEXT_DECORATION = "text-decoration";
+
+ /**
+ * The font-family property is a prioritized list of font family names and/or generic family names for an element.
+ * The browser will use the first value it recognizes.<br/>
+ * There are two types of font-family values:
+ * <ul>
+ * <li>family-name: "times", "courier", "arial", etc.</li>
+ * <li>generic-family: "serif", "sans-serif", "cursive", "fantasy", "monospace".</li>
+ * </ul>
+ * Note: Separate each value with a comma, and always offer a generic-family name as the last alternative.<br/>
+ * Note: If a family-name contains white-space, it should be quoted. Single quotes must be used when using the
+ * "style" attribute in HTML.
+ */
+ public static final String FONT_FAMILY = "font-family";
+
+ /**
+ * Sets the width of an element.
+ */
+ public static final String WIDTH = "width";
+
+ /**
+ * sets the height of an element.
+ */
+ public static final String HEIGHT = "height";
+
+ /**
+ * Sets how far the top edge of an element is above/below the top edge of the parent element.
+ */
+ public static final String TOP = "top";
+
+ /**
+ * Sets how far the left edge of an element is to the right/left of the left edge of the parent element.
+ */
+ public static final String LEFT = "left";
+
+ /**
+ * Places an element in a static, relative, absolute or fixed position.
+ */
+ public static final String POSITION = "position";
+
+ /**
+ * Standard values for {@link Style#DISPLAY}.
+ */
+ public static final class Display
+ {
+ /**
+ * Default. The element will be displayed as an inline element, with no line break before or after the element.
+ */
+ public static final String INLINE = "inline";
+
+ /**
+ * The element will be displayed as a block-level element, with a line break before and after the element.
+ */
+ public static final String BLOCK = "block";
+
+ /**
+ * The element will not be displayed.
+ */
+ public static final String NONE = "none";
+
+ /**
+ * This is a utility class so it has a private constructor.
+ */
+ private Display()
+ {
+ }
+ }
+
+ /**
+ * Standard values for {@link Style#FONT_WEIGHT}.
+ */
+ public static final class FontWeight
+ {
+ /**
+ * Defines thick characters.
+ */
+ public static final String BOLD = "bold";
+
+ /**
+ * Defines thicker characters.
+ */
+ public static final String BOLDER = "bolder";
+
+ /**
+ * This is a utility class so it has a private constructor.
+ */
+ private FontWeight()
+ {
+ }
+ }
+
+ /**
+ * Standard values for {@link Style#FONT_STYLE}.
+ */
+ public static final class FontStyle
+ {
+ /**
+ * The browser displays an italic font.
+ */
+ public static final String ITALIC = "italic";
+
+ /**
+ * This is a utility class so it has a private constructor.
+ */
+ private FontStyle()
+ {
+ }
+ }
+
+ /**
+ * Standard values for {@link Style#TEXT_DECORATION}.
+ */
+ public static final class TextDecoration
+ {
+ /**
+ * Defines a line through the text.
+ */
+ public static final String LINE_THROUGH = "line-through";
+
+ /**
+ * Defines a line under the text.
+ */
+ public static final String UNDERLINE = "underline";
+
+ /**
+ * This is a utility class so it has a private constructor.
+ */
+ private TextDecoration()
+ {
+ }
+ }
+
+ /**
+ * Standard values for {@link Style#POSITION}.
+ */
+ public static final class Position
+ {
+ /**
+ * Default. An element with position: static always has the position the normal flow of the page gives it (a
+ * static element ignores any top, bottom, left, or right declarations).
+ */
+ public static final String STATIC = "static";
+
+ /**
+ * An element with position: relative moves an element relative to its normal position, so "left:20" adds 20
+ * pixels to the element's LEFT position.
+ */
+ public static final String RELATIVE = "relative";
+
+ /**
+ * An element with position: absolute is positioned at the specified coordinates relative to its containing
+ * block. The element's position is specified with the "left", "top", "right", and "bottom" properties.
+ */
+ public static final String ABSOLUTE = "absolute";
+
+ /**
+ * An element with position: fixed is positioned at the specified coordinates relative to the browser window.
+ * The element's position is specified with the "left", "top", "right", and "bottom" properties. The element
+ * remains at that position regardless of scrolling. Works in IE7 (strict mode).
+ */
+ public static final String FIXED = "fixed";
+
+ /**
+ * This is a utility class so it has a private constructor.
+ */
+ private Position()
+ {
+ }
+ }
+
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected Style()
+ {
+ }
+
+ /**
+ * Some browsers expect the camel case form of a style property. For instance, the camel case form of "font-weight"
+ * is "fontWeight".
+ *
+ * @param propertyName The name of style property.
+ * @return The camel case form of the given property name.
+ */
+ public static String toCamelCase(String propertyName)
+ {
+ int dashIndex = propertyName.indexOf('-');
+ if (dashIndex < 0 || dashIndex == propertyName.length() - 1) {
+ return propertyName;
+ }
+ StringBuffer camelCase = new StringBuffer(propertyName.substring(0, dashIndex));
+ camelCase.append(propertyName.substring(dashIndex + 1, dashIndex + 2).toUpperCase());
+ camelCase.append(propertyName.substring(dashIndex + 2));
+ return camelCase.toString();
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableCellElement.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableCellElement.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableCellElement.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,77 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * Extends the implementation provided by GWT to add useful methods. All of them should be removed as soon as they make
+ * their way into GWT's API.
+ *
+ * @version $Id$
+ */
+public final class TableCellElement extends com.google.gwt.dom.client.TableCellElement
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected TableCellElement()
+ {
+ super();
+ }
+
+ /**
+ * @return The row containing this cell.
+ */
+ public TableRowElement getOwnerRow()
+ {
+ return (TableRowElement) getParentElement();
+ }
+
+ /**
+ * @return The next cell inside the same table. If this is the last cell then it returns null.
+ */
+ public TableCellElement getNextCell()
+ {
+ Node nextCell = getNextSiblingElement();
+ if (nextCell == null) {
+ TableRowElement nextRow = getOwnerRow().getNextRow();
+ if (nextRow != null) {
+ nextCell = nextRow.getFirstCell();
+ }
+ }
+ return (TableCellElement) nextCell;
+ }
+
+ /**
+ * @return The previous cell inside the same table. If this is the first cell then it returns null.
+ */
+ public TableCellElement getPreviousCell()
+ {
+ Node prevCell = getPreviousSibling();
+ if (prevCell == null) {
+ TableRowElement prevRow = getOwnerRow().getPreviousRow();
+ if (prevRow != null) {
+ prevCell = prevRow.getLastCell();
+ }
+ }
+ return (TableCellElement) prevCell;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableRowElement.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableRowElement.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TableRowElement.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,94 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+import com.google.gwt.dom.client.TableElement;
+
+/**
+ * Extends the implementation provided by GWT to add useful methods. All of them should be removed as soon as they make
+ * their way into GWT's API.
+ *
+ * @version $Id$
+ */
+public final class TableRowElement extends com.google.gwt.dom.client.TableRowElement
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected TableRowElement()
+ {
+ super();
+ }
+
+ /**
+ * @return The table containing this cell.
+ */
+ public TableElement getOwnerTable()
+ {
+ Node ancestor = this.getParentNode();
+ while (ancestor != null && !"table".equalsIgnoreCase(ancestor.getNodeName())) {
+ ancestor = ancestor.getParentNode();
+ }
+ return (TableElement) ancestor;
+ }
+
+ /**
+ * @return The next row inside the same table. If this is the last row then it returns null.
+ */
+ public TableRowElement getNextRow()
+ {
+ TableElement table = getOwnerTable();
+ if (getRowIndex() < table.getRows().getLength() - 1) {
+ return (TableRowElement) table.getRows().getItem(getRowIndex() + 1);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return The previous row inside the same table. If this is the first row then it returns null.
+ */
+ public TableRowElement getPreviousRow()
+ {
+ TableElement table = getOwnerTable();
+ if (getRowIndex() > 0) {
+ return (TableRowElement) table.getRows().getItem(getRowIndex() - 1);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return The first cell of this row.
+ */
+ public TableCellElement getFirstCell()
+ {
+ return (TableCellElement) getCells().getItem(0);
+ }
+
+ /**
+ * @return The last cell of this row.
+ */
+ public TableCellElement getLastCell()
+ {
+ return (TableCellElement) getCells().getItem(getCells().getLength() - 1);
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Text.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Text.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/Text.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,124 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+import com.google.gwt.dom.client.Node;
+
+/**
+ * Extends the text implementation provided by GWT to add useful methods. All of them should be removed as soon as they
+ * make their way into GWT's API.
+ *
+ * @version $Id$
+ */
+public final class Text extends com.google.gwt.dom.client.Text
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected Text()
+ {
+ }
+
+ /**
+ * Casts a {@link Node} to an instance of this type.
+ *
+ * @param node the instance to be casted to this type.
+ * @return the given object as an instance of {@link Text}.
+ */
+ public static Text as(Node node)
+ {
+ assert node.getNodeType() == Node.TEXT_NODE;
+ return (Text) com.google.gwt.dom.client.Text.as(node);
+ }
+
+ /**
+ * Merges all the neighbor text nodes of this text node and returns a text fragment specifying where is this text
+ * placed in the final text node resulted after the merge.
+ *
+ * @return a text fragment showing the place of this text in the node obtained after the merge.
+ */
+ public TextFragment normalize()
+ {
+ StringBuffer leftText = new StringBuffer();
+ Node leftSibling = this.getPreviousSibling();
+ while (leftSibling != null && leftSibling.getNodeType() == Node.TEXT_NODE) {
+ leftText.insert(0, leftSibling.getNodeValue());
+ leftSibling.getParentNode().removeChild(leftSibling);
+ leftSibling = this.getPreviousSibling();
+ }
+
+ StringBuffer rightText = new StringBuffer();
+ Node rightSibling = this.getNextSibling();
+ while (rightSibling != null && rightSibling.getNodeType() == Node.TEXT_NODE) {
+ rightText.append(rightSibling.getNodeValue());
+ rightSibling.getParentNode().removeChild(rightSibling);
+ rightSibling = this.getNextSibling();
+ }
+
+ int startIndex = leftText.length();
+ int endIndex = startIndex + this.getLength();
+ this.setData(leftText.toString() + this.getData() + rightText.toString());
+ return new TextFragment(this, startIndex, endIndex);
+ }
+
+ /**
+ * @return the offset of this text node relative to the left-most successive text node sibling. The offset is
+ * expressed as the number of characters between this text node and the reference point.
+ */
+ public int getOffset()
+ {
+ int offset = 0;
+ Node leftSibling = this.getPreviousSibling();
+ while (leftSibling != null) {
+ if (leftSibling.getNodeType() == Node.TEXT_NODE) {
+ offset += leftSibling.getNodeValue().length();
+ } else if (DOMUtils.getInstance().isSerializable(leftSibling)) {
+ break;
+ }
+ leftSibling = leftSibling.getPreviousSibling();
+ }
+ return offset;
+ }
+
+ /**
+ * Keeps the text between the given indexes as the value of this node. The remaining text, if present, is placed in
+ * sibling text nodes.
+ *
+ * @param startIndex crop start
+ * @param endIndex crop end
+ */
+ public void crop(int startIndex, int endIndex)
+ {
+ if (startIndex > 0) {
+ String leftData = getData().substring(0, startIndex);
+ Text left = getOwnerDocument().createTextNode(leftData).cast();
+ getParentNode().insertBefore(left, this);
+ setData(getData().substring(startIndex));
+ }
+
+ int length = endIndex - startIndex;
+ if (length < getLength()) {
+ String rightData = getData().substring(length);
+ Text right = getOwnerDocument().createTextNode(rightData).cast();
+ DOMUtils.getInstance().insertAfter(right, this);
+ setData(getData().substring(0, length));
+ }
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TextFragment.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TextFragment.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/TextFragment.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,82 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom;
+
+/**
+ * A text fragment is a substring of a text node from a DOM tree. It is uniquely identified by the source text node, the
+ * index of the first character and the index of the last character.
+ *
+ * @version $Id$
+ */
+public class TextFragment
+{
+ /**
+ * The source text node.
+ */
+ private final Text text;
+
+ /**
+ * The index of fragment's first character, in the source text node.
+ */
+ private final int startIndex;
+
+ /**
+ * The index of fragment's last character, in the source text node.
+ */
+ private final int endIndex;
+
+ /**
+ * Creates a new fragment of the given text node.
+ *
+ * @param text the source text node.
+ * @param startIndex the index of fragment's first character, in the source text node.
+ * @param endIndex the index of fragment's last character, in the source text node.
+ */
+ public TextFragment(Text text, int startIndex, int endIndex)
+ {
+ this.text = text;
+ this.startIndex = startIndex;
+ this.endIndex = endIndex;
+ }
+
+ /**
+ * @return the source text node.
+ */
+ public Text getText()
+ {
+ return text;
+ }
+
+ /**
+ * @return the index of fragment's first character, in the source text node.
+ */
+ public int getStartIndex()
+ {
+ return startIndex;
+ }
+
+ /**
+ * @return the index of fragment's last character, in the source text node.
+ */
+ public int getEndIndex()
+ {
+ return endIndex;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/AbstractSelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/AbstractSelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/AbstractSelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,233 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
+
+/**
+ * Abstract {@link Selection} implementation.
+ * <p>
+ * NOTE: In the current implementation we often make the assumption that the selection contains at most one range. All
+ * the other ranges, if they exist, are sometimes ignored. Additionally, but somehow as a consequence, we consider the
+ * anchor node as being the start container of the first range and the focus node as the end container of the first
+ * range. This has to do with the fact that not all the browsers distinguish the direction in which the user makes the
+ * selection (from left to right or the opposite).
+ *
+ * @version $Id$
+ */
+public abstract class AbstractSelection implements Selection
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#collapse(Node, int)
+ */
+ public void collapse(Node parentNode, int offset)
+ {
+ Range range = ((Document) parentNode.getOwnerDocument()).createRange();
+ range.setStart(parentNode, offset);
+ range.collapse(true);
+ removeAllRanges();
+ addRange(range);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#collapseToEnd()
+ */
+ public void collapseToEnd()
+ {
+ collapse(false);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#collapseToStart()
+ */
+ public void collapseToStart()
+ {
+ collapse(true);
+ }
+
+ /**
+ * Collapses this selection to the specified end point.
+ *
+ * @param toStart whether to collapse to the start or to the end point of the first range in this selection
+ */
+ private void collapse(boolean toStart)
+ {
+ if (getRangeCount() > 0) {
+ Range range = getRangeAt(0);
+ range.collapse(toStart);
+ removeAllRanges();
+ addRange(range);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#containsNode(Node, boolean)
+ */
+ public boolean containsNode(Node node, boolean partlyContained)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#deleteFromDocument()
+ */
+ public void deleteFromDocument()
+ {
+ if (getRangeCount() > 0) {
+ Range range = getRangeAt(0);
+ range.deleteContents();
+ removeAllRanges();
+ addRange(range);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#extend(Node, int)
+ */
+ public void extend(Node parentNode, int offset)
+ {
+ if (getRangeCount() > 0) {
+ Range range = getRangeAt(0);
+ range.setEnd(parentNode, offset);
+ removeAllRanges();
+ addRange(range);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#getAnchorNode()
+ */
+ public Node getAnchorNode()
+ {
+ if (getRangeCount() > 0) {
+ return getRangeAt(0).getStartContainer();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#getAnchorOffset()
+ */
+ public int getAnchorOffset()
+ {
+ if (getRangeCount() > 0) {
+ return getRangeAt(0).getStartOffset();
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#getFocusNode()
+ */
+ public Node getFocusNode()
+ {
+ if (getRangeCount() > 0) {
+ return getRangeAt(0).getEndContainer();
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#getFocusOffset()
+ */
+ public int getFocusOffset()
+ {
+ if (getRangeCount() > 0) {
+ return getRangeAt(0).getEndOffset();
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#isCollapsed()
+ */
+ public boolean isCollapsed()
+ {
+ return getRangeCount() == 1 && getRangeAt(0).isCollapsed();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#selectAllChildren(Node)
+ */
+ public void selectAllChildren(Node parentNode)
+ {
+ Range range = ((Document) parentNode.getOwnerDocument()).createRange();
+ range.selectNodeContents(parentNode);
+ removeAllRanges();
+ addRange(range);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#selectionLanguageChange(boolean)
+ */
+ public void selectionLanguageChange(boolean langRTL)
+ {
+ // TODO
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Selection#toString()
+ */
+ public String toString()
+ {
+ if (getRangeCount() > 0) {
+ return getRangeAt(0).toString();
+ } else {
+ return "";
+ }
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultNativeRangeWrapper.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultNativeRangeWrapper.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultNativeRangeWrapper.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,73 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.xpn.xwiki.wysiwyg.client.dom.JavaScriptObject;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+
+/**
+ * Wraps a native range to be used by the selection who created this object. For instance, in order to remove a range
+ * from the selection we must keep a reference to the native range returned by the native selection. The selection
+ * implementation is responsible for setting and handling the reference to the native range.
+ *
+ * @version $Id$
+ */
+public class DefaultNativeRangeWrapper extends DefaultRange implements NativeRangeWrapper
+{
+ /**
+ * The native range wrapped by this object.
+ */
+ private JavaScriptObject nativeRange;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see NativeRangeWrapper#getNativeRange()
+ */
+ public JavaScriptObject getNativeRange()
+ {
+ return nativeRange;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see NativeRangeWrapper#setNativeRange(JavaScriptObject)
+ */
+ public void setNativeRange(JavaScriptObject nativeRange)
+ {
+ this.nativeRange = nativeRange;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DefaultRange#cloneRange()
+ */
+ public Range cloneRange()
+ {
+ // We should use Object.clone when it is implemented in GWT
+ // See http://code.google.com/p/google-web-toolkit/issues/detail?id=1843
+ DefaultNativeRangeWrapper clone = new DefaultNativeRangeWrapper();
+ clone.setStart(getStartContainer(), getStartOffset());
+ clone.setEnd(getEndContainer(), getEndOffset());
+ return clone;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRange.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRange.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRange.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,685 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.DOMUtils;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.RangeCompare;
+
+/**
+ * This is a cross-browser implementation of the W3C Range specification.
+ * <p>
+ * Acknowledgment to Mozilla Foundation for making nsRange.cpp public.
+ *
+ * @version $Id$
+ * @see http://hg.mozilla.org/mozilla-central/file/b945b4f67e7e/content/base/src/ns…
+ */
+public class DefaultRange implements Range
+{
+ /**
+ * The DOM node containing the start of this range.
+ */
+ private Node startContainer;
+
+ /**
+ * The offset within the {@link #startContainer}.
+ */
+ private int startOffset;
+
+ /**
+ * The DOM node containing the end of this range.
+ */
+ private Node endContainer;
+
+ /**
+ * The offset within the {@link #endContainer}.
+ */
+ private int endOffset;
+
+ /**
+ * Specifies if both boundaries of this range have been successfully set to valid DOM nodes.
+ */
+ private boolean positioned;
+
+ /**
+ * Specifies if this range is in use.
+ */
+ private boolean detached;
+
+ /**
+ * Collection of DOM utility methods.
+ */
+ private DOMUtils domUtils = DOMUtils.getInstance();
+
+ /**
+ * Sets the boundaries of this range.
+ *
+ * @param startContainer {@link #startContainer}
+ * @param startOffset {@link #startOffset}
+ * @param endContainer {@link #endContainer}
+ * @param endOffset {@link #endOffset}
+ */
+ private void setRange(Node startContainer, int startOffset, Node endContainer, int endOffset)
+ {
+ boolean valid = !(startContainer == null ^ endContainer == null);
+ if (valid && startContainer != null) {
+ valid = valid && startContainer.getOwnerDocument() == endContainer.getOwnerDocument();
+ valid = valid && startOffset >= 0 && startOffset <= domUtils.getLength(startContainer);
+ valid = valid && endOffset >= 0 && endOffset <= domUtils.getLength(endContainer);
+ }
+
+ if (!valid) {
+ throw new IllegalArgumentException();
+ }
+
+ this.startContainer = startContainer;
+ this.startOffset = startOffset;
+ this.endContainer = endContainer;
+ this.endOffset = endOffset;
+ positioned = startContainer != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#cloneContents()
+ */
+ public DocumentFragment cloneContents()
+ {
+ if (detached) {
+ throw new IllegalStateException();
+ }
+
+ Node root = getCommonAncestorContainer();
+
+ if (startContainer == endContainer) {
+ return domUtils.cloneNodeContents(root, startOffset, endOffset);
+ }
+
+ DocumentFragment contents = ((Document) root.getOwnerDocument()).createDocumentFragment();
+
+ int startIndex = startOffset;
+ if (startContainer != root) {
+ contents.appendChild(domUtils.cloneNode(root, startContainer, startOffset, false));
+ startIndex = domUtils.getNodeIndex(domUtils.getChild(root, startContainer)) + 1;
+ }
+
+ if (endContainer != root) {
+ int endIndex = domUtils.getNodeIndex(domUtils.getChild(root, endContainer));
+ contents.appendChild(domUtils.cloneNodeContents(root, startIndex, endIndex));
+ contents.appendChild(domUtils.cloneNode(root, endContainer, endOffset, true));
+ } else {
+ contents.appendChild(domUtils.cloneNodeContents(root, startIndex, endOffset));
+ }
+
+ return contents;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#cloneRange()
+ */
+ public Range cloneRange()
+ {
+ if (detached) {
+ throw new IllegalStateException();
+ }
+
+ // We should use Object.clone when it is implemented in GWT
+ // See http://code.google.com/p/google-web-toolkit/issues/detail?id=1843
+ DefaultRange clone = new DefaultRange();
+ clone.setRange(startContainer, startOffset, endContainer, endOffset);
+ return clone;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#collapse(boolean)
+ */
+ public void collapse(boolean toStart)
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+
+ if (toStart) {
+ setRange(startContainer, startOffset, startContainer, startOffset);
+ } else {
+ setRange(endContainer, endOffset, endContainer, endOffset);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#compareBoundaryPoints(RangeCompare, Range)
+ */
+ public short compareBoundaryPoints(RangeCompare how, Range sourceRange)
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+ if (startContainer.getOwnerDocument() != sourceRange.getStartContainer().getOwnerDocument()) {
+ throw new IllegalArgumentException();
+ }
+
+ switch (how) {
+ case START_TO_START:
+ return domUtils.comparePoints(startContainer, startOffset, sourceRange.getStartContainer(), sourceRange
+ .getStartOffset());
+ case START_TO_END:
+ return domUtils.comparePoints(endContainer, endOffset, sourceRange.getStartContainer(), sourceRange
+ .getStartOffset());
+ case END_TO_START:
+ return domUtils.comparePoints(startContainer, startOffset, sourceRange.getEndContainer(), sourceRange
+ .getEndOffset());
+ case END_TO_END:
+ return domUtils.comparePoints(endContainer, endOffset, sourceRange.getEndContainer(), sourceRange
+ .getEndOffset());
+ default:
+ throw new IllegalArgumentException();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#deleteContents()
+ */
+ public void deleteContents()
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+
+ Node root = getCommonAncestorContainer();
+
+ if (startContainer == endContainer) {
+ domUtils.deleteNodeContents(root, startOffset, endOffset);
+ // Take the range gravity into account.
+ collapse(true);
+ } else {
+ int startIndex = startOffset;
+ if (startContainer != root) {
+ domUtils.deleteNodeContents(root, startContainer, startOffset, false);
+ startIndex = domUtils.getNodeIndex(domUtils.getChild(root, startContainer)) + 1;
+ }
+
+ int endIndex = endOffset;
+ if (endContainer != root) {
+ endIndex = domUtils.getNodeIndex(domUtils.getChild(root, endContainer));
+ domUtils.deleteNodeContents(root, endContainer, endOffset, true);
+ // Take the range gravity into account.
+ setEnd(endContainer, 0);
+ } else {
+ // Take the range gravity into account.
+ setEnd(root, startIndex);
+ }
+ domUtils.deleteNodeContents(root, startIndex, endIndex);
+ }
+
+ // At this point we should be checking for the case where we have 2 adjacent text nodes left, each containing
+ // one of the range end points. The spec says the 2 nodes should be merged in that case, and to use Normalize()
+ // to do the merging, but calling Normalize() on the common parent to accomplish this might also normalize nodes
+ // that are outside the range but under the common parent. Need to verify with the range commitee members that
+ // this was the desired behavior. For now we don't merge anything!
+ // Filed as https://bugzilla.mozilla.org/show_bug.cgi?id=401276
+
+ collapseRangeAfterDelete();
+ }
+
+ /**
+ * Utility method that is used by {@link #deleteContents()} and {@link #extractContents()} to collapse the range in
+ * the correct place, under the range's root container (the range end points common container) as outlined by the
+ * Range spec: http://www.w3.org/TR/2000/REC-DOM-Level-2-Traversal-Range-20001113/ranges.h…
+ * <p>
+ * The assumption made by this method is that the delete or extract has been done already, and left the range in a
+ * state where there is no content between the 2 end points.
+ */
+ private void collapseRangeAfterDelete()
+ {
+ // Check if range gravity took care of collapsing the range for us!
+ if (isCollapsed()) {
+ // The range is collapsed so there's nothing for us to do.
+ //
+ // There are 2 possible scenarios here:
+ //
+ // 1. the range could've been collapsed prior to the delete/extract,
+ // which would've resulted in nothing being removed, so the range
+ // is already where it should be.
+ //
+ // 2. Prior to the delete/extract, the range's start and end were in
+ // the same container which would mean everything between them
+ // was removed, causing range gravity to collapse the range.
+ } else {
+ // The range isn't collapsed so figure out the appropriate place to collapse!
+ Node commonAncestor = getCommonAncestorContainer();
+
+ // Collapse to one of the end points if they are already in the
+ // commonAncestor. This should work ok since this method is called
+ // immediately after a delete or extract that leaves no content
+ // between the 2 end points!
+ if (startContainer == commonAncestor) {
+ collapse(true);
+ } else if (endContainer == commonAncestor) {
+ collapse(false);
+ } else {
+ // End points are at differing levels. We want to collapse to the
+ // point that is between the 2 subtrees that contain each point,
+ // under the common ancestor.
+ Node startAncestor = domUtils.getChild(commonAncestor, startContainer);
+ selectNode(startAncestor);
+ collapse(false);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#detach()
+ */
+ public void detach()
+ {
+ if (detached) {
+ throw new IllegalStateException();
+ }
+
+ detached = true;
+ setRange(null, 0, null, 0);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#extractContents()
+ * @see #deleteContents()
+ */
+ public DocumentFragment extractContents()
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+
+ Node root = getCommonAncestorContainer();
+ DocumentFragment contents;
+
+ if (startContainer == endContainer) {
+ contents = domUtils.extractNodeContents(root, startOffset, endOffset);
+ // Take the range gravity into account.
+ collapse(true);
+ } else {
+ contents = ((Document) root.getOwnerDocument()).createDocumentFragment();
+
+ int startIndex = startOffset;
+ if (startContainer != root) {
+ contents.appendChild(domUtils.extractNode(root, startContainer, startOffset, false));
+ startIndex = domUtils.getNodeIndex(domUtils.getChild(root, startContainer)) + 1;
+ }
+
+ if (endContainer != root) {
+ int endIndex = domUtils.getNodeIndex(domUtils.getChild(root, endContainer));
+ contents.appendChild(domUtils.extractNodeContents(root, startIndex, endIndex));
+ contents.appendChild(domUtils.extractNode(root, endContainer, endOffset, true));
+ // Take the range gravity into account.
+ setEnd(endContainer, 0);
+ } else {
+ contents.appendChild(domUtils.extractNodeContents(root, startIndex, endOffset));
+ // Take the range gravity into account.
+ setEnd(root, startIndex);
+ }
+ }
+
+ collapseRangeAfterDelete();
+
+ return contents;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#getCommonAncestorContainer()
+ */
+ public Node getCommonAncestorContainer()
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+
+ return domUtils.getNearestCommonAncestor(startContainer, endContainer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#getEndContainer()
+ */
+ public Node getEndContainer()
+ {
+ if (!positioned) {
+ throw new IllegalStateException();
+ }
+
+ return endContainer;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#getEndOffset()
+ */
+ public int getEndOffset()
+ {
+ if (!positioned) {
+ throw new IllegalStateException();
+ }
+
+ return endOffset;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#getStartContainer()
+ */
+ public Node getStartContainer()
+ {
+ if (!positioned) {
+ throw new IllegalStateException();
+ }
+
+ return startContainer;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#getStartOffset()
+ */
+ public int getStartOffset()
+ {
+ if (!positioned) {
+ throw new IllegalStateException();
+ }
+
+ return startOffset;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#insertNode(Node)
+ */
+ public void insertNode(Node newNode)
+ {
+ // Compute the number of nodes to insert.
+ int delta = newNode.getNodeType() == DOMUtils.DOCUMENT_FRAGMENT_NODE ? newNode.getChildNodes().getLength() : 1;
+ if (delta == 0) {
+ // There's nothing to insert.
+ return;
+ }
+ switch (startContainer.getNodeType()) {
+ case DOMUtils.CDATA_NODE:
+ case DOMUtils.COMMENT_NODE:
+ case Node.TEXT_NODE:
+ Node sibling = domUtils.splitNode(startContainer, startOffset);
+ sibling.getParentNode().insertBefore(newNode, sibling);
+ if (startContainer == endContainer) {
+ setEnd(sibling, endOffset - startOffset);
+ } else if (startContainer.getParentNode() == endContainer) {
+ // Move the end with the number of inserted nodes plus 1 text node resulted after the split.
+ setEnd(endContainer, endOffset + delta + 1);
+ }
+ break;
+ case Node.ELEMENT_NODE:
+ domUtils.insertAt(startContainer, newNode, startOffset);
+ if (startContainer == endContainer) {
+ // Move the end with the number of inserted nodes.
+ setEnd(endContainer, endOffset + delta);
+ }
+ break;
+ default:
+ throw new IllegalStateException();
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#isCollapsed()
+ */
+ public boolean isCollapsed()
+ {
+ if (detached || !positioned) {
+ throw new IllegalStateException();
+ }
+
+ return startContainer == endContainer && startOffset == endOffset;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#selectNode(Node)
+ */
+ public void selectNode(Node refNode)
+ {
+ Node parent = refNode.getParentNode();
+ int index = domUtils.getNodeIndex(refNode);
+ setRange(parent, index, parent, index + 1);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#selectNodeContents(Node)
+ */
+ public void selectNodeContents(Node refNode)
+ {
+ setRange(refNode, 0, refNode, domUtils.getLength(refNode));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setEnd(Node, int)
+ */
+ public void setEnd(Node refNode, int offset)
+ {
+ if (!positioned || startContainer.getOwnerDocument() != refNode.getOwnerDocument()
+ || isAfterOrDisconnected(startContainer, startOffset, refNode, offset)) {
+ setRange(refNode, offset, refNode, offset);
+ } else {
+ setRange(startContainer, startOffset, refNode, offset);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setEndAfter(Node)
+ */
+ public void setEndAfter(Node refNode)
+ {
+ setEnd(refNode.getParentNode(), domUtils.getNodeIndex(refNode) + 1);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setEndBefore(Node)
+ */
+ public void setEndBefore(Node refNode)
+ {
+ setEnd(refNode.getParentNode(), domUtils.getNodeIndex(refNode));
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setStart(Node, int)
+ */
+ public void setStart(Node refNode, int offset)
+ {
+ if (!positioned || endContainer.getOwnerDocument() != refNode.getOwnerDocument()
+ || isAfterOrDisconnected(refNode, offset, endContainer, endOffset)) {
+ setRange(refNode, offset, refNode, offset);
+ } else {
+ setRange(refNode, offset, endContainer, endOffset);
+ }
+ }
+
+ /**
+ * Utility method for testing if one boundary point is after another or it they are disconnected.
+ *
+ * @param alice first point's node
+ * @param aliceOffset first point's offset
+ * @param bob second point's node
+ * @param bobOffset second point's offset
+ * @return true if the first point is after the second point or if the given points are disconnected
+ */
+ private boolean isAfterOrDisconnected(Node alice, int aliceOffset, Node bob, int bobOffset)
+ {
+ try {
+ return domUtils.comparePoints(alice, aliceOffset, bob, bobOffset) == 1;
+ } catch (IllegalArgumentException e) {
+ // The given boundary points are disconnected.
+ return true;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setStartAfter(Node)
+ */
+ public void setStartAfter(Node refNode)
+ {
+ setStart(refNode.getParentNode(), domUtils.getNodeIndex(refNode) + 1);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#setStartBefore(Node)
+ */
+ public void setStartBefore(Node refNode)
+ {
+ setStart(refNode.getParentNode(), domUtils.getNodeIndex(refNode));
+ }
+
+ /**
+ * The {@link #surroundContents(Node)} method raises an exception if the Range partially selects a non-Text node. An
+ * example of a Range for which {@link #surroundContents(Node)} raises an exception is:
+ * <code><FOO>A<strong>B<BAR>C</strong>D</BAR>E</FOO></code>
+ *
+ * @return true if {@link #surroundContents(Node)} can be called on the current range
+ */
+ private boolean canSurroundContents()
+ {
+ if (startContainer == endContainer) {
+ return true;
+ }
+
+ boolean startIsText = startContainer.getNodeType() == Node.TEXT_NODE;
+ boolean endIsText = endContainer.getNodeType() == Node.TEXT_NODE;
+ Node startParent = startContainer.getParentNode();
+ Node endParent = endContainer.getParentNode();
+
+ // I'm using the bitwise AND operator to reduce the cyclomatic complexity.
+ boolean can = (startIsText & endIsText) && startParent != null && startParent == endParent;
+ can = can || (startIsText && startParent != null && startParent == endContainer);
+ return can || (endIsText && endParent != null && endParent == startContainer);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#surroundContents(Node)
+ */
+ public void surroundContents(Node newParent)
+ {
+ // The surroundContents() method raises an exception if the Range partially selects a non-Text node. An example
+ // of a Range for which surroundContents() raises an exception is: <FOO>A|B<BAR>C|D</BAR>E</FOO>
+ if (!canSurroundContents()) {
+ throw new IllegalStateException();
+ }
+
+ // Extract the contents within the range.
+ DocumentFragment contents = extractContents();
+
+ // Spec says we need to remove all of newParent's children prior to insertion.
+ Node child = newParent.getFirstChild();
+ while (child != null) {
+ newParent.removeChild(child);
+ child = newParent.getFirstChild();
+ }
+
+ // Insert newParent at the range's start point.
+ insertNode(newParent);
+
+ // Append the contents we extracted under newParent.
+ newParent.appendChild(contents);
+
+ // Select newParent, and its contents.
+ selectNode(newParent);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#toHTML()
+ */
+ public String toHTML()
+ {
+ if (detached) {
+ throw new IllegalStateException();
+ }
+
+ if (positioned) {
+ return cloneContents().getInnerHTML();
+ } else {
+ return "";
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see Range#toString()
+ */
+ public String toString()
+ {
+ if (detached) {
+ throw new IllegalStateException();
+ }
+
+ if (positioned) {
+ return cloneContents().getInnerText();
+ } else {
+ return "";
+ }
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRangeFactory.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRangeFactory.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultRangeFactory.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,46 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.RangeFactory;
+
+/**
+ * The default {@link RangeFactory} implementation.
+ *
+ * @version $Id$
+ */
+public class DefaultRangeFactory implements RangeFactory
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see RangeFactory#createRange(Document)
+ */
+ public Range createRange(Document doc)
+ {
+ // We create a new native range wrapper without passing a reference to a native range. The selection
+ // implementation should initialize this reference when the new range will be added.
+ Range range = new DefaultNativeRangeWrapper();
+ range.selectNodeContents(doc.getBody());
+ return range;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,127 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla.NativeRange;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla.NativeSelection;
+
+/**
+ * The default selection implementation for browsers supporting the W3C Range specification and following Mozilla
+ * Selection API.
+ *
+ * @version $Id$
+ */
+public class DefaultSelection extends AbstractSelection
+{
+ /**
+ * The underlying native selection object provided by the browser.
+ */
+ private final NativeSelection nativeSelection;
+
+ /**
+ * Creates a new selection object. This object will handle the conversion of {@link Range} objects to the native
+ * range supported by the browser. The native ranges obtained will be applied to the underlying native selection.
+ *
+ * @param nativeSelection the underlying native selection to be used
+ */
+ public DefaultSelection(NativeSelection nativeSelection)
+ {
+ this.nativeSelection = nativeSelection;
+ }
+
+ /**
+ * @return {@link #nativeSelection}
+ */
+ protected NativeSelection getNativeSelection()
+ {
+ return nativeSelection;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#addRange(Range)
+ */
+ public void addRange(Range range)
+ {
+ NativeRangeWrapper wrapper = ((NativeRangeWrapper) range);
+ if (wrapper.getNativeRange() == null) {
+ Document doc = (Document) range.getStartContainer().getOwnerDocument();
+ wrapper.setNativeRange(NativeRange.newInstance(doc));
+ }
+ NativeRange nativeRange = wrapper.getNativeRange().cast();
+ nativeRange.setStart(range.getStartContainer(), range.getStartOffset());
+ nativeRange.setEnd(range.getEndContainer(), range.getEndOffset());
+ nativeSelection.addRange(nativeRange);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#getRangeAt(int)
+ */
+ public Range getRangeAt(int index)
+ {
+ if (index < 0 || index >= getRangeCount()) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ NativeRange nativeRange = nativeSelection.getRangeAt(index);
+ Range range = ((Document) nativeRange.getStartContainer().getOwnerDocument()).createRange();
+ range.setStart(nativeRange.getStartContainer(), nativeRange.getStartOffset());
+ range.setEnd(nativeRange.getEndContainer(), nativeRange.getEndOffset());
+ ((NativeRangeWrapper) range).setNativeRange(nativeRange);
+
+ return range;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#getRangeCount()
+ */
+ public int getRangeCount()
+ {
+ return nativeSelection.getRangeCount();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#removeAllRanges()
+ */
+ public void removeAllRanges()
+ {
+ nativeSelection.removeAllRanges();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#removeRange(Range)
+ */
+ public void removeRange(Range range)
+ {
+ NativeRangeWrapper wrapper = (NativeRangeWrapper) range;
+ nativeSelection.removeRange((NativeRange) wrapper.getNativeRange());
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelectionManager.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelectionManager.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/DefaultSelectionManager.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,43 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
+import com.xpn.xwiki.wysiwyg.client.dom.SelectionManager;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla.NativeSelection;
+
+/**
+ * The default {@link SelectionManager} implementation. Retrieves the selection object using Mozilla's API.
+ *
+ * @version $Id$
+ */
+public class DefaultSelectionManager implements SelectionManager
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see SelectionManager#getSelection(Document)
+ */
+ public Selection getSelection(Document document)
+ {
+ return new DefaultSelection(NativeSelection.getInstance(document));
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/NativeRangeWrapper.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/NativeRangeWrapper.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/NativeRangeWrapper.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,42 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal;
+
+import com.xpn.xwiki.wysiwyg.client.dom.JavaScriptObject;
+
+/**
+ * Interface to access the native range object wrapped by a specific range implementation.
+ *
+ * @version $Id$
+ */
+public interface NativeRangeWrapper
+{
+ /**
+ * @return the native range wrapped by this object.
+ */
+ JavaScriptObject getNativeRange();
+
+ /**
+ * Sets the native range to be wrapped by this object.
+ *
+ * @param nativeRange the native range to be wrapped by this object.
+ */
+ void setNativeRange(JavaScriptObject nativeRange);
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/ControlRange.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/ControlRange.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/ControlRange.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,90 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+
+/**
+ * A control range is a list of DOM elements. When an element is added to a control range and that range is selected the
+ * element will be decorated with special markers for editing that element. For instance if an image is selected this
+ * way the user will be able to resize the image.
+ *
+ * @version $Id$
+ */
+public final class ControlRange extends NativeRange
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected ControlRange()
+ {
+ }
+
+ /**
+ * Creates a new control range from the given document.
+ *
+ * @param doc The owner document of the created control range.
+ * @return A new control range within the specified document.
+ */
+ public static native ControlRange newInstance(Document doc)
+ /*-{
+ var controlRange = doc.body.createControlRange();
+ controlRange.ownerDocument = doc;
+ return controlRange;
+ }-*/;
+
+ /**
+ * @return The number of objects included the range.
+ */
+ public native int getLength()
+ /*-{
+ return this.length;
+ }-*/;
+
+ /**
+ * Adds an element to the control range.
+ *
+ * @param element The element to include in this range.
+ */
+ public native void add(Element element)
+ /*-{
+ this.addElement(element);
+ }-*/;
+
+ /**
+ * @param index Zero-based index of the element to get.
+ * @return The element at the specified index in this control range.
+ */
+ public native Element get(int index)
+ /*-{
+ return this.item(index);
+ }-*/;
+
+ /**
+ * Removes an element from this control range.
+ *
+ * @param index Zero-based index of the element to remove from the control range.
+ */
+ public native void remove(int index)
+ /*-{
+ this.remove(index);
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IEDOMUtils.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IEDOMUtils.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IEDOMUtils.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,141 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.DOMUtils;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+import com.xpn.xwiki.wysiwyg.client.dom.Style;
+
+/**
+ * Contains methods from {@link DOMUtils} that require a different implementation in Internet Explorer.
+ *
+ * @version $Id$
+ */
+public class IEDOMUtils extends DOMUtils
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getComputedStyleProperty(Element, String)
+ */
+ public String getComputedStyleProperty(Element el, String propertyName)
+ {
+ return getComputedStylePropertyIE(el, Style.toCamelCase(propertyName));
+ }
+
+ /**
+ * @param el The element for which we retrieve the computed value of the given style property.
+ * @param propertyName The name of the property in camel case format.
+ * @return The computed value of the given style property on the specified element.
+ */
+ private native String getComputedStylePropertyIE(Element el, String propertyName)
+ /*-{
+ // We force it to be a string because we treat it as a string in the java code.
+ return '' + el.currentStyle[propertyName];
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#importNode(Document, Node, boolean)
+ */
+ public Node importNode(Document doc, Node externalNode, boolean deep)
+ {
+ switch (externalNode.getNodeType()) {
+ case Node.TEXT_NODE:
+ return doc.createTextNode(externalNode.getNodeValue());
+ case Node.ELEMENT_NODE:
+ Element externalElement = Element.as(externalNode);
+ Element internalElement = doc.xCreateElement(externalElement.getTagName());
+ JsArrayString attrNames = getAttributeNames(externalElement);
+ for (int i = 0; i < attrNames.length(); i++) {
+ String attrName = attrNames.get(i);
+ internalElement.setAttribute(attrName, externalElement.getAttribute(attrName));
+ }
+ if (deep) {
+ // TODO
+ }
+ return internalElement;
+ default:
+ throw new IllegalArgumentException("Cannot import node of type " + externalNode.getNodeType() + "!");
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getAttributeNames(Element)
+ */
+ public native JsArrayString getAttributeNames(Element element)
+ /*-{
+ var attrNames = [];
+ for(var i = 0; i < element.attributes.length; i++){
+ if(element.attributes[i].specified) {
+ attrNames.push(element.attributes[i].nodeName);
+ }
+ }
+ return attrNames;
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#setInnerHTML(Element, String)
+ * @see http://code.google.com/p/google-web-toolkit/issues/detail?id=3146
+ */
+ public void setInnerHTML(Element element, String html)
+ {
+ element.setInnerHTML("<span>iesucks</span>" + html);
+ element.removeChild(element.getFirstChild());
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getAttribute(Element, String)
+ */
+ public String getAttribute(Element element, String name)
+ {
+ return element.getAttribute(name) + "";
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getInnerText(Element)
+ */
+ public native String getInnerText(Element element)
+ /*-{
+ return element.innerText;
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#hasAttribute(Element, String)
+ */
+ public native boolean hasAttribute(Element element, String attrName)
+ /*-{
+ return element.getAttribute(attrName) != null;
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,496 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.google.gwt.dom.client.ImageElement;
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.DOMUtils;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.RangeCompare;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.AbstractSelection;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.ie.TextRange.Unit;
+
+/**
+ * The implementation of Mozilla's selection specification using Internet Explorer's selection API.
+ *
+ * @version $Id$
+ */
+public class IESelection extends AbstractSelection
+{
+ /**
+ * Specifies where a range starts or ends inside the DOM tree.
+ */
+ protected static final class RangeBoundary
+ {
+ /**
+ * The node containing the range boundary.
+ */
+ private final Node container;
+
+ /**
+ * The offset within the {@link #container} where the boundary is placed.
+ */
+ private final int offset;
+
+ /**
+ * Creates a new range boundary.
+ *
+ * @param container {@link #container}
+ * @param offset {@link #offset}
+ */
+ public RangeBoundary(Node container, int offset)
+ {
+ this.container = container;
+ this.offset = offset;
+ }
+
+ /**
+ * @return {@link #container}
+ */
+ public Node getContainer()
+ {
+ return container;
+ }
+
+ /**
+ * @return {@link #offset}
+ */
+ public int getOffset()
+ {
+ return offset;
+ }
+
+ }
+
+ /**
+ * The list of elements supporting control selection.
+ */
+ private static final String[] SELECTABLE_ELEMENTS = new String[] {"img", "button"};
+
+ /**
+ * The underlying native selection object provided by the browser.
+ */
+ private final NativeSelection nativeSelection;
+
+ /**
+ * The element used to mark the start of the selection.
+ *
+ * @see #addRange(Range)
+ */
+ private final Element startMarker;
+
+ /**
+ * The native text range used to set the start of the selection.
+ *
+ * @see TextRange#setEndPoint(RangeCompare, TextRange)
+ * @see #addRange(Range)
+ */
+ private final TextRange startRef;
+
+ /**
+ * The element used to mark the end of the selection.
+ *
+ * @see #addRange(Range)
+ */
+ private final Element endMarker;
+
+ /**
+ * The native text range used to set the end of the selection.
+ *
+ * @see TextRange#setEndPoint(RangeCompare, TextRange)
+ * @see #addRange(Range)
+ */
+ private final TextRange endRef;
+
+ /**
+ * Creates a new instance that wraps the given native selection object. This object will be used to implement
+ * Mozilla's selection specification.
+ *
+ * @param nativeSelection the underlying native selection object to be used
+ */
+ public IESelection(NativeSelection nativeSelection)
+ {
+ this.nativeSelection = nativeSelection;
+ startMarker = createBoundaryMarker();
+ startRef = TextRange.newInstance(nativeSelection.getOwnerDocument());
+ endMarker = (Element) startMarker.cloneNode(true);
+ endRef = startRef.duplicate();
+ }
+
+ /**
+ * @return {@link #nativeSelection}
+ */
+ protected NativeSelection getNativeSelection()
+ {
+ return nativeSelection;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#addRange(Range)
+ */
+ public void addRange(Range range)
+ {
+ if (range.getStartContainer() == range.getEndContainer()
+ && range.getStartContainer().getNodeType() == Node.ELEMENT_NODE
+ && range.getStartOffset() == range.getEndOffset() - 1) {
+ Node selectedNode = range.getStartContainer().getChildNodes().getItem(range.getStartOffset());
+ // Test if the selected node supports control selection.
+ if (supportsControlSelection(selectedNode)) {
+ ControlRange controlRange = ControlRange.newInstance(nativeSelection.getOwnerDocument());
+ controlRange.add((Element) selectedNode);
+ controlRange.select();
+ return;
+ }
+ }
+
+ // Otherwise use text selection.
+ addTextRange(adjustRangeAndDOM(range));
+ }
+
+ /**
+ * @param node a DOM node
+ * @return {@code true} if the given node supports control selection, {@code false} otherwise
+ */
+ private boolean supportsControlSelection(Node node)
+ {
+ for (int i = 0; i < SELECTABLE_ELEMENTS.length; i++) {
+ if (SELECTABLE_ELEMENTS[i].equalsIgnoreCase(node.getNodeName())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Adjusts the given range and the DOM tree prior to selecting the range. We have to do this because IE selection
+ * boundaries cannot, in most of the cases, be placed inside empty elements or empty text nodes or at the beginning
+ * of a text node.
+ *
+ * @param range the range to be adjusted
+ * @return the adjusted range
+ */
+ private Range adjustRangeAndDOM(Range range)
+ {
+ Node start = range.getStartContainer();
+ if (range.isCollapsed() && start.getNodeType() == Node.TEXT_NODE && range.getStartOffset() == 0
+ && !isTextBefore(start)) {
+ start.setNodeValue("\u00A0" + start.getNodeValue());
+ Range adjusted = range.cloneRange();
+ adjusted.setEnd(start, 1);
+ return adjusted;
+ }
+ return range;
+ }
+
+ /**
+ * Utility method for testing if the previous sibling (skipping empty text nodes) of a DOM node is a non-empty text
+ * node.
+ *
+ * @param node a DOM node
+ * @return true if the previous sibling, skipping empty text nodes, of the given node is a non-empty text node
+ */
+ private boolean isTextBefore(Node node)
+ {
+ Node sibling = node.getPreviousSibling();
+ // Skip empty text nodes.
+ while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().length() == 0) {
+ sibling = sibling.getPreviousSibling();
+ }
+ return sibling != null && sibling.getNodeType() == Node.TEXT_NODE;
+ }
+
+ /**
+ * Creates a text selection from the given range.
+ *
+ * @param range the range to be added to the selection
+ */
+ protected void addTextRange(Range range)
+ {
+ DOMUtils domUtils = DOMUtils.getInstance();
+ int leftOffset = 0;
+ int rightOffset = domUtils.getLength(range.getEndContainer()) - range.getEndOffset();
+
+ switch (range.getStartContainer().getNodeType()) {
+ case Node.TEXT_NODE:
+ leftOffset = range.getStartOffset();
+ // fall through
+ case DOMUtils.CDATA_NODE:
+ case DOMUtils.COMMENT_NODE:
+ range.getStartContainer().getParentNode().insertBefore(startMarker, range.getStartContainer());
+ break;
+ case Node.ELEMENT_NODE:
+ domUtils.insertAt(range.getStartContainer(), startMarker, range.getStartOffset());
+ break;
+ default:
+ throw new IllegalArgumentException();
+ }
+ startRef.moveToElementText(startMarker);
+ startRef.moveEnd(Unit.CHARACTER, leftOffset);
+
+ switch (range.getEndContainer().getNodeType()) {
+ case DOMUtils.CDATA_NODE:
+ case DOMUtils.COMMENT_NODE:
+ rightOffset = 0;
+ // fall through
+ case Node.TEXT_NODE:
+ domUtils.insertAfter(endMarker, range.getEndContainer());
+ break;
+ case Node.ELEMENT_NODE:
+ domUtils.insertAt(range.getEndContainer(), endMarker, range.getEndContainer().getChildNodes()
+ .getLength()
+ - rightOffset);
+ rightOffset = 0;
+ break;
+ default:
+ throw new IllegalArgumentException();
+ }
+ endRef.moveToElementText(endMarker);
+ endRef.moveStart(Unit.CHARACTER, -rightOffset);
+
+ TextRange textRange = TextRange.newInstance(nativeSelection.getOwnerDocument());
+ textRange.setEndPoint(RangeCompare.END_TO_START, startRef);
+ textRange.setEndPoint(RangeCompare.START_TO_END, endRef);
+
+ domUtils.detach(startMarker);
+ domUtils.detach(endMarker);
+
+ textRange.select();
+ }
+
+ /**
+ * @return an element that can be used a range boundary marker for this selection
+ */
+ protected Element createBoundaryMarker()
+ {
+ ImageElement marker = nativeSelection.getOwnerDocument().xCreateImageElement();
+ marker.setWidth(0);
+ marker.setHeight(0);
+ return marker.cast();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#getRangeAt(int)
+ */
+ public Range getRangeAt(int index)
+ {
+ if (index != 0) {
+ throw new IndexOutOfBoundsException();
+ }
+
+ NativeRange nativeRange = nativeSelection.createRange();
+ Range range = nativeRange.getOwnerDocument().createRange();
+
+ if (nativeRange.isTextRange()) {
+ TextRange textRange = (TextRange) nativeRange;
+
+ RangeBoundary start = getBoundary(textRange, true);
+ range.setStart(start.getContainer(), start.getOffset());
+
+ RangeBoundary end = getBoundary(textRange, false);
+ range.setEnd(end.getContainer(), end.getOffset());
+ } else {
+ range.selectNode(((ControlRange) nativeRange).get(0));
+ }
+
+ return range;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#getRangeCount()
+ */
+ public int getRangeCount()
+ {
+ return 1;
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#removeAllRanges()
+ */
+ public void removeAllRanges()
+ {
+ getNativeSelection().empty();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see AbstractSelection#removeRange(Range)
+ */
+ public void removeRange(Range range)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * Computes the start or end container of a text range.
+ *
+ * @param textRange the text range for which to compute the boundary container
+ * @param start specifies which boundary container to compute
+ * @return the container of the range's start , if start is true, or the container of the range's end, otherwise
+ */
+ protected RangeBoundary getBoundary(TextRange textRange, boolean start)
+ {
+ // Determine the element containing the specified range boundary.
+ TextRange refRange = textRange.duplicate();
+ refRange.collapse(start);
+ Node container = refRange.getParentElement();
+ // The specified range boundary is either between child nodes or inside a text node.
+
+ // We use a text range to find the text node that could possibly contain the range boundary.
+ TextRange searchRange = TextRange.newInstance(textRange.getOwnerDocument());
+ searchRange.moveToElementText((Element) container);
+
+ // The claws used to catch the specified range boundary.
+ RangeCompare compareStart = RangeCompare.valueOf(true, start);
+ RangeCompare compareEnd = RangeCompare.valueOf(false, start);
+
+ // Iterate through all child nodes in search for the range boundary.
+ Node child = container.getFirstChild();
+ int offset = 0;
+ while (child != null) {
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ // Move the reference range before this child element.
+ moveTextRangeBeforeElement(refRange, (Element) child);
+ // Let's see if the boundary is before this child element.
+ if (textRange.compareEndPoints(compareStart, refRange) <= 0) {
+ break;
+ }
+ } else if (child.getNodeType() == Node.TEXT_NODE && child.getNodeValue().length() > 0) {
+ // Select this text node.
+ refRange = searchRange.duplicate();
+ // We have to convert nbsp's to plain spaces because TextRange#getText seems to do so.
+ if (!refRange.findText(child.getNodeValue().replace('\u00A0', '\u0020'), 0, 4)) {
+ // We shouldn't get here!
+ throw new RuntimeException("Unexpected behavior of TextRange#findText");
+ }
+ // See if the range boundary is inside this text node.
+ if (textRange.compareEndPoints(compareEnd, refRange) <= 0) {
+ if (textRange.compareEndPoints(compareStart, refRange) >= 0) {
+ container = child;
+ // Now we have to compute the offset within this text node.
+ offset = getOffset(refRange, textRange, start);
+ }
+ // We either found the boundary or passed beyond it.
+ break;
+ }
+ // Update the search range.
+ searchRange.setEndPoint(RangeCompare.END_TO_START, refRange);
+ }
+ child = child.getNextSibling();
+ offset++;
+ }
+ return new RangeBoundary(container, offset);
+ }
+
+ /**
+ * Moves the given text range before the specified element.
+ *
+ * @param textRange the text range to be moved
+ * @param element the element before which the text range is moved
+ */
+ protected void moveTextRangeBeforeElement(TextRange textRange, Element element)
+ {
+ textRange.moveToElementText(element);
+ // Sometimes moveToElementText has unexpected results. Let's test if textRange starts before element and if not
+ // then try something different.
+ int left = getLeft(element);
+ int top = getTop(element);
+ if (textRange.getOffsetLeft() != left || top < textRange.getOffsetTop()
+ || top > (textRange.getOffsetTop() + getFirstLineHeight(textRange))) {
+ // This can fail moving the text range before the element too (that's why we tried moveToElementText first).
+ textRange.moveToPoint(left, top);
+ // Don't bet on the result!
+ }
+ }
+
+ /**
+ * NOTE: For a {@code strong} element that starts in the middle of a line and spans multiple lines this method
+ * returns the distance in pixels from its first character (provided it starts with text) to the left boundary of
+ * the parent window. This is important since the bounding rectangle of the {@code strong} element can have the
+ * width of the parent window so the distance from the left side of this bounding rectangle to the left boundary of
+ * the parent window could be 0.
+ *
+ * @param element a DOM element
+ * @return the distance, in pixels, from the given element's start point to the left boundary of the parent window
+ */
+ protected native int getLeft(Element element)
+ /*-{
+ var left = -element.ownerDocument.documentElement.scrollLeft;
+ while (element) {
+ left += element.offsetLeft + element.clientLeft - element.scrollLeft;
+ element = element.offsetParent;
+ }
+ return left;
+ }-*/;
+
+ /**
+ * @param element a DOM element
+ * @return the distance, in pixels, from the given element's start point to the top boundary of the parent window
+ */
+ protected native int getTop(Element element)
+ /*-{
+ var top = -element.ownerDocument.documentElement.scrollTop;
+ while (element) {
+ top += element.offsetTop + element.clientTop - element.scrollTop;
+ element = element.offsetParent;
+ }
+ return top;
+ }-*/;
+
+ /**
+ * @param textRange a text range
+ * @return the height, in pixels, of the first line selected by the given text range
+ */
+ protected native int getFirstLineHeight(TextRange textRange)
+ /*-{
+ var firstLineRect = textRange.getClientRects()[0];
+ return firstLineRect.bottom - firstLineRect.top;
+ }-*/;
+
+ /**
+ * Computes the number of characters between the start of the left range to the specified boundary of the right
+ * range. The given ranges need to overlap and the start of the left range has to be before or equal to the
+ * specified boundary of the right range.
+ *
+ * @param left the left text range
+ * @param right the rich text range
+ * @param rightBoundary specifies which boundary of the right text range to consider. Use {@code true} for start
+ * boundary and {@code false} for end boundary.
+ * @return the offset of the right range from the start of the left range
+ */
+ protected int getOffset(TextRange left, TextRange right, boolean rightBoundary)
+ {
+ int offset = 0;
+ RangeCompare whichEndPoints = RangeCompare.valueOf(rightBoundary, true);
+ while (left.compareEndPoints(whichEndPoints, right) < 0 && left.moveStart(Unit.CHARACTER, 1) > 0) {
+ offset++;
+ }
+ return offset;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelectionManager.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelectionManager.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/IESelectionManager.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,42 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
+import com.xpn.xwiki.wysiwyg.client.dom.SelectionManager;
+
+/**
+ * {@link SelectionManager} implementation for Internet Explorer.
+ *
+ * @version $Id$
+ */
+public final class IESelectionManager implements SelectionManager
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see SelectionManager#getSelection(Document)
+ */
+ public Selection getSelection(Document doc)
+ {
+ return new IESelection(NativeSelection.getInstance(doc));
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeRange.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeRange.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeRange.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,74 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+
+/**
+ * Base class for {@link TextRange} and {@link ControlRange}, the two types of range provided by Internet Explorer.
+ *
+ * @version $Id$
+ */
+public class NativeRange extends JavaScriptObject
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected NativeRange()
+ {
+ }
+
+ /**
+ * Makes the selection equal to the current object. When applied to a TextRange object, the select method causes the
+ * current object to be highlighted. When applied to a ControlRange object, the select method produces a shaded
+ * rectangle around the elements in the control range.
+ */
+ public final native void select()
+ /*-{
+ this.select();
+ }-*/;
+
+ /**
+ * @return The document used to create this range.
+ */
+ public final native Document getOwnerDocument()
+ /*-{
+ return this.ownerDocument;
+ }-*/;
+
+ /**
+ * This method is needed because <code>instanceof</code> operator returns true all the time when applied on a
+ * overlay type. For instance:<br/>
+ *
+ * <pre>
+ * TextRange textRange = TextRange.newInstance(doc);
+ * boolean result = textRange instanceof TextRange; // result is true, which is right.
+ * result = textRange instanceof ControlRange // result is also true, which is wrong.
+ * </pre>
+ *
+ * @return true if this is a text range, and false if it is a control range.
+ * @see http://code.google.com/p/google-web-toolkit/wiki/OverlayTypes
+ */
+ public final native boolean isTextRange()
+ /*-{
+ return this.item ? false : true;
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeSelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeSelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/NativeSelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,101 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.google.gwt.core.client.JavaScriptObject;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+
+/**
+ * Wraps the selection JavaScript object provided by Internet Explorer.
+ *
+ * @version $Id$
+ */
+public final class NativeSelection extends JavaScriptObject
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected NativeSelection()
+ {
+ }
+
+ /**
+ * @param doc The DOM document for which to retrieve the selection object.
+ * @return The selection object associated with the given in-line frame.
+ */
+ public static synchronized native NativeSelection getInstance(Document doc)
+ /*-{
+ var selection = doc.selection;
+ selection.ownerDocument = doc;
+ return selection;
+ }-*/;
+
+ /**
+ * Retrieves the type of selection.
+ *
+ * @return One of the following values:
+ * <ul>
+ * <li>none: No selection/insertion point.</li>
+ * <li>text: Specifies a text selection.</li>
+ * <li>control: Specifies a control selection, which enables dimension controls allowing the selected object
+ * to be resized.</li>
+ * </ul>
+ */
+ public native String getType()
+ /*-{
+ return this.type;
+ }-*/;
+
+ /**
+ * Clears the contents of the selection.
+ */
+ public native void clear()
+ /*-{
+ this.clear();
+ }-*/;
+
+ /**
+ * Creates a TextRange object from the current text selection, or a ControlRange object from a control selection.
+ *
+ * @return The created range object.
+ */
+ public native NativeRange createRange()
+ /*-{
+ var range = this.createRange();
+ range.ownerDocument = this.ownerDocument;
+ return range;
+ }-*/;
+
+ /**
+ * Cancels the current selection and sets the selection type to none.
+ */
+ public native void empty()
+ /*-{
+ this.empty();
+ }-*/;
+
+ /**
+ * @return The document associated with this selection object.
+ */
+ public native Document getOwnerDocument()
+ /*-{
+ return this.ownerDocument;
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/TextRange.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/TextRange.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/ie/TextRange.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,520 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.ie;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+import com.xpn.xwiki.wysiwyg.client.dom.RangeCompare;
+
+/**
+ * A text range is a DOM fragment that usually starts and ends inside a text node. It can be used to visually select a
+ * continuous text fragment.
+ *
+ * @version $Id$
+ */
+public final class TextRange extends NativeRange
+{
+ /**
+ * A unit defining a fragment of a text range. It is used when moving the end points of a text range.
+ */
+ public static enum Unit
+ {
+ /**
+ * A character.
+ */
+ CHARACTER,
+ /**
+ * A word is a collection of characters terminated by a space or some other white-space character, such as a
+ * tab.
+ */
+ WORD,
+ /**
+ * A sentence is a collection of words terminated by a punctuation character, such as a period.
+ */
+ SENTENCE,
+ /**
+ * The start or end of the original range.
+ */
+ TEXTEDIT
+ }
+
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected TextRange()
+ {
+ }
+
+ /**
+ * Creates a new text range for the given document. This range can be used to select only DOM nodes within this
+ * document.
+ *
+ * @param doc The owner document of the created range.
+ * @return The created text range.
+ */
+ public static native TextRange newInstance(Document doc)
+ /*-{
+ var textRange = doc.body.createTextRange();
+ textRange.ownerDocument = doc;
+ return textRange;
+ }-*/;
+
+ /**
+ * @return The HTML source as a valid HTML fragment.
+ */
+ public native String getHTML()
+ /*-{
+ return this.htmlText;
+ }-*/;
+
+ /**
+ * Pastes HTML text into this text range, replacing any previous text and HTML elements in the range. This method
+ * might alter the HTML text to make it fit the given text range. For example, pasting a table cell into a text
+ * range that does not contain a table might cause the method to insert a table element. For predictable results,
+ * paste only well-formed HTML text that fits within the given text range.
+ *
+ * @param html The HTML text to paste. The string can contain text and any combination of the HTML tags.
+ */
+ public native void setHTML(String html)
+ /*-{
+ this.pasteHTML(html);
+ }-*/;
+
+ /**
+ * @return The text contained within the range.
+ */
+ public native String getText()
+ /*-{
+ return this.text;
+ }-*/;
+
+ /**
+ * @param text The text to be placed inside the range.
+ */
+ public native void setText(String text)
+ /*-{
+ this.text = text;
+ }-*/;
+
+ /**
+ * Moves the insertion point to the beginning or end of the current range.
+ *
+ * @param toStart if true moves the insertion point to the beginning of the text range. Otherwise, moves the
+ * insertion point to the end of the text range.
+ */
+ public native void collapse(boolean toStart)
+ /*-{
+ this.collapse(toStart);
+ }-*/;
+
+ /**
+ * Compares an end point of a TextRange object with an end point of another range. A text range has two end points.
+ * One end point is located at the beginning of the text range, and the other is located at the end of the text
+ * range. An end point also can be characterized as the position between two characters in an HTML document.
+ *
+ * @param how Specifies which end points to compare.
+ * @param range The range object to compare with this object.
+ * @return One of the following possible values:
+ * <ul>
+ * <li>-1 if the end point of this object is further to the left than the end point of the given range.</li>
+ * <li>0 if the end point of this object is at the same location as the end point of the given range.</li>
+ * <li>1 if the end point of this object is further to the right than the end point of the given range.</li>
+ * </ul>
+ */
+ public short compareEndPoints(RangeCompare how, TextRange range)
+ {
+ // In Internet Explorer the meaning of RangeCompare is reversed, so we reverse the end points.
+ return compareEndPoints(how.reverse().toString(), range);
+ }
+
+ /**
+ * Compares an end point of a TextRange object with an end point of another range. A text range has two end points.
+ * One end point is located at the beginning of the text range, and the other is located at the end of the text
+ * range. An end point also can be characterized as the position between two characters in an HTML document.
+ *
+ * @param type Can be one of the following:
+ * <ul>
+ * <li>StartToEnd: Compare the start of this TextRange object with the end of the range parameter.</li>
+ * <li>StartToStart: Compare the start of this TextRange object with the start of the given range
+ * parameter.</li>
+ * <li>EndToStart: Compare the end of this TextRange object with the start of the range parameter.</li>
+ * <li>EndToEnd: Compare the end of this TextRange object with the end of the range parameter.</li>
+ * </ul>
+ * @param range TextRange object that specifies the range to compare with this object.
+ * @return One of the following possible values:
+ * <ul>
+ * <li>-1 if the end point of this object is further to the left than the end point of the given range.</li>
+ * <li>0 if the end point of this object is at the same location as the end point of the given range.</li>
+ * <li>1 if the end point of this object is further to the right than the end point of the given range.</li>
+ * </ul>
+ */
+ private native short compareEndPoints(String type, TextRange range)
+ /*-{
+ return this.compareEndPoints(type, range);
+ }-*/;
+
+ /**
+ * @return A duplicate of this TextRange.
+ */
+ public native TextRange duplicate()
+ /*-{
+ var clone = this.duplicate();
+ clone.ownerDocument = this.ownerDocument;
+ return clone;
+ }-*/;
+
+ /**
+ * Collapses the given text range and moves the empty range by the given number of units.
+ *
+ * @param unit Specifies the units to move
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ public int move(Unit unit, int count)
+ {
+ return move(unit.toString(), count);
+ }
+
+ /**
+ * Collapses the given text range and moves the empty range by the given number of units.
+ *
+ * @param unit Specifies the units to move, using one of the following values:
+ * <ul>
+ * <li>character: Moves one or more characters.</li>
+ * <li>word: Moves one or more words. A word is a collection of characters terminated by a space or some
+ * other white-space character, such as a tab.</li>
+ * <li>sentence: Moves one or more sentences. A sentence is a collection of words terminated by a
+ * punctuation character, such as a period.</li>
+ * <li>textedit: Moves to the start or end of the original range.</li>
+ * </ul>
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ private native int move(String unit, int count)
+ /*-{
+ return this.move(unit, count);
+ }-*/;
+
+ /**
+ * Moves the end of this range by the given number of units.
+ *
+ * @param unit Specifies the units to move.
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ public int moveEnd(Unit unit, int count)
+ {
+ return moveEnd(unit.toString(), count);
+ }
+
+ /**
+ * Moves the end of this range by the given number of units.
+ *
+ * @param unit Specifies the units to move, using one of the following values:
+ * <ul>
+ * <li>character: Moves one or more characters.</li>
+ * <li>word: Moves one or more words. A word is a collection of characters terminated by a space or some
+ * other white-space character, such as a tab.</li>
+ * <li>sentence: Moves one or more sentences. A sentence is a collection of words terminated by a
+ * punctuation character, such as a period.</li>
+ * <li>textedit: Moves to the start or end of the original range.</li>
+ * </ul>
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ private native int moveEnd(String unit, int count)
+ /*-{
+ return this.moveEnd(unit, count);
+ }-*/;
+
+ /**
+ * Moves the start of this range by the given number of units.
+ *
+ * @param unit Specifies the units to move.
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ public int moveStart(Unit unit, int count)
+ {
+ return moveStart(unit.toString(), count);
+ }
+
+ /**
+ * Moves the start of this range by the given number of units.
+ *
+ * @param unit Specifies the units to move, using one of the following values:
+ * <ul>
+ * <li>character: Moves one or more characters.</li>
+ * <li>word: Moves one or more words. A word is a collection of characters terminated by a space or some
+ * other white-space character, such as a tab.</li>
+ * <li>sentence: Moves one or more sentences. A sentence is a collection of words terminated by a
+ * punctuation character, such as a period.</li>
+ * <li>textedit: Moves to the start or end of the original range.</li>
+ * </ul>
+ * @param count Specifies the number of units to move. This can be positive or negative.
+ * @return The number of units moved.
+ */
+ private native int moveStart(String unit, int count)
+ /*-{
+ return this.moveStart(unit, count);
+ }-*/;
+
+ /**
+ * Moves the text range so that the start and end positions of the range encompass the text in the given element.
+ *
+ * @param element The element object to move to.
+ */
+ public native void moveToElementText(Element element)
+ /*-{
+ this.moveToElementText(element);
+ }-*/;
+
+ /**
+ * The parent element is the element that completely encloses the text in the range. If the text range spans text in
+ * more than one element, this method returns the smallest element that encloses all the elements. When you insert
+ * text into a range that spans multiple elements, the text is placed in the parent element rather than in any of
+ * the contained elements.
+ *
+ * @return The parent element for this text range.
+ */
+ public native Element getParentElement()
+ /*-{
+ return this.parentElement();
+ }-*/;
+
+ /**
+ * Sets the end point of this range based on the end point of another range. A text range has two end points: one at
+ * the beginning of the text range and one at the end. An end point can also be the position between two characters
+ * in an HTML document.
+ *
+ * @param how Specifies which end point of this text range should be moved and which of the given text range's end
+ * points is the reference.
+ * @param range The text range used as the reference.
+ */
+ public void setEndPoint(RangeCompare how, TextRange range)
+ {
+ // In Internet Explorer the meaning of RangeCompare is reversed, so we reverse the end points.
+ switch (how) {
+ case END_TO_START:
+ // Move the start of this range to the end of the given range.
+ if (compareEndPoints(RangeCompare.END_TO_END, range) < 0) {
+ // The end point needs to be updated also because other wise the start point will go beyond the end
+ // point.
+ setEndPoint(RangeCompare.END_TO_END.toString(), range);
+ }
+ break;
+ case START_TO_START:
+ // Move the start of this range to the start of the given range.
+ if (compareEndPoints(RangeCompare.START_TO_END, range) < 0) {
+ // The end point needs to be updated also because other wise the start point will go beyond the end
+ // point.
+ setEndPoint(RangeCompare.END_TO_START.toString(), range);
+ }
+ break;
+ case END_TO_END:
+ // Move the end of this range to the end of the given range.
+ if (compareEndPoints(RangeCompare.END_TO_START, range) > 0) {
+ // The start point needs to be updated also because other wise the end point will go before the
+ // start point.
+ setEndPoint(RangeCompare.START_TO_END.toString(), range);
+ }
+ break;
+ case START_TO_END:
+ // Move the end of this range to the start of the given range.
+ if (compareEndPoints(RangeCompare.START_TO_START, range) > 0) {
+ // The start point needs to be updated also because other wise the end point will go before the
+ // start point.
+ setEndPoint(RangeCompare.START_TO_START.toString(), range);
+ }
+ break;
+ default:
+ // We shouldn't get here.
+ }
+ setEndPoint(how.reverse().toString(), range);
+ }
+
+ /**
+ * Sets the end point of this range based on the end point of another range. A text range has two end points: one at
+ * the beginning of the text range and one at the end. An end point can also be the position between two characters
+ * in an HTML document.
+ *
+ * @param type Specifies the end point to transfer using one of the following values:
+ * <ul>
+ * <li>StartToEnd: Move the start of this TextRange object to the end of the range parameter.</li>
+ * <li>StartToStart: Move the start of this TextRange object to the start of the range parameter.</li>
+ * <li>EndToStart: Move the end of this TextRange object to the start of the range parameter.</li>
+ * <li>EndToEnd: Move the end of this TextRange object to the end of the range parameter.</li>
+ * </ul>
+ * @param range TextRange object from which the source end point is to be taken.
+ */
+ private native void setEndPoint(String type, TextRange range)
+ /*-{
+ this.setEndPoint(type, range);
+ }-*/;
+
+ /**
+ * Searches for text in the document and positions the start and end points of the range to encompass the search
+ * string.<br/>
+ * The value passed for the searchScope parameter controls the part of the document, relative to the range, that is
+ * searched. The behavior of the findText method depends on whether the range is collapsed or not:
+ * <ul>
+ * <li>If the range is collapsed, passing a large positive number causes the text to the right of the range to be
+ * searched. Passing a large negative number causes the text to the left of the range to be searched.</li>
+ * <li>If the range is not collapsed, passing a large positive number causes the text to the right of the start of
+ * the range to be searched. Passing a large negative number causes the text to the left of the end of the range to
+ * be searched. Passing 0 causes only the text selected by the range to be searched.</li>
+ * </ul>
+ * A text range is not modified if the text specified for the findText method is not found.
+ *
+ * @param text The text to find.
+ * @param searchScope The number of characters to search from the starting point of the range. A positive integer
+ * indicates a forward search; a negative integer indicates a backward search.
+ * @param flags One or more of the following flags to indicate the type of search:
+ * <table>
+ * <tr>
+ * <td>0</td>
+ * <td>Default. Match partial words.</td>
+ * </tr>
+ * <tr>
+ * <td>1</td>
+ * <td>Match backwards.</td>
+ * </tr>
+ * <tr>
+ * <td>2</td>
+ * <td>Match whole words only.</td>
+ * </tr>
+ * <tr>
+ * <td>4</td>
+ * <td>Match case.</td>
+ * </tr>
+ * <tr>
+ * <td>131072</td>
+ * <td>Match bytes.</td>
+ * </tr>
+ * <tr>
+ * <td>536870912</td>
+ * <td>Match diacritical marks.</td>
+ * </tr>
+ * <tr>
+ * <td>1073741824</td>
+ * <td>Match Kashida character.</td>
+ * </tr>
+ * <tr>
+ * <td>2147483648</td>
+ * <td>Match AlefHamza character.</td>
+ * </tr>
+ * </table>
+ * @return true if the given text was found.
+ */
+ public native boolean findText(String text, int searchScope, int flags)
+ /*-{
+ return this.findText(text, searchScope, flags);
+ }-*/;
+
+ /**
+ * Tests if this text range equals the given text range.
+ *
+ * @param other the text range to compare with this text range.
+ * @return true if the given text range is equal to this text rage.
+ */
+ public native boolean isEqual(TextRange other)
+ /*-{
+ return this.isEqual(other);
+ }-*/;
+
+ /**
+ * Tests whether one range is contained within another.
+ *
+ * @param other The text range that might be contained in this text range.
+ * @return true if the given text range is contained within or is equal to this text range.
+ */
+ public native boolean inRange(TextRange other)
+ /*-{
+ return this.inRange(other);
+ }-*/;
+
+ /**
+ * Expands the range so that partial units are completely contained.
+ *
+ * @param unit specifies the units that have to be completely included in the range
+ * @return {@code true} if the range was successfully expanded, {@code false} otherwise
+ */
+ public boolean expand(Unit unit)
+ {
+ return expand(unit.toString());
+ }
+
+ /**
+ * Expands the range so that partial units are completely contained.
+ *
+ * @param unit specifies the units that have to be completely included in the range, using one of the following
+ * values:
+ * <ul>
+ * <li>character: Moves one or more characters.</li>
+ * <li>word: Moves one or more words. A word is a collection of characters terminated by a space or some
+ * other white-space character, such as a tab.</li>
+ * <li>sentence: Moves one or more sentences. A sentence is a collection of words terminated by a
+ * punctuation character, such as a period.</li>
+ * <li>textedit: Moves to the start or end of the original range.</li>
+ * </ul>
+ * @return {@code true} if the range was successfully expanded, {@code false} otherwise
+ */
+ private native boolean expand(String unit)
+ /*-{
+ return this.expand(unit);
+ }-*/;
+
+ /**
+ * Moves the start and end positions of this text range to the given point.
+ * <p>
+ * The coordinates of the point must be in pixels and be relative to the upper-left corner of the window. The
+ * resulting text range is empty, but you can expand and move the range using methods such as {@link #expand(Unit)}
+ * and {@link #moveEnd(Unit, int)}.
+ *
+ * @param x integer that specifies the horizontal offset relative to the upper-left corner of the window, in pixels
+ * @param y integer that specifies the vertical offset relative to the upper-left corner of the window, in pixels
+ */
+ public native void moveToPoint(int x, int y)
+ /*-{
+ this.moveToPoint(x, y);
+ }-*/;
+
+ /**
+ * Retrieves the calculated left position of this range's start point relative to the layout or coordinate parent,
+ * as specified by the offsetParent property.
+ *
+ * @return an integer that specifies the left position, in pixels
+ */
+ public native int getOffsetLeft()
+ /*-{
+ return this.offsetLeft;
+ }-*/;
+
+ /**
+ * Retrieves the calculated top position of this range's start point relative to the layout or coordinate parent, as
+ * specified by the offsetParent property.
+ *
+ * @return an integer that specifies the top position, in pixels
+ */
+ public native int getOffsetTop()
+ /*-{
+ return this.offsetTop;
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaDOMUtils.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaDOMUtils.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaDOMUtils.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,119 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla;
+
+import com.google.gwt.core.client.JsArrayString;
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.DOMUtils;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Element;
+
+/**
+ * Contains methods from {@link DOMUtils} that require a different implementation in Mozilla.
+ *
+ * @version $Id$
+ */
+public class MozillaDOMUtils extends DOMUtils
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getComputedStyleProperty(Element, String)
+ */
+ public native String getComputedStyleProperty(Element el, String propertyName)
+ /*-{
+ // We force it to be a string because we treat it as a string in the java code.
+ return '' + el.ownerDocument.defaultView.getComputedStyle(el, null).getPropertyValue(propertyName);
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#importNode(Document, Node, boolean)
+ */
+ public native Node importNode(Document doc, Node externalNode, boolean deep)
+ /*-{
+ return doc.importNode(externalNode, deep);
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#getAttributeNames(Element)
+ */
+ public native JsArrayString getAttributeNames(Element element)
+ /*-{
+ var attrNames = [];
+ for(var i = 0; i < element.attributes.length; i++) {
+ attrNames.push(element.attributes.item(i));
+ }
+ return attrNames;
+ }-*/;
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#setInnerHTML(Element, String)
+ */
+ public void setInnerHTML(Element element, String html)
+ {
+ element.setInnerHTML(html);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DOMUtils#splitHTMLNode(Node, Node, int)
+ */
+ public Node splitHTMLNode(Node parent, Node descendant, int offset)
+ {
+ // Save the length of the descendant before the split to be able to detect where the split took place.
+ int length = getLength(descendant);
+
+ // Split the subtree rooted in the given parent.
+ Node nextLevelSibling = super.splitHTMLNode(parent, descendant, offset);
+
+ // See if the split took place.
+ if (nextLevelSibling != descendant) {
+ if (offset == 0) {
+ // The split took place at the beginning of the descendant. Ensure the first subtree is accessible.
+ // But first see if the first subtree has any leafs besides the descendant.
+ Node child = getChild(parent, descendant);
+ if (!isInline(child) && getFirstLeaf(child) == descendant) {
+ Node refNode = getFarthestInlineAncestor(descendant);
+ refNode = refNode == null ? child : refNode.getParentNode();
+ refNode.appendChild(((Document) refNode.getOwnerDocument()).xCreateBRElement());
+ }
+ }
+ if (offset == length) {
+ // The split took place at the end of the descendant. Ensure the second subtree is accessible.
+ // But first see if the second subtree has any leafs besides the nextLevelSibling.
+ Node child = getChild(parent, nextLevelSibling);
+ if (!isInline(child) && getLastLeaf(child) == nextLevelSibling) {
+ Node refNode = getFarthestInlineAncestor(nextLevelSibling);
+ refNode = refNode == null ? child : refNode.getParentNode();
+ refNode.appendChild(((Document) refNode.getOwnerDocument()).xCreateBRElement());
+ }
+ }
+ }
+
+ return nextLevelSibling;
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,87 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla;
+
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.DOMUtils;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Range;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.DefaultSelection;
+import com.xpn.xwiki.wysiwyg.client.dom.internal.NativeRangeWrapper;
+
+/**
+ * Fixes selection problems found in Firefox versions prior to 3.0.
+ *
+ * @version $Id$
+ */
+public class MozillaSelection extends DefaultSelection
+{
+ /**
+ * Creates a new selection object.
+ *
+ * @param nativeSelection the underlying native selection to be used
+ */
+ public MozillaSelection(NativeSelection nativeSelection)
+ {
+ super(nativeSelection);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see DefaultSelection#addRange(Range)
+ */
+ public void addRange(Range range)
+ {
+ NativeRangeWrapper wrapper = ((NativeRangeWrapper) range);
+ Document doc = (Document) range.getStartContainer().getOwnerDocument();
+ if (wrapper.getNativeRange() == null) {
+ wrapper.setNativeRange(NativeRange.newInstance(doc));
+ } else {
+ // Firefox prior to version 3.0 throws NS_ERROR_ILLEGAL_VALUE if we try to set the start boundary of the
+ // native range after the end boundary, or the other way around. Firefox 3 collapses the native range in
+ // this case. The DefaultRange already implements this behavior so the input range should be valid. We
+ // select all content to avoid the exception in Firefox 2.
+ ((NativeRange) wrapper.getNativeRange()).selectNode(doc.getBody());
+ }
+ NativeRange nativeRange = wrapper.getNativeRange().cast();
+ nativeRange
+ .setStart(range.getStartContainer(), adjustOffset(range.getStartContainer(), range.getStartOffset()));
+ nativeRange.setEnd(range.getEndContainer(), adjustOffset(range.getEndContainer(), range.getEndOffset()));
+ getNativeSelection().addRange(nativeRange);
+ }
+
+ /**
+ * Adjusts the specified offset within the given node to avoid NS_ERROR_DOM_INDEX_SIZE_ERR.
+ *
+ * @param node A DOM node.
+ * @param offset The offset within the given node.
+ * @return the adjusted value of the specified offset.
+ */
+ protected int adjustOffset(Node node, int offset)
+ {
+ if (node.getNodeType() == DOMUtils.COMMENT_NODE) {
+ // Only 0 is allowed.
+ return 0;
+ } else {
+ return offset;
+ }
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelectionManager.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelectionManager.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/MozillaSelectionManager.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,42 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla;
+
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
+import com.xpn.xwiki.wysiwyg.client.dom.SelectionManager;
+
+/**
+ * Implements {@link SelectionManager} for Firefox prior to version 3.0.
+ *
+ * @version $Id$
+ */
+public class MozillaSelectionManager implements SelectionManager
+{
+ /**
+ * {@inheritDoc}
+ *
+ * @see SelectionManager#getSelection(Document)
+ */
+ public Selection getSelection(Document document)
+ {
+ return new MozillaSelection(NativeSelection.getInstance(document));
+ }
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeRange.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeRange.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeRange.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,277 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla;
+
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.DocumentFragment;
+import com.xpn.xwiki.wysiwyg.client.dom.JavaScriptObject;
+
+/**
+ * The native range implementation for browsers that follow the W3C Range specification.
+ *
+ * @version $Id$
+ */
+public final class NativeRange extends JavaScriptObject
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected NativeRange()
+ {
+ }
+
+ /**
+ * Creates a new native range using the given document.
+ *
+ * @param document the document to use for creating the new native range
+ * @return the newly created native range
+ */
+ public static native NativeRange newInstance(Document document)
+ /*-{
+ return document.createRange();
+ }-*/;
+
+ /**
+ * @return true if this range is collapsed
+ */
+ public native boolean isCollapsed()
+ /*-{
+ return this.collapsed;
+ }-*/;
+
+ /**
+ * @return the deepest common ancestor container of this range's two boundary-points
+ */
+ public native Node getCommonAncestorContainer()
+ /*-{
+ return this.commonAncestorContainer;
+ }-*/;
+
+ /**
+ * @return the node within which this range ends
+ */
+ public native Node getEndContainer()
+ /*-{
+ return this.endContainer;
+ }-*/;
+
+ /**
+ * @return the offset within the ending node of this range
+ */
+ public native int getEndOffset()
+ /*-{
+ return this.endOffset;
+ }-*/;
+
+ /**
+ * @return the node within which this range begins
+ */
+ public native Node getStartContainer()
+ /*-{
+ return this.startContainer;
+ }-*/;
+
+ /**
+ * @return the offset within the starting node of this range
+ */
+ public native int getStartOffset()
+ /*-{
+ return this.startOffset;
+ }-*/;
+
+ /**
+ * Sets the attributes describing the start of this range.
+ *
+ * @param refNode the {@link #startContainer} value. This parameter must be different from null.
+ * @param offset the {@link #startOffset} value
+ */
+ public native void setStart(Node refNode, int offset)
+ /*-{
+ this.setStart(refNode, offset);
+ }-*/;
+
+ /**
+ * Sets the attributes describing the end of this range.
+ *
+ * @param refNode the {@link #endContainer} value. This parameter must be different from null.
+ * @param offset the {@link #endOffset} value
+ */
+ public native void setEnd(Node refNode, int offset)
+ /*-{
+ this.setEnd(refNode, offset);
+ }-*/;
+
+ /**
+ * Sets the start position to be before the given node.
+ *
+ * @param refNode the reference node, before which this range will start
+ */
+ public native void setStartBefore(Node refNode)
+ /*-{
+ this.setStartBefore(refNode);
+ }-*/;
+
+ /**
+ * Sets the start position to be after the given node.
+ *
+ * @param refNode the reference node, after which this range will start
+ */
+ public native void setStartAfter(Node refNode)
+ /*-{
+ this.setStartAfter(refNode);
+ }-*/;
+
+ /**
+ * Sets the end position to be before the given node.
+ *
+ * @param refNode the reference node, before which this range will end
+ */
+ public native void setEndBefore(Node refNode)
+ /*-{
+ this.setEndBefore(refNode);
+ }-*/;
+
+ /**
+ * Sets the end of this Range to be after the given node.
+ *
+ * @param refNode the reference node, after which this range will end
+ */
+ public native void setEndAfter(Node refNode)
+ /*-{
+ this.setEndAfter(refNode);
+ }-*/;
+
+ /**
+ * Select a node and its contents.
+ *
+ * @param refNode the node to select
+ */
+ public native void selectNode(Node refNode)
+ /*-{
+ this.selectNode(refNode);
+ }-*/;
+
+ /**
+ * Select the contents within a node.
+ *
+ * @param refNode the node to select from
+ */
+ public native void selectNodeContents(Node refNode)
+ /*-{
+ this.selectNodeContents(refNode);
+ }-*/;
+
+ /**
+ * Collapse this range onto one of its boundary-points.
+ *
+ * @param toStart if true, collapses this range onto its start; if false, collapses it onto its end.
+ */
+ public native void collapse(boolean toStart)
+ /*-{
+ this.collapse(toStart);
+ }-*/;
+
+ /**
+ * Duplicates the contents of this range.
+ *
+ * @return a DocumentFragment that contains content equivalent to this range
+ */
+ public native DocumentFragment cloneContents()
+ /*-{
+ return this.cloneContents();
+ }-*/;
+
+ /**
+ * Removes the contents of this range from the containing document or document fragment without returning a
+ * reference to the removed content.
+ */
+ public native void deleteContents()
+ /*-{
+ this.deleteContents();
+ }-*/;
+
+ /**
+ * Moves the contents of this range from the containing document or document fragment to a new DocumentFragment.
+ *
+ * @return a DocumentFragment containing the extracted contents
+ */
+ public native DocumentFragment extractContents()
+ /*-{
+ return this.extractContents();
+ }-*/;
+
+ /**
+ * Inserts a node into the Document or DocumentFragment at the start of the Range. If the container is a Text node,
+ * this will be split at the start of the Range (as if the Text node's splitText method was performed at the
+ * insertion point) and the insertion will occur between the two resulting Text nodes. Adjacent Text nodes will not
+ * be automatically merged. If the node to be inserted is a DocumentFragment node, the children will be inserted
+ * rather than the DocumentFragment node itself.
+ *
+ * @param newNode the node to insert at the start of this range.
+ */
+ public native void insertNode(Node newNode)
+ /*-{
+ this.insertNode(newNode);
+ }-*/;
+
+ /**
+ * Re-parents the contents of this range to the given node and inserts the node at the position of the start of this
+ * range.
+ *
+ * @param newParent the node to surround the contents with
+ */
+ public native void surroundContents(Node newParent)
+ /*-{
+ this.surroundContents(newParent);
+ }-*/;
+
+ /**
+ * Compare the boundary-points of two ranges in a document.
+ *
+ * @param how the type of comparison
+ * @param sourceRange the range to compared to
+ * @return -1, 0 or 1 depending on whether the corresponding boundary-point of this range is respectively before,
+ * equal to, or after the corresponding boundary-point of sourceRange
+ */
+ public native short compareBoundaryPoints(int how, NativeRange sourceRange)
+ /*-{
+ return this.compareBoundaryPoints(how, sourceRange);
+ }-*/;
+
+ /**
+ * Produces a new range whose boundary-points are equal to the boundary-points of this range.
+ *
+ * @return the duplicated range
+ */
+ public native NativeRange cloneRange()
+ /*-{
+ return this.cloneRange();
+ }-*/;
+
+ /**
+ * Called to indicate that this range is no longer in use and that the implementation may relinquish any resources
+ * associated with this range.
+ */
+ public native void detach()
+ /*-{
+ this.detach();
+ }-*/;
+}
Added: trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeSelection.java
===================================================================
--- trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeSelection.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/com/xpn/xwiki/wysiwyg/client/dom/internal/mozilla/NativeSelection.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -0,0 +1,218 @@
+/*
+ * See the NOTICE file distributed with this work for additional
+ * information regarding copyright ownership.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package com.xpn.xwiki.wysiwyg.client.dom.internal.mozilla;
+
+import com.google.gwt.dom.client.Node;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+import com.xpn.xwiki.wysiwyg.client.dom.JavaScriptObject;
+
+/**
+ * The native selection implementation provided by Mozilla.
+ *
+ * @version $Id$
+ */
+public final class NativeSelection extends JavaScriptObject
+{
+ /**
+ * Default constructor. Needs to be protected because all instances are created from JavaScript.
+ */
+ protected NativeSelection()
+ {
+ }
+
+ /**
+ * Retrieves the native selection object using Mozilla's API.
+ *
+ * @param document the document for which to retrieve the selection instance
+ * @return the native selection object associated with the given document
+ */
+ public static native NativeSelection getInstance(Document document)
+ /*-{
+ return document.defaultView.getSelection();
+ }-*/;
+
+ /**
+ * Adds a range to this selection.
+ *
+ * @param range the range to be added
+ */
+ public native void addRange(NativeRange range)
+ /*-{
+ this.addRange(range);
+ }-*/;
+
+ /**
+ * Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is
+ * collapsed, and the content is focused and editable, the caret will blink there.
+ *
+ * @param parentNode the DOM node where the selection will be set
+ * @param offset specifies where to place the selection in the given node
+ */
+ public native void collapse(Node parentNode, int offset)
+ /*-{
+ this.collapse(parentNode, offset);
+ }-*/;
+
+ /**
+ * Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).
+ * If content is focused and editable, the caret will blink there.
+ */
+ public native void collapseToEnd()
+ /*-{
+ this.collapseToEnd();
+ }-*/;
+
+ /**
+ * Collapses the whole selection to a single point at the start of the current selection (irrespective of
+ * direction). If content is focused and editable, the caret will blink there.
+ */
+ public native void collapseToStart()
+ /*-{
+ this.collapseToStart();
+ }-*/;
+
+ /**
+ * Indicates whether the given node is part of the selection.
+ *
+ * @param node the DOM node to be tested
+ * @param partlyContained if false, the entire subtree rooted in the given node is tested
+ * @return true when the entire node is part of the selection
+ */
+ public native boolean containsNode(Node node, boolean partlyContained)
+ /*-{
+ return this.containsNode(node, partlyContained);
+ }-*/;
+
+ /**
+ * Deletes this selection from document the nodes belong to.
+ */
+ public native void deleteFromDocument()
+ /*-{
+ this.deleteFromDocument();
+ }-*/;
+
+ /**
+ * Extends the selection by moving the selection end to the specified node and offset, preserving the selection
+ * begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless
+ * of direction.
+ *
+ * @param parentNode the node where the selection will be extended to
+ * @param offset specifies where to end the selection in the given node
+ */
+ public native void extend(Node parentNode, int offset)
+ /*-{
+ this.extend(parentNode, offset);
+ }-*/;
+
+ /**
+ * @return the node in which the selection begins
+ */
+ public native Node getAnchorNode()
+ /*-{
+ return this.anchorNode;
+ }-*/;
+
+ /**
+ * @return the offset within the {@link #getAnchorNode()} where the selection begins
+ */
+ public native int getAnchorOffset()
+ /*-{
+ return this.anchorOffset;
+ }-*/;
+
+ /**
+ * @return the node in which the selection ends
+ */
+ public native Node getFocusNode()
+ /*-{
+ return this.focusNode;
+ }-*/;
+
+ /**
+ * @return the offset within the {@link #getFocusNode()} where the selection ends.
+ */
+ public native int getFocusOffset()
+ /*-{
+ return this.focusOffset;
+ }-*/;
+
+ /**
+ * @param index the index of the range to retrieve. Usually the selection contains just one range.
+ * @return the range at the specified index
+ */
+ public native NativeRange getRangeAt(int index)
+ /*-{
+ return this.getRangeAt(index);
+ }-*/;
+
+ /**
+ * @return the number of ranges in the selection
+ */
+ public native int getRangeCount()
+ /*-{
+ return this.rangeCount;
+ }-*/;
+
+ /**
+ * @return true if the selection is collapsed
+ */
+ public native boolean isCollapsed()
+ /*-{
+ return this.isCollapsed;
+ }-*/;
+
+ /**
+ * Removes all ranges from the current selection.
+ */
+ public native void removeAllRanges()
+ /*-{
+ this.removeAllRanges();
+ }-*/;
+
+ /**
+ * Removes the given range from the selection.
+ *
+ * @param range the range to be removed from the selection.
+ */
+ public native void removeRange(NativeRange range)
+ /*-{
+ this.removeRange(range);
+ }-*/;
+
+ /**
+ * Adds all children of the specified node to the selection. Previous selection is lost.
+ *
+ * @param parentNode the parent of the children to be added to the selection
+ */
+ public native void selectAllChildren(Node parentNode)
+ /*-{
+ this.selectAllChildren(parentNode);
+ }-*/;
+
+ /**
+ * Modifies the cursor Bidi level after a change in keyboard direction.
+ *
+ * @param langRTL is true if the new language is right-to-left or false if the new language is left-to-right
+ */
+ public native void selectionLanguageChange(boolean langRTL)
+ /*-{
+ this.selectionLanguageChange(langRTL);
+ }-*/;
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/org/ourproject/kune/platf/Kune-Platform.gwt.xml 2009-03-12 23:46:56 UTC (rev 1074)
@@ -5,10 +5,11 @@
<inherits name='com.google.gwt.i18n.I18N' />
<inherits name="com.google.gwt.user.UserAgent" />
<inherits name="org.ourproject.kune.platf.RichText" />
-
<inherits name="com.google.gwt.libideas.ImmutableResources" />
<inherits name="com.google.gwt.libideas.StyleInjector" />
+ <inherits name="com.xpn.xwiki.wysiwyg.Wysiwyg" />
+
<public path="public" />
<inherits name="com.google.gwt.user.UserAgent" />
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/actions/ActionShortcut.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -6,6 +6,8 @@
public class ActionShortcut {
+ private static final String NO_KEYNAME = "nokeyname";
+
private static boolean has(int modifiers, int modifier) {
return ((modifiers & modifier) == modifier);
}
@@ -16,6 +18,10 @@
private final char key;
private final String keyName;
+ public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key) {
+ this(alt, ctrl, shift, key, NO_KEYNAME);
+ }
+
public ActionShortcut(boolean alt, boolean ctrl, boolean shift, char key, String keyName) {
this.alt = alt;
this.ctrl = ctrl;
@@ -25,7 +31,7 @@
}
public ActionShortcut(boolean ctrl, boolean shift, char key) {
- this(false, ctrl, shift, key, null);
+ this(false, ctrl, shift, key, NO_KEYNAME);
}
public ActionShortcut(boolean ctrl, boolean shift, char key, String keyName) {
@@ -33,7 +39,7 @@
}
public ActionShortcut(boolean ctrl, char key) {
- this(false, ctrl, false, key, null);
+ this(false, ctrl, false, key, NO_KEYNAME);
}
public ActionShortcut(boolean ctrl, char key, String keyName) {
@@ -42,7 +48,7 @@
public ActionShortcut(char key, int modifiers) {
this(has(modifiers, KeyboardListener.MODIFIER_ALT), has(modifiers, KeyboardListener.MODIFIER_CTRL), has(
- modifiers, KeyboardListener.MODIFIER_SHIFT), key, null);
+ modifiers, KeyboardListener.MODIFIER_SHIFT), key, NO_KEYNAME);
}
public ActionShortcut(char key, int modifiers, String keyName) {
@@ -104,7 +110,7 @@
s += sKey(alt, "Alt");
s += sKey(ctrl, "Ctrl");
s += sKey(shift, "Shift");
- s += keyName != null ? translateKey(keyName) + ")" : String.valueOf(key).toUpperCase() + ")";
+ s += keyName != NO_KEYNAME ? translateKey(keyName) + ")" : String.valueOf(key).toUpperCase() + ")";
return s;
}
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-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -17,12 +17,14 @@
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.dom.client.Element;
+import com.google.gwt.dom.client.IFrameElement;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.FocusListener;
import com.google.gwt.user.client.ui.KeyboardListener;
import com.google.gwt.user.client.ui.Widget;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
public class RTEditorPanel implements RTEditorView {
@@ -153,6 +155,28 @@
rta.setFocus(true);
}
+ /**
+ * NOTE: If the current browser doesn't support rich text editing this
+ * method returns <code>null</code>. You should test the returned value and
+ * fail save to an appropriate behavior!<br/>
+ * The appropriate test would be: <code><pre>
+ * if (rta.isAttached() && rta.getDocument() == null) {
+ * // The current browser doesn't support rich text editing.
+ * }
+ * </pre></code>
+ *
+ * @return The DOM document being edited with this rich text area.
+ *
+ * copied from xwiki
+ */
+ public Document getDocument() {
+ if (rta.getElement().getTagName().equalsIgnoreCase("iframe")) {
+ return IFrameElement.as(rta.getElement()).getContentDocument().cast();
+ } else {
+ return null;
+ }
+ }
+
public String getHtml() {
return rta.getHTML();
}
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-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -16,6 +16,7 @@
import org.ourproject.kune.platf.client.dto.AccessRolDTO;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.state.Session;
+import org.ourproject.kune.platf.client.ui.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;
@@ -30,6 +31,7 @@
import com.calclab.suco.client.events.Listener2;
import com.calclab.suco.client.ioc.Provider;
import com.google.gwt.libideas.resources.client.ImageResource;
+import com.xpn.xwiki.wysiwyg.client.dom.Selection;
public class RTEditorPresenter implements RTEditor {
@@ -632,6 +634,21 @@
backgroundColor.setToolTip(i18n.t("Text Background Colour"));
backgroundColor.setAddCondition(canBeBasic);
+ final ActionToolbarMenuDescriptor<Object> devInfo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ Selection selection = view.getDocument().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);
+ }
+ });
+ devInfo.setTextDescription(i18n.t("Developers info"));
+ devInfo.setAddCondition(canBeExtended);
+ devInfo.setParentMenuTitle(i18n.t(FORMAT_MENU));
+ devInfo.setShortcut(new ActionShortcut(true, false, false, 'I'));
+
actions.add(withNoItem(bold));
actions.add(withNoItem(italic));
actions.add(withNoItem(underline));
@@ -665,6 +682,7 @@
actions.add(withNoItem(comment));
actions.add(withNoItem(undoBtn));
actions.add(withNoItem(redoBtn));
+ actions.add(withNoItem(devInfo));
for (String fontName : this.fontNames) {
ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
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-03-12 08:05:10 UTC (rev 1073)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-12 23:46:56 UTC (rev 1074)
@@ -4,6 +4,8 @@
import org.ourproject.kune.platf.client.actions.ActionItemCollection;
import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
+import com.xpn.xwiki.wysiwyg.client.dom.Document;
+
public interface RTEditorView extends View {
void addActions(ActionItemCollection<Object> actions);
@@ -26,6 +28,8 @@
void focus();
+ Document getDocument();
+
String getHtml();
String getText();
1
0
Author: vjrj
Date: 2009-03-12 09:05:10 +0100 (Thu, 12 Mar 2009)
New Revision: 1073
Added:
trunk/img/icons/arrow_in.png
trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/ErrorHandler.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_in.png
trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_out.png
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/entityheader/maxmin/
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspace.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspaceView.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
Modified:
trunk/script/generateBasicUIElements.sh
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/blogs/client/BlogClientModule.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java
trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationComponentGroup.java
trunk/src/main/java/org/ourproject/kune/platf/client/rpc/AsyncCallbackSimple.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/Images.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.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/insertlink/InsertLinkDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignOutLinkPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java
trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Added: trunk/img/icons/arrow_in.png
===================================================================
(Binary files differ)
Property changes on: trunk/img/icons/arrow_in.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/script/generateBasicUIElements.sh
===================================================================
--- trunk/script/generateBasicUIElements.sh 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/script/generateBasicUIElements.sh 2009-03-12 08:05:10 UTC (rev 1073)
@@ -84,7 +84,7 @@
register(Singleton.class, new Factory<${NAME}>(${NAME}.class) {
public ${NAME} create() {
final ${NAME}Presenter presenter = new ${NAME}Presenter();
- final ${NAME}Panel panel = new ${NAME}Panel(presenter));
+ final ${NAME}Panel panel = new ${NAME}Panel(presenter);
presenter.init(panel);
return presenter;
}
Modified: trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/app/client/KuneEntryPoint.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -23,11 +23,11 @@
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.KuneCoreModule;
-import org.ourproject.kune.platf.client.services.KunePlatformModule;
+import org.ourproject.kune.platf.client.services.CoreModule;
+import org.ourproject.kune.platf.client.services.PlatformModule;
import org.ourproject.kune.wiki.client.WikiClientModule;
-import org.ourproject.kune.workspace.client.KuneRegistryModule;
-import org.ourproject.kune.workspace.client.KuneWorkspaceModule;
+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;
@@ -63,9 +63,9 @@
}
public void onModuleLoadCont() {
- Suco.install(new KuneCoreModule(), new KuneRegistryModule(), new KunePlatformModule(), new EmiteUIModule(),
+ Suco.install(new CoreModule(), new RegistryModule(), new PlatformModule(), new EmiteUIModule(),
new DocumentClientModule(), new BlogClientModule(), new WikiClientModule(), new GalleryClientModule(),
- new ChatClientModule(), new KuneWorkspaceModule());
+ 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-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientActions.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -28,7 +28,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -53,7 +53,7 @@
final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo,
- final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler,
+ final Provider<ContentEditor> textEditorProvider, final ErrorHandler errorHandler,
final BlogViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider,
final SitePublicSpaceLink publicLink) {
super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider,
Modified: trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/blogs/client/BlogClientModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -35,7 +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.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -78,7 +78,7 @@
$(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
$$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
$(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), $(BlogViewer.class),
+ $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(BlogViewer.class),
$$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
}
});
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientActions.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -28,7 +28,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -53,7 +53,7 @@
final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo,
- final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler,
+ final Provider<ContentEditor> textEditorProvider, final ErrorHandler errorHandler,
final DocumentViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider,
final SitePublicSpaceLink publicLink) {
super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider,
Modified: trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/docs/client/DocumentClientModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -35,7 +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.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -78,7 +78,7 @@
$(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
$$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
$(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class),
+ $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class),
$(DocumentViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
}
});
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientActions.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -27,7 +27,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -52,7 +52,7 @@
final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo,
- final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler,
+ final Provider<ContentEditor> textEditorProvider, final ErrorHandler errorHandler,
final GalleryViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider,
final SitePublicSpaceLink publicLink) {
super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider,
Modified: trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/gallery/client/GalleryClientModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -35,7 +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.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -78,7 +78,7 @@
$(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
$$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
$(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class),
+ $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class),
$(GalleryViewer.class), $$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
}
});
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationComponentGroup.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationComponentGroup.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/app/ApplicationComponentGroup.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -24,6 +24,11 @@
import com.calclab.suco.client.ioc.decorator.ProviderCollection;
import com.calclab.suco.client.ioc.decorator.Singleton;
+/**
+ * Use this decorator with parts of kune that are needed at start time (like
+ * main widgets in workspace). Them are created automatically when starting.
+ *
+ */
public class ApplicationComponentGroup extends ProviderCollection {
public ApplicationComponentGroup(final Container container) {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/rpc/AsyncCallbackSimple.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/rpc/AsyncCallbackSimple.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/rpc/AsyncCallbackSimple.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -19,15 +19,15 @@
*/
package org.ourproject.kune.platf.client.rpc;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
public abstract class AsyncCallbackSimple<T> implements AsyncCallback<T> {
- private static KuneErrorHandler errorHandler;
+ private static ErrorHandler errorHandler;
- public static void init(KuneErrorHandler kuneErrorHandler) {
+ public static void init(ErrorHandler kuneErrorHandler) {
errorHandler = kuneErrorHandler;
}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java (from rev 1071, trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/CoreModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,40 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.platf.client.services;
+
+import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
+import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
+import org.ourproject.kune.platf.client.app.ToolGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
+
+import com.calclab.suco.client.ioc.module.AbstractModule;
+
+public class CoreModule extends AbstractModule {
+
+ @Override
+ public void onInstall() {
+ registerDecorator(ApplicationComponentGroup.class, new ApplicationComponentGroup(container));
+ registerDecorator(ToolGroup.class, new ToolGroup(container));
+ registerDecorator(EntityOptionsGroup.class, new EntityOptionsGroup(container));
+ registerDecorator(InsertImageGroup.class, new InsertImageGroup(container));
+ registerDecorator(InsertLinkGroup.class, new InsertLinkGroup(container));
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/services/ErrorHandler.java (from rev 1071, trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/ErrorHandler.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,131 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.services;
+
+import org.ourproject.kune.platf.client.errors.AccessViolationException;
+import org.ourproject.kune.platf.client.errors.AlreadyGroupMemberException;
+import org.ourproject.kune.platf.client.errors.AlreadyUserMemberException;
+import org.ourproject.kune.platf.client.errors.ContainerNotPermittedException;
+import org.ourproject.kune.platf.client.errors.ContentNotFoundException;
+import org.ourproject.kune.platf.client.errors.ContentNotPermittedException;
+import org.ourproject.kune.platf.client.errors.GroupNotFoundException;
+import org.ourproject.kune.platf.client.errors.LastAdminInGroupException;
+import org.ourproject.kune.platf.client.errors.SessionExpiredException;
+import org.ourproject.kune.platf.client.errors.UserMustBeLoggedException;
+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.noti.NotifyUser;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Event0;
+import com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.client.ioc.Provider;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
+
+public class ErrorHandler {
+ private final Session session;
+ private final I18nTranslationService i18n;
+ private final Event0 onSessionExpired;
+ private final Provider<StateManager> stateManagerProvider;
+
+ public ErrorHandler(final Session session, final I18nTranslationService i18n,
+ final Provider<StateManager> stateManagerProvider) {
+ this.session = session;
+ this.i18n = i18n;
+ this.stateManagerProvider = stateManagerProvider;
+ this.onSessionExpired = new Event0("onSessionExpired");
+ }
+
+ public void doSessionExpired() {
+ onSessionExpired.fire();
+ NotifyUser.info("Your session has expired. Please log in again.");
+ }
+
+ public void onSessionExpired(final Listener0 listener) {
+ onSessionExpired.add(listener);
+ }
+
+ public void process(final Throwable caught) {
+ NotifyUser.hideProgress();
+ try {
+ throw caught;
+ } catch (final AccessViolationException e) {
+ logException(e);
+ NotifyUser.error(i18n.t("You do not have rights to perform that action"));
+ } catch (final SessionExpiredException e) {
+ logException(e);
+ doSessionExpired();
+ } catch (final UserMustBeLoggedException e) {
+ logException(e);
+ if (session.isLogged()) {
+ doSessionExpired();
+ } else {
+ NotifyUser.important(i18n.t("Please sign in or register to collaborate"));
+ }
+ } catch (final GroupNotFoundException e) {
+ logException(e);
+ NotifyUser.veryImportant(i18n.t("Group not found"));
+ stateManagerProvider.get().gotoToken("");
+ } catch (final IncompatibleRemoteServiceException e) {
+ NotifyUser.error(i18n.t("Your browser is outdated with the server software. Please reload this page."));
+ } catch (final ContentNotFoundException e) {
+ logException(e);
+ NotifyUser.veryImportant(i18n.t("Content not found"));
+ stateManagerProvider.get().gotoToken("");
+ } catch (final ContentNotPermittedException e) {
+ logException(e);
+ NotifyUser.error(i18n.t("Action not permitted in this location"));
+ stateManagerProvider.get().gotoToken("");
+ } catch (final ContainerNotPermittedException e) {
+ logException(e);
+ NotifyUser.error(i18n.t("Action not permitted in this location"));
+ stateManagerProvider.get().gotoToken("");
+ } catch (final LastAdminInGroupException e) {
+ logException(e);
+ NotifyUser.showAlertMessage(i18n.t("Warning"), i18n.t("Sorry, you are the last admin of this group."
+ + " Look for someone to substitute you appropriately as admin before leaving this group."));
+ } catch (final AlreadyGroupMemberException e) {
+ logException(e);
+ NotifyUser.error(i18n.t("This group is already a group member"));
+ } catch (final AlreadyUserMemberException e) {
+ logException(e);
+ NotifyUser.error(i18n.t("This user is already a group member"));
+ } catch (final Throwable e) {
+ logException(e, true);
+ NotifyUser.error(i18n.t("Error performing operation"));
+ GWT.log("Other kind of exception in StateManagerDefault/processErrorException", null);
+ }
+ }
+
+ private void logException(final Throwable e) {
+ logException(e, false);
+ }
+
+ private void logException(final Throwable e, final boolean showException) {
+ if (showException) {
+ Log.debug("Exception in KuneErrorHandler", e);
+ } else {
+ Log.debug("Exception in KuneErrorHandler: " + e.getMessage());
+ }
+ }
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/Images.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/Images.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/Images.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -60,9 +60,15 @@
@Resource("org/ourproject/kune/platf/public/images/arrow-down-white.gif")
AbstractImagePrototype arrowDownWhite();
+ @Resource("org/ourproject/kune/platf/public/images/arrow_in.png")
+ AbstractImagePrototype arrowIn();
+
@Resource("org/ourproject/kune/platf/public/images/arrow-left-green.png")
AbstractImagePrototype arrowLeftGreen();
+ @Resource("org/ourproject/kune/platf/public/images/arrow_out.png")
+ AbstractImagePrototype arrowOut();
+
@Resource("org/ourproject/kune/platf/public/images/arrow-right-black.gif")
AbstractImagePrototype arrowRightBlack();
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -1,40 +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.platf.client.services;
-
-import org.ourproject.kune.platf.client.app.ApplicationComponentGroup;
-import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
-import org.ourproject.kune.platf.client.app.ToolGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
-
-import com.calclab.suco.client.ioc.module.AbstractModule;
-
-public class KuneCoreModule extends AbstractModule {
-
- @Override
- public void onInstall() {
- registerDecorator(ApplicationComponentGroup.class, new ApplicationComponentGroup(container));
- registerDecorator(ToolGroup.class, new ToolGroup(container));
- registerDecorator(EntityOptionsGroup.class, new EntityOptionsGroup(container));
- registerDecorator(InsertImageGroup.class, new InsertImageGroup(container));
- registerDecorator(InsertLinkGroup.class, new InsertLinkGroup(container));
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneErrorHandler.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -1,131 +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.platf.client.services;
-
-import org.ourproject.kune.platf.client.errors.AccessViolationException;
-import org.ourproject.kune.platf.client.errors.AlreadyGroupMemberException;
-import org.ourproject.kune.platf.client.errors.AlreadyUserMemberException;
-import org.ourproject.kune.platf.client.errors.ContainerNotPermittedException;
-import org.ourproject.kune.platf.client.errors.ContentNotFoundException;
-import org.ourproject.kune.platf.client.errors.ContentNotPermittedException;
-import org.ourproject.kune.platf.client.errors.GroupNotFoundException;
-import org.ourproject.kune.platf.client.errors.LastAdminInGroupException;
-import org.ourproject.kune.platf.client.errors.SessionExpiredException;
-import org.ourproject.kune.platf.client.errors.UserMustBeLoggedException;
-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.noti.NotifyUser;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Event0;
-import com.calclab.suco.client.events.Listener0;
-import com.calclab.suco.client.ioc.Provider;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.IncompatibleRemoteServiceException;
-
-public class KuneErrorHandler {
- private final Session session;
- private final I18nTranslationService i18n;
- private final Event0 onSessionExpired;
- private final Provider<StateManager> stateManagerProvider;
-
- public KuneErrorHandler(final Session session, final I18nTranslationService i18n,
- final Provider<StateManager> stateManagerProvider) {
- this.session = session;
- this.i18n = i18n;
- this.stateManagerProvider = stateManagerProvider;
- this.onSessionExpired = new Event0("onSessionExpired");
- }
-
- public void doSessionExpired() {
- onSessionExpired.fire();
- NotifyUser.info("Your session has expired. Please log in again.");
- }
-
- public void onSessionExpired(final Listener0 listener) {
- onSessionExpired.add(listener);
- }
-
- public void process(final Throwable caught) {
- NotifyUser.hideProgress();
- try {
- throw caught;
- } catch (final AccessViolationException e) {
- logException(e);
- NotifyUser.error(i18n.t("You do not have rights to perform that action"));
- } catch (final SessionExpiredException e) {
- logException(e);
- doSessionExpired();
- } catch (final UserMustBeLoggedException e) {
- logException(e);
- if (session.isLogged()) {
- doSessionExpired();
- } else {
- NotifyUser.important(i18n.t("Please sign in or register to collaborate"));
- }
- } catch (final GroupNotFoundException e) {
- logException(e);
- NotifyUser.veryImportant(i18n.t("Group not found"));
- stateManagerProvider.get().gotoToken("");
- } catch (final IncompatibleRemoteServiceException e) {
- NotifyUser.error(i18n.t("Your browser is outdated with the server software. Please reload this page."));
- } catch (final ContentNotFoundException e) {
- logException(e);
- NotifyUser.veryImportant(i18n.t("Content not found"));
- stateManagerProvider.get().gotoToken("");
- } catch (final ContentNotPermittedException e) {
- logException(e);
- NotifyUser.error(i18n.t("Action not permitted in this location"));
- stateManagerProvider.get().gotoToken("");
- } catch (final ContainerNotPermittedException e) {
- logException(e);
- NotifyUser.error(i18n.t("Action not permitted in this location"));
- stateManagerProvider.get().gotoToken("");
- } catch (final LastAdminInGroupException e) {
- logException(e);
- NotifyUser.showAlertMessage(i18n.t("Warning"), i18n.t("Sorry, you are the last admin of this group."
- + " Look for someone to substitute you appropriately as admin before leaving this group."));
- } catch (final AlreadyGroupMemberException e) {
- logException(e);
- NotifyUser.error(i18n.t("This group is already a group member"));
- } catch (final AlreadyUserMemberException e) {
- logException(e);
- NotifyUser.error(i18n.t("This user is already a group member"));
- } catch (final Throwable e) {
- logException(e, true);
- NotifyUser.error(i18n.t("Error performing operation"));
- GWT.log("Other kind of exception in StateManagerDefault/processErrorException", null);
- }
- }
-
- private void logException(final Throwable e) {
- logException(e, false);
- }
-
- private void logException(final Throwable e, final boolean showException) {
- if (showException) {
- Log.debug("Exception in KuneErrorHandler", e);
- } else {
- Log.debug("Exception in KuneErrorHandler: " + e.getMessage());
- }
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -1,419 +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.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.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.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.noti.NotifyUser;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
-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.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.EditHtmlGroup;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPresenter;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditor;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPresenter;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreview;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPanel;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPresenter;
-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;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmail;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExt;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtView;
-import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
-import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
-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 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;
-import com.google.gwt.user.client.Cookies;
-import com.google.gwt.user.client.History;
-import com.google.gwt.user.client.rpc.ServiceDefTarget;
-
-public class KunePlatformModule extends AbstractModule {
-
- @Override
- protected void onInstall() {
-
- register(Singleton.class, new Factory<Session>(Session.class) {
- @Override
- public Session create() {
- return new SessionDefault(Cookies.getCookie(Session.USERHASH), $$(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($(ContentServiceAsync.class));
- }
- }, new Factory<StateManager>(StateManager.class) {
- @Override
- public StateManager create() {
- final StateManagerDefault stateManager = new StateManagerDefault($(ContentProvider.class),
- $(Session.class), $(HistoryWrapper.class));
- History.addHistoryListener(stateManager);
- return stateManager;
- }
- });
-
- register(Singleton.class, new Factory<I18nUITranslationService>(I18nUITranslationService.class) {
- @Override
- public I18nUITranslationService create() {
- final I18nUITranslationService i18n = new I18nUITranslationService();
- i18n.init($(I18nServiceAsync.class), $(Session.class), new Listener0() {
- public void onEvent() {
- onI18nReady();
- }
- });
- return i18n;
- }
- });
-
- register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
- @Override
- public FileDownloadUtils create() {
- return new FileDownloadUtils($(Session.class), $(ImageUtils.class));
- }
- });
-
- register(Singleton.class, new Factory<QuickTipsHelper>(QuickTipsHelper.class) {
- @Override
- public QuickTipsHelper create() {
- return new QuickTipsHelper();
- }
- });
-
- $(I18nUITranslationService.class);
- $(QuickTipsHelper.class);
-
- }
-
- private void onI18nReady() {
- final I18nUITranslationService i18n = $(I18nUITranslationService.class);
-
- if (container.hasProvider(I18nTranslationService.class)) {
- container.removeProvider(I18nTranslationService.class);
- }
-
- register(Singleton.class, new Factory<Resources>(Resources.class) {
- @Override
- public Resources create() {
- return new Resources(i18n);
- }
- });
-
- $(Resources.class);
-
- register(Singleton.class, new Factory<I18nTranslationService>(I18nTranslationService.class) {
- @Override
- public I18nTranslationService create() {
- return i18n;
- }
- });
-
- register(Singleton.class, new Factory<KuneErrorHandler>(KuneErrorHandler.class) {
- @Override
- public KuneErrorHandler create() {
- return new KuneErrorHandler($(Session.class), i18n, $$(StateManager.class));
- }
- });
-
- register(Singleton.class, new Factory<Images>(Images.class) {
- @Override
- public Images create() {
- return Images.App.getInstance();
- }
- }, new Factory<ImageUtils>(ImageUtils.class) {
- @Override
- public ImageUtils create() {
- return new ImageUtils($(Images.class));
- }
- });
-
- AsyncCallbackSimple.init($(KuneErrorHandler.class));
-
- register(Singleton.class, new Factory<Application>(Application.class) {
- @Override
- public Application create() {
- return new ApplicationDefault($(Session.class));
- }
-
- @Override
- public void onAfterCreated(final Application instance) {
- }
- });
-
- register(Singleton.class, new Factory<DeferredCommandWrapper>(DeferredCommandWrapper.class) {
- @Override
- public DeferredCommandWrapper create() {
- return new DeferredCommandWrapper();
- }
- });
-
- register(Singleton.class, new Factory<ColorWebSafePalette>(ColorWebSafePalette.class) {
- @Override
- public ColorWebSafePalette create() {
- final ColorWebSafePalettePresenter presenter = new ColorWebSafePalettePresenter();
- final ColorWebSafePalettePanel panel = new ColorWebSafePalettePanel(presenter);
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) {
- @Override
- public RTEActionTopToolbar create() {
- final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(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 RTEActionSndToolbar toolbar = new RTEActionSndToolbar(panel);
- return toolbar;
- }
- });
-
- register(Singleton.class, new Factory<TimerWrapper>(TimerWrapper.class) {
- @Override
- public TimerWrapper create() {
- return new TimerWrapper();
- }
- });
-
- register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
- @Override
- public RTEditor create() {
- RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
- 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),
- $(DeferredCommandWrapper.class));
- final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
- $(ActionManager.class));
- presenter.init(panel);
- return presenter;
- }
- }, new Factory<RTESavingEditor>(RTESavingEditor.class) {
- @Override
- public RTESavingEditor create() {
- RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
- $(I18nTranslationService.class), $(StateManager.class), $(DeferredCommandWrapper.class),
- $(RTEImgResources.class), $(TimerWrapper.class));
- RTESavingEditorPanel panel = new RTESavingEditorPanel();
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(NoDecoration.class, new Factory<TestRTEDialog>(TestRTEDialog.class) {
- @Override
- public TestRTEDialog create() {
- return new TestRTEDialog($(RTESavingEditor.class));
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<NotifyUser>(NotifyUser.class) {
- @Override
- public NotifyUser create() {
- return new NotifyUser($(I18nTranslationService.class), $(Images.class));
- }
- });
-
- register(Singleton.class, new Factory<RTEImgResources>(RTEImgResources.class) {
- @Override
- public RTEImgResources create() {
- 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) {
- @Override
- public EditHtmlDialog create() {
- final EditHtmlDialogPresenter presenter = new EditHtmlDialogPresenter();
- final EditHtmlDialogPanel panel = new EditHtmlDialogPanel(presenter, $(I18nTranslationService.class),
- $(RTEImgResources.class), $(Images.class), $(EditHtmlGroup.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(EditHtmlGroup.class, new Factory<EditHtmlEditor>(EditHtmlEditor.class) {
- @Override
- public EditHtmlEditor create() {
- final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter($(EditHtmlDialog.class));
- final EditHtmlEditorPanel panel = new EditHtmlEditorPanel(i18n, presenter);
- presenter.init(panel);
- return presenter;
- }
- }, new Factory<EditHtmlPreview>(EditHtmlPreview.class) {
- @Override
- public EditHtmlPreview create() {
- final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter($(EditHtmlDialog.class));
- final EditHtmlPreviewPanel panel = new EditHtmlPreviewPanel(i18n, presenter);
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<InsertImageDialog>(InsertImageDialog.class) {
- @Override
- public InsertImageDialog create() {
- final InsertImageDialogPresenter presenter = new InsertImageDialogPresenter();
- final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter, $(I18nTranslationService.class),
- $(Images.class), $(InsertImageGroup.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(InsertImageGroup.class, new Factory<InsertImageExt>(InsertImageExt.class) {
- @Override
- public InsertImageExt create() {
- final InsertImageExtPresenter presenter = new InsertImageExtPresenter($(InsertImageDialog.class));
- final InsertImageExtPanel panel = new InsertImageExtPanel(presenter, i18n);
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<InsertLinkDialog>(InsertLinkDialog.class) {
- @Override
- public InsertLinkDialog create() {
- final InsertLinkDialogPresenter presenter = new InsertLinkDialogPresenter();
- final InsertLinkDialogPanel panel = new InsertLinkDialogPanel(presenter, $(Images.class),
- $(I18nTranslationService.class), $(InsertLinkGroup.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(
- InsertLinkEmail.class) {
- @Override
- public InsertLinkEmail create() {
- final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter(
- $(InsertLinkDialog.class));
- final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter,
- $(I18nTranslationService.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- $(ApplicationComponentGroup.class).createAll();
- $(ToolGroup.class).createAll();
- $(Application.class).start();
- // $(HelloWorld.class);
- }
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java (from rev 1071, trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/PlatformModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,419 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.platf.client.services;
+
+import org.ourproject.kune.platf.client.actions.ActionManager;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
+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.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.noti.NotifyUser;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
+import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
+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.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.EditHtmlGroup;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditor;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPresenter;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreview;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPanel;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPresenter;
+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;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmail;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExt;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtView;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+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 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;
+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 AbstractModule {
+
+ @Override
+ protected void onInstall() {
+
+ register(Singleton.class, new Factory<Session>(Session.class) {
+ @Override
+ public Session create() {
+ return new SessionDefault(Cookies.getCookie(Session.USERHASH), $$(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($(ContentServiceAsync.class));
+ }
+ }, new Factory<StateManager>(StateManager.class) {
+ @Override
+ public StateManager create() {
+ final StateManagerDefault stateManager = new StateManagerDefault($(ContentProvider.class),
+ $(Session.class), $(HistoryWrapper.class));
+ History.addHistoryListener(stateManager);
+ return stateManager;
+ }
+ });
+
+ register(Singleton.class, new Factory<I18nUITranslationService>(I18nUITranslationService.class) {
+ @Override
+ public I18nUITranslationService create() {
+ final I18nUITranslationService i18n = new I18nUITranslationService();
+ i18n.init($(I18nServiceAsync.class), $(Session.class), new Listener0() {
+ public void onEvent() {
+ onI18nReady();
+ }
+ });
+ return i18n;
+ }
+ });
+
+ register(Singleton.class, new Factory<FileDownloadUtils>(FileDownloadUtils.class) {
+ @Override
+ public FileDownloadUtils create() {
+ return new FileDownloadUtils($(Session.class), $(ImageUtils.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<QuickTipsHelper>(QuickTipsHelper.class) {
+ @Override
+ public QuickTipsHelper create() {
+ return new QuickTipsHelper();
+ }
+ });
+
+ $(I18nUITranslationService.class);
+ $(QuickTipsHelper.class);
+
+ }
+
+ private void onI18nReady() {
+ final I18nUITranslationService i18n = $(I18nUITranslationService.class);
+
+ if (container.hasProvider(I18nTranslationService.class)) {
+ container.removeProvider(I18nTranslationService.class);
+ }
+
+ register(Singleton.class, new Factory<Resources>(Resources.class) {
+ @Override
+ public Resources create() {
+ return new Resources(i18n);
+ }
+ });
+
+ $(Resources.class);
+
+ register(Singleton.class, new Factory<I18nTranslationService>(I18nTranslationService.class) {
+ @Override
+ public I18nTranslationService create() {
+ return i18n;
+ }
+ });
+
+ register(Singleton.class, new Factory<ErrorHandler>(ErrorHandler.class) {
+ @Override
+ public ErrorHandler create() {
+ return new ErrorHandler($(Session.class), i18n, $$(StateManager.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<Images>(Images.class) {
+ @Override
+ public Images create() {
+ return Images.App.getInstance();
+ }
+ }, new Factory<ImageUtils>(ImageUtils.class) {
+ @Override
+ public ImageUtils create() {
+ return new ImageUtils($(Images.class));
+ }
+ });
+
+ AsyncCallbackSimple.init($(ErrorHandler.class));
+
+ register(Singleton.class, new Factory<Application>(Application.class) {
+ @Override
+ public Application create() {
+ return new ApplicationDefault($(Session.class));
+ }
+
+ @Override
+ public void onAfterCreated(final Application instance) {
+ }
+ });
+
+ register(Singleton.class, new Factory<DeferredCommandWrapper>(DeferredCommandWrapper.class) {
+ @Override
+ public DeferredCommandWrapper create() {
+ return new DeferredCommandWrapper();
+ }
+ });
+
+ register(Singleton.class, new Factory<ColorWebSafePalette>(ColorWebSafePalette.class) {
+ @Override
+ public ColorWebSafePalette create() {
+ final ColorWebSafePalettePresenter presenter = new ColorWebSafePalettePresenter();
+ final ColorWebSafePalettePanel panel = new ColorWebSafePalettePanel(presenter);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(NoDecoration.class, new Factory<RTEActionTopToolbar>(RTEActionTopToolbar.class) {
+ @Override
+ public RTEActionTopToolbar create() {
+ final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(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 RTEActionSndToolbar toolbar = new RTEActionSndToolbar(panel);
+ return toolbar;
+ }
+ });
+
+ register(Singleton.class, new Factory<TimerWrapper>(TimerWrapper.class) {
+ @Override
+ public TimerWrapper create() {
+ return new TimerWrapper();
+ }
+ });
+
+ register(NoDecoration.class, new Factory<RTEditor>(RTEditor.class) {
+ @Override
+ public RTEditor create() {
+ RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
+ 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),
+ $(DeferredCommandWrapper.class));
+ final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
+ $(ActionManager.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ }, new Factory<RTESavingEditor>(RTESavingEditor.class) {
+ @Override
+ public RTESavingEditor create() {
+ RTESavingEditorPresenter presenter = new RTESavingEditorPresenter($(RTEditor.class), true,
+ $(I18nTranslationService.class), $(StateManager.class), $(DeferredCommandWrapper.class),
+ $(RTEImgResources.class), $(TimerWrapper.class));
+ RTESavingEditorPanel panel = new RTESavingEditorPanel();
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(NoDecoration.class, new Factory<TestRTEDialog>(TestRTEDialog.class) {
+ @Override
+ public TestRTEDialog create() {
+ return new TestRTEDialog($(RTESavingEditor.class));
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<NotifyUser>(NotifyUser.class) {
+ @Override
+ public NotifyUser create() {
+ return new NotifyUser($(I18nTranslationService.class), $(Images.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<RTEImgResources>(RTEImgResources.class) {
+ @Override
+ public RTEImgResources create() {
+ 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) {
+ @Override
+ public EditHtmlDialog create() {
+ final EditHtmlDialogPresenter presenter = new EditHtmlDialogPresenter();
+ final EditHtmlDialogPanel panel = new EditHtmlDialogPanel(presenter, $(I18nTranslationService.class),
+ $(RTEImgResources.class), $(Images.class), $(EditHtmlGroup.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(EditHtmlGroup.class, new Factory<EditHtmlEditor>(EditHtmlEditor.class) {
+ @Override
+ public EditHtmlEditor create() {
+ final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter($(EditHtmlDialog.class));
+ final EditHtmlEditorPanel panel = new EditHtmlEditorPanel(i18n, presenter);
+ presenter.init(panel);
+ return presenter;
+ }
+ }, new Factory<EditHtmlPreview>(EditHtmlPreview.class) {
+ @Override
+ public EditHtmlPreview create() {
+ final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter($(EditHtmlDialog.class));
+ final EditHtmlPreviewPanel panel = new EditHtmlPreviewPanel(i18n, presenter);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<InsertImageDialog>(InsertImageDialog.class) {
+ @Override
+ public InsertImageDialog create() {
+ final InsertImageDialogPresenter presenter = new InsertImageDialogPresenter();
+ final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter, $(I18nTranslationService.class),
+ $(Images.class), $(InsertImageGroup.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(InsertImageGroup.class, new Factory<InsertImageExt>(InsertImageExt.class) {
+ @Override
+ public InsertImageExt create() {
+ final InsertImageExtPresenter presenter = new InsertImageExtPresenter($(InsertImageDialog.class));
+ final InsertImageExtPanel panel = new InsertImageExtPanel(presenter, i18n);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<InsertLinkDialog>(InsertLinkDialog.class) {
+ @Override
+ public InsertLinkDialog create() {
+ final InsertLinkDialogPresenter presenter = new InsertLinkDialogPresenter();
+ final InsertLinkDialogPanel panel = new InsertLinkDialogPanel(presenter, $(Images.class),
+ $(I18nTranslationService.class), $(InsertLinkGroup.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(
+ InsertLinkEmail.class) {
+ @Override
+ public InsertLinkEmail create() {
+ final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter(
+ $(InsertLinkDialog.class));
+ final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter,
+ $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ $(ApplicationComponentGroup.class).createAll();
+ $(ToolGroup.class).createAll();
+ $(Application.class).start();
+ // $(HelloWorld.class);
+ }
+}
\ No newline at end of file
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-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/IconLabel.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -55,7 +55,7 @@
private HorizontalAlignmentConstant horzAlign;
private MouseListenerCollection mouseListeners;
private MouseWheelListenerCollection mouseWheelListeners;
- private final Element icon;
+ private Element icon;
private final Element textLabel;
/**
@@ -123,7 +123,7 @@
private IconLabel(final AbstractImagePrototype image, final boolean leftIcon) {
setElement(DOM.createDiv());
sinkEvents(Event.ONCLICK | Event.MOUSEEVENTS | Event.ONMOUSEWHEEL | Event.ONDBLCLICK);
- icon = image.createImage().getElement();
+ setIcon(image);
textLabel = DOM.createSpan();
if (leftIcon) {
setStyleName("kune-IconLabel-l");
@@ -164,10 +164,6 @@
mouseWheelListeners.add(listener);
}
- public void setStyleNameToText(final String styleName) {
- DOM.setElementProperty(textLabel.<com.google.gwt.user.client.Element> cast(), "className", styleName);
- }
-
public HorizontalAlignmentConstant getHorizontalAlignment() {
return horzAlign;
}
@@ -244,6 +240,14 @@
DOM.setStyleAttribute(textLabel, "textAlign", align.getTextAlignString());
}
+ public void setIcon(AbstractImagePrototype image) {
+ icon = getImageElement(image);
+ }
+
+ public void setStyleNameToText(final String styleName) {
+ DOM.setElementProperty(textLabel.<com.google.gwt.user.client.Element> cast(), "className", styleName);
+ }
+
public void setText(final String text) {
DOM.setInnerText(textLabel, text);
}
@@ -258,4 +262,8 @@
DOM.setStyleAttribute(textLabel, "whiteSpace", wrap ? "normal" : "nowrap");
}
+ private Element getImageElement(final AbstractImagePrototype image) {
+ return image.createImage().getElement();
+ }
+
}
\ No newline at end of file
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-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -68,8 +68,8 @@
public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
RTEActionSndToolbar sndBar, RTEImgResources imgResources, InsertLinkDialog textEditorInsertElement,
- ColorWebSafePalette palette, Provider<EditHtmlDialog> editHtmlDialog, Provider<InsertImageDialog> insertImageDialog,
- DeferredCommandWrapper deferred) {
+ ColorWebSafePalette palette, Provider<EditHtmlDialog> editHtmlDialog,
+ Provider<InsertImageDialog> insertImageDialog, DeferredCommandWrapper deferred) {
this.i18n = i18n;
this.session = session;
this.topBar = topBar;
@@ -535,6 +535,12 @@
public void onEvent() {
deferred.addCommand(new Listener0() {
public void onEvent() {
+ insertElement.setOnCreateLink(new Listener2<String, String>() {
+ public void onEvent(String name, String url) {
+ view.createLink(url);
+ fireOnEdit();
+ }
+ });
insertElement.show();
}
});
@@ -544,12 +550,6 @@
createLink.setToolTip(i18n.t("Create Link"));
createLink.setShortcut(new ActionShortcut(true, 'K'));
createLink.setAddCondition(canBeExtended);
- insertElement.addOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- view.createLink(url);
- fireOnEdit();
- }
- });
ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
new Listener0() {
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -25,10 +25,8 @@
public interface InsertLinkDialog extends AbstractTabbedDialog {
- @Deprecated
- void addOnCreateLink(Listener2<String, String> slot);
-
- @Deprecated
void fireOnCreateLink(String name, String link);
+ void setOnCreateLink(Listener2<String, String> listener);
+
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -21,32 +21,27 @@
import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
-import com.calclab.suco.client.events.Event2;
import com.calclab.suco.client.events.Listener2;
public class InsertLinkDialogPresenter extends AbstractTabbedDialogPresenter implements InsertLinkDialog {
- private final Event2<String, String> onCreateLink;
+ private Listener2<String, String> onCreateListener;
public InsertLinkDialogPresenter() {
- this.onCreateLink = new Event2<String, String>("onCreateLink");
}
- @Deprecated
- public void addOnCreateLink(final Listener2<String, String> slot) {
- onCreateLink.add(slot);
- }
-
- @Deprecated
public void fireOnCreateLink(String name, String link) {
- onCreateLink.fire(name, link);
+ onCreateListener.onEvent(name, link);
super.hide();
}
- @Deprecated
public void fireOnInsertHtml(String name, String link) {
- onCreateLink.fire(name, link);
+ onCreateListener.onEvent(name, link);
super.hide();
}
+ public void setOnCreateLink(final Listener2<String, String> listener) {
+ this.onCreateListener = listener;
+ }
+
}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_in.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_in.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_out.png
===================================================================
(Binary files differ)
Property changes on: trunk/src/main/java/org/ourproject/kune/platf/public/images/arrow_out.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientActions.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -27,7 +27,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -53,7 +53,7 @@
final Provider<GroupServiceAsync> groupServiceProvider, final Provider<FileUploader> fileUploaderProvider,
final ContentActionRegistry contentActionRegistry, final ContextActionRegistry contextActionRegistry,
final Provider<FileDownloadUtils> fileDownloadProvider, final EntityHeader entityLogo,
- final Provider<ContentEditor> textEditorProvider, final KuneErrorHandler errorHandler,
+ final Provider<ContentEditor> textEditorProvider, final ErrorHandler errorHandler,
final WikiViewer documentViewer, final Provider<ContextPropEditor> contextProvEditorProvider,
final SitePublicSpaceLink publicLink) {
super(session, stateManager, i18n, errorHandler, deferredCommandWrapper, groupServiceProvider,
Modified: trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/wiki/client/WikiClientModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -25,7 +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.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -78,7 +78,7 @@
$(Session.class), $(StateManager.class), $(DeferredCommandWrapper.class),
$$(ContentServiceAsync.class), $$(GroupServiceAsync.class), $$(FileUploader.class),
$(ContentActionRegistry.class), $(ContextActionRegistry.class), $$(FileDownloadUtils.class),
- $(EntityHeader.class), $$(ContentEditor.class), $(KuneErrorHandler.class), $(WikiViewer.class),
+ $(EntityHeader.class), $$(ContentEditor.class), $(ErrorHandler.class), $(WikiViewer.class),
$$(ContextPropEditor.class), $(SitePublicSpaceLink.class));
}
});
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/AbstractFoldableContentActions.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -46,7 +46,7 @@
import org.ourproject.kune.platf.client.rpc.AsyncCallbackSimple;
import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
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;
@@ -86,7 +86,7 @@
protected final Provider<ContentServiceAsync> contentServiceProvider;
protected final Provider<FileUploader> fileUploaderProvider;
protected final ContextNavigator contextNavigator;
- protected final KuneErrorHandler errorHandler;
+ protected final ErrorHandler errorHandler;
protected final Provider<GroupServiceAsync> groupServiceProvider;
protected final ContentActionRegistry contentActionRegistry;
protected final ContextActionRegistry contextActionRegistry;
@@ -99,7 +99,7 @@
private final SitePublicSpaceLink publicLink;
public AbstractFoldableContentActions(Session session, StateManager stateManager, I18nUITranslationService i18n,
- KuneErrorHandler errorHandler, DeferredCommandWrapper deferredCommandWrapper,
+ ErrorHandler errorHandler, DeferredCommandWrapper deferredCommandWrapper,
Provider<GroupServiceAsync> groupServiceProvider, Provider<ContentServiceAsync> contentServiceProvider,
Provider<FileUploader> fileUploaderProvider, ContextNavigator contextNavigator,
ContentActionRegistry contentActionRegistry, ContextActionRegistry contextActionRegistry,
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -1,212 +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;
-
-import org.ourproject.kune.platf.client.registry.AclEditableRegistry;
-import org.ourproject.kune.platf.client.registry.AuthorableRegistry;
-import org.ourproject.kune.platf.client.registry.CanBeHomepageRegistry;
-import org.ourproject.kune.platf.client.registry.ComentableRegistry;
-import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
-import org.ourproject.kune.platf.client.registry.DragableRegistry;
-import org.ourproject.kune.platf.client.registry.DropableRegistry;
-import org.ourproject.kune.platf.client.registry.EmailSubscribeAbleRegistry;
-import org.ourproject.kune.platf.client.registry.LicensableRegistry;
-import org.ourproject.kune.platf.client.registry.PublishModerableRegistry;
-import org.ourproject.kune.platf.client.registry.RateableRegistry;
-import org.ourproject.kune.platf.client.registry.RenamableRegistry;
-import org.ourproject.kune.platf.client.registry.TageableRegistry;
-import org.ourproject.kune.platf.client.registry.TranslatableRegistry;
-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.workspace.client.cnt.ContentActionRegistry;
-import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
-import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry;
-import org.ourproject.kune.workspace.client.socialnet.GroupActionRegistry;
-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 KuneRegistryModule extends AbstractModule {
-
- @Override
- protected void onInstall() {
-
- register(Singleton.class, new Factory<AclEditableRegistry>(AclEditableRegistry.class) {
- @Override
- public AclEditableRegistry create() {
- return new AclEditableRegistry();
- }
- });
- register(Singleton.class, new Factory<AuthorableRegistry>(AuthorableRegistry.class) {
- @Override
- public AuthorableRegistry create() {
- return new AuthorableRegistry();
- }
- });
- register(Singleton.class, new Factory<CanBeHomepageRegistry>(CanBeHomepageRegistry.class) {
- @Override
- public CanBeHomepageRegistry create() {
- return new CanBeHomepageRegistry();
- }
- });
-
- register(Singleton.class, new Factory<ComentableRegistry>(ComentableRegistry.class) {
- @Override
- public ComentableRegistry create() {
- return new ComentableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<DragableRegistry>(DragableRegistry.class) {
- @Override
- public DragableRegistry create() {
- return new DragableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<DropableRegistry>(DropableRegistry.class) {
- @Override
- public DropableRegistry create() {
- return new DropableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<EmailSubscribeAbleRegistry>(EmailSubscribeAbleRegistry.class) {
- @Override
- public EmailSubscribeAbleRegistry create() {
- return new EmailSubscribeAbleRegistry();
- }
- });
-
- register(Singleton.class, new Factory<LicensableRegistry>(LicensableRegistry.class) {
- @Override
- public LicensableRegistry create() {
- return new LicensableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<PublishModerableRegistry>(PublishModerableRegistry.class) {
- @Override
- public PublishModerableRegistry create() {
- return new PublishModerableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<RateableRegistry>(RateableRegistry.class) {
- @Override
- public RateableRegistry create() {
- return new RateableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<TageableRegistry>(TageableRegistry.class) {
- @Override
- public TageableRegistry create() {
- return new TageableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<RenamableRegistry>(RenamableRegistry.class) {
- @Override
- public RenamableRegistry create() {
- return new RenamableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<TranslatableRegistry>(TranslatableRegistry.class) {
- @Override
- public TranslatableRegistry create() {
- return new TranslatableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<VersionableRegistry>(VersionableRegistry.class) {
- @Override
- public VersionableRegistry create() {
- return new VersionableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<XmppComentableRegistry>(XmppComentableRegistry.class) {
- @Override
- public XmppComentableRegistry create() {
- return new XmppComentableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<XmppNotifyCapableRegistry>(XmppNotifyCapableRegistry.class) {
- @Override
- public XmppNotifyCapableRegistry create() {
- return new XmppNotifyCapableRegistry();
- }
- });
-
- register(Singleton.class, new Factory<ContentIconsRegistry>(ContentIconsRegistry.class) {
- @Override
- public ContentIconsRegistry create() {
- return new ContentIconsRegistry();
- }
- });
-
- 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));
- }
- });
-
- register(Singleton.class, new Factory<ContextActionRegistry>(ContextActionRegistry.class) {
- @Override
- public ContextActionRegistry create() {
- return new ContextActionRegistry();
- }
- });
-
- register(Singleton.class, new Factory<ContentActionRegistry>(ContentActionRegistry.class) {
- @Override
- public ContentActionRegistry create() {
- return new ContentActionRegistry();
- }
- });
-
- register(Singleton.class, new Factory<GroupActionRegistry>(GroupActionRegistry.class) {
- @Override
- public GroupActionRegistry create() {
- return new GroupActionRegistry();
- }
- });
-
- register(Singleton.class, new Factory<UserActionRegistry>(UserActionRegistry.class) {
- @Override
- public UserActionRegistry create() {
- return new UserActionRegistry();
- }
- });
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -1,940 +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;
-
-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.app.ApplicationComponentGroup;
-import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.dto.UserSimpleDTO;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.registry.AuthorableRegistry;
-import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
-import org.ourproject.kune.platf.client.registry.RenamableRegistry;
-import org.ourproject.kune.platf.client.rpc.ContentService;
-import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
-import org.ourproject.kune.platf.client.rpc.GroupService;
-import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
-import org.ourproject.kune.platf.client.rpc.I18nServiceAsync;
-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.ImageUtils;
-import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
-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.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.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
-import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.platf.client.utils.TimerWrapper;
-import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
-import org.ourproject.kune.workspace.client.cnt.ActionContentToolbarPresenter;
-import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
-import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
-import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPanel;
-import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPresenter;
-import org.ourproject.kune.workspace.client.cxt.ActionContextBottomToolbar;
-import org.ourproject.kune.workspace.client.cxt.ActionContextTopToolbar;
-import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPanel;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter;
-import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView;
-import org.ourproject.kune.workspace.client.editor.ContentEditor;
-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;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocal;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPanel;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPresenter;
-import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
-import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPanel;
-import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPresenter;
-import org.ourproject.kune.workspace.client.i18n.I18nTranslator;
-import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPanel;
-import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPresenter;
-import org.ourproject.kune.workspace.client.i18n.I18nTranslatorView;
-import org.ourproject.kune.workspace.client.i18n.LanguageSelector;
-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.licensefoot.EntityLicensePanel;
-import org.ourproject.kune.workspace.client.licensefoot.EntityLicensePresenter;
-import org.ourproject.kune.workspace.client.licensewizard.LicenseChangeAction;
-import org.ourproject.kune.workspace.client.licensewizard.LicenseWizard;
-import org.ourproject.kune.workspace.client.licensewizard.LicenseWizardPanel;
-import org.ourproject.kune.workspace.client.licensewizard.LicenseWizardPresenter;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFirstForm;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFirstFormView;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFrdForm;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFrdFormView;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardSndForm;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardSndFormView;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardTrdForm;
-import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardTrdFormView;
-import org.ourproject.kune.workspace.client.newgroup.NewGroup;
-import org.ourproject.kune.workspace.client.newgroup.NewGroupPanel;
-import org.ourproject.kune.workspace.client.newgroup.NewGroupPresenter;
-import org.ourproject.kune.workspace.client.nohomepage.NoHomePage;
-import org.ourproject.kune.workspace.client.nohomepage.NoHomePagePanel;
-import org.ourproject.kune.workspace.client.nohomepage.NoHomePagePresenter;
-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.license.EntityOptionsDefLicense;
-import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePanel;
-import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePresenter;
-import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogo;
-import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogoPanel;
-import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogoPresenter;
-import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConf;
-import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConfPanel;
-import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConfPresenter;
-import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConf;
-import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConfPanel;
-import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConfPresenter;
-import org.ourproject.kune.workspace.client.rate.RateIt;
-import org.ourproject.kune.workspace.client.rate.RateItPanel;
-import org.ourproject.kune.workspace.client.rate.RateItPresenter;
-import org.ourproject.kune.workspace.client.rate.RatePanel;
-import org.ourproject.kune.workspace.client.rate.RatePresenter;
-import org.ourproject.kune.workspace.client.search.EntityLiveSearcherView;
-import org.ourproject.kune.workspace.client.search.GroupLiveSearchPanel;
-import org.ourproject.kune.workspace.client.search.GroupLiveSearcher;
-import org.ourproject.kune.workspace.client.search.GroupLiveSearcherPresenter;
-import org.ourproject.kune.workspace.client.search.SiteSearcher;
-import org.ourproject.kune.workspace.client.search.SiteSearcherPanel;
-import org.ourproject.kune.workspace.client.search.SiteSearcherPresenter;
-import org.ourproject.kune.workspace.client.search.SiteSearcherView;
-import org.ourproject.kune.workspace.client.search.UserLiveSearcher;
-import org.ourproject.kune.workspace.client.search.UserLiveSearcherPanel;
-import org.ourproject.kune.workspace.client.search.UserLiveSearcherPresenter;
-import org.ourproject.kune.workspace.client.signin.Register;
-import org.ourproject.kune.workspace.client.signin.RegisterPanel;
-import org.ourproject.kune.workspace.client.signin.RegisterPresenter;
-import org.ourproject.kune.workspace.client.signin.RegisterView;
-import org.ourproject.kune.workspace.client.signin.SignIn;
-import org.ourproject.kune.workspace.client.signin.SignInPanel;
-import org.ourproject.kune.workspace.client.signin.SignInPresenter;
-import org.ourproject.kune.workspace.client.signin.SignInView;
-import org.ourproject.kune.workspace.client.site.SiteToken;
-import org.ourproject.kune.workspace.client.site.WorkspaceNotifyUser;
-import org.ourproject.kune.workspace.client.site.msg.ToastMessage;
-import org.ourproject.kune.workspace.client.site.msg.ToastMessagePanel;
-import org.ourproject.kune.workspace.client.site.msg.ToastMessagePresenter;
-import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogo;
-import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogoPanel;
-import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogoPresenter;
-import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLink;
-import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLinkPanel;
-import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLinkPresenter;
-import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptions;
-import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptionsPanel;
-import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptionsPresenter;
-import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgress;
-import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgressPanel;
-import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgressPresenter;
-import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink;
-import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLinkPanel;
-import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLinkPresenter;
-import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearch;
-import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearchPanel;
-import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearchPresenter;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLink;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPanel;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPresenter;
-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.skel.ActionCntCtxToolbarPanel;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-import org.ourproject.kune.workspace.client.socialnet.BuddiesSummary;
-import org.ourproject.kune.workspace.client.socialnet.BuddiesSummaryPanel;
-import org.ourproject.kune.workspace.client.socialnet.BuddiesSummaryPresenter;
-import org.ourproject.kune.workspace.client.socialnet.GroupActionRegistry;
-import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummary;
-import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryPanel;
-import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryPresenter;
-import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryView;
-import org.ourproject.kune.workspace.client.socialnet.ParticipationSummary;
-import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPanel;
-import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPresenter;
-import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryView;
-import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry;
-import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddie;
-import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePanel;
-import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePresenter;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionBuddiesSummaryToolbar;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionBuddiesSummaryToolbarPresenter;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionGroupSummaryToolbar;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionGroupSummaryToolbarPresenter;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionParticipationSummaryToolbarPresenter;
-import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionParticipationToolbar;
-import org.ourproject.kune.workspace.client.tags.TagsSummary;
-import org.ourproject.kune.workspace.client.tags.TagsSummaryPanel;
-import org.ourproject.kune.workspace.client.tags.TagsSummaryPresenter;
-import org.ourproject.kune.workspace.client.themes.WsThemePanel;
-import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
-import org.ourproject.kune.workspace.client.title.EntitySubTitle;
-import org.ourproject.kune.workspace.client.title.EntitySubTitlePanel;
-import org.ourproject.kune.workspace.client.title.EntitySubTitlePresenter;
-import org.ourproject.kune.workspace.client.title.EntityTitle;
-import org.ourproject.kune.workspace.client.title.EntityTitlePanel;
-import org.ourproject.kune.workspace.client.title.EntityTitlePresenter;
-import org.ourproject.kune.workspace.client.title.RenameAction;
-import org.ourproject.kune.workspace.client.tool.ToolSelector;
-import org.ourproject.kune.workspace.client.tool.ToolSelectorPresenter;
-import org.ourproject.kune.workspace.client.upload.FileUploader;
-import org.ourproject.kune.workspace.client.upload.FileUploaderDialog;
-import org.ourproject.kune.workspace.client.upload.FileUploaderPresenter;
-
-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 KuneWorkspaceModule extends AbstractModule {
- @Override
- protected void onInstall() {
-
- register(Singleton.class, new Factory<SocialNetworkServiceAsync>(SocialNetworkServiceAsync.class) {
- @Override
- public SocialNetworkServiceAsync create() {
- final SocialNetworkServiceAsync snServiceAsync = (SocialNetworkServiceAsync) GWT.create(SocialNetworkService.class);
- ((ServiceDefTarget) snServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL()
- + "SocialNetworkService");
- return snServiceAsync;
- }
- }, new Factory<GroupServiceAsync>(GroupServiceAsync.class) {
- @Override
- public GroupServiceAsync create() {
- final GroupServiceAsync groupServiceAsync = (GroupServiceAsync) GWT.create(GroupService.class);
- ((ServiceDefTarget) groupServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL() + "GroupService");
- return groupServiceAsync;
- }
- }, new Factory<ContentServiceAsync>(ContentServiceAsync.class) {
- @Override
- public ContentServiceAsync create() {
- final ContentServiceAsync contentServiceAsync = (ContentServiceAsync) GWT.create(ContentService.class);
- ((ServiceDefTarget) contentServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL() + "ContentService");
- return contentServiceAsync;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<WorkspaceSkeleton>(WorkspaceSkeleton.class) {
- @Override
- public WorkspaceSkeleton create() {
- return new WorkspaceSkeleton();
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<SiteProgress>(SiteProgress.class) {
- @Override
- public SiteProgress create() {
- final SiteProgressPresenter presenter = new SiteProgressPresenter();
- final SiteProgressPanel panel = new SiteProgressPanel(presenter, $$(SitePublicSpaceLink.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<SitePublicSpaceLink>(SitePublicSpaceLink.class) {
- @Override
- public SitePublicSpaceLink create() {
- final SitePublicSpaceLinkPresenter presenter = new SitePublicSpaceLinkPresenter($(StateManager.class));
- final SitePublicSpaceLinkPanel panel = new SitePublicSpaceLinkPanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nUITranslationService.class), $(Images.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(NoDecoration.class, new Factory<ToastMessage>(ToastMessage.class) {
- @Override
- public ToastMessage create() {
- final ToastMessagePresenter presenter = new ToastMessagePresenter();
- final ToastMessagePanel panel = new ToastMessagePanel();
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<SiteSignOutLink>(SiteSignOutLink.class) {
- @Override
- public SiteSignOutLink create() {
- final SiteSignOutLinkPresenter presenter = new SiteSignOutLinkPresenter($(Session.class),
- $$(UserServiceAsync.class), $$(KuneErrorHandler.class));
- final SiteSignOutLinkPanel panel = new SiteSignOutLinkPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<SiteNewGroupLink>(SiteNewGroupLink.class) {
- @Override
- public SiteNewGroupLink create() {
- final SiteNewGroupLinkPresenter presenter = new SiteNewGroupLinkPresenter();
- final SiteNewGroupLinkPanel panel = new SiteNewGroupLinkPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nUITranslationService.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<SiteOptions>(SiteOptions.class) {
- @Override
- public SiteOptions create() {
- final SiteOptionsPresenter presenter = new SiteOptionsPresenter();
- final SiteOptionsPanel panel = new SiteOptionsPanel(presenter, $(WorkspaceSkeleton.class),
- $(I18nUITranslationService.class), $$(I18nTranslator.class), $$(TestRTEDialog.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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);
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<EntitySubTitle>(EntitySubTitle.class) {
- @Override
- public EntitySubTitle create() {
- final EntitySubTitlePresenter presenter = new EntitySubTitlePresenter(
- $(I18nUITranslationService.class), $(StateManager.class), false, $(AuthorableRegistry.class));
- final EntitySubTitlePanel panel = new EntitySubTitlePanel(presenter, $(WorkspaceSkeleton.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<ActionManager>(ActionManager.class) {
- @Override
- public ActionManager create() {
- return new ActionManager();
- }
- });
-
- register(Singleton.class, new Factory<ActionGroupSummaryToolbar>(ActionGroupSummaryToolbar.class) {
- @Override
- public ActionGroupSummaryToolbar create() {
- final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
- final ActionGroupSummaryToolbarPresenter toolbar = new ActionGroupSummaryToolbarPresenter(panel);
- return toolbar;
- }
- }, new Factory<ActionParticipationToolbar>(ActionParticipationToolbar.class) {
- @Override
- public ActionParticipationToolbar create() {
- final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
- final ActionParticipationSummaryToolbarPresenter toolbar = new ActionParticipationSummaryToolbarPresenter(
- panel);
- return toolbar;
- }
- }, new Factory<ActionBuddiesSummaryToolbar>(ActionBuddiesSummaryToolbar.class) {
- @Override
- public ActionBuddiesSummaryToolbar create() {
- final ActionToolbarPanel<UserSimpleDTO> panel = new ActionToolbarPanel<UserSimpleDTO>(
- $$(ActionManager.class));
- final ActionBuddiesSummaryToolbarPresenter toolbar = new ActionBuddiesSummaryToolbarPresenter(panel);
- return toolbar;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<GroupMembersSummary>(GroupMembersSummary.class) {
- @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));
- final GroupMembersSummaryView view = new GroupMembersSummaryPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $(
- ActionGroupSummaryToolbar.class).getView());
- presenter.init(view);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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());
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(ApplicationComponentGroup.class, new Factory<ParticipationSummary>(ParticipationSummary.class) {
- @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));
- final ParticipationSummaryView view = new ParticipationSummaryPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class),
- ($(ActionParticipationToolbar.class).getView()));
- presenter.init(view);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(EntityOptionsGroup.class, new Factory<EntityOptionsToolsConf>(EntityOptionsToolsConf.class) {
- @Override
- public EntityOptionsToolsConf create() {
- final EntityOptionsToolsConfPresenter presenter = new EntityOptionsToolsConfPresenter(
- $(StateManager.class), $(Session.class), $(I18nTranslationService.class),
- $(EntityOptions.class), $$(GroupServiceAsync.class));
- final EntityOptionsToolsConfPanel panel = new EntityOptionsToolsConfPanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(EntityOptionsGroup.class, new Factory<EntityOptionsDefLicense>(EntityOptionsDefLicense.class) {
- @Override
- public EntityOptionsDefLicense create() {
- final EntityOptionsDefLicensePresenter presenter = new EntityOptionsDefLicensePresenter(
- $(EntityOptions.class), $(StateManager.class), $(Session.class), $$(LicenseWizard.class),
- $$(LicenseChangeAction.class));
- final EntityOptionsDefLicensePanel panel = new EntityOptionsDefLicensePanel(presenter,
- $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(EntityOptionsGroup.class,
- new Factory<EntityOptionsPublicSpaceConf>(EntityOptionsPublicSpaceConf.class) {
- @Override
- public EntityOptionsPublicSpaceConf create() {
- final EntityOptionsPublicSpaceConfPresenter presenter = new EntityOptionsPublicSpaceConfPresenter(
- $(EntityOptions.class));
- final EntityOptionsPublicSpaceConfPanel panel = new EntityOptionsPublicSpaceConfPanel(
- presenter, $(WorkspaceSkeleton.class), $(I18nTranslationService.class),
- $(WsThemePresenter.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<LicenseChangeAction>(LicenseChangeAction.class) {
- @Override
- public LicenseChangeAction create() {
- return new LicenseChangeAction($$(GroupServiceAsync.class), $(Session.class),
- $(I18nTranslationService.class), $(StateManager.class));
- }
- });
-
- register(Singleton.class, new Factory<RenameAction>(RenameAction.class) {
- @Override
- public RenameAction create() {
- return new RenameAction($(I18nTranslationService.class), $(Session.class),
- $$(ContentServiceAsync.class));
- }
- });
-
- register(Singleton.class, new Factory<LicenseWizard>(LicenseWizard.class) {
- @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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<LicenseWizardFirstFormView>(LicenseWizardFirstFormView.class) {
- @Override
- public LicenseWizardFirstFormView create() {
- return new LicenseWizardFirstForm($(I18nTranslationService.class));
- }
- });
-
- register(Singleton.class, new Factory<LicenseWizardSndFormView>(LicenseWizardSndFormView.class) {
- @Override
- public LicenseWizardSndFormView create() {
- return new LicenseWizardSndForm($(I18nTranslationService.class));
- }
- });
-
- register(Singleton.class, new Factory<LicenseWizardTrdFormView>(LicenseWizardTrdFormView.class) {
- @Override
- public LicenseWizardTrdFormView create() {
- return new LicenseWizardTrdForm($(Images.class), $(I18nTranslationService.class));
- }
- });
-
- register(Singleton.class, new Factory<LicenseWizardFrdFormView>(LicenseWizardFrdFormView.class) {
- @Override
- public LicenseWizardFrdFormView create() {
- return new LicenseWizardFrdForm($(I18nTranslationService.class), $(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));
- presenter.init(panel);
- return presenter;
- }
-
- @Override
- public void onAfterCreated(FileUploader uploader) {
- $(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));
- presenter.init(view);
- return presenter;
- }
- });
-
- 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));
- presenter.init(view);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(view);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<UserLiveSearcher>(UserLiveSearcher.class) {
- @Override
- public UserLiveSearcher create() {
- final UserLiveSearcherPresenter presenter = new UserLiveSearcherPresenter();
- final EntityLiveSearcherView view = new UserLiveSearcherPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class));
- presenter.init(view);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<GroupLiveSearcher>(GroupLiveSearcher.class) {
- @Override
- public GroupLiveSearcher create() {
- final GroupLiveSearcherPresenter presenter = new GroupLiveSearcherPresenter();
- final EntityLiveSearcherView view = new GroupLiveSearchPanel(presenter,
- $(I18nTranslationService.class), $(FileDownloadUtils.class));
- presenter.init(view);
- return presenter;
- }
- });
-
- register(Singleton.class, new Factory<ToolSelector>(ToolSelector.class) {
- @Override
- public ToolSelector create() {
- final ToolSelectorPresenter presenter = new ToolSelectorPresenter($(StateManager.class),
- $(WsThemePresenter.class));
- return presenter;
- }
- });
-
- 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));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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));
- presenter.init(view);
- return presenter;
- }
- });
-
- // Register of tokens like "signin", "newgroup", "translate" etcetera
- $(StateManager.class).addSiteToken(SiteToken.signin.toString(), new Listener0() {
- public void onEvent() {
- $(SignIn.class).doSignIn();
- }
- });
-
- $(StateManager.class).addSiteToken(SiteToken.register.toString(), new Listener0() {
- public void onEvent() {
- $(Register.class).doRegister();
- }
- });
-
- $(StateManager.class).addSiteToken(SiteToken.newgroup.toString(), new Listener0() {
- public void onEvent() {
- $(NewGroup.class).doNewGroup();
- }
- });
-
- $(StateManager.class).addSiteToken(SiteToken.translate.toString(), new Listener0() {
- public void onEvent() {
- $(I18nTranslator.class).doShowTranslator();
- }
- });
-
- register(NoDecoration.class, new Factory<ActionContentToolbar>(ActionContentToolbar.class) {
- @Override
- public ActionContentToolbar create() {
- final ActionCntCtxToolbarPanel<StateToken> tbar = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTENT_TOPBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
- final ActionContentToolbar toolbar = new ActionContentToolbarPresenter(tbar);
- return toolbar;
- }
- });
-
- register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) {
- @Override
- public ContentEditor create() {
- return new ContentEditor($(RTEditor.class), true, $(I18nTranslationService.class),
- $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
- $(RTEImgResources.class), $(WorkspaceSkeleton.class), $(TimerWrapper.class),
- new RTESavingEditorPanel());
- }
- });
- register(NoDecoration.class, new Factory<ActionContextTopToolbar>(ActionContextTopToolbar.class) {
- @Override
- public ActionContextTopToolbar create() {
- final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTEXT_TOPBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
- final ActionContextTopToolbar toolbar = new ActionContextTopToolbar(panel);
- return toolbar;
- }
- });
-
- register(NoDecoration.class, new Factory<ActionContextBottomToolbar>(ActionContextBottomToolbar.class) {
- @Override
- public ActionContextBottomToolbar create() {
- final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
- AbstractFoldableContentActions.CONTEXT_BOTTOMBAR, $$(ActionManager.class),
- $(WorkspaceSkeleton.class));
- final ActionContextBottomToolbar toolbar = new ActionContextBottomToolbar(panel);
- return toolbar;
- }
- });
-
- register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) {
- @Override
- public ContextNavigator create() {
- final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
- $(Session.class), $(I18nTranslationService.class), $(ContentIconsRegistry.class),
- $(ContentCapabilitiesRegistry.class), $(ActionContextTopToolbar.class),
- $(ActionContextBottomToolbar.class), $(ContextActionRegistry.class),
- $$(FileDownloadUtils.class), true, $(RenameAction.class));
- final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter,
- $(I18nTranslationService.class), $(WorkspaceSkeleton.class), $(ActionManager.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- 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 ContextPropEditorView view = new ContextPropEditorPanel(presenter,
- $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $$(LanguageSelector.class),
- $(Images.class));
- presenter.init(view);
- return presenter;
- }
- });
-
- register(InsertImageGroup.class, new Factory<InsertImageLocal>(InsertImageLocal.class) {
- @Override
- public InsertImageLocal create() {
- final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter($(InsertImageDialog.class));
- final InsertImageLocalPanel panel = new InsertImageLocalPanel(presenter,
- $(I18nTranslationService.class));
- presenter.init(panel);
- return presenter;
- }
- });
-
- }
-}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java (from rev 1071, trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneRegistryModule.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/RegistryModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,212 @@
+/*
+ *
+ * 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;
+
+import org.ourproject.kune.platf.client.registry.AclEditableRegistry;
+import org.ourproject.kune.platf.client.registry.AuthorableRegistry;
+import org.ourproject.kune.platf.client.registry.CanBeHomepageRegistry;
+import org.ourproject.kune.platf.client.registry.ComentableRegistry;
+import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
+import org.ourproject.kune.platf.client.registry.DragableRegistry;
+import org.ourproject.kune.platf.client.registry.DropableRegistry;
+import org.ourproject.kune.platf.client.registry.EmailSubscribeAbleRegistry;
+import org.ourproject.kune.platf.client.registry.LicensableRegistry;
+import org.ourproject.kune.platf.client.registry.PublishModerableRegistry;
+import org.ourproject.kune.platf.client.registry.RateableRegistry;
+import org.ourproject.kune.platf.client.registry.RenamableRegistry;
+import org.ourproject.kune.platf.client.registry.TageableRegistry;
+import org.ourproject.kune.platf.client.registry.TranslatableRegistry;
+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.workspace.client.cnt.ContentActionRegistry;
+import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
+import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry;
+import org.ourproject.kune.workspace.client.socialnet.GroupActionRegistry;
+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 {
+
+ @Override
+ protected void onInstall() {
+
+ register(Singleton.class, new Factory<AclEditableRegistry>(AclEditableRegistry.class) {
+ @Override
+ public AclEditableRegistry create() {
+ return new AclEditableRegistry();
+ }
+ });
+ register(Singleton.class, new Factory<AuthorableRegistry>(AuthorableRegistry.class) {
+ @Override
+ public AuthorableRegistry create() {
+ return new AuthorableRegistry();
+ }
+ });
+ register(Singleton.class, new Factory<CanBeHomepageRegistry>(CanBeHomepageRegistry.class) {
+ @Override
+ public CanBeHomepageRegistry create() {
+ return new CanBeHomepageRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<ComentableRegistry>(ComentableRegistry.class) {
+ @Override
+ public ComentableRegistry create() {
+ return new ComentableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<DragableRegistry>(DragableRegistry.class) {
+ @Override
+ public DragableRegistry create() {
+ return new DragableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<DropableRegistry>(DropableRegistry.class) {
+ @Override
+ public DropableRegistry create() {
+ return new DropableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<EmailSubscribeAbleRegistry>(EmailSubscribeAbleRegistry.class) {
+ @Override
+ public EmailSubscribeAbleRegistry create() {
+ return new EmailSubscribeAbleRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<LicensableRegistry>(LicensableRegistry.class) {
+ @Override
+ public LicensableRegistry create() {
+ return new LicensableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<PublishModerableRegistry>(PublishModerableRegistry.class) {
+ @Override
+ public PublishModerableRegistry create() {
+ return new PublishModerableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<RateableRegistry>(RateableRegistry.class) {
+ @Override
+ public RateableRegistry create() {
+ return new RateableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<TageableRegistry>(TageableRegistry.class) {
+ @Override
+ public TageableRegistry create() {
+ return new TageableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<RenamableRegistry>(RenamableRegistry.class) {
+ @Override
+ public RenamableRegistry create() {
+ return new RenamableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<TranslatableRegistry>(TranslatableRegistry.class) {
+ @Override
+ public TranslatableRegistry create() {
+ return new TranslatableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<VersionableRegistry>(VersionableRegistry.class) {
+ @Override
+ public VersionableRegistry create() {
+ return new VersionableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<XmppComentableRegistry>(XmppComentableRegistry.class) {
+ @Override
+ public XmppComentableRegistry create() {
+ return new XmppComentableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<XmppNotifyCapableRegistry>(XmppNotifyCapableRegistry.class) {
+ @Override
+ public XmppNotifyCapableRegistry create() {
+ return new XmppNotifyCapableRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<ContentIconsRegistry>(ContentIconsRegistry.class) {
+ @Override
+ public ContentIconsRegistry create() {
+ return new ContentIconsRegistry();
+ }
+ });
+
+ 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));
+ }
+ });
+
+ register(Singleton.class, new Factory<ContextActionRegistry>(ContextActionRegistry.class) {
+ @Override
+ public ContextActionRegistry create() {
+ return new ContextActionRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<ContentActionRegistry>(ContentActionRegistry.class) {
+ @Override
+ public ContentActionRegistry create() {
+ return new ContentActionRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<GroupActionRegistry>(GroupActionRegistry.class) {
+ @Override
+ public GroupActionRegistry create() {
+ return new GroupActionRegistry();
+ }
+ });
+
+ register(Singleton.class, new Factory<UserActionRegistry>(UserActionRegistry.class) {
+ @Override
+ public UserActionRegistry create() {
+ return new UserActionRegistry();
+ }
+ });
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java (from rev 1071, trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/WorkspaceModule.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,952 @@
+/*
+ *
+ * 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;
+
+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.app.ApplicationComponentGroup;
+import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.dto.UserSimpleDTO;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+import org.ourproject.kune.platf.client.registry.AuthorableRegistry;
+import org.ourproject.kune.platf.client.registry.ContentCapabilitiesRegistry;
+import org.ourproject.kune.platf.client.registry.RenamableRegistry;
+import org.ourproject.kune.platf.client.rpc.ContentService;
+import org.ourproject.kune.platf.client.rpc.ContentServiceAsync;
+import org.ourproject.kune.platf.client.rpc.GroupService;
+import org.ourproject.kune.platf.client.rpc.GroupServiceAsync;
+import org.ourproject.kune.platf.client.rpc.I18nServiceAsync;
+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.ErrorHandler;
+import org.ourproject.kune.platf.client.services.ImageUtils;
+import org.ourproject.kune.platf.client.services.Images;
+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.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.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+import org.ourproject.kune.platf.client.utils.TimerWrapper;
+import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
+import org.ourproject.kune.workspace.client.cnt.ActionContentToolbarPresenter;
+import org.ourproject.kune.workspace.client.cnt.ContentIconsRegistry;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigator;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPanel;
+import org.ourproject.kune.workspace.client.ctxnav.ContextNavigatorPresenter;
+import org.ourproject.kune.workspace.client.cxt.ActionContextBottomToolbar;
+import org.ourproject.kune.workspace.client.cxt.ActionContextTopToolbar;
+import org.ourproject.kune.workspace.client.cxt.ContextActionRegistry;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditor;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPanel;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorPresenter;
+import org.ourproject.kune.workspace.client.cxt.ContextPropEditorView;
+import org.ourproject.kune.workspace.client.editor.ContentEditor;
+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;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocal;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPanel;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPresenter;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPanel;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPresenter;
+import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspace;
+import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePanel;
+import org.ourproject.kune.workspace.client.entityheader.maxmin.MaxMinWorkspacePresenter;
+import org.ourproject.kune.workspace.client.i18n.I18nTranslator;
+import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPanel;
+import org.ourproject.kune.workspace.client.i18n.I18nTranslatorPresenter;
+import org.ourproject.kune.workspace.client.i18n.I18nTranslatorView;
+import org.ourproject.kune.workspace.client.i18n.LanguageSelector;
+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.licensefoot.EntityLicensePanel;
+import org.ourproject.kune.workspace.client.licensefoot.EntityLicensePresenter;
+import org.ourproject.kune.workspace.client.licensewizard.LicenseChangeAction;
+import org.ourproject.kune.workspace.client.licensewizard.LicenseWizard;
+import org.ourproject.kune.workspace.client.licensewizard.LicenseWizardPanel;
+import org.ourproject.kune.workspace.client.licensewizard.LicenseWizardPresenter;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFirstForm;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFirstFormView;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFrdForm;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardFrdFormView;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardSndForm;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardSndFormView;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardTrdForm;
+import org.ourproject.kune.workspace.client.licensewizard.pages.LicenseWizardTrdFormView;
+import org.ourproject.kune.workspace.client.newgroup.NewGroup;
+import org.ourproject.kune.workspace.client.newgroup.NewGroupPanel;
+import org.ourproject.kune.workspace.client.newgroup.NewGroupPresenter;
+import org.ourproject.kune.workspace.client.nohomepage.NoHomePage;
+import org.ourproject.kune.workspace.client.nohomepage.NoHomePagePanel;
+import org.ourproject.kune.workspace.client.nohomepage.NoHomePagePresenter;
+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.license.EntityOptionsDefLicense;
+import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePanel;
+import org.ourproject.kune.workspace.client.options.license.EntityOptionsDefLicensePresenter;
+import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogo;
+import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogoPanel;
+import org.ourproject.kune.workspace.client.options.logo.EntityOptionsLogoPresenter;
+import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConf;
+import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConfPanel;
+import org.ourproject.kune.workspace.client.options.pscape.EntityOptionsPublicSpaceConfPresenter;
+import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConf;
+import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConfPanel;
+import org.ourproject.kune.workspace.client.options.tools.EntityOptionsToolsConfPresenter;
+import org.ourproject.kune.workspace.client.rate.RateIt;
+import org.ourproject.kune.workspace.client.rate.RateItPanel;
+import org.ourproject.kune.workspace.client.rate.RateItPresenter;
+import org.ourproject.kune.workspace.client.rate.RatePanel;
+import org.ourproject.kune.workspace.client.rate.RatePresenter;
+import org.ourproject.kune.workspace.client.search.EntityLiveSearcherView;
+import org.ourproject.kune.workspace.client.search.GroupLiveSearchPanel;
+import org.ourproject.kune.workspace.client.search.GroupLiveSearcher;
+import org.ourproject.kune.workspace.client.search.GroupLiveSearcherPresenter;
+import org.ourproject.kune.workspace.client.search.SiteSearcher;
+import org.ourproject.kune.workspace.client.search.SiteSearcherPanel;
+import org.ourproject.kune.workspace.client.search.SiteSearcherPresenter;
+import org.ourproject.kune.workspace.client.search.SiteSearcherView;
+import org.ourproject.kune.workspace.client.search.UserLiveSearcher;
+import org.ourproject.kune.workspace.client.search.UserLiveSearcherPanel;
+import org.ourproject.kune.workspace.client.search.UserLiveSearcherPresenter;
+import org.ourproject.kune.workspace.client.signin.Register;
+import org.ourproject.kune.workspace.client.signin.RegisterPanel;
+import org.ourproject.kune.workspace.client.signin.RegisterPresenter;
+import org.ourproject.kune.workspace.client.signin.RegisterView;
+import org.ourproject.kune.workspace.client.signin.SignIn;
+import org.ourproject.kune.workspace.client.signin.SignInPanel;
+import org.ourproject.kune.workspace.client.signin.SignInPresenter;
+import org.ourproject.kune.workspace.client.signin.SignInView;
+import org.ourproject.kune.workspace.client.site.SiteToken;
+import org.ourproject.kune.workspace.client.site.WorkspaceNotifyUser;
+import org.ourproject.kune.workspace.client.site.msg.ToastMessage;
+import org.ourproject.kune.workspace.client.site.msg.ToastMessagePanel;
+import org.ourproject.kune.workspace.client.site.msg.ToastMessagePresenter;
+import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogo;
+import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogoPanel;
+import org.ourproject.kune.workspace.client.sitebar.sitelogo.SiteLogoPresenter;
+import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLink;
+import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLinkPanel;
+import org.ourproject.kune.workspace.client.sitebar.sitenewgroup.SiteNewGroupLinkPresenter;
+import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptions;
+import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptionsPanel;
+import org.ourproject.kune.workspace.client.sitebar.siteoptions.SiteOptionsPresenter;
+import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgress;
+import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgressPanel;
+import org.ourproject.kune.workspace.client.sitebar.siteprogress.SiteProgressPresenter;
+import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLink;
+import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLinkPanel;
+import org.ourproject.kune.workspace.client.sitebar.sitepublic.SitePublicSpaceLinkPresenter;
+import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearch;
+import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearchPanel;
+import org.ourproject.kune.workspace.client.sitebar.sitesearch.SiteSearchPresenter;
+import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLink;
+import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPanel;
+import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignInLinkPresenter;
+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.skel.ActionCntCtxToolbarPanel;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+import org.ourproject.kune.workspace.client.socialnet.BuddiesSummary;
+import org.ourproject.kune.workspace.client.socialnet.BuddiesSummaryPanel;
+import org.ourproject.kune.workspace.client.socialnet.BuddiesSummaryPresenter;
+import org.ourproject.kune.workspace.client.socialnet.GroupActionRegistry;
+import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummary;
+import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryPanel;
+import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryPresenter;
+import org.ourproject.kune.workspace.client.socialnet.GroupMembersSummaryView;
+import org.ourproject.kune.workspace.client.socialnet.ParticipationSummary;
+import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPanel;
+import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryPresenter;
+import org.ourproject.kune.workspace.client.socialnet.ParticipationSummaryView;
+import org.ourproject.kune.workspace.client.socialnet.UserActionRegistry;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddie;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePanel;
+import org.ourproject.kune.workspace.client.socialnet.other.AddAsBuddiePresenter;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionBuddiesSummaryToolbar;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionBuddiesSummaryToolbarPresenter;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionGroupSummaryToolbar;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionGroupSummaryToolbarPresenter;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionParticipationSummaryToolbarPresenter;
+import org.ourproject.kune.workspace.client.socialnet.toolbar.ActionParticipationToolbar;
+import org.ourproject.kune.workspace.client.tags.TagsSummary;
+import org.ourproject.kune.workspace.client.tags.TagsSummaryPanel;
+import org.ourproject.kune.workspace.client.tags.TagsSummaryPresenter;
+import org.ourproject.kune.workspace.client.themes.WsThemePanel;
+import org.ourproject.kune.workspace.client.themes.WsThemePresenter;
+import org.ourproject.kune.workspace.client.title.EntitySubTitle;
+import org.ourproject.kune.workspace.client.title.EntitySubTitlePanel;
+import org.ourproject.kune.workspace.client.title.EntitySubTitlePresenter;
+import org.ourproject.kune.workspace.client.title.EntityTitle;
+import org.ourproject.kune.workspace.client.title.EntityTitlePanel;
+import org.ourproject.kune.workspace.client.title.EntityTitlePresenter;
+import org.ourproject.kune.workspace.client.title.RenameAction;
+import org.ourproject.kune.workspace.client.tool.ToolSelector;
+import org.ourproject.kune.workspace.client.tool.ToolSelectorPresenter;
+import org.ourproject.kune.workspace.client.upload.FileUploader;
+import org.ourproject.kune.workspace.client.upload.FileUploaderDialog;
+import org.ourproject.kune.workspace.client.upload.FileUploaderPresenter;
+
+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 {
+ @Override
+ protected void onInstall() {
+
+ register(Singleton.class, new Factory<SocialNetworkServiceAsync>(SocialNetworkServiceAsync.class) {
+ @Override
+ public SocialNetworkServiceAsync create() {
+ final SocialNetworkServiceAsync snServiceAsync = (SocialNetworkServiceAsync) GWT.create(SocialNetworkService.class);
+ ((ServiceDefTarget) snServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL()
+ + "SocialNetworkService");
+ return snServiceAsync;
+ }
+ }, new Factory<GroupServiceAsync>(GroupServiceAsync.class) {
+ @Override
+ public GroupServiceAsync create() {
+ final GroupServiceAsync groupServiceAsync = (GroupServiceAsync) GWT.create(GroupService.class);
+ ((ServiceDefTarget) groupServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL() + "GroupService");
+ return groupServiceAsync;
+ }
+ }, new Factory<ContentServiceAsync>(ContentServiceAsync.class) {
+ @Override
+ public ContentServiceAsync create() {
+ final ContentServiceAsync contentServiceAsync = (ContentServiceAsync) GWT.create(ContentService.class);
+ ((ServiceDefTarget) contentServiceAsync).setServiceEntryPoint(GWT.getModuleBaseURL() + "ContentService");
+ return contentServiceAsync;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<WorkspaceSkeleton>(WorkspaceSkeleton.class) {
+ @Override
+ public WorkspaceSkeleton create() {
+ return new WorkspaceSkeleton();
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<SiteProgress>(SiteProgress.class) {
+ @Override
+ public SiteProgress create() {
+ final SiteProgressPresenter presenter = new SiteProgressPresenter();
+ final SiteProgressPanel panel = new SiteProgressPanel(presenter, $$(SitePublicSpaceLink.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<SitePublicSpaceLink>(SitePublicSpaceLink.class) {
+ @Override
+ public SitePublicSpaceLink create() {
+ final SitePublicSpaceLinkPresenter presenter = new SitePublicSpaceLinkPresenter($(StateManager.class));
+ final SitePublicSpaceLinkPanel panel = new SitePublicSpaceLinkPanel(presenter,
+ $(WorkspaceSkeleton.class), $(I18nUITranslationService.class), $(Images.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(NoDecoration.class, new Factory<ToastMessage>(ToastMessage.class) {
+ @Override
+ public ToastMessage create() {
+ final ToastMessagePresenter presenter = new ToastMessagePresenter();
+ final ToastMessagePanel panel = new ToastMessagePanel();
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<SiteSignOutLink>(SiteSignOutLink.class) {
+ @Override
+ public SiteSignOutLink create() {
+ final SiteSignOutLinkPresenter presenter = new SiteSignOutLinkPresenter($(Session.class),
+ $$(UserServiceAsync.class), $$(ErrorHandler.class));
+ final SiteSignOutLinkPanel panel = new SiteSignOutLinkPanel(presenter,
+ $(I18nUITranslationService.class), $(WorkspaceSkeleton.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<SiteNewGroupLink>(SiteNewGroupLink.class) {
+ @Override
+ public SiteNewGroupLink create() {
+ final SiteNewGroupLinkPresenter presenter = new SiteNewGroupLinkPresenter();
+ final SiteNewGroupLinkPanel panel = new SiteNewGroupLinkPanel(presenter, $(WorkspaceSkeleton.class),
+ $(I18nUITranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<SiteOptions>(SiteOptions.class) {
+ @Override
+ public SiteOptions create() {
+ final SiteOptionsPresenter presenter = new SiteOptionsPresenter();
+ final SiteOptionsPanel panel = new SiteOptionsPanel(presenter, $(WorkspaceSkeleton.class),
+ $(I18nUITranslationService.class), $$(I18nTranslator.class), $$(TestRTEDialog.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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);
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<EntitySubTitle>(EntitySubTitle.class) {
+ @Override
+ public EntitySubTitle create() {
+ final EntitySubTitlePresenter presenter = new EntitySubTitlePresenter(
+ $(I18nUITranslationService.class), $(StateManager.class), false, $(AuthorableRegistry.class));
+ final EntitySubTitlePanel panel = new EntitySubTitlePanel(presenter, $(WorkspaceSkeleton.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<ActionManager>(ActionManager.class) {
+ @Override
+ public ActionManager create() {
+ return new ActionManager();
+ }
+ });
+
+ register(Singleton.class, new Factory<ActionGroupSummaryToolbar>(ActionGroupSummaryToolbar.class) {
+ @Override
+ public ActionGroupSummaryToolbar create() {
+ final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
+ final ActionGroupSummaryToolbarPresenter toolbar = new ActionGroupSummaryToolbarPresenter(panel);
+ return toolbar;
+ }
+ }, new Factory<ActionParticipationToolbar>(ActionParticipationToolbar.class) {
+ @Override
+ public ActionParticipationToolbar create() {
+ final ActionToolbarPanel<StateToken> panel = new ActionToolbarPanel<StateToken>($$(ActionManager.class));
+ final ActionParticipationSummaryToolbarPresenter toolbar = new ActionParticipationSummaryToolbarPresenter(
+ panel);
+ return toolbar;
+ }
+ }, new Factory<ActionBuddiesSummaryToolbar>(ActionBuddiesSummaryToolbar.class) {
+ @Override
+ public ActionBuddiesSummaryToolbar create() {
+ final ActionToolbarPanel<UserSimpleDTO> panel = new ActionToolbarPanel<UserSimpleDTO>(
+ $$(ActionManager.class));
+ final ActionBuddiesSummaryToolbarPresenter toolbar = new ActionBuddiesSummaryToolbarPresenter(panel);
+ return toolbar;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<GroupMembersSummary>(GroupMembersSummary.class) {
+ @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));
+ final GroupMembersSummaryView view = new GroupMembersSummaryPanel(presenter,
+ $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $(
+ ActionGroupSummaryToolbar.class).getView());
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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());
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<ParticipationSummary>(ParticipationSummary.class) {
+ @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));
+ final ParticipationSummaryView view = new ParticipationSummaryPanel(presenter,
+ $(I18nUITranslationService.class), $(WorkspaceSkeleton.class),
+ ($(ActionParticipationToolbar.class).getView()));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(EntityOptionsGroup.class, new Factory<EntityOptionsToolsConf>(EntityOptionsToolsConf.class) {
+ @Override
+ public EntityOptionsToolsConf create() {
+ final EntityOptionsToolsConfPresenter presenter = new EntityOptionsToolsConfPresenter(
+ $(StateManager.class), $(Session.class), $(I18nTranslationService.class),
+ $(EntityOptions.class), $$(GroupServiceAsync.class));
+ final EntityOptionsToolsConfPanel panel = new EntityOptionsToolsConfPanel(presenter,
+ $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(EntityOptionsGroup.class, new Factory<EntityOptionsDefLicense>(EntityOptionsDefLicense.class) {
+ @Override
+ public EntityOptionsDefLicense create() {
+ final EntityOptionsDefLicensePresenter presenter = new EntityOptionsDefLicensePresenter(
+ $(EntityOptions.class), $(StateManager.class), $(Session.class), $$(LicenseWizard.class),
+ $$(LicenseChangeAction.class));
+ final EntityOptionsDefLicensePanel panel = new EntityOptionsDefLicensePanel(presenter,
+ $(WorkspaceSkeleton.class), $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(EntityOptionsGroup.class,
+ new Factory<EntityOptionsPublicSpaceConf>(EntityOptionsPublicSpaceConf.class) {
+ @Override
+ public EntityOptionsPublicSpaceConf create() {
+ final EntityOptionsPublicSpaceConfPresenter presenter = new EntityOptionsPublicSpaceConfPresenter(
+ $(EntityOptions.class));
+ final EntityOptionsPublicSpaceConfPanel panel = new EntityOptionsPublicSpaceConfPanel(
+ presenter, $(WorkspaceSkeleton.class), $(I18nTranslationService.class),
+ $(WsThemePresenter.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseChangeAction>(LicenseChangeAction.class) {
+ @Override
+ public LicenseChangeAction create() {
+ return new LicenseChangeAction($$(GroupServiceAsync.class), $(Session.class),
+ $(I18nTranslationService.class), $(StateManager.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<RenameAction>(RenameAction.class) {
+ @Override
+ public RenameAction create() {
+ return new RenameAction($(I18nTranslationService.class), $(Session.class),
+ $$(ContentServiceAsync.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseWizard>(LicenseWizard.class) {
+ @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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseWizardFirstFormView>(LicenseWizardFirstFormView.class) {
+ @Override
+ public LicenseWizardFirstFormView create() {
+ return new LicenseWizardFirstForm($(I18nTranslationService.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseWizardSndFormView>(LicenseWizardSndFormView.class) {
+ @Override
+ public LicenseWizardSndFormView create() {
+ return new LicenseWizardSndForm($(I18nTranslationService.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseWizardTrdFormView>(LicenseWizardTrdFormView.class) {
+ @Override
+ public LicenseWizardTrdFormView create() {
+ return new LicenseWizardTrdForm($(Images.class), $(I18nTranslationService.class));
+ }
+ });
+
+ register(Singleton.class, new Factory<LicenseWizardFrdFormView>(LicenseWizardFrdFormView.class) {
+ @Override
+ public LicenseWizardFrdFormView create() {
+ return new LicenseWizardFrdForm($(I18nTranslationService.class), $(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));
+ presenter.init(panel);
+ return presenter;
+ }
+
+ @Override
+ public void onAfterCreated(FileUploader uploader) {
+ $(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));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<UserLiveSearcher>(UserLiveSearcher.class) {
+ @Override
+ public UserLiveSearcher create() {
+ final UserLiveSearcherPresenter presenter = new UserLiveSearcherPresenter();
+ final EntityLiveSearcherView view = new UserLiveSearcherPanel(presenter,
+ $(I18nTranslationService.class), $(FileDownloadUtils.class));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<GroupLiveSearcher>(GroupLiveSearcher.class) {
+ @Override
+ public GroupLiveSearcher create() {
+ final GroupLiveSearcherPresenter presenter = new GroupLiveSearcherPresenter();
+ final EntityLiveSearcherView view = new GroupLiveSearchPanel(presenter,
+ $(I18nTranslationService.class), $(FileDownloadUtils.class));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ register(Singleton.class, new Factory<ToolSelector>(ToolSelector.class) {
+ @Override
+ public ToolSelector create() {
+ final ToolSelectorPresenter presenter = new ToolSelectorPresenter($(StateManager.class),
+ $(WsThemePresenter.class));
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ // Register of tokens like "signin", "newgroup", "translate" etcetera
+ $(StateManager.class).addSiteToken(SiteToken.signin.toString(), new Listener0() {
+ public void onEvent() {
+ $(SignIn.class).doSignIn();
+ }
+ });
+
+ $(StateManager.class).addSiteToken(SiteToken.register.toString(), new Listener0() {
+ public void onEvent() {
+ $(Register.class).doRegister();
+ }
+ });
+
+ $(StateManager.class).addSiteToken(SiteToken.newgroup.toString(), new Listener0() {
+ public void onEvent() {
+ $(NewGroup.class).doNewGroup();
+ }
+ });
+
+ $(StateManager.class).addSiteToken(SiteToken.translate.toString(), new Listener0() {
+ public void onEvent() {
+ $(I18nTranslator.class).doShowTranslator();
+ }
+ });
+
+ register(NoDecoration.class, new Factory<ActionContentToolbar>(ActionContentToolbar.class) {
+ @Override
+ public ActionContentToolbar create() {
+ final ActionCntCtxToolbarPanel<StateToken> tbar = new ActionCntCtxToolbarPanel<StateToken>(
+ AbstractFoldableContentActions.CONTENT_TOPBAR, $$(ActionManager.class),
+ $(WorkspaceSkeleton.class));
+ final ActionContentToolbar toolbar = new ActionContentToolbarPresenter(tbar);
+ return toolbar;
+ }
+ });
+
+ register(Singleton.class, new Factory<ContentEditor>(ContentEditor.class) {
+ @Override
+ public ContentEditor create() {
+ return new ContentEditor($(RTEditor.class), true, $(I18nTranslationService.class),
+ $(StateManager.class), $(SiteSignOutLink.class), $(DeferredCommandWrapper.class),
+ $(RTEImgResources.class), $(WorkspaceSkeleton.class), $(TimerWrapper.class),
+ new RTESavingEditorPanel());
+ }
+ });
+ register(NoDecoration.class, new Factory<ActionContextTopToolbar>(ActionContextTopToolbar.class) {
+ @Override
+ public ActionContextTopToolbar create() {
+ final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
+ AbstractFoldableContentActions.CONTEXT_TOPBAR, $$(ActionManager.class),
+ $(WorkspaceSkeleton.class));
+ final ActionContextTopToolbar toolbar = new ActionContextTopToolbar(panel);
+ return toolbar;
+ }
+ });
+
+ register(NoDecoration.class, new Factory<ActionContextBottomToolbar>(ActionContextBottomToolbar.class) {
+ @Override
+ public ActionContextBottomToolbar create() {
+ final ActionCntCtxToolbarPanel<StateToken> panel = new ActionCntCtxToolbarPanel<StateToken>(
+ AbstractFoldableContentActions.CONTEXT_BOTTOMBAR, $$(ActionManager.class),
+ $(WorkspaceSkeleton.class));
+ final ActionContextBottomToolbar toolbar = new ActionContextBottomToolbar(panel);
+ return toolbar;
+ }
+ });
+
+ register(Singleton.class, new Factory<ContextNavigator>(ContextNavigator.class) {
+ @Override
+ public ContextNavigator create() {
+ final ContextNavigatorPresenter presenter = new ContextNavigatorPresenter($(StateManager.class),
+ $(Session.class), $(I18nTranslationService.class), $(ContentIconsRegistry.class),
+ $(ContentCapabilitiesRegistry.class), $(ActionContextTopToolbar.class),
+ $(ActionContextBottomToolbar.class), $(ContextActionRegistry.class),
+ $$(FileDownloadUtils.class), true, $(RenameAction.class));
+ final ContextNavigatorPanel panel = new ContextNavigatorPanel(presenter,
+ $(I18nTranslationService.class), $(WorkspaceSkeleton.class), $(ActionManager.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ 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 ContextPropEditorView view = new ContextPropEditorPanel(presenter,
+ $(I18nUITranslationService.class), $(WorkspaceSkeleton.class), $$(LanguageSelector.class),
+ $(Images.class));
+ presenter.init(view);
+ return presenter;
+ }
+ });
+
+ register(InsertImageGroup.class, new Factory<InsertImageLocal>(InsertImageLocal.class) {
+ @Override
+ public InsertImageLocal create() {
+ final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter($(InsertImageDialog.class));
+ final InsertImageLocalPanel panel = new InsertImageLocalPanel(presenter,
+ $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ register(ApplicationComponentGroup.class, new Factory<MaxMinWorkspace>(MaxMinWorkspace.class) {
+ @Override
+ public MaxMinWorkspace create() {
+ final MaxMinWorkspacePresenter presenter = new MaxMinWorkspacePresenter();
+ final MaxMinWorkspacePanel panel = new MaxMinWorkspacePanel(presenter, $(WorkspaceSkeleton.class),
+ $(Images.class), $(EntityHeader.class), $(I18nTranslationService.class));
+ presenter.init(panel);
+ return presenter;
+ }
+ });
+
+ }
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/EntityHeaderButton.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -8,9 +8,17 @@
public class EntityHeaderButton extends IconLabel implements View {
public EntityHeaderButton(AbstractImagePrototype icon, String text) {
super(icon, text, false);
+ setDefStyle();
}
public EntityHeaderButton(String text, AbstractImagePrototype icon) {
super(text, icon, false);
+ setDefStyle();
}
+
+ private void setDefStyle() {
+ addStyleName("kune-Margin-Medium-t");
+ addStyleName("kune-pointer");
+ }
+
}
\ No newline at end of file
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspace.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspace.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspace.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.workspace.client.entityheader.maxmin;
+
+public interface MaxMinWorkspace {
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePanel.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePanel.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,53 @@
+package org.ourproject.kune.workspace.client.entityheader.maxmin;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
+import org.ourproject.kune.workspace.client.entityheader.EntityHeaderButton;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.Widget;
+
+public class MaxMinWorkspacePanel implements MaxMinWorkspaceView {
+
+ public static final String MIN_ICON = "mmwp-min_bt";
+ public static final String MAX_ICON = "mmwp-max_bt";
+ private final WorkspaceSkeleton ws;
+ private final EntityHeaderButton maxBtn;
+ private final EntityHeaderButton minBtn;
+
+ public MaxMinWorkspacePanel(final MaxMinWorkspacePresenter presenter, WorkspaceSkeleton ws, Images images,
+ final EntityHeader entityHeader, I18nTranslationService i18n) {
+ this.ws = ws;
+ maxBtn = new EntityHeaderButton("", images.arrowOut());
+ minBtn = new EntityHeaderButton("", images.arrowIn());
+ maxBtn.setTitle(i18n.t("Maximize the workspace"));
+ minBtn.setTitle(i18n.t("Minimize the workspace"));
+ maxBtn.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ presenter.onMaximize();
+ }
+ });
+ minBtn.addClickListener(new ClickListener() {
+ public void onClick(Widget arg0) {
+ presenter.onMinimize();
+ }
+ });
+ minBtn.setVisible(false);
+ minBtn.ensureDebugId(MIN_ICON);
+ maxBtn.ensureDebugId(MAX_ICON);
+ entityHeader.addWidget(maxBtn);
+ entityHeader.addWidget(minBtn);
+ }
+
+ public void setMaximized(boolean maximized) {
+ ws.setMaximized(maximized);
+ }
+
+ public void showMaxButton(boolean showMax) {
+ maxBtn.setVisible(showMax);
+ minBtn.setVisible(!showMax);
+ }
+
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspacePresenter.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,32 @@
+package org.ourproject.kune.workspace.client.entityheader.maxmin;
+
+import org.ourproject.kune.platf.client.View;
+
+public class MaxMinWorkspacePresenter implements MaxMinWorkspace {
+
+ private MaxMinWorkspaceView view;
+
+ public MaxMinWorkspacePresenter() {
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(MaxMinWorkspaceView view) {
+ this.view = view;
+ }
+
+ public void onMaximize() {
+ showMaximized(true);
+ }
+
+ public void onMinimize() {
+ showMaximized(false);
+ }
+
+ private void showMaximized(boolean maximized) {
+ view.setMaximized(maximized);
+ view.showMaxButton(!maximized);
+ }
+}
Added: trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspaceView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspaceView.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/entityheader/maxmin/MaxMinWorkspaceView.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.workspace.client.entityheader.maxmin;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface MaxMinWorkspaceView extends View {
+
+ void setMaximized(boolean maximized);
+
+ void showMaxButton(boolean showMax);
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -82,9 +82,6 @@
}
});
optionsButton.ensureDebugId(GROUP_OPTIONS_ICON);
- optionsButton.addStyleName("kune-Margin-Medium-t");
- optionsButton.addStyleName("kune-pointer");
-
entityHeader.addWidget(optionsButton);
}
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignOutLinkPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignOutLinkPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/sitebar/sitesign/SiteSignOutLinkPresenter.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -28,7 +28,7 @@
import org.ourproject.kune.platf.client.errors.SessionExpiredException;
import org.ourproject.kune.platf.client.errors.UserMustBeLoggedException;
import org.ourproject.kune.platf.client.rpc.UserServiceAsync;
-import org.ourproject.kune.platf.client.services.KuneErrorHandler;
+import org.ourproject.kune.platf.client.services.ErrorHandler;
import org.ourproject.kune.platf.client.state.Session;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
@@ -47,7 +47,7 @@
private final BeforeActionCollection beforeSignOutCollection;
public SiteSignOutLinkPresenter(final Session session, final Provider<UserServiceAsync> userServiceProvider,
- final Provider<KuneErrorHandler> kuneErrorHandlerProvider) {
+ final Provider<ErrorHandler> kuneErrorHandlerProvider) {
this.session = session;
this.userServiceProvider = userServiceProvider;
session.onUserSignIn(new Listener<UserInfoDTO>() {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/Entity.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -111,6 +111,11 @@
entitySummary.doLayoutIfNeeded();
}
+ public void setMaximized(boolean maximized) {
+ entityWorkspace.setMaximized(maximized);
+ entitySummary.setMaximized(maximized);
+ }
+
public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
if (oldTheme != null) {
entityFitPanel.removeClass("k-entity-" + oldTheme);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntitySummary.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -156,4 +156,13 @@
return trayBar;
}
+ public void setMaximized(boolean maximized) {
+ entitySummary.setVisible(!maximized);
+ if (maximized) {
+ mainFitPanel.collapse();
+ } else {
+ mainFitPanel.expand();
+ }
+ }
+
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/EntityWorkspace.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -55,6 +55,7 @@
private final Panel cntCtxBorderLayout;
private final Panel mainFitPanel;
private final Panel bottomPanel;
+ private final Panel contextWrap;
public EntityWorkspace() {
mainFitPanel = new Panel();
@@ -97,7 +98,7 @@
bottomPanel.setHeight(WorkspaceSkeleton.DEF_TOOLBAR_HEIGHT);
final Panel contentWrap = new Panel();
- final Panel contextWrap = new Panel();
+ contextWrap = new Panel();
contentWrap.setLayout(new BorderLayout());
contextWrap.setLayout(new BorderLayout());
contentWrap.setBorder(true);
@@ -220,6 +221,14 @@
setPanel(context, widget);
}
+ public void setMaximized(boolean maximized) {
+ if (maximized) {
+ contextWrap.collapse();
+ } else {
+ contextWrap.expand();
+ }
+ }
+
public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
final String themeS = newTheme.toString();
if (oldTheme != null) {
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java 2009-03-11 14:24:39 UTC (rev 1072)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/skel/WorkspaceSkeleton.java 2009-03-12 08:05:10 UTC (rev 1073)
@@ -136,6 +136,10 @@
entity.refreshSummary();
}
+ public void setMaximized(boolean maximized) {
+ entity.setMaximized(maximized);
+ }
+
public void setTheme(final WsTheme oldTheme, final WsTheme newTheme) {
entity.setTheme(oldTheme, newTheme);
}
1
0
11 Mar '09
Author: vjrj
Date: 2009-03-11 15:24:39 +0100 (Wed, 11 Mar 2009)
New Revision: 1072
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/
trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsView.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialog.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -0,0 +1,35 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.dialogs.tabbed;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
+
+public interface AbstractTabbedDialog {
+
+ public void hideMessages();
+
+ public void setErrorMessage(String message, Level level);
+
+ void addOptionTab(View view);
+
+ void show();
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -0,0 +1,195 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.dialogs.tabbed;
+
+import java.util.ArrayList;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.platf.client.ui.dialogs.MessageToolbar;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.calclab.suco.client.events.Listener0;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.Component;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.TabPanel;
+import com.gwtext.client.widgets.event.WindowListenerAdapter;
+
+public abstract class AbstractTabbedDialogPanel {
+ private BasicDialog dialog;
+ private final String dialogId;
+ private TabPanel tabPanel;
+ private MessageToolbar messageErrorBar;
+ private String title;
+ private final int width;
+ private final int height;
+ private final int minWidth;
+ private final int minHeight;
+ private final boolean modal;
+ private final Images images;
+ private final String errorLabelId;
+ private String iconCls;
+ private Listener0 onHideListener;
+ private final ArrayList<Button> buttons;
+
+ public AbstractTabbedDialogPanel(String dialogId, String title, int width, int height, int minWidth, int minHeight,
+ boolean modal, Images images, String errorLabelId) {
+ this.dialogId = dialogId;
+ this.title = title;
+ this.width = width;
+ this.height = height;
+ this.minWidth = minWidth;
+ this.minHeight = minHeight;
+ this.modal = modal;
+ this.images = images;
+ this.errorLabelId = errorLabelId;
+ buttons = new ArrayList<Button>();
+ }
+
+ /**
+ * User before show/render
+ *
+ * @param button
+ */
+ public void addButton(Button button) {
+ buttons.add(button);
+ }
+
+ public void addHideListener(final Listener0 onHideListener) {
+ this.onHideListener = onHideListener;
+ if (dialog != null) {
+ addHideListener();
+ }
+ }
+
+ public void addOptionTab(View view) {
+ if (view instanceof Panel) {
+ addTab((Panel) view);
+ } else if (view instanceof DefaultForm) {
+ addTab(((DefaultForm) view).getFormPanel());
+ } else {
+ Log.error("Programatic error: Unexpected element added to GroupOptions");
+ }
+ doLayoutIfNeeded();
+ }
+
+ public void createAndShow() {
+ show();
+ setFirstTabActive();
+ }
+
+ public void doLayoutIfNeeded() {
+ if (dialog.isRendered()) {
+ dialog.doLayout(false);
+ }
+ }
+
+ public void hide() {
+ if (dialog != null) {
+ dialog.hide();
+ }
+ }
+
+ public void hideMessages() {
+ if (dialog != null) {
+ messageErrorBar.hideErrorMessage();
+ }
+ }
+
+ public boolean isVisible() {
+ createDialogIfNecessary();
+ return dialog.isVisible();
+ }
+
+ public void setErrorMessage(final String message, final Level level) {
+ messageErrorBar.setErrorMessage(message, level);
+ }
+
+ public void setFirstTabActive() {
+ tabPanel.setActiveTab(0);
+ }
+
+ public void setIconCls(String iconCls) {
+ this.iconCls = iconCls;
+ if (dialog != null) {
+ dialog.setIconCls(iconCls);
+ }
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ if (dialog != null) {
+ dialog.setTitle(title);
+ }
+ }
+
+ public void show() {
+ createDialogIfNecessary();
+ dialog.show();
+ }
+
+ private void addHideListener() {
+ dialog.addListener(new WindowListenerAdapter() {
+ @Override
+ public void onClose(Panel panel) {
+ onHideListener.onEvent();
+ }
+
+ @Override
+ public void onHide(Component component) {
+ onHideListener.onEvent();
+ }
+ });
+ }
+
+ private void addTab(Panel newTab) {
+ createDialogIfNecessary();
+ tabPanel.add(newTab);
+ }
+
+ private void createDialog() {
+ dialog = new BasicDialog(dialogId, title, modal, true, width, height, minWidth, minHeight);
+ dialog.setCollapsible(false);
+ messageErrorBar = new MessageToolbar(images, errorLabelId);
+ dialog.setBottomToolbar(messageErrorBar.getToolbar());
+ tabPanel = new TabPanel();
+ tabPanel.setBorder(false);
+ dialog.add(tabPanel);
+ if (iconCls != null) {
+ dialog.setIconCls(iconCls);
+ }
+ if (onHideListener != null) {
+ addHideListener();
+ }
+ for (Button button : buttons) {
+ dialog.addButton(button);
+ }
+ }
+
+ private void createDialogIfNecessary() {
+ if (dialog == null) {
+ createDialog();
+ }
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -0,0 +1,57 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.dialogs.tabbed;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
+
+public abstract class AbstractTabbedDialogPresenter {
+
+ private AbstractTabbedDialogView view;
+
+ public void addOptionTab(View tab) {
+ view.addOptionTab(tab);
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void hide() {
+ view.hide();
+ }
+
+ public void hideMessages() {
+ view.hideMessages();
+ }
+
+ public void init(AbstractTabbedDialogView view) {
+ this.view = view;
+ }
+
+ public void setErrorMessage(String message, Level level) {
+ view.setErrorMessage(message, level);
+ }
+
+ public void show() {
+ view.createAndShow();
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/dialogs/tabbed/AbstractTabbedDialogView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -0,0 +1,37 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.dialogs.tabbed;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
+
+public interface AbstractTabbedDialogView extends View {
+
+ void addOptionTab(View tab);
+
+ void createAndShow();
+
+ void hide();
+
+ void hideMessages();
+
+ void setErrorMessage(final String message, final Level level);
+
+}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,11 +1,11 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml;
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialog;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
-public interface EditHtmlDialog extends AbstractOptions {
+public interface EditHtmlDialog extends AbstractTabbedDialog {
String getHtml();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -2,16 +2,16 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
import com.google.gwt.user.client.Window;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-public class EditHtmlDialogPanel extends AbstractOptionsPanel implements EditHtmlDialogView {
+public class EditHtmlDialogPanel extends AbstractTabbedDialogPanel implements EditHtmlDialogView {
public static final String EDIT_HTML_DIALOG = "ehtml-dialog";
public static final String EDIG_HTML_DIALOG_ERROR_ID = "ehtml-dialgo-error";
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,11 +1,11 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
import com.calclab.suco.client.events.Listener;
import com.calclab.suco.client.events.Listener0;
-public class EditHtmlDialogPresenter extends AbstractOptionsPresenter implements EditHtmlDialog {
+public class EditHtmlDialogPresenter extends AbstractTabbedDialogPresenter implements EditHtmlDialog {
private Listener<String> updateListener;
private Listener0 cancelListener;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,8 +1,8 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogView;
-public interface EditHtmlDialogView extends AbstractOptionsView, View {
+public interface EditHtmlDialogView extends AbstractTabbedDialogView, View {
int HEIGHT = 225;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,7 +1,7 @@
package org.ourproject.kune.platf.client.ui.rte.insertimg;
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialog;
-public interface InsertImageDialog extends AbstractOptions {
+public interface InsertImageDialog extends AbstractTabbedDialog {
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -2,9 +2,9 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel;
-public class InsertImageDialogPanel extends AbstractOptionsPanel implements InsertImageDialogView {
+public class InsertImageDialogPanel extends AbstractTabbedDialogPanel implements InsertImageDialogView {
private static final String INSERT_IMG_DIALOG = "iip-dial";
private static final String INSERT_IMG_DIALOG_ERROR_ID = "iip-err";
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,8 +1,8 @@
package org.ourproject.kune.platf.client.ui.rte.insertimg;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
-public class InsertImageDialogPresenter extends AbstractOptionsPresenter implements InsertImageDialog {
+public class InsertImageDialogPresenter extends AbstractTabbedDialogPresenter implements InsertImageDialog {
public InsertImageDialogPresenter() {
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,8 +1,8 @@
package org.ourproject.kune.platf.client.ui.rte.insertimg;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogView;
-public interface InsertImageDialogView extends AbstractOptionsView, View {
+public interface InsertImageDialogView extends AbstractTabbedDialogView, View {
int HEIGHT = 225;
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -19,11 +19,11 @@
*/
package org.ourproject.kune.platf.client.ui.rte.insertlink;
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialog;
import com.calclab.suco.client.events.Listener2;
-public interface InsertLinkDialog extends AbstractOptions {
+public interface InsertLinkDialog extends AbstractTabbedDialog {
@Deprecated
void addOnCreateLink(Listener2<String, String> slot);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -21,11 +21,11 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel;
import com.calclab.suco.client.events.Listener0;
-public class InsertLinkDialogPanel extends AbstractOptionsPanel implements InsertLinkDialogView {
+public class InsertLinkDialogPanel extends AbstractTabbedDialogPanel implements InsertLinkDialogView {
public static final String TEXT_EDT_INSERT_DIALOG = "k-ted-iep-dialog";
public static final String TEXT_EDT_INSERT_DIALOG_ERROR_ID = "k-ted-iep-dialog-err";
private final InsertLinkGroup textEditorInsertElementGroup;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -19,12 +19,12 @@
*/
package org.ourproject.kune.platf.client.ui.rte.insertlink;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
import com.calclab.suco.client.events.Event2;
import com.calclab.suco.client.events.Listener2;
-public class InsertLinkDialogPresenter extends AbstractOptionsPresenter implements InsertLinkDialog {
+public class InsertLinkDialogPresenter extends AbstractTabbedDialogPresenter implements InsertLinkDialog {
private final Event2<String, String> onCreateLink;
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -20,8 +20,8 @@
package org.ourproject.kune.platf.client.ui.rte.insertlink;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogView;
-public interface InsertLinkDialogView extends AbstractOptionsView, View {
+public interface InsertLinkDialogView extends AbstractTabbedDialogView, View {
int HEIGHT = 225;
}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptions.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,35 +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.options;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-
-public interface AbstractOptions {
-
- public void hideMessages();
-
- public void setErrorMessage(String message, Level level);
-
- void addOptionTab(View view);
-
- void show();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,195 +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.options;
-
-import java.util.ArrayList;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.platf.client.ui.dialogs.BasicDialog;
-import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.dialogs.MessageToolbar;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-
-import com.allen_sauer.gwt.log.client.Log;
-import com.calclab.suco.client.events.Listener0;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.Component;
-import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.TabPanel;
-import com.gwtext.client.widgets.event.WindowListenerAdapter;
-
-public abstract class AbstractOptionsPanel {
- private BasicDialog dialog;
- private final String dialogId;
- private TabPanel tabPanel;
- private MessageToolbar messageErrorBar;
- private String title;
- private final int width;
- private final int height;
- private final int minWidth;
- private final int minHeight;
- private final boolean modal;
- private final Images images;
- private final String errorLabelId;
- private String iconCls;
- private Listener0 onHideListener;
- private final ArrayList<Button> buttons;
-
- public AbstractOptionsPanel(String dialogId, String title, int width, int height, int minWidth, int minHeight,
- boolean modal, Images images, String errorLabelId) {
- this.dialogId = dialogId;
- this.title = title;
- this.width = width;
- this.height = height;
- this.minWidth = minWidth;
- this.minHeight = minHeight;
- this.modal = modal;
- this.images = images;
- this.errorLabelId = errorLabelId;
- buttons = new ArrayList<Button>();
- }
-
- /**
- * User before show/render
- *
- * @param button
- */
- public void addButton(Button button) {
- buttons.add(button);
- }
-
- public void addHideListener(final Listener0 onHideListener) {
- this.onHideListener = onHideListener;
- if (dialog != null) {
- addHideListener();
- }
- }
-
- public void addOptionTab(View view) {
- if (view instanceof Panel) {
- addTab((Panel) view);
- } else if (view instanceof DefaultForm) {
- addTab(((DefaultForm) view).getFormPanel());
- } else {
- Log.error("Programatic error: Unexpected element added to GroupOptions");
- }
- doLayoutIfNeeded();
- }
-
- public void createAndShow() {
- show();
- setFirstTabActive();
- }
-
- public void doLayoutIfNeeded() {
- if (dialog.isRendered()) {
- dialog.doLayout(false);
- }
- }
-
- public void hide() {
- if (dialog != null) {
- dialog.hide();
- }
- }
-
- public void hideMessages() {
- if (dialog != null) {
- messageErrorBar.hideErrorMessage();
- }
- }
-
- public boolean isVisible() {
- createDialogIfNecessary();
- return dialog.isVisible();
- }
-
- public void setErrorMessage(final String message, final Level level) {
- messageErrorBar.setErrorMessage(message, level);
- }
-
- public void setFirstTabActive() {
- tabPanel.setActiveTab(0);
- }
-
- public void setIconCls(String iconCls) {
- this.iconCls = iconCls;
- if (dialog != null) {
- dialog.setIconCls(iconCls);
- }
- }
-
- public void setTitle(String title) {
- this.title = title;
- if (dialog != null) {
- dialog.setTitle(title);
- }
- }
-
- public void show() {
- createDialogIfNecessary();
- dialog.show();
- }
-
- private void addHideListener() {
- dialog.addListener(new WindowListenerAdapter() {
- @Override
- public void onClose(Panel panel) {
- onHideListener.onEvent();
- }
-
- @Override
- public void onHide(Component component) {
- onHideListener.onEvent();
- }
- });
- }
-
- private void addTab(Panel newTab) {
- createDialogIfNecessary();
- tabPanel.add(newTab);
- }
-
- private void createDialog() {
- dialog = new BasicDialog(dialogId, title, modal, true, width, height, minWidth, minHeight);
- dialog.setCollapsible(false);
- messageErrorBar = new MessageToolbar(images, errorLabelId);
- dialog.setBottomToolbar(messageErrorBar.getToolbar());
- tabPanel = new TabPanel();
- tabPanel.setBorder(false);
- dialog.add(tabPanel);
- if (iconCls != null) {
- dialog.setIconCls(iconCls);
- }
- if (onHideListener != null) {
- addHideListener();
- }
- for (Button button : buttons) {
- dialog.addButton(button);
- }
- }
-
- private void createDialogIfNecessary() {
- if (dialog == null) {
- createDialog();
- }
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,57 +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.options;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-
-public abstract class AbstractOptionsPresenter {
-
- private AbstractOptionsView view;
-
- public void addOptionTab(View tab) {
- view.addOptionTab(tab);
- }
-
- public View getView() {
- return view;
- }
-
- public void hide() {
- view.hide();
- }
-
- public void hideMessages() {
- view.hideMessages();
- }
-
- public void init(AbstractOptionsView view) {
- this.view = view;
- }
-
- public void setErrorMessage(String message, Level level) {
- view.setErrorMessage(message, level);
- }
-
- public void show() {
- view.createAndShow();
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/AbstractOptionsView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -1,37 +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.options;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-
-public interface AbstractOptionsView extends View {
-
- void addOptionTab(View tab);
-
- void createAndShow();
-
- void hide();
-
- void hideMessages();
-
- void setErrorMessage(final String message, final Level level);
-
-}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptions.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -20,9 +20,10 @@
package org.ourproject.kune.workspace.client.options;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialog;
import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-public interface EntityOptions extends AbstractOptions {
+public interface EntityOptions extends AbstractTabbedDialog {
public void addOptionTab(View tab);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPanel.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -23,13 +23,14 @@
import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPanel;
import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
import org.ourproject.kune.workspace.client.entityheader.EntityHeaderButton;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;
-public class EntityOptionsPanel extends AbstractOptionsPanel implements EntityOptionsView {
+public class EntityOptionsPanel extends AbstractTabbedDialogPanel implements EntityOptionsView {
public static final String ENTITY_OP_PANEL_ID = "k-eop-diag";
public static final String GROUP_OPTIONS_ERROR_ID = "k-eop-err-mess";
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-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsPresenter.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -21,10 +21,11 @@
import org.ourproject.kune.platf.client.dto.StateAbstractDTO;
import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
import com.calclab.suco.client.events.Listener;
-public class EntityOptionsPresenter extends AbstractOptionsPresenter implements EntityOptions {
+public class EntityOptionsPresenter extends AbstractTabbedDialogPresenter implements EntityOptions {
EntityOptionsView view;
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsView.java 2009-03-11 14:08:13 UTC (rev 1071)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/options/EntityOptionsView.java 2009-03-11 14:24:39 UTC (rev 1072)
@@ -20,8 +20,9 @@
package org.ourproject.kune.workspace.client.options;
import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.dialogs.tabbed.AbstractTabbedDialogView;
-public interface EntityOptionsView extends View, AbstractOptionsView {
+public interface EntityOptionsView extends View, AbstractTabbedDialogView {
int HEIGHT = 270;
1
0
Author: vjrj
Date: 2009-03-11 15:08:13 +0100 (Wed, 11 Mar 2009)
New Revision: 1071
Added:
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/edithtml/EditHtmlAgent.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkGroup.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmail.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocal.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalView.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/RTEActionSndToolbarPresenter.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/RTEActionTopToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.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/edithtml/editor/EditHtmlEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KuneCoreModule.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -23,7 +23,7 @@
import org.ourproject.kune.platf.client.app.EntityOptionsGroup;
import org.ourproject.kune.platf.client.app.ToolGroup;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
import com.calclab.suco.client.ioc.module.AbstractModule;
@@ -35,6 +35,6 @@
registerDecorator(ToolGroup.class, new ToolGroup(container));
registerDecorator(EntityOptionsGroup.class, new EntityOptionsGroup(container));
registerDecorator(InsertImageGroup.class, new InsertImageGroup(container));
- registerDecorator(TextEditorInsertElementGroup.class, new TextEditorInsertElementGroup(container));
+ registerDecorator(InsertLinkGroup.class, new InsertLinkGroup(container));
}
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -50,16 +50,14 @@
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
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.RTEActionSndToolbarPresenter;
import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbar;
-import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbarPresenter;
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.EditHtml;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlGroup;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlPanel;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlPresenter;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogPresenter;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditor;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlEditorPresenter;
@@ -67,24 +65,24 @@
import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPanel;
import org.ourproject.kune.platf.client.ui.rte.edithtml.preview.EditHtmlPreviewPresenter;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePanel;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.TextEditorInsertLinkEmail;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.TextEditorInsertLinkEmailPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.email.TextEditorInsertLinkEmailPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExt;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtView;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmail;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.email.InsertLinkEmailPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExt;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.InsertLinkExtView;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPresenter;
@@ -256,14 +254,14 @@
@Override
public RTEActionTopToolbar create() {
final ActionToolbarPanel<Object> panel = new ActionToolbarPanel<Object>($$(ActionManager.class));
- final RTEActionTopToolbarPresenter toolbar = new RTEActionTopToolbarPresenter(panel);
+ 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 RTEActionSndToolbarPresenter toolbar = new RTEActionSndToolbarPresenter(panel);
+ final RTEActionSndToolbar toolbar = new RTEActionSndToolbar(panel);
return toolbar;
}
});
@@ -281,8 +279,8 @@
RTEActionTopToolbar topBar = $(RTEActionTopToolbar.class);
RTEActionSndToolbar sndBar = $(RTEActionSndToolbar.class);
final RTEditorPresenter presenter = new RTEditorPresenter($(I18nTranslationService.class),
- $(Session.class), topBar, sndBar, $(RTEImgResources.class), $(TextEditorInsertElement.class),
- $(ColorWebSafePalette.class), $$(EditHtml.class), $$(InsertImage.class),
+ $(Session.class), topBar, sndBar, $(RTEImgResources.class), $(InsertLinkDialog.class),
+ $(ColorWebSafePalette.class), $$(EditHtmlDialog.class), $$(InsertImageDialog.class),
$(DeferredCommandWrapper.class));
final RTEditorPanel panel = new RTEditorPanel(presenter, $(I18nUITranslationService.class),
$(ActionManager.class));
@@ -326,11 +324,11 @@
registerDecorator(EditHtmlGroup.class, new EditHtmlGroup(container));
- register(Singleton.class, new Factory<EditHtml>(EditHtml.class) {
+ register(Singleton.class, new Factory<EditHtmlDialog>(EditHtmlDialog.class) {
@Override
- public EditHtml create() {
- final EditHtmlPresenter presenter = new EditHtmlPresenter();
- final EditHtmlPanel panel = new EditHtmlPanel(presenter, $(I18nTranslationService.class),
+ public EditHtmlDialog create() {
+ final EditHtmlDialogPresenter presenter = new EditHtmlDialogPresenter();
+ final EditHtmlDialogPanel panel = new EditHtmlDialogPanel(presenter, $(I18nTranslationService.class),
$(RTEImgResources.class), $(Images.class), $(EditHtmlGroup.class));
presenter.init(panel);
return presenter;
@@ -340,7 +338,7 @@
register(EditHtmlGroup.class, new Factory<EditHtmlEditor>(EditHtmlEditor.class) {
@Override
public EditHtmlEditor create() {
- final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter($(EditHtml.class));
+ final EditHtmlEditorPresenter presenter = new EditHtmlEditorPresenter($(EditHtmlDialog.class));
final EditHtmlEditorPanel panel = new EditHtmlEditorPanel(i18n, presenter);
presenter.init(panel);
return presenter;
@@ -348,18 +346,18 @@
}, new Factory<EditHtmlPreview>(EditHtmlPreview.class) {
@Override
public EditHtmlPreview create() {
- final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter($(EditHtml.class));
+ final EditHtmlPreviewPresenter presenter = new EditHtmlPreviewPresenter($(EditHtmlDialog.class));
final EditHtmlPreviewPanel panel = new EditHtmlPreviewPanel(i18n, presenter);
presenter.init(panel);
return presenter;
}
});
- register(Singleton.class, new Factory<InsertImage>(InsertImage.class) {
+ register(Singleton.class, new Factory<InsertImageDialog>(InsertImageDialog.class) {
@Override
- public InsertImage create() {
- final InsertImagePresenter presenter = new InsertImagePresenter();
- final InsertImagePanel panel = new InsertImagePanel(presenter, $(I18nTranslationService.class),
+ public InsertImageDialog create() {
+ final InsertImageDialogPresenter presenter = new InsertImageDialogPresenter();
+ final InsertImageDialogPanel panel = new InsertImageDialogPanel(presenter, $(I18nTranslationService.class),
$(Images.class), $(InsertImageGroup.class));
presenter.init(panel);
return presenter;
@@ -369,44 +367,44 @@
register(InsertImageGroup.class, new Factory<InsertImageExt>(InsertImageExt.class) {
@Override
public InsertImageExt create() {
- final InsertImageExtPresenter presenter = new InsertImageExtPresenter($(InsertImage.class));
+ final InsertImageExtPresenter presenter = new InsertImageExtPresenter($(InsertImageDialog.class));
final InsertImageExtPanel panel = new InsertImageExtPanel(presenter, i18n);
presenter.init(panel);
return presenter;
}
});
- register(Singleton.class, new Factory<TextEditorInsertElement>(TextEditorInsertElement.class) {
+ register(Singleton.class, new Factory<InsertLinkDialog>(InsertLinkDialog.class) {
@Override
- public TextEditorInsertElement create() {
- final TextEditorInsertElementPresenter presenter = new TextEditorInsertElementPresenter();
- final TextEditorInsertElementPanel panel = new TextEditorInsertElementPanel(presenter, $(Images.class),
- $(I18nTranslationService.class), $(TextEditorInsertElementGroup.class));
+ public InsertLinkDialog create() {
+ final InsertLinkDialogPresenter presenter = new InsertLinkDialogPresenter();
+ final InsertLinkDialogPanel panel = new InsertLinkDialogPanel(presenter, $(Images.class),
+ $(I18nTranslationService.class), $(InsertLinkGroup.class));
presenter.init(panel);
return presenter;
}
});
- register(TextEditorInsertElementGroup.class,
- new Factory<TextEditorInsertLinkExt>(TextEditorInsertLinkExt.class) {
+ register(InsertLinkGroup.class,
+ new Factory<InsertLinkExt>(InsertLinkExt.class) {
@Override
- public TextEditorInsertLinkExt create() {
- final TextEditorInsertLinkExtPresenter presenter = new TextEditorInsertLinkExtPresenter(
- $(TextEditorInsertElement.class));
- final TextEditorInsertLinkExtView panel = new TextEditorInsertLinkExtPanel(presenter,
+ public InsertLinkExt create() {
+ final InsertLinkExtPresenter presenter = new InsertLinkExtPresenter(
+ $(InsertLinkDialog.class));
+ final InsertLinkExtView panel = new InsertLinkExtPanel(presenter,
$(I18nTranslationService.class));
presenter.init(panel);
return presenter;
}
});
- register(TextEditorInsertElementGroup.class, new Factory<TextEditorInsertLinkEmail>(
- TextEditorInsertLinkEmail.class) {
+ register(InsertLinkGroup.class, new Factory<InsertLinkEmail>(
+ InsertLinkEmail.class) {
@Override
- public TextEditorInsertLinkEmail create() {
- final TextEditorInsertLinkEmailPresenter presenter = new TextEditorInsertLinkEmailPresenter(
- $(TextEditorInsertElement.class));
- final TextEditorInsertLinkEmailPanel panel = new TextEditorInsertLinkEmailPanel(presenter,
+ public InsertLinkEmail create() {
+ final InsertLinkEmailPresenter presenter = new InsertLinkEmailPresenter(
+ $(InsertLinkDialog.class));
+ final InsertLinkEmailPanel panel = new InsertLinkEmailPanel(presenter,
$(I18nTranslationService.class));
presenter.init(panel);
return presenter;
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-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionSndToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java (from rev 1070, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,13 @@
+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/RTEActionSndToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionSndToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionSndToolbar {
-
- public RTEActionSndToolbarPresenter(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-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionTopToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java (from rev 1070, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,13 @@
+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
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionTopToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionTopToolbar {
-
- public RTEActionTopToolbarPresenter(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,10 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.basic;
-
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-
-public class RTEcanBeBasic implements ActionAddCondition<Object> {
- public boolean mustBeAdded(Object param) {
- // TODO Auto-generated method stub
- return false;
- }
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -18,10 +18,10 @@
import org.ourproject.kune.platf.client.state.Session;
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.EditHtml;
+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.InsertImage;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
+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.utils.DeferredCommandWrapper;
import com.calclab.suco.client.events.Event0;
@@ -58,17 +58,17 @@
private ActionToolbarPushButtonDescriptor<Object> underline;
private ActionToolbarPushButtonDescriptor<Object> strikethrough;
private final Event0 onEdit;
- private final TextEditorInsertElement insertElement;
+ private final InsertLinkDialog insertElement;
private final ColorWebSafePalette palette;
private final DeferredCommandWrapper deferred;
private final ActionAddCondition<Object> canBeBasic;
private final ActionAddCondition<Object> canBeExtended;
- private final Provider<EditHtml> editHtmlDialog;
- private final Provider<InsertImage> insertImageDialog;
+ private final Provider<EditHtmlDialog> editHtmlDialog;
+ private final Provider<InsertImageDialog> insertImageDialog;
public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
- RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement,
- ColorWebSafePalette palette, Provider<EditHtml> editHtmlDialog, Provider<InsertImage> insertImageDialog,
+ RTEActionSndToolbar sndBar, RTEImgResources imgResources, InsertLinkDialog textEditorInsertElement,
+ ColorWebSafePalette palette, Provider<EditHtmlDialog> editHtmlDialog, Provider<InsertImageDialog> insertImageDialog,
DeferredCommandWrapper deferred) {
this.i18n = i18n;
this.session = session;
@@ -399,7 +399,7 @@
ActionToolbarMenuDescriptor<Object> editHtml = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
new Listener0() {
public void onEvent() {
- EditHtml dialog = editHtmlDialog.get();
+ EditHtmlDialog dialog = editHtmlDialog.get();
dialog.setUpdateListener(new Listener<String>() {
public void onEvent(String html) {
view.setHtml(html);
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,21 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.edithtml;
-
-import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlAgent;
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public interface EditHtml extends AbstractOptions {
-
- String getHtml();
-
- void setAgent(EditHtmlAgent agent);
-
- void setCancelListener(Listener0 cancelListener);
-
- void setHtml(String html);
-
- void setUpdateListener(Listener<String> updateListener);
-
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlAgent.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlAgent.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,8 @@
+package org.ourproject.kune.platf.client.ui.rte.edithtml;
+
+public interface EditHtmlAgent {
+
+ String getHtml();
+
+ void setHtml(String html);
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtml.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,20 @@
+package org.ourproject.kune.platf.client.ui.rte.edithtml;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptions;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public interface EditHtmlDialog extends AbstractOptions {
+
+ String getHtml();
+
+ void setAgent(EditHtmlAgent agent);
+
+ void setCancelListener(Listener0 cancelListener);
+
+ void setHtml(String html);
+
+ void setUpdateListener(Listener<String> updateListener);
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,60 @@
+package org.ourproject.kune.platf.client.ui.rte.edithtml;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
+
+import com.google.gwt.user.client.Window;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+
+public class EditHtmlDialogPanel extends AbstractOptionsPanel implements EditHtmlDialogView {
+
+ public static final String EDIT_HTML_DIALOG = "ehtml-dialog";
+ public static final String EDIG_HTML_DIALOG_ERROR_ID = "ehtml-dialgo-error";
+ private final EditHtmlGroup editHtmlGroup;
+ private final I18nTranslationService i18n;
+ private Button cancel;
+ private final EditHtmlDialogPresenter presenter;
+
+ public EditHtmlDialogPanel(final EditHtmlDialogPresenter presenter, I18nTranslationService i18n, RTEImgResources resources,
+ Images images, EditHtmlGroup editHtmlGroup) {
+ super(EDIT_HTML_DIALOG, i18n.tWithNT("Edit the HTML",
+ "Option in a content editor to edit the html internal code (for advance users)"),
+ Window.getClientWidth() - 100, HEIGHT + 80, Window.getClientWidth() - 100, HEIGHT + 80, true, images,
+ EDIG_HTML_DIALOG_ERROR_ID);
+ this.presenter = presenter;
+ this.i18n = i18n;
+ this.editHtmlGroup = editHtmlGroup;
+ // super.setIconCls(RTEImgResources.SUFFIX +
+ // resources.edithtml().getName());
+ }
+
+ @Override
+ public void createAndShow() {
+ if (cancel == null) {
+ cancel = new Button(i18n.t("Cancel"));
+ Button update = new Button(i18n.t("Update"));
+ cancel.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onCancel();
+ }
+ });
+ update.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onUpdate();
+ }
+ });
+ super.addButton(update);
+ super.addButton(cancel);
+ }
+ editHtmlGroup.createAll();
+ super.createAndShow();
+ super.setErrorMessage(i18n.t("This option is only for advanced users"), Level.info);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,51 @@
+package org.ourproject.kune.platf.client.ui.rte.edithtml;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+
+import com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public class EditHtmlDialogPresenter extends AbstractOptionsPresenter implements EditHtmlDialog {
+
+ private Listener<String> updateListener;
+ private Listener0 cancelListener;
+ private EditHtmlAgent agent;
+
+ public EditHtmlDialogPresenter() {
+ }
+
+ public String getHtml() {
+ return agent.getHtml();
+ }
+
+ public void onCancel() {
+ if (cancelListener != null) {
+ cancelListener.onEvent();
+ }
+ hide();
+ }
+
+ public void onUpdate() {
+ if (updateListener != null) {
+ // FIXME
+ updateListener.onEvent(agent.getHtml());
+ }
+ hide();
+ }
+
+ public void setAgent(EditHtmlAgent agent) {
+ this.agent = agent;
+ }
+
+ public void setCancelListener(Listener0 cancelListener) {
+ this.cancelListener = cancelListener;
+ }
+
+ public void setHtml(String html) {
+ agent.setHtml(html);
+ }
+
+ public void setUpdateListener(Listener<String> updateListener) {
+ this.updateListener = updateListener;
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,8 @@
+package org.ourproject.kune.platf.client.ui.rte.edithtml;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+
+public interface EditHtmlDialogView extends AbstractOptionsView, View {
+ int HEIGHT = 225;
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,60 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.edithtml;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser.Level;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
-
-import com.google.gwt.user.client.Window;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-
-public class EditHtmlPanel extends AbstractOptionsPanel implements EditHtmlView {
-
- public static final String EDIT_HTML_DIALOG = "ehtml-dialog";
- public static final String EDIG_HTML_DIALOG_ERROR_ID = "ehtml-dialgo-error";
- private final EditHtmlGroup editHtmlGroup;
- private final I18nTranslationService i18n;
- private Button cancel;
- private final EditHtmlPresenter presenter;
-
- public EditHtmlPanel(final EditHtmlPresenter presenter, I18nTranslationService i18n, RTEImgResources resources,
- Images images, EditHtmlGroup editHtmlGroup) {
- super(EDIT_HTML_DIALOG, i18n.tWithNT("Edit the HTML",
- "Option in a content editor to edit the html internal code (for advance users)"),
- Window.getClientWidth() - 100, HEIGHT + 80, Window.getClientWidth() - 100, HEIGHT + 80, true, images,
- EDIG_HTML_DIALOG_ERROR_ID);
- this.presenter = presenter;
- this.i18n = i18n;
- this.editHtmlGroup = editHtmlGroup;
- // super.setIconCls(RTEImgResources.SUFFIX +
- // resources.edithtml().getName());
- }
-
- @Override
- public void createAndShow() {
- if (cancel == null) {
- cancel = new Button(i18n.t("Cancel"));
- Button update = new Button(i18n.t("Update"));
- cancel.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onCancel();
- }
- });
- update.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onUpdate();
- }
- });
- super.addButton(update);
- super.addButton(cancel);
- }
- editHtmlGroup.createAll();
- super.createAndShow();
- super.setErrorMessage(i18n.t("This option is only for advanced users"), Level.info);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,52 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.edithtml;
-
-import org.ourproject.kune.platf.client.ui.rte.edithtml.editor.EditHtmlAgent;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public class EditHtmlPresenter extends AbstractOptionsPresenter implements EditHtml {
-
- private Listener<String> updateListener;
- private Listener0 cancelListener;
- private EditHtmlAgent agent;
-
- public EditHtmlPresenter() {
- }
-
- public String getHtml() {
- return agent.getHtml();
- }
-
- public void onCancel() {
- if (cancelListener != null) {
- cancelListener.onEvent();
- }
- hide();
- }
-
- public void onUpdate() {
- if (updateListener != null) {
- // FIXME
- updateListener.onEvent(agent.getHtml());
- }
- hide();
- }
-
- public void setAgent(EditHtmlAgent agent) {
- this.agent = agent;
- }
-
- public void setCancelListener(Listener0 cancelListener) {
- this.cancelListener = cancelListener;
- }
-
- public void setHtml(String html) {
- agent.setHtml(html);
- }
-
- public void setUpdateListener(Listener<String> updateListener) {
- this.updateListener = updateListener;
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/EditHtmlView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,8 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.edithtml;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
-
-public interface EditHtmlView extends AbstractOptionsView, View {
- int HEIGHT = 225;
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlAgent.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,8 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.edithtml.editor;
-
-public interface EditHtmlAgent {
-
- String getHtml();
-
- void setHtml(String html);
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -2,7 +2,7 @@
import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlView;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogView;
import com.gwtext.client.widgets.form.TextArea;
@@ -15,9 +15,9 @@
super("HTML");
super.setAutoWidth(true);
super.setHideLabels(true);
- super.setHeight(EditHtmlView.HEIGHT - 20);
+ super.setHeight(EditHtmlDialogView.HEIGHT - 20);
editorField = new TextArea();
- editorField.setHeight(EditHtmlView.HEIGHT - 70);
+ editorField.setHeight(EditHtmlDialogView.HEIGHT - 70);
editorField.setWidth("98%");
editorField.setTabIndex(4);
editorField.setName(HTML_FIELD);
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/editor/EditHtmlEditorPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,14 +1,15 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml.editor;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlAgent;
public class EditHtmlEditorPresenter implements EditHtmlEditor, EditHtmlAgent {
private EditHtmlEditorView view;
- private final EditHtml editHtml;
+ private final EditHtmlDialog editHtml;
- public EditHtmlEditorPresenter(EditHtml editHtml) {
+ public EditHtmlEditorPresenter(EditHtmlDialog editHtml) {
this.editHtml = editHtml;
editHtml.setAgent(this);
}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,7 +1,7 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml.preview;
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlView;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialogView;
import com.google.gwt.user.client.ui.HTML;
import com.gwtext.client.widgets.Panel;
@@ -12,7 +12,7 @@
public EditHtmlPreviewPanel(I18nTranslationService i18n, final EditHtmlPreviewPresenter presenter) {
setTitle(i18n.t("Preview"));
setCls("kune-Content-Main");
- setHeight(EditHtmlView.HEIGHT - 45);
+ setHeight(EditHtmlDialogView.HEIGHT - 45);
setPaddings(5);
setAutoScroll(true);
setAutoWidth(true);
@@ -20,7 +20,7 @@
@Override
public void onActivate(Panel panel) {
clear();
- setHeight(EditHtmlView.HEIGHT - 45);
+ setHeight(EditHtmlDialogView.HEIGHT - 45);
add(new HTML(presenter.getHtml()));
if (isRendered()) {
doLayout();
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/edithtml/preview/EditHtmlPreviewPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,14 +1,14 @@
package org.ourproject.kune.platf.client.ui.rte.edithtml.preview;
import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
+import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlDialog;
public class EditHtmlPreviewPresenter implements EditHtmlPreview {
private EditHtmlPreviewView view;
- private final EditHtml editHtml;
+ private final EditHtmlDialog editHtml;
- public EditHtmlPreviewPresenter(EditHtml editHtml) {
+ public EditHtmlPreviewPresenter(EditHtmlDialog editHtml) {
this.editHtml = editHtml;
}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimg;
-
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
-
-public interface InsertImage extends AbstractOptions {
-
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImage.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptions;
+
+public interface InsertImageDialog extends AbstractOptions {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,26 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
+
+public class InsertImageDialogPanel extends AbstractOptionsPanel implements InsertImageDialogView {
+
+ private static final String INSERT_IMG_DIALOG = "iip-dial";
+ private static final String INSERT_IMG_DIALOG_ERROR_ID = "iip-err";
+ private final InsertImageGroup insertImageGroup;
+
+ public InsertImageDialogPanel(final InsertImageDialogPresenter presenter, I18nTranslationService i18n, Images images,
+ InsertImageGroup insertImageGroup) {
+ super(INSERT_IMG_DIALOG, i18n.t("Insert an image"), 380, HEIGHT + 90, 380, HEIGHT + 90, true, images,
+ INSERT_IMG_DIALOG_ERROR_ID);
+ super.setIconCls("k-picture-icon");
+ this.insertImageGroup = insertImageGroup;
+ }
+
+ @Override
+ public void createAndShow() {
+ insertImageGroup.createAll();
+ super.createAndShow();
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,9 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+
+public class InsertImageDialogPresenter extends AbstractOptionsPresenter implements InsertImageDialog {
+
+ public InsertImageDialogPresenter() {
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,8 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+
+public interface InsertImageDialogView extends AbstractOptionsView, View {
+ int HEIGHT = 225;
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,26 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimg;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
-
-public class InsertImagePanel extends AbstractOptionsPanel implements InsertImageView {
-
- private static final String INSERT_IMG_DIALOG = "iip-dial";
- private static final String INSERT_IMG_DIALOG_ERROR_ID = "iip-err";
- private final InsertImageGroup insertImageGroup;
-
- public InsertImagePanel(final InsertImagePresenter presenter, I18nTranslationService i18n, Images images,
- InsertImageGroup insertImageGroup) {
- super(INSERT_IMG_DIALOG, i18n.t("Insert an image"), 380, HEIGHT + 90, 380, HEIGHT + 90, true, images,
- INSERT_IMG_DIALOG_ERROR_ID);
- super.setIconCls("k-picture-icon");
- this.insertImageGroup = insertImageGroup;
- }
-
- @Override
- public void createAndShow() {
- insertImageGroup.createAll();
- super.createAndShow();
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImagePresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,9 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimg;
-
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
-
-public class InsertImagePresenter extends AbstractOptionsPresenter implements InsertImage {
-
- public InsertImagePresenter() {
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/InsertImageView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,8 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimg;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
-
-public interface InsertImageView extends AbstractOptionsView, View {
- int HEIGHT = 225;
-}
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -3,7 +3,7 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.ui.TextUtils;
import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageView;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogView;
import com.gwtext.client.core.EventObject;
import com.gwtext.client.widgets.Button;
@@ -22,7 +22,7 @@
public InsertImageExtPanel(final InsertImageExtPresenter presenter, I18nTranslationService i18n) {
super(i18n.t("External image"));
super.setAutoWidth(true);
- super.setHeight(InsertImageView.HEIGHT);
+ super.setHeight(InsertImageDialogView.HEIGHT);
linkField = new TextField();
linkField.setTabIndex(1);
linkField.setFieldLabel(i18n.t("External image link (URL)"));
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,12 +1,12 @@
package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
public class InsertImageExtPresenter implements InsertImageExt {
- private final InsertImage insertImageDialog;
+ private final InsertImageDialog insertImageDialog;
- public InsertImageExtPresenter(InsertImage insertImageDialog) {
+ public InsertImageExtPresenter(InsertImageDialog insertImageDialog) {
this.insertImageDialog = insertImageDialog;
}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialog.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,34 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptions;
+
+import com.calclab.suco.client.events.Listener2;
+
+public interface InsertLinkDialog extends AbstractOptions {
+
+ @Deprecated
+ void addOnCreateLink(Listener2<String, String> slot);
+
+ @Deprecated
+ void fireOnCreateLink(String name, String link);
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.services.Images;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
+
+import com.calclab.suco.client.events.Listener0;
+
+public class InsertLinkDialogPanel extends AbstractOptionsPanel implements InsertLinkDialogView {
+ public static final String TEXT_EDT_INSERT_DIALOG = "k-ted-iep-dialog";
+ public static final String TEXT_EDT_INSERT_DIALOG_ERROR_ID = "k-ted-iep-dialog-err";
+ private final InsertLinkGroup textEditorInsertElementGroup;
+
+ public InsertLinkDialogPanel(final InsertLinkDialogPresenter presenter, Images images,
+ I18nTranslationService i18n, final InsertLinkGroup textEditorInsertElementGroup) {
+ super(TEXT_EDT_INSERT_DIALOG, i18n.tWithNT("Insert a link",
+ "Option in a text editor to insert links and other elements"), 380, HEIGHT + 90, 380, HEIGHT + 90,
+ true, images, TEXT_EDT_INSERT_DIALOG_ERROR_ID);
+ super.setIconCls("k-link-icon");
+ this.textEditorInsertElementGroup = textEditorInsertElementGroup;
+ super.addHideListener(new Listener0() {
+ public void onEvent() {
+ textEditorInsertElementGroup.resetAll();
+ }
+ });
+ }
+
+ @Override
+ public void createAndShow() {
+ textEditorInsertElementGroup.createAll();
+ super.createAndShow();
+ }
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
+
+import com.calclab.suco.client.events.Event2;
+import com.calclab.suco.client.events.Listener2;
+
+public class InsertLinkDialogPresenter extends AbstractOptionsPresenter implements InsertLinkDialog {
+
+ private final Event2<String, String> onCreateLink;
+
+ public InsertLinkDialogPresenter() {
+ this.onCreateLink = new Event2<String, String>("onCreateLink");
+ }
+
+ @Deprecated
+ public void addOnCreateLink(final Listener2<String, String> slot) {
+ onCreateLink.add(slot);
+ }
+
+ @Deprecated
+ public void fireOnCreateLink(String name, String link) {
+ onCreateLink.fire(name, link);
+ super.hide();
+ }
+
+ @Deprecated
+ public void fireOnInsertHtml(String name, String link) {
+ onCreateLink.fire(name, link);
+ super.hide();
+ }
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkDialogView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,27 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
+
+public interface InsertLinkDialogView extends AbstractOptionsView, View {
+ int HEIGHT = 225;
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkGroup.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/InsertLinkGroup.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,46 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ \*/
+package org.ourproject.kune.platf.client.ui.rte.insertlink;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstract;
+
+import com.calclab.suco.client.ioc.Container;
+import com.calclab.suco.client.ioc.Provider;
+import com.calclab.suco.client.ioc.decorator.ProviderCollection;
+import com.calclab.suco.client.ioc.decorator.Singleton;
+
+public class InsertLinkGroup extends ProviderCollection {
+
+ public InsertLinkGroup(final Container container) {
+ super(container, Singleton.instance);
+ }
+
+ public void createAll() {
+ for (final Provider<?> p : getProviders()) {
+ p.get();
+ }
+ }
+
+ public void resetAll() {
+ for (final Provider<?> p : getProviders()) {
+ ((InsertLinkAbstract) p.get()).reset();
+ }
+ }
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElement.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.platf.client.ui.rte.insertlink;
-
-import org.ourproject.kune.workspace.client.options.AbstractOptions;
-
-import com.calclab.suco.client.events.Listener2;
-
-public interface TextEditorInsertElement extends AbstractOptions {
-
- @Deprecated
- void addOnCreateLink(Listener2<String, String> slot);
-
- @Deprecated
- void fireOnCreateLink(String name, String link);
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementGroup.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,46 +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.platf.client.ui.rte.insertlink;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstract;
-
-import com.calclab.suco.client.ioc.Container;
-import com.calclab.suco.client.ioc.Provider;
-import com.calclab.suco.client.ioc.decorator.ProviderCollection;
-import com.calclab.suco.client.ioc.decorator.Singleton;
-
-public class TextEditorInsertElementGroup extends ProviderCollection {
-
- public TextEditorInsertElementGroup(final Container container) {
- super(container, Singleton.instance);
- }
-
- public void createAll() {
- for (final Provider<?> p : getProviders()) {
- p.get();
- }
- }
-
- public void resetAll() {
- for (final Provider<?> p : getProviders()) {
- ((TextEditorInsertAbstract) p.get()).reset();
- }
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,52 +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.platf.client.ui.rte.insertlink;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.services.Images;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPanel;
-
-import com.calclab.suco.client.events.Listener0;
-
-public class TextEditorInsertElementPanel extends AbstractOptionsPanel implements TextEditorInsertElementView {
- public static final String TEXT_EDT_INSERT_DIALOG = "k-ted-iep-dialog";
- public static final String TEXT_EDT_INSERT_DIALOG_ERROR_ID = "k-ted-iep-dialog-err";
- private final TextEditorInsertElementGroup textEditorInsertElementGroup;
-
- public TextEditorInsertElementPanel(final TextEditorInsertElementPresenter presenter, Images images,
- I18nTranslationService i18n, final TextEditorInsertElementGroup textEditorInsertElementGroup) {
- super(TEXT_EDT_INSERT_DIALOG, i18n.tWithNT("Insert a link",
- "Option in a text editor to insert links and other elements"), 380, HEIGHT + 90, 380, HEIGHT + 90,
- true, images, TEXT_EDT_INSERT_DIALOG_ERROR_ID);
- super.setIconCls("k-link-icon");
- this.textEditorInsertElementGroup = textEditorInsertElementGroup;
- super.addHideListener(new Listener0() {
- public void onEvent() {
- textEditorInsertElementGroup.resetAll();
- }
- });
- }
-
- @Override
- public void createAndShow() {
- textEditorInsertElementGroup.createAll();
- super.createAndShow();
- }
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,52 +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.platf.client.ui.rte.insertlink;
-
-import org.ourproject.kune.workspace.client.options.AbstractOptionsPresenter;
-
-import com.calclab.suco.client.events.Event2;
-import com.calclab.suco.client.events.Listener2;
-
-public class TextEditorInsertElementPresenter extends AbstractOptionsPresenter implements TextEditorInsertElement {
-
- private final Event2<String, String> onCreateLink;
-
- public TextEditorInsertElementPresenter() {
- this.onCreateLink = new Event2<String, String>("onCreateLink");
- }
-
- @Deprecated
- public void addOnCreateLink(final Listener2<String, String> slot) {
- onCreateLink.add(slot);
- }
-
- @Deprecated
- public void fireOnCreateLink(String name, String link) {
- onCreateLink.fire(name, link);
- super.hide();
- }
-
- @Deprecated
- public void fireOnInsertHtml(String name, String link) {
- onCreateLink.fire(name, link);
- super.hide();
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/TextEditorInsertElementView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,27 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.platf.client.ui.rte.insertlink;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.workspace.client.options.AbstractOptionsView;
-
-public interface TextEditorInsertElementView extends AbstractOptionsView, View {
- int HEIGHT = 225;
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstract.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink;
+
+public interface InsertLinkAbstract {
+
+ void reset();
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+
+public class InsertLinkAbstractPresenter implements InsertLinkAbstract {
+
+ private InsertLinkAbstractView view;
+ private final InsertLinkDialog editorInsertElement;
+
+ public InsertLinkAbstractPresenter(InsertLinkDialog editorInsertElement) {
+ this.editorInsertElement = editorInsertElement;
+ }
+
+ public View getView() {
+ return view;
+ }
+
+ public void init(InsertLinkAbstractView view) {
+ this.view = view;
+ editorInsertElement.addOptionTab(view);
+ }
+
+ public void onInsert(String name, String link) {
+ editorInsertElement.fireOnCreateLink(name, link);
+ reset();
+ }
+
+ public void reset() {
+ view.reset();
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/InsertLinkAbstractView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,28 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface InsertLinkAbstractView extends View {
+
+ void reset();
+
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstract.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,26 +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.platf.client.ui.rte.insertlink.abstractlink;
-
-public interface TextEditorInsertAbstract {
-
- void reset();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,51 +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.platf.client.ui.rte.insertlink.abstractlink;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-
-public class TextEditorInsertAbstractPresenter implements TextEditorInsertAbstract {
-
- private TextEditorInsertAbstractView view;
- private final TextEditorInsertElement editorInsertElement;
-
- public TextEditorInsertAbstractPresenter(TextEditorInsertElement editorInsertElement) {
- this.editorInsertElement = editorInsertElement;
- }
-
- public View getView() {
- return view;
- }
-
- public void init(TextEditorInsertAbstractView view) {
- this.view = view;
- editorInsertElement.addOptionTab(view);
- }
-
- public void onInsert(String name, String link) {
- editorInsertElement.fireOnCreateLink(name, link);
- reset();
- }
-
- public void reset() {
- view.reset();
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/abstractlink/TextEditorInsertAbstractView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,28 +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.platf.client.ui.rte.insertlink.abstractlink;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface TextEditorInsertAbstractView extends View {
-
- void reset();
-
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmail.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmail.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.email;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstract;
+
+public interface InsertLinkEmail extends InsertLinkAbstract {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,67 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.email;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView;
+
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.form.VType;
+
+public class InsertLinkEmailPanel extends DefaultForm implements InsertLinkEmailView {
+
+ public static final String EMAIL_FIELD = "k-teilep-email-field";
+ private final TextField emailField;
+
+ public InsertLinkEmailPanel(final InsertLinkEmailPresenter presenter,
+ I18nTranslationService i18n) {
+ super(i18n.t("Email link"));
+ super.setAutoWidth(true);
+ super.setHeight(InsertLinkDialogView.HEIGHT);
+ emailField = new TextField();
+ emailField.setTabIndex(4);
+ emailField.setFieldLabel(i18n.t("Email"));
+ emailField.setName(EMAIL_FIELD);
+ emailField.setVtype(VType.EMAIL);
+ emailField.setWidth(DEF_MEDIUM_FIELD_WIDTH);
+ emailField.setAllowBlank(false);
+ emailField.setValidationEvent(false);
+ emailField.setId(EMAIL_FIELD);
+ add(emailField);
+ Button insert = new Button(i18n.t("Insert"));
+ insert.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ if (getFormPanel().getForm().isValid()) {
+ presenter.onInsert("", "mailto://" + emailField.getRawValue());
+ }
+ }
+ });
+ addButton(insert);
+ }
+
+ public void clear() {
+ super.reset();
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.email;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter;
+
+public class InsertLinkEmailPresenter extends InsertLinkAbstractPresenter implements
+ InsertLinkEmail {
+
+ public InsertLinkEmailPresenter(InsertLinkDialog editorInsertElement) {
+ super(editorInsertElement);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/InsertLinkEmailView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.platf.client.ui.rte.insertlink.email;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractView;
+
+public interface InsertLinkEmailView extends InsertLinkAbstractView {
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmail.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,26 +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.platf.client.ui.rte.insertlink.email;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstract;
-
-public interface TextEditorInsertLinkEmail extends TextEditorInsertAbstract {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,67 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.platf.client.ui.rte.insertlink.email;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementView;
-
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.widgets.form.TextField;
-import com.gwtext.client.widgets.form.VType;
-
-public class TextEditorInsertLinkEmailPanel extends DefaultForm implements TextEditorInsertLinkEmailView {
-
- public static final String EMAIL_FIELD = "k-teilep-email-field";
- private final TextField emailField;
-
- public TextEditorInsertLinkEmailPanel(final TextEditorInsertLinkEmailPresenter presenter,
- I18nTranslationService i18n) {
- super(i18n.t("Email link"));
- super.setAutoWidth(true);
- super.setHeight(TextEditorInsertElementView.HEIGHT);
- emailField = new TextField();
- emailField.setTabIndex(4);
- emailField.setFieldLabel(i18n.t("Email"));
- emailField.setName(EMAIL_FIELD);
- emailField.setVtype(VType.EMAIL);
- emailField.setWidth(DEF_MEDIUM_FIELD_WIDTH);
- emailField.setAllowBlank(false);
- emailField.setValidationEvent(false);
- emailField.setId(EMAIL_FIELD);
- add(emailField);
- Button insert = new Button(i18n.t("Insert"));
- insert.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- if (getFormPanel().getForm().isValid()) {
- presenter.onInsert("", "mailto://" + emailField.getRawValue());
- }
- }
- });
- addButton(insert);
- }
-
- public void clear() {
- super.reset();
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.platf.client.ui.rte.insertlink.email;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractPresenter;
-
-public class TextEditorInsertLinkEmailPresenter extends TextEditorInsertAbstractPresenter implements
- TextEditorInsertLinkEmail {
-
- public TextEditorInsertLinkEmailPresenter(TextEditorInsertElement editorInsertElement) {
- super(editorInsertElement);
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/email/TextEditorInsertLinkEmailView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,25 +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.platf.client.ui.rte.insertlink.email;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractView;
-
-public interface TextEditorInsertLinkEmailView extends TextEditorInsertAbstractView {
-}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExt.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExt.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.ext;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstract;
+
+public interface InsertLinkExt extends InsertLinkAbstract {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,103 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.ext;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.TextUtils;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView;
+
+import com.google.gwt.user.client.ui.Frame;
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.PaddedPanel;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class InsertLinkExtPanel extends DefaultForm implements InsertLinkExtView {
+
+ public static final String LINK_FIELD = "k-teilep-link-f";
+ final TextField linkField;
+ final Panel previewPanel;
+
+ public InsertLinkExtPanel(final InsertLinkExtPresenter presenter,
+ final I18nTranslationService i18n) {
+ super(i18n.t("External link"));
+ super.setAutoWidth(true);
+ super.setHeight(InsertLinkDialogView.HEIGHT);
+ linkField = new TextField();
+ linkField.setTabIndex(1);
+ linkField.setFieldLabel(i18n.t("External link (URL)"));
+ linkField.setRegex(TextUtils.URL_REGEXP);
+ linkField.setRegexText(i18n.t("The link should be a URL in the format 'http://www.domain.com'"));
+ linkField.setName(LINK_FIELD);
+ linkField.setWidth(DEF_FIELD_WIDTH);
+ linkField.setAllowBlank(false);
+ linkField.setMinLength(3);
+ linkField.setMaxLength(250);
+ linkField.setValidationEvent(false);
+ linkField.setId(LINK_FIELD);
+ add(linkField);
+ previewPanel = new Panel();
+ previewPanel.setLayout(new FitLayout());
+ previewPanel.setHeight(125);
+ add(new PaddedPanel(previewPanel, 0));
+ Button preview = new Button(i18n.t("Preview"));
+ preview.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onPreview();
+ }
+ });
+ addButton(preview);
+
+ Button insert = new Button(i18n.t("Insert"));
+ insert.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onInsert();
+ }
+ });
+ addButton(insert);
+ }
+
+ public String getUrl() {
+ return linkField.getRawValue();
+ }
+
+ @Override
+ public void reset() {
+ super.reset();
+ previewPanel.clear();
+ }
+
+ public void setPreviewUrl(String url) {
+ Frame previewFrame = new Frame(url);
+ previewPanel.clear();
+ previewPanel.add(previewFrame);
+ previewPanel.doLayout();
+ }
+
+ public void setUrl(String url) {
+ linkField.setValue(url);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,79 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.platf.client.ui.rte.insertlink.ext;
+
+import org.ourproject.kune.platf.client.ui.TextUtils;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter;
+
+public class InsertLinkExtPresenter extends InsertLinkAbstractPresenter implements
+ InsertLinkExt {
+
+ interface Action {
+ void onValid(String url);
+ }
+
+ private InsertLinkExtView view;
+
+ public InsertLinkExtPresenter(InsertLinkDialog editorInsertElement) {
+ super(editorInsertElement);
+ }
+
+ public void init(InsertLinkExtView view) {
+ super.init(view);
+ this.view = view;
+ }
+
+ public void onInsert() {
+ doActionIfValid(new Action() {
+ public void onValid(String url) {
+ onInsert("", url);
+ }
+ });
+ }
+
+ public void onPreview() {
+ doActionIfValid(new Action() {
+ public void onValid(String url) {
+ view.setPreviewUrl(url);
+ }
+ });
+ }
+
+ private void doActionIfValid(Action action) {
+ String url = view.getUrl();
+ if (url.matches(TextUtils.URL_REGEXP)) {
+ action.onValid(url);
+ } else {
+ if (!url.startsWith("http://")) {
+ url = "http://" + url;
+ if (url.matches(TextUtils.URL_REGEXP)) {
+ view.setUrl(url);
+ action.onValid(url);
+ } else {
+ view.isValid();
+ }
+ } else {
+ // Seems is not valid
+ view.isValid();
+ }
+ }
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/InsertLinkExtView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.platf.client.ui.rte.insertlink.ext;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractView;
+
+public interface InsertLinkExtView extends InsertLinkAbstractView {
+
+ public String getUrl();
+
+ public boolean isValid();
+
+ public void setPreviewUrl(String url);
+
+ public void setUrl(String url);
+}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExt.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,26 +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.platf.client.ui.rte.insertlink.ext;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstract;
-
-public interface TextEditorInsertLinkExt extends TextEditorInsertAbstract {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,103 +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.platf.client.ui.rte.insertlink.ext;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.TextUtils;
-import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementView;
-
-import com.google.gwt.user.client.ui.Frame;
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.PaddedPanel;
-import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.widgets.form.TextField;
-import com.gwtext.client.widgets.layout.FitLayout;
-
-public class TextEditorInsertLinkExtPanel extends DefaultForm implements TextEditorInsertLinkExtView {
-
- public static final String LINK_FIELD = "k-teilep-link-f";
- final TextField linkField;
- final Panel previewPanel;
-
- public TextEditorInsertLinkExtPanel(final TextEditorInsertLinkExtPresenter presenter,
- final I18nTranslationService i18n) {
- super(i18n.t("External link"));
- super.setAutoWidth(true);
- super.setHeight(TextEditorInsertElementView.HEIGHT);
- linkField = new TextField();
- linkField.setTabIndex(1);
- linkField.setFieldLabel(i18n.t("External link (URL)"));
- linkField.setRegex(TextUtils.URL_REGEXP);
- linkField.setRegexText(i18n.t("The link should be a URL in the format 'http://www.domain.com'"));
- linkField.setName(LINK_FIELD);
- linkField.setWidth(DEF_FIELD_WIDTH);
- linkField.setAllowBlank(false);
- linkField.setMinLength(3);
- linkField.setMaxLength(250);
- linkField.setValidationEvent(false);
- linkField.setId(LINK_FIELD);
- add(linkField);
- previewPanel = new Panel();
- previewPanel.setLayout(new FitLayout());
- previewPanel.setHeight(125);
- add(new PaddedPanel(previewPanel, 0));
- Button preview = new Button(i18n.t("Preview"));
- preview.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onPreview();
- }
- });
- addButton(preview);
-
- Button insert = new Button(i18n.t("Insert"));
- insert.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onInsert();
- }
- });
- addButton(insert);
- }
-
- public String getUrl() {
- return linkField.getRawValue();
- }
-
- @Override
- public void reset() {
- super.reset();
- previewPanel.clear();
- }
-
- public void setPreviewUrl(String url) {
- Frame previewFrame = new Frame(url);
- previewPanel.clear();
- previewPanel.add(previewFrame);
- previewPanel.doLayout();
- }
-
- public void setUrl(String url) {
- linkField.setValue(url);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,79 +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.platf.client.ui.rte.insertlink.ext;
-
-import org.ourproject.kune.platf.client.ui.TextUtils;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractPresenter;
-
-public class TextEditorInsertLinkExtPresenter extends TextEditorInsertAbstractPresenter implements
- TextEditorInsertLinkExt {
-
- interface Action {
- void onValid(String url);
- }
-
- private TextEditorInsertLinkExtView view;
-
- public TextEditorInsertLinkExtPresenter(TextEditorInsertElement editorInsertElement) {
- super(editorInsertElement);
- }
-
- public void init(TextEditorInsertLinkExtView view) {
- super.init(view);
- this.view = view;
- }
-
- public void onInsert() {
- doActionIfValid(new Action() {
- public void onValid(String url) {
- onInsert("", url);
- }
- });
- }
-
- public void onPreview() {
- doActionIfValid(new Action() {
- public void onValid(String url) {
- view.setPreviewUrl(url);
- }
- });
- }
-
- private void doActionIfValid(Action action) {
- String url = view.getUrl();
- if (url.matches(TextUtils.URL_REGEXP)) {
- action.onValid(url);
- } else {
- if (!url.startsWith("http://")) {
- url = "http://" + url;
- if (url.matches(TextUtils.URL_REGEXP)) {
- view.setUrl(url);
- action.onValid(url);
- } else {
- view.isValid();
- }
- } else {
- // Seems is not valid
- view.isValid();
- }
- }
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertlink/ext/TextEditorInsertLinkExtView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,33 +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.platf.client.ui.rte.insertlink.ext;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractView;
-
-public interface TextEditorInsertLinkExtView extends TextEditorInsertAbstractView {
-
- public String getUrl();
-
- public boolean isValid();
-
- public void setPreviewUrl(String url);
-
- public void setUrl(String url);
-}
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-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -8,20 +8,36 @@
public interface RTESavingEditor {
+ /**
+ * Start to edit some html code
+ *
+ * @param html
+ * the html text to edit
+ * @param onSave
+ * the save action (when user click the save button)
+ * @param onEditCancelled
+ * the cancel action (when user click the cancel/close button)
+ */
void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
RTEditor getBasicEditor();
/**
- * This is use for listen to changes as url changes, window close, and
- * save/cancel or stop these actions
+ * This is used for listen to changes that affect the edition as url
+ * changes, window close, to save/cancel or stop these actions
*
- * @return
+ * @return the listener
*/
BeforeActionListener getBeforeSavingListener();
+ /**
+ * Call this when your save action is successful
+ */
void onSavedSuccessful();
+ /**
+ * Call this when your save action fails
+ */
void onSaveFailed();
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -49,10 +49,10 @@
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.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkGroup;
import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
@@ -73,9 +73,9 @@
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;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.TextEditorInsertLinkLocal;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.TextEditorInsertLinkLocalPanel;
-import org.ourproject.kune.workspace.client.editor.insertlocallink.TextEditorInsertLinkLocalPresenter;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocal;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPanel;
+import org.ourproject.kune.workspace.client.editor.insertlocallink.InsertLinkLocalPresenter;
import org.ourproject.kune.workspace.client.entityheader.EntityHeader;
import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPanel;
import org.ourproject.kune.workspace.client.entityheader.EntityHeaderPresenter;
@@ -806,13 +806,13 @@
}
});
- register(TextEditorInsertElementGroup.class, new Factory<TextEditorInsertLinkLocal>(
- TextEditorInsertLinkLocal.class) {
+ register(InsertLinkGroup.class, new Factory<InsertLinkLocal>(
+ InsertLinkLocal.class) {
@Override
- public TextEditorInsertLinkLocal create() {
- final TextEditorInsertLinkLocalPresenter presenter = new TextEditorInsertLinkLocalPresenter(
- $(TextEditorInsertElement.class));
- final TextEditorInsertLinkLocalPanel panel = new TextEditorInsertLinkLocalPanel(presenter,
+ public InsertLinkLocal create() {
+ final InsertLinkLocalPresenter presenter = new InsertLinkLocalPresenter(
+ $(InsertLinkDialog.class));
+ final InsertLinkLocalPanel panel = new InsertLinkLocalPanel(presenter,
$(WorkspaceSkeleton.class), $(I18nTranslationService.class), $(FileDownloadUtils.class));
presenter.init(panel);
return presenter;
@@ -928,7 +928,7 @@
register(InsertImageGroup.class, new Factory<InsertImageLocal>(InsertImageLocal.class) {
@Override
public InsertImageLocal create() {
- final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter($(InsertImage.class));
+ final InsertImageLocalPresenter presenter = new InsertImageLocalPresenter($(InsertImageDialog.class));
final InsertImageLocalPanel panel = new InsertImageLocalPanel(presenter,
$(I18nTranslationService.class));
presenter.init(panel);
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -2,7 +2,7 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.ui.TextUtils;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageView;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialogView;
import com.google.gwt.user.client.ui.Label;
import com.gwtext.client.widgets.Panel;
@@ -12,7 +12,7 @@
public InsertImageLocalPanel(final InsertImageLocalPresenter presenter, I18nTranslationService i18n) {
super(i18n.t("Local image"));
setAutoWidth(true);
- setHeight(InsertImageView.HEIGHT);
+ setHeight(InsertImageDialogView.HEIGHT);
setPaddings(20);
add(new Label(TextUtils.IN_DEVELOPMENT));
}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocalimg/InsertImageLocalPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,12 +1,12 @@
package org.ourproject.kune.workspace.client.editor.insertlocalimg;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageDialog;
public class InsertImageLocalPresenter implements InsertImageLocal {
- private final InsertImage insertImageDialog;
+ private final InsertImageDialog insertImageDialog;
- public InsertImageLocalPresenter(InsertImage insertImageDialog) {
+ public InsertImageLocalPresenter(InsertImageDialog insertImageDialog) {
this.insertImageDialog = insertImageDialog;
}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocal.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocal.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.workspace.client.editor.insertlocallink;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstract;
+
+public interface InsertLinkLocal extends InsertLinkAbstract {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,51 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.workspace.client.editor.insertlocallink;
+
+import org.ourproject.kune.platf.client.dto.LinkDTO;
+import org.ourproject.kune.platf.client.dto.StateToken;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.WindowUtils;
+import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialogView;
+import org.ourproject.kune.workspace.client.search.AbstractLiveSearcherPanel;
+import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
+
+import com.calclab.suco.client.events.Listener;
+
+public class InsertLinkLocalPanel extends AbstractLiveSearcherPanel implements InsertLinkLocalView {
+
+ private static final String DATA_PROXY_URL = "/kune/json/ContentJSONService/search";
+
+ public InsertLinkLocalPanel(final InsertLinkLocalPresenter presenter,
+ final WorkspaceSkeleton ws, I18nTranslationService i18n, FileDownloadUtils downloadUtils) {
+ super(i18n, TEMPLATE_TEXT_PREFIX + downloadUtils.getLogoImageUrl(new StateToken("{shortName}"))
+ + TEMPLATE_TEXT_SUFFIX, DATA_PROXY_URL, new Listener<LinkDTO>() {
+ public void onEvent(LinkDTO link) {
+ // FIXME
+ presenter.onInsert("", WindowUtils.getLocation().getHref() + link.getLink());
+ }
+ });
+ super.setTitle(i18n.t("Local link"));
+ super.setFrame(true);
+ super.setHeight(InsertLinkDialogView.HEIGHT);
+ super.setPaddings(20);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.ourproject.kune.workspace.client.editor.insertlocallink;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.InsertLinkDialog;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractPresenter;
+
+public class InsertLinkLocalPresenter extends InsertLinkAbstractPresenter implements
+ InsertLinkLocal {
+
+ public InsertLinkLocalPresenter(InsertLinkDialog editorInsertElement) {
+ super(editorInsertElement);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/InsertLinkLocalView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -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.editor.insertlocallink;
+
+import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.InsertLinkAbstractView;
+
+public interface InsertLinkLocalView extends InsertLinkAbstractView {
+}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocal.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,26 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor.insertlocallink;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstract;
-
-public interface TextEditorInsertLinkLocal extends TextEditorInsertAbstract {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPanel.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,51 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor.insertlocallink;
-
-import org.ourproject.kune.platf.client.dto.LinkDTO;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.WindowUtils;
-import org.ourproject.kune.platf.client.ui.download.FileDownloadUtils;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementView;
-import org.ourproject.kune.workspace.client.search.AbstractLiveSearcherPanel;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.calclab.suco.client.events.Listener;
-
-public class TextEditorInsertLinkLocalPanel extends AbstractLiveSearcherPanel implements TextEditorInsertLinkLocalView {
-
- private static final String DATA_PROXY_URL = "/kune/json/ContentJSONService/search";
-
- public TextEditorInsertLinkLocalPanel(final TextEditorInsertLinkLocalPresenter presenter,
- final WorkspaceSkeleton ws, I18nTranslationService i18n, FileDownloadUtils downloadUtils) {
- super(i18n, TEMPLATE_TEXT_PREFIX + downloadUtils.getLogoImageUrl(new StateToken("{shortName}"))
- + TEMPLATE_TEXT_SUFFIX, DATA_PROXY_URL, new Listener<LinkDTO>() {
- public void onEvent(LinkDTO link) {
- // FIXME
- presenter.onInsert("", WindowUtils.getLocation().getHref() + link.getLink());
- }
- });
- super.setTitle(i18n.t("Local link"));
- super.setFrame(true);
- super.setHeight(TextEditorInsertElementView.HEIGHT);
- super.setPaddings(20);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalPresenter.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,32 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor.insertlocallink;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractPresenter;
-
-public class TextEditorInsertLinkLocalPresenter extends TextEditorInsertAbstractPresenter implements
- TextEditorInsertLinkLocal {
-
- public TextEditorInsertLinkLocalPresenter(TextEditorInsertElement editorInsertElement) {
- super(editorInsertElement);
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java 2009-03-11 13:47:13 UTC (rev 1070)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insertlocallink/TextEditorInsertLinkLocalView.java 2009-03-11 14:08:13 UTC (rev 1071)
@@ -1,25 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor.insertlocallink;
-
-import org.ourproject.kune.platf.client.ui.rte.insertlink.abstractlink.TextEditorInsertAbstractView;
-
-public interface TextEditorInsertLinkLocalView extends TextEditorInsertAbstractView {
-}
1
0
Author: vjrj
Date: 2009-03-11 14:47:13 +0100 (Wed, 11 Mar 2009)
New Revision: 1070
Added:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/
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/RTEActionSndToolbarPresenter.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/RTEActionTopToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.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/insertimg/ext/
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/
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/test/java/org/ourproject/kune/platf/client/ui/rte/saving/
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java
Removed:
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignleft.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignright.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/backcolor.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/bold.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/centerpara.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/charfontname.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/decrementindent.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultbullet.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultnumbering.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/edithtml.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontcolor.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontheight.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/hfixedline.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/images.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/incrementindent.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/abstractlink/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkemail/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linkext/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/insert/linklocal/
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/italic.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link_break.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/removeFormat.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/strikeout.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/subscript.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/superscript.png
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/underline.png
trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
Modified:
trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java
trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java
Log:
Incomplete - task Better RTE (Rich Text Editor) support
Modified: trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/services/KunePlatformModule.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -48,17 +48,14 @@
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePanel;
import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalettePresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionSndToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionSndToolbarPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTEActionTopToolbarPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPresenter;
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.RTEActionSndToolbarPresenter;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbar;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEActionTopToolbarPresenter;
+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.EditHtml;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlGroup;
import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtmlPanel;
@@ -74,9 +71,9 @@
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePanel;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImagePresenter;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExt;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExtPanel;
-import org.ourproject.kune.platf.client.ui.rte.insertimgext.InsertImageExtPresenter;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExt;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPanel;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.ext.InsertImageExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementPanel;
@@ -88,6 +85,9 @@
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPanel;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtPresenter;
import org.ourproject.kune.platf.client.ui.rte.insertlink.ext.TextEditorInsertLinkExtView;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditor;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
+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;
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionSndToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionSndToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionSndToolbar {
-
- public RTEActionSndToolbarPresenter(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-public interface RTEActionTopToolbar extends ActionToolbar<Object> {
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,12 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
-
-public class RTEActionTopToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionTopToolbar {
-
- public RTEActionTopToolbarPresenter(ActionToolbarView<Object> toolbar) {
- super(toolbar);
- }
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,26 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTESavingEditor {
-
- void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
-
- RTEditor getBasicEditor();
-
- /**
- * This is use for listen to changes as url changes, window close, and
- * save/cancel or stop these actions
- *
- * @return
- */
- BeforeActionListener getBeforeSavingListener();
-
- void onSavedSuccessful();
-
- void onSaveFailed();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,14 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
-
-import com.calclab.suco.client.events.Listener0;
-
-public class RTESavingEditorPanel implements RTESavingEditorView {
-
- public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
- Listener0 onCancel) {
- NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,244 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.ui.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;
-
-public class RTESavingEditorPresenter implements RTESavingEditor {
-
- @Deprecated
- private static final String FILE_MENU_OPTION = "File";
- public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
- public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
-
- private final RTEditor editor;
- private final boolean autoSave;
- private boolean savePending;
- private boolean saveAndCloseConfirmed;
- private Listener<String> onSave;
- private Listener0 onEditCancelled;
- private final RTEImgResources imgResources;
- private final TimerWrapper timer;
- private final DeferredCommandWrapper deferredCommandWrapper;
- private final I18nTranslationService i18n;
- private final StateManager stateManager;
- private final BeforeActionListener beforeStateChangeListener;
- ActionToolbarButtonDescriptor<Object> saveBtn;
- private RTESavingEditorView view;
-
- public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
- StateManager stateManager, DeferredCommandWrapper deferredCommandWrapper,
- RTEImgResources imgResources, TimerWrapper timer) {
- this.editor = editor;
- this.autoSave = autoSave;
- this.i18n = i18n;
- this.stateManager = stateManager;
- this.deferredCommandWrapper = deferredCommandWrapper;
- this.imgResources = imgResources;
- this.savePending = false;
- this.saveAndCloseConfirmed = false;
- createActions();
- this.timer = timer;
- timer.configure(new Listener0() {;
-
- public void onEvent() {
- onAutoSave();
- }
- });
- editor.addOnEditListener(new Listener0() {
- public void onEvent() {
- onEdit();
- }
- });
- beforeStateChangeListener = new BeforeActionListener() {
- public boolean beforeAction() {
- return beforeTokenChange();
- }
- };
- }
-
- public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) {
- this.onSave = onSave;
- this.onEditCancelled = onEditCancelled;
- editor.setHtml(html);
- editor.attach();
- stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
- enableSaveBtn(false);
- }
-
- public RTEditor getBasicEditor() {
- return editor;
- }
-
- public BeforeActionListener getBeforeSavingListener() {
- return beforeStateChangeListener;
- }
-
- public void init(RTESavingEditorView view) {
- this.view = view;
- }
-
- public void onDoSaveAndClose() {
- saveAndCloseConfirmed = true;
- onDoSave();
- }
-
- public void onSavedSuccessful() {
- if (saveAndCloseConfirmed) {
- onCancelConfirmed();
- } else {
- reset();
- }
- }
-
- public void onSaveFailed() {
- timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- if (saveAndCloseConfirmed) {
- saveAndCloseConfirmed = false;
- }
- }
-
- protected void onAutoSave() {
- onDoSave();
- }
-
- protected void onCancel() {
- if (savePending) {
- timer.cancel();
- Listener0 onYes = new Listener0() {
- public void onEvent() {
- onDoSaveAndClose();
- }
- };
- Listener0 onCancel = new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- };
- view.askConfirmation(i18n.t("Save confirmation"),
- i18n.t("Do you want to save before closing the editor?"), onYes, onCancel);
- } else {
- onCancelConfirmed();
- }
- }
-
- protected void onCancelConfirmed() {
- stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
- stateManager.resumeTokenChange();
- reset();
- editor.reset();
- onDoEditCancelled();
- }
-
- protected void onDoSave() {
- onSave.onEvent(editor.getHtml());
- }
-
- boolean beforeTokenChange() {
- if (savePending) {
- onCancel();
- return false;
- } else {
- deferredCommandWrapper.addCommand(new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- });
- return true;
- }
- }
-
- void onEdit() {
- if (!savePending) {
- savePending = true;
- if (autoSave) {
- timer.schedule(AUTOSAVE_IN_MILLISECONDS);
- }
- enableSaveBtn(true);
- }
- }
-
- private void createActions() {
- Listener0 onPerformSaveCall = new Listener0() {
- public void onEvent() {
- onDoSave();
- }
- };
- saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.sndbar, onPerformSaveCall);
- saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
- saveBtn.setToolTip(i18n.t("Save"));
- saveBtn.setShortcut(new ActionShortcut(true, 'S'));
- saveBtn.setPosition(0);
-
- ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.topbar, onPerformSaveCall);
- save.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
- save.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
- save.setTextDescription(i18n.t("Save"));
- save.setShortcut(new ActionShortcut(true, 'S'));
- save.setPosition(0);
-
- ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.topbar, new Listener<Object>() {
- public void onEvent(Object parameter) {
- onCancel();
- }
- });
- close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
- close.setTextDescription(i18n.t("Close"));
-
- Listener0 onPerformSaveAndCloseCall = new Listener0() {
- public void onEvent() {
- if (savePending) {
- timer.cancel();
- onDoSaveAndClose();
- } else {
- onCancelConfirmed();
- }
- }
- };
- ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
- RTEditor.topbar, onPerformSaveAndCloseCall);
- saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
- saveclose.setTextDescription(i18n.t("Save & Close"));
-
- ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>(
- AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall);
- // saveCloseBtn.setIconCls(RTEImgResources.SUFFIX +
- // imgResources.save().getName());
- saveCloseBtn.setTextDescription(i18n.t("Save & Close"));
- saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
-
- editor.addAction(save);
- editor.addAction(saveclose);
- editor.addAction(close);
- editor.addAction(saveBtn);
- editor.addAction(saveCloseBtn);
- }
-
- private void enableSaveBtn(boolean enable) {
- editor.getSndBar().setButtonEnable(saveBtn, enable);
- }
-
- private void onDoEditCancelled() {
- onEditCancelled.onEvent();
- }
-
- private void reset() {
- timer.cancel();
- savePending = false;
- saveAndCloseConfirmed = false;
- enableSaveBtn(false);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,10 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTESavingEditorView extends View {
-
- void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,10 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-
-public class RTEcanBeBasic implements ActionAddCondition<Object> {
- public boolean mustBeAdded(Object param) {
- // TODO Auto-generated method stub
- return false;
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,46 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarPosition;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-
-import com.calclab.suco.client.events.Listener0;
-
-public interface RTEditor {
-
- public final ActionToolbarPosition topbar = new ActionToolbarPosition("rte-topbar");
- public final ActionToolbarPosition sndbar = new ActionToolbarPosition("rte-sndbar");;
-
- void addAction(ActionDescriptor<Object> action);
-
- void addActions(ActionCollection<Object> actions);
-
- void addOnEditListener(Listener0 listener);
-
- void attach();
-
- ActionAddCondition<Object> canBeBasic();
-
- ActionAddCondition<Object> canBeExtended();
-
- View getEditorArea();
-
- String getHtml();
-
- ActionToolbar<Object> getSndBar();
-
- String getText();
-
- ActionToolbar<Object> getTopBar();
-
- void reset();
-
- void setExtended(boolean extended);
-
- void setHtml(String html);
-
- void setText(String text);
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,318 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import java.util.Date;
-import java.util.HashMap;
-
-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.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-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 com.allen_sauer.gwt.log.client.Log;
-import com.google.gwt.dom.client.Element;
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.FocusListener;
-import com.google.gwt.user.client.ui.KeyboardListener;
-import com.google.gwt.user.client.ui.Widget;
-
-public class RTEditorPanel implements RTEditorView {
-
- private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener {
-
- public void onChange(Widget sender) {
- presenter.fireOnEdit();
- }
-
- public void onClick(Widget sender) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status. This will catch any cases where the user
- // moves the cursor using the keyboard, or uses one of the
- // browser's built-in keyboard shortcuts.
- updateStatus();
- }
- }
-
- public void onFocus(Widget sender) {
- presenter.onEditorFocus();
- }
-
- public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == rta) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursor
- // using the keyboard, or uses one of the browser's built-in
- // keyboard shortcuts.
-
- updateStatus();
- fireEdit();
- if (modifiers != 0) {
- Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")");
- ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
- if (actionItem != null) {
- actionManager.doAction(actionItem);
- updateStatus();
- } else {
- Log.debug("...but not mapped to any action");
- }
- }
- }
- }
-
- public void onLostFocus(Widget sender) {
-
- }
- }
- private final I18nUITranslationService i18n;
- private final RichTextArea rta;
- private final BasicFormatter basic;
- private final ExtendedFormatter extended;
- private final HashMap<ActionShortcut, ActionItem<Object>> shortcuts;
- private final ActionManager actionManager;
- private final RTEditorPresenter presenter;
-
- public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n, ActionManager actionManager) {
- this.presenter = presenter;
- this.i18n = i18n;
- this.actionManager = actionManager;
- rta = new RichTextArea();
- basic = rta.getBasicFormatter();
- extended = rta.getExtendedFormatter();
- shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>();
- EventListener listener = new EventListener();
- rta.addClickListener(listener);
- rta.addKeyboardListener(listener);
- rta.addFocusListener(listener);
- rta.setWidth("96%");
- rta.setHeight("100%");
- }
-
- public void addActions(ActionItemCollection<Object> actionItems) {
- for (ActionItem<Object> actionItem : actionItems) {
- ActionDescriptor<Object> action = actionItem.getAction();
- if (action.hasShortcut() && action.mustBeAdded(null)) {
- ActionShortcut shortcut = action.getShortcut();
- shortcuts.put(shortcut, actionItem);
- }
- }
- }
-
- public void addComment(String userName) {
- String time = i18n.formatDateWithLocale(new Date(), true);
- Element span = DOM.createSpan();
- span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
- DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
- insertHtml(" " + span.getString() + " ");
- }
-
- public void adjustSize(int height) {
- rta.setHeight("" + height);
- }
-
- public boolean canBeBasic() {
- return basic != null;
- }
-
- public boolean canBeExtended() {
- return extended != null;
- }
-
- public void copy() {
- extended.copy();
- }
-
- public void createLink(String url) {
- extended.createLink(url);
- }
-
- public void cut() {
- extended.cut();
- }
-
- public void delete() {
- extended.delete();
- }
-
- public void focus() {
- rta.setFocus(true);
- }
-
- public String getHtml() {
- return rta.getHTML();
- }
-
- public Widget getRTE() {
- return rta;
- }
-
- public String getText() {
- return rta.getText();
- }
-
- public void insertHorizontalRule() {
- extended.insertHorizontalRule();
- }
-
- public void insertHtml(String html) {
- extended.insertHtml(html);
- }
-
- public void insertImage(String url) {
- extended.insertImage(url);
- }
-
- public void insertOrderedList() {
- extended.insertOrderedList();
- }
-
- public void insertUnorderedList() {
- extended.insertUnorderedList();
- }
-
- public boolean isAttached() {
- return rta.isAttached();
- }
-
- public boolean isBold() {
- return basic.isBold();
- }
-
- public boolean isItalic() {
- return basic.isItalic();
- }
-
- 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 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 setBackColor(String color) {
- basic.setBackColor(color);
- }
-
- public void setFontName(String name) {
- basic.setFontName(name);
- }
-
- public void setFontSize(FontSize size) {
- basic.setFontSize(size);
- }
-
- public void setForeColor(String color) {
- basic.setForeColor(color);
- }
-
- public void setHtml(String html) {
- rta.setHTML(html);
- }
-
- public void setText(String text) {
- rta.setText(text);
- }
-
- 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();
- }
-
- /**
- * 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/RTEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,761 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionAddCondition;
-import org.ourproject.kune.platf.client.actions.ActionCollection;
-import org.ourproject.kune.platf.client.actions.ActionDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionEnableCondition;
-import org.ourproject.kune.platf.client.actions.ActionItem;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.actions.ActionShortcut;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
-import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
-import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.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.state.Session;
-import org.ourproject.kune.platf.client.ui.palette.ColorWebSafePalette;
-import org.ourproject.kune.platf.client.ui.rte.edithtml.EditHtml;
-import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
-import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-
-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.events.Listener2;
-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", "Small", "Medium", "Large", "Very large",
- "Extra large" };
- private static final RichTextArea.FontSize[] fontSizesConstants = 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 TextEditorInsertElement insertElement;
- private final ColorWebSafePalette palette;
- private final DeferredCommandWrapper deferred;
- private final ActionAddCondition<Object> canBeBasic;
- private final ActionAddCondition<Object> canBeExtended;
- private final Provider<EditHtml> editHtmlDialog;
- private final Provider<InsertImage> insertImageDialog;
-
- public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
- RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement,
- ColorWebSafePalette palette, Provider<EditHtml> editHtmlDialog, Provider<InsertImage> insertImageDialog,
- DeferredCommandWrapper deferred) {
- this.i18n = i18n;
- this.session = session;
- this.topBar = topBar;
- this.sndBar = sndBar;
- this.insertElement = textEditorInsertElement;
- this.palette = palette;
- this.editHtmlDialog = editHtmlDialog;
- this.insertImageDialog = insertImageDialog;
- 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(Object param) {
- return view.canBeBasic();
- }
- };
- canBeExtended = new ActionAddCondition<Object>() {
- public boolean mustBeAdded(Object param) {
- return isExtended();
- }
- };
- }
-
- public void addAction(ActionDescriptor<Object> action) {
- actions.add(withNoItem(action));
- }
-
- public void addActions(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 canBeBasic();
- }
-
- public ActionAddCondition<Object> canBeExtended() {
- return canBeExtended();
- }
-
- 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(RTEditorView view) {
- this.view = view;
- createBasicActions();
- }
-
- public void onEditorFocus() {
- topBar.hideAllMenus();
- sndBar.hideAllMenus();
- palette.hide();
- }
-
- public void reset() {
- topBar.clear();
- sndBar.clear();
- }
-
- public void setExtended(boolean extended) {
- this.extended = extended;
- }
-
- public void setHtml(String html) {
- view.setHtml(html);
- view.focus();
- }
-
- public void setText(String text) {
- view.setText(text);
- view.focus();
- }
-
- public void updateStatus() {
- if (view.canBeBasic()) {
- sndBar.setPushButtonPressed(bold, view.isBold());
- 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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(true, '0'));
- 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 ActionShortcut(true, '9'));
- 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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(true, 'R'));
- justifyRight.setAddCondition(canBeBasic);
-
- ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
- new Listener0() {
- public void onEvent() {
- view.undo();
- fireOnEdit();
- }
- });
- undo.setShortcut(new ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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() {
- EditHtml dialog = editHtmlDialog.get();
- dialog.setUpdateListener(new Listener<String>() {
- public void onEvent(String html) {
- view.setHtml(html);
- fireOnEdit();
- }
- });
- dialog.show();
- 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() {
- view.focus();
- String author = session.isLogged() ? session.getCurrentUser().getShortName()
- : i18n.t("anonymous user");
- view.addComment(author);
- fireOnEdit();
- }
- });
- comment.setEnableCondition(new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(Object param) {
- return session.isLogged();
- }
- });
- comment.setShortcut(new ActionShortcut(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 ActionShortcut(true, true, ' ', "Space"));
- hr.setIconCls(getCssName(imgResources.hfixedline()));
- hr.setParentMenuTitle(i18n.t(INSERT_MENU));
- hr.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, 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 ActionShortcut(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 ActionShortcut(true, '8'));
- ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
- ul.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- insertImageDialog.get().show();
- }
- });
- img.setIconCls(getCssName(imgResources.images()));
- img.setToolTip(i18n.t("Insert Image"));
- img.setAddCondition(canBeExtended);
-
- ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- deferred.addCommand(new Listener0() {
- public void onEvent() {
- insertElement.show();
- }
- });
- }
- });
- createLink.setIconCls(getCssName(imgResources.link()));
- createLink.setToolTip(i18n.t("Create Link"));
- createLink.setShortcut(new ActionShortcut(true, 'K'));
- createLink.setAddCondition(canBeExtended);
- insertElement.addOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- view.createLink(url);
- fireOnEdit();
- }
- });
-
- ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.unlink();
- fireOnEdit();
- }
- });
- removeLink.setIconCls(getCssName(imgResources.linkbreak()));
- removeLink.setToolTip(i18n.t("Remove Link"));
- removeLink.setShortcut(new ActionShortcut(true, true, 'K'));
- removeLink.setAddCondition(canBeExtended);
-
- final ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol,
- sndbar, new Listener0() {
- public void onEvent() {
- view.removeFormat();
- fireOnEdit();
- }
- });
- removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
- removeFormat.setToolTip(i18n.t("Clear Formatting"));
- removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
- removeFormat.setAddCondition(canBeExtended);
- removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
-
- final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
- topbar, new Listener0() {
- public void onEvent() {
- insertSimpleTable();
- }
- });
- insertTable.setIconCls(getCssName(imgResources.inserttable()));
- insertTable.setTextDescription(i18n.t("Insert Table ..."));
- insertTable.setAddCondition(canBeExtended);
- insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
-
- final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
- accessRol, sndbar, new Listener0() {
- public void onEvent() {
- insertSimpleTable();
- }
- });
- 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() {
- palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar,
- removeFormat), new Listener<String>() {
- public void onEvent(String color) {
- palette.hide();
- view.setForeColor(color);
- fireOnEdit();
- }
- });
- }
- });
- 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() {
- palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor),
- new Listener<String>() {
- public void onEvent(String color) {
- palette.hide();
- view.setBackColor(color);
- fireOnEdit();
- }
- });
- }
- });
- backgroundColor.setIconCls(getCssName(imgResources.backcolor()));
- backgroundColor.setToolTip(i18n.t("Text Background Colour"));
- backgroundColor.setAddCondition(canBeBasic);
-
- 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(hr));
- actions.add(withNoItem(subscript));
- actions.add(withNoItem(superscript));
- actions.add(withNoItem(decreaseIndent));
- actions.add(withNoItem(increaseIndent));
- actions.add(withNoItem(ol));
- actions.add(withNoItem(ul));
- actions.add(withNoItem(removeFormat));
- // topActions.add(withNoItem(hrButton));
- actions.add(withNoItem(img));
- actions.add(withNoItem(createLink));
- actions.add(withNoItem(removeLink));
- actions.add(withNoItem(insertTableBtn));
- actions.add(withNoItem(insertTable));
- actions.add(withNoItem(comment));
- actions.add(withNoItem(undoBtn));
- actions.add(withNoItem(redoBtn));
-
- for (String fontName : this.fontNames) {
- ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
- 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));
- }
-
- private ActionToolbarMenuDescriptor<Object> createFontNameAction(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(ActionAddCondition<Object> canBeBasic,
- final int fontSize, String fontSizeName) {
- final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
- new Listener0() {
- public void onEvent() {
- view.setFontSize(fontSizesConstants[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);
- return font;
- }
-
- private int getActionLeftPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
- return bar.getLeftPosition(action);
- }
-
- private int getActionTopPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
- return bar.getTopPosition(action);
- }
-
- private String getCssName(ImageResource imageResource) {
- return RTEImgResources.SUFFIX + imageResource.getName();
- }
-
- private void insertSimpleTable() {
- view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
- + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
- + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
- + "</td>\n" + "</tr>\n</tbody>\n</table>");
- fireOnEdit();
- }
-
- private boolean isExtended() {
- return extended && view.canBeExtended();
- }
-
- private ActionEnableCondition<Object> isInsertHtmlSupported() {
- return new ActionEnableCondition<Object>() {
- public boolean mustBeEnabled(Object param) {
- return true;
- }
- };
- }
-
- private void styleToolbar(ActionToolbar<Object> bar) {
- bar.setNormalStyle();
- }
-
- private ActionItemCollection<Object> withNoItem(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(ActionDescriptor<Object> action) {
- return new ActionItem<Object>(action, null);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,102 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import org.ourproject.kune.platf.client.View;
-import org.ourproject.kune.platf.client.actions.ActionItemCollection;
-import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
-
-public interface RTEditorView extends View {
-
- void addActions(ActionItemCollection<Object> actions);
-
- void addComment(String userName);
-
- void adjustSize(int height);
-
- boolean canBeBasic();
-
- boolean canBeExtended();
-
- void copy();
-
- void createLink(String url);
-
- void cut();
-
- void delete();
-
- void focus();
-
- String getHtml();
-
- String getText();
-
- void insertHorizontalRule();
-
- void insertHtml(String html);
-
- void insertImage(String url);
-
- void insertOrderedList();
-
- void insertUnorderedList();
-
- boolean isAttached();
-
- boolean isBold();
-
- boolean isItalic();
-
- 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 setBackColor(String color);
-
- void setFontName(String name);
-
- void setFontSize(FontSize fontSize);
-
- void setForeColor(String color);
-
- void setHtml(String html);
-
- void setText(String text);
-
- 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/TestRTEDialog.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/TestRTEDialog.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -2,6 +2,9 @@
import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPanel;
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.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;
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbar.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+
+public interface RTEActionSndToolbar extends ActionToolbar<Object> {
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionSndToolbarPresenter.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionSndToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,12 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
+
+public class RTEActionSndToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionSndToolbar {
+
+ public RTEActionSndToolbarPresenter(ActionToolbarView<Object> toolbar) {
+ super(toolbar);
+ }
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbar.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
+
+public interface RTEActionTopToolbar extends ActionToolbar<Object> {
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java (from rev 1055, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEActionTopToolbarPresenter.java 2009-03-03 01:35:36 UTC (rev 1055)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEActionTopToolbarPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,12 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarPresenter;
+import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbarView;
+
+public class RTEActionTopToolbarPresenter extends ActionToolbarPresenter<Object> implements RTEActionTopToolbar {
+
+ public RTEActionTopToolbarPresenter(ActionToolbarView<Object> toolbar) {
+ super(toolbar);
+ }
+
+}
\ No newline at end of file
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEcanBeBasic.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEcanBeBasic.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.actions.ActionAddCondition;
+
+public class RTEcanBeBasic implements ActionAddCondition<Object> {
+ public boolean mustBeAdded(Object param) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditor.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,46 @@
+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 {
+
+ public final ActionToolbarPosition topbar = new ActionToolbarPosition("rte-topbar");
+ public final ActionToolbarPosition sndbar = new ActionToolbarPosition("rte-sndbar");;
+
+ void addAction(ActionDescriptor<Object> action);
+
+ void addActions(ActionCollection<Object> actions);
+
+ void addOnEditListener(Listener0 listener);
+
+ void attach();
+
+ ActionAddCondition<Object> canBeBasic();
+
+ ActionAddCondition<Object> canBeExtended();
+
+ View getEditorArea();
+
+ String getHtml();
+
+ ActionToolbar<Object> getSndBar();
+
+ String getText();
+
+ ActionToolbar<Object> getTopBar();
+
+ void reset();
+
+ void setExtended(boolean extended);
+
+ void setHtml(String html);
+
+ void setText(String text);
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPanel.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,319 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import java.util.Date;
+import java.util.HashMap;
+
+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.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
+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 com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.dom.client.Element;
+import com.google.gwt.user.client.DOM;
+import com.google.gwt.user.client.ui.ChangeListener;
+import com.google.gwt.user.client.ui.ClickListener;
+import com.google.gwt.user.client.ui.FocusListener;
+import com.google.gwt.user.client.ui.KeyboardListener;
+import com.google.gwt.user.client.ui.Widget;
+
+public class RTEditorPanel implements RTEditorView {
+
+ private class EventListener implements ClickListener, ChangeListener, KeyboardListener, FocusListener {
+
+ public void onChange(Widget sender) {
+ presenter.fireOnEdit();
+ }
+
+ public void onClick(Widget sender) {
+ if (sender == rta) {
+ // We use the RichTextArea's onKeyUp event to update the
+ // toolbar status. This will catch any cases where the user
+ // moves the cursor using the keyboard, or uses one of the
+ // browser's built-in keyboard shortcuts.
+ updateStatus();
+ }
+ }
+
+ public void onFocus(Widget sender) {
+ presenter.onEditorFocus();
+ }
+
+ public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
+ }
+
+ public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
+ }
+
+ public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
+ if (sender == rta) {
+ // We use the RichTextArea's onKeyUp event to update the
+ // toolbar status.
+ // This will catch any cases where the user moves the cursor
+ // using the keyboard, or uses one of the browser's built-in
+ // keyboard shortcuts.
+
+ updateStatus();
+ fireEdit();
+ if (modifiers != 0) {
+ Log.debug("RTE shortcut pressed (" + modifiers + ", " + keyCode + ")");
+ ActionItem<Object> actionItem = shortcuts.get(new ActionShortcut(keyCode, modifiers));
+ if (actionItem != null) {
+ actionManager.doAction(actionItem);
+ updateStatus();
+ } else {
+ Log.debug("...but not mapped to any action");
+ }
+ }
+ }
+ }
+
+ public void onLostFocus(Widget sender) {
+
+ }
+ }
+ private final I18nUITranslationService i18n;
+ private final RichTextArea rta;
+ private final BasicFormatter basic;
+ private final ExtendedFormatter extended;
+ private final HashMap<ActionShortcut, ActionItem<Object>> shortcuts;
+ private final ActionManager actionManager;
+ private final RTEditorPresenter presenter;
+
+ public RTEditorPanel(final RTEditorPresenter presenter, I18nUITranslationService i18n, ActionManager actionManager) {
+ this.presenter = presenter;
+ this.i18n = i18n;
+ this.actionManager = actionManager;
+ rta = new RichTextArea();
+ basic = rta.getBasicFormatter();
+ extended = rta.getExtendedFormatter();
+ shortcuts = new HashMap<ActionShortcut, ActionItem<Object>>();
+ EventListener listener = new EventListener();
+ rta.addClickListener(listener);
+ rta.addKeyboardListener(listener);
+ rta.addFocusListener(listener);
+ rta.setWidth("96%");
+ rta.setHeight("100%");
+ }
+
+ public void addActions(ActionItemCollection<Object> actionItems) {
+ for (ActionItem<Object> actionItem : actionItems) {
+ ActionDescriptor<Object> action = actionItem.getAction();
+ if (action.hasShortcut() && action.mustBeAdded(null)) {
+ ActionShortcut shortcut = action.getShortcut();
+ shortcuts.put(shortcut, actionItem);
+ }
+ }
+ }
+
+ public void addComment(String userName) {
+ String time = i18n.formatDateWithLocale(new Date(), true);
+ Element span = DOM.createSpan();
+ span.setInnerHTML("<em>" + i18n.t("type your comment here") + "</em> -" + userName + " " + time);
+ DOM.setElementProperty(span.<com.google.gwt.user.client.Element> cast(), "className", "k-rte-comment");
+ insertHtml(" " + span.getString() + " ");
+ }
+
+ public void adjustSize(int height) {
+ rta.setHeight("" + height);
+ }
+
+ public boolean canBeBasic() {
+ return basic != null;
+ }
+
+ public boolean canBeExtended() {
+ return extended != null;
+ }
+
+ public void copy() {
+ extended.copy();
+ }
+
+ public void createLink(String url) {
+ extended.createLink(url);
+ }
+
+ public void cut() {
+ extended.cut();
+ }
+
+ public void delete() {
+ extended.delete();
+ }
+
+ public void focus() {
+ rta.setFocus(true);
+ }
+
+ public String getHtml() {
+ return rta.getHTML();
+ }
+
+ public Widget getRTE() {
+ return rta;
+ }
+
+ public String getText() {
+ return rta.getText();
+ }
+
+ public void insertHorizontalRule() {
+ extended.insertHorizontalRule();
+ }
+
+ public void insertHtml(String html) {
+ extended.insertHtml(html);
+ }
+
+ public void insertImage(String url) {
+ extended.insertImage(url);
+ }
+
+ public void insertOrderedList() {
+ extended.insertOrderedList();
+ }
+
+ public void insertUnorderedList() {
+ extended.insertUnorderedList();
+ }
+
+ public boolean isAttached() {
+ return rta.isAttached();
+ }
+
+ public boolean isBold() {
+ return basic.isBold();
+ }
+
+ public boolean isItalic() {
+ return basic.isItalic();
+ }
+
+ 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 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 setBackColor(String color) {
+ basic.setBackColor(color);
+ }
+
+ public void setFontName(String name) {
+ basic.setFontName(name);
+ }
+
+ public void setFontSize(FontSize size) {
+ basic.setFontSize(size);
+ }
+
+ public void setForeColor(String color) {
+ basic.setForeColor(color);
+ }
+
+ public void setHtml(String html) {
+ rta.setHTML(html);
+ }
+
+ public void setText(String text) {
+ rta.setText(text);
+ }
+
+ 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();
+ }
+
+ /**
+ * 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 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,762 @@
+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.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.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.state.Session;
+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.EditHtml;
+import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
+import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
+
+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.events.Listener2;
+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", "Small", "Medium", "Large", "Very large",
+ "Extra large" };
+ private static final RichTextArea.FontSize[] fontSizesConstants = 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 TextEditorInsertElement insertElement;
+ private final ColorWebSafePalette palette;
+ private final DeferredCommandWrapper deferred;
+ private final ActionAddCondition<Object> canBeBasic;
+ private final ActionAddCondition<Object> canBeExtended;
+ private final Provider<EditHtml> editHtmlDialog;
+ private final Provider<InsertImage> insertImageDialog;
+
+ public RTEditorPresenter(I18nTranslationService i18n, Session session, RTEActionTopToolbar topBar,
+ RTEActionSndToolbar sndBar, RTEImgResources imgResources, TextEditorInsertElement textEditorInsertElement,
+ ColorWebSafePalette palette, Provider<EditHtml> editHtmlDialog, Provider<InsertImage> insertImageDialog,
+ DeferredCommandWrapper deferred) {
+ this.i18n = i18n;
+ this.session = session;
+ this.topBar = topBar;
+ this.sndBar = sndBar;
+ this.insertElement = textEditorInsertElement;
+ this.palette = palette;
+ this.editHtmlDialog = editHtmlDialog;
+ this.insertImageDialog = insertImageDialog;
+ 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(Object param) {
+ return view.canBeBasic();
+ }
+ };
+ canBeExtended = new ActionAddCondition<Object>() {
+ public boolean mustBeAdded(Object param) {
+ return isExtended();
+ }
+ };
+ }
+
+ public void addAction(ActionDescriptor<Object> action) {
+ actions.add(withNoItem(action));
+ }
+
+ public void addActions(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 canBeBasic();
+ }
+
+ public ActionAddCondition<Object> canBeExtended() {
+ return canBeExtended();
+ }
+
+ 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(RTEditorView view) {
+ this.view = view;
+ createBasicActions();
+ }
+
+ public void onEditorFocus() {
+ topBar.hideAllMenus();
+ sndBar.hideAllMenus();
+ palette.hide();
+ }
+
+ public void reset() {
+ topBar.clear();
+ sndBar.clear();
+ }
+
+ public void setExtended(boolean extended) {
+ this.extended = extended;
+ }
+
+ public void setHtml(String html) {
+ view.setHtml(html);
+ view.focus();
+ }
+
+ public void setText(String text) {
+ view.setText(text);
+ view.focus();
+ }
+
+ public void updateStatus() {
+ if (view.canBeBasic()) {
+ sndBar.setPushButtonPressed(bold, view.isBold());
+ 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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(true, '0'));
+ 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 ActionShortcut(true, '9'));
+ 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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(true, 'R'));
+ justifyRight.setAddCondition(canBeBasic);
+
+ ActionToolbarMenuDescriptor<Object> undo = new ActionToolbarMenuDescriptor<Object>(accessRol, topbar,
+ new Listener0() {
+ public void onEvent() {
+ view.undo();
+ fireOnEdit();
+ }
+ });
+ undo.setShortcut(new ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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 ActionShortcut(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() {
+ EditHtml dialog = editHtmlDialog.get();
+ dialog.setUpdateListener(new Listener<String>() {
+ public void onEvent(String html) {
+ view.setHtml(html);
+ fireOnEdit();
+ }
+ });
+ dialog.show();
+ 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() {
+ view.focus();
+ String author = session.isLogged() ? session.getCurrentUser().getShortName()
+ : i18n.t("anonymous user");
+ view.addComment(author);
+ fireOnEdit();
+ }
+ });
+ comment.setEnableCondition(new ActionEnableCondition<Object>() {
+ public boolean mustBeEnabled(Object param) {
+ return session.isLogged();
+ }
+ });
+ comment.setShortcut(new ActionShortcut(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 ActionShortcut(true, true, ' ', "Space"));
+ hr.setIconCls(getCssName(imgResources.hfixedline()));
+ hr.setParentMenuTitle(i18n.t(INSERT_MENU));
+ hr.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> hrButton = new ActionToolbarButtonDescriptor<Object>(accessRol, 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 ActionShortcut(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 ActionShortcut(true, '8'));
+ ul.setRightSeparator(ActionToolbarButtonSeparator.separator);
+ ul.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> img = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ insertImageDialog.get().show();
+ }
+ });
+ img.setIconCls(getCssName(imgResources.images()));
+ img.setToolTip(i18n.t("Insert Image"));
+ img.setAddCondition(canBeExtended);
+
+ ActionToolbarButtonDescriptor<Object> createLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ deferred.addCommand(new Listener0() {
+ public void onEvent() {
+ insertElement.show();
+ }
+ });
+ }
+ });
+ createLink.setIconCls(getCssName(imgResources.link()));
+ createLink.setToolTip(i18n.t("Create Link"));
+ createLink.setShortcut(new ActionShortcut(true, 'K'));
+ createLink.setAddCondition(canBeExtended);
+ insertElement.addOnCreateLink(new Listener2<String, String>() {
+ public void onEvent(String name, String url) {
+ view.createLink(url);
+ fireOnEdit();
+ }
+ });
+
+ ActionToolbarButtonDescriptor<Object> removeLink = new ActionToolbarButtonDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.unlink();
+ fireOnEdit();
+ }
+ });
+ removeLink.setIconCls(getCssName(imgResources.linkbreak()));
+ removeLink.setToolTip(i18n.t("Remove Link"));
+ removeLink.setShortcut(new ActionShortcut(true, true, 'K'));
+ removeLink.setAddCondition(canBeExtended);
+
+ final ActionToolbarButtonDescriptor<Object> removeFormat = new ActionToolbarButtonDescriptor<Object>(accessRol,
+ sndbar, new Listener0() {
+ public void onEvent() {
+ view.removeFormat();
+ fireOnEdit();
+ }
+ });
+ removeFormat.setIconCls(getCssName(imgResources.removeFormat()));
+ removeFormat.setToolTip(i18n.t("Clear Formatting"));
+ removeFormat.setShortcut(new ActionShortcut(true, ' ', "Space"));
+ removeFormat.setAddCondition(canBeExtended);
+ removeFormat.setRightSeparator(ActionToolbarButtonSeparator.separator);
+
+ final ActionToolbarMenuDescriptor<Object> insertTable = new ActionToolbarMenuDescriptor<Object>(accessRol,
+ topbar, new Listener0() {
+ public void onEvent() {
+ insertSimpleTable();
+ }
+ });
+ insertTable.setIconCls(getCssName(imgResources.inserttable()));
+ insertTable.setTextDescription(i18n.t("Insert Table ..."));
+ insertTable.setAddCondition(canBeExtended);
+ insertTable.setParentMenuTitle(i18n.t(INSERT_MENU));
+
+ final ActionToolbarButtonDescriptor<Object> insertTableBtn = new ActionToolbarButtonDescriptor<Object>(
+ accessRol, sndbar, new Listener0() {
+ public void onEvent() {
+ insertSimpleTable();
+ }
+ });
+ 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() {
+ palette.show(getActionLeftPosition(sndBar, removeFormat), getActionTopPosition(sndBar,
+ removeFormat), new Listener<String>() {
+ public void onEvent(String color) {
+ palette.hide();
+ view.setForeColor(color);
+ fireOnEdit();
+ }
+ });
+ }
+ });
+ 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() {
+ palette.show(getActionLeftPosition(sndBar, fontColor), getActionTopPosition(sndBar, fontColor),
+ new Listener<String>() {
+ public void onEvent(String color) {
+ palette.hide();
+ view.setBackColor(color);
+ fireOnEdit();
+ }
+ });
+ }
+ });
+ backgroundColor.setIconCls(getCssName(imgResources.backcolor()));
+ backgroundColor.setToolTip(i18n.t("Text Background Colour"));
+ backgroundColor.setAddCondition(canBeBasic);
+
+ 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(hr));
+ actions.add(withNoItem(subscript));
+ actions.add(withNoItem(superscript));
+ actions.add(withNoItem(decreaseIndent));
+ actions.add(withNoItem(increaseIndent));
+ actions.add(withNoItem(ol));
+ actions.add(withNoItem(ul));
+ actions.add(withNoItem(removeFormat));
+ // topActions.add(withNoItem(hrButton));
+ actions.add(withNoItem(img));
+ actions.add(withNoItem(createLink));
+ actions.add(withNoItem(removeLink));
+ actions.add(withNoItem(insertTableBtn));
+ actions.add(withNoItem(insertTable));
+ actions.add(withNoItem(comment));
+ actions.add(withNoItem(undoBtn));
+ actions.add(withNoItem(redoBtn));
+
+ for (String fontName : this.fontNames) {
+ ActionToolbarMenuDescriptor<Object> fontNameAction = createFontNameAction(canBeBasic, fontName);
+ 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));
+ }
+
+ private ActionToolbarMenuDescriptor<Object> createFontNameAction(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(ActionAddCondition<Object> canBeBasic,
+ final int fontSize, String fontSizeName) {
+ final ActionToolbarMenuDescriptor<Object> font = new ActionToolbarMenuDescriptor<Object>(accessRol, sndbar,
+ new Listener0() {
+ public void onEvent() {
+ view.setFontSize(fontSizesConstants[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);
+ return font;
+ }
+
+ private int getActionLeftPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
+ return bar.getLeftPosition(action);
+ }
+
+ private int getActionTopPosition(ActionToolbar<Object> bar, ActionToolbarButtonDescriptor<Object> action) {
+ return bar.getTopPosition(action);
+ }
+
+ private String getCssName(ImageResource imageResource) {
+ return RTEImgResources.SUFFIX + imageResource.getName();
+ }
+
+ private void insertSimpleTable() {
+ view.insertHtml("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">\n" + "<tbody>\n"
+ + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n" + "</td>\n"
+ + "</tr>\n" + "<tr>\n" + "<td width=\"50%\"><br>\n" + "</td>\n" + "<td width=\"50%\"><br>\n"
+ + "</td>\n" + "</tr>\n</tbody>\n</table>");
+ fireOnEdit();
+ }
+
+ private boolean isExtended() {
+ return extended && view.canBeExtended();
+ }
+
+ private ActionEnableCondition<Object> isInsertHtmlSupported() {
+ return new ActionEnableCondition<Object>() {
+ public boolean mustBeEnabled(Object param) {
+ return true;
+ }
+ };
+ }
+
+ private void styleToolbar(ActionToolbar<Object> bar) {
+ bar.setNormalStyle();
+ }
+
+ private ActionItemCollection<Object> withNoItem(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(ActionDescriptor<Object> action) {
+ return new ActionItem<Object>(action, null);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java (from rev 1064, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTEditorView.java 2009-03-10 00:05:50 UTC (rev 1064)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/basic/RTEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,102 @@
+package org.ourproject.kune.platf.client.ui.rte.basic;
+
+import org.ourproject.kune.platf.client.View;
+import org.ourproject.kune.platf.client.actions.ActionItemCollection;
+import org.ourproject.kune.platf.client.ui.rte.RichTextArea.FontSize;
+
+public interface RTEditorView extends View {
+
+ void addActions(ActionItemCollection<Object> actions);
+
+ void addComment(String userName);
+
+ void adjustSize(int height);
+
+ boolean canBeBasic();
+
+ boolean canBeExtended();
+
+ void copy();
+
+ void createLink(String url);
+
+ void cut();
+
+ void delete();
+
+ void focus();
+
+ String getHtml();
+
+ String getText();
+
+ void insertHorizontalRule();
+
+ void insertHtml(String html);
+
+ void insertImage(String url);
+
+ void insertOrderedList();
+
+ void insertUnorderedList();
+
+ boolean isAttached();
+
+ boolean isBold();
+
+ boolean isItalic();
+
+ 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 setBackColor(String color);
+
+ void setFontName(String name);
+
+ void setFontSize(FontSize fontSize);
+
+ void setForeColor(String color);
+
+ void setHtml(String html);
+
+ void setText(String text);
+
+ void toggleBold();
+
+ void toggleItalic();
+
+ void toggleStrikethrough();
+
+ void toggleSubscript();
+
+ void toggleSuperscript();
+
+ void toggleUnderline();
+
+ void undo();
+
+ void unlink();
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExt.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,5 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+public interface InsertImageExt {
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,61 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.ui.TextUtils;
+import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageView;
+
+import com.gwtext.client.core.EventObject;
+import com.gwtext.client.widgets.Button;
+import com.gwtext.client.widgets.PaddedPanel;
+import com.gwtext.client.widgets.Panel;
+import com.gwtext.client.widgets.event.ButtonListenerAdapter;
+import com.gwtext.client.widgets.form.TextField;
+import com.gwtext.client.widgets.layout.FitLayout;
+
+public class InsertImageExtPanel extends DefaultForm implements InsertImageExtView {
+
+ private static final String LINK_FIELD = "iiep-img-field";
+ private final TextField linkField;
+ private final Panel previewPanel;
+
+ public InsertImageExtPanel(final InsertImageExtPresenter presenter, I18nTranslationService i18n) {
+ super(i18n.t("External image"));
+ super.setAutoWidth(true);
+ super.setHeight(InsertImageView.HEIGHT);
+ linkField = new TextField();
+ linkField.setTabIndex(1);
+ linkField.setFieldLabel(i18n.t("External image link (URL)"));
+ linkField.setRegex(TextUtils.URL_REGEXP);
+ linkField.setRegexText(i18n.t("The link should be a URL in the format 'http://www.domain.com'"));
+ linkField.setName(LINK_FIELD);
+ linkField.setWidth(DEF_FIELD_WIDTH);
+ linkField.setAllowBlank(false);
+ linkField.setMinLength(3);
+ linkField.setMaxLength(250);
+ linkField.setValidationEvent(false);
+ linkField.setId(LINK_FIELD);
+ add(linkField);
+ previewPanel = new Panel();
+ previewPanel.setLayout(new FitLayout());
+ previewPanel.setHeight(125);
+ add(new PaddedPanel(previewPanel, 0));
+ Button preview = new Button(i18n.t("Preview"));
+ preview.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onPreview();
+ }
+ });
+ addButton(preview);
+
+ Button insert = new Button(i18n.t("Insert"));
+ insert.addListener(new ButtonListenerAdapter() {
+ @Override
+ public void onClick(Button button, EventObject e) {
+ presenter.onInsert();
+ }
+ });
+ addButton(insert);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,26 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
+
+public class InsertImageExtPresenter implements InsertImageExt {
+
+ private final InsertImage insertImageDialog;
+
+ public InsertImageExtPresenter(InsertImage insertImageDialog) {
+ this.insertImageDialog = insertImageDialog;
+ }
+
+ public void init(InsertImageExtView view) {
+ insertImageDialog.addOptionTab(view);
+ }
+
+ public void onInsert() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void onPreview() {
+ // TODO Auto-generated method stub
+
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtView.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimg/ext/InsertImageExtView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,7 @@
+package org.ourproject.kune.platf.client.ui.rte.insertimg.ext;
+
+import org.ourproject.kune.platf.client.View;
+
+public interface InsertImageExtView extends View {
+}
+
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExt.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,5 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-public interface InsertImageExt {
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,61 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.TextUtils;
-import org.ourproject.kune.platf.client.ui.dialogs.DefaultForm;
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageView;
-
-import com.gwtext.client.core.EventObject;
-import com.gwtext.client.widgets.Button;
-import com.gwtext.client.widgets.PaddedPanel;
-import com.gwtext.client.widgets.Panel;
-import com.gwtext.client.widgets.event.ButtonListenerAdapter;
-import com.gwtext.client.widgets.form.TextField;
-import com.gwtext.client.widgets.layout.FitLayout;
-
-public class InsertImageExtPanel extends DefaultForm implements InsertImageExtView {
-
- private static final String LINK_FIELD = "iiep-img-field";
- private final TextField linkField;
- private final Panel previewPanel;
-
- public InsertImageExtPanel(final InsertImageExtPresenter presenter, I18nTranslationService i18n) {
- super(i18n.t("External image"));
- super.setAutoWidth(true);
- super.setHeight(InsertImageView.HEIGHT);
- linkField = new TextField();
- linkField.setTabIndex(1);
- linkField.setFieldLabel(i18n.t("External image link (URL)"));
- linkField.setRegex(TextUtils.URL_REGEXP);
- linkField.setRegexText(i18n.t("The link should be a URL in the format 'http://www.domain.com'"));
- linkField.setName(LINK_FIELD);
- linkField.setWidth(DEF_FIELD_WIDTH);
- linkField.setAllowBlank(false);
- linkField.setMinLength(3);
- linkField.setMaxLength(250);
- linkField.setValidationEvent(false);
- linkField.setId(LINK_FIELD);
- add(linkField);
- previewPanel = new Panel();
- previewPanel.setLayout(new FitLayout());
- previewPanel.setHeight(125);
- add(new PaddedPanel(previewPanel, 0));
- Button preview = new Button(i18n.t("Preview"));
- preview.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onPreview();
- }
- });
- addButton(preview);
-
- Button insert = new Button(i18n.t("Insert"));
- insert.addListener(new ButtonListenerAdapter() {
- @Override
- public void onClick(Button button, EventObject e) {
- presenter.onInsert();
- }
- });
- addButton(insert);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,26 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
-
-public class InsertImageExtPresenter implements InsertImageExt {
-
- private final InsertImage insertImageDialog;
-
- public InsertImageExtPresenter(InsertImage insertImageDialog) {
- this.insertImageDialog = insertImageDialog;
- }
-
- public void init(InsertImageExtView view) {
- insertImageDialog.addOptionTab(view);
- }
-
- public void onInsert() {
- // TODO Auto-generated method stub
-
- }
-
- public void onPreview() {
- // TODO Auto-generated method stub
-
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/insertimgext/InsertImageExtView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,7 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte.insertimgext;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface InsertImageExtView extends View {
-}
-
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,27 @@
+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 com.calclab.suco.client.events.Listener;
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTESavingEditor {
+
+ void edit(String html, Listener<String> onSave, Listener0 onEditCancelled);
+
+ RTEditor getBasicEditor();
+
+ /**
+ * This is use for listen to changes as url changes, window close, and
+ * save/cancel or stop these actions
+ *
+ * @return
+ */
+ BeforeActionListener getBeforeSavingListener();
+
+ void onSavedSuccessful();
+
+ void onSaveFailed();
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPanel.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,14 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.ui.noti.NotifyUser;
+
+import com.calclab.suco.client.events.Listener0;
+
+public class RTESavingEditorPanel implements RTESavingEditorView {
+
+ public void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm,
+ Listener0 onCancel) {
+ NotifyUser.askConfirmation(confirmationTitle, confirmationText, onConfirm, onCancel);
+ }
+
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java (from rev 1069, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,245 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.actions.ActionShortcut;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonDescriptor;
+import org.ourproject.kune.platf.client.actions.ActionToolbarButtonSeparator;
+import org.ourproject.kune.platf.client.actions.ActionToolbarMenuDescriptor;
+import org.ourproject.kune.platf.client.actions.BeforeActionListener;
+import org.ourproject.kune.platf.client.dto.AccessRolDTO;
+import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
+import org.ourproject.kune.platf.client.state.StateManager;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+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;
+
+public class RTESavingEditorPresenter implements RTESavingEditor {
+
+ @Deprecated
+ private static final String FILE_MENU_OPTION = "File";
+ public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
+ public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
+
+ private final RTEditor editor;
+ private final boolean autoSave;
+ private boolean savePending;
+ private boolean saveAndCloseConfirmed;
+ private Listener<String> onSave;
+ private Listener0 onEditCancelled;
+ private final RTEImgResources imgResources;
+ private final TimerWrapper timer;
+ private final DeferredCommandWrapper deferredCommandWrapper;
+ private final I18nTranslationService i18n;
+ private final StateManager stateManager;
+ private final BeforeActionListener beforeStateChangeListener;
+ ActionToolbarButtonDescriptor<Object> saveBtn;
+ private RTESavingEditorView view;
+
+ public RTESavingEditorPresenter(RTEditor editor, final boolean autoSave, final I18nTranslationService i18n,
+ StateManager stateManager, DeferredCommandWrapper deferredCommandWrapper,
+ RTEImgResources imgResources, TimerWrapper timer) {
+ this.editor = editor;
+ this.autoSave = autoSave;
+ this.i18n = i18n;
+ this.stateManager = stateManager;
+ this.deferredCommandWrapper = deferredCommandWrapper;
+ this.imgResources = imgResources;
+ this.savePending = false;
+ this.saveAndCloseConfirmed = false;
+ createActions();
+ this.timer = timer;
+ timer.configure(new Listener0() {;
+
+ public void onEvent() {
+ onAutoSave();
+ }
+ });
+ editor.addOnEditListener(new Listener0() {
+ public void onEvent() {
+ onEdit();
+ }
+ });
+ beforeStateChangeListener = new BeforeActionListener() {
+ public boolean beforeAction() {
+ return beforeTokenChange();
+ }
+ };
+ }
+
+ public void edit(String html, Listener<String> onSave, Listener0 onEditCancelled) {
+ this.onSave = onSave;
+ this.onEditCancelled = onEditCancelled;
+ editor.setHtml(html);
+ editor.attach();
+ stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
+ enableSaveBtn(false);
+ }
+
+ public RTEditor getBasicEditor() {
+ return editor;
+ }
+
+ public BeforeActionListener getBeforeSavingListener() {
+ return beforeStateChangeListener;
+ }
+
+ public void init(RTESavingEditorView view) {
+ this.view = view;
+ }
+
+ public void onDoSaveAndClose() {
+ saveAndCloseConfirmed = true;
+ onDoSave();
+ }
+
+ public void onSavedSuccessful() {
+ if (saveAndCloseConfirmed) {
+ onCancelConfirmed();
+ } else {
+ reset();
+ }
+ }
+
+ public void onSaveFailed() {
+ timer.schedule(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
+ if (saveAndCloseConfirmed) {
+ saveAndCloseConfirmed = false;
+ }
+ }
+
+ protected void onAutoSave() {
+ onDoSave();
+ }
+
+ protected void onCancel() {
+ if (savePending) {
+ timer.cancel();
+ Listener0 onYes = new Listener0() {
+ public void onEvent() {
+ onDoSaveAndClose();
+ }
+ };
+ Listener0 onCancel = new Listener0() {
+ public void onEvent() {
+ onCancelConfirmed();
+ }
+ };
+ view.askConfirmation(i18n.t("Save confirmation"),
+ i18n.t("Do you want to save before closing the editor?"), onYes, onCancel);
+ } else {
+ onCancelConfirmed();
+ }
+ }
+
+ protected void onCancelConfirmed() {
+ stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
+ stateManager.resumeTokenChange();
+ reset();
+ editor.reset();
+ onDoEditCancelled();
+ }
+
+ protected void onDoSave() {
+ onSave.onEvent(editor.getHtml());
+ }
+
+ boolean beforeTokenChange() {
+ if (savePending) {
+ onCancel();
+ return false;
+ } else {
+ deferredCommandWrapper.addCommand(new Listener0() {
+ public void onEvent() {
+ onCancelConfirmed();
+ }
+ });
+ return true;
+ }
+ }
+
+ void onEdit() {
+ if (!savePending) {
+ savePending = true;
+ if (autoSave) {
+ timer.schedule(AUTOSAVE_IN_MILLISECONDS);
+ }
+ enableSaveBtn(true);
+ }
+ }
+
+ private void createActions() {
+ Listener0 onPerformSaveCall = new Listener0() {
+ public void onEvent() {
+ onDoSave();
+ }
+ };
+ saveBtn = new ActionToolbarButtonDescriptor<Object>(AccessRolDTO.Editor, RTEditor.sndbar, onPerformSaveCall);
+ saveBtn.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
+ saveBtn.setToolTip(i18n.t("Save"));
+ saveBtn.setShortcut(new ActionShortcut(true, 'S'));
+ saveBtn.setPosition(0);
+
+ ActionToolbarMenuDescriptor<Object> save = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
+ RTEditor.topbar, onPerformSaveCall);
+ save.setIconCls(RTEImgResources.SUFFIX + imgResources.save().getName());
+ save.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
+ save.setTextDescription(i18n.t("Save"));
+ save.setShortcut(new ActionShortcut(true, 'S'));
+ save.setPosition(0);
+
+ ActionToolbarMenuDescriptor<Object> close = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
+ RTEditor.topbar, new Listener<Object>() {
+ public void onEvent(Object parameter) {
+ onCancel();
+ }
+ });
+ close.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
+ close.setTextDescription(i18n.t("Close"));
+
+ Listener0 onPerformSaveAndCloseCall = new Listener0() {
+ public void onEvent() {
+ if (savePending) {
+ timer.cancel();
+ onDoSaveAndClose();
+ } else {
+ onCancelConfirmed();
+ }
+ }
+ };
+ ActionToolbarMenuDescriptor<Object> saveclose = new ActionToolbarMenuDescriptor<Object>(AccessRolDTO.Editor,
+ RTEditor.topbar, onPerformSaveAndCloseCall);
+ saveclose.setParentMenuTitle(i18n.t(FILE_MENU_OPTION));
+ saveclose.setTextDescription(i18n.t("Save & Close"));
+
+ ActionToolbarButtonDescriptor<Object> saveCloseBtn = new ActionToolbarButtonDescriptor<Object>(
+ AccessRolDTO.Editor, RTEditor.topbar, onPerformSaveAndCloseCall);
+ // saveCloseBtn.setIconCls(RTEImgResources.SUFFIX +
+ // imgResources.save().getName());
+ saveCloseBtn.setTextDescription(i18n.t("Save & Close"));
+ saveCloseBtn.setLeftSeparator(ActionToolbarButtonSeparator.fill);
+
+ editor.addAction(save);
+ editor.addAction(saveclose);
+ editor.addAction(close);
+ editor.addAction(saveBtn);
+ editor.addAction(saveCloseBtn);
+ }
+
+ private void enableSaveBtn(boolean enable) {
+ editor.getSndBar().setButtonEnable(saveBtn, enable);
+ }
+
+ private void onDoEditCancelled() {
+ onEditCancelled.onEvent();
+ }
+
+ private void reset() {
+ timer.cancel();
+ savePending = false;
+ saveAndCloseConfirmed = false;
+ enableSaveBtn(false);
+ }
+}
Copied: trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java (from rev 1066, trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java)
===================================================================
--- trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorView.java 2009-03-10 13:43:43 UTC (rev 1066)
+++ trunk/src/main/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,10 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import org.ourproject.kune.platf.client.View;
+
+import com.calclab.suco.client.events.Listener0;
+
+public interface RTESavingEditorView extends View {
+
+ void askConfirmation(String confirmationTitle, String confirmationText, Listener0 onConfirm, Listener0 onCancel);
+}
Modified: trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/KuneWorkspaceModule.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -46,14 +46,14 @@
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.rte.RTESavingEditorPanel;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
import org.ourproject.kune.platf.client.ui.rte.TestRTEDialog;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
import org.ourproject.kune.platf.client.ui.rte.img.RTEImgResources;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImage;
import org.ourproject.kune.platf.client.ui.rte.insertimg.InsertImageGroup;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElement;
import org.ourproject.kune.platf.client.ui.rte.insertlink.TextEditorInsertElementGroup;
+import org.ourproject.kune.platf.client.ui.rte.saving.RTESavingEditorPanel;
import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
import org.ourproject.kune.platf.client.utils.TimerWrapper;
import org.ourproject.kune.workspace.client.cnt.ActionContentToolbar;
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-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/ContentEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -4,11 +4,11 @@
import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
import org.ourproject.kune.platf.client.state.StateManager;
import org.ourproject.kune.platf.client.ui.AbstractToolbar;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorPresenter;
-import org.ourproject.kune.platf.client.ui.rte.RTESavingEditorView;
-import org.ourproject.kune.platf.client.ui.rte.RTEditor;
-import org.ourproject.kune.platf.client.ui.rte.RTEditorPanel;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditor;
+import org.ourproject.kune.platf.client.ui.rte.basic.RTEditorPanel;
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;
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditor.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,33 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public interface TextEditor {
-
- void editContent(String content, Listener<String> onSave, Listener0 onEditCancelled);
-
- void onSavedSuccessful();
-
- void onSaveFailed();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorImages.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,96 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.ImageBundle;
-
-public interface TextEditorImages extends ImageBundle {
-
- @Resource("alignleft.png")
- AbstractImagePrototype alignleft();
-
- @Resource("alignright.png")
- AbstractImagePrototype alignright();
-
- @Resource("backcolor.png")
- AbstractImagePrototype backcolor();
-
- @Resource("bold.png")
- AbstractImagePrototype bold();
-
- @Resource("centerpara.png")
- AbstractImagePrototype centerpara();
-
- @Resource("charfontname.png")
- AbstractImagePrototype charfontname();
-
- @Resource("decrementindent.png")
- AbstractImagePrototype decrementindent();
-
- @Resource("defaultbullet.png")
- AbstractImagePrototype defaultbullet();
-
- @Resource("defaultnumbering.png")
- AbstractImagePrototype defaultnumbering();
-
- @Resource("edithtml.png")
- AbstractImagePrototype edithtml();
-
- @Resource("fontcolor.png")
- AbstractImagePrototype fontcolor();
-
- @Resource("fontheight.png")
- AbstractImagePrototype fontheight();
-
- @Resource("hfixedline.png")
- AbstractImagePrototype hfixedline();
-
- @Resource("images.png")
- AbstractImagePrototype images();
-
- @Resource("incrementindent.png")
- AbstractImagePrototype incrementindent();
-
- @Resource("italic.png")
- AbstractImagePrototype italic();
-
- @Resource("link.png")
- AbstractImagePrototype link();
-
- @Resource("link_break.png")
- AbstractImagePrototype linkBreak();
-
- @Resource("removeFormat.png")
- AbstractImagePrototype removeFormat();
-
- @Resource("strikeout.png")
- AbstractImagePrototype strikeout();
-
- @Resource("subscript.png")
- AbstractImagePrototype subscript();
-
- @Resource("superscript.png")
- AbstractImagePrototype superscript();
-
- @Resource("underline.png")
- AbstractImagePrototype underline();
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPanel.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,155 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-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.insertlink.TextEditorInsertElement;
-import org.ourproject.kune.workspace.client.skel.Toolbar;
-import org.ourproject.kune.workspace.client.skel.WorkspaceSkeleton;
-
-import com.google.gwt.user.client.DOM;
-import com.google.gwt.user.client.Timer;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.gwtext.client.widgets.BoxComponent;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.event.ContainerListenerAdapter;
-
-public class TextEditorPanel implements TextEditorView {
- private static final String BACKCOLOR_ENABLED = "#FFF";
- private static final String BACKCOLOR_DISABLED = "#CCC";
- public static final String TEXT_AREA = "k-tep-ta";
- private final RichTextArea gwtRTarea;
- private final TextEditorToolbar textEditorToolbar;
- private final TextEditorPresenter presenter;
- private final Timer saveTimer;
- private final I18nTranslationService i18n;
- private final VerticalPanel mainPanel;
- private final WorkspaceSkeleton ws;
-
- public TextEditorPanel(final TextEditorPresenter presenter, final I18nTranslationService i18n,
- final WorkspaceSkeleton ws, final ColorWebSafePalette colorPalette,
- final TextEditorInsertElement textEditorInsertElement, boolean permitHtmlButton) {
- this.presenter = presenter;
- this.i18n = i18n;
- this.ws = ws;
- mainPanel = new VerticalPanel();
- mainPanel.setWidth("100%");
-
- gwtRTarea = new RichTextArea();
- gwtRTarea.setWidth("96%");
- gwtRTarea.setHeight("100%");
- gwtRTarea.addStyleName("kune-TexEditorPanel-TextArea");
- gwtRTarea.ensureDebugId(TEXT_AREA);
-
- final Toolbar editorTopBar = new Toolbar();
- editorTopBar.getPanel().setWidth("auto");
- textEditorToolbar = new TextEditorToolbar(gwtRTarea, presenter, colorPalette, i18n, permitHtmlButton,
- textEditorInsertElement);
- editorTopBar.add(textEditorToolbar);
- editorTopBar.addStyleName("k-toolbar-bottom-line");
-
- mainPanel.add(editorTopBar.getPanel());
- mainPanel.add(gwtRTarea);
-
- adjustSize(ws.getEntityWorkspace().getContentHeight());
- ws.getEntityWorkspace().addContentListener(new ContainerListenerAdapter() {
- @Override
- public void onResize(final BoxComponent component, final int adjWidth, final int adjHeight,
- final int rawWidth, final int rawHeight) {
- adjustSize(adjHeight);
- }
- });
-
- saveTimer = new Timer() {
- @Override
- public void run() {
- presenter.onSave();
- }
- };
- }
-
- public void attach() {
- ws.getEntityWorkspace().setContent(mainPanel);
- }
-
- public void detach() {
- mainPanel.removeFromParent();
- }
-
- public void editHTML(final boolean edit) {
- textEditorToolbar.editHTML(edit);
- }
-
- public String getHTML() {
- return gwtRTarea.getHTML();
- }
-
- public String getText() {
- return gwtRTarea.getText();
- }
-
- public void saveTimerCancel() {
- saveTimer.cancel();
- }
-
- public void scheduleSave(final int delayMillis) {
- saveTimer.schedule(delayMillis);
- }
-
- public void setEnabled(final boolean enabled) {
- final String bgColor = enabled ? BACKCOLOR_ENABLED : BACKCOLOR_DISABLED;
- DOM.setStyleAttribute(gwtRTarea.getElement(), "backgroundColor", bgColor);
- gwtRTarea.setEnabled(enabled);
- }
-
- public void setHeight(final String height) {
- gwtRTarea.setHeight(height);
- }
-
- public void setHTML(final String html) {
- gwtRTarea.setHTML(html);
- }
-
- public void setText(final String text) {
- gwtRTarea.setText(text);
- }
-
- public void showSaveBeforeDialog() {
- MessageBox.confirm(i18n.t("Save confirmation"), i18n.t("Do you want to save before closing the editor?"),
- new MessageBox.ConfirmCallback() {
- public void execute(final String btnID) {
- if (btnID.equals("yes")) {
- presenter.onSaveAndClose();
- } else {
- presenter.onCancelConfirmed();
- }
- }
- });
-
- }
-
- private void adjustSize(final int height) {
- int newHeight = height - WorkspaceSkeleton.DEF_TOOLBAR_HEIGHT - 27;
- gwtRTarea.setHeight("" + newHeight);
- mainPanel.setCellHeight(gwtRTarea, "" + newHeight);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorPresenter.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,212 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.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.ActionToolbarMenuDescriptor;
-import org.ourproject.kune.platf.client.actions.BeforeActionListener;
-import org.ourproject.kune.platf.client.actions.toolbar.ActionToolbar;
-import org.ourproject.kune.platf.client.dto.AccessRolDTO;
-import org.ourproject.kune.platf.client.dto.StateToken;
-import org.ourproject.kune.platf.client.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-import org.ourproject.kune.platf.client.utils.DeferredCommandWrapper;
-import org.ourproject.kune.workspace.client.sitebar.sitesign.SiteSignOutLink;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener0;
-
-public class TextEditorPresenter implements TextEditor {
- public static final int AUTOSAVE_AFTER_FAILS_IN_MILLISECONS = 20000;
- public static final int AUTOSAVE_IN_MILLISECONDS = 10000;
- public static final String CLOSE_ID = "k-teditc-close";
- public static final String SAVE_ID = "k-teditp-save";
- private boolean editingHtml;
- private TextEditorView view;
- private boolean savePending;
- private final boolean autoSave;
- private boolean saveAndCloseConfirmed;
- private Listener<String> onSave;
- private Listener0 onEditCancelled;
- private final ActionToolbar<StateToken> topToolbar;
- private ActionToolbarMenuDescriptor<StateToken> save;
- private ActionToolbarButtonDescriptor<StateToken> close;
- private final I18nUITranslationService i18n;
- private final BeforeActionListener beforeStateChangeListener;
- private final StateManager stateManager;
- private final SiteSignOutLink siteSignOutLink;
- private final DeferredCommandWrapper deferredCommandWrapper;
-
- public TextEditorPresenter(final boolean isAutoSave, final ActionToolbar<StateToken> topToolbar,
- final I18nUITranslationService i18n, StateManager stateManager, SiteSignOutLink siteSignOutLink,
- DeferredCommandWrapper deferredCommandWrapper) {
- this.topToolbar = topToolbar;
- this.autoSave = isAutoSave;
- this.i18n = i18n;
- this.stateManager = stateManager;
- this.siteSignOutLink = siteSignOutLink;
- this.deferredCommandWrapper = deferredCommandWrapper;
- this.savePending = false;
- this.editingHtml = false;
- this.saveAndCloseConfirmed = false;
- createActions();
-
- beforeStateChangeListener = new BeforeActionListener() {
- public boolean beforeAction() {
- return beforeTokenChange();
- }
- };
- }
-
- public void editContent(final String content, final Listener<String> onSave, final Listener0 onEditCancelled) {
- this.onSave = onSave;
- this.onEditCancelled = onEditCancelled;
- topToolbar.attach();
- view.attach();
- setContent(content);
- stateManager.addBeforeStateChangeListener(beforeStateChangeListener);
- siteSignOutLink.addBeforeSignOut(beforeStateChangeListener);
- }
-
- public void init(final TextEditorView view) {
- this.view = view;
- this.view.setEnabled(true);
- }
-
- public void onEdit() {
- if (!savePending) {
- savePending = true;
- if (autoSave) {
- view.scheduleSave(AUTOSAVE_IN_MILLISECONDS);
- }
- }
- }
-
- public void onSaveAndClose() {
- saveAndCloseConfirmed = true;
- onSave();
- }
-
- public void onSavedSuccessful() {
- if (saveAndCloseConfirmed) {
- onCancelConfirmed();
- } else {
- reset();
- }
- }
-
- public void onSaveFailed() {
- view.scheduleSave(AUTOSAVE_AFTER_FAILS_IN_MILLISECONS);
- if (saveAndCloseConfirmed) {
- saveAndCloseConfirmed = false;
- }
- }
-
- protected void onCancel() {
- if (savePending) {
- view.saveTimerCancel();
- view.showSaveBeforeDialog();
- } else {
- onCancelConfirmed();
- }
- }
-
- protected void onCancelConfirmed() {
- stateManager.removeBeforeStateChangeListener(beforeStateChangeListener);
- siteSignOutLink.removeBeforeSignOut(beforeStateChangeListener);
- stateManager.resumeTokenChange();
- reset();
- view.detach();
- topToolbar.detach();
- onEditCancelled.onEvent();
- }
-
- protected void onEditHTML() {
- if (editingHtml) {
- // normal editor
- final String html = view.getText();
- view.setHTML(html);
- view.editHTML(false);
- editingHtml = false;
- } else {
- // html editor
- final String html = view.getHTML();
- view.setText(html);
- view.editHTML(true);
- editingHtml = true;
- }
- }
-
- protected void onSave() {
- onSave.onEvent(view.getHTML());
- }
-
- boolean beforeTokenChange() {
- if (savePending) {
- onCancel();
- return false;
- } else {
- deferredCommandWrapper.addCommand(new Listener0() {
- public void onEvent() {
- onCancelConfirmed();
- }
- });
- return true;
- }
- }
-
- private void createActions() {
- save = new ActionToolbarMenuDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- onSave();
- }
- });
- save.setTextDescription(i18n.tWithNT("Save", "used in button"));
- save.setParentMenuTitle(i18n.t("File"));
- save.setId(SAVE_ID);
- // save.setIconUrl("images/");
-
- close = new ActionToolbarButtonDescriptor<StateToken>(AccessRolDTO.Viewer, null, new Listener<StateToken>() {
- public void onEvent(final StateToken token) {
- onCancel();
- }
- });
- close.setTextDescription(i18n.tWithNT("Close", "used in button"));
- close.setId(CLOSE_ID);
- // close.setIconUrl("images/");
-
- final ActionItemCollection<StateToken> collection = new ActionItemCollection<StateToken>();
- collection.add(new ActionItem<StateToken>(save, null));
- collection.add(new ActionItem<StateToken>(close, null));
- topToolbar.addActions(collection, null);
- }
-
- private void reset() {
- view.saveTimerCancel();
- savePending = false;
- saveAndCloseConfirmed = false;
- }
-
- private void setContent(final String html) {
- this.view.setHTML(html);
- }
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorToolbar.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,403 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.i18n.I18nTranslationService;
-import org.ourproject.kune.platf.client.ui.KuneUiUtils;
-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.insertlink.TextEditorInsertElement;
-
-import com.calclab.suco.client.events.Listener;
-import com.calclab.suco.client.events.Listener2;
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.Command;
-import com.google.gwt.user.client.ui.AbstractImagePrototype;
-import com.google.gwt.user.client.ui.ChangeListener;
-import com.google.gwt.user.client.ui.ClickListener;
-import com.google.gwt.user.client.ui.Composite;
-import com.google.gwt.user.client.ui.HorizontalPanel;
-import com.google.gwt.user.client.ui.KeyboardListener;
-import com.google.gwt.user.client.ui.MenuBar;
-import com.google.gwt.user.client.ui.PushButton;
-import com.google.gwt.user.client.ui.ToggleButton;
-import com.google.gwt.user.client.ui.VerticalPanel;
-import com.google.gwt.user.client.ui.Widget;
-import com.gwtext.client.widgets.MessageBox;
-import com.gwtext.client.widgets.MessageBox.PromptCallback;
-
-/**
- * A sample toolbar for use with {@link RichTextArea}. It provides a simple UI
- * for all rich text formatting, dynamically displayed only for the available
- * functionality.
- */
-public class TextEditorToolbar extends Composite {
-
- /**
- * We use an inner EventListener class to avoid exposing event methods on
- * the RichTextToolbar itself.
- */
- private class EventListener implements ClickListener, ChangeListener, KeyboardListener {
-
- public static final String TEXT_EDITOR_TOOLBAR_INS_IMG = "k-textedtol-img";
- private final TextEditorInsertElement insertElement;
-
- public EventListener(TextEditorInsertElement insertElement) {
- this.insertElement = insertElement;
- insertElement.addOnCreateLink(new Listener2<String, String>() {
- public void onEvent(String name, String url) {
- extended.createLink(url);
- }
- });
- }
-
- public void onChange(final Widget sender) {
- fireEdit();
- }
-
- public void onClick(final Widget sender) {
- if (sender == bold) {
- basic.toggleBold();
- } else if (sender == italic) {
- basic.toggleItalic();
- } else if (sender == underline) {
- basic.toggleUnderline();
- } else if (sender == subscript) {
- basic.toggleSubscript();
- } else if (sender == superscript) {
- basic.toggleSuperscript();
- } else if (sender == strikethrough) {
- extended.toggleStrikethrough();
- } else if (sender == indent) {
- extended.rightIndent();
- } else if (sender == outdent) {
- extended.leftIndent();
- } else if (sender == justifyLeft) {
- basic.setJustification(RichTextArea.Justification.LEFT);
- } else if (sender == justifyCenter) {
- basic.setJustification(RichTextArea.Justification.CENTER);
- } else if (sender == justifyRight) {
- basic.setJustification(RichTextArea.Justification.RIGHT);
- } else if (sender == insertImage) {
- showImagePanel();
- } else if (sender == createLink) {
- insertElement.show();
- } else if (sender == backColor) {
- colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
- public void onEvent(final String color) {
- basic.setBackColor(color);
- colorPalette.hide();
- }
- });
- } else if (sender == editHtml) {
- presenter.onEditHTML();
- } else if (sender == fontColor) {
- colorPalette.show(sender.getAbsoluteLeft(), sender.getAbsoluteTop() + 20, new Listener<String>() {
- public void onEvent(final String color) {
- basic.setForeColor(color);
- colorPalette.hide();
- }
- });
- } else if (sender == removeLink) {
- extended.removeLink();
- } else if (sender == hr) {
- extended.insertHorizontalRule();
- } else if (sender == ol) {
- extended.insertOrderedList();
- } else if (sender == ul) {
- extended.insertUnorderedList();
- } else if (sender == removeFormat) {
- extended.removeFormat();
- } else if (sender == richText) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursur
- // using the
- // keyboard, or uses one of the browser's built-in keyboard
- // shortcuts.
- updateStatus();
- }
- if (sender != richText) {
- // some button pressed is equiv to edit
- fireEdit();
- }
- }
-
- public void onKeyDown(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == removeLink && keyCode == KeyboardListener.KEY_ENTER) {
- fireEditHTML();
- }
- }
-
- public void onKeyPress(final Widget sender, final char keyCode, final int modifiers) {
- }
-
- public void onKeyUp(final Widget sender, final char keyCode, final int modifiers) {
- if (sender == richText) {
- // We use the RichTextArea's onKeyUp event to update the
- // toolbar status.
- // This will catch any cases where the user moves the cursor
- // using the keyboard, or uses one of the browser's built-in
- // keyboard shortcuts.
- updateStatus();
- fireEdit();
- }
- }
-
- private void showImagePanel() {
- MessageBox.prompt("Insert image", "Enter an image URL:", new PromptCallback() {
- public void execute(final String btnID, final String text) {
- if (btnID.equals("ok") && text != null) {
- extended.insertImage(text);
- }
- }
- });
-
- }
- }
-
- private static final RichTextArea.FontSize[] fontSizesConstants = 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 final TextEditorImages images = (TextEditorImages) GWT.create(TextEditorImages.class);
- private final EventListener listener;
- private final RichTextArea richText;
- private final RichTextArea.BasicFormatter basic;
- private final RichTextArea.ExtendedFormatter extended;
- private final VerticalPanel outer = new VerticalPanel();
- private final HorizontalPanel topPanel = new HorizontalPanel();
- private ToggleButton bold;
- private ToggleButton italic;
- private ToggleButton underline;
- private ToggleButton subscript;
- private ToggleButton superscript;
- private ToggleButton strikethrough;
- private ToggleButton editHtml;
- private PushButton indent;
- private PushButton outdent;
- private PushButton justifyLeft;
- private PushButton justifyCenter;
- private PushButton justifyRight;
- private PushButton hr;
- private PushButton ol;
- private PushButton ul;
- private PushButton insertImage;
- private PushButton createLink;
- private PushButton removeLink;
- private PushButton removeFormat;
- private PushButton backColor;
- private PushButton fontColor;
- private MenuBar fonts;
- private MenuBar fontSizes;
- private final ColorWebSafePalette colorPalette;
- private final TextEditorPresenter presenter;
- private final I18nTranslationService i18n;
-
- /**
- * Creates a new toolbar that drives the given rich text area.
- *
- * @param richText
- * the rich text area to be controlled
- */
- public TextEditorToolbar(final RichTextArea richText, final TextEditorPresenter presenter,
- final ColorWebSafePalette colorPalette, final I18nTranslationService i18n, boolean permitEditHtml,
- TextEditorInsertElement insertElement) {
- this.richText = richText;
- this.colorPalette = colorPalette;
- this.i18n = i18n;
- this.basic = richText.getBasicFormatter();
- this.extended = richText.getExtendedFormatter();
- this.presenter = presenter;
- listener = new EventListener(insertElement);
-
- initWidget(outer);
-
- outer.add(topPanel);
- outer.setVerticalAlignment(VerticalPanel.ALIGN_MIDDLE);
- setStyleName("gwt-RichTextToolbar");
-
- if (basic != null) {
- topPanel.add(bold = createToggleButton(images.bold(), i18n.t("Toggle Bold")));
- topPanel.add(italic = createToggleButton(images.italic(), i18n.t("Toggle Italic")));
- topPanel.add(underline = createToggleButton(images.underline(), i18n.t("Toggle Underline")));
- }
-
- if (extended != null) {
- topPanel.add(strikethrough = createToggleButton(images.strikeout(), i18n.t("Toggle Strikethrough")));
- }
-
- if (basic != null) {
- subscript = createToggleButton(images.subscript(), i18n.t("Toggle Subscript"));
- superscript = createToggleButton(images.superscript(), i18n.t("Toggle Superscript"));
- topPanel.add(subscript);
- topPanel.add(superscript);
- topPanel.add(justifyLeft = createPushButton(images.alignleft(), i18n.t("Left Justify")));
- topPanel.add(justifyCenter = createPushButton(images.centerpara(), i18n.t("Center")));
- topPanel.add(justifyRight = createPushButton(images.alignright(), i18n.t("Right Justify")));
- }
-
- if (extended != null) {
- topPanel.add(indent = createPushButton(images.incrementindent(), i18n.t("Indent Right")));
- topPanel.add(outdent = createPushButton(images.decrementindent(), i18n.t("Indent Left")));
- hr = createPushButton(images.hfixedline(), i18n.t("Insert Horizontal Rule"));
- topPanel.add(hr);
- topPanel.add(ol = createPushButton(images.defaultnumbering(), i18n.t("Insert Ordered List")));
- topPanel.add(ul = createPushButton(images.defaultbullet(), i18n.t("Insert Unordered List")));
- topPanel.add(insertImage = createPushButton(images.images(), i18n.t("Insert Image")));
- topPanel.add(createLink = createPushButton(images.link(), i18n.t("Create Link")));
- topPanel.add(removeLink = createPushButton(images.linkBreak(), i18n.t("Remove Link")));
- removeFormat = createPushButton(images.removeFormat(), i18n.t("Remove Formatting"));
- topPanel.add(removeFormat);
- }
-
- if (basic != null) {
- topPanel.add(backColor = createPushButton(images.backcolor(), i18n.t("Background Color")));
- topPanel.add(fontColor = createPushButton(images.fontcolor(), i18n.t("Font Color")));
- topPanel.add(fonts = createFontsMenu());
- topPanel.add(fontSizes = createFontSizesMenu());
-
- // We only use these listeners for updating status, so don't
- // hook them up unless at least basic editing is supported.
- richText.addKeyboardListener(listener);
- richText.addClickListener(listener);
- }
-
- if (basic != null && permitEditHtml) {
- topPanel.add(editHtml = createToggleButton(images.edithtml(), i18n.t("Edit HTML")));
- }
-
- // super.setVisible(false);
- }
-
- public void editHTML(final boolean edit) {
- final boolean enable = !edit;
- if (basic != null) {
- bold.setVisible(enable);
- italic.setVisible(enable);
- underline.setVisible(enable);
- subscript.setVisible(enable);
- superscript.setVisible(enable);
- justifyLeft.setVisible(enable);
- justifyCenter.setVisible(enable);
- justifyRight.setVisible(enable);
- backColor.setVisible(enable);
- fontColor.setVisible(enable);
- }
- if (extended != null) {
- strikethrough.setVisible(enable);
- indent.setVisible(enable);
- outdent.setVisible(enable);
- insertImage.setVisible(enable);
- createLink.setVisible(enable);
- removeLink.setVisible(enable);
- ol.setVisible(enable);
- ul.setVisible(enable);
- hr.setVisible(enable);
- removeFormat.setVisible(enable);
- fonts.setVisible(enable);
- fontSizes.setVisible(enable);
- }
- }
-
- private MenuBar createFontSizesMenu() {
- final MenuBar menu = new MenuBar();
- final MenuBar submenu = new MenuBar(true);
- final String fontSizes[] = { i18n.t("Extra small"), i18n.t("Very small"), i18n.t("Small"), i18n.t("Medium"),
- i18n.t("Large"), i18n.t("Very large"), i18n.t("Extra large") };
-
- KuneUiUtils.setQuickTip(menu, i18n.t("Font Size"));
- menu.addItem(images.fontheight().getHTML(), true, submenu);
- for (int i = 0; i < fontSizes.length; i++) {
- final String f = fontSizes[i];
- final int fontSize = i;
- submenu.addItem("<font size=\"" + (i + 1) + "\">" + f + "</font>", true, new Command() {
- public void execute() {
- basic.setFontSize(fontSizesConstants[fontSize]);
- fireEdit();
- }
- });
- }
- menu.setStyleName("RichTextToolbar-menu");
- submenu.setStyleName("RichTextToolbar-submenu");
- return menu;
- }
-
- private MenuBar createFontsMenu() {
- final MenuBar menu = new MenuBar();
- final MenuBar submenu = new MenuBar(true);
- final String fontName[] = { "Times New Roman", "Arial", "Courier New", "Georgia", "Trebuchet", "Verdana" };
-
- KuneUiUtils.setQuickTip(menu, i18n.t("Font Type"));
- menu.addItem(images.charfontname().getHTML(), true, submenu);
- for (final String f : fontName) {
- submenu.addItem("<span style=\"font-family: " + f + "\">" + f + "</span>", true, new Command() {
- public void execute() {
- basic.setFontName(f);
- fireEdit();
- }
- });
- }
- menu.setStyleName("RichTextToolbar-menu");
- submenu.setStyleName("RichTextToolbar-submenu");
- return menu;
- }
-
- private PushButton createPushButton(final AbstractImagePrototype img, final String tip) {
- final PushButton pb = new PushButton(img.createImage());
- pb.addClickListener(listener);
- KuneUiUtils.setQuickTip(pb, tip);
- return pb;
- }
-
- private ToggleButton createToggleButton(final AbstractImagePrototype img, final String tip) {
- final ToggleButton tb = new ToggleButton(img.createImage());
- tb.addClickListener(listener);
- KuneUiUtils.setQuickTip(tb, tip);
- return tb;
- }
-
- private void fireEdit() {
- presenter.onEdit();
- }
-
- private void fireEditHTML() {
- presenter.onEditHTML();
- }
-
- /**
- * Updates the status of all the stateful buttons.
- */
- private void updateStatus() {
- if (basic != null) {
- bold.setDown(basic.isBold());
- italic.setDown(basic.isItalic());
- underline.setDown(basic.isUnderlined());
- subscript.setDown(basic.isSubscript());
- superscript.setDown(basic.isSuperscript());
- }
-
- if (extended != null) {
- strikethrough.setDown(extended.isStrikethrough());
- }
- }
-
-}
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java
===================================================================
--- trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/main/java/org/ourproject/kune/workspace/client/editor/TextEditorView.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,50 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2009 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package org.ourproject.kune.workspace.client.editor;
-
-import org.ourproject.kune.platf.client.View;
-
-public interface TextEditorView extends View {
-
- void attach();
-
- void detach();
-
- void editHTML(boolean edit);
-
- String getHTML();
-
- String getText();
-
- void saveTimerCancel();
-
- void scheduleSave(int delayMillis);
-
- void setEnabled(boolean enabled);
-
- void setHeight(String height);
-
- void setHTML(String html);
-
- void setText(String text);
-
- void showSaveBeforeDialog();
-
-}
\ No newline at end of file
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignleft.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/alignright.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/backcolor.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/bold.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/centerpara.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/charfontname.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/decrementindent.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultbullet.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/defaultnumbering.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/edithtml.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontcolor.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/fontheight.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/hfixedline.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/images.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/incrementindent.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/italic.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/link_break.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/removeFormat.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/strikeout.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/subscript.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/superscript.png
===================================================================
(Binary files differ)
Deleted: trunk/src/main/java/org/ourproject/kune/workspace/client/editor/underline.png
===================================================================
(Binary files differ)
Deleted: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -1,158 +0,0 @@
-package org.ourproject.kune.platf.client.ui.rte;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import org.junit.Before;
-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.i18n.I18nUITranslationService;
-import org.ourproject.kune.platf.client.state.StateManager;
-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.Listener0;
-import com.calclab.suco.testing.events.MockedListener;
-import com.calclab.suco.testing.events.MockedListener0;
-import com.google.gwt.libideas.resources.client.ImageResource;
-
-public class RTESavingEditorPresenterTest {
-
- private RTESavingEditorPresenter presenter;
- private MockedListener<String> saveListener;
- private MockedListener0 cancelListener;
- private StateManager stateManager;
- private DeferredCommandWrapper deferredCommandWrapper;
- private RTEditor rteEditor;
- private TimerWrapper timer;
- @SuppressWarnings("unchecked")
- private ActionToolbar sndbar;
- private RTESavingEditorView view;
-
- @SuppressWarnings("unchecked")
- @Before
- public void createObjects() {
- I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
- 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);
- Mockito.when(imageResource.getName()).thenReturn("save");
- Mockito.when(imgResources.save()).thenReturn(imageResource);
- sndbar = Mockito.mock(ActionToolbar.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,
- imgResources, timer);
- presenter.init(view);
- saveListener = new MockedListener<String>();
- cancelListener = new MockedListener0();
- }
-
- @Test
- public void historyChangeWithoutPendingMustAccept() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- boolean change = presenter.beforeTokenChange();
- assertTrue(change);
- verifyAskConfirmationCalled(Mockito.never());
- Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
- }
-
- @Test
- public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
- editAndChangeHistoryToken();
- presenter.onCancelConfirmed();
- assertTrue(saveListener.isNotCalled());
- Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
- }
-
- @Test
- public void historyChangeWithPendingSaveMustPosponeIt() {
- editAndChangeHistoryToken();
- presenter.onDoSaveAndClose();
- presenter.onSavedSuccessful();
- assertTrue(saveListener.isCalledOnce());
- Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
- }
-
- @Test
- public void initialEditWithCancel() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onCancel();
- assertTrue(saveListener.isNotCalled());
- assertTrue(cancelListener.isCalledOnce());
- }
-
- @Test
- public void initialEditWithEditionAndSave() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- presenter.onDoSave();
- 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);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- presenter.onCancel();
- presenter.onCancelConfirmed();
- assertTrue(saveListener.isNotCalled());
- assertTrue(cancelListener.isCalledOnce());
- }
-
- @Test
- public void testSavePendingAndSaveFails() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- String textModified = "Text modified";
- Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
- presenter.onEdit();
- 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);
- assertTrue(saveListener.isCalled(2));
- }
-
- @SuppressWarnings("unchecked")
- private void checkSaveBtnDisabled() {
- Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
- }
-
- private String editAndChangeHistoryToken() {
- presenter.edit("Text to edit", saveListener, cancelListener);
- presenter.onEdit();
- String newToken = "somegroup";
- boolean change = presenter.beforeTokenChange();
- assertFalse(change);
- verifyAskConfirmationCalled(Mockito.times(1));
- return newToken;
- }
-
- private void verifyAskConfirmationCalled(VerificationMode mode) {
- Mockito.verify(view, mode).askConfirmation(Mockito.anyString(), Mockito.anyString(),
- (Listener0) Mockito.anyObject(), (Listener0) Mockito.anyObject());
- }
-
-}
Copied: trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java (from rev 1069, trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java)
===================================================================
--- trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/RTESavingEditorPresenterTest.java 2009-03-11 13:21:45 UTC (rev 1069)
+++ trunk/src/test/java/org/ourproject/kune/platf/client/ui/rte/saving/RTESavingEditorPresenterTest.java 2009-03-11 13:47:13 UTC (rev 1070)
@@ -0,0 +1,161 @@
+package org.ourproject.kune.platf.client.ui.rte.saving;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+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.i18n.I18nUITranslationService;
+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.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 com.calclab.suco.client.events.Listener0;
+import com.calclab.suco.testing.events.MockedListener;
+import com.calclab.suco.testing.events.MockedListener0;
+import com.google.gwt.libideas.resources.client.ImageResource;
+
+public class RTESavingEditorPresenterTest {
+
+ private RTESavingEditorPresenter presenter;
+ private MockedListener<String> saveListener;
+ private MockedListener0 cancelListener;
+ private StateManager stateManager;
+ private DeferredCommandWrapper deferredCommandWrapper;
+ private RTEditor rteEditor;
+ private TimerWrapper timer;
+ @SuppressWarnings("unchecked")
+ private ActionToolbar sndbar;
+ private RTESavingEditorView view;
+
+ @SuppressWarnings("unchecked")
+ @Before
+ public void createObjects() {
+ I18nUITranslationService i18n = Mockito.mock(I18nUITranslationService.class);
+ 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);
+ Mockito.when(imageResource.getName()).thenReturn("save");
+ Mockito.when(imgResources.save()).thenReturn(imageResource);
+ sndbar = Mockito.mock(ActionToolbar.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,
+ imgResources, timer);
+ presenter.init(view);
+ saveListener = new MockedListener<String>();
+ cancelListener = new MockedListener0();
+ }
+
+ @Test
+ public void historyChangeWithoutPendingMustAccept() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ boolean change = presenter.beforeTokenChange();
+ assertTrue(change);
+ verifyAskConfirmationCalled(Mockito.never());
+ Mockito.verify(deferredCommandWrapper, Mockito.times(1)).addCommand((Listener0) Mockito.anyObject());
+ }
+
+ @Test
+ public void historyChangeWithPendingSaveAndCancelMustPosponeIt() {
+ editAndChangeHistoryToken();
+ presenter.onCancelConfirmed();
+ assertTrue(saveListener.isNotCalled());
+ Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+ }
+
+ @Test
+ public void historyChangeWithPendingSaveMustPosponeIt() {
+ editAndChangeHistoryToken();
+ presenter.onDoSaveAndClose();
+ presenter.onSavedSuccessful();
+ assertTrue(saveListener.isCalledOnce());
+ Mockito.verify(stateManager, Mockito.times(1)).resumeTokenChange();
+ }
+
+ @Test
+ public void initialEditWithCancel() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ presenter.onCancel();
+ assertTrue(saveListener.isNotCalled());
+ assertTrue(cancelListener.isCalledOnce());
+ }
+
+ @Test
+ public void initialEditWithEditionAndSave() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ presenter.onDoSave();
+ 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);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ presenter.onCancel();
+ presenter.onCancelConfirmed();
+ assertTrue(saveListener.isNotCalled());
+ assertTrue(cancelListener.isCalledOnce());
+ }
+
+ @Test
+ public void testSavePendingAndSaveFails() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ String textModified = "Text modified";
+ Mockito.when(rteEditor.getHtml()).thenReturn(textModified);
+ presenter.onEdit();
+ 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);
+ assertTrue(saveListener.isCalled(2));
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkSaveBtnDisabled() {
+ Mockito.verify(sndbar, Mockito.times(1)).setButtonEnable(presenter.saveBtn, false);
+ }
+
+ private String editAndChangeHistoryToken() {
+ presenter.edit("Text to edit", saveListener, cancelListener);
+ presenter.onEdit();
+ String newToken = "somegroup";
+ boolean change = presenter.beforeTokenChange();
+ assertFalse(change);
+ verifyAskConfirmationCalled(Mockito.times(1));
+ return newToken;
+ }
+
+ private void verifyAskConfirmationCalled(VerificationMode mode) {
+ Mockito.verify(view, mode).askConfirmation(Mockito.anyString(), Mockito.anyString(),
+ (Listener0) Mockito.anyObject(), (Listener0) Mockito.anyObject());
+ }
+
+}
1
0