01: /*******************************************************************************
02: * Copyright (c) 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Common Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/cpl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.presentation.wrappedtabs;
11:
12: import org.eclipse.jface.action.ContributionItem;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.events.SelectionAdapter;
15: import org.eclipse.swt.events.SelectionEvent;
16: import org.eclipse.swt.widgets.Menu;
17: import org.eclipse.swt.widgets.MenuItem;
18: import org.eclipse.ui.presentations.IStackPresentationSite;
19:
20: /**
21: * Contributions for supporting maximizing, minimizing, and restoring the state of
22: * a stack presentation.
23: *
24: * @since 3.0
25: */
26: public class ChangeStackStateContributionItem extends ContributionItem {
27:
28: private IStackPresentationSite site;
29:
30: public ChangeStackStateContributionItem(IStackPresentationSite site) {
31: this .site = site;
32: }
33:
34: public void dispose() {
35: super .dispose();
36: }
37:
38: public void fill(Menu menu, int index) {
39: if (site.supportsState(IStackPresentationSite.STATE_MAXIMIZED)
40: && site.getState() != IStackPresentationSite.STATE_MAXIMIZED) {
41: MenuItem item1 = new MenuItem(menu, SWT.PUSH, index);
42: item1.setText("&Maximize");
43: item1.addSelectionListener(new SelectionAdapter() {
44: public void widgetSelected(SelectionEvent e) {
45: site
46: .setState(IStackPresentationSite.STATE_MAXIMIZED);
47: }
48: });
49: }
50: if (site.getState() != IStackPresentationSite.STATE_RESTORED) {
51: MenuItem item = new MenuItem(menu, SWT.PUSH, index);
52: item.setText("&Restore");
53: item.addSelectionListener(new SelectionAdapter() {
54: public void widgetSelected(SelectionEvent e) {
55: site
56: .setState(IStackPresentationSite.STATE_RESTORED);
57: }
58: });
59: }
60: }
61:
62: public boolean isDynamic() {
63: return true;
64: }
65: }
|