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 168758 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]
Initial patch
313179 (text/plain), 8.17 KB, created by
Tatiana Fesenko
on 2010-05-17 12:10:18 EDT
(
hide
)
Description:
Initial patch
Filename:
MIME Type:
Creator:
Tatiana Fesenko
Created:
2010-05-17 12:10:18 EDT
Size:
8.17 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.papyrus.diagram.common >Index: src/org/eclipse/papyrus/diagram/common/wizards/NewPapyrusProjectWizard.java >=================================================================== >--- src/org/eclipse/papyrus/diagram/common/wizards/NewPapyrusProjectWizard.java (revision 1621) >+++ src/org/eclipse/papyrus/diagram/common/wizards/NewPapyrusProjectWizard.java (working copy) >@@ -50,14 +50,11 @@ > > private SelectDiagramKindPage myDiagramKindPage; > >- private IStructuredSelection selection; >- > private String initialProjectName; > > public void init(IWorkbench workbench, IStructuredSelection selection) { > super.init(workbench, selection); > setWindowTitle("New Papyrus Project"); >- this.selection = selection; > } > > public void addPages() { >@@ -89,12 +86,12 @@ > } > // if the user wants to create a diagram > if (myDiagramKindPage.getCreationCommand() != null) { >- return createDiagram(); >+ return createPapyrusModel(); > } > return true; > } > >- private boolean createDiagram() { >+ private boolean createPapyrusModel() { > final DiResourceSet diResourceSet = new DiResourceSet(); > try { > // create a new file, result != null if successful >Index: src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java >=================================================================== >--- src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java (revision 1622) >+++ src/org/eclipse/papyrus/diagram/common/wizards/CreateUMLModelWizard.java (working copy) >@@ -22,11 +22,11 @@ > import org.eclipse.uml2.uml.UMLPackage; > > public class CreateUMLModelWizard extends CreateModelWizard { >- >+ > public CreateUMLModelWizard() { > super(); > } >- >+ > public CreateUMLModelWizard(URI domainModelURI) { > super(domainModelURI); > } >@@ -37,33 +37,28 @@ > */ > // @unused > public static final String ID_UMLWIZARD = "org.eclipse.papyrus.wizards.createumlmodel"; >- /** >- * The config element which declares this wizard. >- */ >- private IConfigurationElement configElement; >+ >+ /** >+ * The config element which declares this wizard. >+ */ >+ private IConfigurationElement configElement; >+ > >- > > @Override > protected String getModelContentType() { > return UMLPackage.eCONTENT_TYPE; > } >- >+ > @Override > protected String getModelFileExtension() { > return "uml"; > } > >- @Override >- protected void initializeModelResource(Resource resource, String rootElementName) { >- // fjcano #293135 :: support model templates >- if(!isInitializeFromTemplate()) { >- Model model = UMLFactory.eINSTANCE.createModel(); >- model.setName(rootElementName); >- resource.getContents().add(model); >- } else { >- super.initializeModelResource(resource, rootElementName); >- } >+ protected void initializeEmptyModel(Resource resource, String rootElementName, String templatePath) { >+ 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 1622) >+++ src/org/eclipse/papyrus/wizards/CreateModelWizard.java (working copy) >@@ -155,7 +155,6 @@ > try { > // create a new file, result != null if successful > final IFile newFile = newModelFilePage.createNewFile(); >- NewModelFilePage.fileCount++; > > RecordingCommand command = new RecordingCommand(diResourceSet.getTransactionalEditingDomain()) { > >@@ -197,12 +196,8 @@ > // SashSystem. > EditorUtils.getTransactionalIPageMngr(diResourceSet.getDiResource(), diResourceSet.getTransactionalEditingDomain()); > } else { >- // Create requested diagram. >- if(domainModelURI != null) { >- creationCommand.createDiagram(diResourceSet, selectRootElementPage.getModelElement(), diagramName); >- } else { >- creationCommand.createDiagram(diResourceSet, null, diagramName); >- } >+ EObject root = domainModelURI != null ? selectRootElementPage.getModelElement() : null; >+ creationCommand.createDiagram(diResourceSet, root, diagramName); > } > try { > diResourceSet.save(new NullProgressMonitor()); >@@ -231,47 +226,41 @@ > protected abstract String getModelFileExtension(); > > // fjcano #293135 :: support model templates >- protected void initializeModelResource(Resource resource, String rootElementName) { >- if(isInitializeFromTemplate()) { >- Resource templateResource = loadTemplateResource(); >- 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 void initializeModelResource(Resource resource, String rootElementName) { >+ String templatePath = selectTemplateWizardPage.getTemplatePath(); >+ boolean initializeFromTemplate = templatePath != null; >+ if(initializeFromTemplate) { >+ initializeFromTemplate(resource, rootElementName, templatePath); > } else { >- // nothing >- return; >+ initializeEmptyModel(resource, rootElementName); > } > } >- >- // fjcano #293135 :: support model templates >- protected boolean isInitializeFromTemplate() { >- return getTemplatePath() != null; >+ >+ 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); >+ } > } >- >- // fjcano #293135 :: support model templates >- protected String getTemplatePath() { >- String templatePath = selectTemplateWizardPage.getTemplatePath(); >- return templatePath; >+ protected void initializeEmptyModel(Resource resource, String rootElementName) { > } > >- // fjcano #293135 :: support model templates >- protected Resource loadTemplateResource() { >+ private Resource loadTemplateResource(String templatePath) { > String templatePluginID = selectTemplateWizardPage.getTemplatePluginId(); >- String templatePath = getTemplatePath(); > java.net.URL templateURL = Platform.getBundle(templatePluginID).getResource(templatePath); >- if(templatePath != null) { >- 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; >- } >+ 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; > } >+ >+ > } >Index: src/org/eclipse/papyrus/wizards/NewModelFilePage.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/NewModelFilePage.java (revision 1613) >+++ src/org/eclipse/papyrus/wizards/NewModelFilePage.java (working copy) >@@ -10,6 +10,7 @@ > *******************************************************************************/ > package org.eclipse.papyrus.wizards; > >+import org.eclipse.core.resources.IFile; > import org.eclipse.jface.viewers.IStructuredSelection; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.ui.IWorkbench; >@@ -23,7 +24,7 @@ > public class NewModelFilePage extends WizardNewFileCreationPage { > > /** index for several file creation */ >- protected static int fileCount = 1; >+ private static int fileCount = 1; > > protected boolean createFromSemanticModel; > >@@ -89,6 +90,13 @@ > // return false; > return true; > } >+ >+ @Override >+ public IFile createNewFile() { >+ IFile created = super.createNewFile(); >+ fileCount++; >+ return created; >+ } > > /** > * {@inheritDoc}
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