KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.ContributionItem;
14 import org.eclipse.swt.SWT;
15 import org.eclipse.swt.widgets.Menu;
16 import org.eclipse.swt.widgets.MenuItem;
17 import org.eclipse.swt.widgets.ToolBar;
18 import org.eclipse.swt.widgets.ToolItem;
19
20 /**
21  * This class represents a pseudo-group defined by an action set.
22  * It is not a real group ( aka GroupMarker ) because that would interfere with
23  * the pre-existing groups in a menu or toolbar.
24  */

25 public class ActionSetSeparator extends ContributionItem implements
26         IActionSetContributionItem {
27     private String JavaDoc actionSetId;
28
29     /**
30      * Constructs a new group marker.
31      */

32     public ActionSetSeparator(String JavaDoc groupName, String JavaDoc newActionSetId) {
33         super(groupName);
34         actionSetId = newActionSetId;
35     }
36
37     /* (non-Javadoc)
38      * Method declared on IContributionItem.
39      * Fills the given menu with a SWT separator MenuItem.
40      */

41     public void fill(Menu menu, int index) {
42         if (index >= 0) {
43             new MenuItem(menu, SWT.SEPARATOR, index);
44         } else {
45             new MenuItem(menu, SWT.SEPARATOR);
46         }
47     }
48
49     /* (non-Javadoc)
50      * Method declared on IContributionItem.
51      * Fills the given tool bar with a SWT separator ToolItem.
52      */

53     public void fill(ToolBar toolbar, int index) {
54         if (index >= 0) {
55             new ToolItem(toolbar, SWT.SEPARATOR, index);
56         } else {
57             new ToolItem(toolbar, SWT.SEPARATOR);
58         }
59     }
60
61     /**
62      * Returns the action set id.
63      */

64     public String JavaDoc getActionSetId() {
65         return actionSetId;
66     }
67
68     /**
69      * The <code>Separator</code> implementation of this <code>IContributionItem</code>
70      * method returns <code>true</code>
71      */

72     public boolean isSeparator() {
73         return true;
74     }
75
76     /**
77      * Sets the action set id.
78      */

79     public void setActionSetId(String JavaDoc newActionSetId) {
80         actionSetId = newActionSetId;
81     }
82 }
83
Popular Tags