Search in sources :

Example 1 with IDeleteTreeItemHandler

use of org.eclipse.sirius.web.services.explorer.api.IDeleteTreeItemHandler in project sirius-web by eclipse-sirius.

the class ExplorerDescriptionProvider method getDeleteHandler.

private IStatus getDeleteHandler(VariableManager variableManager) {
    var optionalEditingContext = variableManager.get(IEditingContext.EDITING_CONTEXT, IEditingContext.class);
    var optionalTreeItem = variableManager.get(TreeItem.SELECTED_TREE_ITEM, TreeItem.class);
    if (optionalEditingContext.isPresent() && optionalTreeItem.isPresent()) {
        IEditingContext editingContext = optionalEditingContext.get();
        TreeItem treeItem = optionalTreeItem.get();
        // @formatter:off
        var optionalHandler = this.deleteTreeItemHandlers.stream().filter(handler -> handler.canHandle(editingContext, treeItem)).findFirst();
        if (optionalHandler.isPresent()) {
            IDeleteTreeItemHandler deleteTreeItemHandler = optionalHandler.get();
            return deleteTreeItemHandler.handle(editingContext, treeItem);
        }
    }
    // $NON-NLS-1$
    return new Failure("");
}
Also used : IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) DocumentMetadataAdapter(org.eclipse.sirius.web.services.documents.DocumentMetadataAdapter) IObjectService(org.eclipse.sirius.components.core.api.IObjectService) IRenameTreeItemHandler(org.eclipse.sirius.web.services.explorer.api.IRenameTreeItemHandler) IKindParser(org.eclipse.sirius.components.core.api.IKindParser) TreeRenderer(org.eclipse.sirius.components.trees.renderer.TreeRenderer) ArrayList(java.util.ArrayList) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) IExplorerDescriptionProvider(org.eclipse.sirius.components.collaborative.trees.api.IExplorerDescriptionProvider) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) IStatus(org.eclipse.sirius.components.representations.IStatus) IDeleteTreeItemHandler(org.eclipse.sirius.web.services.explorer.api.IDeleteTreeItemHandler) Service(org.springframework.stereotype.Service) RepresentationMetadata(org.eclipse.sirius.components.core.RepresentationMetadata) TreeDescription(org.eclipse.sirius.components.trees.description.TreeDescription) SemanticKindConstants(org.eclipse.sirius.components.core.api.SemanticKindConstants) Failure(org.eclipse.sirius.components.representations.Failure) Predicate(java.util.function.Predicate) EObject(org.eclipse.emf.ecore.EObject) TreeItem(org.eclipse.sirius.components.trees.TreeItem) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) IRepresentationService(org.eclipse.sirius.web.services.api.representations.IRepresentationService) Objects(java.util.Objects) List(java.util.List) GetOrCreateRandomIdProvider(org.eclipse.sirius.components.representations.GetOrCreateRandomIdProvider) Resource(org.eclipse.emf.ecore.resource.Resource) ImageConstants(org.eclipse.sirius.components.compatibility.services.ImageConstants) Optional(java.util.Optional) VariableManager(org.eclipse.sirius.components.representations.VariableManager) IRepresentationImageProvider(org.eclipse.sirius.components.collaborative.api.IRepresentationImageProvider) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) TreeItem(org.eclipse.sirius.components.trees.TreeItem) IDeleteTreeItemHandler(org.eclipse.sirius.web.services.explorer.api.IDeleteTreeItemHandler) Failure(org.eclipse.sirius.components.representations.Failure)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 UUID (java.util.UUID)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 EObject (org.eclipse.emf.ecore.EObject)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)1 IRepresentationImageProvider (org.eclipse.sirius.components.collaborative.api.IRepresentationImageProvider)1 IExplorerDescriptionProvider (org.eclipse.sirius.components.collaborative.trees.api.IExplorerDescriptionProvider)1 ImageConstants (org.eclipse.sirius.components.compatibility.services.ImageConstants)1 RepresentationMetadata (org.eclipse.sirius.components.core.RepresentationMetadata)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 IKindParser (org.eclipse.sirius.components.core.api.IKindParser)1 IObjectService (org.eclipse.sirius.components.core.api.IObjectService)1 SemanticKindConstants (org.eclipse.sirius.components.core.api.SemanticKindConstants)1 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)1 Failure (org.eclipse.sirius.components.representations.Failure)1