Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2460] Separates the management of element creation from the referenc…
…e widget in specific services Bug: #2460 Signed-off-by: Florian ROUËNÉ <florian.rouene@obeosoft.com>
- Loading branch information
Showing
31 changed files
with
540 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
...components/collaborative/widget/reference/ReferenceWidgetDefaultCreateElementHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/******************************************************************************* | ||
* 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.collaborative.widget.reference; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
|
||
import org.eclipse.sirius.components.core.api.ChildCreationDescription; | ||
import org.eclipse.sirius.components.core.api.IEditService; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.widget.reference.IReferenceWidgetCreateElementHandler; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* * Default implementation of {@link IReferenceWidgetCreateElementHandler}. | ||
* * This implementation use {@link IEditService}. | ||
* | ||
* @author frouene | ||
*/ | ||
@Service | ||
public class ReferenceWidgetDefaultCreateElementHandler implements IReferenceWidgetCreateElementHandler { | ||
|
||
private final IEditService editService; | ||
|
||
public ReferenceWidgetDefaultCreateElementHandler(IEditService editService) { | ||
this.editService = Objects.requireNonNull(editService); | ||
} | ||
|
||
@Override | ||
public boolean canHandle(String descriptionId) { | ||
return false; // Default implementation, it'll be used if no other service can handle the descriptionId | ||
} | ||
|
||
@Override | ||
public List<ChildCreationDescription> getRootCreationDescriptions(IEditingContext editingContext, String domainId, String referenceKind, String descriptionId) { | ||
return this.editService.getRootCreationDescriptions(editingContext, domainId, false, referenceKind); | ||
} | ||
|
||
@Override | ||
public List<ChildCreationDescription> getChildCreationDescriptions(IEditingContext editingContext, String kind, String referenceKind, String descriptionId) { | ||
return this.editService.getChildCreationDescriptions(editingContext, kind, referenceKind); | ||
} | ||
|
||
@Override | ||
public Optional<Object> createRootObject(IEditingContext editingContext, UUID documentId, String domainId, String rootObjectCreationDescriptionId, String descriptionId) { | ||
return this.editService.createRootObject(editingContext, documentId, domainId, rootObjectCreationDescriptionId); | ||
} | ||
|
||
@Override | ||
public Optional<Object> createChild(IEditingContext editingContext, Object object, String childCreationDescriptionId, String descriptionId) { | ||
return this.editService.createChild(editingContext, object, childCreationDescriptionId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.