01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.tests.harness.util;
11:
12: import org.eclipse.ui.IPageLayout;
13: import org.eclipse.ui.IPerspectiveFactory;
14:
15: /**
16: * This perspective is used for testing api. It defines an initial
17: * layout with no parts, just an editor area.
18: */
19: public class EmptyPerspective implements IPerspectiveFactory {
20:
21: /**
22: * The perspective id for the empty perspective.
23: */
24: public static final String PERSP_ID = "org.eclipse.ui.tests.harness.util.EmptyPerspective";
25:
26: /**
27: * The perspective id for the second empty perspective.
28: */
29: public static final String PERSP_ID2 = "org.eclipse.ui.tests.harness.util.EmptyPerspective2";
30:
31: private static String LastPerspective;
32:
33: /**
34: * Returns the descriptor for the perspective last opened using this factory.
35: *
36: * @return the descriptor for the perspective last opened using this factory, or <code>null</code>
37: */
38: public static String getLastPerspective() {
39: return LastPerspective;
40: }
41:
42: /**
43: * Sets the descriptor for the perspective last opened using this factory.
44: *
45: * @param persp the descriptor for the perspective last opened using this factory, or <code>null</code>
46: */
47: public static void setLastPerspective(String perspId) {
48: LastPerspective = perspId;
49: }
50:
51: /**
52: * Constructs a new Default layout engine.
53: */
54: public EmptyPerspective() {
55: super ();
56: }
57:
58: /**
59: * Defines the initial layout for a perspective.
60: *
61: * Implementors of this method may add additional views to a
62: * perspective. The perspective already contains an editor folder
63: * with <code>ID = ILayoutFactory.ID_EDITORS</code>. Add additional views
64: * to the perspective in reference to the editor folder.
65: *
66: * This method is only called when a new perspective is created. If
67: * an old perspective is restored from a persistence file then
68: * this method is not called.
69: *
70: * @param factory the factory used to add views to the perspective
71: */
72: public void createInitialLayout(IPageLayout layout) {
73: setLastPerspective(layout.getDescriptor().getId());
74: // do no layout, this is the empty perspective
75: }
76: }
|