-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
211: Revise TypeHints and server side feedback for creation actions
- Add a new parameter to EdgeTypeHint, 'dynamic', indicating that new edges need to check with the server before allowing creation - Add a new Request/Response to implement this check
- Loading branch information
1 parent
a48db75
commit 7b1a160
Showing
6 changed files
with
177 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
....eclipse.glsp.server/src/org/eclipse/glsp/server/actions/CheckEdgeTargetResultAction.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,40 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.glsp.server.actions; | ||
|
||
/** | ||
* {@link ResponseAction} for a {@link RequestCheckEdgeTargetAction}. | ||
*/ | ||
public class CheckEdgeTargetResultAction extends ResponseAction { | ||
|
||
public static final String KIND = "setTargetTypeHints"; | ||
|
||
private boolean isValid; | ||
|
||
public CheckEdgeTargetResultAction() { | ||
this(false); | ||
} | ||
|
||
public CheckEdgeTargetResultAction(final boolean isValid) { | ||
super(KIND); | ||
this.setValid(isValid); | ||
} | ||
|
||
public boolean isValid() { return isValid; } | ||
|
||
public void setValid(final boolean isValid) { this.isValid = isValid; } | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
...eclipse.glsp.server/src/org/eclipse/glsp/server/actions/RequestCheckEdgeTargetAction.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,69 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.glsp.server.actions; | ||
|
||
import org.eclipse.glsp.server.types.EdgeTypeHint; | ||
|
||
/** | ||
* A {@link RequestAction} used to check the validity of an edge being created. This is used | ||
* to update creation feedback on the client side, for edges configured with a dynamic {@link EdgeTypeHint}. | ||
* | ||
* @see EdgeTypeHint#isDynamic() | ||
* @see CheckEdgeTargetResultAction | ||
*/ | ||
public class RequestCheckEdgeTargetAction extends RequestAction<CheckEdgeTargetResultAction> { | ||
|
||
public static final String KIND = "requestCheckEdgeTarget"; | ||
|
||
private String edgeTypeId; | ||
|
||
private String sourceElementId; | ||
|
||
private String targetElementId; | ||
|
||
public RequestCheckEdgeTargetAction() { | ||
super(KIND); | ||
} | ||
|
||
/** | ||
* The element type id of the Edge. | ||
* | ||
* @return | ||
* the element type id of the Edge. | ||
*/ | ||
public String getEdgeTypeId() { return edgeTypeId; } | ||
|
||
public void setEdgeTypeId(final String edgeTypeId) { this.edgeTypeId = edgeTypeId; } | ||
|
||
/** | ||
* The ID of the source element of the edge being created. | ||
* | ||
* @return the ID of the source element of the edge being created. | ||
*/ | ||
public String getSourceElementId() { return sourceElementId; } | ||
|
||
public void setSourceElementId(final String sourceElementId) { this.sourceElementId = sourceElementId; } | ||
|
||
/** | ||
* The ID of the target element of the edge being created. | ||
* | ||
* @return the ID of the target element of the edge being created. | ||
*/ | ||
public String getTargetElementId() { return targetElementId; } | ||
|
||
public void setTargetElementId(final String targetElementId) { this.targetElementId = targetElementId; } | ||
|
||
} |
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
43 changes: 43 additions & 0 deletions
43
...erver/src/org/eclipse/glsp/server/diagram/DefaultRequestTargetTypeHintsActionHandler.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,43 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2023 EclipseSource and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* https://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.glsp.server.diagram; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.glsp.server.actions.AbstractActionHandler; | ||
import org.eclipse.glsp.server.actions.Action; | ||
import org.eclipse.glsp.server.actions.CheckEdgeTargetResultAction; | ||
import org.eclipse.glsp.server.actions.RequestCheckEdgeTargetAction; | ||
|
||
import com.google.inject.Inject; | ||
|
||
/** | ||
* Default handler implementation for {@link RequestCheckEdgeTargetAction}. | ||
* This handler always rejects creation of dynamic Edges. Client applications | ||
* should replace this default implementation with their own logic to | ||
* conditionally accept creation of new edges configured with a Dynamic type. | ||
*/ | ||
public class DefaultRequestTargetTypeHintsActionHandler extends AbstractActionHandler<RequestCheckEdgeTargetAction> { | ||
|
||
@Inject | ||
protected DiagramConfiguration diagramConfiguration; | ||
|
||
@Override | ||
protected List<Action> executeAction(final RequestCheckEdgeTargetAction actualAction) { | ||
return List.of(new CheckEdgeTargetResultAction()); | ||
} | ||
|
||
} |
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