1 11 12 package org.eclipse.ui.internal; 13 14 import java.util.Set ; 15 16 import org.eclipse.core.runtime.IStatus; 17 import org.eclipse.core.runtime.Status; 18 import org.eclipse.jface.preference.IPreferenceStore; 19 import org.eclipse.ui.IMemento; 20 import org.eclipse.ui.IWorkbenchPage; 21 import org.eclipse.ui.IWorkbenchPreferenceConstants; 22 import org.eclipse.ui.PartInitException; 23 import org.eclipse.ui.internal.util.PrefUtil; 24 import org.eclipse.ui.views.IStickyViewDescriptor; 25 import org.eclipse.ui.views.IViewRegistry; 26 27 31 public class StickyViewManager implements IStickyViewManager { 32 33 private IWorkbenchPage page; 34 35 public StickyViewManager(IWorkbenchPage page) { 36 this.page = page; 37 } 38 39 40 public static IStickyViewManager getInstance(IWorkbenchPage page) { 41 IStickyViewManager stickyViewMan; 42 IPreferenceStore preferenceStore = PrefUtil.getAPIPreferenceStore(); 43 boolean enable32Behavior = preferenceStore 44 .getBoolean(IWorkbenchPreferenceConstants.ENABLE_32_STICKY_CLOSE_BEHAVIOR); 45 if (enable32Behavior) 46 stickyViewMan = new StickyViewManager32(page); 47 else 48 stickyViewMan = new StickyViewManager(page); 49 50 return stickyViewMan; 51 } 52 53 59 public void add(String perspectiveId, Set stickyViewSet) { 60 } 62 63 68 public void clear() { 69 } 71 72 77 public void remove(String perspectiveId) { 78 } 80 81 86 public void restore(IMemento memento) { 87 } 89 90 95 public void save(IMemento memento) { 96 } 98 99 105 public void update(Perspective oldPersp, Perspective newPersp) { 106 if (oldPersp == null || newPersp == null) { 107 return; 108 } 109 IViewRegistry viewReg = WorkbenchPlugin.getDefault().getViewRegistry(); 110 IStickyViewDescriptor[] stickyDescs = viewReg.getStickyViews(); 111 for (int i = 0; i < stickyDescs.length; i++) { 112 final String viewId = stickyDescs[i].getId(); 113 try { 114 if (oldPersp.findView(viewId) != null) { 117 page.showView(viewId, null, IWorkbenchPage.VIEW_CREATE); 118 } 119 else if (newPersp.findView(viewId) != null 122 && oldPersp.findView(viewId) == null) { 123 page.hideView(newPersp.findView(viewId)); 124 } 125 } catch (PartInitException e) { 126 WorkbenchPlugin 127 .log( 128 "Could not open view :" + viewId, new Status(IStatus.ERROR, WorkbenchPlugin.PI_WORKBENCH, IStatus.ERROR, "Could not open view :" + viewId, e)); } 130 } 131 } 132 133 } 134 | Popular Tags |