Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » TitleAreaDialog in a XWT file
TitleAreaDialog in a XWT file [message #635029] Mon, 25 October 2010 13:18 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 57
Registered: September 2009
Member
Hello,

I would like to realise a window based on TitleAreaDialog.
I see the TitleAreaDialog.xwt and .java in the projet org.eclipse.e4.xwt.tests.jface.dialog but how can I add a composite between <TitleAreaDialog> and </TitleAreaDialog>.

What are the elements to add (composite, labels ...) ?

Thanks
Re: TitleAreaDialog in a XWT file [message #635285 is a reply to message #635029] Tue, 26 October 2010 09:28 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 57
Registered: September 2009
Member
Hello,
I reply to my message because I found a solution that can help someone too:

Aim:
A menu opens a XWTTitleAreaDialog describes with an xwt file. (The link between the menu and the handler is described in a fragment file)

Solution
The menu calls a class named MyHandler containing:
public class MyHandler {        
    @Execute
    public void execute(final MApplication application_, Shell parentShell_, IEclipseContext context_) {    
        //open an XWTTitleAreaDialog
        XWTTitleAreaDialog myTitleDialog = new XWTTitleAreaDialog(parentShell_, CompositeElement.class, new Person());
        myTitleDialog .setMessage("This message is displayed in the description view", IMessageProvider.INFORMATION);
        myTitleDialog .open();                                      
    }
    
    @CanExecute
    public boolean canExecute() {
            return true;
    }
}


The class Person.java defines data to display in the dialog:
public class Person {
    private String name;
    /**
     * Constructor
     */
    public Person() {
        name = "Toto"; // just for example        
    }
    /**
     * @return the name
     */
    public String getName() {
        return name;
    }
    /**
     * @param _name the name to set
     */
    public void setName(String _name) {
        name = _name;
    }
}


I describe a xwt file name CompositeElement.xwt containing:
<Composite xmlns="http://www.eclipse.org/xwt/presentation"
	xmlns:x="http://www.eclipse.org/xwt" xmlns:css="http://www.eclipse.org/css"
	xmlns:c="clr-namespace:myproject.ui" x:Class="myproject.ui.dialog.CompositeElement"
	bounds="0,0,636,516">
	<Composite.layout>
		<GridLayout numColumns="2" />
	</Composite.layout>
	<Composite.layoutData>
		<GridData grabExcessHorizontalSpace="true"
			horizontalAlignment="SWT.FILL" />
	</Composite.layoutData>

	<Label text="Name:"></Label>
	<Text text="{Binding path=name}">
		<Text.layoutData>
			<GridData grabExcessHorizontalSpace="true" widthHint="150"
				horizontalIndent="40" />
		</Text.layoutData>
	</Text>
</Composite>


The associated java class is:
public class CompositeElement extends Composite{
    /**
     * @param _parent
     * @param _style
     */
    public CompositeElement(Composite _parent, int _style) {
        super(_parent, _style);        
    }
}


The XWT file is very usefull because I can change XWT and test dialog directly without relaunching all the application (this dialog is in a bundle).

Re: TitleAreaDialog in a XWT file [message #635441 is a reply to message #635285] Tue, 26 October 2010 19:20 Go to previous message
Yves YANG is currently offline Yves YANGFriend
Messages: 688
Registered: July 2009
Senior Member
Thanks! I appreciate your participation and fedback.

Best regards
Yves YANG
"Valoueee" <val.dupin@free.fr> wrote in message
news:ia66pf$4j9$1@news.eclipse.org...
> Hello,
> I reply to my message because I found a solution that can help someone
> too:
>
> Aim:
> A menu opens a XWTTitleAreaDialog describes with an xwt file. (The link
> between the menu and the handler is described in a fragment file)
>
> Solution
> The menu calls a class named MyHandler containing:
> public class MyHandler { @Execute
> public void execute(final MApplication application_, Shell
> parentShell_, IEclipseContext context_) { //open an XWTTitleAreaDialog
> XWTTitleAreaDialog myTitleDialog = new
> XWTTitleAreaDialog(parentShell_, CompositeElement.class, new Person());
> myTitleDialog .setMessage("This message is displayed in the
> description view", IMessageProvider.INFORMATION);
> myTitleDialog .open(); }
> @CanExecute
> public boolean canExecute() {
> return true;
> }
> }
>
> The class Person.java defines data to display in the dialog:
> public class Person {
> private String name;
> /**
> * Constructor
> */
> public Person() {
> name = "Toto"; // just for example }
> /**
> * @return the name
> */
> public String getName() {
> return name;
> }
> /**
> * @param _name the name to set
> */
> public void setName(String _name) {
> name = _name;
> }
> }
>
> I describe a xwt file name CompositeElement.xwt containing:
> <Composite xmlns="http://www.eclipse.org/xwt/presentation"
> xmlns:x="http://www.eclipse.org/xwt"
> xmlns:css="http://www.eclipse.org/css"
> xmlns:c="clr-namespace:myproject.ui"
> x:Class="myproject.ui.dialog.CompositeElement"
> bounds="0,0,636,516">
> <Composite.layout>
> <GridLayout numColumns="2" />
> </Composite.layout>
> <Composite.layoutData>
> <GridData grabExcessHorizontalSpace="true"
> horizontalAlignment="SWT.FILL" />
> </Composite.layoutData>
>
> <Label text="Name:"></Label>
> <Text text="{Binding path=name}">
> <Text.layoutData>
> <GridData grabExcessHorizontalSpace="true" widthHint="150"
> horizontalIndent="40" />
> </Text.layoutData>
> </Text>
> </Composite>
>
> The associated java class is:
> public class CompositeElement extends Composite{
> /**
> * @param _parent
> * @param _style
> */
> public CompositeElement(Composite _parent, int _style) {
> super(_parent, _style); }
> }
>
> The XWT file is very usefull because I can change XWT and test dialog
> directly without relaunching all the application (this dialog is in a
> bundle).
>
>
Previous Topic:I18N / L10N of the workbench model
Next Topic:ComboViewer
Goto Forum:
  


Current Time: Fri Apr 26 07:01:40 GMT 2024

Powered by FUDForum. Page generated in 0.02662 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top