1 11 package org.eclipse.ui.internal.presentations; 12 13 import org.eclipse.swt.widgets.Composite; 14 import org.eclipse.ui.IMemento; 15 import org.eclipse.ui.presentations.AbstractPresentationFactory; 16 import org.eclipse.ui.presentations.IPresentationSerializer; 17 import org.eclipse.ui.presentations.IStackPresentationSite; 18 import org.eclipse.ui.presentations.StackPresentation; 19 20 23 public class PresentationFactoryUtil { 24 25 public static final int ROLE_EDITOR = 0x01; 26 27 public static final int ROLE_VIEW = 0x02; 28 29 public static final int ROLE_STANDALONE = 0x03; 30 31 public static final int ROLE_STANDALONE_NOTITLE = 0x04; 32 33 public static StackPresentation createPresentation( 34 AbstractPresentationFactory factory, int role, Composite parent, 35 IStackPresentationSite site, IPresentationSerializer serializer, 36 IMemento memento) { 37 38 StackPresentation presentation = null; 39 40 switch (role) { 41 case ROLE_EDITOR: 42 presentation = factory.createEditorPresentation(parent, site); 43 break; 44 case ROLE_STANDALONE: 45 presentation = factory.createStandaloneViewPresentation(parent, 46 site, true); 47 break; 48 case ROLE_STANDALONE_NOTITLE: 49 presentation = factory.createStandaloneViewPresentation(parent, 50 site, false); 51 break; 52 default: 53 presentation = factory.createViewPresentation(parent, site); 54 } 55 56 if (role != ROLE_EDITOR && memento != null && serializer != null) { 58 presentation.restoreState(serializer, memento); 59 } 60 61 return presentation; 62 } 63 64 private PresentationFactoryUtil() { 65 66 } 67 } 68 | Popular Tags |