forked from eclipse-syson/syson
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fix] Disable D&D of TreeItems inside Explorer view
Signed-off-by: Axel RICHARD <[email protected]>
- Loading branch information
1 parent
15d9e40
commit 8eb5eb9
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...nfiguration/src/main/java/org/eclipse/syson/application/explorer/DropTreeItemHandler.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,53 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 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.syson.application.explorer; | ||
|
||
import org.eclipse.sirius.components.collaborative.api.ChangeDescription; | ||
import org.eclipse.sirius.components.collaborative.trees.api.ITreeEventHandler; | ||
import org.eclipse.sirius.components.collaborative.trees.api.ITreeInput; | ||
import org.eclipse.sirius.components.collaborative.trees.dto.DropTreeItemInput; | ||
import org.eclipse.sirius.components.core.api.IEditingContext; | ||
import org.eclipse.sirius.components.core.api.IPayload; | ||
import org.eclipse.sirius.components.core.api.SuccessPayload; | ||
import org.eclipse.sirius.components.trees.Tree; | ||
import org.eclipse.sirius.components.trees.description.TreeDescription; | ||
import org.springframework.context.annotation.Primary; | ||
import org.springframework.core.Ordered; | ||
import org.springframework.core.annotation.Order; | ||
import org.springframework.stereotype.Service; | ||
|
||
import reactor.core.publisher.Sinks.Many; | ||
import reactor.core.publisher.Sinks.One; | ||
|
||
/** | ||
* Disable the D&D inside the Explorer view. Sirius Web now allows the D&D of tree items inside the Explorer view, but | ||
* the default behavior is not suitable for SysON. Indeed, when an Element is D&D, SysON should also D&D its Membership | ||
* container at the same time. | ||
* | ||
* @author arichard | ||
*/ | ||
@Service | ||
@Primary | ||
@Order(value = Ordered.HIGHEST_PRECEDENCE) | ||
public class DropTreeItemHandler implements ITreeEventHandler { | ||
|
||
@Override | ||
public boolean canHandle(ITreeInput treeInput) { | ||
return treeInput instanceof DropTreeItemInput; | ||
} | ||
|
||
@Override | ||
public void handle(One<IPayload> payloadSink, Many<ChangeDescription> changeDescriptionSink, IEditingContext editingContext, TreeDescription treeDescription, Tree tree, ITreeInput treeInput) { | ||
payloadSink.tryEmitValue(new SuccessPayload(treeInput.id())); | ||
} | ||
} |