KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > menus > SReference


1 /*******************************************************************************
2  * Copyright (c) 2005, 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
12 package org.eclipse.ui.internal.menus;
13
14 /**
15  * <p>
16  * A reference to an already existing menu element. A reference is used to
17  * modify or extend the meaning of an existing menu element.
18  * </p>
19  * <p>
20  * Clients may instantiate this class, but must not extend.
21  * </p>
22  * <p>
23  * <strong>PROVISIONAL</strong>. This class or interface has been added as
24  * part of a work in progress. There is a guarantee neither that this API will
25  * work nor that it will remain the same. Please do not use this API without
26  * consulting with the Platform/UI team.
27  * </p>
28  * <p>
29  * This class will eventually exist in <code>org.eclipse.jface.menus</code>.
30  * </p>
31  *
32  * @since 3.2
33  */

34 public final class SReference {
35
36     /**
37      * The constant for a reference that refers to an unspecified type of menu
38      * element.
39      */

40     public static final int TYPE_UNSPECIFIED = 0;
41
42     /**
43      * The constant for a reference that refers to a menu.
44      */

45     public static final int TYPE_MENU = 1;
46
47     /**
48      * The constant for a reference that refers to a group.
49      */

50     public static final int TYPE_GROUP = 2;
51
52     /**
53      * The constant for a reference that refers to an item.
54      */

55     public static final int TYPE_ITEM = 3;
56
57     /**
58      * The constant for a reference that refers to a widget.
59      */

60     public static final int TYPE_WIDGET = 4;
61
62     /**
63      * The type of reference. This must be one of the type constants given in
64      * this class.
65      */

66     private final int type;
67
68     /**
69      * The identifier of the menu element this refers to. Must not be
70      * <code>null</code>.
71      */

72     private final String JavaDoc id;
73
74     /**
75      * Constructs a new instance of <code>SReference</code>.
76      *
77      * @param type
78      * The type of menu element this is making reference to. This
79      * must be one of <code>TYPE_UNSPECIFIED</code>,
80      * <code>TYPE_MENU</code>, <code>TYPE_GROUP</code>,
81      * <code>TYPE_ITEM</code> or <code>TYPE_WIDGET</code>.
82      * @param id
83      * The identifier of the menu element this refers to; must not be
84      * <code>null</code>.
85      */

86     public SReference(final int type, final String JavaDoc id) {
87         if ((type < TYPE_UNSPECIFIED) || (type > TYPE_WIDGET)) {
88             throw new IllegalArgumentException JavaDoc(
89                     "The type of reference is not understood"); //$NON-NLS-1$
90
}
91         if (id == null) {
92             throw new NullPointerException JavaDoc(
93                     "The identifier of the menu element must be null"); //$NON-NLS-1$
94
}
95
96         this.type = type;
97         this.id = id;
98     }
99
100     /**
101      * Returns the identifier of the menu element to which this refers.
102      *
103      * @return The identifier of the menu element; never <code>null</code>.
104      */

105     public final String JavaDoc getId() {
106         return id;
107     }
108
109     /**
110      * Returns the type of reference. This will be one of the type constants in
111      * this class.
112      *
113      * @return The type of reference.
114      */

115     public final int getType() {
116         return type;
117     }
118 }
119
Popular Tags