diff --git a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/LSPUtil.xtend b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/LSPUtil.xtend index b69faaf60..4e1a17154 100644 --- a/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/LSPUtil.xtend +++ b/plugins/de.cau.cs.kieler.klighd.lsp/src/de/cau/cs/kieler/klighd/lsp/LSPUtil.xtend @@ -18,6 +18,7 @@ package de.cau.cs.kieler.klighd.lsp import com.google.common.html.HtmlEscapers import de.cau.cs.kieler.klighd.ViewContext +import de.cau.cs.kieler.klighd.kgraph.KEdge import de.cau.cs.kieler.klighd.kgraph.KNode /** @@ -64,6 +65,26 @@ class LSPUtil { } } + /** + * Get a {@code KEdge} based by id. + * + * @param diagramState The state of the diagram + * @param uri The uri of the model file + * @param edgeId The id of the edge element + * @return the {@code KEdge} of the edge described by {@code id}. + * Returns null if the {@code ViewContext} of the resource described by {@code uri} is null. + * Returns null if the element behind the id is no kEdge. + */ + static def getKEdge(KGraphDiagramState diagramState, String uri, String nodeId) { + val kGraphElement = diagramState.getIdToKGraphMap(uri).get(nodeId) + + if (kGraphElement instanceof KEdge) { + return kGraphElement as KEdge + } else { + return null + } + } + /** * Escapes the given message to be safely displayable in a client context putting this message into an HTML page * to avoid possibilities of XSS attacks and a clearly readable message. Uses Google Guava's {@link HtmlEscapers} diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/InputType.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/InputType.java new file mode 100644 index 000000000..e76e028f1 --- /dev/null +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/InputType.java @@ -0,0 +1,33 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2024 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package de.cau.cs.kieler.klighd.structurebasedediting; + +/** + * Data class for structured editing input type. + */ +public class InputType { + String field; + String type; + String label; + + public InputType(String field, String type, String label) { + this.field = field; + this.type = type; + this.label = label; + } + +} \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingMessage.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingMessage.java new file mode 100644 index 000000000..498e70513 --- /dev/null +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingMessage.java @@ -0,0 +1,35 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2024 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package de.cau.cs.kieler.klighd.structurebasedediting; + +/** + * Data class for structure editing message to be send from client to server. + */ +public class StructureBasedEditingMessage { + + String label; + String kind; + Boolean mergable; + InputType[] inputs; + + public StructureBasedEditingMessage(String label, String kind, Boolean mergable, InputType[] inputs) { + this.label = label; + this.kind = kind; + this.mergable = mergable; + this.inputs = inputs; + } +} diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingOptions.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingOptions.java new file mode 100644 index 000000000..8ec19e454 --- /dev/null +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/structurebasedediting/StructureBasedEditingOptions.java @@ -0,0 +1,32 @@ +/* + * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient + * + * http://rtsys.informatik.uni-kiel.de/kieler + * + * Copyright 2024 by + * + Kiel University + * + Department of Computer Science + * + Real-Time and Embedded Systems Group + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * SPDX-License-Identifier: EPL-2.0 + */ +package de.cau.cs.kieler.klighd.structurebasedediting; + +import java.util.Map; + +import de.cau.cs.kieler.klighd.filtering.SemanticFilterTag; + +/** + * Property that holds the information about support structured editing messages and what elements support which message. + */ +public class StructureBasedEditingOptions { + Map options; + + public StructureBasedEditingOptions(Map map) { + options = map; + } +} \ No newline at end of file diff --git a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdProperties.java b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdProperties.java index fb3d6d5c6..c968e3a35 100644 --- a/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdProperties.java +++ b/plugins/de.cau.cs.kieler.klighd/src/de/cau/cs/kieler/klighd/util/KlighdProperties.java @@ -35,6 +35,7 @@ import de.cau.cs.kieler.klighd.kgraph.KNode; import de.cau.cs.kieler.klighd.krendering.KText; import de.cau.cs.kieler.klighd.microlayout.Bounds; +import de.cau.cs.kieler.klighd.structurebasedediting.StructureBasedEditingOptions; /** * A collection of KLighD-specific {@link IProperty IProperties} @@ -381,6 +382,20 @@ public static boolean isSelectable(final EObject viewElement) { public static final IProperty IS_NODE_TITLE = new Property("klighd.isNodeTitle", false); + /** + * Property holding the structured editing options which are supported for a certain language. + * By default no support is given. + */ + public static final IProperty STRUCTURED_EDITING = + new Property("klighd.StructuralEditingOptions", null); + + /** + * Property determining if the contextmenu should be rendered on the client. Since the contextmenu is only suported + * for certain languages it makes sense to keep track only on the server to show it + */ + public static final IProperty SHOW_STRUCTURED_EDITING_MENU = + new Property("klighd.showContextmenu", true); + /** * Property determining whether this node should be rendered as a proxy. */