1 12 package org.eclipse.ui.internal; 13 14 import org.eclipse.ui.IFolderLayout; 15 import org.eclipse.ui.PartInitException; 16 import org.eclipse.ui.activities.WorkbenchActivityHelper; 17 import org.eclipse.ui.views.IViewDescriptor; 18 19 28 public class FolderLayout implements IFolderLayout { 29 private ViewStack folder; 30 31 private PageLayout pageLayout; 32 33 private ViewFactory viewFactory; 34 35 39 public FolderLayout(PageLayout pageLayout, ViewStack folder, 40 ViewFactory viewFactory) { 41 super(); 42 this.folder = folder; 43 this.viewFactory = viewFactory; 44 this.pageLayout = pageLayout; 45 } 46 47 50 public void addPlaceholder(String viewId) { 51 if (!pageLayout.checkValidPlaceholderId(viewId)) { 52 return; 53 } 54 55 PartPlaceholder newPart = new PartPlaceholder(viewId); 57 linkPartToPageLayout(viewId, newPart); 58 59 folder.add(newPart); 61 } 62 63 66 public void addView(String viewId) { 67 if (pageLayout.checkPartInLayout(viewId)) { 68 return; 69 } 70 71 try { 72 IViewDescriptor descriptor = viewFactory.getViewRegistry().find( 73 ViewFactory.extractPrimaryId(viewId)); 74 if (descriptor == null) { 75 throw new PartInitException("View descriptor not found: " + viewId); } 77 if (WorkbenchActivityHelper.filterItem(descriptor)) { 78 addPlaceholder(viewId); 80 LayoutHelper.addViewActivator(pageLayout, viewId); 81 } else { 82 83 ViewPane newPart = LayoutHelper.createView(pageLayout 84 .getViewFactory(), viewId); 85 linkPartToPageLayout(viewId, newPart); 86 folder.add(newPart); 87 } 88 } catch (PartInitException e) { 89 WorkbenchPlugin.log(getClass(), "addView(String)", e); } 92 } 93 94 98 private void linkPartToPageLayout(String viewId, LayoutPart newPart) { 99 pageLayout.setRefPart(viewId, newPart); 100 pageLayout.setFolderPart(viewId, folder); 101 pageLayout.getViewLayoutRec(viewId, true); 103 } 104 105 108 public String getProperty(String id) { 109 return folder.getProperty(id); 110 } 111 112 115 public void setProperty(String id, String value) { 116 folder.setProperty(id,value); 117 } 118 } 119 | Popular Tags |