|
Lines 14-29
Link Here
|
| 14 |
import org.eclipse.core.runtime.IProgressMonitor; |
14 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 15 |
import org.eclipse.jface.wizard.Wizard; |
15 |
import org.eclipse.jface.wizard.Wizard; |
| 16 |
import org.eclipse.jface.wizard.WizardPage; |
16 |
import org.eclipse.jface.wizard.WizardPage; |
| 17 |
import org.eclipse.pde.core.plugin.IPluginBase; |
17 |
import org.eclipse.pde.core.plugin.*; |
| 18 |
import org.eclipse.pde.core.plugin.IPluginElement; |
18 |
import org.eclipse.pde.internal.ui.templates.*; |
| 19 |
import org.eclipse.pde.core.plugin.IPluginExtension; |
|
|
| 20 |
import org.eclipse.pde.core.plugin.IPluginModelBase; |
| 21 |
import org.eclipse.pde.core.plugin.IPluginReference; |
| 22 |
import org.eclipse.pde.internal.ui.templates.IHelpContextIds; |
| 23 |
import org.eclipse.pde.internal.ui.templates.PDETemplateMessages; |
| 24 |
import org.eclipse.pde.internal.ui.templates.PDETemplateSection; |
| 25 |
import org.eclipse.pde.ui.IFieldData; |
19 |
import org.eclipse.pde.ui.IFieldData; |
| 26 |
import org.eclipse.pde.ui.templates.PluginReference; |
20 |
import org.eclipse.pde.ui.templates.PluginReference; |
|
|
21 |
import org.eclipse.ui.IWorkbenchActionConstants; |
| 22 |
import org.eclipse.ui.menus.MenuUtil; |
| 27 |
|
23 |
|
| 28 |
public class MailTemplate extends PDETemplateSection { |
24 |
public class MailTemplate extends PDETemplateSection { |
| 29 |
|
25 |
|
|
Lines 79-89
Link Here
|
| 79 |
createApplicationExtension(); |
75 |
createApplicationExtension(); |
| 80 |
createPerspectiveExtension(); |
76 |
createPerspectiveExtension(); |
| 81 |
createViewExtension(); |
77 |
createViewExtension(); |
| 82 |
if (getTargetVersion() >= 3.1) { |
78 |
|
| 83 |
createCommandExtension(false); |
79 |
boolean generateKeyBindings = (getTargetVersion() >= 3.1); |
|
|
80 |
boolean useCommandsOnly = (getTargetVersion() >= 3.6); |
| 81 |
|
| 82 |
createCommandExtension(generateKeyBindings, useCommandsOnly); |
| 83 |
if (generateKeyBindings) { |
| 84 |
createBindingsExtension(); |
84 |
createBindingsExtension(); |
| 85 |
} else { |
85 |
} |
| 86 |
createCommandExtension(true); |
86 |
if (useCommandsOnly) { |
|
|
87 |
createUiMenuExtension(); |
| 87 |
} |
88 |
} |
| 88 |
createProductExtension(); |
89 |
createProductExtension(); |
| 89 |
} |
90 |
} |
|
Lines 149-155
Link Here
|
| 149 |
plugin.add(extension); |
150 |
plugin.add(extension); |
| 150 |
} |
151 |
} |
| 151 |
|
152 |
|
| 152 |
private void createCommandExtension(boolean generateKeyBindings) throws CoreException { |
153 |
private void createCommandExtension(boolean generateKeyBindings, boolean useCommandsOnly) throws CoreException { |
| 153 |
IPluginBase plugin = model.getPluginBase(); |
154 |
IPluginBase plugin = model.getPluginBase(); |
| 154 |
String id = plugin.getId(); |
155 |
String id = plugin.getId(); |
| 155 |
IPluginExtension extension = createExtension("org.eclipse.ui.commands", true); //$NON-NLS-1$ |
156 |
IPluginExtension extension = createExtension("org.eclipse.ui.commands", true); //$NON-NLS-1$ |
|
Lines 162-169
Link Here
|
| 162 |
|
163 |
|
| 163 |
element = model.getPluginFactory().createElement(extension); |
164 |
element = model.getPluginFactory().createElement(extension); |
| 164 |
element.setName("command"); //$NON-NLS-1$ |
165 |
element.setName("command"); //$NON-NLS-1$ |
| 165 |
element.setAttribute("description", "Opens a mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ |
166 |
if (useCommandsOnly) { |
| 166 |
element.setAttribute("name", "Open Mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ |
167 |
element.setAttribute("description", "Opens Another Message View"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
168 |
element.setAttribute("name", "Open Another Message View"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 169 |
element.setAttribute("defaultHandler", getStringOption(KEY_PACKAGE_NAME) + ".OpenViewHandler"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 170 |
} else { |
| 171 |
element.setAttribute("description", "Opens a mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 172 |
element.setAttribute("name", "Open Mailbox"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 173 |
} |
| 167 |
element.setAttribute("id", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
174 |
element.setAttribute("id", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 168 |
element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ |
175 |
element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 169 |
extension.add(element); |
176 |
extension.add(element); |
|
Lines 174-179
Link Here
|
| 174 |
element.setAttribute("name", "Open Message Dialog"); //$NON-NLS-1$ //$NON-NLS-2$ |
181 |
element.setAttribute("name", "Open Message Dialog"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 175 |
element.setAttribute("id", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
182 |
element.setAttribute("id", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 176 |
element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ |
183 |
element.setAttribute("categoryId", id + ".category"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
|
184 |
if (useCommandsOnly) { |
| 185 |
element.setAttribute("defaultHandler", getStringOption(KEY_PACKAGE_NAME) + ".OpenMessageHandler"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 186 |
} |
| 177 |
extension.add(element); |
187 |
extension.add(element); |
| 178 |
|
188 |
|
| 179 |
if (generateKeyBindings) { |
189 |
if (generateKeyBindings) { |
|
Lines 187-207
Link Here
|
| 187 |
element = model.getPluginFactory().createElement(extension); |
197 |
element = model.getPluginFactory().createElement(extension); |
| 188 |
element.setName("keyBinding"); //$NON-NLS-1$ |
198 |
element.setName("keyBinding"); //$NON-NLS-1$ |
| 189 |
element.setAttribute("commandId", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
199 |
element.setAttribute("commandId", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 190 |
element.setAttribute("keySequence", "CTRL+2"); //$NON-NLS-1$ //$NON-NLS-2$ |
200 |
element.setAttribute("keySequence", "M1+2"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 191 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
201 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 192 |
extension.add(element); |
202 |
extension.add(element); |
| 193 |
|
203 |
|
| 194 |
element = model.getPluginFactory().createElement(extension); |
204 |
element = model.getPluginFactory().createElement(extension); |
| 195 |
element.setName("keyBinding"); //$NON-NLS-1$ |
205 |
element.setName("keyBinding"); //$NON-NLS-1$ |
| 196 |
element.setAttribute("commandId", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
206 |
element.setAttribute("commandId", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 197 |
element.setAttribute("keySequence", "CTRL+3"); //$NON-NLS-1$ //$NON-NLS-2$ |
207 |
element.setAttribute("keySequence", "M1+3"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 198 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
208 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 199 |
extension.add(element); |
209 |
extension.add(element); |
| 200 |
|
210 |
|
| 201 |
element = model.getPluginFactory().createElement(extension); |
211 |
element = model.getPluginFactory().createElement(extension); |
| 202 |
element.setName("keyBinding"); //$NON-NLS-1$ |
212 |
element.setName("keyBinding"); //$NON-NLS-1$ |
| 203 |
element.setAttribute("commandId", "org.eclipse.ui.file.exit"); //$NON-NLS-1$ //$NON-NLS-2$ |
213 |
element.setAttribute("commandId", "org.eclipse.ui.file.exit"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 204 |
element.setAttribute("keySequence", "CTRL+Q"); //$NON-NLS-1$ //$NON-NLS-2$ |
214 |
element.setAttribute("keySequence", "M1+Q"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 205 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
215 |
element.setAttribute("keyConfigurationId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 206 |
extension.add(element); |
216 |
extension.add(element); |
| 207 |
} |
217 |
} |
|
Lines 240-245
Link Here
|
| 240 |
plugin.add(extension); |
250 |
plugin.add(extension); |
| 241 |
} |
251 |
} |
| 242 |
|
252 |
|
|
|
253 |
private void createUiMenuExtension() throws CoreException { |
| 254 |
IPluginBase plugin = model.getPluginBase(); |
| 255 |
String id = plugin.getId(); |
| 256 |
IPluginExtension extension = createExtension("org.eclipse.ui.menus", true); //$NON-NLS-1$ |
| 257 |
|
| 258 |
IPluginElement menuContribution = model.getPluginFactory().createElement(extension); |
| 259 |
menuContribution.setName("menuContribution"); //$NON-NLS-1$ |
| 260 |
menuContribution.setAttribute("locationURI", MenuUtil.MAIN_MENU); //$NON-NLS-1$ |
| 261 |
extension.add(menuContribution); |
| 262 |
|
| 263 |
IPluginElement fileMenu = model.getPluginFactory().createElement(extension); |
| 264 |
fileMenu.setName("menu"); //$NON-NLS-1$ |
| 265 |
fileMenu.setAttribute("id", IWorkbenchActionConstants.M_FILE); //$NON-NLS-1$ |
| 266 |
fileMenu.setAttribute("label", "&File"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 267 |
menuContribution.add(fileMenu); |
| 268 |
|
| 269 |
addMenuCommandElement(model, fileMenu, "org.eclipse.ui.window.newWindow", null); //$NON-NLS-1$ |
| 270 |
addMenuSeparatorElement(model, fileMenu, IWorkbenchActionConstants.M_FILE + ".separator1"); //$NON-NLS-1$ |
| 271 |
addMenuCommandElement(model, fileMenu, id + ".openMessage", "icons/sample3.gif"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 272 |
addMenuCommandElement(model, fileMenu, id + ".open", "icons/sample2.gif"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 273 |
addMenuSeparatorElement(model, fileMenu, IWorkbenchActionConstants.M_FILE + ".separator2"); //$NON-NLS-1$ |
| 274 |
addMenuCommandElement(model, fileMenu, "org.eclipse.ui.file.exit", null); //$NON-NLS-1$ |
| 275 |
|
| 276 |
IPluginElement helpMenu = model.getPluginFactory().createElement(extension); |
| 277 |
helpMenu.setName("menu"); //$NON-NLS-1$ |
| 278 |
helpMenu.setAttribute("id", IWorkbenchActionConstants.M_HELP); //$NON-NLS-1$ |
| 279 |
helpMenu.setAttribute("label", "&Help"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 280 |
menuContribution.add(helpMenu); |
| 281 |
|
| 282 |
addMenuCommandElement(model, helpMenu, "org.eclipse.ui.help.aboutAction", null); //$NON-NLS-1$ |
| 283 |
|
| 284 |
IPluginElement toolbarContribution = model.getPluginFactory().createElement(extension); |
| 285 |
toolbarContribution.setName("menuContribution"); //$NON-NLS-1$ |
| 286 |
toolbarContribution.setAttribute("locationURI", MenuUtil.MAIN_TOOLBAR); //$NON-NLS-1$ |
| 287 |
extension.add(toolbarContribution); |
| 288 |
|
| 289 |
IPluginElement mainToolbar = model.getPluginFactory().createElement(extension); |
| 290 |
mainToolbar.setName("toolbar"); //$NON-NLS-1$ |
| 291 |
mainToolbar.setAttribute("id", "main"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 292 |
toolbarContribution.add(mainToolbar); |
| 293 |
|
| 294 |
addMenuCommandElement(model, mainToolbar, id + ".openMessage", "icons/sample3.gif"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 295 |
addMenuCommandElement(model, mainToolbar, id + ".open", "icons/sample2.gif"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 296 |
|
| 297 |
if (!extension.isInTheModel()) |
| 298 |
plugin.add(extension); |
| 299 |
} |
| 300 |
|
| 301 |
private void addMenuCommandElement(IPluginModelBase model, IPluginElement menuElement, String commandId, String icon) throws CoreException { |
| 302 |
IPluginElement commandElement = model.getPluginFactory().createElement(menuElement); |
| 303 |
commandElement.setName("command"); //$NON-NLS-1$ |
| 304 |
commandElement.setAttribute("commandId", commandId); //$NON-NLS-1$ |
| 305 |
commandElement.setAttribute("style", "push"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 306 |
if (icon != null) { |
| 307 |
commandElement.setAttribute("icon", icon); //$NON-NLS-1$ |
| 308 |
} |
| 309 |
menuElement.add(commandElement); |
| 310 |
} |
| 311 |
|
| 312 |
private void addMenuSeparatorElement(IPluginModelBase model, IPluginElement menuElement, String name) throws CoreException { |
| 313 |
IPluginElement commandElement = model.getPluginFactory().createElement(menuElement); |
| 314 |
commandElement.setName("separator"); //$NON-NLS-1$ |
| 315 |
commandElement.setAttribute("name", name); //$NON-NLS-1$ |
| 316 |
commandElement.setAttribute("visible", "true"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 317 |
menuElement.add(commandElement); |
| 318 |
} |
| 319 |
|
| 243 |
private void createProductExtension() throws CoreException { |
320 |
private void createProductExtension() throws CoreException { |
| 244 |
IPluginBase plugin = model.getPluginBase(); |
321 |
IPluginBase plugin = model.getPluginBase(); |
| 245 |
IPluginExtension extension = createExtension("org.eclipse.core.runtime.products", true); //$NON-NLS-1$ |
322 |
IPluginExtension extension = createExtension("org.eclipse.core.runtime.products", true); //$NON-NLS-1$ |