Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [eclipse-incubator-e4-dev] Describe your UI with XMl (XUL, XHTML...) to render it with SWT and SWT CSS engine.

Hi,
E4 so hot, I'm hotted by E4. But seems My hot is a bow of cool water.
As mentioned before, I not have so much thing in English and others because of my hard.
So in 4 words just.
1, I have an Object Notation(ON, former version at on.dev.java.net), the simplest format, as you will see later. And I make a simpler ON text editor work it, (yes in my eclipse 34M7 dropins directory).
2, I making a protocol definition at UI and binding. And in my implementation, I just lock at MigLayout, of cause, to change it, not so hard. And stylesheet in consideration, but not CSS.
3, I making a FormBuilder to build a external Form Manager, which handle callback or other programming. the Form not a Composite but need a Composite, somehow like browsers' Document object.
4, I making a PropertySheetPage worked with the FormBuilder, which need a FormInfo provider just IPropertySource. I not employ plugin schema, its burd so weight, I not wanna add any more :)

I now struggle with eclipse databinding to make it work with a extenal listener manager. yes, I prefer Pure Java Object to beans.
I think no necessary let more speaking in the Global Intelligence.
Just 2 statements:
Ant teach me to employ default property to object. f.e. you can def a label just like: label: Address; no need to do like this: label{ text:Address}
ON support words as ONE word. f.e. E4 developer is "E4 developer", just like our names, Zhuang zhou is "Zhuang zhou",

Happy to hear you.

Regards,
Qinxian

Attachments {
form.on.bmp : Image of form.on file compact version in the editor;
from.on.swtform.bmp: Image of the later test application form with mispelled file name J
and: form.on text;
and: form.on simple unit test
}

the form definition: form.on
@preference{
    CaseSensitive:false;
    ControlDefaultAttribute: text;
    ControlStyle: inherit;
    alias{
        color:foreground;
    }
    NameFormat: -;
}
@inherit: combined, append;
@model: com.argaprict.model.TestModel;
@resource: model.resource.file,form;
@StyleSheet{
    @repeat:    override=combination, first, last;
    @include: ../style2/testform.on;
    .{
        style: NONE;
    }
    label1,text1{
        color: red;
    }
    label{
        background: FFFed;
        color: blue;
        font{
            style: italic,bold;
            weight: 12;
        }
        //transform: capitalize;
    }
    button{
        style: PUSH;
        @event: focus;
        backgroupColor: red;
        cursor: help;
    }
    text{
        style: SINGLE, BORDER;
        color: FFFFF;
        font: Roman 12 italic normal;
    }
    form{
        style: NONE;
    }
}
@layout: wrap 3;
@bind{
    sex: model.getSexe();
}

@id: helloForm;
@title: Hello World Form;
label: Hello;
@field{
    id: name;
    label: Name;
    value: {}
}
label {
    @id: label1;
    text: hello;
    color: green;
}
text{
    @style: override;
    //@class: override, inherit;
    @id: name;
    text: init text;
    color: 255, 128, 0;
}
text{
    style: BORDER;
    @id: address.state;
    @binding: model.name;
    layoutData: wrap;
    color: blue;
}
button{
    style: FLAT;
    style: int;
    @class: button;
    @id: button1;
    @binding: model.name;
    text: hello;
    @SWT.Selection: 'System.out.println("hello");';
}
@fields
    {name: name; control:text; label: true;}
    {name: age; control: spinner; label: false}
    {name: sex; control: {text:{style: checkbox}}    }
    {id: active; control: checkbox; needLabel: false;}
    {
        id: attribute;
        fields{id: name}{id:comments}
        fields:name, comments;       
    }
    {
        group: name;
    }
@groupbox{text: this group;
    field{id: name;}
}
a test:
public class FormBuilderTest {
    ONObject root;
    boolean block;
    DefaultOrganization model = new DefaultOrganization();

    @Before
    public void setupClass() throws Exception {
        root = ON.from(new File("resource/onforms/form.on"));
    }

    @Test
    public void testForm1_0() {
        block = true;
        testForm1();
    }

    @After
    public void tearDown() {
        System.err.println(model.getAddress().getState());
    }

    private void testForm1() {
        ApplicationWindow window = new ApplicationWindow(new Shell()) {
            Form form;
            FormBuilder builder = new FormBuilder(root);

            @Override
            protected void configureShell(Shell shell) {
                super.configureShell(shell);
                shell.setText(FormBuilderTest.this.getClass().getSimpleName());
            }

            @Override
            protected Control createContents(final Composite parent) {
                Composite client = new Composite(parent, SWT.NONE);
                client.setLayout(new MigLayout("wrap 2", "fill"));
                form = new SWTForm(client);
                builder.build(form);
                assertEquals(Button.class, form.getWidget("button1").getClass());
                assertNotNull(form.getWidget("label1"));
                assertNotNull(form.getWidget("name"));
                assertEquals("init text", ((Text) form.getWidget("name")).getText());
                assertNotNull(form.getWidget("address.state"));
                assertEquals("model.name", form.getWidget("address.state").getData("@binding"));
                Button button = form.getWidget("button1");
                button.addListener(SWT.Selection, new Listener() {
                    @Override
                    public void handleEvent(Event event) {
                        model.setName("ON world");
                        model.getAddress().setState("FUJIAN");
                        form.bind(SWTObservables.getRealm(parent.getDisplay()), model);
                        System.err.println(model.getName());
                    }
                });
                return client;
            }
        };
        window.setBlockOnOpen(block);
        window.open();
    }

    @Test
    public void testForm1_again1() {
        testForm1();
    }

}

Attachment: form.on.bmp
Description: Windows bitmap

Attachment: from.on.swtform.bmp
Description: Windows bitmap


Back to the top