Skip to content

Commit

Permalink
#406 Update to Theia 1.18.0 and switch to Codicons
Browse files Browse the repository at this point in the history
- Replace FontAwesome icons with codicons
- Fix validation of task node label
   - It is not possible to edit the name in this example, only the label text, therefore this validation rule could never return a result.

Fixes eclipse-glsp/glsp/issues/406
  • Loading branch information
ndoschek authored and planger committed Oct 19, 2021
1 parent 54bb925 commit 0a51fc6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,19 @@
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.eclipse.glsp.example.workflow.wfgraph.ActivityNode;
import org.eclipse.glsp.example.workflow.wfgraph.TaskNode;
import org.eclipse.glsp.graph.GCompartment;
import org.eclipse.glsp.graph.GEdge;
import org.eclipse.glsp.graph.GLabel;
import org.eclipse.glsp.graph.GModelElement;
import org.eclipse.glsp.server.features.validation.Marker;
import org.eclipse.glsp.server.features.validation.MarkerKind;
import org.eclipse.glsp.server.features.validation.ModelValidator;
import org.eclipse.glsp.server.model.GModelState;
import org.eclipse.glsp.server.utils.GModelUtil;

public class WorkflowModelValidator implements ModelValidator {

Expand Down Expand Up @@ -57,7 +61,7 @@ public List<Marker> validate(final GModelState modelState, final GModelElement..
private static List<Marker> validateTaskNode(final GModelState modelState, final GModelElement taskNode) {
List<Marker> markers = new ArrayList<>();
validateTaskNode_isAutomated(modelState, taskNode).ifPresent(m -> markers.add(m));
validateTaskNode_nameStartsUpperCase(modelState, taskNode).ifPresent(m -> markers.add(m));
validateTaskNode_labelStartsUpperCase(modelState, taskNode).ifPresent(m -> markers.add(m));
return markers;
}

Expand All @@ -73,11 +77,15 @@ private static Optional<Marker> validateTaskNode_isAutomated(final GModelState m
}

@SuppressWarnings("checkstyle:MethodName")
private static Optional<Marker> validateTaskNode_nameStartsUpperCase(final GModelState modelState,
private static Optional<Marker> validateTaskNode_labelStartsUpperCase(final GModelState modelState,
final GModelElement element) {
TaskNode taskNode = (TaskNode) element;
if (!Character.isUpperCase(taskNode.getName().charAt(0))) {
return Optional.of(new Marker("Task node name in upper case",
List<GCompartment> gCompartment = GModelUtil.filterByType(taskNode.getChildren(), GCompartment.class)
.collect(Collectors.toList());
List<GLabel> gLabels = GModelUtil.filterByType(gCompartment.get(0).getChildren(), GLabel.class)
.collect(Collectors.toList());
if (gLabels.size() > 0 && !Character.isUpperCase(gLabels.get(0).getText().charAt(0))) {
return Optional.of(new Marker("Task node label in upper case",
"Task node names should start with upper case letters", element.getId(), MarkerKind.WARNING));
}
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ public List<PaletteItem> getItems(final Map<String, String> args, final GModelSt
counter = 0;
List<PaletteItem> nodes = createPaletteItems(handlers, CreateNodeOperation.class);
List<PaletteItem> edges = createPaletteItems(handlers, CreateEdgeOperation.class);
return Lists.newArrayList(PaletteItem.createPaletteGroup("node-group", "Nodes", nodes, "fa-hammer", "A"),
PaletteItem.createPaletteGroup("edge-group", "Edges", edges, "fa-hammer", "B"));
return Lists.newArrayList(
PaletteItem.createPaletteGroup("node-group", "Nodes", nodes, "symbol-property", "A"),
PaletteItem.createPaletteGroup("edge-group", "Edges", edges, "symbol-property", "B"));

}

Expand Down

0 comments on commit 0a51fc6

Please sign in to comment.