Permalink
Browse files

Changes towards release 1.0

  • Loading branch information...
bwolff committed Apr 20, 2013
1 parent 13d441f commit 959ccfe0306a42e05bb066c6b8a33385a1bfdc9a
View
@@ -3,7 +3,7 @@ import grails.plugins.rwt.ThemeConfigurationHelper
import grails.plugins.rwt.ApplicationConfigurationBean
class RwtGrailsPlugin {
- def version = "0.1"
+ def version = "1.0"
def grailsVersion = "2.0 > *"
def title = "The RAP Widget Toolkit (RWT) for Grails"
def author = "Benjamin Wolff"
@@ -8,6 +8,8 @@ grails.project.dependency.resolution = {
repositories {
grailsCentral()
+ mavenLocal()
+ mavenCentral() // Required for resolving the RWT bundles.
}
dependencies {
@@ -20,4 +20,4 @@ class UrlMappings {
}
{code}
-Now the RWT application is reachable via: @http://server/foo@
+Now the RWT application is reachable via: @http://server/foo@
@@ -6,5 +6,20 @@ rwt {
}
{code}
-There are two aspects that can be configured, the global RWT settings, and the settings
-specific to the single entry points.
+There are different aspects that can be configured, the global RWT application settings, the entry
+point settings, and the theme settings.
+
+For more information about RWT in general please have a look at the
+[RAP/RWT 2.0 developer's guide|http://www.eclipse.org/rap/developers-guide/index.php?version=2.0].
+
+{note}
+*Classpath Resources*
+
+Some configuration settings (e.g. theme CSS files) expect a relative path to a file that is visible
+on the classpath. The easiest way is to put your static file resources in a
+sub-folder of @src/java@ or @src/groovy@ of your Grails application. This way the files are
+available in the classpath without any additional configuration.
+
+This also enables you to reference files that are provided in the classpath by other plugins or
+libraries.
+{note}
@@ -1 +1,5 @@
-Options to configure global aspects of the RWT application will come in future versions of this plugin.
+Options to configure global aspects of the RWT application will come in future versions of this plugin.
+
+* *operationMode* - [RWT documentation about operation modes|http://www.eclipse.org/rap/developers-guide/devguide.php?topic=application-setup.html&version=2.0#compat] (optional).
+* *phaseListeners* - (optional).
+* *themableWidgets* - (optional).
@@ -6,7 +6,7 @@ rwt {
entrypoints {
hello {
bean = 'entryPointBean'
- pageTitle = 'Hello RWT World!'
+ ...
}
}
}
@@ -16,8 +16,12 @@ The given example configures an entry point with the name @hello@. By default, t
be mapped to the relative URL path '/hello'. The following settings need to be provided for an
entry point configuration:
-* *bean* - The name (string) of the bean that implements the IEntryPoint interface (mandatory).
+* *bean* - The name (string) of the bean that implements the EntryPoint interface (mandatory).
* *pageTitle* - The title (string) that will be displayed as the browser's title (optional).
+* *favicon* - Relative path to an .ico image that will be used as the favicon for the entry point (optional).
+* *themeId* - (optional).
+* *headHtml* - Relative path to a file containing HTML. The content of the file will be added to the <head> element of the page (optional). Please see
+* *bodyHtml* - Relative path to a file containing HTML. The content of the file will be added to the <body> element of the page (optional).
A Grails-RWT application can contain an arbitrary number of entry points, which usually refer to
different entry point beans.
@@ -27,17 +31,34 @@ rwt {
entrypoints {
hello {
bean = 'helloEntryPoint'
- pageTitle = 'Hello RWT World!'
+ ...
}
helloAgain {
bean = 'helloAgainEntryPoint'
- pageTitle = 'Hello again, RWT World!'
+ ...
}
}
}
{code}
-In this example there will be two entry points accessible under '/hello' and '/helloAgain'.
+In this example there will be two entry points accessible under '/hello' and '/helloAgain'. For
+customizing the default URL mapping behaviour please see the [Advanced Topics|guide:advancedTopics]
+chapter.
+
+Shown below is an example with all available entry point configuration values:
-For customizing the default URL mapping behaviour please see the [Advanced Topics|guide:advancedTopics] chapter.
+{code}
+rwt {
+ entrypoints {
+ hello {
+ bean = 'helloEntryPointService'
+ pageTitle = 'Hello RWT World!'
+ favicon = 'icons/favicon.ico'
+ themeId = 'mytheme'
+ headHtml = 'html/head.html'
+ bodyHtml = 'html/body.html'
+ }
+ }
+}
+{code}
@@ -1,6 +1,6 @@
The plugin logs some information in the INFO and DEBUG levels. To increase the verbosity of the
log messages you can enable the debug level for some plugin artifacts. Add the following lines to
-the [log4j section|http://grails.org/doc/latest/guide/conf.html#logging] in your @Config.groovy@ file:
+the [log4j section|http://grails.org/doc/latest/guide/conf.html#logging] of your @Config.groovy@ file:
{code}
log4j = {
@@ -0,0 +1,24 @@
+The current version of the plugin is based on RWT version 2.0. The required libraries are resolved
+from the Maven central repository using the default [Grails dependency mechanism (Ivy)|http://grails.org/doc/latest/guide/conf.html#ivy].
+An application can override these dependencies manually to use a more recent version of RWT. This
+can be useful to test new milestone releases or use new service releases without having to wait for
+a new release of the Grails-RWT plugin.
+
+{warning}
+The internal mechanisms of the Grails RWT plugin are currently based on the API of version 2.0. If
+you use a new RWT version that comes with breaking API changes the plugin won't work anymore. In
+order to use the latest RWT version in this case a new release of the Grails RWT plugin is necessary.
+{warning}
+
+Here is an example configuration in the BuildConfig.groovy to use an RWT 2.1 milestone release:
+
+{code}
+grails.project.dependency.resolution = {
+
+ dependencies {
+ compile('org.eclipse.rap:org.eclipse.rap.rwt:2.1.0-M1')
+ compile('org.eclipse.rap:org.eclipse.rap.jface:2.1.0-M1')
+ compile('org.eclipse.rap:org.eclipse.rap.jface.databinding:2.1.0-M1')
+ }
+}
+{code}
@@ -0,0 +1,33 @@
+The plugin supports a simply configuration of
+[RWT themes and theme contributions|http://www.eclipse.org/rap/developers-guide/devguide.php?topic=theming.html&version=2.0]
+that can be used in the entry point configuration. The themes are provided via CSS files and
+configured via relative paths in the application's classpath. Shown below is an example theme
+configuration:
+
+{code}
+rwt {
+ themes {
+ rwtdefault = 'themes/default.css'
+ mytheme = 'themes/mytheme.css'
+ mytheme2 = ['themes/mytheme2.css', 'themes/mytheme3.css']
+ }
+}
+{code}
+
+Themes are configured in the @themes@ block, each entry in this block represents a different theme,
+the name of the entry is the theme ID that is used to reference it in the [entry point configuration|guide:entryPointConfiguration].
+A special theme name is @rwtdefault@. This name references the default RWT theme and the CSS files
+provided for this name are treated as contributions and will be merged into the RWT default theme.
+Additions to this theme are automatically applied to your widgets without the need to add a theme
+configuration to your entry point. The example shown above also creates the two custom themes with
+the ID @mytheme@ and @mytheme2@.
+
+As mentioned before, the values of the themes are paths denoting a CSS file on the classpath. The
+value can be a single path string or a list of path strings. In case a list of paths is provided,
+the first file will be used as the main theme file and the subsequent files are treated as contributions
+to this theme file. The order in which they are specified determine the order in which the
+contributions are applied. This mechanism allows it to enhance your own themes with theme additions coming
+from other plugins or libraries, as long as the CSS files are accessible via the classpath.
+
+For more information about theming in RWT and what widgets and properties are supported in the CSS
+please refer to the [RWT theming documentation|http://www.eclipse.org/rap/developers-guide/devguide.php?topic=theming.html&version=2.0].
@@ -3,7 +3,7 @@ application. You should be familiar with how to [create a Grails application|htt
and artifacts like [domain classes|http://grails.org/doc/latest/guide/GORM.html#quickStartGuide] and
[services|http://grails.org/doc/latest/guide/services.html].
-The RWT setup process is based on the [standalone guide|http://eclipse.org/rap/developers-guide/devguide.php?topic=advanced/rwt-standalone.html].
+The RWT setup process is based on the [standalone guide|http://www.eclipse.org/rap/developers-guide/devguide.php?topic=rwt-standalone.html&version=2.0].
However, the Grails-RWT plugin does most of the setup for you, as you will see in this guide.
Start with creating an example Grails application and then follow the instructions below. The next
@@ -1,5 +1,5 @@
The only thing that is missing now is the configuration of our new RWT entry point. This is done
-in an own [configuration|http://grails.org/doc/latest/guide/conf.html#config] block in the
+in a [configuration|http://grails.org/doc/latest/guide/conf.html#config] block in the
@grails-app/conf/Config.groovy@ file.
{code}
@@ -22,5 +22,5 @@ Here we simply specify our entry point as a block under @entrypoints@ and provid
entry point bean, which is described above. We can also specify a string that will be displayed as
the browser's page title.
-More information about the configuration of an RWT application and the entry points is available
+More information about the configuration of the RWT application and the entry points is available
[here|guide:configuration].
@@ -13,49 +13,43 @@ snippet highlight interesting points.
{code}
package grails.rwt.example
+import org.eclipse.jface.layout.GridDataFactory
+import org.eclipse.jface.layout.GridLayoutFactory
import org.eclipse.jface.viewers.ArrayContentProvider
import org.eclipse.jface.viewers.LabelProvider
import org.eclipse.jface.viewers.ListViewer
-import org.eclipse.rap.rwt.lifecycle.IEntryPoint
+import org.eclipse.rap.rwt.application.AbstractEntryPoint
import org.eclipse.swt.SWT
import org.eclipse.swt.events.SelectionAdapter
import org.eclipse.swt.events.SelectionEvent
-import org.eclipse.swt.layout.GridData
-import org.eclipse.swt.layout.GridLayout
import org.eclipse.swt.widgets.Button
+import org.eclipse.swt.widgets.Composite
import org.eclipse.swt.widgets.Display
import org.eclipse.swt.widgets.Label
-import org.eclipse.swt.widgets.List
import org.eclipse.swt.widgets.Shell
-// "Note the use of Groovy syntax"
+// "Note the use of the Groovy syntax"
-class HelloEntryPointService implements IEntryPoint { // "The service needs to implement IEntryPoint"
+class HelloEntryPointService extends AbstractEntryPoint { // "The service needs to implement EntryPoint"
def fooService // "Other services will get injected by Grails"
@Override
- int createUI() {
+ protected void createContents(Composite parent) {
log.info("Creating RWT UI ...") // "Implicit logger object"
-
- Display display = new Display()
- Shell shell = new Shell(display)
- shell.setSize(500, 400)
- shell.layout = new GridLayout()
- shell.setText("Hello RWT!")
- final Label label = new Label(shell, SWT.NONE)
- label.layoutData = new GridData(SWT.FILL, SWT.CENTER, true, false)
+ final Label label = new Label(parent, SWT.NONE)
+ GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(label)
// "JFace is available"
- ListViewer viewer = new ListViewer(shell, SWT.V_SCROLL | SWT.H_SCROLL)
- viewer.list.layoutData = new GridData(SWT.FILL, SWT.FILL, true, true)
+ ListViewer viewer = new ListViewer(parent, SWT.V_SCROLL | SWT.H_SCROLL)
+ GridDataFactory.swtDefaults().hint(500, 300).applyTo(viewer.list)
viewer.contentProvider = ArrayContentProvider.instance
viewer.labelProvider = new LabelProvider()
- viewer.input = Foo.list() // "Use domain objects and GORM directly, no DTOs required!"
+ viewer.input = Foo.list() // "Use domain objects and GORM, no DTOs required!"
- Button button = new Button(shell, SWT.PUSH)
- button.layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, false, false)
+ Button button = new Button(parent, SWT.PUSH)
+ GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.CENTER).applyTo(button)
button.text = "Click me!"
button.addSelectionListener(new SelectionAdapter() {
Integer num = 0
@@ -65,9 +59,14 @@ class HelloEntryPointService implements IEntryPoint { // "The service needs to i
label.text = fooService.serviceMethod(num++) // "Call methods of other services"
}
})
+ }
- shell.open()
- return 0
+ @Override
+ protected Shell createShell(Display display) {
+ Shell shell = new Shell(display)
+ shell.setText("Hello RWT!")
+ GridLayoutFactory.swtDefaults().applyTo(shell)
+ return shell
}
}
{code}
@@ -7,7 +7,7 @@ grails.project.dependency.resolution = {
plugins {
// Other plugin dependencies
- compile ':rwt:0.1'
+ compile ':rwt:1.0'
}
}
{code}
@@ -1,18 +1,17 @@
-This plugin integrates the [RAP Widget Toolkit (RWT)|http://wiki.eclipse.org/WidgetToolkit] - a
-web-based Ajax/JavaScript widget library similar to [SWT|http://www.eclipse.org/swt/] - into your Grails
-application.
+This plugin integrates the [RAP Widget Toolkit (RWT)|http://eclipse.org/rap/developers-guide/devguide.php?topic=rwt.html&version=2.0] - a
+web-based Ajax/JavaScript widget library similar to SWT - into your Grails application.
RWT is the web UI part of the [Remote Application Platform (RAP)|http://www.eclipse.org/rap] - an
application framework based on the [Eclipse platform|http://wiki.eclipse.org/Platform].
RWT is provided in
-[standalone|http://eclipse.org/rap/developers-guide/devguide.php?topic=advanced/rwt-standalone.html]
+[standalone|http://eclipse.org/rap/developers-guide/devguide.php?topic=rwt-standalone.html&version=2.0]
mode by this plugin, without the full RAP workbench or OSGi. Besides the SWT API, you can use the
[JFace API|http://wiki.eclipse.org/JFace] to build your user interfaces.
RWT enables you to create highly interactive, desktop-like Ajax interfaces by only writing
Java/Groovy code. In contrast to the popular [Google Web Toolkit|http://developers.google.com/web-toolkit/] ([Grails plugin|http://grails.org/plugin/gwt]),
-RWT is not compiled to JavaScript, but provides its own set of JavaScript widget which communicate
-transparantly with your server-side code. Since basically everything happens on the server-side
+RWT is not compiled to JavaScript, but provides its own set of JavaScript widget that communicate
+transparently with your server-side code. Since basically everything happens on the server-side
(besides the rendering in the browser), it is not necessary to use DTOs or other transfer objects
to display the data on the client. The domain objects can be seamlessly used in the UI logic (e.g.
via [DataBinding|http://wiki.eclipse.org/index.php/JFace_Data_Binding]).
@@ -24,8 +23,10 @@ RWT. Have fun!
h3. Grails & RWT Version
-The plugin requires at least [Grails 2.0|http://grails.org/Download] to be used. The current version
-of this plugin ships with [RWT 2.0 M3|http://www.eclipse.org/rap/noteworthy/2.0/?build=M3].
+The plugin requires at least [Grails 2.0|http://grails.org/Download] and was currently build using
+Grails 2.2.1. The current version of this plugin ships with
+[RWT 2.0|http://www.eclipse.org/rap/downloads/2.0/] by default, but later RWT versions can be
+[configured instead|guide:rwtVersionConfiguration].
h3. License
@@ -1,10 +1 @@
-This section sums up a few issues that will be tackled/resolved in upcoming versions of this plugin.
-
-* *Theming & Branding*
-** Support the RWT custom CSS and theming options.
-* *Configuration*
-** Allow to configure more aspects of RWT. Allow simple addition of resources etc.
-* *Use Maven for the RWT dependencies*
-** Unfortunately there is no maven repository available that can server the required RWT dependency jar files. Currently, the required jars are bundled with the plugin. This is no ideal, as it doesn't allow to switch the RWT version. This situation can be improved if the jar files will become available in a public Maven repository.
-
Please file any issues/requests/ideas in the [GitHub issue tracker|http://github.com/bwolff/grails-rwt/issues].
@@ -1,2 +1,8 @@
+* April 18, 2013
+** 1.0 release
+** Added support for configuring other RWT application aspects (e.g. themes).
+** Updated to use the RWT 2.0 final release.
+** RWT dependencies are now resolved from the Maven central repository.
+
* November 18, 2012
** First 0.1 release
View
@@ -13,6 +13,8 @@ configuration:
title: Configuration
applicationConfiguration: Application Configuration
entryPointConfiguration: Entry Point Configuration
+ themeConfiguration: Theme Configuration
loggingConfiguration: Logging Configuration
+ rwtVersionConfiguration: RWT Version Configuration
advancedTopics:
title: Advanced Topics
@@ -21,6 +21,7 @@ package grails.plugins.rwt
import groovy.util.ConfigObject
import org.eclipse.rap.rwt.application.Application.OperationMode
+import org.eclipse.rap.rwt.lifecycle.PhaseListener
/**
* Simple pogo that encapsulates the configuration for the RWT application. There is only one
@@ -33,16 +34,24 @@ class ApplicationConfigurationBean {
/**
* The RWT operation mode. If not provided, the operation mode defaults to JEE_COMPATIBILITY,
* which is the recommended mode for new standalone RWT applications.
- *
+ * <p>
* See: http://eclipse.org/rap/developers-guide/devguide.php?topic=advanced/application-setup.html#compat
*/
OperationMode operationMode
+ List phaseListeners
+ List<Class> themableWidgets
public ApplicationConfigurationBean(ConfigObject grailsConfig) {
extractApplicationConfiguration(grailsConfig)
}
private void extractApplicationConfiguration(ConfigObject grailsConfig) {
- operationMode = grailsConfig.rwt.operationMode ?: null
+ def operationModeSetting = grailsConfig.rwt.operationMode ?: null
+ if (operationModeSetting instanceof String) {
+ operationModeSetting = OperationMode.valueOf(operationModeSetting)
+ }
+ operationMode = operationModeSetting
+ phaseListeners = grailsConfig.rwt.phaseListeners ?: null
+ themableWidgets = grailsConfig.rwt.themableWidgets ?: null
}
}
Oops, something went wrong.

0 comments on commit 959ccfe

Please sign in to comment.