Friday, May 20, 2011

Add local jars to maven

Here is the guide to add local project jars to maven:
http://dchekmarev.ru/blog/article/1269622277

Thursday, May 19, 2011

Intellij Idea

Examined Idea sources. It seems they use JLayeredPane to draw rectangles and different line over the components while dnd'ing. For example when dragging over a JTree this will draw an a rectangle around the node beeing dragged over

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

Flash with gif stub

To make the flash banner with gif stub you can use the code, provided here:

http://www.alistapart.com/articles/flashsatay/


Things to notice:
  • do not use <embed> within <object> or you'll get both flash and image displayed. Do not use <embed> at all - it is old tag from netscape
  • change classid and codebase to type and data
The final markup will look like:
<object type="application/x-shockwave-flash" data="c.swf?path=movie.swf" width="400" height="300">
  <param name="movie" value="c.swf?path=movie.swf" />
  <img src="noflash.gif" width="200" height="100" alt="" />
</object>

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 :)