001: /*******************************************************************************
002: * Copyright (c) 2004, 2006 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.internal;
011:
012: import org.eclipse.jface.action.IMenuManager;
013: import org.eclipse.swt.graphics.Point;
014: import org.eclipse.ui.presentations.IPresentablePart;
015: import org.eclipse.ui.presentations.IStackPresentationSite;
016: import org.eclipse.ui.presentations.StackPresentation;
017:
018: /**
019: * @since 3.0
020: */
021: public abstract class DefaultStackPresentationSite implements
022: IStackPresentationSite {
023:
024: private StackPresentation presentation;
025:
026: private int state = IStackPresentationSite.STATE_RESTORED;
027:
028: private int activeState = StackPresentation.AS_INACTIVE;
029:
030: public DefaultStackPresentationSite() {
031:
032: }
033:
034: public void setPresentation(StackPresentation newPresentation) {
035: presentation = newPresentation;
036: if (presentation != null) {
037: presentation.setState(state);
038: presentation.setActive(activeState);
039: }
040: }
041:
042: public StackPresentation getPresentation() {
043: return presentation;
044: }
045:
046: public int getState() {
047: return state;
048: }
049:
050: public void setActive(int activeState) {
051: if (activeState != this .activeState) {
052: this .activeState = activeState;
053: if (presentation != null) {
054: presentation.setActive(activeState);
055: }
056: }
057: }
058:
059: public int getActive() {
060: return activeState;
061: }
062:
063: /* (non-Javadoc)
064: * @see org.eclipse.ui.internal.skins.IStackPresentationSite#selectPart(org.eclipse.ui.internal.skins.IPresentablePart)
065: */
066: public void selectPart(IPresentablePart toSelect) {
067:
068: if (presentation != null) {
069: presentation.selectPart(toSelect);
070: }
071: }
072:
073: public void dispose() {
074: if (presentation != null) {
075: presentation.dispose();
076: }
077: setPresentation(null);
078: }
079:
080: /* (non-Javadoc)
081: * @see org.eclipse.ui.internal.skins.IPresentationSite#setState(int)
082: */
083: public void setState(int newState) {
084: setPresentationState(newState);
085: }
086:
087: public void setPresentationState(int newState) {
088: state = newState;
089: if (presentation != null) {
090: presentation.setState(newState);
091: }
092: }
093:
094: /* (non-Javadoc)
095: * @see org.eclipse.ui.internal.skins.IPresentablePart#isClosable()
096: */
097: public boolean isCloseable(IPresentablePart part) {
098: return part.isCloseable();
099: }
100:
101: /* (non-Javadoc)
102: * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(org.eclipse.ui.internal.skins.IPresentablePart, boolean)
103: */
104: public void dragStart(IPresentablePart beingDragged,
105: Point initialPosition, boolean keyboard) {
106: }
107:
108: /* (non-Javadoc)
109: * @see org.eclipse.ui.internal.skins.IPresentationSite#close(org.eclipse.ui.internal.skins.IPresentablePart)
110: */
111: public void close(IPresentablePart toClose) {
112: }
113:
114: /* (non-Javadoc)
115: * @see org.eclipse.ui.internal.skins.IPresentationSite#dragStart(boolean)
116: */
117: public void dragStart(Point initialPosition, boolean keyboard) {
118: }
119:
120: /* (non-Javadoc)
121: * @see org.eclipse.ui.presentations.IStackPresentationSite#supportsState(int)
122: */
123: public boolean supportsState(int state) {
124: return true;
125: }
126:
127: /* (non-Javadoc)
128: * @see org.eclipse.ui.presentations.IStackPresentationSite#getSelectedPart()
129: */
130: public abstract IPresentablePart getSelectedPart();
131:
132: public void addSystemActions(IMenuManager menuManager) {
133:
134: }
135:
136: public abstract boolean isPartMoveable(IPresentablePart toMove);
137:
138: public abstract boolean isStackMoveable();
139:
140: }
|