Skip to content

Commit

Permalink
Added structure-based editing stuf (not tested).
Browse files Browse the repository at this point in the history
  • Loading branch information
soerendomroes committed Mar 12, 2024
1 parent 7fd0f67 commit 20c1bcc
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -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<SemanticFilterTag, StructureBasedEditingMessage[]> options;

public StructureBasedEditingOptions(Map<SemanticFilterTag, StructureBasedEditingMessage[]> map) {
options = map;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -381,6 +382,20 @@ public static boolean isSelectable(final EObject viewElement) {
public static final IProperty<Boolean> IS_NODE_TITLE =
new Property<Boolean>("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<StructureBasedEditingOptions> STRUCTURED_EDITING =
new Property<StructureBasedEditingOptions>("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<Boolean> SHOW_STRUCTURED_EDITING_MENU =
new Property<Boolean>("klighd.showContextmenu", true);

/**
* Property determining whether this node should be rendered as a proxy.
*/
Expand Down

0 comments on commit 20c1bcc

Please sign in to comment.