01: /*******************************************************************************
02: * Copyright (c) 2004, 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.internal.presentations;
11:
12: import org.eclipse.jface.action.Action;
13: import org.eclipse.ui.internal.ViewPane;
14: import org.eclipse.ui.internal.WorkbenchMessages;
15: import org.eclipse.ui.internal.WorkbenchPage;
16: import org.eclipse.ui.presentations.IPresentablePart;
17: import org.eclipse.ui.presentations.IStackPresentationSite;
18:
19: public class SystemMenuDetach extends Action implements
20: ISelfUpdatingAction {
21:
22: private ViewPane viewPane;
23: private IStackPresentationSite site;
24: private WorkbenchPage page;
25:
26: public SystemMenuDetach(IStackPresentationSite site) {
27: this .site = site;
28: setText(WorkbenchMessages.PartPane_detach);
29: update();
30: }
31:
32: public void update() {
33: IPresentablePart presentablePart = site.getSelectedPart();
34: setEnabled(presentablePart != null
35: && site.isPartMoveable(presentablePart));
36: if (viewPane != null) {
37: setChecked(!viewPane.isDocked());
38: page = viewPane.getPage();
39: }
40: }
41:
42: public boolean shouldBeVisible() {
43: if (page != null) {
44: return page.getActivePerspective().getPresentation()
45: .canDetach();
46: }
47: return false;
48: }
49:
50: public void dispose() {
51: site = null;
52: }
53:
54: public void setPane(ViewPane current) {
55: viewPane = current;
56: update();
57: }
58:
59: public void run() {
60: if (site != null) {
61: if (!isChecked()) {
62: viewPane.doDetach();
63: } else {
64: viewPane.doAttach();
65: }
66: }
67: }
68:
69: }
|