01: /*******************************************************************************
02: * Copyright (c) 2004, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.presentations;
11:
12: import org.eclipse.swt.widgets.Composite;
13: import org.eclipse.ui.IMemento;
14: import org.eclipse.ui.presentations.AbstractPresentationFactory;
15: import org.eclipse.ui.presentations.IPresentationSerializer;
16: import org.eclipse.ui.presentations.IStackPresentationSite;
17: import org.eclipse.ui.presentations.StackPresentation;
18:
19: /**
20: *
21: */
22: public class PresentationFactoryUtil {
23:
24: public static final int ROLE_EDITOR = 0x01;
25:
26: public static final int ROLE_VIEW = 0x02;
27:
28: public static final int ROLE_STANDALONE = 0x03;
29:
30: public static final int ROLE_STANDALONE_NOTITLE = 0x04;
31:
32: public static StackPresentation createPresentation(
33: AbstractPresentationFactory factory, int role,
34: Composite parent, IStackPresentationSite site,
35: IPresentationSerializer serializer, IMemento memento) {
36:
37: StackPresentation presentation = null;
38:
39: switch (role) {
40: case ROLE_EDITOR:
41: presentation = factory.createEditorPresentation(parent,
42: site);
43: break;
44: case ROLE_STANDALONE:
45: presentation = factory.createStandaloneViewPresentation(
46: parent, site, true);
47: break;
48: case ROLE_STANDALONE_NOTITLE:
49: presentation = factory.createStandaloneViewPresentation(
50: parent, site, false);
51: break;
52: default:
53: presentation = factory.createViewPresentation(parent, site);
54: }
55:
56: //don't initialize editors at creation time - it will not contain any parts
57: if (role != ROLE_EDITOR && memento != null
58: && serializer != null) {
59: presentation.restoreState(serializer, memento);
60: }
61:
62: return presentation;
63: }
64:
65: private PresentationFactoryUtil() {
66:
67: }
68: }
|