KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > menus > MenuUtil


1 /*******************************************************************************
2  * Copyright (c) 2007 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.menus;
13
14 /**
15  * Provides utilities and constants for use with the
16  * new menus API.
17  *
18  * @since 3.3
19  *
20  */

21 public class MenuUtil {
22     /** Main Menu */
23     public final static String JavaDoc MAIN_MENU = "menu:org.eclipse.ui.main.menu"; //$NON-NLS-1$
24
/** Main ToolBar (CoolBar) */
25     public final static String JavaDoc MAIN_TOOLBAR = "toolbar:org.eclipse.ui.main.toolbar"; //$NON-NLS-1$
26

27     /** -Any- Popup Menu */
28     public final static String JavaDoc ANY_POPUP = "popup:org.eclipse.ui.popup.any"; //$NON-NLS-1$
29

30     /** Top Left Trim Area */
31     public final static String JavaDoc TRIM_COMMAND1 = "toolbar:org.eclipse.ui.trim.command1"; //$NON-NLS-1$
32
/** Top Right Trim Area */
33     public final static String JavaDoc TRIM_COMMAND2 = "toolbar:org.eclipse.ui.trim.command2"; //$NON-NLS-1$
34
/** Left Vertical Trim Area */
35     public final static String JavaDoc TRIM_VERTICAL1 = "toolbar:org.eclipse.ui.trim.vertical1"; //$NON-NLS-1$
36
/** Right Vertical Trim Area */
37     public final static String JavaDoc TRIM_VERTICAL2 = "toolbar:org.eclipse.ui.trim.vertical2"; //$NON-NLS-1$
38
/** Bottom (Status) Trim Area */
39     public final static String JavaDoc TRIM_STATUS = "toolbar:org.eclipse.ui.trim.status"; //$NON-NLS-1$
40

41     /**
42      * @param id The menu's id
43      * @return
44      * The lcoation URI for a menu with the given id
45      */

46     public static String JavaDoc menuUri(String JavaDoc id) {
47         return "menu:" + id; //$NON-NLS-1$
48
}
49     
50     /**
51      * @param id The id of the menu
52      * @param location The relative location specifier
53      * @param refId The id of the menu element to be relative to
54      * @return
55      * A location URI formatted with the given parameters
56      */

57     public static String JavaDoc menuAddition(String JavaDoc id, String JavaDoc location, String JavaDoc refId) {
58         return menuUri(id) + '?' + location + '=' + refId;
59     }
60     
61     /**
62      * Convenience method to create a standard menu addition
63      * The resulting string has the format:
64      * "menu:[id]?after=additions"
65      * @param id The id of the root element to contribute to
66      * @return The formatted string
67      */

68     public static String JavaDoc menuAddition(String JavaDoc id) {
69         return menuAddition(id, "after", "additions"); //$NON-NLS-1$//$NON-NLS-2$
70
}
71     
72     /**
73      * @param id The toolbar's id
74      * @return
75      * The lcoation URI for a toolbar with the given id
76      */

77     public static String JavaDoc toolbarUri(String JavaDoc id) {
78         return "toolbar:" + id; //$NON-NLS-1$
79
}
80     
81     /**
82      * @param id The id of the toolbar
83      * @param location The relative location specifier
84      * @param refId The id of the toolbar element to be relative to
85      * @return
86      * A location URI formatted with the given parameters
87      */

88     public static String JavaDoc toolbarAddition(String JavaDoc id, String JavaDoc location, String JavaDoc refId) {
89         return toolbarUri(id) + '?' + location + '=' + refId;
90     }
91     
92     /**
93      * Convenience method to create a standard toolbar addition
94      * The resulting string has the format:
95      * "toolbar:[id]?after=additions"
96      * @param id The id of the root element to contribute to
97      * @return The formatted string
98      */

99     public static String JavaDoc toolbarAddition(String JavaDoc id) {
100         return toolbarAddition(id, "after", "additions"); //$NON-NLS-1$//$NON-NLS-2$
101
}
102 }
103
Popular Tags