Class ShellFactory
Shell
. This offers several benefits over creating Shell normal way:
- The same factory can be used many times to create several Shell instances
- The setters on ShellFactory all return "this", allowing them to be chained
Shell shell = ShellFactory.newShell(SWT.BORDER) // .text("My Shell") // .maximized(true) // .create(parent);
The above example creates a maximized shell with a text and creates the shell in "parent". Where "parent" has to be another shell.
GridDataFactory gridDataFactory = GridDataFactory.swtDefaults(); ShellFactory shellFactory = ShellFactory.newShell(SWT.PUSH).layout(gridDataFactory::create); shellFactory.text("Shell 1").create(parent); shellFactory.text("Shell 2").create(parent); shellFactory.text("Shell 3").create(parent);
The above example creates three shells using the same instance of ShellFactory. Note the layout method. A Supplier is used to create unique GridData for every single shell.
- Since:
- 3.21
-
Method Summary
Modifier and TypeMethodDescriptionfinal Shell
Creates the shell in the given display.fullScreen
(boolean fullScreen) Sets the full screen state of the receiver.maximized
(boolean maximized) Sets the maximized state of the receiver.menuBar
(Function<Decorations, Menu> menuFunction) Sets the shell's menu bar by aFunction
.minimized
(boolean minimized) Sets the minimized stated of the receiver.static ShellFactory
newShell
(int style) Creates a new ShellFactory with the given style.onActivate
(Consumer<ShellEvent> consumer) Creates aShellListener
and registers it for the activated event.onClose
(Consumer<ShellEvent> consumer) Creates aShellListener
and registers it for the closed event.onDeactivate
(Consumer<ShellEvent> consumer) Creates aShellListener
and registers it for the deactivated event.onDeiconify
(Consumer<ShellEvent> consumer) Creates aShellListener
and registers it for the deiconified (un-minimized) event.onIconify
(Consumer<ShellEvent> consumer) Creates aShellListener
and registers it for the iconified (minimized) event.Sets the receiver's text, which is the string that the window manager will typically display as the receiver's title, to the argument, which must not be null.Methods inherited from class org.eclipse.jface.widgets.AbstractCompositeFactory
layout
Methods inherited from class org.eclipse.jface.widgets.AbstractControlFactory
background, enabled, font, foreground, layoutData, orientation, supplyLayoutData, tooltip
Methods inherited from class org.eclipse.jface.widgets.AbstractWidgetFactory
addProperty, cast, create, data, data
-
Method Details
-
create
Creates the shell in the given display.- Returns:
- the created shell
- Since:
- 3.28
-
newShell
Creates a new ShellFactory with the given style. Refer toShell(Shell, int)
for possible styles.- Returns:
- a new ShellFactory instance
-
text
Sets the receiver's text, which is the string that the window manager will typically display as the receiver's title, to the argument, which must not be null.Note: If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.
- Returns:
- this
- See Also:
-
minimized
Sets the minimized stated of the receiver. If the argument istrue
causes the receiver to switch to the minimized state, and if the argument isfalse
and the receiver was previously minimized, causes the receiver to switch back to either the maximized or normal states.Note: The result of intermixing calls to
setMaximized(true)
andsetMinimized(true)
will vary by platform. Typically, the behavior will match the platform user's expectations, but not always. This should be avoided if possible.- Parameters:
minimized
- the new minimized state- Returns:
- this
- See Also:
-
maximized
Sets the maximized state of the receiver. If the argument istrue
causes the receiver to switch to the maximized state, and if the argument isfalse
and the receiver was previously maximized, causes the receiver to switch back to either the minimized or normal states.Note: The result of intermixing calls to
setMaximized(true)
andsetMinimized(true)
will vary by platform. Typically, the behavior will match the platform user's expectations, but not always. This should be avoided if possible.- Parameters:
maximized
- the new maximized state- Returns:
- this
- See Also:
-
fullScreen
Sets the full screen state of the receiver. If the argument istrue
causes the receiver to switch to the full screen state, and if the argument isfalse
and the receiver was previously switched into full screen state, causes the receiver to switch back to either the maximized or normal states.Note: The result of intermixing calls to
setFullScreen(true)
,setMaximized(true)
andsetMinimized(true)
will vary by platform. Typically, the behavior will match the platform user's expectations, but not always. This should be avoided if possible.- Parameters:
fullScreen
- the new fullscreen state- Returns:
- this
- See Also:
-
onActivate
Creates aShellListener
and registers it for the activated event. If event is raised it calls the given consumer. TheShellEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-
onDeactivate
Creates aShellListener
and registers it for the deactivated event. If event is raised it calls the given consumer. TheShellEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-
onIconify
Creates aShellListener
and registers it for the iconified (minimized) event. If event is raised it calls the given consumer. TheShellEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-
onDeiconify
Creates aShellListener
and registers it for the deiconified (un-minimized) event. If event is raised it calls the given consumer. TheShellEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-
onClose
Creates aShellListener
and registers it for the closed event. If event is raised it calls the given consumer. TheShellEvent
is passed to the consumer.- Parameters:
consumer
- the consumer whose accept method is called- Returns:
- this
- See Also:
-