1

在我的 eclipse 插件中,在运行时我根据用户交互为 Tabfolder 创建多个 TabItems。当创建太多 TabItems 时,就会出现问题。我正在寻找一个选项来创建一个带有关闭控件的 TabItem,以便用户可以在不需要时关闭相应的 TabItem。有没有办法创建这个?

4

2 回答 2

3

如果您使用 CTabFolder 而不是 TabFolder,那么您可以将 CTabItem 用于选项卡并将 SWT.CLOSE 样式传递给构造函数。这将在选项卡上创建一个关闭按钮。

于 2012-07-24T11:50:44.870 回答
0

按下SHIFT + TAB 可在打开一个编辑器时在编辑器之间切换。

您第二次按下SHIFT + TAB 键打开另一个编辑器,但使用 RCP Eclipse 关闭前一个编辑器。

public class Emp_editor_open extends AbstractHandler{

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {

        IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
        IWorkbenchPage page = window.getActivePage();

        //Three object create in EditorInput 
        ProductEditorInput product_input=new ProductEditorInput();
        EmployeeEditorInput emp_input=new EmployeeEditorInput();
        UserEditorInput std_input = new UserEditorInput();

        IEditorReference[] editors = page.getEditorReferences();
        System.out.println("Length : "+editors.length);

        if(editors.length==0){
            //First Time or empty editors to check this condition
            try {
                page.openEditor(product_input,ProductEditor.ID);
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

        else if(page.getActiveEditor().getTitle().equals("Product_Editor")){
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(emp_input, EmployeeEditor.Id);
                System.out.println("Employee Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        else if(page.getActiveEditor().getTitle().equals("Employee_Editor")){
            System.out.println("Emp:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(std_input, UserEditor.ID);
                System.out.println("student Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        else if(page.getActiveEditor().getTitle().equals("Student_Editor")){
            System.out.println("Product:: "+page.getActiveEditor().getTitle());
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        else {
            try {
                page.closeAllEditors(true);
                page.openEditor(product_input,ProductEditor.ID);
                System.out.println("product Editor open");
            } catch (PartInitException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        return null;
    }
}

插件.xml


    <extension point="org.eclipse.ui.commands">
        <command
                defaultHandler="rcp_demo.Toolbar.Emp_editor_open"
                id="RCP_Demo.Toolbar.emp_editor_open_cmd"
                name="Employee_Editor_open">
        </command>
    </extension>
    <extension point="org.eclipse.ui.bindings">
        <key
                commandId="RCP_Demo.Toolbar.emp_editor_open_cmd"
                schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
                sequence="M2+TAB">
        </key>              
    </extension>            

键序:M2 表示Shift

于 2017-01-31T11:49:00.003 回答