Home » Eclipse Projects » e(fx)clipse » PerspectiveStack not visible(How do I get Perspective buttons?)
|
Re: PerspectiveStack not visible [message #1220229 is a reply to message #1220193] |
Tue, 10 December 2013 13:57 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
What you see in Eclipse IDE to switch between perspectives is a
ToolControl contribution made to the top-WindowTrim of your
MTrimmedWindow and unfortunately there's currently no pure e4
implementation of it available.
So you'd have to write one your own, a very cheap one could look like this:
class MyPerspectiveSwitchControl {
@PostConstruct
void init(Group g, MTrimmedWindow w, EPartService ps) {
MPerspectiveStack st = (MPerspectiveStack)w.getChildern().get(0);
HBox box = new HBox();
for( MPerspective p : st.getChildren() ) {
MPersepective fp = p;
RadioButton b = new RadioButton(p.getLabel());
b.setOnAction(e -> ps.switchPerspective(fp));
box.getChildren().add(b);
}
g.getChildren().add(box);
}
}
(if you use Java7 replace the lambda from above with an anonymous
class). To place it on the right you need to have an e.g. a Toolbar as
the first element in the TrimBar and tag it with (fillspace) [1]
On your request to implement the part class, you are asking for JavaFX
documentation? In fact you use pure JavaFX there (e.g. FXML produced by
SB, ... ).
I'd suggest to start at http://javafx.com/ and maybe buy a book on FX or
have you been looking for something different?
In case you are interested in samples with have some in our git-repo
(http://git.eclipse.org/c/efxclipse/org.eclipse.efxclipse.git/tree/demos):
- org.eclipse.fx.demo.e4
- org.eclipse.fx.demo.contacts*
- org.eclipse.fx.demo.media
I also have some code in https://github.com/tomsontom/ece_2013 where you
see an e4 app which is a bit more complex by using CDO, ... .
Tom
[1]http://wiki.eclipse.org/Efxclipse/Runtime/e4
On 10.12.13 14:23, Thorsten Seitz wrote:
> I created a simple test application with e(fx)clipse 0.9.1 and e4 (based
> on http://wiki.eclipse.org/Efxclipse/Tutorials/Tutorial4), configuring a
> TrimmedWindow with a PerspectiveStack containing several Perspectives
> which each just hold one Part.
>
> I was able to create a simple SamplePart class used by these parts which
> contains just a label. When launching the application the label is
> displayed, so I'm obviously looking at a Part contained in a Perspective.
>
> I would have expected to see a PerspectiveStack with Perspective buttons
> as well (like in Eclipse IDE), but nothing like that is to be seen, so
> it seems that this has to be done explicitly. Where would I put buttons
> to switch between my perspectives?
>
> Any help or pointers to documentation how to do that is greatly
> appreciated!
> (Any documentation how to implement java classes referred to by parts
> when using JavaFX in general would be very useful as well)
>
> Thanks!
>
> Thorsten
>
|
|
|
Re: PerspectiveStack not visible [message #1220386 is a reply to message #1220229] |
Wed, 11 December 2013 12:37 |
Thorsten Seitz Messages: 6 Registered: December 2013 |
Junior Member |
|
|
Hi Tom,
many thanks for you prompt and detailed answer!
I had already tried to add a ToolControl trim contribution but so far I have not been successful: I added a Trim Contribution where I set the parent id to that of the Window Trim. The Window Trim contains a Toolbar with "fillspace" tag (which does work nicely). But no matter what I add to the Trim Contribution nothing appears. I tried a Toolbar with some Tool Buttons, a ToolControl with a class just creating a label and now a ToolControl with the MyPerspectiveSwitchControl from your answer, to no avail.
When using SWT instead of e(fx)clipse the above example with Tool Buttons worked, but even then I could not get it positioned on the right (I tried "RIGHT" and "right" in the Position field of the Trim Contribution [without the quotation marks]).
Thomas Schindl wrote on Tue, 10 December 2013 08:57On your request to implement the part class, you are asking for JavaFX
documentation? In fact you use pure JavaFX there (e.g. FXML produced by
SB, ... ).
No, I'm not looking for JavaFX documentation here
What I meant was: how do I know which arguments can be injected where?
i.e.
the MyPerspectiveSwitchControl uses
@PostConstruct
void init(Group g, MTrimmedWindow w, EPartService ps)
for my try at a PerspectiveSwitcher I used
@Inject
public PerspectiveSwitcher(BorderPane parent, final MApplication application)
for a SamplePart I used
@Inject
public SamplePart(BorderPane parent, final MApplication application)
(which works)
but I haven't been able to find documentation about
(a) whether or when to use @Inject on a constructor or @PostConstruct on a method, and
(b) which types of arguments may be injected, especially when using JavaFX (Group, BorderPane etc), except for MTrim rendering tags.
I will try to harvest the github samples but documentation giving the whole picture would be better, of course.
Thorsten
|
|
|
Re: PerspectiveStack not visible [message #1220391 is a reply to message #1220386] |
Wed, 11 December 2013 13:19 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Hi,
I think TrimContribution was the wrong term that I used - the
contribution (menu,toolbar,trim) stuff is something only needed for
legacy IDE support and hence is not supported in e(fx)clipse
In pseudo code your XMI should look like this:
MTrimmedWindow {
trimBars : [
MWindowTrim {
side: TOP
children : [
ToolBar {
tags : ["fillspace"]
},
ToolControl {
contributionURI : "bundleclass:..."
}
]
}
]
}
On your request:
a) I tend to use @PostContruct because then I have already all
field/method injections
b) Generally speaking you always get a BorderPane unless you request
otherwise
I just saw that I had not documented MToolControl which lately got
the same possibility MPart already had since some time.
see https://wiki.eclipse.org/Efxclipse/Runtime/e4#MToolControl
I'm sorry that there's not more than what is currently on the wiki. I
can only emphasize that the wiki is open to anyone so if you found out
how something works, write it up on the wiki, in case you are uncertain
if this is the best approach ping on this newsgroup or on our developer
mailing list.
I've started writing up core recipes at
https://wiki.eclipse.org/Efxclipse/Runtime/Recipes and the more we get
the better!
In case you want to see all possibilities e4 on fx provides you can
checkout "org.eclipse.fx.testcases.e4", whenever we implement something
we add a test example for it in this application - it's not a pretty app ;-)
Tom
On 11.12.13 13:37, Thorsten Seitz wrote:
> Hi Tom,
>
> many thanks for you prompt and detailed answer!
>
> I had already tried to add a ToolControl trim contribution but so far I
> have not been successful: I added a Trim Contribution where I set the
> parent id to that of the Window Trim. The Window Trim contains a Toolbar
> with "fillspace" tag (which does work nicely). But no matter what I add
> to the Trim Contribution nothing appears. I tried a Toolbar with some
> Tool Buttons, a ToolControl with a class just creating a label and now a
> ToolControl with the MyPerspectiveSwitchControl from your answer, to no
> avail.
>
> When using SWT instead of e(fx)clipse the above example with Tool
> Buttons worked, but even then I could not get it positioned on the right
> (I tried "RIGHT" and "right" in the Position field of the Trim
> Contribution [without the quotation marks]).
>
>
> Thomas Schindl wrote on Tue, 10 December 2013 08:57
>> On your request to implement the part class, you are asking for JavaFX
>> documentation? In fact you use pure JavaFX there (e.g. FXML produced by
>> SB, ... ).
>
> No, I'm not looking for JavaFX documentation here :)
> What I meant was: how do I know which arguments can be injected where?
> i.e. the MyPerspectiveSwitchControl uses
> @PostConstruct
> void init(Group g, MTrimmedWindow w, EPartService ps)
> for my try at a PerspectiveSwitcher I used
> @Inject
> public PerspectiveSwitcher(BorderPane parent, final MApplication
> application)
> for a SamplePart I used
> @Inject
> public SamplePart(BorderPane parent, final MApplication application)
> (which works)
> but I haven't been able to find documentation about
>
> (a) whether or when to use @Inject on a constructor or @PostConstruct on
> a method, and
> (b) which types of arguments may be injected, especially when using
> JavaFX (Group, BorderPane etc), except for
> http://wiki.eclipse.org/Efxclipse/Runtime/e4#MTrimElement.
>
> I will try to harvest the github samples but documentation giving the
> whole picture would be better, of course.
>
> Thorsten
|
|
| | | | | | | |
Goto Forum:
Current Time: Sat Jan 18 12:06:12 GMT 2025
Powered by FUDForum. Page generated in 0.05283 seconds
|