KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > action > Separator


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.jface.action;
12
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  * A separator is a special kind of contribution item which acts
21  * as a visual separator and, optionally, acts as a group marker.
22  * Unlike group markers, separators do have a visual representation for
23  * menus and toolbars.
24  * <p>
25  * This class may be instantiated; it is not intended to be
26  * subclassed outside the framework.
27  * </p>
28  */

29 public class Separator extends AbstractGroupMarker {
30     /**
31      * Creates a separator which does not start a new group.
32      */

33     public Separator() {
34         super();
35     }
36
37     /**
38      * Creates a new separator which also defines a new group having the given group name.
39      * The group name must not be <code>null</code> or the empty string.
40      * The group name is also used as the item id.
41      *
42      * @param groupName the group name of the separator
43      */

44     public Separator(String JavaDoc groupName) {
45         super(groupName);
46     }
47
48     /* (non-Javadoc)
49      * Method declared on IContributionItem.
50      * Fills the given menu with a SWT separator MenuItem.
51      */

52     public void fill(Menu menu, int index) {
53         if (index >= 0) {
54             new MenuItem(menu, SWT.SEPARATOR, index);
55         } else {
56             new MenuItem(menu, SWT.SEPARATOR);
57         }
58     }
59
60     /* (non-Javadoc)
61      * Method declared on IContributionItem.
62      * Fills the given tool bar with a SWT separator ToolItem.
63      */

64     public void fill(ToolBar toolbar, int index) {
65         if (index >= 0) {
66             new ToolItem(toolbar, SWT.SEPARATOR, index);
67         } else {
68             new ToolItem(toolbar, SWT.SEPARATOR);
69         }
70     }
71
72     /**
73      * The <code>Separator</code> implementation of this <code>IContributionItem</code>
74      * method returns <code>true</code>
75      */

76     public boolean isSeparator() {
77         return true;
78     }
79 }
80
Popular Tags