Sandro,

Thanks for a nice feedback.

I committed BXML2JavaConver to github already.
So you can download the source code from there.

(
In case, if you are not familiar with git, following is the instruction to
download the source code from github.
1) install git from http://git-scm.com/

2) type:
git close git://github.com/calathus/BXML-to-Java-converter.git

3) this create a folder under directory where the command is executed.
)

By the way, this version was based on the idea to use AOP like interception
for Pivot objects. This approach is quite general, but use a lots of
variables.
And after I recognized the pattern, I think this code should not be used for
this BXML to Java converter.

Now I have almost completed a new version which generates codes with
suggested anonymous class based coding style.
I will commit this version later in github after I fixed some issue.

But if you consider this should be committed to a storage related to apache
project, I would commit this to appropriate place for that.
Anyway I think this requires more testing and review.

Actually I found one problem for using this approach for current Pivot
source code. In order to use this coding style, the Pivot API classes should
not be final. Although most of them are not final, but I found
TableView.Column is defined as final class.(I locally changed this to none
final class to avoid this restriction. Are there any good reason to make
this final?)

-----
By the way, this kind coding style is independent form BXML2Java converter.
We can use this style when we want to write some Pivot application in Java
directly.
That was actually my original goal.

Although BXML based declarative style makes the GUI specification shorter,
when I started using Pivot, I faced a lots of runtime error, and it was
quite difficult to debug, I couldn't see any clue to debug. This
heterogeneous approach mixing, XML, Javascript, etc reminds me old JSP style
approach.

I think, the simplicity of Pivot to use Java for browser and desktop is very
important aspect, but somehow the current strong dependency for (b)xml file
is reducing the power of this approach.(static type checking, generic class
library, debugability etc)
If we use expressive language(even Java), we should be able to get rid of
this kind of mixture.

BTW, I will add a sample output of new code generator with declarative(?)
style (it was generated by new BXM2Java converter from
stock_tracker_window.bxml.)

--------------------


    static class ROOT extends StockTrackerWindow {{
        try {
            setTitle("Pivot Stock Tracker");
            setMaximized(true);
            setContent(new TablePane() {{
                setStyles("{padding:8, horizontalSpacing:6,
verticalSpacing:6}");
                // columns(): READ_ONLY_PROPERTY
                getColumns().add(new TablePane.Column() {{
                    setWidth(1, true);
                }}); // INSTANCE, name: <TablePane.Column>
                getRows().add(new TablePane.Row() {{
                    setHeight(-1);
                    add(new Label() {{
                        setText("Pivot Stock Tracker");
                        setStyles("{font:{size:14, bold:true},
verticalAlignment:'center'}");
                    }}); // INSTANCE, name: <Label>
                }}); // INSTANCE, name: <TablePane.Row>
                getRows().add(new TablePane.Row() {{
                    setHeight(1, true);
                    add(new SplitPane() {{
                        setSplitRatio(0.4f);
                        // left(): WRITABLE_PROPERTY
                        setLeft(new Border() {{
                            setStyles("{color:10}");
                            setContent(new ScrollPane() {{

 setHorizontalScrollBarPolicy(ScrollPane.ScrollBarPolicy.FILL_TO_CAPACITY);

 setVerticalScrollBarPolicy(ScrollPane.ScrollBarPolicy.FILL_TO_CAPACITY);
                                setView(new StackPane() {{
                                    add(new TableView() {{

 CodeEmitterRuntime.register("stocksTableView", this);

 setSelectMode(TableView.SelectMode.MULTI);

 setStyles("{showHorizontalGridLines:false}");
                                        // columns(): READ_ONLY_PROPERTY
                                        getColumns().add(new
TableView.Column() {{
                                            setName("symbol");
                                            setHeaderData("Symbol");
                                            setWidth(1, true);
                                        }}); // INSTANCE, name:
<TableView.Column>
                                        getColumns().add(new
TableView.Column() {{
                                            setName("value");
                                            setHeaderData("Value");
                                            setWidth(1, true);
                                            // cellRenderer():
WRITABLE_PROPERTY
                                            setCellRenderer(new
TableViewNumberCellRenderer() {{

 setStyles("{horizontalAlignment:'right'}");
                                                setNumberFormat("$0.00");
                                            }}); // INSTANCE, name:
<content:TableViewNumberCellRenderer>
                                        }}); // INSTANCE, name:
<TableView.Column>
                                        getColumns().add(new
TableView.Column() {{
                                            setName("change");
                                            setHeaderData("Change");
                                            setWidth(1, true);
                                            // cellRenderer():
WRITABLE_PROPERTY
                                            setCellRenderer(new
ChangeCellRenderer() {{

 setStyles("{horizontalAlignment:'right'}");

 setNumberFormat("+0.00;-0.00");
                                            }}); // INSTANCE, name:
<stocktracker:ChangeCellRenderer>
                                        }}); // INSTANCE, name:
<TableView.Column>
                                    }}); // INSTANCE, name: <TableView>
                                }}); // INSTANCE, name: <StackPane>
                                // columnHeader(): WRITABLE_PROPERTY
                                setColumnHeader(new TableViewHeader() {{

 setTableView((TableView)CodeEmitterRuntime.getNodeValue("stocksTableView"));

 setSortMode(TableViewHeader.SortMode.SINGLE_COLUMN);
                                }}); // INSTANCE, name: <TableViewHeader>
                            }}); // INSTANCE, name: <ScrollPane>
                        }}); // INSTANCE, name: <Border>
                        // right(): WRITABLE_PROPERTY
                        setRight(new Border() {{
                            setStyles("{padding:6, color:10}");
                                add(new BoxPane() {{

 CodeEmitterRuntime.register("detailPane", this);
                                    setOrientation(Orientation.VERTICAL);
                                    setStyles("{fill:true}");
                                    add(new Label() {{
                                        setTextKey("companyName");
                                        setStyles("{font:{size:12,
bold:true}}");
                                    }}); // INSTANCE, name: <Label>
                                    add(new Separator() {{
                                    }}); // INSTANCE, name: <Separator>
                                    add(new Form() {{
                                        setStyles("{padding:0, fill:true,
showFlagIcons:false, showFlagHighlight:false,
leftAlignLabels:true}");
                                        getSections().add(new Form.Section()
{{
                                            final ValueMapping
valueMapping_0 = (new ValueMapping() {{

 CodeEmitterRuntime.register("valueMapping", this);
                                                }}); // INSTANCE, name:
<stocktracker:ValueMapping>
                                            final ChangeMapping
changeMapping_1 = (new ChangeMapping() {{

 CodeEmitterRuntime.register("changeMapping", this);
                                                }}); // INSTANCE, name:
<stocktracker:ChangeMapping>
                                            final VolumeMapping
volumeMapping_2 = (new VolumeMapping() {{

 CodeEmitterRuntime.register("volumeMapping", this);
                                                }}); // INSTANCE, name:
<stocktracker:VolumeMapping>
                                            add(new Label() {{

 CodeEmitterRuntime.register("valueLabel", this);
                                                setTextKey("value");

 setTextBindMapping(valueMapping_0);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this,
"Value");
                                            }}); // INSTANCE, name: <Label>
                                            add(new Label() {{

 CodeEmitterRuntime.register("changeLabel", this);
                                                setTextKey("change");

 setTextBindMapping(changeMapping_1);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this,
"Change");
                                            }}); // INSTANCE, name: <Label>
                                            add(new Label() {{

 CodeEmitterRuntime.register("openingValueLabel", this);
                                                setTextKey("openingValue");

 setTextBindMapping(valueMapping_0);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this, "Open");
                                            }}); // INSTANCE, name: <Label>
                                            add(new Label() {{

 CodeEmitterRuntime.register("highValueLabel", this);
                                                setTextKey("highValue");

 setTextBindMapping(valueMapping_0);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this, "High");
                                            }}); // INSTANCE, name: <Label>
                                            add(new Label() {{

 CodeEmitterRuntime.register("lowValueLabel", this);
                                                setTextKey("lowValue");

 setTextBindMapping(valueMapping_0);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this, "Low");
                                            }}); // INSTANCE, name: <Label>
                                            add(new Label() {{

 CodeEmitterRuntime.register("volumeLabel", this);
                                                setTextKey("volume");

 setTextBindMapping(volumeMapping_2);

 setStyles("{horizontalAlignment:'right'}");
                                                Form.setLabel(this,
"Volume");
                                            }}); // INSTANCE, name: <Label>
                                        }}); // INSTANCE, name:
<Form.Section>
                                    }}); // INSTANCE, name: <Form>
                                }}); // INSTANCE, name: <BoxPane>
                        }}); // INSTANCE, name: <Border>
                    }}); // INSTANCE, name: <SplitPane>
                }}); // INSTANCE, name: <TablePane.Row>
                getRows().add(new TablePane.Row() {{
                    setHeight(-1);
                    add(new BoxPane() {{
                        setStyles("{horizontalAlignment:'left',
verticalAlignment:'center'}");
                        add(new Label() {{
                            setText("Symbol");
                            setStyles("{font:{bold:true}}");
                        }}); // INSTANCE, name: <Label>
                        add(new TextInput() {{
                            CodeEmitterRuntime.register("symbolTextInput",
this);
                            setTextSize(10);
                            setMaximumLength(8);
                        }}); // INSTANCE, name: <TextInput>
                        add(new LinkButton() {{
                            CodeEmitterRuntime.register("addSymbolButton",
this);
                            setEnabled(false);
                            setTooltipText("Add symbol");
                            setButtonData(new ButtonData() {{
                                setIcon(new
URL("file:/share/workspace/pivot/tutorials/src/org/apache/pivot/tutorials/stocktracker/add.png"));
                            }}); // INSTANCE, name: <content:ButtonData>
                        }}); // INSTANCE, name: <LinkButton>
                        add(new LinkButton() {{

 CodeEmitterRuntime.register("removeSymbolsButton", this);
                            setEnabled(false);
                            setTooltipText("Remove selected symbols");
                            setButtonData(new ButtonData() {{
                                setIcon(new
URL("file:/share/workspace/pivot/tutorials/src/org/apache/pivot/tutorials/stocktracker/delete.png"));
                            }}); // INSTANCE, name: <content:ButtonData>
                        }}); // INSTANCE, name: <LinkButton>
                    }}); // INSTANCE, name: <BoxPane>
                }}); // INSTANCE, name: <TablePane.Row>
                getRows().add(new TablePane.Row() {{
                    setHeight(-1);
                    add(new TablePane() {{
                        // columns(): READ_ONLY_PROPERTY
                        getColumns().add(new TablePane.Column() {{
                            setWidth(1, true);
                        }}); // INSTANCE, name: <TablePane.Column>
                        getColumns().add(new TablePane.Column() {{
                            setWidth(-1);
                        }}); // INSTANCE, name: <TablePane.Column>
                        getRows().add(new TablePane.Row() {{
                            add(new BoxPane() {{
                                add(new Label() {{
                                    setText("Last Update");
                                }}); // INSTANCE, name: <Label>
                                add(new Label() {{

 CodeEmitterRuntime.register("lastUpdateLabel", this);
                                }}); // INSTANCE, name: <Label>
                            }}); // INSTANCE, name: <BoxPane>
                            add(new BoxPane() {{
                                setStyles("{horizontalAlignment:'right'}");
                                add(new Label() {{
                                    setText("Data provided by");
                                }}); // INSTANCE, name: <Label>
                                add(new LinkButton() {{

 CodeEmitterRuntime.register("yahooFinanceButton", this);
                                    setButtonData("Yahoo! Finance");
                                }}); // INSTANCE, name: <LinkButton>
                            }}); // INSTANCE, name: <BoxPane>
                        }}); // INSTANCE, name: <TablePane.Row>
                    }}); // INSTANCE, name: <TablePane>
                }}); // INSTANCE, name: <TablePane.Row>
            }}); // INSTANCE, name: <TablePane>
            CodeEmitterRuntime.bind(ROOT.this, "stocksTableView");
            CodeEmitterRuntime.bind(ROOT.this, "symbolTextInput");
            CodeEmitterRuntime.bind(ROOT.this, "addSymbolButton");
            CodeEmitterRuntime.bind(ROOT.this, "removeSymbolsButton");
            CodeEmitterRuntime.bind(ROOT.this, "detailPane");
            CodeEmitterRuntime.bind(ROOT.this, "lastUpdateLabel");
            CodeEmitterRuntime.bind(ROOT.this, "yahooFinanceButton");
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }}


On Tue, Dec 28, 2010 at 3:01 PM, Sandro Martini <[email protected]>wrote:

> Hi all,
> (last time I answered to the other thread, so I repeat here)
>
> @calathus:
> great work !! I think this idea is much interesting from many points of
> view.
> Are you interested in sharing with us even the first code you produced
> (but adding it in a jira ticket, otherwise we will not be able to use
> it, by Apache legal constraints) ?
>
> @all (developers and not only):
> what do you think on have the BXML to Java feature inside a (re-enabled)
> developer-only Tools subproject (or something similar), for the 2.1 release
> ?
> And last:
> the changes that calatus made in BXMLSerializer, maybe could be
> applied to the "standard" version of BXMLSerializer ... or better to a
> Tools-specific extension of it (if could be done) ... open a ticket
> for the 2.1 ?
>
> Bye,
> Sandro
>



-- 
Cheers,
calathus

Reply via email to