org.eclipse.fx.ui.dialogs.Dialog issues [message #1221360] |
Tue, 17 December 2013 09:14  |
Eclipse User |
|
|
|
I am using the org.eclipse.fx.ui.dialogs package to implement dialogs for my application. I am extending the Dialog class itself and have discovered that it does not honor the modality setting. The Dialog class defaults the modality to Modality.WINDOW_MODAL but when I open the dialog, the "owning" window is still interactive. Is this a bug? Also, I noticed that unless I override the getModality() method, there is no way to set a different modality on a dialog.
On a different subject, I am using CSS styling and although the style settings work elsewhere in the application, they are being ignored in my dialog. Since the dialogs seem to work with their own stages and scenes, is there something I need to do to get a dialog to "see" the CSS file and use it?
|
|
|
|
|
Re: org.eclipse.fx.ui.dialogs.Dialog issues [message #1221487 is a reply to message #1221478] |
Tue, 17 December 2013 15:20   |
Eclipse User |
|
|
|
Well your code does not make much sense. If you debug it you'll notice
that nothing will ever be injected into your controller => Stage is NULL!
The reason for that is that injection only works if you create the
instance through the DI-Container (you simply create the instance your own!)
Do make injection work you'd have to make your code look like this:
@PostContextCreate
public void execute(IEclipseContext context) {
MainController mainController =
ContextInjectionFactory.make(MainController.class,context);
context.set(MainController.class, mainController);
}
Still this won't work because at this point in time there's not going to
be a stage in the context because none has yet created (well I'm
cheating a bit because the initial stage created by FX-Bootstrap is there).
So how can you solve this:
public class MainController {
@Inject
@Active
@Optional
private MWindow currentActiveWindow;
public void openSearchDialog() {
MessageSearchDialog dialog = new
MessageSearchDialog((Stage)currentActiveWindow.getWidget(), "Message
Search");
int response = dialog.open();
if (response == Dialog.OK_BUTTON) {
// TODO do the search
}
}
}
I've written a blog post on @Active some weeks ago
http://tomsondev.bestsolution.at/2013/01/30/active-in-e4/.
Other options are:
a) you pass along the stage to openSearchDialog
b) you rework this stuff as Command/Handler and use
ECommand/EHandlerService to invoke them which would make the code look like
public class SearchDialogHandler {
@Execute
String openDialog(MWindow w) {
MessageSearchDialog dialog = new
MessageSearchDialog((Stage)currentActiveWindow.getWidget(), "Message
Search");
int response = dialog.open();
if (response == Dialog.OK_BUTTON) {
// TODO do the search
return ....;
}
}
return null;
}
}
This will make the lifecycle stuff needless and IMHO the right way to go.
Tom
On 17.12.13 20:59, Joseph Gagnon wrote:
> I am injecting a Stage object into a controller that provides the
> ability to open the dialog. The Stage object is then passed to the
> dialog constructor.
>
> This controller is created in a handler class that is designated with
> the @PostContextCreate annotation. The handler is registered in the
> plugin.xml as a product property named lifeCycleURI. The reason I'm
> doing this is to make the controller available to anything within the
> application and so that it's available as soon as the context has been
> created. If this is the wrong way to do this, or there's a better method
> to provide the same capability, please let me know.
>
> I suspect that this has something to do with its inability to "see" the
> CSS file. Does that make sense?
>
>
> public class LifecycleHandler {
>
> @PostContextCreate
> public void execute(IEclipseContext context) {
> MainController mainController = new MainController();
> context.set(MainController.class, mainController);
> }
>
> }
>
>
>
> public class MainController {
>
> @Inject
> private Stage stage;
>
> public void openSearchDialog() {
> MessageSearchDialog dialog = new MessageSearchDialog(stage, "Message
> Search");
> int response = dialog.open();
>
> if (response == Dialog.OK_BUTTON) {
> // TODO do the search
> }
> }
>
> }
>
>
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03848 seconds