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.internal;
11:
12: import org.eclipse.jface.action.ContributionItem;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.widgets.Menu;
15: import org.eclipse.swt.widgets.MenuItem;
16: import org.eclipse.swt.widgets.ToolBar;
17: import org.eclipse.swt.widgets.ToolItem;
18:
19: /**
20: * This class represents a pseudo-group defined by an action set.
21: * It is not a real group ( aka GroupMarker ) because that would interfere with
22: * the pre-existing groups in a menu or toolbar.
23: */
24: public class ActionSetSeparator extends ContributionItem implements
25: IActionSetContributionItem {
26: private String actionSetId;
27:
28: /**
29: * Constructs a new group marker.
30: */
31: public ActionSetSeparator(String groupName, String newActionSetId) {
32: super (groupName);
33: actionSetId = newActionSetId;
34: }
35:
36: /* (non-Javadoc)
37: * Method declared on IContributionItem.
38: * Fills the given menu with a SWT separator MenuItem.
39: */
40: public void fill(Menu menu, int index) {
41: if (index >= 0) {
42: new MenuItem(menu, SWT.SEPARATOR, index);
43: } else {
44: new MenuItem(menu, SWT.SEPARATOR);
45: }
46: }
47:
48: /* (non-Javadoc)
49: * Method declared on IContributionItem.
50: * Fills the given tool bar with a SWT separator ToolItem.
51: */
52: public void fill(ToolBar toolbar, int index) {
53: if (index >= 0) {
54: new ToolItem(toolbar, SWT.SEPARATOR, index);
55: } else {
56: new ToolItem(toolbar, SWT.SEPARATOR);
57: }
58: }
59:
60: /**
61: * Returns the action set id.
62: */
63: public String getActionSetId() {
64: return actionSetId;
65: }
66:
67: /**
68: * The <code>Separator</code> implementation of this <code>IContributionItem</code>
69: * method returns <code>true</code>
70: */
71: public boolean isSeparator() {
72: return true;
73: }
74:
75: /**
76: * Sets the action set id.
77: */
78: public void setActionSetId(String newActionSetId) {
79: actionSetId = newActionSetId;
80: }
81: }
|