KickJava   Java API By Example, From Geeks To Geeks.

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


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 import org.eclipse.jface.util.Util;
15 import org.eclipse.ui.internal.misc.Policy;
16
17 /**
18  * <p>
19  * A leaf element within a location. This provides the most specific piece of
20  * information as to where the menu element should appear. The <code>path</code>
21  * specifies where within the popup menu the menu element should be placed.
22  * </p>
23  * <p>
24  * Clients must not implement or extend.
25  * </p>
26  * <p>
27  * <strong>PROVISIONAL</strong>. This class or interface has been added as
28  * part of a work in progress. There is a guarantee neither that this API will
29  * work nor that it will remain the same. Please do not use this API without
30  * consulting with the Platform/UI team.
31  * </p>
32  * <p>
33  * This class will eventually exist in <code>org.eclipse.jface.menus</code>.
34  * </p>
35  *
36  * @since 3.2
37  * @see org.eclipse.ui.internal.menus.SBar
38  * @see org.eclipse.ui.internal.menus.SPopup
39  */

40 public abstract class LeafLocationElement implements LocationElement {
41
42     /**
43      *
44      */

45     public static final String JavaDoc BREAKPOINT_PATH = "org.eclipse.search.menu"; //$NON-NLS-1$
46

47     /**
48      * The path separator used to separate menu containers.
49      */

50     public static final char PATH_SEPARATOR = '/';
51
52     /**
53      * The path within this location element to the final location. The path is
54      * a slash-delimited list of menu elements.
55      */

56     private final String JavaDoc path;
57
58     /**
59      * Constructs a new instance of <code>LeafLocationElement</code>.
60      *
61      * @param path
62      * The path to the final location. If this value is
63      * <code>null</code>, it means that it should be inserted at
64      * the top-level of the location.
65      */

66     public LeafLocationElement(final String JavaDoc path) {
67         if (Policy.EXPERIMENTAL_MENU && path != null
68                 && path.indexOf(BREAKPOINT_PATH) > -1) {
69             System.err.println("LeafLocationElement: " + path); //$NON-NLS-1$
70
}
71         this.path = path;
72     }
73
74     /**
75      * Returns the full path for this location. The path is a slash-delimited
76      * list of menu elements.
77      *
78      * @return The full path. If this value is <code>null</code>, it means
79      * that it should be inserted at the top-level of the location.
80      */

81     public final String JavaDoc getPath() {
82         return path;
83     }
84
85     /**
86      * Returns a tokenizer for this location element. A location tokenizer is
87      * capable of returning each element along the path as its own instance of
88      * <code>LeafLocationElement</code>. This can be used for creating
89      * implicit locations when parsing paths.
90      *
91      * @return A tokenizer for this location element; never <code>null</code>.
92      */

93     public abstract ILocationElementTokenizer getTokenizer();
94
95     /* (non-Javadoc)
96      * @see java.lang.Object#equals(java.lang.Object)
97      */

98     public boolean equals(Object JavaDoc obj) {
99         if (this==obj) {
100             return true;
101         }
102         if (obj instanceof LeafLocationElement) {
103             LeafLocationElement leaf = (LeafLocationElement) obj;
104             return Util.equals(path, leaf.path);
105         }
106         return false;
107     }
108
109     /* (non-Javadoc)
110      * @see java.lang.Object#hashCode()
111      */

112     public int hashCode() {
113         return Util.hashCode(path);
114     }
115 }
116
Popular Tags