1 11 package org.eclipse.ui.internal.part; 12 13 import org.eclipse.jface.action.IStatusLineManager; 14 import org.eclipse.swt.widgets.Composite; 15 import org.eclipse.ui.IActionBars; 16 import org.eclipse.ui.IMemento; 17 import org.eclipse.ui.IViewPart; 18 import org.eclipse.ui.IViewSite; 19 import org.eclipse.ui.internal.components.framework.ComponentException; 20 import org.eclipse.ui.internal.components.framework.FactoryMap; 21 import org.eclipse.ui.internal.components.framework.ServiceFactory; 22 import org.eclipse.ui.internal.part.components.services.IPartActionBars; 23 import org.eclipse.ui.internal.part.components.services.IPartDescriptor; 24 import org.eclipse.ui.internal.part.components.services.IWorkbenchPartFactory; 25 import org.eclipse.ui.internal.part.services.NullEditorInput; 26 import org.eclipse.ui.internal.part.services.ViewToPartActionBarsAdapter; 27 28 39 public class NewViewToOldWrapper extends NewPartToOldWrapper implements IViewPart { 40 41 private IMemento viewMemento = null; 42 43 46 public NewViewToOldWrapper(IPartDescriptor descriptor) { 47 super(new PartPropertyProvider(null, null, null, descriptor, new NullEditorInput())); 48 } 49 50 53 public void init(IViewSite site, IMemento memento) { 54 init(site); 55 viewMemento = memento; 56 } 57 58 61 public void init(IViewSite site) { 62 setSite(site); 63 } 64 65 public IViewSite getViewSite() { 66 return (IViewSite)getSite(); 67 } 68 69 protected Part createPart(Composite parent, ServiceFactory args) throws ComponentException { 70 IWorkbenchPartFactory factory = getFactory(); 71 String id = getSite().getId(); 72 73 Part result = factory.createView(id, parent, getMemento(), args); 74 75 return result; 76 } 77 78 public void createPartControl(Composite parent) { 79 super.createPartControl(parent); 80 viewMemento = null; 81 } 82 83 protected IMemento getMemento() { 84 return viewMemento; 85 } 86 87 protected String getSecondaryId() { 88 return getViewSite().getSecondaryId(); 89 } 90 91 94 protected void addServices(FactoryMap context) { 95 super.addServices(context); 96 97 context.mapInstance(IActionBars.class, getViewSite().getActionBars()); 98 } 99 100 103 public void saveState(IMemento memento) { 104 Part part = getPart(); 105 if (part != null) { 106 part.saveState(memento); 107 } 108 } 109 110 protected IPartActionBars createPartActionBars() { 111 return new ViewToPartActionBarsAdapter(getViewSite().getActionBars()); 112 } 113 114 protected IStatusLineManager getStatusLineManager() { 115 return getViewSite().getActionBars().getStatusLineManager(); 116 } 117 } 118 | Popular Tags |