Showing posts with label swinghtmltemplate. Show all posts
Showing posts with label swinghtmltemplate. Show all posts

Wednesday, June 22, 2011

wizard with swinghtmltemplate

We want to create wizard for creating new persons with swinghtmltemplate. Wizard is a dialog with 3 pages:
  • Greeting
  • Entering data
  • Confirmation

We will store the overall form design in in the default.html. This file contains bottom panel and places the wizard page in specified position. This file can be used as a skin (or layout) later for simular wizards.

This is the final result (click to see animation):



swinghtmltemplate 0.6 released

Happy to announce release 0.6 of my swinghtmltemplate project.

There is an integration with Flying Saucer (xhtmlrenderer) project added in this release, allowing to use real html for component content and mix it with swing components. Read more about it here. You can check it online in the builder tool.

Other changes include:
  • popupMenu component, also available online in the builder tool
  • 'size' atribute for input tag
  • percents can be used as cell width/height in table tag
  • 'onchange' attribute in list tag
  • card layout support
  • bug fixes

Tuesday, May 17, 2011

dnd mockup

I'm testing drag and drop for swinghtmltemplate.

The html code is like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns:j="http://www.oracle.com/swing">
<head>
    <title>DND test</title>
    <meta name='display-as' content="frame"/>
    <meta name='size' content="800 600"/>
    <meta name='onclose' content="exit"/>
</head>
<body style="display: border;">

    <table>
        <tr>
            <td width="fill" height="fill">
                <div>
                    <input type="text" text='test' align="top" dragsource='true'/>
                    <j:scroll>
                        <j:list id='source' droptarget='true'
                                ondblclick='onDblclick' selectedElements='${model.selectedSource}'
                                dragsource='true' accept-mime='sht/tag-source' ondrop='onDrop'>
                            <j:selectItems value='${source}'/>
                        </j:list>
                    </j:scroll>
                </div>
            </td>
            <td width="fill">
                <j:scroll>
                    <j:list id='target' droptarget='true'
                            ondblclick='onDblclick' selectedElements='${model.selectedTarget}'
                            dragsource='true' accept-mime='sht/tag-source' ondrop='onDrop'>
                        <j:selectItems value='${target}'/>
                    </j:list>
                </j:scroll>
            </td>
        </tr>
    </table>

</body>
</html>


Object, that can be used as dnd source, a marked with attribute dragsource='true'. Dnd targets are marked with droptarget='true'. accept-mime specifies the mime for DataFlavor which will be accepted by component. If not specified it will accept any flavor.

The source tag must be able to produce data to be carried in transferData. Currently there is a helper service, which creates transfer data from selection in JTable, JTextComponent, JList and JTree (it depends in tag's component type, not on tag type). After merge to main project this creation process will move to tag. The mime for created transferable is sht/tag-source.

ondrop='onDrop' specifies method name to be invoked on dnd drop. It recieve DropTargetDropEvent as parameter and must return true on drop accept.


Controller's code is under the cut.

Wednesday, May 11, 2011

swinghtmltemplate 0.5 released

New release 0.5 is available for swinghtmltemplate project.

Check an updated documentation, download jars or add this to maven:

<dependencies>
        <dependency>
            <groupId>com.googlecode.swinghtmltemplate</groupId>
            <artifactId>swinghtmltemplate</artifactId>
            <version>0.5</version>
        </dependency>
    </dependencies>


    <repositories>
        <repository>
            <id>swinghtmltemplate</id>
            <name>Swing html template repo</name>
            <url>http://swinghtmltemplate.googlecode.com/svn/maven-repository</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>never</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>


Tuesday, May 10, 2011

selecting swing components in jquery style

The latest commit #527 I've changed the signature of query method. Now it returns the QueryResult object allowing you to manipulate result in jquery style. Check the example:

DomModel model = ...;
model.query(".loginForm label.important").attr("color", "red");

DomModel model = ...;
model.query("input[type='text']").each(new Visitor() {
  public void visit(Tag tag) {
    JTextField f = tag.getComponent();
    if (StringUtils.isNotEmpty(f.getText()) {
       f.setEnabled(false);
    }
  }
});

Maybe I should think about some animation support, like:

DomModel model = ...;
//start 'shake' effect on components
model.query(".loginForm label.important").animate("shake");

The version 0.5 will include this functionality. It will be released soon as I finish documenting new features. By the way, you can checkout the trunk, build it and use it. I hope no changes in the code will be made until the release (except for bug fixes).

Friday, May 6, 2011

Matrix binded to formTable

I've just updated builder tool of my swinghtmltemplate project with new example of formTable binded to the large matrix (35x35 in the example). I want to see how quickly JTable is updated when binded data is changed.

You can find it in "Tags/Matrix binded to formTable". Open an example (dbl click on it), build it ("Build" button below the code) and press dump button (below the table).

In the dump listner I update every matrix value with random number. On my PC (Dual Core E6700@3.2GHz, 8Gb Ram) it has a delay for about one second before table is updated after the first click. Later clicks update table little bit faster.

On my boss's PC there's almost no delay.

The matrix is just a List<java.util.List<Data>> datas;. Each element is special Data class, you can examine it in the "Code" tab. It has "value" property.

Thursday, May 5, 2011

background-image attribute in swinghtmltemplate

Just made a commit to swinghtmltemplate project. The new feature is 'background-attribute' support.

Sorry for white ugly borders, i'm neither a designer, nor a drawer :)

Thursday, April 28, 2011

swinghtmltemplate builder tool with groovy

I've just uploaded an updated version of builder tool for swinghtmltemplate project. Now it supports binding html form to groovy class.

This way you can create dynamic forms with custom logic in java (groovy actually) at runtime.





Animated screenshot is under cut

Tuesday, April 26, 2011

swinghtmltemplate builder tool

I've made a simple form editor for swinghtmltemplate project. It is available usung webstart from here.

Monday, April 25, 2011

dataTable usage

I've commited the wiki page with the description of usage. You can read it here.

This tag allows you to bind Collection of items to the JTable row, so adding and removing items will immediately update table's content.

Thursday, April 21, 2011

Beans binding with human face

In my previous article I've showed how to easily compose swing forms with html markup. Since that time my swinghtmltemplate library moved to version 0.3 with beans binding support. Here I'll show basic examples of using binding.

swinghtmltemplate 0.3 released

Happy to announce the 0.3 version of my swinghtmltemplate project.
New version includes beans binding support, new tags (dataTable, formTable etc), bug fixes.

Check documentation for this release here

You can download jars here, or you can use maven:


  
    com.googlecode.swinghtmltemplate
    swinghtmltemplate
    0.3
  



  
    swinghtmltemplate
    Swing html template repo
    http://swinghtmltemplate.googlecode.com/svn/maven-repository
    
       true
       never
    
    
       false
    
 

Thursday, November 25, 2010

Ease Swing GUI Creation with HTML Templating

Creating GUI in Java is rather difficult. Ordinary code looks like:

JPanel south = new JPanel(new BorderLayout());  
south.add(new JLabel(«login»), BorderLayout.WEST); 
south.add(new JTextField(),BorderLayout.CENTER);
rootPanel.add(south, BorderLayout.SOUTH);


Imagine that you have 15 fields... TableLayout and MigLayout ease layout for many fields, but anyway you have to write Java code.

swinghtmltemplate

I'm developing new library which helps making markup of swing forms using html code.
The library is called swinghtmltamplate, you can find it here.
Documentation is also available in english and in russian.

The small introduction can be found at  codeproject.com.

Я разрабатываю библиотеку для описания swing форм с помощью html.
Библиотека называется swinghtmltemplate, код доступен здесь.
Также есть документация на английском и на русском.

Небольшая статья о библиотеке есть на codeproject.com.