How to restrict the minimum size of the window for Eclipse e4 -
i making application based on eclipse e4 framework. wondering how minimal size of application window can controlled. there seems no properties can defined in e4xmi file purpose.
does know how it?
i found thread in eclipse community forum (http://www.eclipse.org/forums/index.php/t/244875/) saying can achieved creating own renderer. how can exactly?
thank :)
assuming using built-in swt renderers, can listen creation of e4 mwindow elements , gain access underlying swt shell. in example listener registered in addon, can add e4xmi.
import javax.annotation.postconstruct; import org.eclipse.e4.core.services.events.ieventbroker; import org.eclipse.e4.ui.model.application.ui.basic.mwindow; import org.eclipse.e4.ui.workbench.uievents; import org.eclipse.swt.widgets.shell; import org.osgi.service.event.event; import org.osgi.service.event.eventhandler; public class minsizeaddon { @postconstruct public void init(final ieventbroker eventbroker) { eventhandler handler = new eventhandler() { @override public void handleevent(event event) { if (!uievents.isset(event)) return; object objelement = event.getproperty(uievents.eventtags.element); if (!(objelement instanceof mwindow)) return; mwindow windowmodel = (mwindow)objelement; shell theshell = (shell)windowmodel.getwidget(); if (theshell == null) return; theshell.setminimumsize(400, 300); } }; eventbroker.subscribe(uievents.uielement.topic_widget, handler); } }
note, executed mwindow in application, , there can more of them (i.e. when mpart detached mpartstack seperate window). if want limit execution specific mwindows, recommend add tag window in e4xmi , check tag before setting minimum size.
Comments
Post a Comment