我正在开发一个eclipse RCP插件。现在我需要创建一个多标签编辑器,能够在运行时动态添加标签,但我不知道该怎么做。有谁知道我该怎么做?
感谢
答案 0 :(得分:0)
您应该可以执行与MultiPageEditorPart
类似的操作 - 它有几个addPage
个功能。可以按原样使用此编辑器,也可以将其用作灵感。
答案 1 :(得分:0)
为时已晚,但有些人可能从这段代码中受益:
/** The text editor used in the new page. */
private TextEditor editor;
private StyledText text;
/**
* Creates a multi-page editor example.
*/
public MultiPageEditor() {
super();
ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
}
void createDynamicPage() {
try {
editor = new TextEditor();
int index = addPage(editor, getEditorInput());
setPageText(index, "new page"+index);
} catch (PartInitException e) {
ErrorDialog.openError(
getSite().getShell(),
"Error creating nested editor",
null,
e.getStatus());
}
}
void createMainPage() {
Composite composite = new Composite(getContainer(), SWT.NONE);
GridLayout layout = new GridLayout();
composite.setLayout(layout);
layout.numColumns = 2;
Button clickButton = new Button(composite, SWT.NONE);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 2;
clickButton.setLayoutData(gd);
clickButton.setText("click");
clickButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
createDynamicPage();
}
});
int index = addPage(composite);
setPageText(index, "main page");
}
/**
* Creates the pages of the multi-page editor.
*/
protected void createPages() {
createMainPage();