Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1946] Enable child extenders in the View DSL implementation #1957

Merged
merged 1 commit into from
May 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,20 @@ In the _styleDescription_, the definition of a color are now a select list of al

=== New Features

- https://github.com/eclipse-sirius/sirius-components/issues/1883[#1883] [sirius-web] Add the possibility to programmatically set some metadate such as specifics natures to a project.
- https://github.com/eclipse-sirius/sirius-components/issues/1883[#1883] [sirius-web] Add the possibility to programmatically set some metadata such as specifics natures to a project.
These natures can be used later to enable or not some capabilities on a project.
This work will start by adding the ability to filter the project's domains.
A large set of features will have to be updated in order to stop considering the list of metamodels available in an editing context as a certainty.
- https://github.com/eclipse-sirius/sirius-components/issues/1946[1#946] Enabled child extenders in the View DSL implementation.
This allows downstream projects and applications to provide their own sub-types of the DSL types (e.g. new WidgetDescriptions).
In addition to registering the extension metadmodel itself, users must provide a `ChildExtenderProvider` bean for their extensions to be properly integrated.

=== Improvements

- https://github.com/eclipse-sirius/sirius-components/issues/1869[#1869] [tree] Navigate to the first child with the right arrow if a node is expanded.
Navigate to the parent with the left arrow if a node is collapsed
- https://github.com/eclipse-sirius/sirius-components/issues/1621[#1621] [project] Migrate the onboard area to Material-UI


== v2023.4.0

=== Architectural decision records
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright (c) 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.components.emf.configuration;

import java.util.function.Supplier;

import org.eclipse.emf.edit.provider.IChildCreationExtender;

/**
* Used to extend EMF's global IChildCreationExtender.Descriptor.Registry with new IChildCreationExtender.
* Corresponds to the {@code org.eclipse.emf.edit.childCreationExtenders} extension point configuration.
*
* @author pcdavid
*/
public record ChildExtenderProvider(String nsURI, Supplier<IChildCreationExtender> childExtenderProvider) {
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2019, 2021 Obeo and others.
* Copyright (c) 2019, 2023 Obeo and others.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -12,28 +12,57 @@
*******************************************************************************/
package org.eclipse.sirius.components.emf.configuration;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;

import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.emf.ecore.impl.EPackageRegistryImpl;
import org.eclipse.emf.ecore.impl.EValidatorRegistryImpl;
import org.eclipse.emf.ecore.util.EcoreAdapterFactory;
import org.eclipse.emf.edit.EMFEditPlugin;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IChildCreationExtender.Descriptor;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.sirius.components.emf.services.ILabelFeatureProvider;
import org.eclipse.sirius.components.emf.services.LabelFeatureProviderRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import jakarta.annotation.PostConstruct;

/**
* Configuration of the EMF beans.
*
* @author sbegaudeau
*/
@Configuration
public class EMFConfiguration {
private final List<ChildExtenderProvider> childExtenderProviders;

public EMFConfiguration(List<ChildExtenderProvider> childExtenderProviders) {
this.childExtenderProviders = Objects.requireNonNull(childExtenderProviders);
}

@PostConstruct
public void initializeChildExtenders() {
var childExtenderRegistry = (IChildCreationExtender.Descriptor.Registry.Impl) EMFEditPlugin.getChildCreationExtenderDescriptorRegistry();
for (ChildExtenderProvider childExtenderProvider : this.childExtenderProviders) {
Collection<Descriptor> descriptors = childExtenderRegistry.get(childExtenderProvider.nsURI());
if (descriptors == null) {
descriptors = new ArrayList<>();
} else {
descriptors = new ArrayList<>(descriptors);
}
descriptors.add(childExtenderProvider.childExtenderProvider()::get);
childExtenderRegistry.put(childExtenderProvider.nsURI(), descriptors);
}
}

@Bean
public ComposedAdapterFactory composedAdapterFactory(List<AdapterFactory> adapterFactories) {
ComposedAdapterFactory composedAdapterFactory = new ComposedAdapterFactory(adapterFactories);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -142,7 +143,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -216,7 +217,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -165,7 +166,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -203,7 +204,7 @@ public String getCreateChildText(Object owner, Object feature, Object child, Col
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021, 2022 Obeo.
* Copyright (c) 2021, 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,6 +18,7 @@
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -118,7 +119,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -320,7 +321,7 @@ public String getCreateChildText(Object owner, Object feature, Object child, Col
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -194,7 +195,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright (c) 2021, 2022 Obeo.
* Copyright (c) 2021, 2023 Obeo.
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
Expand All @@ -18,6 +18,7 @@
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -118,7 +119,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -170,7 +171,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -163,7 +164,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -186,7 +187,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -139,7 +140,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -180,7 +181,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.provider.IChildCreationExtender;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
Expand Down Expand Up @@ -180,7 +181,7 @@ protected void collectNewChildDescriptors(Collection<Object> newChildDescriptors
*/
@Override
public ResourceLocator getResourceLocator() {
return ViewEditPlugin.INSTANCE;
return ((IChildCreationExtender) this.adapterFactory).getResourceLocator();
}

}