Changeset 1306
- Timestamp:
- 11/13/07 19:43:05 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
org.jalcedo.templates/trunk/org.jalcedo.templates.editor.ui/src/org/jalcedo/templates/editor/ui/internal/MasterViewAndDetailEditorWizard.java
r1294 r1306 36 36 import org.eclipse.pde.core.plugin.IPluginImport; 37 37 import org.eclipse.pde.core.plugin.IPluginModelBase; 38 import org.eclipse.pde.core.plugin.IPluginModelFactory;39 38 import org.eclipse.pde.core.plugin.IPluginObject; 39 import org.eclipse.pde.core.plugin.IPluginParent; 40 40 import org.eclipse.pde.ui.IExtensionWizard; 41 41 import org.eclipse.ui.IWorkbenchWindow; … … 148 148 this.addExtention(pluginModelBase, viewExtension); 149 149 150 IPluginElement perspectiveElement = findPluginE lement(pluginModelBase,151 "org.eclipse.ui.perspectives");150 IPluginElement perspectiveElement = findPluginExtensionElement( 151 pluginModelBase, "org.eclipse.ui.perspectives"); 152 152 if (perspectiveElement != null) { 153 153 IPluginExtension perspectiveExtension = createPerspectiveExtension( … … 194 194 } 195 195 196 private IPluginElement findPluginE lement(IPluginModelBase pluginModelBase,197 String extensionPoint) {196 private IPluginElement findPluginExtensionElement( 197 IPluginModelBase pluginModelBase, String extensionPoint) { 198 198 199 199 IPluginBase plugin = pluginModelBase.getPluginBase(); … … 243 243 pluginModelBase, "org.eclipse.ui.perspectiveExtensions", true); 244 244 245 IPluginModelFactory factory = pluginModelBase.getPluginFactory(); 246 247 IPluginElement peElement = factory.createElement(perspectiveExtension); 248 peElement.setName("perspectiveExtension"); 249 peElement.setAttribute("targetID", perspectiveElement 250 .getAttribute("id").getValue()); 251 perspectiveExtension.add(peElement); 252 253 IPluginElement viewElement = factory.createElement(peElement); 254 255 viewElement.setName("view"); 256 viewElement.setAttribute("id", viewModel.getPackageName() + "." 257 + viewModel.getClassName()); 245 String perspectiveID = perspectiveElement.getAttribute("id").getValue(); 246 247 IPluginElement peElement = createPluginElement(perspectiveExtension, 248 "perspectiveExtension", "targetID", perspectiveID); 249 250 String viewID = viewModel.getPackageName() + "." 251 + viewModel.getClassName(); 252 253 IPluginElement viewElement = createPluginElement(peElement, "view", 254 "id", viewID); 258 255 viewElement.setAttribute("ratio", "0.5"); 259 256 viewElement.setAttribute("relationship", "left"); 260 257 viewElement.setAttribute("relative", "org.eclipse.ui.editorss"); 261 peElement.add(viewElement); 258 262 259 return perspectiveExtension; 263 260 } … … 274 271 GeneratableClassModel viewModel, IPluginModelBase pluginModelBase) 275 272 throws CoreException { 273 276 274 IPluginExtension extension = createExtension(pluginModelBase, 277 275 "org.eclipse.ui.views", true); 278 IPluginModelFactory factory = pluginModelBase.getPluginFactory();279 280 IPluginElement viewElement = factory.createElement(extension);281 276 282 277 String modelFQDN = viewModel.getPackageName() + "." 283 278 + viewModel.getClassName(); 284 279 285 viewElement.setName("view"); 286 viewElement.setAttribute("id", modelFQDN); 280 IPluginElement viewElement = createPluginElement(extension, "view", 281 "id", modelFQDN); 282 287 283 viewElement.setAttribute("name", viewModel.getClassName()); 288 284 viewElement.setAttribute("class", modelFQDN); 289 extension.add(viewElement);290 285 return extension; 286 } 287 288 private IPluginElement createPluginElement(IPluginParent parent, 289 String elementName, String idAttributeName, String idValue) 290 throws CoreException { 291 IPluginObject[] children = parent.getChildren(); 292 for (IPluginObject pluginObject : children) { 293 if (pluginObject instanceof IPluginElement) { 294 IPluginElement element = (IPluginElement) pluginObject; 295 if (element.getName().equals(elementName) 296 && element.getAttribute(idAttributeName).getValue() 297 .equals(idValue)) { 298 return element; 299 } 300 } 301 } 302 IPluginElement pluginElement = pluginModelBase.getPluginFactory() 303 .createElement(parent); 304 pluginElement.setName(elementName); 305 pluginElement.setAttribute(idAttributeName, idValue); 306 parent.add(pluginElement); 307 return pluginElement; 291 308 } 292 309 … … 304 321 IPluginExtension extension = createExtension(pluginModelBase, 305 322 "org.eclipse.ui.editors", true); 306 IPluginModelFactory factory = pluginModelBase.getPluginFactory();307 308 IPluginElement editorElement = factory.createElement(extension);309 323 310 324 String modelFQDN = editorModel.getPackageName() + "." 311 325 + editorModel.getClassName(); 312 326 313 editorElement.setName("editor"); 314 editorElement.setAttribute("id", modelFQDN); 327 IPluginElement editorElement = createPluginElement(extension, "editor", 328 "id", modelFQDN); 329 315 330 editorElement.setAttribute("name", editorModel.getClassName()); 316 331 editorElement.setAttribute("class", modelFQDN); 317 332 editorElement.setAttribute("icon", EDITOR_ICON_PATH); 318 extension.add(editorElement);319 333 return extension; 320 334 }
