eclipse-efx / efxclipse-rt

Eclipse Public License 1.0
28 stars 29 forks source link

Easy way to disable window resizing #452

Open amitjoy opened 1 year ago

amitjoy commented 1 year ago

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.

tomsontom commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

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