1 11 package org.eclipse.ui.internal.part; 12 13 import org.eclipse.ui.IEditorInput; 14 import org.eclipse.ui.IViewPart; 15 import org.eclipse.ui.IViewSite; 16 import org.eclipse.ui.IWorkbenchPart; 17 import org.eclipse.ui.IWorkbenchPart2; 18 import org.eclipse.ui.PartInitException; 19 import org.eclipse.ui.internal.components.framework.ComponentException; 20 import org.eclipse.ui.internal.part.components.services.IPartActionBars; 21 import org.eclipse.ui.internal.part.components.services.IPartDescriptor; 22 import org.eclipse.ui.internal.part.services.PartToViewActionBarsAdapter; 23 24 27 public class OldViewToNewWrapper extends OldPartToNewWrapper { 28 29 private IViewSite site; 30 private IPartDescriptor descriptor; 31 32 private IViewPart part; 33 private IEditorInput editorInput; 34 private PartToViewActionBarsAdapter actionBars; 35 36 public OldViewToNewWrapper(IViewPart part, IPartActionBars partActionBars, 37 StandardWorkbenchServices services) throws ComponentException { 38 super(services); 39 this.part = part; 40 41 actionBars = new PartToViewActionBarsAdapter(partActionBars, 42 services.getStatusHandler(), services.getStatusFactory()); 43 44 descriptor = services.getDescriptor(); 45 46 editorInput = services.getEditorInput(); 47 site = new CompatibilityPartSite( 48 services, part, null, actionBars); 49 50 try { 51 part.init(site, services.getState()); 52 } catch (PartInitException e) { 53 throw new ComponentException(part.getClass(), e); 54 } 55 56 part.createPartControl(services.getParentComposite()); 57 58 setPart(part); 59 } 60 61 64 public String getContentDescription() { 65 IWorkbenchPart part = getPart(); 66 if (part instanceof IWorkbenchPart2) { 67 IWorkbenchPart2 wbp2 = (IWorkbenchPart2)part; 68 69 return wbp2.getContentDescription(); 70 } 71 72 String title = getTitle(); 73 if (title.equals(getPartName())) { 74 return ""; } 76 return getTitle(); 77 } 78 79 public String getTitle() { 80 return getPart().getTitle(); 81 } 82 83 86 public IEditorInput getEditorInput() { 87 return editorInput; 88 } 89 90 93 public String getPartName() { 94 IWorkbenchPart part = getPart(); 95 if (part instanceof IWorkbenchPart2) { 96 IWorkbenchPart2 wbp2 = (IWorkbenchPart2)part; 97 98 return wbp2.getPartName(); 99 } 100 101 return descriptor.getLabel(); 102 } 103 104 107 public boolean isDirty() { 108 return false; 109 } 110 } 111 | Popular Tags |