Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Easy way to disable window resizing #452

Open
amitjoy opened this issue Nov 8, 2022 · 3 comments
Open

Easy way to disable window resizing #452

amitjoy opened this issue Nov 8, 2022 · 3 comments

Comments

@amitjoy
Copy link

amitjoy commented Nov 8, 2022

Is there any easy way to disable window resizing? for example, using persisted properties, similar to Eclipse e4 with SWT where we can disable the resizing by setting styleOverride persisted property to the numeric value of SWT.CLOSE | SWT.TITLE.

@amitjoy amitjoy changed the title Easy way to disable window resizing? Easy way to disable window resizing Nov 8, 2022
@tomsontom
Copy link
Contributor

There's no such feature currently but it would be easy to add - until then the only possibility is to provide your own renderer for MWindow by subclassing "DefWindowRenderer" and "DefWindowRenderer.WWindowImpl" and overloading there "createWidget" (https://github.com/eclipse-efx/efxclipse-rt/blob/3.x/modules/ui/org.eclipse.fx.ui.workbench.renderers.fx/src/main/java/org/eclipse/fx/ui/workbench/renderers/fx/DefWindowRenderer.java#L456).

Of course you could also do all that using eg https://wiki.eclipse.org/Efxclipse/Runtime/e4#ELifecycleService

Maybe you want to provide a PR

@amitjoy
Copy link
Author

amitjoy commented Nov 10, 2022

@tomsontom Thanks a lot for your quick response! I have tried the following as an easy way to achieve this:

  1. Enabled org.eclipse.fx.ui.workbench.services.lifecycle.LifecycleAddon
  2. Added EFX_LC:bundleclass://com.osgifx.console.application/com.osgifx.console.application.lifecycle.WindowLifecycle as a tag to the TrimmedWindow element
package com.osgifx.console.application.lifecycle;

import org.eclipse.e4.ui.model.application.ui.basic.MWindow;
import org.eclipse.fx.ui.workbench.renderers.base.widget.WWindow;
import org.eclipse.fx.ui.workbench.services.lifecycle.annotation.PreShow;

import javafx.stage.Stage;

public final class WindowLifecycle {

    @PreShow
    public void disableResizing(final MWindow window) {
        final var stage = (Stage) (WWindow<?>) window.getWidget();
        stage.setResizable(false);
    }

}

and

Screenshot 2022-11-10 at 04 01 51

Somehow, the lifecycle callback is not getting invoked at all whereas I debugged that the addon can successfully create the instance of the lifecycle class.

Do you have any idea why the lifecycle callback is not getting executed?

Eagerly looking forward to your further assistance.

@amitjoy
Copy link
Author

amitjoy commented Nov 10, 2022

As far as I debugged, for TrimmedWindow, it requires a method with @InitContext where MWindow can not be injected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants