Posts

Showing posts from 2008

WPF, visibility and hiding controls using presentation models

In WPF, the data context for a control often sets the range of data available for binding. Using a presentation model, you can provide properties that are easy to bind to and provide some conditional display logic. For example, if your presentation model has the following fields: bool HasTitle { get; } string Title { get; } IList DataList { get; } Then you can use these fields to bind. For example, create a new UserControl and in code (say in a spring container) set the DataContext to the presentation model. Then in the resource section of the control: <UserControl.Resources> <CollectionViewSource x:Key="dataList" Source="{Binding Source=DataList}"/> </UserControl.Resource> then use this as the source for your list views, etc. Gn the section where you define the controls that make up the user control you can toggle the visibility of different elements: <Style x:Key="smallTitleStyle" TargetType="TextBlock"> ...

eclipse, RCP, spring, hibernate and XAML Soyatec UPF

After playing around with jface data binding and straight eclipse APIs for building data driven db screens, as well as uface and rolling my own framework modeled after inpowersoft's framework, I am also looking at the XAML product (free but not open source at this point) from soyatec. I have been pleasantly surprised at the quality of the implementation so far and the ability to do easy data binding. The only area where more documentation is needed is where the XAML is backed by a java class and you need to access or set resources or data context's of individual content controls (etc.) In WPF, this happens automatically through partial classes. In UPF, you need to program a little code to make this happen. The API is not obvious but I am working towards a fuller understanding. In addition, I am learning XAML. I have determined that while XML is not the greatest specification language for this, its relatively straight forward and seems to work pretty good. I will complete a min...

presentation frameworks and eclipse RCP

I was looking through XAML again. I like it. While not perfect, I like the underlying presentation framework (WPF) that XAML maps into. XAML itself is not particularly interesting. The presentation framework is, however. In eclipse RCP, the presentation framework also exists but seems to get aborted at the view part level. The workbench part, the view part, etc. all define a logical UI hierarchy with resources (although fairly specific to the RCP). At the view part level, however, the hierarchy starts breaking down. That's where the managed form classes come in. In essence, this logical hierarchy "renders" the UI using createPartControl() using SWT underneath. Personally, I think the presentation framework has alot of good ideas and is generally well constructed. I wish something as flexible as this was used ontop of SWT to build the RCP framework. In a sense, SWT has some of the presentation framework with a logical set of SWT widgets, etc., so its not an alien concep...

hibernate+spring+eclipse: setting the path to HBM files

One issue I have constantly had trouble with is setting the directory of HBM files in a separate plugin than the main plugin in an eclipse+hibernate+spring RCP application. No path specification work except something like the following: <property name="mappingDirectoryLocations"> <list> <value>classpath*:/**/org/top/dirwithmappings</value> </list> </property> The standard examples in the spring and hibernate reference documents never worked for me. This classpath works even when the HBM and POJO files are in a different eclipse plugin. I believe that the hibernate references do not account for an OSGI environment although the syntax obviously helps across different jars.

hibernate tools and the destination package

I've had alot of challenges getting hibernate tools to generate my pojos in 2 separate processing steps. Some teams may generate the POJOS directly with annotations using hibernate tools but I have found that to allow me to make modifications to the POJOs and control various aspects of pojo generation that is not currently supported by the tools or requires changing the template (which is not hard to do) is difficult. For example, if you generate a pojo directly from the JDBC configuration, then you cannot specify an "extends" class unless you change the template. I have found that generating the pojo through a two-step process gives me the control I need without resorting to changing the template. Here is the process I used. Step 1: Create a reveng.xml file for the application. Use this reveng.xml file for Step 2. Step 2: Create HBM files using a dedicated hibernate console and a dedicated code generation configuration. Use the reveng.xml file from Step 1. Step 3: Modif...

eclipse RCP and database applications

Just came across www.inpowersoft.com which has a forms package for eclipse RCP using hibernate. It includes features needed in common db applications such as master detail and most importantly integrates with hibernate so that it also manages transactions, etc. Looks like a good package for Oracle forms-type applications. I like the ideas in the packages and it looks good on the screen as well. I encourage people to look into it. I believe that it brings together and finalizes many small issues that take alot of developer time to implement but are really infrastructure plumbing.

eclipse - common navigator framework (CNF)

CNF is part of the eclipse API that provides a general navigation framework (a tree object) with content that can be provided through eclipse plugin.xml extensions. The hard part though is understanding how to get certain types of content to be linked (bound) to specific content and label providers. For simple hierarchies, this is not a big deal, but for complex hierarchies where the content is spread across plugins and navigation content is provided through multiple specifications of org.eclipse.ui.navigator.navigatorContent extensions. The tricky part is the triggerPoints and possibleChildren specifications. When is each used? Should you always duplicate content into both of these sections. The enablement element is actually provided so you can do exactly that. The only true answer comes from looking at the source code. Since content extensions are provided through plugin.xml specifications and navigatorContent components are lazily instantiated, the underlying CommonViewer uses a c...

long conversations in rich client applications - orchestra

I was looking through some projects and came upon orchestra from apache as part of teh myfaces project. It provides a generic mechanism for conversations. It is geared towards web applications but the framework appears to be quite general, depending on spring scopes, and potentially can be used in rich client applications. I'll investigate and post back here to this blog. I can report back that it all works for rich client applications. Even though it uses spring scopes (where one could just use annotations or conversation names), the framework works. For rich clients, you need a different configuration approach than listed in the myfaces documentation that composes the umbrella project of which orchestra is a subproject. You need to do this once somewhere: FrameworkAdapter.setCurrentInstance((FrameworkAdapter)getBean("orchestraFramework")); Here, I have a method in the same class that has getBean() obtain a bean from the toplevel application context. In that toplevel c...

eclipse and plugin.xml object lifecycle management

Eclipse uses plugins for modularity. The plugins often specify content directed towards the presentation layer (the UI). In many extensions, class names are specified to indicate which class should be used for certain jface and SWT classes, for example, specifying a jface content provider such as ITreeContentProvider. Since the eclipse plugin actually creates the class using this class name, you do not always have object lifecycle control over it. Note that a class specified in the plugin could implement the IExecutableExtensionFactory or IExecutableExtension interface however you may need to have access to the input object to properly create the specified class. If you need the input data to fully initialize or create the class through those executable extension interfaces, then the pattern below will be useful to you. You can also specify a factory class in extension points instead of a class name. The factory will be used to create the instance object. If the factory knows a well-...

XAML-like behavior (or not) in eclipse plugin specs for CommonNavigator

Here's something that is bugging me a bit. In XAML, you can specify data contexts and automatically created hierarchical resource contexts (Resources) fairly easily in markup. In eclipse, say for the common navigator content specification, you specify label and content providers in XML. Then set the input into the common navigator (which is really a tree viewer) in code. I'm okay with the setting the input in code, however, I am unable to control the lifecycle of of the label and content providers directly and hence, cannot do spring initialization and bean post processor tricks to help set properties and behaviors that are really configuration issues (including property dependencies). I guess the only thing to do is to call specific "processors" to run on the label or content provider explicitly in the Viewer.setInput() method when it is called or connect up the instance of the laber or content viewer using a customized FactoryBean that dynamically connects (at the...

Resources in .Net == bean factories in spring?

I was reading through MSDN documentation yesterday and it struck me that the Resources feature in XAML is actually a bean factory in the world of spring. It looks different, but the idea of storing objects defined in XML and making that accessible, and having hierarchical contexts was pretty much like spring. It makes you realize that using spring at a more fundamental level inside of RCP applications could be a good idea. The hierarchical contexts appear to be automatically assembled based on the scope of the resources e.g. Windows.Resource versus Page.Resource I believe are automatically nested. On a separate note, DataContext looks to be the same as a hibernate Session although .Net DataContext has more support for data binding and other features. The DataContext provides identify scoping boundaries, has connection information, etc. The real issue for the eclipse RCP is that the jface GUI elements do not allow more lifecycle control when defined in the plugin extensions. The plugins...

event processing

For the data binding library I authored, swtdatabinding (not SWT dependent actually), I am looking into using an event processing framework to help decouple the event processing and allow me plug-into multiple event frameworks such as that from J2SE or SWT which different classes and semantics but essentially address the same area. Most of the events for data binding are around property change notification of some sort whether it is on a bean or a list. In the market, there are a variety of systems including eventbus and others that are mentioned to address this area. All are targeted towards specific uses. Other event stream or complex event processing (CEP) libraries exist such as esper, JECHo and JMS inside OpenESB (using JBI) as well as commercial offerings in BEA, Websphere and Progress Software. Many of these have easy to use filtering or event processing domain specific languages for specifying filtering criteria and the like. I suggest you investigate these libraries for ide...