1 11 package org.eclipse.ui.internal.part; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 import org.eclipse.core.runtime.IProgressMonitor; 15 import org.eclipse.jface.action.IStatusLineManager; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.ui.IActionBars; 18 import org.eclipse.ui.IEditorInput; 19 import org.eclipse.ui.IEditorPart; 20 import org.eclipse.ui.IEditorSite; 21 import org.eclipse.ui.IMemento; 22 import org.eclipse.ui.PartInitException; 23 import org.eclipse.ui.internal.components.framework.ComponentException; 24 import org.eclipse.ui.internal.components.framework.FactoryMap; 25 import org.eclipse.ui.internal.components.framework.ServiceFactory; 26 import org.eclipse.ui.internal.part.components.services.IPartActionBars; 27 import org.eclipse.ui.internal.part.components.services.IPartDescriptor; 28 import org.eclipse.ui.internal.part.components.services.IWorkbenchPartFactory; 29 import org.eclipse.ui.internal.part.services.NullEditorInput; 30 import org.eclipse.ui.internal.part.services.NullPartActionBars; 31 32 39 public class NewEditorToOldWrapper extends NewPartToOldWrapper implements 40 IEditorPart { 41 42 private IAdaptable additionalServices = new IAdaptable() { 43 46 public Object getAdapter(Class adapter) { 47 if (adapter == IEditorInput.class) { 48 return getPropertyProvider().getEditorInput(); 49 } 50 if (adapter == IActionBars.class) { 51 return getEditorSite().getActionBars(); 52 } 53 return null; 54 } 55 }; 56 57 public NewEditorToOldWrapper(IPartDescriptor descriptor) { 58 super(new PartPropertyProvider(null, null, null, descriptor, new NullEditorInput())); 59 } 60 61 64 protected IMemento getMemento() { 65 return null; 66 } 67 68 71 protected Part createPart(Composite parent, ServiceFactory args) throws ComponentException { 72 IWorkbenchPartFactory factory = getFactory(); 73 return factory.createEditor(getSite().getId(), parent, getPropertyProvider().getEditorInput(), 74 getMemento(), args); 75 } 76 77 80 protected String getSecondaryId() { 81 return null; 82 } 83 84 87 public IEditorSite getEditorSite() { 88 return (IEditorSite)getSite(); 89 } 90 91 94 protected void addServices(FactoryMap context) { 95 super.addServices(context); 96 97 context.addInstance(additionalServices); 98 } 99 100 103 public void init(IEditorSite site, IEditorInput input) 104 throws PartInitException { 105 106 ((PartPropertyProvider)getPropertyProvider()).setEditorInput(input); 107 setSite(site); 108 } 109 110 113 public void doSave(IProgressMonitor monitor) { 114 115 } 116 117 120 public void doSaveAs() { 121 122 } 123 124 127 public boolean isSaveAsAllowed() { 128 return false; 129 } 130 131 134 public boolean isSaveOnCloseNeeded() { 135 return false; 136 } 137 138 protected IPartActionBars createPartActionBars() { 139 return new NullPartActionBars(); 140 } 141 142 protected IStatusLineManager getStatusLineManager() { 143 return getEditorSite().getActionBars().getStatusLineManager(); 144 } 145 } 146 | Popular Tags |