|
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 useKeyBindings = (getTargetVersion() >= 3.1); |
|
|
80 |
boolean useCommandsOnly = (getTargetVersion() >= 3.4); |
| 81 |
|
| 82 |
createCommandExtension(!useKeyBindings, useCommandsOnly); |
| 83 |
if (useKeyBindings) { |
| 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 generateOldKeyBindings, 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-182
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 (generateOldKeyBindings) { |
| 180 |
element = model.getPluginFactory().createElement(extension); |
190 |
element = model.getPluginFactory().createElement(extension); |
| 181 |
element.setName("keyConfiguration"); //$NON-NLS-1$ |
191 |
element.setName("keyConfiguration"); //$NON-NLS-1$ |
| 182 |
element.setAttribute("description", "The key configuration for this sample"); //$NON-NLS-1$ //$NON-NLS-2$ |
192 |
element.setAttribute("description", "The key configuration for this sample"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
Lines 218-238
Link Here
|
| 218 |
IPluginElement element = model.getPluginFactory().createElement(extension); |
228 |
IPluginElement element = model.getPluginFactory().createElement(extension); |
| 219 |
element.setName("key"); //$NON-NLS-1$ |
229 |
element.setName("key"); //$NON-NLS-1$ |
| 220 |
element.setAttribute("commandId", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
230 |
element.setAttribute("commandId", id + ".open"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 221 |
element.setAttribute("sequence", "CTRL+2"); //$NON-NLS-1$ //$NON-NLS-2$ |
231 |
element.setAttribute("sequence", "M1+2"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 222 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
232 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 223 |
extension.add(element); |
233 |
extension.add(element); |
| 224 |
|
234 |
|
| 225 |
element = model.getPluginFactory().createElement(extension); |
235 |
element = model.getPluginFactory().createElement(extension); |
| 226 |
element.setName("key"); //$NON-NLS-1$ |
236 |
element.setName("key"); //$NON-NLS-1$ |
| 227 |
element.setAttribute("commandId", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
237 |
element.setAttribute("commandId", id + ".openMessage"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 228 |
element.setAttribute("sequence", "CTRL+3"); //$NON-NLS-1$ //$NON-NLS-2$ |
238 |
element.setAttribute("sequence", "M1+3"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 229 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
239 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 230 |
extension.add(element); |
240 |
extension.add(element); |
| 231 |
|
241 |
|
| 232 |
element = model.getPluginFactory().createElement(extension); |
242 |
element = model.getPluginFactory().createElement(extension); |
| 233 |
element.setName("key"); //$NON-NLS-1$ |
243 |
element.setName("key"); //$NON-NLS-1$ |
| 234 |
element.setAttribute("commandId", "org.eclipse.ui.file.exit"); //$NON-NLS-1$ //$NON-NLS-2$ |
244 |
element.setAttribute("commandId", "org.eclipse.ui.file.exit"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 235 |
element.setAttribute("sequence", "CTRL+X"); //$NON-NLS-1$ //$NON-NLS-2$ |
245 |
element.setAttribute("sequence", "M1+X"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 236 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
246 |
element.setAttribute("schemeId", "org.eclipse.ui.defaultAcceleratorConfiguration"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 237 |
extension.add(element); |
247 |
extension.add(element); |
| 238 |
|
248 |
|
|
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$ |