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 242317 Details for
Bug 432986
Several Diagram specific concepts are no more proposed in the VSM editor.
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.
NewChildDescriptorTest.java
NewChildDescriptorTest.java (text/x-java), 4.89 KB, created by
Pierre-Charles David
on 2014-04-25 05:31:42 EDT
(
hide
)
Description:
NewChildDescriptorTest.java
Filename:
MIME Type:
Creator:
Pierre-Charles David
Created:
2014-04-25 05:31:42 EDT
Size:
4.89 KB
patch
obsolete
>/******************************************************************************* > * Copyright (c) 2014 Obeo. > * 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: > * Obeo - initial API and implementation > *******************************************************************************/ >package org.eclipse.sirius.temp; > >import java.util.Collection; >import java.util.Set; > >import org.eclipse.emf.common.notify.AdapterFactory; >import org.eclipse.emf.ecore.EClass; >import org.eclipse.emf.ecore.EObject; >import org.eclipse.emf.ecore.EPackage; >import org.eclipse.emf.ecore.util.EcoreUtil; >import org.eclipse.emf.edit.command.CommandParameter; >import org.eclipse.emf.edit.provider.ComposedAdapterFactory; >import org.eclipse.emf.edit.provider.ComposedAdapterFactory.Descriptor; >import org.eclipse.emf.edit.provider.ComposedAdapterFactory.Descriptor.Registry; >import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; >import org.eclipse.sirius.viewpoint.description.DescriptionPackage; >import org.junit.Test; > >import com.google.common.base.Function; >import com.google.common.collect.HashMultimap; >import com.google.common.collect.ImmutableSet; >import com.google.common.collect.Iterables; >import com.google.common.collect.Lists; >import com.google.common.collect.Multimap; >import com.google.common.collect.Ordering; > >/** > * Outputs a sorted list of all the "newChildDescriptors" available for all > * Sirius types available in a VSM editor. Implemented as a JUnit test to be run > * as a "JUnit Plug-in Test" to be sure it is executed in the correct runtime > * context (with all the various extension points and registries correctly > * setup). > * > * @author pcdavid > */ >public class NewChildDescriptorTest { > @Test > public void printChildDescriptors() { > Collection<EPackage> packages = withDescendants(Lists.newArrayList(DescriptionPackage.eINSTANCE, /*org.eclipse.sirius.diagram.description.DescriptionPackage.eINSTANCE,*/ > org.eclipse.sirius.diagram.sequence.description.DescriptionPackage.eINSTANCE, org.eclipse.sirius.table.metamodel.table.description.DescriptionPackage.eINSTANCE, > org.eclipse.sirius.tree.description.DescriptionPackage.eINSTANCE)); > > Multimap<EClass, EClass> result = HashMultimap.create(); > Registry registry = ComposedAdapterFactory.Descriptor.Registry.INSTANCE; > for (EPackage pkg : packages) { > Descriptor descriptor = registry.getDescriptor(Lists.newArrayList(pkg, IEditingDomainItemProvider.class)); > if (descriptor != null) { > AdapterFactory factory = descriptor.createAdapterFactory(); > for (EClass klass : Iterables.filter(pkg.getEClassifiers(), EClass.class)) { > if (!klass.isAbstract() && !klass.isInterface()) { > EObject instance = EcoreUtil.create(klass); > IEditingDomainItemProvider provider = (IEditingDomainItemProvider) factory.adapt(instance, IEditingDomainItemProvider.class); > Collection<?> descriptors = provider.getNewChildDescriptors(instance, null, null); > for (CommandParameter param : Iterables.filter(descriptors, CommandParameter.class)) { > result.put(klass, ((EObject) param.getValue()).eClass()); > } > } > } > } > } > System.out.println(format(result)); > } > > private Set<EPackage> withDescendants(Iterable<EPackage> roots) { > Collection<EPackage> result = Lists.newArrayList(); > for (EPackage root : roots) { > result.add(root); > result.addAll(withDescendants(root.getESubpackages())); > } > return ImmutableSet.copyOf(result); > } > > private String fqn(EClass klass) { > return qualify(klass.getName(), klass.getEPackage()); > } > > private String qualify(String name, EPackage pkg) { > if (pkg == null) { > return name; > } else { > return qualify(pkg.getName() + "." + name, pkg.getESuperPackage()); > } > } > > private String format(Multimap<EClass, EClass> result) { > Function<EClass, String> qname = new Function<EClass, String>() { > @Override > public String apply(EClass klass) { > return fqn(klass); > } > }; > StringBuilder sb = new StringBuilder(); > Ordering<EClass> ordering = Ordering.natural().onResultOf(qname); > for (EClass k : ordering.sortedCopy(result.keys())) { > sb.append(fqn(k)).append(":\n"); > for (EClass child : ordering.sortedCopy(result.get(k))) { > sb.append(" - ").append(fqn(child)).append("\n"); > } > } > return sb.toString(); > } > >}
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 Raw
Actions:
View
Attachments on
bug 432986
:
242317
|
242318
|
242319
|
242320
|
242321
|
242476
|
242477
|
242478
|
242493
|
242494
|
242495
|
242496
|
242497