RCP添加一個多頁編輯器
1、在plugin中,添加一個新的編輯器

?
2、添加多頁編輯器的類
package myviewrcp2.editors; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Label; import org.eclipse.ui.PartInitException; import org.eclipse.ui.part.MultiPageEditorPart; public class MutiEditorSample extends MultiPageEditorPart{ public static final String ID = "myviewrcp2.editors.MutiEditorSample"; private JSEditor page1; //編輯器對象 private JSEditor page2; //編輯器對象 private Label control1; //標(biāo)簽對象 //父類抽象方法 @Override protected void createPages() { // TODO Auto-generated method stub //創(chuàng)建頁面和標(biāo)簽對象 page1 = new JSEditor(); page2 = new JSEditor(); control1 = new Label(getContainer(),SWT.NONE); control1.setText("這是第一個標(biāo)簽"); try { //添加第一頁 addPage(page1, new JsEditorInput("One")); //設(shè)置選項卡的名稱 setPageText(0, "One"); //添加第二頁 addPage(page2,new JsEditorInput("Two")); setPageText(1, "Two"); //添加第三頁為1個標(biāo)簽 addPage(control1); setPageText(2, "Three"); }catch(PartInitException e) { e.printStackTrace(); } } @Override public void doSave(IProgressMonitor arg0) { // TODO Auto-generated method stub } @Override public void doSaveAs() { // TODO Auto-generated method stub } @Override public boolean isSaveAsAllowed() { // TODO Auto-generated method stub return false; } }
3、添加打開多頁編輯器的代碼

4、效果如圖:

?
鏈接:https://www.dianjilingqu.com/608523.html