2012-07-24 4 views
1

내 eclipse 플러그인에서 런타임시 사용자 상호 작용에 따라 Tabfolder에 대해 여러 개의 TabItem을 만듭니다. 너무 많은 TabItem이 생성 될 때 문제가 발생합니다. 사용자가 필요하지 않을 때 해당 TabItem을 닫을 수 있도록 닫기 컨트롤이있는 TabItem을 만드는 옵션을 찾고있었습니다. 이 방법을 만들 수 있습니까?닫기 컨트롤이있는 탭 항목

답변

3

TabFolder 대신 CTabFolder를 사용하면 탭에 CTabItem을 사용하고 SWT.CLOSE 스타일을 생성자에 전달할 수 있습니다. 그러면 탭에 닫기 버튼이 생성됩니다.

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; 
    } 
} 

plugin.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는 시프트

수단