Is there a way to replace the shell generated by Eclipse RCP for the MTrimmedWindow by a user defined window?
是否有一种方法可以用用户定义的窗口替换Eclipse RCP为MTrimmedWindow生成的shell ?
Eclipse creates a shell with a particular style type, which can only be provided while creating. I want to remove maximize and resize from the shell element created for the MTrimmedWindow. If any one has a solution for the above problem please reply.
Eclipse创建一个具有特定样式类型的shell,该类型只能在创建时提供。我希望从为MTrimmedWindow创建的外壳元素中移除最大化和调整大小。如果有人对上述问题有解决办法,请回复。
3 个解决方案
#1
6
The style for the shell cannot be changed after creation, and the shell itself cannot be exchanged after it has been created by the renderer. But the situation is not hopeless.
shell的样式在创建之后不能更改,在呈现程序创建之后也不能交换shell本身。但情况并非毫无希望。
Eclipse 4 uses renderers to generate UI elements from the application model. These renderers can be exchanged by using the Rendering Framework, and this is one possible way to create a shell with a style different from the default.
Eclipse 4使用渲染器从应用程序模型生成UI元素。这些渲染器可以通过使用渲染框架进行交换,这是创建与默认样式不同的shell的一种可能方式。
The solution would involve writing an own renderer for UIElements of the type MWindow, providing a WorkbenchRendererFactory to create a new SWT renderer for MWindows, and registering the new factory with the product.
解决方案将涉及为MWindow类型的UIElements编写一个自己的渲染器,提供一个WorkbenchRendererFactory来为MWindows创建一个新的SWT渲染器,并将新工厂注册到产品中。
Default: Shell creation by WBWRenderer
默认值:wbwrench创建Shell
WBWRenderer (workbench window renderer) is the standard renderer for SWT elements of type MWindow.
wbwrderer(工作台窗口渲染器)是MWindow类型的SWT元素的标准渲染器。
In WBWRenderer#createWidget
, the shell is created with the style SWT.SHELL_TRIM
, which is a convenience style for SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE
:
在wbderer #createWidget中,shell是用SWT样式创建的。SHELL_TRIM,这是SWT的一种便利样式。| SWT。标题| SWT。分钟| SWT。马克斯| SWT.RESIZE:
wbwShell = new Shell(Display.getCurrent(), SWT.SHELL_TRIM | rtlStyle);
This will result in a TrimmedWindow that can be maximized and resized, without the possibility to change this behaviour after creation.
这将导致可以最大化和调整大小的TrimmedWindow,而不可能在创建后改变这种行为。
Shell creation by new renderer
新渲染器创建Shell
To get around the above mentioned limitation, you can provide a different renderer, using WBWRenderer as a template. This allows you to change the code for the shell creation, e.g.
为了克服上述限制,您可以提供一个不同的渲染器,使用wbwrench作为模板。这允许您更改shell创建的代码,例如。
wbwShell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.TITLE |
SWT.MIN | rtlStyle);
This renderer needs to be returned by a WorkbenchRendererFactory as the renderer used for showing MWindows. Additionally, the renderer factory has to be added as a product property in the plugin.xml.
此渲染器需要由WorkbenchRendererFactory作为用于显示MWindows的渲染器返回。此外,渲染器工厂必须作为product属性添加到plugin.xml中。
These changes will result in a TrimmedWindow that cannot be maximized or resized.
这些更改将导致无法最大化或调整大小的TrimmedWindow。
An example of how to write and register the WorkbenchRendererFactory can be found here.
如何编写和注册WorkbenchRendererFactory的示例可以在这里找到。
A better solution?
更好的解决方案吗?
Actually, there could be a better way to style SWT shells since WBWRenderer already uses tags to determine MWindow behaviour: shellMaximized
and shellMinimized
. These tags can be set in the supplementary tab of the trimmed window in the application model editor.
实际上,由于wbwrderer已经使用标记来确定MWindow行为,所以可以有更好的方式来使用SWT shell: shell最大化和shell最小化。这些标签可以设置在应用程序模型编辑器的裁剪窗口的辅助选项卡中。
If swt style tags could be set in a similar manner, they could be used to set the shell style. This would be a feature request for Eclipse.
如果可以以类似的方式设置swt样式标记,则可以使用它们来设置shell样式。这将是Eclipse的一个特性请求。
#2
1
This can now be solved with a specific "persisted state" key flag, as documented in https://bugs.eclipse.org/bugs/show_bug.cgi?id=386951 . For example to realize a NO_TRIM window, add the key/value styleOverride/8, where 8 is the value if you get the numeric of
现在可以使用特定的“持久化状态”键标志来解决这个问题,如https://bugs.eclipse.org/bugs/show_bug.cgi?id = 386951。例如,要实现NO_TRIM窗口,请添加key/value styleOverride/8,其中8是如果得到的数值
int val = SWT.NO_TRIM;
System.out.println(val);
#3
0
In addition to col.panic's answer if you wanted a style of
如果你想要一种风格的话,除了col.panic牌的回答
SWT.CLOSE | SWT.TITLE
your styleOverride value would be 96
你的styleOverride值是96
System.out.println(SWT.CLOSE | SWT.TITLE) = 96
#1
6
The style for the shell cannot be changed after creation, and the shell itself cannot be exchanged after it has been created by the renderer. But the situation is not hopeless.
shell的样式在创建之后不能更改,在呈现程序创建之后也不能交换shell本身。但情况并非毫无希望。
Eclipse 4 uses renderers to generate UI elements from the application model. These renderers can be exchanged by using the Rendering Framework, and this is one possible way to create a shell with a style different from the default.
Eclipse 4使用渲染器从应用程序模型生成UI元素。这些渲染器可以通过使用渲染框架进行交换,这是创建与默认样式不同的shell的一种可能方式。
The solution would involve writing an own renderer for UIElements of the type MWindow, providing a WorkbenchRendererFactory to create a new SWT renderer for MWindows, and registering the new factory with the product.
解决方案将涉及为MWindow类型的UIElements编写一个自己的渲染器,提供一个WorkbenchRendererFactory来为MWindows创建一个新的SWT渲染器,并将新工厂注册到产品中。
Default: Shell creation by WBWRenderer
默认值:wbwrench创建Shell
WBWRenderer (workbench window renderer) is the standard renderer for SWT elements of type MWindow.
wbwrderer(工作台窗口渲染器)是MWindow类型的SWT元素的标准渲染器。
In WBWRenderer#createWidget
, the shell is created with the style SWT.SHELL_TRIM
, which is a convenience style for SWT.CLOSE | SWT.TITLE | SWT.MIN | SWT.MAX | SWT.RESIZE
:
在wbderer #createWidget中,shell是用SWT样式创建的。SHELL_TRIM,这是SWT的一种便利样式。| SWT。标题| SWT。分钟| SWT。马克斯| SWT.RESIZE:
wbwShell = new Shell(Display.getCurrent(), SWT.SHELL_TRIM | rtlStyle);
This will result in a TrimmedWindow that can be maximized and resized, without the possibility to change this behaviour after creation.
这将导致可以最大化和调整大小的TrimmedWindow,而不可能在创建后改变这种行为。
Shell creation by new renderer
新渲染器创建Shell
To get around the above mentioned limitation, you can provide a different renderer, using WBWRenderer as a template. This allows you to change the code for the shell creation, e.g.
为了克服上述限制,您可以提供一个不同的渲染器,使用wbwrench作为模板。这允许您更改shell创建的代码,例如。
wbwShell = new Shell(Display.getCurrent(), SWT.CLOSE | SWT.TITLE |
SWT.MIN | rtlStyle);
This renderer needs to be returned by a WorkbenchRendererFactory as the renderer used for showing MWindows. Additionally, the renderer factory has to be added as a product property in the plugin.xml.
此渲染器需要由WorkbenchRendererFactory作为用于显示MWindows的渲染器返回。此外,渲染器工厂必须作为product属性添加到plugin.xml中。
These changes will result in a TrimmedWindow that cannot be maximized or resized.
这些更改将导致无法最大化或调整大小的TrimmedWindow。
An example of how to write and register the WorkbenchRendererFactory can be found here.
如何编写和注册WorkbenchRendererFactory的示例可以在这里找到。
A better solution?
更好的解决方案吗?
Actually, there could be a better way to style SWT shells since WBWRenderer already uses tags to determine MWindow behaviour: shellMaximized
and shellMinimized
. These tags can be set in the supplementary tab of the trimmed window in the application model editor.
实际上,由于wbwrderer已经使用标记来确定MWindow行为,所以可以有更好的方式来使用SWT shell: shell最大化和shell最小化。这些标签可以设置在应用程序模型编辑器的裁剪窗口的辅助选项卡中。
If swt style tags could be set in a similar manner, they could be used to set the shell style. This would be a feature request for Eclipse.
如果可以以类似的方式设置swt样式标记,则可以使用它们来设置shell样式。这将是Eclipse的一个特性请求。
#2
1
This can now be solved with a specific "persisted state" key flag, as documented in https://bugs.eclipse.org/bugs/show_bug.cgi?id=386951 . For example to realize a NO_TRIM window, add the key/value styleOverride/8, where 8 is the value if you get the numeric of
现在可以使用特定的“持久化状态”键标志来解决这个问题,如https://bugs.eclipse.org/bugs/show_bug.cgi?id = 386951。例如,要实现NO_TRIM窗口,请添加key/value styleOverride/8,其中8是如果得到的数值
int val = SWT.NO_TRIM;
System.out.println(val);
#3
0
In addition to col.panic's answer if you wanted a style of
如果你想要一种风格的话,除了col.panic牌的回答
SWT.CLOSE | SWT.TITLE
your styleOverride value would be 96
你的styleOverride值是96
System.out.println(SWT.CLOSE | SWT.TITLE) = 96