You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by calathus <ca...@gmail.com> on 2011/01/03 09:22:24 UTC
Re: [pivot] are there any tools to convert bxml to Java?
Sandro,
I fixed a bug(add=>setContent for embedded node), and made a few
improvements, now the sample StockTracker is now working.
I updated the github site including the READEME file with the new generated
Java code:
https://github.com/calathus/bxml2Java
Although there are a few more issues, this would be a good starting point.
I will report some of the issues I faced later.
(e.g, the attribute setting invocation sometimes must be called after all
elements are added.. but this looks not good API design for Pivot..)
On Thu, Dec 30, 2010 at 1:32 AM, Sandro Martini <sa...@gmail.com>wrote:
>
> Hi,
> thanks for the new link, but as you I'm too much busy at the moment (and I
> have not so much knowledge on BXML internals at the moment) ... if you do
> not hurry I can try to take a look in next weeks, and tell you.
>
> Greg (and others) what do you think on see what should be changed in
> BXMLSerializer (for the 2.1 release) to enable a subclass of it to do the
> code generation stuff ?
> I can add a jira ticket and put some info there so we can keep track of
> this
> ... tell me.
>
> Bye,
> Sandro
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/pivot-are-there-any-tools-to-convert-bxml-to-Java-tp2118284p2166783.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> The current code does not handle listener code in BXML.
> These restriction may be removed if someone who know BXML well.
> But for me, some JS based BXML file translated in Java uisng JS interpreter seems not so appealing situation.
> Why do we want to use JS in Java?
It is sometimes convenient to use JS. Also, it allows us to execute code that is not compiled (for example, in BXML that is generated by a server or an authoring tool). Finally, you are not restricted to JS - you can use any JVM scripting language, such as Groovy or Clojure.
> So I have not tried much for supporting this aspect.
I don't think that will be a problem. If you are converting BXML to Java, you probably don't want to use script anyways. You may however still want to define event/handler mappings in BXML, such that Java methods will be invoked instead of script functions - I have been prototyping a way to make this easier and will be sharing the results soon.
> Also in order to support this style of code generation, some of the final class definition must be changed in Pivot.
These classes are final by design. Making them final allows them to be treated more like "structs" in JVMs that support advanced escape analysis. They are not meant to be instantiated or manipulated in BXML (though you can use them in script).
> and some handling of attribute evaluation order is desirable.
As I mentioned in my previous email, attribute ordering is only relevant if the generated code is meant to be human-readable (which I do not see as a priority).
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
Hi,
The current code does not handle listener code in BXML.
These restriction may be removed if someone who know BXML well.
But for me, some JS based BXML file translated in Java uisng JS interpreter
seems not so appealing situation.
Why do we want to use JS in Java?
So I have not tried much for supporting this aspect.
Also in order to support this style of code generation, some of the final
class definition must be changed in Pivot. and some handling of attribute
evaluation order is desirable.
Followings are the classes using final under wtk. I think some of class
(e.g, sequence) do not have to be none final since they are not used for
this anonymous class style instance creation.
# grep -R "final class" * | grep java:
src/org/apache/pivot/wtk/text/TextNode.java:public final class TextNode
extends Node {
src/org/apache/pivot/wtk/BrowserApplicationContext.java:public final class
BrowserApplicationContext extends ApplicationContext {
src/org/apache/pivot/wtk/BrowserApplicationContext.java: public static
final class HostApplet extends Applet {
src/org/apache/pivot/wtk/Accordion.java: public final class PanelSequence
implements Sequence<Component>, Iterable<Component> {
src/org/apache/pivot/wtk/Display.java:public final class Display extends
Container {
src/org/apache/pivot/wtk/Component.java: public final class
StyleDictionary implements Dictionary<String, Object>, Iterable<String> {
src/org/apache/pivot/wtk/Component.java: public final class
UserDataDictionary implements
src/org/apache/pivot/wtk/Component.java: public final class
DecoratorSequence implements Sequence<Decorator>,
src/org/apache/pivot/wtk/Span.java:public final class Span {
src/org/apache/pivot/wtk/TreeView.java: public static final class
PathComparator implements Comparator<Path> {
src/org/apache/pivot/wtk/Menu.java: public final class SectionSequence
implements Sequence<Section>, Iterable<Section> {
src/org/apache/pivot/wtk/DesktopApplicationContext.java://public final class
DesktopApplicationContext extends ApplicationContext {
src/org/apache/pivot/wtk/Point.java:public final class Point implements
Serializable {
src/org/apache/pivot/wtk/TableView.java: public static final class Column
{
src/org/apache/pivot/wtk/TableView.java: public final class
ColumnSequence implements Sequence<Column>, Iterable<Column> {
src/org/apache/pivot/wtk/TableView.java: public final class
SortDictionary implements Dictionary<String, SortDirection>,
Iterable<String> {
src/org/apache/pivot/wtk/Prompt.java: public final class OptionSequence
implements Sequence<Object>, Iterable<Object> {
src/org/apache/pivot/wtk/Insets.java:public final class Insets implements
Serializable {
src/org/apache/pivot/wtk/ScrollBar.java: public static final class Scope
{
src/org/apache/pivot/wtk/Dimensions.java:public final class Dimensions
implements Serializable {
src/org/apache/pivot/wtk/Keyboard.java:public final class Keyboard {
src/org/apache/pivot/wtk/Keyboard.java: public static final class
KeyStroke {
src/org/apache/pivot/wtk/Keyboard.java: public static final class KeyCode
{
src/org/apache/pivot/wtk/MenuBar.java: public final class ItemSequence
implements Sequence<Item>, Iterable<Item> {
src/org/apache/pivot/wtk/CornerRadii.java:public final class CornerRadii
implements Serializable {
src/org/apache/pivot/wtk/TabPane.java: public final class TabSequence
implements Sequence<Component>, Iterable<Component> {
src/org/apache/pivot/wtk/GraphicsUtilities.java:public final class
GraphicsUtilities {
src/org/apache/pivot/wtk/TextArea.java: public static final class
Paragraph {
src/org/apache/pivot/wtk/TextArea.java: public final class
ParagraphSequence implements Sequence<Paragraph>, Iterable<Paragraph> {
src/org/apache/pivot/wtk/TablePane.java: public final class RowSequence
implements Sequence<Row>, Iterable<Row> {
src/org/apache/pivot/wtk/TablePane.java: public final class
ColumnSequence implements Sequence<Column>, Iterable<Column> {
src/org/apache/pivot/wtk/TablePane.java: public static final class Filler
extends Component {
src/org/apache/pivot/wtk/Clipboard.java:public final class Clipboard {
src/org/apache/pivot/wtk/Automation.java:public final class Automation {
src/org/apache/pivot/wtk/skin/GridPaneSkin.java: protected final class
Metadata {
src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java: public final
class ColorChooserPopup extends Window {
src/org/apache/pivot/wtk/skin/ColorChooserButtonSkin.java: public final
class ColorChooserPopupSkin extends WindowSkin {
src/org/apache/pivot/wtk/Action.java: public static final class
NamedActionDictionary
src/org/apache/pivot/wtk/Mouse.java:public final class Mouse {
src/org/apache/pivot/wtk/content/TableViewMultiCellRenderer.java: public
static final class RendererMapping {
src/org/apache/pivot/wtk/Limits.java:public final class Limits implements
Serializable {
src/org/apache/pivot/wtk/Form.java: public final class SectionSequence
implements Sequence<Section>, Iterable<Section> {
src/org/apache/pivot/wtk/ApplicationContext.java: public static final
class ResourceCacheDictionary
src/org/apache/pivot/wtk/ApplicationContext.java: public static final
class ScheduledCallback extends TimerTask {
src/org/apache/pivot/wtk/Alert.java: public final class OptionSequence
implements Sequence<Object>, Iterable<Object> {
src/org/apache/pivot/wtk/Bounds.java:public final class Bounds implements
Serializable {
src/org/apache/pivot/wtk/GridPane.java: public static final class Row
implements Sequence<Component>, Iterable<Component> {
src/org/apache/pivot/wtk/GridPane.java: public final class RowSequence
implements Sequence<Row>, Iterable<Row> {
----------------
I have already changed following classes to none final so that the generated
Java codes for tutorial bxml files can be compiled.
src/org/apache/pivot/wtk/DesktopApplicationContext.java://public final class
DesktopApplicationContext extends ApplicationContext {
src/org/apache/pivot/wtk/TableView.java:// public static final class
Column {
src/org/apache/pivot/wtk/TablePane.java:// public static final class
Filler extends Component {
src/org/apache/pivot/wtk/GridPane.java:// public static final class Row
implements Sequence<Component>, Iterable<Component> {
On Mon, Jan 3, 2011 at 5:38 AM, Sandro Martini <sa...@gmail.com>wrote:
>
> Hi Calatus,
>
> > I fixed a bug(add=>setContent for embedded node), and made a few
> > improvements, now the sample StockTracker is now working. I updated the
> > github site including the READEME file with the new generated Java code:
> Very good, I'll try to take a look as soon as possible :-) ...
>
> I hope for the 2.1 we will be able to merge the required enhancements to
> Pivot with Todd prototype of BXMLCompiler ... so your sample could be
> simplified a lot.
>
> Bye,
> Sandro
>
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/pivot-are-there-any-tools-to-convert-bxml-to-Java-tp2118284p2184776.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Sandro Martini <sa...@gmail.com>.
Hi Calatus,
> I fixed a bug(add=>setContent for embedded node), and made a few
> improvements, now the sample StockTracker is now working. I updated the
> github site including the READEME file with the new generated Java code:
Very good, I'll try to take a look as soon as possible :-) ...
I hope for the 2.1 we will be able to merge the required enhancements to
Pivot with Todd prototype of BXMLCompiler ... so your sample could be
simplified a lot.
Bye,
Sandro
--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/pivot-are-there-any-tools-to-convert-bxml-to-Java-tp2118284p2184776.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> I'm not familar with the implemetation of selectedIndex, but my guess is that it is used when some getSelectedElement is called. If that is the case, if there are no selected element is found, it can use the selectedDefaultIndex information to get the element from the elements. These or some lazy evaluation function are often used idiom, it is not umbiguos.
Again, Pivot components have no knowledge of "elements". "selectedIndex" simply maps to getSelectedIndex() and setSelectedIndex() in the TabPane class.
> As I said, (although I mentioned code generator), my main concern is what kind of hand write coding style can be supported with Pivot library.
> If there is not much such exception like selectedIndex, I do not care much for this issue.
These cases certainly exist, but they are not the common case.
> But I think there are useful information for you to understand what kind of problems pivot users would face when they start writing Java code directly.
I do understand these issues. Pivot is fundamentally a Java UI toolkit. Originally, it didn't even have a markup language - all user interfaces were constructed entirely programmatically. We added markup support later for the sake of convenience and readability.
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 3:37 PM, Greg Brown <gk...@verizon.net> wrote:
> > It would be confusing to change the semantics of existing selectedIndex.
> It looks like very imperative operator which is not appropriate for using
> element attribute declaration.
>
> ...and yet BXML, which uses attributes extensively, handles it just fine.
> :-)
>
> > The clearer approach would be to introduce new declarative attribute
> operator like selectedDefaultIndex, which will not apply immediately for the
> existing element list.
>
> When would it be applied? This is what I mean when I say it would be more
> confusing. I know immediately what "selectedIndex" and setSelectedIndex()
> do. I have no idea what "selectedDefaultIndex" means.
>
I'm not familar with the implemetation of selectedIndex, but my guess is
that it is used when some getSelectedElement is called. If that is the case,
if there are no selected element is found, it can use the
selectedDefaultIndex information to get the element from the elements. These
or some lazy evaluation function are often used idiom, it is not umbiguos.
>
> > But as you will see, we need to know which attributes need to be defined
> later, we must have detailed knowledge for the API. these are not so
> easy/simple API for the user.
>
> I think you may be getting hung up on trying to automatically generate code
> that is organized the way you want it. A developer writing out your builder
> syntax by hand will know when it is appropriate to call each setter, and
> (once again) it does not matter where these attributes are set in generated
> code.
>
As I said, (although I mentioned code generator), my main concern is what
kind of hand write coding style can be supported with Pivot library.
If there is not much such exception like selectedIndex, I do not care much
for this issue.
But I think there are useful information for you to understand what kind of
problems pivot users would face when they start writing Java code directly.
>
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> It would be confusing to change the semantics of existing selectedIndex. It looks like very imperative operator which is not appropriate for using element attribute declaration.
...and yet BXML, which uses attributes extensively, handles it just fine. :-)
> The clearer approach would be to introduce new declarative attribute operator like selectedDefaultIndex, which will not apply immediately for the existing element list.
When would it be applied? This is what I mean when I say it would be more confusing. I know immediately what "selectedIndex" and setSelectedIndex() do. I have no idea what "selectedDefaultIndex" means.
> But as you will see, we need to know which attributes need to be defined later, we must have detailed knowledge for the API. these are not so easy/simple API for the user.
I think you may be getting hung up on trying to automatically generate code that is organized the way you want it. A developer writing out your builder syntax by hand will know when it is appropriate to call each setter, and (once again) it does not matter where these attributes are set in generated code.
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 2:07 PM, Greg Brown <gk...@verizon.net> wrote:
> > If the bxml definition(or GUI) is so simple, this attributes order would
> not be a big issue.
> > but if we have more complex definition like stock_tracker_window.bxml
> file, the corresponding Java code will be following big size.
> > You would imagine how frustration to find corresponding element from
> attribute definitions if they are moved to after inner class definitions.
>
> If you prefer to see most of your attribute setters before the creation of
> the sub-elements, there's no reason you can't do that. However, there's
> simply no way to avoid calling some setters after sub-element creation. I
> don't see this as a big deal at all, and I actually think it helps improve
> readability - it makes it obvious that those setters depend on the prior
> code having been executed.
>
> And again, this only applies to hand-coded builder code. For the reasons I
> mentioned before, it isn't relevant to generated code. I understand that it
> would be ideal to be able to put all of your setters in one place, but
> logically it just doesn't work (unless you do some sort of deferred set,
> which I actually think has the potential to make the code more confusing).
>
It would be confusing to change the semantics of existing selectedIndex. It
looks like very imperative operator which is not appropriate for using
element attribute declaration.
The clearer approach would be to introduce new declarative attribute
operator like selectedDefaultIndex, which will not apply immediately for the
existing element list.
As a workaround, I would change the code so that selectedIndex java code
will be commented out, but declared at opening tag.
then only selectedIndex type java code will be generated at the closing tag
without comment.
But as you will see, we need to know which attributes need to be defined
later, we must have detailed knowledge for the API. these are not so
easy/simple API for the user.
>
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> If the bxml definition(or GUI) is so simple, this attributes order would not be a big issue.
> but if we have more complex definition like stock_tracker_window.bxml file, the corresponding Java code will be following big size.
> You would imagine how frustration to find corresponding element from attribute definitions if they are moved to after inner class definitions.
If you prefer to see most of your attribute setters before the creation of the sub-elements, there's no reason you can't do that. However, there's simply no way to avoid calling some setters after sub-element creation. I don't see this as a big deal at all, and I actually think it helps improve readability - it makes it obvious that those setters depend on the prior code having been executed.
And again, this only applies to hand-coded builder code. For the reasons I mentioned before, it isn't relevant to generated code. I understand that it would be ideal to be able to put all of your setters in one place, but logically it just doesn't work (unless you do some sort of deferred set, which I actually think has the potential to make the code more confusing).
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
If the bxml definition(or GUI) is so simple, this attributes order would not
be a big issue.
but if we have more complex definition like stock_tracker_window.bxml file,
the corresponding Java code will be following big size.
You would imagine how frustration to find corresponding element from
attribute definitions if they are moved to after inner class definitions.
static StockTrackerWindow create() throws Exception {
return new StockTrackerWindow() {{
final Map<String, Object> namespace = new HashMap<String, Object>();
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() {{
namespace.put("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)namespace.get("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}");
setContent(new BoxPane() {{
namespace.put("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() {{
namespace.put("valueMapping", this);
}}); // INSTANCE,
name: <stocktracker:ValueMapping>
final ChangeMapping
changeMapping_1 = (new ChangeMapping() {{
namespace.put("changeMapping", this);
}}); // INSTANCE,
name: <stocktracker:ChangeMapping>
final VolumeMapping
volumeMapping_2 = (new VolumeMapping() {{
namespace.put("volumeMapping", this);
}}); // INSTANCE,
name: <stocktracker:VolumeMapping>
add(new Label() {{
namespace.put("valueLabel", this);
setTextKey("value");
setTextBindMapping(valueMapping_0);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "Value");
}}); // INSTANCE, name: <Label>
add(new Label() {{
namespace.put("changeLabel", this);
setTextKey("change");
setTextBindMapping(changeMapping_1);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "Change");
}}); // INSTANCE, name: <Label>
add(new Label() {{
namespace.put("openingValueLabel", this);
setTextKey("openingValue");
setTextBindMapping(valueMapping_0);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "Open");
}}); // INSTANCE, name: <Label>
add(new Label() {{
namespace.put("highValueLabel", this);
setTextKey("highValue");
setTextBindMapping(valueMapping_0);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "High");
}}); // INSTANCE, name: <Label>
add(new Label() {{
namespace.put("lowValueLabel", this);
setTextKey("lowValue");
setTextBindMapping(valueMapping_0);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "Low");
}}); // INSTANCE, name: <Label>
add(new Label() {{
namespace.put("volumeLabel", this);
setTextKey("volume");
setTextBindMapping(volumeMapping_2);
setStyles("{horizontalAlignment:'right'}");
Form.setLabel(this, "Volume");
}}); // INSTANCE, name: <Label>
}}); // INSTANCE, name: <Form.Section>
}}); // INSTANCE, name: <Form>
CodeEmitterRuntime.initialize(this, namespace);
}}); // 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() {{
namespace.put("symbolTextInput", this);
setTextSize(10);
setMaximumLength(8);
}}); // INSTANCE, name: <TextInput>
add(new LinkButton() {{
namespace.put("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() {{
namespace.put("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() {{
namespace.put("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() {{
namespace.put("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(this, namespace, "stocksTableView");
CodeEmitterRuntime.bind(this, namespace, "symbolTextInput");
CodeEmitterRuntime.bind(this, namespace, "addSymbolButton");
CodeEmitterRuntime.bind(this, namespace, "removeSymbolsButton");
CodeEmitterRuntime.bind(this, namespace, "detailPane");
CodeEmitterRuntime.bind(this, namespace, "lastUpdateLabel");
CodeEmitterRuntime.bind(this, namespace, "yahooFinanceButton");
CodeEmitterRuntime.initialize(this, namespace);
}};
}
On Mon, Jan 3, 2011 at 1:35 PM, Greg Brown <gk...@verizon.net> wrote:
> Here's an example of what I mean. The following two files generate the
> exact same output:
>
>
> http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java
>
> http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml
>
> The Java version uses your builder pattern, but sets the property values
> after processing the child content. I don't think readability suffers in the
> least - the logic is still quite easy to follow.
>
> G
>
> On Jan 3, 2011, at 4:09 PM, Greg Brown wrote:
>
> >> I understand your position. But the attribute order, final classes
> issues are independent from BXML to Java converter.
> >> The current API will prohibit readable Java code written by hand.
> >> If you check the generated code sample in my github, and move all
> attributes after all of inner elements declaration, you will not like to
> have that codes.
> >
> > The final class issue is definitely a problem for your pattern. But I
> don't see the issue with attribute ordering. There's simply no way to set
> the selectedIndex property of a tab pane before the tabs have been created.
> It has to be done afterwards.
> >
> >
> >
> >
> >
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
Here's an example of what I mean. The following two files generate the exact same output:
http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/builder/BuilderExample.java
http://svn.apache.org/repos/asf/pivot/trunk/examples/src/org/apache/pivot/examples/builder/builder_example.bxml
The Java version uses your builder pattern, but sets the property values after processing the child content. I don't think readability suffers in the least - the logic is still quite easy to follow.
G
On Jan 3, 2011, at 4:09 PM, Greg Brown wrote:
>> I understand your position. But the attribute order, final classes issues are independent from BXML to Java converter.
>> The current API will prohibit readable Java code written by hand.
>> If you check the generated code sample in my github, and move all attributes after all of inner elements declaration, you will not like to have that codes.
>
> The final class issue is definitely a problem for your pattern. But I don't see the issue with attribute ordering. There's simply no way to set the selectedIndex property of a tab pane before the tabs have been created. It has to be done afterwards.
>
>
>
>
>
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> I understand your position. But the attribute order, final classes issues are independent from BXML to Java converter.
> The current API will prohibit readable Java code written by hand.
> If you check the generated code sample in my github, and move all attributes after all of inner elements declaration, you will not like to have that codes.
The final class issue is definitely a problem for your pattern. But I don't see the issue with attribute ordering. There's simply no way to set the selectedIndex property of a tab pane before the tabs have been created. It has to be done afterwards.
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 12:34 PM, Greg Brown <gk...@verizon.net> wrote:
> > OK, I'm not actually thinking BXML should be abandoned. There are many
> type of user and usage scenario which would fit BXML approach.
> > But these approach is static, it is not good fit for creating more
> dynamic library for GUI(for instance the number of table columns are changed
> based on passed parameter class).
> > Since you put low priority for supporting readable Java code generation,
> I thought you may not be interested in this type of approach.
>
> I don't see the value in trying to generate "readable" Java code from BXML.
> If you are a developer who prefers to declare your UI in Java (perhaps using
> your builder approach), then you probably won't be using BXML anyways and
> won't care what the generated code looks like. If you are a developer who
> prefers BXML, you most likely will never look at the generated code, since
> presumably you want to continue developing in BXML and only use the compiler
> for the performance or compile-time type safety benefits.
>
I understand your position. But the attribute order, final classes issues
are independent from BXML to Java converter.
The current API will prohibit readable Java code written by hand.
If you check the generated code sample in my github, and move all attributes
after all of inner elements declaration, you will not like to have that
codes.
> Besides, all we're really talking about here is where generated attribute
> setters go. The generated code would still be quite readable - it just may
> not be organized exactly the way you would do it had you written it by hand.
> To me, that's just not a major issue.
>
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> OK, I'm not actually thinking BXML should be abandoned. There are many type of user and usage scenario which would fit BXML approach.
> But these approach is static, it is not good fit for creating more dynamic library for GUI(for instance the number of table columns are changed based on passed parameter class).
> Since you put low priority for supporting readable Java code generation, I thought you may not be interested in this type of approach.
I don't see the value in trying to generate "readable" Java code from BXML. If you are a developer who prefers to declare your UI in Java (perhaps using your builder approach), then you probably won't be using BXML anyways and won't care what the generated code looks like. If you are a developer who prefers BXML, you most likely will never look at the generated code, since presumably you want to continue developing in BXML and only use the compiler for the performance or compile-time type safety benefits.
Besides, all we're really talking about here is where generated attribute setters go. The generated code would still be quite readable - it just may not be organized exactly the way you would do it had you written it by hand. To me, that's just not a major issue.
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 12:10 PM, Greg Brown <gk...@verizon.net> wrote:
> > Pivot definitely can support Java in similar level as Swing.
> > So at this level, I think there are not much disagreement.
> >
> > Also you would think swing style is not usable, so you introduced BXML.
> > But I want to have an usable Java framework without relying on external
> framework(XML)
> > I wonder why you are not interesting in this type of approach.
>
> What makes you think I am not interested? I have already said repeatedly
> that I like the approach you have suggested. But I think that it should be
> an addition to the existing XML approach, not a replacement for it.
>
OK, I'm not actually thinking BXML should be abandoned. There are many type
of user and usage scenario which would fit BXML approach.
But these approach is static, it is not good fit for creating more dynamic
library for GUI(for instance the number of table columns are changed based
on passed parameter class).
Since you put low priority for supporting readable Java code generation, I
thought you may not be interested in this type of approach.
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> Pivot definitely can support Java in similar level as Swing.
> So at this level, I think there are not much disagreement.
>
> Also you would think swing style is not usable, so you introduced BXML.
> But I want to have an usable Java framework without relying on external framework(XML)
> I wonder why you are not interesting in this type of approach.
What makes you think I am not interested? I have already said repeatedly that I like the approach you have suggested. But I think that it should be an addition to the existing XML approach, not a replacement for it.
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 11:54 AM, Greg Brown <gk...@verizon.net> wrote:
> > Vaadin is quite old project around 10 year old.(they renamed it recently)
>
> Ah, that makes sense. It did seem pretty mature for what seemed like such a
> young product.
>
> > Anyway, it is more costructive to have better model than just following
> old model/style like swing.
> > I personally did not interested in using these Java API before since it
> was so messy.
>
> I agree with you - that's why we created BXML. However, saying that you
> would prefer a better approach is not the same thing as saying that Pivot
> does not support Java.
>
Pivot definitely can support Java in similar level as Swing.
So at this level, I think there are not much disagreement.
Also you would think swing style is not usable, so you introduced BXML.
But I want to have an usable Java framework without relying on external
framework(XML)
I wonder why you are not interesting in this type of approach.
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> Vaadin is quite old project around 10 year old.(they renamed it recently)
Ah, that makes sense. It did seem pretty mature for what seemed like such a young product.
> Anyway, it is more costructive to have better model than just following old model/style like swing.
> I personally did not interested in using these Java API before since it was so messy.
I agree with you - that's why we created BXML. However, saying that you would prefer a better approach is not the same thing as saying that Pivot does not support Java.
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 11:16 AM, Greg Brown <gk...@verizon.net> wrote:
> > I think just telling the technological possibility is not good enough to
> claim Java API based approach is supported.(it similar to claim machine
> language can support anything)
>
> Huh? Have you actually looked at the Javadoc? It isn't just a
> "technological possibility" - the entire platform is written in Java! Take
> BXML out of the picture and every feature would still work.
>
> > If it can support readable GUI description in Java, we should claim it
> supports Java API based development.
>
> Here is an example of a readable Pivot GUI description in Java:
>
> PushButton pushButton = new PushButton();
> pushButton.setButtonData("My Button");
>
> The builder syntax you proposed is nice, but it is certainly not a
> requirement for saying that Pivot supports Java development. It is simply a
> design pattern. Would you say that Swing does not support Java development
> because it does not provide a builder syntax? If so, I doubt that you would
> find many who would agree.
>
> > Yes, Vaadin is server based stateful session approach. So it has a
> problem to support cloud based server infrastructure like Google app engine.
> > That was the main reason I was more interested in Pivot.
> > But for GUI developing phase, these difference of deployment approach are
> not much noticeable. In this sense, I thought Pivot and Vaadin is similar.
> And I expected Pivot be similar to Vaadin when I start evaluating Pivot.
>
> You may want to adjust that expectation. We did not model the design of
> Pivot on Vaadin in any way. In fact, I'm not even sure that Vaadin existed
> when Pivot 1.0 was released. Pivot's architecture was much more heavily
> influenced by the design of Swing, Flex, and WPF.
>
Vaadin is quite old project around 10 year old.(they renamed it recently)
Anyway, it is more costructive to have better model than just following old
model/style like swing.
I personally did not interested in using these Java API before since it was
so messy.
>
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> I think just telling the technological possibility is not good enough to claim Java API based approach is supported.(it similar to claim machine language can support anything)
Huh? Have you actually looked at the Javadoc? It isn't just a "technological possibility" - the entire platform is written in Java! Take BXML out of the picture and every feature would still work.
> If it can support readable GUI description in Java, we should claim it supports Java API based development.
Here is an example of a readable Pivot GUI description in Java:
PushButton pushButton = new PushButton();
pushButton.setButtonData("My Button");
The builder syntax you proposed is nice, but it is certainly not a requirement for saying that Pivot supports Java development. It is simply a design pattern. Would you say that Swing does not support Java development because it does not provide a builder syntax? If so, I doubt that you would find many who would agree.
> Yes, Vaadin is server based stateful session approach. So it has a problem to support cloud based server infrastructure like Google app engine.
> That was the main reason I was more interested in Pivot.
> But for GUI developing phase, these difference of deployment approach are not much noticeable. In this sense, I thought Pivot and Vaadin is similar. And I expected Pivot be similar to Vaadin when I start evaluating Pivot.
You may want to adjust that expectation. We did not model the design of Pivot on Vaadin in any way. In fact, I'm not even sure that Vaadin existed when Pivot 1.0 was released. Pivot's architecture was much more heavily influenced by the design of Swing, Flex, and WPF.
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 10:08 AM, Greg Brown <gk...@verizon.net> wrote:
> > I think some people would prefer to use BXML style, but the point here is
> Java API based development should be equally well supported.(without
> assuming the use of BXML).
>
> It is. You are not required to use BXML. Anything that can be done in BXML
> can also be done in Java or any other JVM language. BXML is just a shortcut
> to writing such code by hand.
>
I think just telling the technological possibility is not good enough to
claim Java API based approach is supported.(it similar to claim machine
language can support anything)
If it can support readable GUI description in Java, we should claim it
supports Java API based development.
>
> > I think Pivot is, in the basic Java oriented approach, more closer to
> Vaadin than Silverlight etc. Vaadin explicitly avoid using any form of XML
> as basic policy, it emphasizes pure Java based approach. I wonder Pivot
> developers have looked at the project..
>
> I am loosely familiar with Vaadin. However, I believe Pivot and Vaadin
> address different use cases. Pivot (like Flex and Silverlight) runs on the
> client, whereas Vaadin runs on the server. To me, Vaadin seems more closely
> related to something like Canoo than Pivot.
>
> Yes, Vaadin is server based stateful session approach. So it has a problem
to support cloud based server infrastructure like Google app engine.
That was the main reason I was more interested in Pivot.
But for GUI developing phase, these difference of deployment approach are
not much noticeable. In this sense, I thought Pivot and Vaadin is similar.
And I expected Pivot be similar to Vaadin when I start evaluating Pivot.
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> I think some people would prefer to use BXML style, but the point here is Java API based development should be equally well supported.(without assuming the use of BXML).
It is. You are not required to use BXML. Anything that can be done in BXML can also be done in Java or any other JVM language. BXML is just a shortcut to writing such code by hand.
> I think Pivot is, in the basic Java oriented approach, more closer to Vaadin than Silverlight etc. Vaadin explicitly avoid using any form of XML as basic policy, it emphasizes pure Java based approach. I wonder Pivot developers have looked at the project..
I am loosely familiar with Vaadin. However, I believe Pivot and Vaadin address different use cases. Pivot (like Flex and Silverlight) runs on the client, whereas Vaadin runs on the server. To me, Vaadin seems more closely related to something like Canoo than Pivot.
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 9:44 AM, Greg Brown <gk...@verizon.net> wrote:
> On Mon, Jan 3, 2011 at 8:38 AM, Greg Brown <gk...@verizon.net> wrote:
>
>> If the attribute was processed in the opening tag, we'd get an
>>> IndexOutOfBoundsException, since the Labels would not have been added yet.
>>>
>>
>> This is the problem I faced. But most of other attribute seems OK to set
>> at the opening tag.
>>
>>
>> Correct - many attributes can be set in the opening tag, but any that have
>> dependencies on child elements cannot. Since there is no harm in setting all
>> attributes in the closing tag, that is what we do.
>>
>> If Pivot is used only through BXML, these order are hidden from user, it
>> may not matter.
>> But if it is directly used in Java codes, this makes code hard to read.
>>
>>
>> Agreed, but if you are hand-coding using your builder style, you can put
>> the setters wherever you like. If you are using a BXML to Java converter, it
>> doesn't really matter where they go because the generated code isn't really
>> meant to be human-readable (that's what BXML is for).
>>
>
> This is quite opposite for my purpose. I would want to have human readable
> Java code. In fact, If we do start using this builder style, we will not
> need BXML file nor this converter.
>
>
> Though you may prefer to use the builder pattern exclusively, others may
> prefer to continue working with BXML. The converter would be a nice way to
> ensure that a BXML source is valid.
>
>
I think some people would prefer to use BXML style, but the point here is
Java API based development should be equally well supported.(without
assuming the use of BXML).
I think Pivot is, in the basic Java oriented approach, more closer to Vaadin
than Silverlight etc. Vaadin explicitly avoid using any form of XML as basic
policy, it emphasizes pure Java based approach. I wonder Pivot developers
have looked at the project..
Also this cases, I wonder why it just can't set the initial index value. The
>> Pivot code may select element after tabs tag is closed if selectedIndex is
>> defined.
>>
>>
>> Not sure what you mean. TabPane has a default value for selectedIndex.
>> However, TabPane doesn't know anything about a closing tag - only
>> BXMLSerializer knows about that.
>>
>
> I have not looked at the current codes for selectedIndex, but if it
> creates a selectedIndex function and register in a list of post evaluation
> function associated with the corresponding element, when the tag is closed,
> it can start evaluation these functions.
>
> ...
>
> Essentially it is hard for user to remember which attributes must be set
> after elements declaration,
>
>
> "selectedIndex" simply maps to TabPane#setSelectedIndex(). Obviously, you
> can't call setSelectedIndex() until the tabs have been added. So I don't
> think there should be any confusion on the developer's part.
>
> It would probably help for you to look at the Java APIs themselves rather
> than trying to reverse-engineer them from BXML. I think that may help
> clarify some things for you.
>
> BTW, I believe I understand the issue with the non-struct final classes now
> - since you can't create anonymous inner subclasses of them, it breaks your
> builder pattern. I can see an argument for making those classes non-final -
> however, the struct classes need to stay final for performance reasons (and,
> as I mentioned, aren't really meant to be used in markup anyways).
>
> G
>
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> On Mon, Jan 3, 2011 at 8:38 AM, Greg Brown <gk...@verizon.net> wrote:
>> If the attribute was processed in the opening tag, we'd get an IndexOutOfBoundsException, since the Labels would not have been added yet.
>>
>> This is the problem I faced. But most of other attribute seems OK to set at the opening tag.
>
> Correct - many attributes can be set in the opening tag, but any that have dependencies on child elements cannot. Since there is no harm in setting all attributes in the closing tag, that is what we do.
>
>> If Pivot is used only through BXML, these order are hidden from user, it may not matter.
>> But if it is directly used in Java codes, this makes code hard to read.
>
> Agreed, but if you are hand-coding using your builder style, you can put the setters wherever you like. If you are using a BXML to Java converter, it doesn't really matter where they go because the generated code isn't really meant to be human-readable (that's what BXML is for).
>
> This is quite opposite for my purpose. I would want to have human readable Java code. In fact, If we do start using this builder style, we will not need BXML file nor this converter.
Though you may prefer to use the builder pattern exclusively, others may prefer to continue working with BXML. The converter would be a nice way to ensure that a BXML source is valid.
>> Also this cases, I wonder why it just can't set the initial index value. The Pivot code may select element after tabs tag is closed if selectedIndex is defined.
>
> Not sure what you mean. TabPane has a default value for selectedIndex. However, TabPane doesn't know anything about a closing tag - only BXMLSerializer knows about that.
>
> I have not looked at the current codes for selectedIndex, but if it creates a selectedIndex function and register in a list of post evaluation function associated with the corresponding element, when the tag is closed, it can start evaluation these functions.
...
> Essentially it is hard for user to remember which attributes must be set after elements declaration,
"selectedIndex" simply maps to TabPane#setSelectedIndex(). Obviously, you can't call setSelectedIndex() until the tabs have been added. So I don't think there should be any confusion on the developer's part.
It would probably help for you to look at the Java APIs themselves rather than trying to reverse-engineer them from BXML. I think that may help clarify some things for you.
BTW, I believe I understand the issue with the non-struct final classes now - since you can't create anonymous inner subclasses of them, it breaks your builder pattern. I can see an argument for making those classes non-final - however, the struct classes need to stay final for performance reasons (and, as I mentioned, aren't really meant to be used in markup anyways).
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 8:38 AM, Greg Brown <gk...@verizon.net> wrote:
> If the attribute was processed in the opening tag, we'd get an
>> IndexOutOfBoundsException, since the Labels would not have been added yet.
>>
>
> This is the problem I faced. But most of other attribute seems OK to set at
> the opening tag.
>
>
> Correct - many attributes can be set in the opening tag, but any that have
> dependencies on child elements cannot. Since there is no harm in setting all
> attributes in the closing tag, that is what we do.
>
> If Pivot is used only through BXML, these order are hidden from user, it
> may not matter.
> But if it is directly used in Java codes, this makes code hard to read.
>
>
> Agreed, but if you are hand-coding using your builder style, you can put
> the setters wherever you like. If you are using a BXML to Java converter, it
> doesn't really matter where they go because the generated code isn't really
> meant to be human-readable (that's what BXML is for).
>
This is quite opposite for my purpose. I would want to have human readable
Java code. In fact, If we do start using this builder style, we will not
need BXML file nor this converter. This tools is useful for migration or to
understand how to write Java code using existing Pivot sample bxml files.
(Since there are not much such direct Java source codes samples in Pivot
project)
One of my main objective for using Java was to develop generic class library
for basic CRUD feature.
So it is important, these Java code is human readable.
I have already changed the code generation so that it generate attribute
setters at the closing tag. But it is not acceptable for readability point
of view.
It is equivalent asking to write bxml file with some attribute after
element declaration.
>
> Also this cases, I wonder why it just can't set the initial index value.
> The Pivot code may select element after tabs tag is closed if selectedIndex
> is defined.
>
>
> Not sure what you mean. TabPane has a default value for selectedIndex.
> However, TabPane doesn't know anything about a closing tag - only
> BXMLSerializer knows about that.
>
I have not looked at the current codes for selectedIndex, but if it creates
a selectedIndex function and register in a list of post evaluation function
associated with the corresponding element, when the tag is closed, it can
start evaluation these functions. This approach will allow to set
selectedIndex just after the opening tag.
Essentially it is hard for user to remember which attributes must be set
after elements declaration, and even if it is done so, the code is not easy
to read. So these things should be handled by the Pivot core level.
>
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> If the attribute was processed in the opening tag, we'd get an IndexOutOfBoundsException, since the Labels would not have been added yet.
>
> This is the problem I faced. But most of other attribute seems OK to set at the opening tag.
Correct - many attributes can be set in the opening tag, but any that have dependencies on child elements cannot. Since there is no harm in setting all attributes in the closing tag, that is what we do.
> If Pivot is used only through BXML, these order are hidden from user, it may not matter.
> But if it is directly used in Java codes, this makes code hard to read.
Agreed, but if you are hand-coding using your builder style, you can put the setters wherever you like. If you are using a BXML to Java converter, it doesn't really matter where they go because the generated code isn't really meant to be human-readable (that's what BXML is for).
> Also this cases, I wonder why it just can't set the initial index value. The Pivot code may select element after tabs tag is closed if selectedIndex is defined.
Not sure what you mean. TabPane has a default value for selectedIndex. However, TabPane doesn't know anything about a closing tag - only BXMLSerializer knows about that.
G
Re: [pivot] are there any tools to convert bxml to Java?
Posted by calathus <ca...@gmail.com>.
On Mon, Jan 3, 2011 at 5:09 AM, Greg Brown <gk...@verizon.net> wrote:
> > I will report some of the issues I faced later.
> > (e.g, the attribute setting invocation sometimes must be called after all
> elements are added.. but this looks not good API design for Pivot..)
>
> Attributes are always processed in the closing tag. This is so cases such
> as the following are properly handled:
>
> <TabPane selectedIndex="2">
> <tabs>
> <Label text="A"/>
> <Label text="B"/>
> <Label text="C"/>
> </tabs>
> </TabPane>
>
> If the attribute was processed in the opening tag, we'd get an
> IndexOutOfBoundsException, since the Labels would not have been added yet.
>
This is the problem I faced. But most of other attribute seems OK to set at
the opening tag.
If Pivot is used only through BXML, these order are hidden from user, it may
not matter.
But if it is directly used in Java codes, this makes code hard to read.
since many case, there are a lot of included elements, and after all these
elements, attributes must be set. these codes are far from the corresponding
element instantiation code.
Also this cases, I wonder why it just can't set the initial index value. The
Pivot code may select element after tabs tag is closed if selectedIndex is
defined.
In Scala, this may be implemented with lazy select function.
>
> G
>
>
--
Cheers,
calathus
Re: [pivot] are there any tools to convert bxml to Java?
Posted by Greg Brown <gk...@verizon.net>.
> I will report some of the issues I faced later.
> (e.g, the attribute setting invocation sometimes must be called after all elements are added.. but this looks not good API design for Pivot..)
Attributes are always processed in the closing tag. This is so cases such as the following are properly handled:
<TabPane selectedIndex="2">
<tabs>
<Label text="A"/>
<Label text="B"/>
<Label text="C"/>
</tabs>
</TabPane>
If the attribute was processed in the opening tag, we'd get an IndexOutOfBoundsException, since the Labels would not have been added yet.
G