Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 169962 Details for
Bug 313179
[Usability] Refactor CreateModelWizard
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Refactoring - creation functionality was woved from the Wizard to the corresponding wizard pages
313179 (text/plain), 25.04 KB, created by
Tatiana Fesenko
on 2010-05-26 06:17:51 EDT
(
hide
)
Description:
Refactoring - creation functionality was woved from the Wizard to the corresponding wizard pages
Filename:
MIME Type:
Creator:
Tatiana Fesenko
Created:
2010-05-26 06:17:51 EDT
Size:
25.04 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.papyrus.diagram.common >Index: src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java >=================================================================== >--- src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java (revision 1714) >+++ src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java (working copy) >@@ -14,9 +14,10 @@ > package org.eclipse.papyrus.diagram.common.wizards; > > import org.eclipse.emf.common.util.URI; >-import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.papyrus.wizards.Activator; > import org.eclipse.papyrus.wizards.CreateModelWizard; >+import org.eclipse.papyrus.wizards.SelectTemplateWizardPage; > import org.eclipse.uml2.uml.Model; > import org.eclipse.uml2.uml.UMLFactory; > import org.eclipse.uml2.uml.UMLPackage; >@@ -48,13 +49,18 @@ > return "uml"; > } > >- /** >- * This method is invoked for creation of a model >- */ >- protected void initializeEmptyModel(Resource resource, String rootElementName) { >- Model model = UMLFactory.eINSTANCE.createModel(); >- model.setName(rootElementName); >- resource.getContents().add(model); >+ protected SelectTemplateWizardPage getSelectTemplateWizardPage() { >+ return new SelectTemplateWizardPage(Activator.PLUGIN_ID, null, null) { >+ /** >+ * This method is invoked for creation of a model >+ */ >+ protected void initializeEmptyModel(Resource resource, String rootElementName) { >+ Model model = UMLFactory.eINSTANCE.createModel(); >+ model.setName(rootElementName); >+ resource.getContents().add(model); >+ } >+ }; > } > >+ > } >#P org.eclipse.papyrus.wizards >Index: src/org/eclipse/papyrus/wizards/CreateModelWizard.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/CreateModelWizard.java (revision 1714) >+++ src/org/eclipse/papyrus/wizards/CreateModelWizard.java (working copy) >@@ -7,32 +7,19 @@ > * > * Contributors: > * Obeo - initial API and implementation >+ * Tatiana Fesenko(CEA) - [313179] Refactor CreateModelWizard > *******************************************************************************/ > package org.eclipse.papyrus.wizards; > >-import java.io.IOException; >-import java.util.ArrayList; >-import java.util.List; >+import static org.eclipse.papyrus.wizards.Activator.log; > > import org.eclipse.core.resources.IFile; >-import org.eclipse.core.runtime.IPath; >-import org.eclipse.core.runtime.NullProgressMonitor; >-import org.eclipse.core.runtime.Path; >-import org.eclipse.core.runtime.Platform; > import org.eclipse.emf.common.util.URI; > import org.eclipse.emf.ecore.EObject; > import org.eclipse.emf.ecore.resource.Resource; >-import org.eclipse.emf.ecore.resource.ResourceSet; >-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >-import org.eclipse.emf.ecore.util.EcoreUtil; >-import org.eclipse.emf.transaction.RecordingCommand; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.jface.wizard.Wizard; >-import org.eclipse.papyrus.core.extension.commands.ICreationCommand; > import org.eclipse.papyrus.core.utils.DiResourceSet; >-import org.eclipse.papyrus.core.utils.EditorUtils; >-import org.eclipse.papyrus.core.utils.PapyrusTrace; >-import org.eclipse.papyrus.resource.uml.UmlModel; > import org.eclipse.ui.INewWizard; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.IWorkbenchPage; >@@ -138,37 +125,14 @@ > } > selectDiagramKindPage = new SelectDiagramKindPage("Select kind of diagram"); > // fjcano #293135 :: support model templates >- selectTemplateWizardPage = new SelectTemplateWizardPage(Activator.PLUGIN_ID, null, null); >+ selectTemplateWizardPage = getSelectTemplateWizardPage(); > } > >- /** >- * Suggests a name of diagram file for the domain model file >- */ >- protected String getDiagramFileName(IFile domainModel) { >- String diModelFileName = (domainModel.getLocation().removeFileExtension().lastSegment()); >- diModelFileName += ".di"; >- return diModelFileName; >- } >- >- /** >- * Returns the first file from the given selection >- */ >- private IFile getSelectedFile(IStructuredSelection selection) { >- if(selection != null && !selection.isEmpty() && selection.getFirstElement() instanceof IFile) { >- return (IFile)selection.getFirstElement(); >- } >- return null; >+ protected SelectTemplateWizardPage getSelectTemplateWizardPage() { >+ return new SelectTemplateWizardPage(Activator.PLUGIN_ID, null, null); > } > > /** >- * Returns true is the file can be served as a model model for the diagram >- */ >- protected boolean isSupportedDomainModelFile(IFile file) { >- return file != null && getModelFileExtension().equals(file.getFileExtension()); >- } >- >- >- /** > * This method will be invoked, when the "Finish" button is pressed. > * > * @return <code>true</code> if everything runs without problems, <code>false</code> if an exception must be caught. >@@ -176,151 +140,67 @@ > */ > @Override > public boolean performFinish() { >- try { >- // create a new file, result != null if successful >- final IFile newFile = newModelFilePage.createNewFile(); >- >- RecordingCommand command = new RecordingCommand(diResourceSet.getTransactionalEditingDomain()) { >- >- @Override >- protected void doExecute() { >- // Create Model Resource, Notation Resource, DI Resource >- diResourceSet.createModelResources(newFile, getModelContentType(), getModelFileExtension()); >- >- // Initialize Model Resource >- Resource modelResource = diResourceSet.getModelResource(); >- if(modelResource != null) { >- IPath path = new Path(newFile.getName()); >- initializeModelResource(modelResource, path.removeFileExtension().toString()); >- } >- } >- }; >- diResourceSet.getTransactionalEditingDomain().getCommandStack().execute(command); >- >- // WorkspaceModifyOperation operation = new >- // WorkspaceModifyOperation() { >- // @Override >- // protected void execute(IProgressMonitor progressMonitor) { >- // >- // } >- // }; >- // >- // getContainer().run(false, false, operation); >- >- // open newly created file in the editor >- IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); >- if((newFile != null) && (page != null)) { >- >- String diagramName = selectDiagramKindPage.getDiagramName(); >- ICreationCommand creationCommand = selectDiagramKindPage.getCreationCommand(); >+ // create a new file, result != null if successful >+ final IFile newFile = newModelFilePage.createNewFile(); >+ selectTemplateWizardPage.initializeModelResource(diResourceSet, newFile, getModelContentType(), getModelFileExtension()); >+ if(newFile == null) { >+ return false; >+ } > >- if(creationCommand == null) { >- // Create an empty editor (no diagrams opened) >- // Geting an IPageMngr is enough to initialize the >- // SashSystem. >- EditorUtils.getTransactionalIPageMngr(diResourceSet.getDiResource(), diResourceSet.getTransactionalEditingDomain()); >- } else { >- EObject root = domainModelURI != null ? selectRootElementPage.getModelElement() : null; >- creationCommand.createDiagram(diResourceSet, root, diagramName); >- } >- try { >- diResourceSet.save(new NullProgressMonitor()); >- } catch (IOException e) { >- PapyrusTrace.log(e); >- return false; >- } >+ EObject root = domainModelURI != null ? selectRootElementPage.getModelElement() : null; >+ selectDiagramKindPage.createDiagram(diResourceSet, root); > >- try { >- IDE.openEditor(page, newFile, true); >- } catch (PartInitException e) { >- PapyrusTrace.log(e); >- return false; >- } >+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage(); >+ if(page != null) { >+ try { >+ IDE.openEditor(page, newFile, true); >+ } catch (PartInitException e) { >+ log.error(e); >+ return false; > } >- } catch (Exception e) { >- e.printStackTrace(); >- return false; > } > > return true; > } > > /** >- * Gets the model content type. >- * >- * @return the model content type >+ * Suggests a name of diagram file for the domain model file > */ >- protected abstract String getModelContentType(); >- >- /** >- * Gets the model file extension. >- * >- * @return the model file extension >- */ >- protected abstract String getModelFileExtension(); >+ protected String getDiagramFileName(IFile domainModel) { >+ String diModelFileName = (domainModel.getLocation().removeFileExtension().lastSegment()); >+ diModelFileName += ".di"; >+ return diModelFileName; >+ } > >- // fjcano #293135 :: support model templates > /** >- * Initialize model resource. >- * >- * @param resource the resource >- * @param rootElementName the root element name >+ * Returns true is the file can be served as a model model for the diagram > */ >- private void initializeModelResource(Resource resource, String rootElementName) { >- String templatePath = selectTemplateWizardPage.getTemplatePath(); >- boolean initializeFromTemplate = templatePath != null; >- if(initializeFromTemplate) { >- initializeFromTemplate(resource, rootElementName, templatePath); >- } else { >- initializeEmptyModel(resource, rootElementName); >- } >+ protected boolean isSupportedDomainModelFile(IFile file) { >+ return file != null && getModelFileExtension().equals(file.getFileExtension()); > } > > /** >- * Initialize from template. >- * >- * @param resource the resource >- * @param rootElementName the root element name >- * @param templatePath the template path >+ * Returns the first file from the given selection > */ >- protected void initializeFromTemplate(Resource resource, String rootElementName, String templatePath) { >- Resource templateResource = loadTemplateResource(templatePath); >- List<EObject> eObjectsToAdd = new ArrayList<EObject>(); >- for(EObject eObject : templateResource.getContents()) { >- eObjectsToAdd.add(EcoreUtil.copy(eObject)); >- } >- for(EObject eObject : eObjectsToAdd) { >- resource.getContents().add(eObject); >+ private IFile getSelectedFile(IStructuredSelection selection) { >+ if(selection != null && !selection.isEmpty() && selection.getFirstElement() instanceof IFile) { >+ return (IFile)selection.getFirstElement(); > } >+ return null; > } > > /** >- * Initialize empty model. >- * >- * @param resource the resource >- * @param rootElementName the root element name >+ * Gets the model content type. >+ * >+ * @return the model content type > */ >- protected void initializeEmptyModel(Resource resource, String rootElementName) { >- } >+ protected abstract String getModelContentType(); > > /** >- * Load template resource. >- * >- * @param templatePath the template path >- * @return the resource >+ * Gets the model file extension. >+ * >+ * @return the model file extension > */ >- private Resource loadTemplateResource(String templatePath) { >- String templatePluginID = selectTemplateWizardPage.getTemplatePluginId(); >- java.net.URL templateURL = Platform.getBundle(templatePluginID).getResource(templatePath); >- String fullUri = templateURL.getPath(); >- URI uri = URI.createPlatformPluginURI(templatePluginID + fullUri, true); >- ResourceSet resourceSet = new ResourceSetImpl(); >- Resource resource = resourceSet.getResource(uri, true); >- if(resource.isLoaded()) { >- return resource; >- } >- return null; >- } >- >+ protected abstract String getModelFileExtension(); > > } >Index: src/org/eclipse/papyrus/wizards/Activator.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/Activator.java (revision 1714) >+++ src/org/eclipse/papyrus/wizards/Activator.java (working copy) >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.papyrus.wizards; > >+import org.eclipse.papyrus.log.LogHelper; > import org.eclipse.ui.plugin.AbstractUIPlugin; > import org.osgi.framework.BundleContext; > >@@ -25,6 +26,9 @@ > > // The shared instance > private static Activator plugin; >+ >+ /** Logging helper */ >+ public static LogHelper log; > > /** > * The constructor >@@ -40,6 +44,7 @@ > public void start(BundleContext context) throws Exception { > super.start(context); > plugin = this; >+ log = new LogHelper(plugin); > } > > /* >Index: src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java (revision 1714) >+++ src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java (working copy) >@@ -15,10 +15,20 @@ > import java.util.Collection; > import java.util.List; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IExtension; > import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; > import org.eclipse.core.runtime.Platform; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.EObject; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.ResourceSet; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.emf.ecore.util.EcoreUtil; >+import org.eclipse.emf.transaction.RecordingCommand; > import org.eclipse.jface.viewers.ILabelProviderListener; > import org.eclipse.jface.viewers.IStructuredContentProvider; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -27,6 +37,7 @@ > import org.eclipse.jface.viewers.TableViewer; > import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.papyrus.core.utils.DiResourceSet; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; >@@ -60,20 +71,17 @@ > // TODO Auto-generated constructor stub > } > >- public SelectTemplateWizardPage(String editorId, WizardPage nextPage, >- WizardPage templatePage) { >+ public SelectTemplateWizardPage(String editorId, WizardPage nextPage, WizardPage templatePage) { > super("Select creation approach"); > this.setTitle("Select creation approach"); >- this >- .setDescription("Diagrams can be created from scratch or from a template"); >+ this.setDescription("Diagrams can be created from scratch or from a template"); > this.editorId = editorId; > } > > public String getTemplatePath() { > if(this.useTemplateButton.getSelection()) { > if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >- Object first = ((IStructuredSelection)this.templateTableViewer >- .getSelection()).getFirstElement(); >+ Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); > if(first instanceof ModelTemplateDescription) { > return ((ModelTemplateDescription)first).getPath(); > } >@@ -86,8 +94,7 @@ > public String getTemplatePluginId() { > if(this.useTemplateButton.getSelection()) { > if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >- Object first = ((IStructuredSelection)this.templateTableViewer >- .getSelection()).getFirstElement(); >+ Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); > if(first instanceof ModelTemplateDescription) { > return ((ModelTemplateDescription)first).getPluginId(); > } >@@ -125,13 +132,11 @@ > templateTableViewer = new TableViewer(composite); > templateTableViewer.getTable().setLayoutData(data); > >- templateTableViewer >- .setContentProvider(new ModelTemplatesContentProvider()); >+ templateTableViewer.setContentProvider(new ModelTemplatesContentProvider()); > templateTableViewer.setLabelProvider(new ModelTemplatesLabelProvider()); > templateTableViewer.setInput(0); > if(templateTableViewer.getTable().getItemCount() > 0) { >- IStructuredSelection ss = new StructuredSelection( >- templateTableViewer.getElementAt(0)); >+ IStructuredSelection ss = new StructuredSelection(templateTableViewer.getElementAt(0)); > templateTableViewer.setSelection(ss); > } else { > useTemplateButton.setEnabled(false); >@@ -171,8 +176,98 @@ > > } > >- private class ModelTemplatesContentProvider implements >- IStructuredContentProvider { >+ public void initializeModelResource(final DiResourceSet diResourceSet, final IFile newFile, final String modelContentType, final String modelFileExtension) { >+ RecordingCommand command = new RecordingCommand(diResourceSet.getTransactionalEditingDomain()) { >+ >+ @Override >+ protected void doExecute() { >+ // Create Model Resource, Notation Resource, DI Resource >+ diResourceSet.createModelResources(newFile, modelContentType, modelFileExtension); >+ >+ // Initialize Model Resource >+ Resource modelResource = diResourceSet.getModelResource(); >+ if(modelResource != null) { >+ IPath path = new Path(newFile.getName()); >+ initializeModelResource(modelResource, path.removeFileExtension().toString()); >+ } >+ } >+ }; >+ diResourceSet.getTransactionalEditingDomain().getCommandStack().execute(command); >+ >+ } >+ >+ /** >+ * Initialize model resource. >+ * >+ * @param resource >+ * the resource >+ * @param rootElementName >+ * the root element name >+ */ >+ protected void initializeModelResource(Resource resource, String rootElementName) { >+ String templatePath = getTemplatePath(); >+ boolean initializeFromTemplate = templatePath != null; >+ if(initializeFromTemplate) { >+ initializeFromTemplate(resource, rootElementName, templatePath); >+ } else { >+ initializeEmptyModel(resource, rootElementName); >+ } >+ } >+ >+ /** >+ * Initialize from template. >+ * >+ * @param resource >+ * the resource >+ * @param rootElementName >+ * the root element name >+ * @param templatePath >+ * the template path >+ */ >+ protected void initializeFromTemplate(Resource resource, String rootElementName, String templatePath) { >+ Resource templateResource = loadTemplateResource(templatePath); >+ List<EObject> eObjectsToAdd = new ArrayList<EObject>(); >+ for(EObject eObject : templateResource.getContents()) { >+ eObjectsToAdd.add(EcoreUtil.copy(eObject)); >+ } >+ for(EObject eObject : eObjectsToAdd) { >+ resource.getContents().add(eObject); >+ } >+ } >+ >+ /** >+ * Initialize empty model. >+ * >+ * @param resource >+ * the resource >+ * @param rootElementName >+ * the root element name >+ */ >+ protected void initializeEmptyModel(Resource resource, String rootElementName) { >+ } >+ >+ /** >+ * Load template resource. >+ * >+ * @param templatePath >+ * the template path >+ * @return the resource >+ */ >+ private Resource loadTemplateResource(String templatePath) { >+ String templatePluginID = getTemplatePluginId(); >+ java.net.URL templateURL = Platform.getBundle(templatePluginID).getResource(templatePath); >+ String fullUri = templateURL.getPath(); >+ URI uri = URI.createPlatformPluginURI(templatePluginID + fullUri, true); >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ Resource resource = resourceSet.getResource(uri, true); >+ if(resource.isLoaded()) { >+ return resource; >+ } >+ return null; >+ } >+ >+ >+ private class ModelTemplatesContentProvider implements IStructuredContentProvider { > > private static final String extensionPointId = "org.eclipse.papyrus.wizards.templates"; > >@@ -189,8 +284,7 @@ > List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); > > IExtensionRegistry registry = Platform.getExtensionRegistry(); >- IExtension[] extensions = registry.getExtensionPoint( >- extensionPointId).getExtensions(); >+ IExtension[] extensions = registry.getExtensionPoint(extensionPointId).getExtensions(); > > for(IExtension extension : extensions) { > templates.addAll(processExtension(extension)); >@@ -199,15 +293,10 @@ > return templates.toArray(); > } > >- private Collection<ModelTemplateDescription> processExtension( >- IExtension extension) { >+ private Collection<ModelTemplateDescription> processExtension(IExtension extension) { > List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); >- for(IConfigurationElement configElement : extension >- .getConfigurationElements()) { >- templates.add(new ModelTemplateDescription(configElement >- .getAttribute(ATTRIBUTE_NAME), extension >- .getContributor().getName(), configElement >- .getAttribute(ATTRIBUTE_FILE))); >+ for(IConfigurationElement configElement : extension.getConfigurationElements()) { >+ templates.add(new ModelTemplateDescription(configElement.getAttribute(ATTRIBUTE_NAME), extension.getContributor().getName(), configElement.getAttribute(ATTRIBUTE_FILE))); > } > return templates; > } >@@ -233,8 +322,7 @@ > > private String pluginId; > >- public ModelTemplateDescription(String name, String pluginId, >- String path) { >+ public ModelTemplateDescription(String name, String pluginId, String path) { > super(); > this.name = name; > // this.e = metamodelURI; >@@ -283,8 +371,7 @@ > public String getColumnText(Object element, int columnIndex) { > if(element instanceof ModelTemplateDescription) { > ModelTemplateDescription modelTemplate = (ModelTemplateDescription)element; >- return modelTemplate.getName() + " (" >- + modelTemplate.getFileName() + ")"; >+ return modelTemplate.getName() + " (" + modelTemplate.getFileName() + ")"; > } > return null; > } >Index: src/org/eclipse/papyrus/wizards/SelectDiagramKindPage.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/SelectDiagramKindPage.java (revision 1714) >+++ src/org/eclipse/papyrus/wizards/SelectDiagramKindPage.java (working copy) >@@ -11,15 +11,20 @@ > *******************************************************************************/ > package org.eclipse.papyrus.wizards; > >+import java.io.IOException; > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.emf.ecore.EObject; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.papyrus.core.extension.NotFoundException; > import org.eclipse.papyrus.core.extension.commands.CreationCommandDescriptor; > import org.eclipse.papyrus.core.extension.commands.CreationCommandRegistry; > import org.eclipse.papyrus.core.extension.commands.ICreationCommand; > import org.eclipse.papyrus.core.extension.commands.ICreationCommandRegistry; >+import org.eclipse.papyrus.core.utils.DiResourceSet; >+import org.eclipse.papyrus.core.utils.EditorUtils; > import org.eclipse.papyrus.core.utils.PapyrusTrace; > import org.eclipse.swt.SWT; > import org.eclipse.swt.events.ModifyEvent; >@@ -73,14 +78,14 @@ > public ICreationCommand getCreationCommand() { > return creationCommand; > } >- >+ > public SelectDiagramKindPage(String pageName) { > super(pageName); > setPageComplete(false); > setTitle("Initialization information"); > setDescription("Select name and kind of the diagram"); > } >- >+ > /** > * {@inheritDoc} > */ >@@ -94,11 +99,11 @@ > > createNameForm(plate); > createDiagramKindForm(plate); >- >-// if(!myDiagramKindButtons.isEmpty()) { >-// Button defaultKind = myDiagramKindButtons.get(0); >-// setDefaultDiagramKind((String)defaultKind.getData()); >-// } >+ >+ // if(!myDiagramKindButtons.isEmpty()) { >+ // Button defaultKind = myDiagramKindButtons.get(0); >+ // setDefaultDiagramKind((String)defaultKind.getData()); >+ // } > setPageComplete(validatePage()); > > } >@@ -128,12 +133,12 @@ > button.setData(desc.getCommandId()); > myDiagramKindButtons.add(button); > } >- >+ > } >- >+ > private void setDefaultDiagramKind(String defaultKindCommandId) { > for(Button button : myDiagramKindButtons) { >- if (defaultKindCommandId != null && defaultKindCommandId.equals(button.getData())) { >+ if(defaultKindCommandId != null && defaultKindCommandId.equals(button.getData())) { > button.setSelection(true); > } else { > button.setSelection(false); >@@ -143,7 +148,7 @@ > } > > private void setDiagramCreationCommand(String commandId) { >- if (commandId == null) { >+ if(commandId == null) { > this.creationCommand = null; > return; > } >@@ -210,9 +215,30 @@ > setErrorMessage(message); > setPageComplete(message == null); > } >- >+ > protected boolean validatePage() { > return false == "".equals(getDiagramName()) && getCreationCommand() != null; > } >- >+ >+ public boolean createDiagram(DiResourceSet diResourceSet, EObject root) { >+ String diagramName = getDiagramName(); >+ ICreationCommand creationCommand = getCreationCommand(); >+ >+ if(creationCommand != null) { >+ creationCommand.createDiagram(diResourceSet, root, diagramName); >+ } else { >+ // Create an empty editor (no diagrams opened) >+ // Geting an IPageMngr is enough to initialize the >+ // SashSystem. >+ EditorUtils.getTransactionalIPageMngr(diResourceSet.getDiResource(), diResourceSet.getTransactionalEditingDomain()); >+ } >+ try { >+ diResourceSet.save(new NullProgressMonitor()); >+ } catch (IOException e) { >+ PapyrusTrace.log(e); >+ return false; >+ } >+ return true; >+ } >+ > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
sebastien.gerard
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 313179
:
168758
|
169501
|
169796
| 169962 |
169963
|
170771