diff options
author | Maged Elaasar | 2018-03-17 00:06:14 +0000 |
---|---|---|
committer | ptessier | 2018-04-19 20:55:57 +0000 |
commit | 371756cd59fe03ac08e079a6a98b2b332da6ff92 (patch) | |
tree | c50ab6ebf82acaeaf37f372acba864a49a876a04 /plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org | |
parent | 9795d6a6d23ed40a5fe31b89c6868e9c407a5edb (diff) | |
download | org.eclipse.papyrus-371756cd59fe03ac08e079a6a98b2b332da6ff92.tar.gz org.eclipse.papyrus-371756cd59fe03ac08e079a6a98b2b332da6ff92.tar.xz org.eclipse.papyrus-371756cd59fe03ac08e079a6a98b2b332da6ff92.zip |
Bug 527664 - [AFViewpoints] Architecture Model Editor remove
CreationCommandClass property value
Converted the Creation/ConversionCommandClass properties in the
architecture editor to be of type string instead of Class. They can now
reference class names from the workspace (on their project's class
path). Also added validation rules for that. Finally, I added a
Browse... button in the property sheet to help put values for them.
remove some reexport
increase version to take in account API tool
Change-Id: I6792449fbee70b089f83780c4935242fff72d50b
Signed-off-by: Maged Elaasar <melaasar@gmail.com>
Diffstat (limited to 'plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org')
2 files changed, 156 insertions, 2 deletions
diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java index 48bbd71b8b7..5619788896a 100644 --- a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/ArchitectureEditor.java @@ -95,8 +95,8 @@ import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.papyrus.infra.core.architecture.provider.ArchitectureItemProviderAdapterFactory; import org.eclipse.papyrus.infra.architecture.representation.provider.RepresentationItemProviderAdapterFactory; +import org.eclipse.papyrus.infra.core.architecture.provider.ArchitectureItemProviderAdapterFactory; import org.eclipse.papyrus.infra.types.provider.ElementTypesConfigurationsItemProviderAdapterFactory; import org.eclipse.papyrus.infra.ui.architecture.ArchitectureUIPlugin; import org.eclipse.swt.SWT; @@ -1210,7 +1210,7 @@ public class ArchitectureEditor getActionBarContributor().shareGlobalActions(this, actionBars); } }; - propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); + propertySheetPage.setPropertySourceProvider(new CustomAdapterFactoryContentProvider(adapterFactory)); propertySheetPages.add(propertySheetPage); return propertySheetPage; diff --git a/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/CustomAdapterFactoryContentProvider.java b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/CustomAdapterFactoryContentProvider.java new file mode 100644 index 00000000000..380d9268f5d --- /dev/null +++ b/plugins/infra/ui/org.eclipse.papyrus.infra.ui.architecture/src/org/eclipse/papyrus/infra/ui/architecture/editor/CustomAdapterFactoryContentProvider.java @@ -0,0 +1,154 @@ +/***************************************************************************** + * Copyright (c) 2018 CEA LIST and others. + * + * 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: + * CEA LIST - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.infra.ui.architecture.editor; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EStructuralFeature; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.PropertyDescriptor; +import org.eclipse.emf.edit.ui.provider.PropertySource; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.core.IType; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jdt.core.search.IJavaSearchScope; +import org.eclipse.jdt.core.search.SearchEngine; +import org.eclipse.jdt.ui.IJavaElementSearchConstants; +import org.eclipse.jdt.ui.JavaUI; +import org.eclipse.jface.viewers.CellEditor; +import org.eclipse.jface.viewers.DialogCellEditor; +import org.eclipse.jface.window.Window; +import org.eclipse.papyrus.infra.gmfdiag.common.Activator; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.SelectionDialog; +import org.eclipse.ui.views.properties.IPropertyDescriptor; +import org.eclipse.ui.views.properties.IPropertySource; + +/** + * @author melaasar + * + */ +public class CustomAdapterFactoryContentProvider extends AdapterFactoryContentProvider { + + /** + * @param adapterFactory + */ + public CustomAdapterFactoryContentProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * @see org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource(java.lang.Object) + * + * @param object + * @return + */ + @Override + protected IPropertySource createPropertySource(Object object, + IItemPropertySource itemPropertySource) { + return new CustomPropertySource(object, itemPropertySource); + } + + /** + * A custom property source + */ + private class CustomPropertySource extends PropertySource { + /** + * Constructor. + * + * @param object + * @param itemPropertySource + */ + public CustomPropertySource(Object object, IItemPropertySource itemPropertySource) { + super(object, itemPropertySource); + } + + /* + * @see + * PropertySource#createPropertyDescriptor(org.eclipse.emf.edit .provider.IItemPropertyDescriptor) + */ + protected IPropertyDescriptor createPropertyDescriptor(IItemPropertyDescriptor itemPropertyDescriptor) { + return new CustomPropertyDescriptor(object, itemPropertyDescriptor); + } + } + + private class CustomPropertyDescriptor extends PropertyDescriptor { + + /** + * @param object + * @param itemPropertyDescriptor + */ + public CustomPropertyDescriptor(Object object, IItemPropertyDescriptor itemPropertyDescriptor) { + super(object, itemPropertyDescriptor); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.views.properties.IPropertyDescriptor#createPr opertyEditor(org.eclipse.swt.widgets.Composite) + */ + public CellEditor createPropertyEditor(Composite composite) { + final EObject eObject = (EObject) object; + final EStructuralFeature feature = (EStructuralFeature) itemPropertyDescriptor.getFeature(eObject); + if (feature.getName().endsWith("Class") || feature.getName().endsWith("class")) { + CellEditor cellEditor = new DialogCellEditor(composite) { + @Override + protected Object openDialogBox(Control cellEditorWindow) { + return selectTypeDialog(cellEditorWindow, eObject, feature); + } + }; + return cellEditor; + } + return super.createPropertyEditor(composite); + } + } + + public String selectTypeDialog(Control cellEditorWindow, EObject eObject, EStructuralFeature feature) { + URI uri = eObject.eResource().getURI(); + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IFile file = workspace.getRoot().getFile(new Path(uri.toPlatformString(false))); + IProject project = file.getProject(); + IJavaProject[] javaProject = new IJavaProject[] {JavaCore.create(project)}; + IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(javaProject); + + int scope = IJavaElementSearchConstants.CONSIDER_CLASSES; + String filter = (String) eObject.eGet(feature); + if (filter == null || filter.length() == 0) + filter = "**"; //$NON-NLS-1$ + + try { + SelectionDialog dialog = JavaUI.createTypeDialog(cellEditorWindow.getShell(), PlatformUI.getWorkbench().getProgressService(), searchScope, scope, false, filter); + dialog.setTitle("Select Class"); + if (dialog.open() == Window.OK) { + IType type = (IType) dialog.getResult()[0]; + return type.getFullyQualifiedName('$'); + } + } catch (JavaModelException e) { + Activator.log.error(e); + } + return null; + } +} |