为什么我在 eclipse 插件中看不到 SWT / JFace TitleAreaDialog 的变化?
Why can't I see Changes in SWT / JFace TitleAreaDialog in my eclipse plugin?
我正在开发一个 eclipse 插件(不是 RCP),我正在使用 Jface 和 SWT 创建它的用户界面。事实上,我已经下载了 WindowBuilder 插件,以便更容易地开发用户界面,并且我已经创建了一个自定义的 TitleAreaDialog。
到目前为止一切正常,我可以在 WindowBuilder(上图)中看到以下 TitleAreaDialog,当我尝试 运行 eclipse 插件时出现问题。左侧的树及其元素消失:
WindowBuilder (top) and Plugin executed (bottom)
有人知道发生了什么事吗?我是否必须向 plugin.xml 或 MANIFEST.MF 添加内容?
谢谢。
编辑:
在 zip 中,您会找到 plugin.xml、MANIFEST.XML、build.properties、处理程序和名为 PlugiGUI 的图形用户界面。如果您有任何问题,请问我。
谢谢。
You can download the code here.
编辑 2:
MANIFEST.MF部分代码如下
Bundle-SymbolicName: org.eclipse.plugin.arturito;singleton:=true
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
swing2swt.jar
部分TitleAreaDialog代码如下:
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
//TITLE AND IMAGE OF TitleDialog
...
//Composite
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
container.setLayoutData(new GridData(GridData.FILL_BOTH));
//Creates the division
SashForm sashForm = new SashForm(container, SWT.NONE);
//Right division
Group rightGroup = new Group(sashForm, SWT.NONE);
rightGroup.setLayout(new StackLayout());
//Create the tree
Tree tree = new Tree(rightGroup, SWT.BORDER);
tree.setLinesVisible(true);
tree.setToolTipText("");
tree.setHeaderVisible(true);
//Create tree elements
TreeItem pluginProperties = new TreeItem(tree, SWT.NONE);
pluginProperties.setText("Plugin properties");
pluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoProperties.png"));
TreeItem createPluginProperties = new TreeItem(pluginProperties, SWT.NONE);
createPluginProperties.setText("Create");
createPluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoPlus.png"));
TreeItem editPluginProperties = new TreeItem(pluginProperties, SWT.NONE);
editPluginProperties.setText("Edit/Delete");
editPluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoRemoveEdit.png"));
pluginProperties.setExpanded(true);
//MORE TREE ELEMENTS WITH SAME PATTERN
..............
//Left division
Group leftGroup = new Group(sashForm, SWT.NONE);
leftGroup.setLayout(new StackLayout());
Composite projectConfigDescriptor = new Composite(leftGroup, SWT.NONE);
//Proportion of sashForm
sashForm.setWeights(new int[] {220, 469});
return area;
}
为什么 WindowBuilder 会显示我想要的 TitleDialog 而我的插件却没有?
您已将左右组的布局设置为 StackLayout
。此布局要求您告诉它当前哪个控件是要显示的顶部控件。所以你会这样做:
StackLayout layout = new StackLayout();
rightGroup.setLayout(layout);
... create Tree
layout.topControl = tree;
然而,就目前而言,没有理由使用 StackLayout
,因为您只是在每一侧创建一个顶级控件。所以你可以只使用 FillLayout
:
rightGroup.setLayout(new FillLayout());
我正在开发一个 eclipse 插件(不是 RCP),我正在使用 Jface 和 SWT 创建它的用户界面。事实上,我已经下载了 WindowBuilder 插件,以便更容易地开发用户界面,并且我已经创建了一个自定义的 TitleAreaDialog。
到目前为止一切正常,我可以在 WindowBuilder(上图)中看到以下 TitleAreaDialog,当我尝试 运行 eclipse 插件时出现问题。左侧的树及其元素消失:
WindowBuilder (top) and Plugin executed (bottom)
有人知道发生了什么事吗?我是否必须向 plugin.xml 或 MANIFEST.MF 添加内容?
谢谢。
编辑: 在 zip 中,您会找到 plugin.xml、MANIFEST.XML、build.properties、处理程序和名为 PlugiGUI 的图形用户界面。如果您有任何问题,请问我。
谢谢。
You can download the code here.
编辑 2: MANIFEST.MF部分代码如下
Bundle-SymbolicName: org.eclipse.plugin.arturito;singleton:=true
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .,
swing2swt.jar
部分TitleAreaDialog代码如下:
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
//TITLE AND IMAGE OF TitleDialog
...
//Composite
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new FillLayout(SWT.HORIZONTAL));
container.setLayoutData(new GridData(GridData.FILL_BOTH));
//Creates the division
SashForm sashForm = new SashForm(container, SWT.NONE);
//Right division
Group rightGroup = new Group(sashForm, SWT.NONE);
rightGroup.setLayout(new StackLayout());
//Create the tree
Tree tree = new Tree(rightGroup, SWT.BORDER);
tree.setLinesVisible(true);
tree.setToolTipText("");
tree.setHeaderVisible(true);
//Create tree elements
TreeItem pluginProperties = new TreeItem(tree, SWT.NONE);
pluginProperties.setText("Plugin properties");
pluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoProperties.png"));
TreeItem createPluginProperties = new TreeItem(pluginProperties, SWT.NONE);
createPluginProperties.setText("Create");
createPluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoPlus.png"));
TreeItem editPluginProperties = new TreeItem(pluginProperties, SWT.NONE);
editPluginProperties.setText("Edit/Delete");
editPluginProperties.setImage(ResourceManager.getPluginImage("org.eclipse.plugin.arturito", "icons/arturitoRemoveEdit.png"));
pluginProperties.setExpanded(true);
//MORE TREE ELEMENTS WITH SAME PATTERN
..............
//Left division
Group leftGroup = new Group(sashForm, SWT.NONE);
leftGroup.setLayout(new StackLayout());
Composite projectConfigDescriptor = new Composite(leftGroup, SWT.NONE);
//Proportion of sashForm
sashForm.setWeights(new int[] {220, 469});
return area;
}
为什么 WindowBuilder 会显示我想要的 TitleDialog 而我的插件却没有?
您已将左右组的布局设置为 StackLayout
。此布局要求您告诉它当前哪个控件是要显示的顶部控件。所以你会这样做:
StackLayout layout = new StackLayout();
rightGroup.setLayout(layout);
... create Tree
layout.topControl = tree;
然而,就目前而言,没有理由使用 StackLayout
,因为您只是在每一侧创建一个顶级控件。所以你可以只使用 FillLayout
:
rightGroup.setLayout(new FillLayout());