Skip to content

anjlab/eclipse-tapestry5-plugin

Repository files navigation

Eclipse Integration for Tapestry5

Yet another Design/Code switcher for Tapestry5 applications.

Screenshot

Tapestry Context View

Go to Window -> Show View -> Other..., filter by "Tapestry" and select "Tapestry Context".

Tapestry Context View will appear (top right on this screenshot):

  • Provides context for opened Tapestry file
  • Includes code/template files of selected page/component, as well as list of properties files, @Import'ed and @Path @Inject'ed assets
  • Click on the file in a view to open this file
  • Simple validation implemented to highlight assets, JavaScript stacks & T5.4 modules that couldn't be resolved
    • supports default/classpath: or context: binding prefixes for assets
    • supports Tapestry symbols expansion in asset path

Screenshot

Quick Switch within Tapestry Context

Note: This feature is only available in Eclipse 4.

Quick Switch provides the same navigation functionality as Tapestry Context view. Use it when you work in maximized editor mode and/or your Tapestry Context view is minimized.

Default shortcut for this pop-up is CMD+;:

Screenshot

Tip: If you installed Quick Switch feature, I recommend you to change key bindings vice versa: CMD+; for Code/Design switch and CMD+R for the Quick Switch pop-up:

Eclipse Preferences

Jump to Definition

CMD+Hover over component reference to jump to one of its definitions:

Screenshot

Completion Proposals

Tapestry5 completion proposals now available for all WTP Editors.

parameter-proposal property-code property-proposal

Tapestry Project Outline

Go to Window -> Show View -> Other..., filter by "Tapestry" and select "Tapestry Project Outline".

Tapestry Project Outline view

This view displays structure of your Tapestry5 project:

  • Select your main Tapestry5 project (i.e. the project with web.xml) in the "Project Explorer" to see its outline
  • View all Tapestry5 modules available in classpath of the main Tapestry5 project
  • View library mappings, JavaScript stacks, Tapestry services, decorators, advisors, and configuration contributions declared in each module (only available if source code attached to the module class)
  • View symbols declared in the project
  • Double click on Module name or JavaScript stack to open its source code
  • Double click on Library mapping, Service, Decorator, Advisor, Contribution, or Symbol opens their declaration
  • Selecting a item in Tapestry Project Outline view makes it appear in the Javadoc View and also highlights definition source range in a Java editor if the editor for this file is open & active
  • Content of this view will be updated automatically in background when you're adding new or updating existing modules, changing web.xml, or editing your pages/components files
  • More to come...

Note: Analysis of 3rd party modules will only work if you have sources attached to your JARs in Eclipse (which is the default if you import your project via ./gradlew eclipse or mvn eclipse:eclipse -DdownloadSources=true). If you don't have sources attached to one of your module classes you will see warning icon near it in the Tapestry Project Outline view.

Note: CMD+Hover feature won't be able to find components in the modules that don't have attached sources.

Support for JavaScript stack overrides

It is possible in Tapestry5 to override stack definitions, for example, this is what Tapestry5 jQuery does for core stacks. Overridden stacks will have special markers in Tapestry Project Outline view.

stacks-overrides stacks-overridden

Support for Tapestry Symbols

All symbols declared in a project collected & presented in one place.

  • For every symbol you can find provider name (i.e. ApplicationDefauls or FactoryDefaults), tapestry module where this symbol declared, and even value of the symbol.
  • Markers for new, override, and overridden symbols.
  • Double-click on symbol to open source code of the declaration.
tapestry-symbols

Quickly Create Files for Tapestry5

Create new Tapestry5 pages, components and mixins quickly

Click to open standard New Java Class dialog with pre-filled source folder and package name fields.

Tapestry5Toolbar

Create new files in context

Create complement files for current Tapestry Context.

ViewToolbar

Click to open standard New File dialog with pre-filled location and file-name fields:

NewFile

Tapestry templates and JavaScript files will be created with sample content.

TemplateContent

Notice how cursor position is set in the new file -- it's right in the place you want to start extending it! :)

Creating JavaScript or CSS assets for page/component will add/modify @Import annotation by putting the reference to new asset.

JavaScriptContent

Edit templates

There are few very basic templates that come with the plugin.

Using Tapestry Context's Edit Templates menu it's now possible to edit those templates.

edit-templates

Selecting a template from the list will open or create corresponding file under src/main/eclipse-tapestry5.

It's assumed that this folder will be committed to your repository and shared with your team.

page.* templates used when creating assets within a page Tapestry Context, component.* -- for components, etc.

Templates are not limited to just *.js, *.css, and *.properties -- you may add templates with your own file extensions manually, i.e. page.coffee or page.less.

It is possible to have more than one set of templates organized in sub-folders.

Templates in the root of src/main/eclipse-tapestry5 will be used by default. Putting templates to sub-folder will override default templates for files created under that subfolder/package.

For example, to use different templates for all pages under com.example.app.pages.admin package, put your templates in src/main/eclipse-tapestry5/admin folder.

Two special snippets supported in templates: $ContextName$ and $Caret$.

$ContextName$ will be replaced with name of a Tapestry Context for which the file was created.

$Caret$ used to position a cursor in a newly created file.

Advanced Configuration

All plugin's configuration is stored in src/main/eclipse-tapestry5/config.json which is a JSON file with some additional formatting (see GSON's lenient parsing mode).

To create this file with default content click Project Settings... from Tapestry Context's menu.

The file has some inlined comments that should be self-explanatory, i.e. default config.json for Tapestry 5.3 can be found here.

File naming conventions

When creating new file within Tapestry Context it's possible to specify naming convention that should be used for a name of the file:

    # Naming conventions for new files. Supported values are:
    # UpperCamel, lowerCamel, lower_underscode, lower-hyphen
    
    fileNamingConventions: {
        
        *.js = UpperCamel
        
        , *.css = UpperCamel
        
        , *.* = UpperCamel
        
    }

For *.tml and *.java files naming convention is always UpperCamel and cannot be overridden.

Concrete convention is picked in the order from top to bottom using simple Glob pattern matching.

Other settings

Other settings can be used to help plugin to parse structure of your project, read inline comments for more details: T5.3 and T5.4.

This is still work in progress and is subject to change.

Install

Use this update site URL:

https://github.com/raw/wiki/anjlab/eclipse-tapestry5-plugin/update-site

Or drag & drop this icon into a running Eclipse:

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client

How to build

  1. Download "Eclipse IDE for Enterprise Java and Web Developers" from Eclipse.org
  2. Clone this project and import via File -> Import... -> General / Existing Projects into Workspace
  3. Open update-site/target-platform.target and click Set as Active Target Platform
  4. Right click update-site/site.xml and select Plug-in Tools -> Build Site
  5. That's it, the update-site folder will contain the build and be used for local installation.

Thanks To

YourKit

YourKit supports open source projects with its full-featured Java Profiler.

YourKit, LLC is the creator of YourKit Java Profiler and YourKit .NET Profiler, innovative and intelligent tools for profiling Java and .NET applications.