Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add structure based editing for SCCharts #107

Draft
wants to merge 51 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
396cd18
interactive: regions must not be moveable
Drakae Oct 21, 2020
5bf7e73
interactive: default value of interactive layout is true for regions
Drakae Oct 30, 2020
8898d6a
Initial commit, just testing for now
May 23, 2022
b728d56
SCCharts synthesis can now support the proxy-view API
May 31, 2022
bf538f0
Added a type check
May 31, 2022
c132cb7
Made proxy-renderings non-square
Jun 6, 2022
b5368a9
Made proxies even less intrusive & centered labels
Jun 6, 2022
b2eb2d0
Added a max label length
fight4day Jun 12, 2022
8ffddec
Removed TODOs
fight4day Jun 12, 2022
10552f6
Property name changes
fight4day Jun 25, 2022
215dc4c
Preparation for semantic filtering
fight4day Jun 30, 2022
f423fc7
Added several semantic filters
fight4day Jun 30, 2022
0247b62
Removed some comments
fight4day Jul 1, 2022
4e55503
Added a new tag, the corresponding rule is still TODO
fight4day Jul 1, 2022
e4c4d09
Fixed AT_LEAST_3_DECLARATIONS rule
fight4day Jul 2, 2022
eb4eec8
Added some rules that test the util class
fight4day Jul 4, 2022
220ee24
Rename
fight4day Jul 4, 2022
00284c2
Merge remote-tracking branch 'origin/master' into tik/proxy-view
fight4day Jul 5, 2022
6e0100a
mka code review first change
fight4day Jul 6, 2022
6381522
Assume run-config as unchanged
fight4day Jul 6, 2022
0950d48
Most of the code review
fight4day Jul 6, 2022
889fee5
Code review
fight4day Jul 20, 2022
29e4f87
Merge branch 'master' into jet/scccharts
soerendomroes Oct 13, 2022
87f8c16
Added SCTX constraint serializer.
soerendomroes Oct 20, 2022
6737be3
scharts.ide: Added interactive node id provider for SCTX.
soerendomroes Oct 21, 2022
697e3b9
scharts.ide.interactive: Remove NodeIdProvider service interface.
soerendomroes Oct 24, 2022
f7bf8dc
scharts.ide/ui: Documentation, setting interactive layout in synthesis
soerendomroes Nov 7, 2022
c746ab7
Add MrTree lS extension and configuration.
soerendomroes Nov 8, 2022
9eb7cc2
Added Mrtree so supported ls extensions.
soerendomroes Nov 11, 2022
53287ae
Trivial rules fixed
fight4day Aug 2, 2022
fda6cea
Tested semantic filtering v2
fight4day Aug 2, 2022
429ac73
Beautification
fight4day Aug 29, 2022
d110656
Implemented an SCGraph specific proxy-rendering
fight4day Sep 12, 2022
891bafb
Merge branch 'master' into nre/tik-merge2
NiklasRentzCAU Mar 2, 2023
7204d36
sccharts.ui: removed example code for semantic filtering.
NiklasRentzCAU Mar 3, 2023
5fc246c
extract common values and methods to ProxyStyles class
Eddykasp Mar 6, 2023
cf2419c
use proxystyles defined values
Eddykasp Mar 6, 2023
7f74b0e
refactoring
Eddykasp Mar 6, 2023
24b0934
refactoring
Eddykasp Mar 6, 2023
941c4a4
sccharts.ui: removed some code duplication/unneeded code.
NiklasRentzCAU Mar 7, 2023
7b89469
rename filters
Eddykasp Mar 15, 2023
378e35f
sccharts.ui: removed layout calculation of proxies in the synthesis.
NiklasRentzCAU Apr 25, 2023
b350366
changed the semantic filter rules to be consistent with their
Eddykasp Sep 12, 2023
635ca6a
clearer labels for semantic filter rules
Eddykasp Sep 12, 2023
76dc47b
set sensible default values for semantic filters
Eddykasp Sep 12, 2023
fd5104b
Change semantic filter rules to align with client-side interpretation
Eddykasp Sep 13, 2023
55e047b
Merge remote-tracking branch 'origin/interactiveSCCharts' into sdo/in…
soerendomroes Mar 7, 2024
eea62ab
Merge origin/master into sdo/interactiveMrTree.
soerendomroes Mar 7, 2024
110e5e3
Fixed SCTX Serializer.
soerendomroes Mar 7, 2024
ebff309
Merge remote-tracking branch 'origin/nre/tik-merge2' into
soerendomroes Mar 12, 2024
b34cebb
Added structure based editing for SCCharts (not tested).
soerendomroes Mar 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.cau.cs.kieler.language.server.sccharts.structurebasedediting.SCChartsStructureBasedEditingActionHandler
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.cau.cs.kieler.language.server.sccharts.SCTXConstraintSerializer
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
de.cau.cs.kieler.language.server.registration.RegistrationLanguageServerContribution
de.cau.cs.kieler.language.server.kicool.KiCoolLanguageServerContribution
de.cau.cs.kieler.language.server.simulation.SimulationLanguageServerContribution
de.cau.cs.kieler.language.server.verification.VerificationLanguageServerContribution
de.cau.cs.kieler.language.server.verification.VerificationLanguageServerContribution
de.cau.cs.kieler.language.server.sccharts.structurebasedediting.SCChartsStructeBasedEditingLanguageServerContribution
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
de.cau.cs.kieler.sccharts.ui.synthesis.hooks.StructuralEditingHook
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package de.cau.cs.kieler.language.server
import de.cau.cs.kieler.core.services.KielerServiceLoader
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient
import de.cau.cs.kieler.klighd.lsp.interactive.layered.LayeredInteractiveLanguageServerExtension
import de.cau.cs.kieler.klighd.lsp.interactive.mrtree.MrTreeInteractiveLanguageServerExtension
import de.cau.cs.kieler.klighd.lsp.interactive.rectpacking.RectpackingInteractiveLanguageServerExtension
import de.cau.cs.kieler.klighd.lsp.launch.AbstractLsCreator
import java.util.List
Expand All @@ -32,14 +33,17 @@ class LSCreator extends AbstractLsCreator {

RectpackingInteractiveLanguageServerExtension rectPack

MrTreeInteractiveLanguageServerExtension mrTree

List<ILSDiagramHighlighter> diagramHighlighters

List<ILanguageServerExtension> iLanguageServerExtensions

override getLanguageServerExtensions() {
constraints = injector.getInstance(LayeredInteractiveLanguageServerExtension)
rectPack = injector.getInstance(RectpackingInteractiveLanguageServerExtension)
iLanguageServerExtensions = newArrayList(constraints, rectPack)
mrTree = injector.getInstance(MrTreeInteractiveLanguageServerExtension)
iLanguageServerExtensions = newArrayList(constraints, rectPack, mrTree)
for (lse : KielerServiceLoader.load(ILanguageServerContribution)) {
iLanguageServerExtensions.add(lse.getLanguageServerExtension(injector))
}
Expand All @@ -60,6 +64,7 @@ class LSCreator extends AbstractLsCreator {
}
constraints.client = languageClient as KGraphLanguageClient
rectPack.client = languageClient as KGraphLanguageClient
mrTree.client = languageClient as KGraphLanguageClient
diagramHighlighters = newArrayList
for (iLSdhc : KielerServiceLoader.load(ILSDiagramHighlighterContribution)) {
var highlighter = iLSdhc.getHighlighter(injector)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* KIELER - Kiel Integrated Environment for Layout Eclipse RichClient
*
* http://rtsys.informatik.uni-kiel.de/kieler
*
* Copyright 2022 by
* + Kiel University
* + Department of Computer Science
* + Real-Time and Embedded Systems Group
*
* This code is provided under the terms of the Eclipse Public License (EPL).
*/
package de.cau.cs.kieler.language.server.sccharts

import de.cau.cs.kieler.annotations.Annotatable
import de.cau.cs.kieler.annotations.AnnotationsFactory
import de.cau.cs.kieler.annotations.TypedStringAnnotation
import de.cau.cs.kieler.klighd.internal.util.KlighdInternalProperties
import de.cau.cs.kieler.klighd.kgraph.KNode
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageClient
import de.cau.cs.kieler.klighd.lsp.KGraphLanguageServerExtension
import de.cau.cs.kieler.klighd.lsp.interactive.ConstraintProperty
import de.cau.cs.kieler.klighd.lsp.interactive.IConstraintSerializer
import de.cau.cs.kieler.sccharts.impl.StateImpl
import java.io.ByteArrayOutputStream
import java.util.List
import java.util.Map
import org.eclipse.elk.graph.properties.IProperty
import org.eclipse.lsp4j.Position
import org.eclipse.lsp4j.Range
import org.eclipse.lsp4j.TextEdit

/**
* Serialize a constraint for an SCChart node (region or state) as a layout annotation.
*
* @author sdo
*
*/
class SCTXConstraintSerializer implements IConstraintSerializer {

override canHandle(Object graph) {
return graph instanceof StateImpl
}

override serializeConstraints(List<ConstraintProperty<Object>> changedNodes, Object graph, String uri,
KGraphLanguageServerExtension ls, KGraphLanguageClient client) {
// Serialize model into given uri.
val resource = ls.getResource(uri)

// Get previous file content as String
var outputStream = new ByteArrayOutputStream
resource.save(outputStream, emptyMap)
val codeBefore = outputStream.toString
val Map<String, List<TextEdit>> changes = newHashMap
changedNodes.forEach[c|
val Annotatable anno = c.KNode.getProperty(KlighdInternalProperties.MODEL_ELEMENT) as Annotatable
copyConstraintAnnotations(anno, c.KNode, c.property.id, c.property)
]
// Get changed file as String
outputStream = new ByteArrayOutputStream
resource.save(outputStream, emptyMap)
val String codeAfter = outputStream.toString().trim

// The range is the length of the previous file.
// Just make sure the range is big enough
val Range range = new Range(new Position(0, 0), new Position(codeBefore.split("\r\n|\r|\n").length * 2, 0))
val TextEdit textEdit = new TextEdit(range, codeAfter)
changes.put(uri, #[textEdit]);
client.replaceContentInFile(uri, codeAfter, range)
}

/**
* Copies an arbitrary IProperty of a KNode to a State if the value on the KNode
* is different to the value on the State.
* If the new value on the KNode was the default value of the property
* then the property is set to null on the State.
*
* @param state The target state.
* @param kNode The source KNode of the property.
* @param annotation The annotation that should be set.
* @param property Determines which IProperty should be copied.
*/
static def <T> copyConstraintAnnotations(Annotatable state, KNode kNode, String annotation, IProperty<T> property) {
val String value = "" + kNode.getProperty(property)

val annotations = state.getAnnotations().filter(TypedStringAnnotation)

// Remove old annotation if it exists.
var TypedStringAnnotation annotationToRemove = null
for (a : annotations) {
if (a.type.equals(annotation)) {
annotationToRemove = a
}
}
if (annotationToRemove !== null) {
state.annotations.remove(annotationToRemove)
}

// Add annotation with new value if the value is not the default one.
if (kNode.getProperty(property) !== null && !kNode.getProperty(property).equals(property.^default)) {
var newA = AnnotationsFactory::eINSTANCE.createTypedStringAnnotation => [
it.name = "layout"
it.type = annotation
it.values += value
]
state.annotations.add(newA)
}

}

}
Loading
Loading