Skip to content
Browse files

Multiple changes...

  • Loading branch information...
1 parent d46317d commit 8104cc69ccde0f7feac778bb6834597728842de3 @bwolff committed Apr 16, 2013
View
15 .classpath
@@ -1,25 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src/groovy"/>
- <classpathentry kind="src" path="src/docs"/>
<classpathentry kind="src" path="grails-app/conf"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="src" path=".link_to_grails_plugins/release-2.0.4/src/groovy">
+ <classpathentry kind="src" path=".link_to_grails_plugins/hibernate-2.2.1/grails-app/i18n">
<attributes>
<attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" path=".link_to_grails_plugins/release-2.0.4/src/java">
+ <classpathentry kind="src" path=".link_to_grails_plugins/release-2.2.1/src/groovy">
<attributes>
<attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
</attributes>
</classpathentry>
- <classpathentry kind="src" path=".link_to_grails_plugins/rest-client-builder-1.0.2/src/groovy">
+ <classpathentry kind="src" path=".link_to_grails_plugins/release-2.2.1/src/java">
+ <attributes>
+ <attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path=".link_to_grails_plugins/rest-client-builder-1.0.3/src/groovy">
<attributes>
<attribute name="org.grails.ide.eclipse.core.SOURCE_FOLDER" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.grails.ide.eclipse.core.CLASSPATH_CONTAINER"/>
- <classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
- <classpathentry kind="output" path="target/eclipseclasses"/>
+ <classpathentry kind="output" path="target-eclipse/classes"/>
</classpath>
View
4 README.md
@@ -5,6 +5,8 @@ This plugin integrates RWT - the web-ported Standard Widget Toolkit (SWT) - into
application. It enables you to build your RWT and JFace powered user interfaces using Groovy and the
complete Grails framework stack with all its powerful features and syntactic DSL sugar.
-The RWT plugin is available here: http://grails.org/plugin/rwt
+The RWT plugin is available here: http://grails.org/plugin/rwt/
The documentation is available here: http://bwolff.github.com/grails-rwt/
+
+A small example application that demonstrates the usage of the plugin is available here: https://github.com/bwolff/grails-rwt-example/
View
48 RwtGrailsPlugin.groovy
@@ -1,6 +1,5 @@
-import grails.plugins.rwt.EntryPointConfiguration
-
-import org.eclipse.rap.rwt.application.Application.OperationMode
+import grails.plugins.rwt.EntryPointConfigurationHelper
+import grails.plugins.rwt.ThemeConfigurationHelper
class RwtGrailsPlugin {
def version = "0.1"
@@ -20,9 +19,9 @@ complete Grails framework stack with all its powerful features and syntactic DSL
def scm = [ url: "https://github.com/bwolff/grails-rwt/" ]
def doWithWebDescriptor = { xml ->
- // If there is no RWT entry points configured, don't register the RWT servlet.
- def paths = getEntryPointPaths(application)
- if (!paths) {
+ // If there is no RWT entry point configured, don't register the RWT servlet.
+ final entryPointHelper = new EntryPointConfigurationHelper(application.config)
+ if (!entryPointHelper.hasEntryPoints()) {
log.warn "No RWT entry point configured. Skipping RWT servlet registration ..."
return
}
@@ -38,7 +37,7 @@ complete Grails framework stack with all its powerful features and syntactic DSL
}
// Add an RWT servlet mapping for each configured entry point path.
- paths.each { path ->
+ entryPointHelper.entryPointPaths.each { path ->
def mappingElement = xml.'servlet-mapping'
lastMapping = mappingElement[mappingElement.size() - 1]
lastMapping + {
@@ -55,42 +54,25 @@ complete Grails framework stack with all its powerful features and syntactic DSL
def doWithSpring = {
// If there is no RWT entry points configured, don't create the RWT application
// configuration bean.
- def configurations = getEntryPointConfigurations(application)
- if (!configurations) {
+ final entryPointHelper = new EntryPointConfigurationHelper(application.config)
+ if (!entryPointHelper.hasEntryPoints()) {
log.warn "No RWT entry points configured. Skipping RWT application configuration."
return
}
+
+ final themeHelper = new ThemeConfigurationHelper(application.config)
- // Extract the RWT operation mode. The operation mode defaults to JEE_COMPATIBILITY, which
- // is the recommended mode for new standalone RWT applications.
+ // Extract the RWT operation mode. If not provided, the operation mode defaults to
+ // JEE_COMPATIBILITY, which is the recommended mode for new standalone RWT applications.
// See: http://eclipse.org/rap/developers-guide/devguide.php?topic=advanced/application-setup.html#compat
- def opMode = application.config.rwt.operationmode ?: OperationMode.JEE_COMPATIBILITY
+ final opMode = application.config.rwt.operationmode ?: null
// Create the RWT ApplicationConfiguration bean.
rwtApplicationConfiguration(grails.plugins.rwt.ApplicationConfigurationBean) {
grailsApplication = ref('grailsApplication')
operationMode = opMode
- entryPointConfigurations = configurations
- }
- }
-
- private getEntryPointPaths(application) {
- return application.config.rwt.entrypoints.collect { name, values -> '/' + name }
- }
-
- private getEntryPointConfigurations(application) {
- application.config.rwt.entrypoints.collect { name, values ->
- def path = '/' + name
- def entryPointBeanName = values.bean ?: null // TODO This would be an error!
- def entryPointConfiguration = new EntryPointConfiguration()
- entryPointConfiguration.path = path
- entryPointConfiguration.entryPointBeanName = entryPointBeanName
- entryPointConfiguration.pageTitle = values.pageTitle ?: null
- entryPointConfiguration.favicon = values.favicon ?: null
- entryPointConfiguration.themeId = values.themeId ?: null
- entryPointConfiguration.headHtml = values.headHtml ?: null
- entryPointConfiguration.bodyHtml = values.bodyHtml ?: null
- return entryPointConfiguration
+ entryPointConfigurationHelper = entryPointHelper
+ themeConfigurationHelper = themeHelper
}
}
}
View
5 application.properties
@@ -1 +1,4 @@
-app.grails.version=2.1.1
+#Grails Metadata file
+#Tue Apr 16 18:55:50 CEST 2013
+app.grails.version=2.2.1
+app.name=grails-rwt.git
View
9 grails-app/conf/BuildConfig.groovy
@@ -10,10 +10,15 @@ grails.project.dependency.resolution = {
grailsCentral()
}
+ dependencies {
+ compile('org.eclipse.rap:org.eclipse.rap.rwt:2.0.0')
+ compile('org.eclipse.rap:org.eclipse.rap.jface:2.0.0')
+ compile('org.eclipse.rap:org.eclipse.rap.jface.databinding:2.0.0')
+ }
+
plugins {
- build(':release:2.0.4', ':rest-client-builder:1.0.2') {
+ build(':release:2.2.1', ':rest-client-builder:1.0.3') {
export = false
}
}
}
-
View
2 grails-app/conf/Config.groovy
@@ -9,3 +9,5 @@ grails.doc.authors = "Benjamin Wolff"
grails.doc.license = "APACHE V2.0"
//grails.doc.copyright = "© Copyright 2012 Benjamin Wolff. All Rights Reserved."
//grails.doc.footer = "Some footer"
+grails.views.default.codec="none" // none, html, base64
+grails.views.gsp.encoding="UTF-8"
View
BIN lib/org.eclipse.rap.jface_2.0.0.20121031-1050.jar
Binary file not shown.
View
BIN lib/org.eclipse.rap.rwt_2.0.0.20121112-1148.jar
Binary file not shown.
View
94 src/groovy/grails/plugins/rwt/ApplicationConfigurationBean.groovy
@@ -1,17 +1,37 @@
+/*******************************************************************************
+ * Copyright 2012-2013 Benjamin Wolff
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * Benjamin Wolff - initial API and implementation
+ ******************************************************************************/
package grails.plugins.rwt
import groovy.util.logging.Commons
import org.codehaus.groovy.grails.commons.GrailsApplication
+import org.codehaus.groovy.grails.exceptions.GrailsConfigurationException
+import org.eclipse.rap.rwt.RWT
import org.eclipse.rap.rwt.application.Application
import org.eclipse.rap.rwt.application.ApplicationConfiguration
import org.eclipse.rap.rwt.application.Application.OperationMode
-import org.eclipse.rap.rwt.lifecycle.IEntryPoint
-import org.eclipse.rap.rwt.lifecycle.IEntryPointFactory
+import org.eclipse.rap.rwt.application.EntryPoint
+import org.eclipse.rap.rwt.application.EntryPointFactory
/**
* Configures the RWT application. An instance of this class will be registered as a Spring bean
- * and injected where needed.
+ * and can then be injected where needed.
*
* @author Benjamin Wolff
*/
@@ -20,25 +40,75 @@ class ApplicationConfigurationBean implements ApplicationConfiguration {
GrailsApplication grailsApplication
OperationMode operationMode
- List<EntryPointConfiguration> entryPointConfigurations
+ EntryPointConfigurationHelper entryPointConfigurationHelper
+ ThemeConfigurationHelper themeConfigurationHelper
+ @Override
void configure(Application application) {
- application.setOperationMode(operationMode)
- log.debug "RWT operation mode set to: ${operationMode}"
+ if (operationMode) {
+ application.setOperationMode(operationMode)
+ log.debug "RWT operation mode set to: ${operationMode}"
+ }
+
+ // First we register the themes, they need to be present before we register the entry points.
+ if (themeConfigurationHelper.hasThemes()) {
+ themeConfigurationHelper.themeConfigurations.each { ThemeConfigurationBean conf ->
+ validateThemeFilesExists(conf)
+
+ // Themes configured under the default theme are contributions to the RWT default
+ // theme.
+ if (conf.isDefaultTheme()) {
+ registerTheme(application, RWT.DEFAULT_THEME_ID, conf.themeFilePaths)
+ log.debug "Adding CSS files as contribution to RWT default theme: ${conf.themeFilePaths}"
+ } else {
+ registerTheme(application, conf.themeId, conf.themeFilePaths)
+ log.debug "Adding CSS files to custom RWT theme \"${conf.themeId}\": ${conf.themeFilePaths}"
+ }
+ }
+ } else {
+ log.debug "No RWT themes configured, skipping registration."
+ }
- entryPointConfigurations.each { EntryPointConfiguration conf ->
- IEntryPointFactory entryPointFactory = getEntryPointFactoryForBean(conf.entryPointBeanName)
+ // Register the entry points.
+ entryPointConfigurationHelper.entryPointConfigurations.each { EntryPointConfigurationBean conf ->
+ validateReferencedThemeIdExists(conf)
+
+ EntryPointFactory entryPointFactory = getEntryPointFactoryForBean(conf.entryPointBeanName)
application.addEntryPoint(conf.path, entryPointFactory, conf.entryPointProperties)
- log.debug "Registered RWT entry point -" +
+ log.debug "Registered RWT entry point." +
" Path: ${conf.path}," +
" EntryPoint bean: ${conf.entryPointBeanName}," +
" Properties: ${conf.entryPointProperties}"
}
}
- IEntryPointFactory getEntryPointFactoryForBean(String entryPointBeanName) {
- IEntryPoint entryPointBean = grailsApplication.mainContext.getBean(entryPointBeanName, IEntryPoint)
- return new EntryPointFactory(entryPoint: entryPointBean)
+ private void validateThemeFilesExists(ThemeConfigurationBean conf) {
+ // The theme files need to be available on the classpath.
+ conf.themeFilePaths.each { String path ->
+ if (!getClass().getClassLoader().getResourceAsStream(path)) {
+ throw new GrailsConfigurationException("[RWT] The custom RWT theme" +
+ " \"${conf.themeId}\" references a file that is not available on the" +
+ " classpath: ${path}")
+ }
+ }
+ }
+
+ private void validateReferencedThemeIdExists(EntryPointConfigurationBean conf) {
+ if (conf.themeId && !themeConfigurationHelper.hasThemeId(conf.themeId)) {
+ throw new GrailsConfigurationException("[RWT] The entry point configuration" +
+ " \"${conf.name}\" references a custom theme that was not configured: ${conf.themeId}")
+ }
+ }
+
+ private EntryPointFactory getEntryPointFactoryForBean(String entryPointBeanName) {
+ EntryPoint entryPointBean = grailsApplication.mainContext.getBean(entryPointBeanName, EntryPoint)
+ return new GrailsRwtEntryPointFactory(entryPoint: entryPointBean)
+ }
+
+ private registerTheme(Application application, String themeId, List<String> themeFilePaths) {
+ themeFilePaths.each { String path ->
+ application.addStyleSheet(themeId, path)
+ }
}
}
View
53 src/groovy/grails/plugins/rwt/EntryPointConfiguration.groovy
@@ -1,53 +0,0 @@
-package grails.plugins.rwt
-
-import org.eclipse.rap.rwt.client.WebClient
-
-/**
- * Simple POGO that encapsulates the configuration for an RWT entry point. A list of these object is
- * created according to the Config.groovy configuration and passed to the
- * {@link ApplicationConfigurationBean} that uses it to configure the entry point.
- *
- * @author Benjamin Wolff
- */
-class EntryPointConfiguration {
-
- String path
- String entryPointBeanName
- String pageTitle
- String favicon
- String themeId
- String headHtml
- String bodyHtml
-
- /**
- * Returns a map of the configured entry point properties according to the {@link WebClient}
- * constants.
- *
- * @return A map of the configured entry point properties. Never null.
- */
- Map<String, String> getEntryPointProperties() {
- Map<String, String> properties = [:]
-
- if (pageTitle) {
- properties[WebClient.PAGE_TITLE] = pageTitle
- }
-
- if (favicon) {
- properties[WebClient.FAVICON] = favicon
- }
-
- if (themeId) {
- properties[WebClient.THEME_ID] = themeId
- }
-
- if (headHtml) {
- properties[WebClient.HEAD_HTML] = headHtml
- }
-
- if (bodyHtml) {
- properties[WebClient.BODY_HTML] = bodyHtml
- }
-
- return properties
- }
-}
View
22 src/groovy/grails/plugins/rwt/EntryPointFactory.groovy
@@ -1,22 +0,0 @@
-package grails.plugins.rwt
-
-import org.eclipse.rap.rwt.lifecycle.IEntryPoint
-import org.eclipse.rap.rwt.lifecycle.IEntryPointFactory
-
-/**
- * Simple implementation of an {@link IEntryPointFactory}. A concrete {@link IEntryPoint}
- * implementing object can be set, which is then returned by the {@link #create()} method.
- * <p>
- * This factory implementation is used to be passed to the entry point configuration in the
- * {@link ApplicationConfigurationBean}.
- *
- * @author Benjamin Wolff
- */
-class EntryPointFactory implements IEntryPointFactory {
-
- IEntryPoint entryPoint
-
- IEntryPoint create() {
- return entryPoint
- }
-}

0 comments on commit 8104cc6

Please sign in to comment.
Something went wrong with that request. Please try again.