Dashboard > Spring Rich Client Project (Spring Rich) > Home > Contributions
  Spring Rich Client Project (Spring Rich) Log In View a printable version of the current page.  
  Contributions
Added by Larry Streepy, last edited by Jonny Wray on Jan 30, 2006  (view change)
Labels: 
(None)

Community Contributions

Please feel free to post any examples, ideas, source code, anything that will help stimulate the RCP community and further the acceptance of the RCP framework.

Authors

Larry Streepy

Samples

Please post (hopefully) complete samples of using the RCP framework in a project setting.

Framework Extensions

Please post new/enhanced classes that extend the RCP framework.

Master/Detail Forms

Integration with JIDE components.

The jide-springrcp project at java.net provides code to integrate Spring RCP with the various components provided by JIDE. Current functionality:

  • A multiple page per application, and multiple view per page implementation within the Spring RCP framework using the JIDE docking framework as the underlying technology.
  • An implementation of the Spring RCP editor concept. The implementation is built on the JIDE docking framework and provides declarative editor support much like that of views.
  • Integration of the JIDE status bar into the Spring RCP framework via some adapter classes.
  • Data binding/binders for a number of JIDE data entry components.
  • Example application that provides an interface to the Google web service. The application is fully functional serves to illustrate the use of Spring RCP, JIDE and the integration code in building a Swing application.

Authors: Jonny Wray

Components

Please post components (implementation, binding and binders) for use within the RCP framework.

ShuttleList

Provided by Larry Streepy, some changes by Benoit Xhenseval

A ShuttleList is a pair of list boxes, one called the source and the other called chosen. There are buttons between the lists to move items from one to the other. I know that this has been implemented numerous times, but I actually couldn't find any code online, and the interesting thing with this implementation is that it provides and Binder and Binding so that it can fit into the RCP framework. The implementation is a little unique in that it really behaves like a different UI implementation for a single list. (I didn't actually do that since I don't know much about creating alternate UI implementations). The ShuttleList presents a typical selection model that represents the "chosen" elements. It can be used identically to the BoundList implementation that is part of RCP. The code is moderately commented, so I hope others can make use of it.

We added the ShuttleList to a new org.springframework.richclient.components package, it this is not suitable you can change it. The file to get is shuttleListComponents.zip.

By default, the component only shows the "chosen" list with a command button beside it to expand the control to show the source list and the control buttons.

The ShuttleList now allows you to select different icons if required; this is done via the model Id in a consistent mode with the rest of Spring RC

So, for a model like this with "myObjectModel" for Id:

HierarchicalFormModel model = FormModelHelper.createCompoundFormModel(myObject,"myObjectModel");

To properly configure the command button, you need to include this in your images.properties file:

myObjectModel.shuttleList.edit=iconName

and if it cannot find it, it will revert to the existing

shuttleList.edit=iconName

I don't know how to specify a default icon for a command button, so if anyone would like to post a fix for this, that would be great!

If there are no icons, it will look for some text which is now configurable:

myObjectModel.shuttleList.editText=Edit...

and if it cannot find it, it will revert to:

shuttleList.editText=...

If there are both icon and text settings, it will display the text setting as a tooltip on the button.

Now a recent change made to the source code relates to text headers for the chosen items and available items. Once again, this is configurable via the usual messagesXX.properties:

For the sourceList, in order of selection:

myObjectModel.shuttleList.sourceList.label=...
shuttleList.sourceList.label=...

For the chosenList, in order of selection:

myObjectModel.shuttleList.chosenList.label=...
shuttleList.chosenList.label=...

If there is no text, no labels are displayed which is the current behaviour.

A picture of the component in the default "unexpanded" mode is here and expanded is here. Here is also a picture that shows 2 headers here.

The class PdbBindingFactory is an example of an extended BindingFactory that will ease the creation of bound ShuttleList components. You'll probably want to change the name of this class or add it's code to your own extension.

The PdbBindingFactory can be made the default factory easily by creating a class that looks like this:

public class PdbBindingFactoryProvider implements BindingFactoryProvider {

    /*
     * (non-Javadoc)
     *
     * @see org.springframework.richclient.form.binding.BindingFactoryProvider#getBindingFactory(org.springframework.binding.form.FormModel)
     */
    public BindingFactory getBindingFactory(FormModel formModel) {
        return new PdbBindingFactory( (ConfigurableFormModel) formModel );
    }

and adding the following entry to the application-context.xml

<bean id="bindingFactoryProvider" class="xxxx.PdbBindingFactoryProvider"/>

Obviously, you'll want to name these classes something that makes sense in your application and this is optional. All you're really trying to get is a BinderFactory that includes the createBoundShuttleList methods.

Regardless of how you accomplish that task, you must register the ShuttleList under controlType for the BinderSelectionStrategy, like this:

<bean id="binderSelectionStrategy"
    class="....SwingBinderSelectionStrategy">  <!-- or any Strategy extending AbstractBinderSelectionStrategy-->
    <property name="bindersForControlTypes">
      <map>
         <entry>
          <key>
            <value type="java.lang.Class">.....ShuttleList</value>
          </key>
          <bean
            class="......ShuttleListBinder">
          </bean>
        </entry>
      </map>
    </property>
...
  </bean>

Once these things have been set up, you can use the new createBoundShuttleList in any Form.

One example of the code to call it (assuming that the Set contains only Strings)

class MyClass {
  private Set mySet;
  ...
}

HierarchicalFormModel formModel = FormModelHelper.createCompoundFormModel(myClass,"myClassModel");
MyForm myForm = new MyForm(formModel);

And the Form:

public class MyForm extends AbstractForm {
  public MyForm(final FormModel formModel) {
   super(formModel, "formId");
  }


protected JComponent createFormControl() {
  PdbBindingFactory pdf = (PdbBindingFactory)getBindingFactory();
  TableFormBuilder formBuilder = new TableFormBuilder(getBindingFactory());
  Collection allEntries = ....
  formBuilder.add(pdf.createBoundShuttleList("mySet", allEntries));
  return formBuilder.getForm();
}
Master-Detail Forms (Spring Rich Client Project (Spring Rich))

Site running on a free Atlassian Confluence Open Source Project License granted to Spring Framework. Evaluate Confluence today.
Powered by Atlassian Confluence, the Enterprise Wiki. (Version: 2.5.5 Build:#811 Jul 25, 2007) - Bug/feature request - Contact Administrators