KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > DefaultStackPresentationSite


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.internal;
12
13 import org.eclipse.jface.action.IMenuManager;
14 import org.eclipse.swt.graphics.Point;
15 import org.eclipse.ui.presentations.IPresentablePart;
16 import org.eclipse.ui.presentations.IStackPresentationSite;
17 import org.eclipse.ui.presentations.StackPresentation;
18
19 /**
20  * @since 3.0
21  */

22 public abstract class DefaultStackPresentationSite implements
23         IStackPresentationSite {
24
25     private StackPresentation presentation;
26
27     private int state = IStackPresentationSite.STATE_RESTORED;
28
29     private int activeState = StackPresentation.AS_INACTIVE;
30
31     public DefaultStackPresentationSite() {
32
33     }
34
35     public void setPresentation(StackPresentation newPresentation) {
36         presentation = newPresentation;
37         if (presentation != null) {
38             presentation.setState(state);
39             presentation.setActive(activeState);
40         }
41     }
42
43     public StackPresentation getPresentation() {
44         return presentation;
45     }
46
47     public int getState() {
48         return state;
49     }
50
51     public void setActive(int activeState) {
52         if (activeState != this.activeState) {
53             this.activeState = activeState;
54             if (presentation != null) {
55                 presentation.setActive(activeState);
56             }
57         }
58     }
59
60     public int getActive() {
61         return activeState;
62     }
63
64     /* (non-Javadoc)
65      * @see org.eclipse.ui.internal.skins.IStackPresentationSite#selectPart(org.eclipse.ui.internal.skins.IPresentablePart)
66      */

67     public void selectPart(IPresentablePart toSelect) {
68
69         if (presentation != null) {
70             presentation.selectPart(toSelect);
71         }
72     }
73
74     public void dispose() {
75         if (presentation != null) {
76             presentation.dispose();
77         }
78         setPresentation(null);
79     }
80
81     /* (non-Javadoc)
82      * @see org.eclipse.ui.internal.skins.IPresentationSite#setState(int)
83      */

84     public void setState(int newState) {
85         setPresentationState(newState);
86     }
87
88     public void setPresentationState(int newState) {
89         state = newState;
90         if (presentation != null) {
91             presentation.setState(newState);
92         }
93     }
94
95     /* (non-Javadoc)
96      * @see org.eclipse.ui.internal.skins.IPresentablePart#isClosable()
97      */

98     public boolean isCloseable(IPresentablePart part) {
99         return part.isCloseable();
100     }
101
102     /* (non-Javadoc)
103      * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(org.eclipse.ui.internal.skins.IPresentablePart, boolean)
104      */

105     public void dragStart(IPresentablePart beingDragged, Point initialPosition,
106             boolean keyboard) {
107     }
108
109     /* (non-Javadoc)
110      * @see org.eclipse.ui.internal.skins.IPresentationSite#close(org.eclipse.ui.internal.skins.IPresentablePart)
111      */

112     public void close(IPresentablePart toClose) {
113     }
114
115     /* (non-Javadoc)
116      * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(boolean)
117      */

118     public void dragStart(Point initialPosition, boolean keyboard) {
119     }
120
121     /* (non-Javadoc)
122      * @see org.eclipse.ui.presentations.IStackPresentationSite#supportsState(int)
123      */

124     public boolean supportsState(int state) {
125         return true;
126     }
127
128     /* (non-Javadoc)
129      * @see org.eclipse.ui.presentations.IStackPresentationSite#getSelectedPart()
130      */

131     public abstract IPresentablePart getSelectedPart();
132
133     public void addSystemActions(IMenuManager menuManager) {
134
135     }
136
137     public abstract boolean isPartMoveable(IPresentablePart toMove);
138
139     public abstract boolean isStackMoveable();
140
141 }
142
Popular Tags