How to extend WindowBuilder to support new components. 1. Add component to palette. 1.1. Palette contribution in project



Similar documents
Sabre Red Apps. Developer Toolkit Overview. October 2014


Creating a Java application using Perfect Developer and the Java Develo...

Software Development Kit

Tutorial: Time Of Day Part 2 GUI Design in NetBeans

Smooks Dev Tools Reference Guide. Version: GA

Developing Eclipse Plug-ins* Learning Objectives. Any Eclipse product is composed of plug-ins

Tutorial #1. Android Application Development Advanced Hello World App

Eclipse 4 RCP application Development COURSE OUTLINE

CRM Global Search: Installation & Configuration

E4 development: examples, methods and tools. Eclipse Con France 2014

Builder User Guide. Version 5.4. Visual Rules Suite - Builder. Bosch Software Innovations

Eclipse Web Tools Platform. Naci Dai (Eteration), WTP JST Lead

Eclipse Rich Client Platform. Kai Tödter Karsten Becker et al. Organized by:

Implementation of ULC Visual Editor for Eclipse

Alkacon Software GmbH

EMC Documentum Composer

Software project management. and. Maven

GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012

CS506 Web Design and Development Solved Online Quiz No. 01

INFOPATH FORMS FOR OUTLOOK, SHAREPOINT, OR THE WEB

Tutorial 5: Developing Java applications

TIBCO Silver Fabric Continuity User s Guide

IBM BPM V8.5 Standard Consistent Document Managment

Understanding class paths in Java EE projects with Rational Application Developer Version 8.0

Eclipse with Mac OSX Getting Started Selecting Your Workspace. Creating a Project.

IBM Tivoli Workload Scheduler Integration Workbench V8.6.: How to customize your automation environment by creating a custom Job Type plug-in

Getting Started with Android Programming (5 days) with Android 4.3 Jelly Bean

Introduction to Android Programming (CS5248 Fall 2015)

Introduction to Android Development. Jeff Avery CS349, Mar 2013

How to Create an Android Application using Eclipse on Windows 7

IBM Rational Web Developer for WebSphere Software Version 6.0

Tutorial: BlackBerry Object API Application Development. Sybase Unwired Platform 2.2 SP04

MiG Layout Quick Start Guide v Adding Components to the Grid. Merging and Splitting Cells

INTEGRATING MICROSOFT DYNAMICS CRM WITH SIMEGO DS3

TIBCO ActiveMatrix BusinessWorks Plug-in for Big Data User s Guide

Summer Internship 2013

WebSphere Training Outline

Terms and Definitions for CMS Administrators, Architects, and Developers

WIRIS quizzes web services Getting started with PHP and Java

Practical Eclipse Rich Client Platform Projects

JiST Graphical User Interface Event Viewer. Mark Fong

creating a text-based editor for eclipse

WebSphere Business Monitor V6.2 KPI history and prediction lab

Duke University Program Design & Construction Course

CI/CD Cheatsheet. Lars Fabian Tuchel Date: 18.March 2014 DOC:

Java 7 Recipes. Freddy Guime. vk» (,\['«** g!p#« Carl Dea. Josh Juneau. John O'Conner

Department of Veterans Affairs. Open Source Electronic Health Record Services

Umbrello UML Modeller Handbook

Tutorial: BlackBerry Application Development. Sybase Unwired Platform 2.0

Android Developer Fundamental 1

Mobile Solutions for Data Collection. Sarah Croft and Laura Pierik

Tutorial for Spring DAO with JDBC

Implementing a Web Service Client using Java

SDK Quick Start Guide

Hands on exercise for

2. Click the download button for your operating system (Windows, Mac, or Linux).

TIBCO ActiveMatrix BusinessWorks Plug-in for Big Data User's Guide

Oracle Forms Services Secure Web.Show_Document() calls to Oracle Reports Server 6i

Getting Started: Creating a Simple App

RTI Routing Service. Release Notes

Demo: Embedding Windows Presentation Foundation elements inside a Java GUI application. Version 7.3

Android Development. Marc Mc Loughlin

Mocean Android SDK Developer Guide

Composite.Community.Newsletter - User Guide

Tutorial: Android Object API Application Development. SAP Mobile Platform 2.3 SP02

Implementing SQI via SOAP Web-Services

Operational Decision Manager Worklight Integration

Installing Java 5.0 and Eclipse on Mac OS X

This document covers version of BPMN2 Modeler, published November 15, 2013.

Installing (1.8.7) 9/2/ Installing jgrasp

TIBCO ActiveMatrix BusinessWorks Plug-in for TIBCO Managed File Transfer Software Installation

Amazon Glacier. Developer Guide API Version

Talend Component: tjasperreportexec

Software project management. and. Maven

Oracle Enterprise Performance Management System IBM WebSphere Manual Deployment Guide

NRG Software Postal Tool Kit v1.5

Installing and Sending with DocuSign for NetSuite v2.2

Android Application Development: Hands- On. Dr. Jogesh K. Muppala

Customizing MISys Manufacturing Reports Using ADO-XML 6/3/2013

VX Search File Search Solution. VX Search FILE SEARCH SOLUTION. User Manual. Version 8.2. Jan Flexense Ltd.

InfoSphere Master Data Management operational server v11.x OSGi best practices and troubleshooting guide

Android on Intel Course App Development - Advanced

SDK Code Examples Version 2.4.2

NASA Workflow Tool. User Guide. September 29, 2010

Developing In Eclipse, with ADT

Builder User Guide. Version Visual Rules Suite - Builder. Bosch Software Innovations

Kaseya 2. Quick Start Guide. for Network Monitor 4.1

An introduction to creating JSF applications in Rational Application Developer Version 8.0

Plugin JUnit. Contents. Mikaël Marche. November 18, 2005

Eclipse Platform Technical Overview

How to utilize Administration and Monitoring Console (AMC) in your TDI solution

Developing NFC Applications on the Android Platform. The Definitive Resource

Application Developer Guide

4D Plugin SDK v11. Another minor change, real values on 10 bytes is no longer supported.

A Sample OFBiz application implementing remote access via RMI and SOAP Table of contents

TIBCO ActiveMatrix BPM Mediation Component Development

Oracle SOA Suite 11g Oracle SOA Suite 11g HL7 Inbound Example

Transcription:

How to extend WindowBuilder to support new components. Here is an overview on how to add new components to be used within WindowlBuilder. Note, that there are at least three levels of support for components: Add component to the palette; Describe the component using *.wbp-component.xml; Write a Java code for special model/layout features. Let's look at the 3 levels step by step: 1. Add component to palette 1.1. Palette contribution in project You define your Palette contribution in an XML file called toolkitid.wpb-palette.xml within your project's «wbp-meta» folder. Your palette must have «category» and «component» attributes. <palette> <category id="someuniqueid" name="custom category" description="category added for project RCP_project" open="true"> <component class="javax.swing.jbutton"/> <component class="javax.swing.jradiobutton" name="your name" description="you can write any description here."/> </category> </palette> You can use the Project Palette wizard to generate such file for you (this is just a sample so ignore the fact that it always generates Swing components). Most of the attributes in *.wbp-palette.xml are self-explanatory. The next attribute specifies the id of another category (in the same file or in a contribution from plugin.xml) before which this category should be added.

Here is the result of the previously shown contribution: Note, that you can define component outside of new category, so put it into some existing standard category, but in this case you should specify category attribute. <component category="com.instantiations.designer.rcp.composites" class="javax.swing.jradiobutton" name="your name"/> Icon for component can be placed in a png or gif format directly near the component class, with the same name as the component, or in wbp-meta folder, in the same package/folder and same name, but with.png/.gif extension. 1.2. Palette contribution in jar You can place your *.wbp-palette.xml file within the project where you want to edit GUI using WindowBuilder or in any project required by your GUI project or directly in a jar file with contributed components. Just by adding my-components.jar to the classpath will automatically add the components to the palette. If your project does not include the jar, you will not see the corresponding entries on the palette, so they will not consume space. 1.3 Palette contribution from plugin.xml If you want to use more features, for example specify the location of a category relative to other categories (use the next attribute) or always show components and add corresponding jar to the classpath automatically, then you should create a plugin and use Eclipse extensions to contribute to WindowBuilder palette. <extension point="com.instantiations.designer.core.toolkits"> <toolkit id="com.instantiations.designer.rcp"> <classloader-library bundle="com.instantiations.designer.rcp.nebula.lib" jar="cdatetime-0.9.0.jar"/> <palette> <category id="com.instantiations.designer.rcp.nebula" name="nebula" description="nebula custom widgets" next="com.instantiations.designer.rcp.formsapi"> <!-- CDateTime --> <component class="org.eclipse.swt.nebula.widgets.cdatetime.cbutton"> <library type="org.eclipse.swt.nebula.widgets.cdatetime.cbutton" bundle="com.instantiations.designer.rcp.nebula.lib" jar="cdatetime-0.9.0.jar"/> </component> In the XML file shown above, the classloader-library tells WindowBuilder that the cdatetime-0.9.0.jar file should always be added into the ClassLoader (even if it is not in the classpath). This makes it possible for the components to load from the jar file and always displayed on the palette. You should also specify the library element for the component to tell WindowBuilder that some library should be added to the classpath the first time you try to use this component. For a full description of palette related attributes see the toolkits.exsd schema. 1.4 Palette commands in project There are times when you want to use different palettes for different projects (of same

toolkit), or if you want to share the same palette across all the developers working on the same project. You can add an empty xml file called, toolkitid.wbp-palette-commands.xml, within your project's «wbp-meta» folder. When WindowBuilder finds this file, it will save all the operations that you perform on the palette (like moving categories and components, adding new components, etc) into this file and read from it later. For example, after moving the «Layouts» category above the «Containers» category, this file will have the following content: <commands> <movecategory id="com.instantiations.designer.swing.layouts" nextcategory="com.instantiations.designer.swing.containers"/> </commands> 2. Describe component using *.wbp-component.xml WindowBuilder 7.0 allows you to describe as much information about your component that can be used to provide for convenient editing. Just like the <icon>, <description> for component can be placed directly near a component class, with the same name as the component, or in wbpmeta folder, also in the same package/folder and same name. The simplest component description looks like this: <component xmlns="http://www.instantiations.com/d2/wbpcomponent"> <model class="com.instantiations.designer.swt.model.widgets.labelinfo"/> <description>instances of this class represent a non-selectable user interface object that displays a string or image. When SEPARATOR is specified, displays a single vertical or horizontal line.</description> <!-- CREATION --> <creation> <source><![cdata[new org.eclipse.swt.widgets.label(%parent%, org.eclipse.swt.swt.none)]]></source> <invocation signature="settext(java.lang.string)"><![cdata["new Label"]]></invocation> </creation> <creation id="separatorhorizontal" name="horizontal Separator"> <source><![cdata[new org.eclipse.swt.widgets.label(%parent%, org.eclipse.swt.swt.separator org.eclipse.swt.swt.horizontal)]]></source> <description>horizontal separator.</description> </creation> </component> As you can see, you can specify only the <description> attribute and one or more <creation> elements. The <description> attribute can also be skipped, but not recommended, as it is used by default as the description for the component on the palette. Note, that plugin com.instantiations.designer.core includes a XSD schema file, schema/wbpcomponent.xsd that is used for validating *.wbp-component.xml files. It sets fairly strong rules on format, to ensure that your XML editor validates description files as you write them. Components may have different constructors with values bound to some method-based properties. Such constructors rarely used in SWT, but often used in Swing. So, it would be convenient to describe this directly. Here is the description for JLabel. As you can see, you can use the property attribute with method signature (or field name for public field based properties). <!-- CONSTRUCTORS --> <constructors>

</constructors> Note, that you don't have to declare all constructors of your component. You need to do this only if you want to tell WindowBuilder something useful about the constructor. For example that some parameter is bound to some property, or specify default value of parameter (when user presses DEL key on «constructor/parameter» property). Components may have a lot of properties, more than a hundred, for Swing. But you only use a handful of them. So, as a component developer you should specify which properties should be marked as rarely used (advanced), sometimes used (normal) and often used (preferred). Some properties may be even declared as hidden, so they will never be displayed to user, even if the component has it. <!-- PROPERTIES --> <properties-preferred names="text icon labelfor"/> <properties-advanced names="border disabledicon displayedmnemonicindex horizontaltextposition icontextgap verticaltextposition"/> <properties-hidden names="ui"/> WindowBuilder understands a special <tag> property, such as marking it as a «text» property, so you can easily edit its text by pressing the Space key when the component is selected. <property-tag name="text" tag="istext" value="true"/> Properties have different types and for most standard types, WindowBuilder includes a special property editor to use in the properties table. However, there are times when the standard editor is not good enough, for example for integer enumerations. In this case, you should specify a «configurable property editor». <property id="setverticalalignment(int)"> <editor id="staticfield"> <parameter name="class">javax.swing.swingconstants</parameter> <parameter name="fields">top CENTER BOTTOM</parameter> </editor> <property id="sethorizontalalignment(int)"> <editor id="staticfield"> <parameter name="class">javax.swing.swingconstants</parameter> <parameter name="fields">left CENTER RIGHT LEADING TRAILING</parameter> </editor> See Table 1.5 in *.wbp-component.xml documentation for a list of existing configurable editors. If for some reason you don t want to specify a property category using <properties-*> element, you can do this separately for some property. <property id="setdisplayedmnemonic(char)"> <category value="preferred"/> Some components can not be used separately, but are containers that accept other components. Oftentimes, the description in the XML file is enough to support this. There are two types of description based containers: simple (accept only one component) and flow (accept several

components, allow to order them). See the simplecontainer and flowcontainer documentation. 3. Write Java code Sometimes descriptions are not enough. For example you need some special editing behavior, so you should write GEF LayoutEditPolicy. In this case you need to write a plugin to host your models and policies. Here is how you can specify a model for a component in its description: <model class="com.instantiations.designer.swing.model.component.componentinfo"/> Class ComponentInfo is an indirect subclass of JavaInfo that provides basic support for all Java models. Usually all your models will be subclasses of ComponentInfo/ContainerInfo (for Swing) or ControlInfo/CompositeInfo (for SWT). WindowBuilder provides a lot of broadcast notifications that can be used to be informed about some event, or participate in them. For example you may install a listener for adding properties to any component (by your choice), even if it is not yours, see com.instantiations.designer.core.model.broadcast.javaeventlistener.addproperties(javainfo, List<Property>). Or you can be informed that some JavaInfo component was deleted, so you may also want to delete some other resources/source, see com.instantiations.designer.core.model.broadcast.javaeventlistener.deleteafter(javainfo, JavaInfo). 4. Configuring static objects Sometimes you know that your application configures environment in which it executes. For example loads preferences from file/database, configure default settings of layout managers, etc. In most cases you can not execute same Java configuration code, so WindowBuilder provides support for «design time configuration». To use it, create a file called ConfigureClassLoader.mvel in your project's wbp-meta folder. MVEL http://mvel.codehaus.org/ is a powerful expression language for Java-based applications. For example this script sets default insets (we don't recommend to use such strange values :-)) for MigLayout on JPanel containers. import net.miginfocom.layout.*; PlatformDefaults.setPanelInsets( new UnitValue(20), new UnitValue(50), new UnitValue(10), new UnitValue(5));