Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 9b861221a645d0b0fe7ed1b9ec4af3571448e9de (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/*******************************************************************************
 * Copyright (c) 2007, 2015 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ui.menus;

import java.util.Map;

import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.services.IServiceLocator;

/**
 * A help class for the various parameters that can be used with command
 * contributions. Mandatory parameters are in the constructor, and public fields
 * can be set to fill in other parameters.
 *
 * @since 3.4
 */
public class CommandContributionItemParameter {
	/**
	 * a service locator that is most appropriate for this contribution. Typically
	 * the local {@link IWorkbenchWindow} or {@link IWorkbenchPartSite} will be
	 * sufficient. Must not be <code>null</code>.
	 */
	public IServiceLocator serviceLocator;

	/**
	 * The id for this item. May be <code>null</code>. Items without an id cannot be
	 * referenced later.
	 */
	public String id;

	/**
	 * A command id for a defined command. Must not be <code>null</code>.
	 */
	public String commandId;

	/**
	 * A map of strings to strings which represent parameter names to values. The
	 * parameter names must match those in the command definition. May be
	 * <code>null</code>
	 */
	public Map parameters;

	/**
	 * An icon for this item. May be <code>null</code>.
	 */
	public ImageDescriptor icon;

	/**
	 * A disabled icon for this item. May be <code>null</code>.
	 */
	public ImageDescriptor disabledIcon;

	/**
	 * A hover icon for this item. May be <code>null</code>.
	 */
	public ImageDescriptor hoverIcon;

	/**
	 * A label for this item. May be <code>null</code>.
	 */
	public String label;

	/**
	 * A mnemonic for this item to be applied to the label. May be
	 * <code>null</code>.
	 */
	public String mnemonic;

	/**
	 * A tooltip for this item. May be <code>null</code>. Tooltips are currently
	 * only valid for toolbar contributions.
	 */
	public String tooltip;

	/**
	 * The style of this menu contribution. See the CommandContributionItem STYLE_*
	 * contants.
	 */
	public int style;

	/**
	 * The help context id to be applied to this contribution. May be
	 * <code>null</code>
	 */
	public String helpContextId;

	/**
	 * The icon style to use. May be <code>null</code> for default style.
	 *
	 * @see org.eclipse.ui.commands.ICommandImageService
	 */
	public String iconStyle;

	/**
	 * The visibility tracking for a menu contribution.
	 */
	public boolean visibleEnabled;

	/**
	 * Any number of mode bits, like
	 * {@link CommandContributionItem#MODE_FORCE_TEXT}.
	 */
	public int mode;

	/**
	 * Create the parameter object. Nullable attributes can be set directly.
	 *
	 * @param serviceLocator a service locator that is most appropriate for this
	 *                       contribution. Typically the local
	 *                       {@link IWorkbenchWindow} or {@link IWorkbenchPartSite}
	 *                       will be sufficient. Must not be <code>null</code>.
	 * @param id             The id for this item. May be <code>null</code>. Items
	 *                       without an id cannot be referenced later.
	 * @param commandId      A command id for a defined command. Must not be
	 *                       <code>null</code>.
	 * @param style          The style of this menu contribution. See the STYLE_*
	 *                       contants.
	 */
	public CommandContributionItemParameter(IServiceLocator serviceLocator, String id, String commandId, int style) {
		this.serviceLocator = serviceLocator;
		this.id = id;
		this.commandId = commandId;
		this.style = style;
	}

	/**
	 * Build the parameter object.
	 * <p>
	 * <b>Note:</b> This constructor should not be called outside the framework.
	 * </p>
	 *
	 * @param serviceLocator a service locator that is most appropriate for this
	 *                       contribution. Typically the local
	 *                       {@link IWorkbenchWindow} or {@link IWorkbenchPartSite}
	 *                       will be sufficient. Must not be <code>null</code>.
	 * @param id             The id for this item. May be <code>null</code>. Items
	 *                       without an id cannot be referenced later.
	 * @param commandId      A command id for a defined command. Must not be
	 *                       <code>null</code>.
	 * @param parameters     A map of strings to strings which represent parameter
	 *                       names to values. The parameter names must match those
	 *                       in the command definition. May be <code>null</code>
	 * @param icon           An icon for this item. May be <code>null</code>.
	 * @param disabledIcon   A disabled icon for this item. May be
	 *                       <code>null</code>.
	 * @param hoverIcon      A hover icon for this item. May be <code>null</code>.
	 * @param label          A label for this item. May be <code>null</code>.
	 * @param mnemonic       A mnemonic for this item to be applied to the label.
	 *                       May be <code>null</code>.
	 * @param tooltip        A tooltip for this item. May be <code>null</code>.
	 *                       Tooltips are currently only valid for toolbar
	 *                       contributions.
	 * @param style          The style of this menu contribution. See the STYLE_*
	 *                       contants.
	 * @param helpContextId  the help context id to be applied to this contribution.
	 *                       May be <code>null</code>
	 * @param visibleEnabled Visibility tracking for the menu contribution.
	 * @noreference This constructor is not intended to be referenced by clients.
	 */
	public CommandContributionItemParameter(IServiceLocator serviceLocator, String id, String commandId, Map parameters,
			ImageDescriptor icon, ImageDescriptor disabledIcon, ImageDescriptor hoverIcon, String label,
			String mnemonic, String tooltip, int style, String helpContextId, boolean visibleEnabled) {
		this.serviceLocator = serviceLocator;
		this.id = id;
		this.commandId = commandId;
		this.parameters = parameters;
		this.icon = icon;
		this.disabledIcon = disabledIcon;
		this.hoverIcon = hoverIcon;
		this.label = label;
		this.mnemonic = mnemonic;
		this.tooltip = tooltip;
		this.style = style;
		this.helpContextId = helpContextId;
		this.visibleEnabled = visibleEnabled;
	}
}

Back to the top