|
Re: TitleAreaDialog in a XWT file [message #635285 is a reply to message #635029] |
Tue, 26 October 2010 09:28 |
Missing name Missing name 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 |
Yves YANG 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).
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.23924 seconds