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 170771 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]
Refactor SelectTemplateWizardPage
313179 (text/plain), 28.44 KB, created by
Tatiana Fesenko
on 2010-06-02 06:29:56 EDT
(
hide
)
Description:
Refactor SelectTemplateWizardPage
Filename:
MIME Type:
Creator:
Tatiana Fesenko
Created:
2010-06-02 06:29:56 EDT
Size:
28.44 KB
patch
obsolete
>Index: src/org/eclipse/papyrus/wizards/template/ModelTemplateDescription.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/template/ModelTemplateDescription.java (revision 0) >+++ src/org/eclipse/papyrus/wizards/template/ModelTemplateDescription.java (revision 0) >@@ -0,0 +1,109 @@ >+/***************************************************************************** >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.wizards.template; >+ >+/** >+ * The Class ModelTemplateDescription. >+ */ >+public class ModelTemplateDescription { >+ >+ /** The name. */ >+ private String name; >+ >+ // private String metamodelURI; >+ /** The path. */ >+ private String path; >+ >+ /** The plugin id. */ >+ private String pluginId; >+ >+ /** The language. */ >+ private String language; >+ >+ /** >+ * Instantiates a new model template description. >+ * >+ * @param name the name >+ * @param pluginId the plugin id >+ * @param path the path >+ */ >+ public ModelTemplateDescription(String name, String pluginId, String path) { >+ super(); >+ this.name = name; >+ // this.e = metamodelURI; >+ this.path = path; >+ this.pluginId = pluginId; >+ } >+ >+ /** >+ * Sets the language. >+ * >+ * @param language the new language >+ */ >+ public void setLanguage(String language) { >+ this.language = language; >+ } >+ >+ /** >+ * Gets the name. >+ * >+ * @return the name >+ */ >+ public String getName() { >+ return name; >+ } >+ >+ // /** >+ // * @return the metamodelURI >+ // */ >+ // public String getMetamodelURI() { >+ // return metamodelURI; >+ // } >+ >+ /** >+ * @return the path >+ */ >+ public String getPath() { >+ return path; >+ } >+ >+ /** >+ * Gets the file name. >+ * >+ * @return the file name >+ */ >+ public String getFileName() { >+ String[] pathParts = path.split("/"); >+ return pathParts[pathParts.length - 1]; >+ } >+ >+ /** >+ * Gets the plugin id. >+ * >+ * @return the plugin id >+ */ >+ public String getPluginId() { >+ return pluginId; >+ } >+ >+ /** >+ * Gets the language. >+ * >+ * @return the language >+ */ >+ public String getLanguage() { >+ return language; >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/papyrus/wizards/template/ModelTemplatesContentProvider.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/template/ModelTemplatesContentProvider.java (revision 0) >+++ src/org/eclipse/papyrus/wizards/template/ModelTemplatesContentProvider.java (revision 0) >@@ -0,0 +1,121 @@ >+/***************************************************************************** >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.wizards.template; >+ >+import java.util.ArrayList; >+import java.util.Collection; >+import java.util.List; >+ >+import org.eclipse.core.runtime.IConfigurationElement; >+import org.eclipse.core.runtime.IExtension; >+import org.eclipse.core.runtime.IExtensionRegistry; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.jface.viewers.IStructuredContentProvider; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.jface.viewers.Viewer; >+ >+/** >+ * The Class ModelTemplatesContentProvider. >+ */ >+public class ModelTemplatesContentProvider implements IStructuredContentProvider { >+ >+ /** The Constant EXTENSION_POINT_ID. */ >+ private static final String EXTENSION_POINT_ID = "org.eclipse.papyrus.wizards.templates"; >+ >+ /** The Constant ATTRIBUTE_NAME. */ >+ private static final String ATTRIBUTE_NAME = "name"; >+ >+ /** The Constant ATTRIBUTE_FILE. */ >+ private static final String ATTRIBUTE_FILE = "file"; >+ >+ /** The Constant ATTRIBUTE_LANGUAGE. */ >+ private static final String ATTRIBUTE_LANGUAGE = "language"; >+ >+ /** >+ * @see org.eclipse.jface.viewers.IContentProvider#dispose() >+ * >+ */ >+ public void dispose() { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ /** >+ * Gets the templates description. >+ * >+ * @return the templates description >+ */ >+ private ModelTemplateDescription[] getTemplatesDescription() { >+ List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); >+ >+ IExtensionRegistry registry = Platform.getExtensionRegistry(); >+ IExtension[] extensions = registry.getExtensionPoint(EXTENSION_POINT_ID).getExtensions(); >+ >+ for(IExtension extension : extensions) { >+ templates.addAll(processExtension(extension)); >+ } >+ >+ return templates.toArray(new ModelTemplateDescription[templates.size()]); >+ } >+ >+ /** >+ * Process extension. >+ * >+ * @param extension the extension >+ * @return the collection >+ */ >+ private Collection<ModelTemplateDescription> processExtension(IExtension extension) { >+ List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); >+ for(IConfigurationElement configElement : extension.getConfigurationElements()) { >+ ModelTemplateDescription template = new ModelTemplateDescription(configElement.getAttribute(ATTRIBUTE_NAME), extension.getContributor().getName(), configElement.getAttribute(ATTRIBUTE_FILE)); >+ template.setLanguage(configElement.getAttribute(ATTRIBUTE_LANGUAGE)); >+ templates.add(template); >+ } >+ return templates; >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) >+ * >+ * @param inputElement >+ * @return >+ */ >+ public Object[] getElements(Object inputElement) { >+ if(inputElement instanceof String) { >+ List<ModelTemplateDescription> result = new ArrayList<ModelTemplateDescription>(); >+ String diagramCategory = (String)inputElement; >+ for(ModelTemplateDescription template : getTemplatesDescription()) { >+ if(diagramCategory == null || diagramCategory.equals(template.getLanguage())) { >+ result.add(template); >+ } >+ } >+ return result.toArray(); >+ } >+ return new Object[0]; >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) >+ * >+ * @param viewer >+ * @param oldInput >+ * @param newInput >+ */ >+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >+ if(viewer instanceof TableViewer) { >+ ((TableViewer)viewer).add(getElements(null)); >+ } >+ } >+ >+} >\ No newline at end of file >Index: src/org/eclipse/papyrus/wizards/template/ModelTemplatesLabelProvider.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/template/ModelTemplatesLabelProvider.java (revision 0) >+++ src/org/eclipse/papyrus/wizards/template/ModelTemplatesLabelProvider.java (revision 0) >@@ -0,0 +1,89 @@ >+/***************************************************************************** >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.wizards.template; >+ >+import org.eclipse.jface.viewers.ILabelProviderListener; >+import org.eclipse.jface.viewers.ITableLabelProvider; >+import org.eclipse.swt.graphics.Image; >+ >+/** >+ * The Class ModelTemplatesLabelProvider. >+ */ >+public class ModelTemplatesLabelProvider implements ITableLabelProvider { >+ >+ /** >+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) >+ * >+ * @param element >+ * @param columnIndex >+ * @return >+ */ >+ public Image getColumnImage(Object element, int columnIndex) { >+ return null; >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) >+ * >+ * @param element >+ * @param columnIndex >+ * @return >+ */ >+ public String getColumnText(Object element, int columnIndex) { >+ if(element instanceof ModelTemplateDescription) { >+ ModelTemplateDescription modelTemplate = (ModelTemplateDescription)element; >+ return modelTemplate.getName() + " (" + modelTemplate.getFileName() + ")"; >+ } >+ return null; >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ * >+ * @param listener >+ */ >+ public void addListener(ILabelProviderListener listener) { >+ >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() >+ * >+ */ >+ public void dispose() { >+ >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String) >+ * >+ * @param element >+ * @param property >+ * @return >+ */ >+ public boolean isLabelProperty(Object element, String property) { >+ >+ return false; >+ } >+ >+ /** >+ * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener) >+ * >+ * @param listener >+ */ >+ public void removeListener(ILabelProviderListener listener) { >+ >+ } >+ >+} >Index: src/org/eclipse/papyrus/wizards/template/SelectModelTemplateComposite.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/template/SelectModelTemplateComposite.java (revision 0) >+++ src/org/eclipse/papyrus/wizards/template/SelectModelTemplateComposite.java (revision 0) >@@ -0,0 +1,178 @@ >+/***************************************************************************** >+ * Copyright (c) 2010 CEA LIST. >+ * >+ * >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * Tatiana Fesenko (CEA LIST) - Initial API and implementation >+ * >+ *****************************************************************************/ >+package org.eclipse.papyrus.wizards.template; >+ >+import org.eclipse.jface.viewers.IStructuredSelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.viewers.TableViewer; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.SelectionEvent; >+import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.layout.GridData; >+import org.eclipse.swt.layout.GridLayout; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Composite; >+import org.eclipse.swt.widgets.Group; >+ >+ >+/** >+ * The Class SelectModelTemplateComposite. >+ */ >+public class SelectModelTemplateComposite extends Composite { >+ >+ /** The new model button. */ >+ private Button newModelButton; >+ >+ /** The template table viewer. */ >+ private TableViewer templateTableViewer; >+ >+ /** The use template button. */ >+ private Button useTemplateButton; >+ >+ /** >+ * Instantiates a new select model template composite. >+ * >+ * @param parent the parent >+ */ >+ public SelectModelTemplateComposite(Composite parent) { >+ super(parent, SWT.NONE); >+ setLayout(new GridLayout()); >+ >+ Group composite = new Group(this, 0); >+ composite.setText("Creation approach"); >+ >+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >+ GridLayout gridLayout = new GridLayout(1, false); >+ gridLayout.marginWidth = 20; >+ gridLayout.marginTop = 10; >+ gridLayout.verticalSpacing = 10; >+ composite.setLayout(gridLayout); >+ createDialogArea(composite); >+ } >+ >+ /** >+ * Creates the dialog area. >+ * >+ * @param composite the composite >+ */ >+ private void createDialogArea(Composite composite) { >+ createApproachSelectionButtons(composite); >+ createTemplatesViewer(composite); >+ } >+ >+ /** >+ * Creates the templates viewer. >+ * >+ * @param composite the composite >+ */ >+ private void createTemplatesViewer(Composite composite) { >+ GridData data = new GridData(GridData.FILL_BOTH); >+ templateTableViewer = new TableViewer(composite); >+ templateTableViewer.getTable().setLayoutData(data); >+ >+ templateTableViewer.setContentProvider(new ModelTemplatesContentProvider()); >+ templateTableViewer.setLabelProvider(new ModelTemplatesLabelProvider()); >+ if(templateTableViewer.getTable().getItemCount() > 0) { >+ IStructuredSelection ss = new StructuredSelection(templateTableViewer.getElementAt(0)); >+ templateTableViewer.setSelection(ss); >+ } else { >+ useTemplateButton.setEnabled(true); >+ } >+ templateTableViewer.getControl().setEnabled(false); >+ } >+ >+ /** >+ * Creates the approach selection buttons. >+ * >+ * @param composite the composite >+ */ >+ private void createApproachSelectionButtons(Composite composite) { >+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ newModelButton = new Button(composite, SWT.RADIO); >+ newModelButton.setText("Create new model"); >+ newModelButton.setLayoutData(data); >+ newModelButton.setSelection(true); >+ >+ data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >+ useTemplateButton = new Button(composite, SWT.RADIO); >+ useTemplateButton.setText("Initialize from template"); >+ useTemplateButton.setLayoutData(data); >+ useTemplateButton.setSelection(false); >+ >+ useTemplateButton.addSelectionListener(new SelectionListener() { >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // TODO Auto-generated method stub >+ >+ } >+ >+ public void widgetSelected(SelectionEvent e) { >+ if(useTemplateButton.getSelection()) { >+ templateTableViewer.getControl().setEnabled(true); >+ } else { >+ templateTableViewer.getControl().setEnabled(false); >+ } >+ } >+ >+ }); >+ >+ } >+ >+ /** >+ * Gets the template path. >+ * >+ * @return the template path >+ */ >+ public String getTemplatePath() { >+ if(this.useTemplateButton.getSelection()) { >+ if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >+ Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); >+ if(first instanceof ModelTemplateDescription) { >+ return ((ModelTemplateDescription)first).getPath(); >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Gets the template plugin id. >+ * >+ * @return the template plugin id >+ */ >+ public String getTemplatePluginId() { >+ if(this.useTemplateButton.getSelection()) { >+ if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >+ Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); >+ if(first instanceof ModelTemplateDescription) { >+ return ((ModelTemplateDescription)first).getPluginId(); >+ } >+ } >+ } >+ >+ return null; >+ } >+ >+ /** >+ * Sets the input. >+ * >+ * @param input the new input >+ */ >+ public void setInput(Object input) { >+ templateTableViewer.setInput(input); >+ } >+ >+} >+ >Index: src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java >=================================================================== >--- src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java (revision 1772) >+++ src/org/eclipse/papyrus/wizards/SelectTemplateWizardPage.java (working copy) >@@ -13,13 +13,9 @@ > package org.eclipse.papyrus.wizards; > > import java.util.ArrayList; >-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; >@@ -30,13 +26,6 @@ > 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; >-import org.eclipse.jface.viewers.ITableLabelProvider; >-import org.eclipse.jface.viewers.StructuredSelection; >-import org.eclipse.jface.viewers.TableViewer; >-import org.eclipse.jface.viewers.Viewer; > import org.eclipse.jface.wizard.IWizardPage; > import org.eclipse.jface.wizard.WizardPage; > import org.eclipse.papyrus.core.utils.DiResourceSet; >@@ -44,15 +33,8 @@ > import org.eclipse.papyrus.resource.notation.NotationModel; > import org.eclipse.papyrus.resource.sasheditor.DiModel; > import org.eclipse.papyrus.resource.uml.UmlModel; >-import org.eclipse.swt.SWT; >-import org.eclipse.swt.events.SelectionEvent; >-import org.eclipse.swt.events.SelectionListener; >-import org.eclipse.swt.graphics.Image; >-import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.layout.GridLayout; >-import org.eclipse.swt.widgets.Button; >+import org.eclipse.papyrus.wizards.template.SelectModelTemplateComposite; > import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Group; > > /** > * A wizard page that allows the selection of template models contributed via an >@@ -64,55 +46,41 @@ > */ > public class SelectTemplateWizardPage extends WizardPage { > >- private Button newModelButton; >- >- private Button useTemplateButton; >- >- private TableViewer templateTableViewer; >- >- private String editorId; >+ /** The select template composite. */ >+ private SelectModelTemplateComposite selectTemplateComposite; > >+ /** >+ * Instantiates a new select template wizard page. >+ * >+ * @param pageName the page name >+ */ > protected SelectTemplateWizardPage(String pageName) { > super(pageName); >- // TODO Auto-generated constructor stub > } > >+ /** >+ * Instantiates a new select template wizard page. >+ * >+ * @param editorId the editor id >+ * @param nextPage the next page >+ * @param templatePage the template page >+ */ > 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.editorId = editorId; > } > >- public String getTemplatePath() { >- if(this.useTemplateButton.getSelection()) { >- if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >- Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); >- if(first instanceof ModelTemplateDescription) { >- return ((ModelTemplateDescription)first).getPath(); >- } >- } >- } >- >- return null; >- } >- >- public String getTemplatePluginId() { >- if(this.useTemplateButton.getSelection()) { >- if(this.templateTableViewer.getSelection() instanceof IStructuredSelection) { >- Object first = ((IStructuredSelection)this.templateTableViewer.getSelection()).getFirstElement(); >- if(first instanceof ModelTemplateDescription) { >- return ((ModelTemplateDescription)first).getPluginId(); >- } >- } >- } > >- return null; >- } >+ /** >+ * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean) >+ * >+ * @param visible >+ */ > @Override > public void setVisible(boolean visible) { > super.setVisible(visible); >- templateTableViewer.setInput(getDiagramCategory()); >+ selectTemplateComposite.setInput(getDiagramCategory()); > } > > /** >@@ -128,77 +96,26 @@ > return ((SelectDiagramCategoryPage)previousPage).getDiagramCategory(); > } > >+ /** >+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) >+ * >+ * @param parent >+ */ > public void createControl(Composite parent) { >- Composite root = new Composite(parent, SWT.NONE); >- GridLayout gridLayout = new GridLayout(); >- root.setLayout(gridLayout); >- Group composite = new Group(root, 0); >- composite.setText("Creation approach"); >- >- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- gridLayout = new GridLayout(1, false); >- gridLayout.marginWidth = 20; >- gridLayout.marginTop = 10; >- gridLayout.verticalSpacing = 10; >- composite.setLayout(gridLayout); >- createDialogArea(composite); >- >- setControl(root); >- } >- >- private void createDialogArea(Composite composite) { >- createApproachSelectionButtons(composite); >- createTemplatesViewer(composite); >- } >- >- private void createTemplatesViewer(Composite composite) { >- GridData data = new GridData(GridData.FILL_BOTH); >- templateTableViewer = new TableViewer(composite); >- templateTableViewer.getTable().setLayoutData(data); >- >- templateTableViewer.setContentProvider(new ModelTemplatesContentProvider()); >- templateTableViewer.setLabelProvider(new ModelTemplatesLabelProvider()); >- if(templateTableViewer.getTable().getItemCount() > 0) { >- IStructuredSelection ss = new StructuredSelection(templateTableViewer.getElementAt(0)); >- templateTableViewer.setSelection(ss); >- } else { >- useTemplateButton.setEnabled(false); >- } >- templateTableViewer.getControl().setEnabled(false); >+ selectTemplateComposite = new SelectModelTemplateComposite(parent); >+ setControl(selectTemplateComposite); > } > >- private void createApproachSelectionButtons(Composite composite) { >- GridData data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- newModelButton = new Button(composite, SWT.RADIO); >- newModelButton.setText("Create new model"); >- newModelButton.setLayoutData(data); >- newModelButton.setSelection(true); >- >- data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); >- useTemplateButton = new Button(composite, SWT.RADIO); >- useTemplateButton.setText("Initialize from template"); >- useTemplateButton.setLayoutData(data); >- useTemplateButton.setSelection(false); >- >- useTemplateButton.addSelectionListener(new SelectionListener() { >- >- public void widgetDefaultSelected(SelectionEvent e) { >- // TODO Auto-generated method stub >- >- } > >- public void widgetSelected(SelectionEvent e) { >- if(useTemplateButton.getSelection()) { >- templateTableViewer.getControl().setEnabled(true); >- } else { >- templateTableViewer.getControl().setEnabled(false); >- } >- } >- >- }); >- >- } >- >+ /** >+ * Initialize model resource. >+ * >+ * @param diResourceSet the di resource set >+ * @param newFile the new file >+ * @param root the root >+ * @param modelContentType the model content type >+ * @param modelFileExtension the model file extension >+ */ > public void initializeModelResource(final DiResourceSet diResourceSet, final IFile newFile, final EObject root, final String modelContentType, final String modelFileExtension) { > RecordingCommand command = new RecordingCommand(diResourceSet.getTransactionalEditingDomain()) { > >@@ -258,7 +175,7 @@ > * the root element name > */ > protected void initializeModelResource(Resource resource, String rootElementName) { >- String templatePath = getTemplatePath(); >+ String templatePath = selectTemplateComposite.getTemplatePath(); > boolean initializeFromTemplate = templatePath != null; > if(initializeFromTemplate) { > initializeFromTemplate(resource, rootElementName, templatePath); >@@ -307,7 +224,7 @@ > * @return the resource > */ > private Resource loadTemplateResource(String templatePath) { >- String templatePluginID = getTemplatePluginId(); >+ String templatePluginID = selectTemplateComposite.getTemplatePluginId(); > java.net.URL templateURL = Platform.getBundle(templatePluginID).getResource(templatePath); > String fullUri = templateURL.getPath(); > URI uri = URI.createPlatformPluginURI(templatePluginID + fullUri, true); >@@ -319,157 +236,4 @@ > return null; > } > >- >- private class ModelTemplatesContentProvider implements IStructuredContentProvider { >- >- private static final String extensionPointId = "org.eclipse.papyrus.wizards.templates"; >- >- private static final String ATTRIBUTE_NAME = "name"; >- >- private static final String ATTRIBUTE_FILE = "file"; >- >- private static final String ATTRIBUTE_LANGUAGE = "language"; >- >- public void dispose() { >- // TODO Auto-generated method stub >- >- } >- >- private ModelTemplateDescription[] getTemplatesDescription() { >- List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); >- >- IExtensionRegistry registry = Platform.getExtensionRegistry(); >- IExtension[] extensions = registry.getExtensionPoint(extensionPointId).getExtensions(); >- >- for(IExtension extension : extensions) { >- templates.addAll(processExtension(extension)); >- } >- >- return templates.toArray(new ModelTemplateDescription[templates.size()]); >- } >- >- private Collection<ModelTemplateDescription> processExtension(IExtension extension) { >- List<ModelTemplateDescription> templates = new ArrayList<ModelTemplateDescription>(); >- for(IConfigurationElement configElement : extension.getConfigurationElements()) { >- ModelTemplateDescription template = new ModelTemplateDescription(configElement.getAttribute(ATTRIBUTE_NAME), extension.getContributor().getName(), configElement.getAttribute(ATTRIBUTE_FILE)); >- template.setLanguage(configElement.getAttribute(ATTRIBUTE_LANGUAGE)); >- templates.add(template); >- } >- return templates; >- } >- >- public Object[] getElements(Object inputElement) { >- if(inputElement instanceof String) { >- List<ModelTemplateDescription> result = new ArrayList<ModelTemplateDescription>(); >- String diagramCategory = (String)inputElement; >- for(ModelTemplateDescription template : getTemplatesDescription()) { >- if(diagramCategory == null || diagramCategory.equals(template.getLanguage())) { >- result.add(template); >- } >- } >- return result.toArray(); >- } >- return new Object[0]; >- } >- >- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { >- if(viewer instanceof TableViewer) { >- ((TableViewer)viewer).add(getElements(null)); >- } >- } >- >- } >- >- private class ModelTemplateDescription { >- >- private String name; >- >- // private String metamodelURI; >- private String path; >- >- private String pluginId; >- >- private String language; >- >- public ModelTemplateDescription(String name, String pluginId, String path) { >- super(); >- this.name = name; >- // this.e = metamodelURI; >- this.path = path; >- this.pluginId = pluginId; >- } >- >- public void setLanguage(String language) { >- this.language = language; >- } >- >- /** >- * @return the name >- */ >- public String getName() { >- return name; >- } >- >- // /** >- // * @return the metamodelURI >- // */ >- // public String getMetamodelURI() { >- // return metamodelURI; >- // } >- >- /** >- * @return the path >- */ >- public String getPath() { >- return path; >- } >- >- public String getFileName() { >- String[] pathParts = path.split("/"); >- return pathParts[pathParts.length - 1]; >- } >- >- public String getPluginId() { >- return pluginId; >- } >- >- public String getLanguage() { >- return language; >- } >- >- } >- >- private class ModelTemplatesLabelProvider implements ITableLabelProvider { >- >- public Image getColumnImage(Object element, int columnIndex) { >- return null; >- } >- >- public String getColumnText(Object element, int columnIndex) { >- if(element instanceof ModelTemplateDescription) { >- ModelTemplateDescription modelTemplate = (ModelTemplateDescription)element; >- return modelTemplate.getName() + " (" + modelTemplate.getFileName() + ")"; >- } >- return null; >- } >- >- public void addListener(ILabelProviderListener listener) { >- >- } >- >- public void dispose() { >- >- } >- >- public boolean isLabelProperty(Object element, String property) { >- >- return false; >- } >- >- public void removeListener(ILabelProviderListener listener) { >- >- } >- >- } >- > }
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