Skip to content

Commit 8ea5065

Browse files
authored
Merge branch 'main' into feature/finished/IIA-1586-Pattern-border-highlight
2 parents 217e2a4 + 00d9225 commit 8ea5065

9 files changed

Lines changed: 366 additions & 20 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package dev.ikm.komet.kview.events;
2+
3+
import dev.ikm.komet.framework.events.Evt;
4+
import dev.ikm.komet.framework.events.EvtType;
5+
import dev.ikm.komet.framework.view.ViewProperties;
6+
import dev.ikm.tinkar.common.id.PublicId;
7+
8+
public class AddStampEvent extends Evt {
9+
public AddStampEvent(Object source, EvtType eventType) {
10+
super(source, eventType);
11+
}
12+
}

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/details/DetailsController.java

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@
5555
import dev.ikm.tinkar.terms.TinkarTerm;
5656
import javafx.application.Platform;
5757
import javafx.beans.InvalidationListener;
58+
import javafx.beans.property.BooleanProperty;
5859
import javafx.beans.property.ObjectProperty;
60+
import javafx.beans.property.SimpleBooleanProperty;
5961
import javafx.collections.ObservableList;
6062
import javafx.css.PseudoClass;
6163
import javafx.event.ActionEvent;
@@ -174,9 +176,6 @@ public class DetailsController {
174176
@FXML
175177
private Label pathLabel;
176178

177-
@FXML
178-
private Label originationLabel;
179-
180179
@FXML
181180
private Label statusLabel;
182181

@@ -322,7 +321,7 @@ public class DetailsController {
322321

323322
private final EventHandler<MouseEvent> mouseFilterPressedOnScene = this::onMouseFilterPressedOnScene;
324323

325-
private boolean isStampSelected;
324+
private BooleanProperty stampSelected;
326325

327326
public DetailsController() {
328327
}
@@ -333,7 +332,8 @@ public DetailsController(UUID conceptTopic) {
333332

334333
@FXML
335334
public void initialize() {
336-
isStampSelected = false;
335+
stampSelected = new SimpleBooleanProperty(false);
336+
stampSelected.subscribe(this::onStampSelectionChanged);
337337

338338
identiconImageView.setOnContextMenuRequested(contextMenuEvent -> {
339339
// query all available memberships (semantics having the purpose as 'membership', and no fields)
@@ -551,7 +551,7 @@ public void invalidated(Observable observable) {
551551
private void onMouseFilterPressedOnScene(MouseEvent mouseEvent) {
552552
Point2D localMousePos = stampContainer.sceneToLocal(mouseEvent.getSceneX(), mouseEvent.getSceneY());
553553
if (!stampContainer.contains(localMousePos)) {
554-
updateStampSelection(false);
554+
stampSelected.set(false);
555555
}
556556
}
557557

@@ -844,7 +844,7 @@ public void updateView() {
844844
getConceptViewModel().setPropertyValue(MODE, CREATE);
845845
stampViewModel.setPropertyValue(MODE, CREATE);
846846
}
847-
conceptViewModel.setPropertyValue(CONCEPT_STAMP_VIEW_MODEL,stampViewModel);
847+
conceptViewModel.setPropertyValue(CONCEPT_STAMP_VIEW_MODEL, stampViewModel);
848848

849849

850850
// Display info for top banner area
@@ -1353,7 +1353,6 @@ public void clearView() {
13531353
lastUpdatedLabel.setText("");
13541354
moduleLabel.setText("");
13551355
pathLabel.setText("");
1356-
originationLabel.setText("");
13571356
statusLabel.setText("");
13581357
authorTooltip.setText("");
13591358
notAvailInferredAxiomLabel.setVisible(true);
@@ -1377,12 +1376,20 @@ public HBox getConceptHeaderControlToolBarHbox() {
13771376

13781377
@FXML
13791378
private void onMousePressedOnStamp(MouseEvent mouseEvent) {
1380-
updateStampSelection(!isStampSelected);
1379+
stampSelected.setValue(!stampSelected.get());
13811380
}
13821381

1383-
private void updateStampSelection(boolean isSelected) {
1384-
isStampSelected = isSelected;
1385-
stampContainer.pseudoClassStateChanged(STAMP_SELECTED, isStampSelected);
1382+
private void onStampSelectionChanged(boolean isSelected) {
1383+
stampContainer.pseudoClassStateChanged(STAMP_SELECTED, isSelected);
1384+
1385+
if (isSelected) {
1386+
if (!propertiesToggleButton.isSelected()) {
1387+
propertiesToggleButton.fire();
1388+
}
1389+
1390+
eventBus.publish(conceptTopic, new AddStampEvent(stampContainer,
1391+
AddStampEvent.ANY));
1392+
}
13861393
}
13871394

13881395
@FXML

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/properties/PropertiesController.java

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@
2020
import dev.ikm.komet.framework.events.Subscriber;
2121
import dev.ikm.komet.framework.view.ViewProperties;
2222
import dev.ikm.komet.kview.events.*;
23+
import dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2;
2324
import dev.ikm.tinkar.common.id.PublicId;
25+
import dev.ikm.tinkar.entity.EntityVersion;
26+
import dev.ikm.tinkar.entity.StampEntity;
2427
import dev.ikm.tinkar.terms.EntityFacade;
28+
import dev.ikm.tinkar.terms.State;
2529
import dev.ikm.tinkar.terms.TinkarTerm;
2630
import javafx.event.ActionEvent;
2731
import javafx.fxml.FXML;
@@ -34,24 +38,34 @@
3438
import javafx.scene.layout.Pane;
3539
import javafx.scene.layout.StackPane;
3640
import javafx.scene.shape.SVGPath;
41+
import org.carlfx.cognitive.loader.Config;
3742
import org.carlfx.cognitive.loader.FXMLMvvmLoader;
3843
import org.carlfx.cognitive.loader.JFXNode;
3944
import org.slf4j.Logger;
4045
import org.slf4j.LoggerFactory;
4146

4247
import java.io.IOException;
4348
import java.io.Serializable;
49+
import java.util.List;
4450
import java.util.UUID;
4551

4652
import static dev.ikm.komet.kview.fxutils.CssHelper.genText;
53+
import static dev.ikm.komet.kview.mvvm.model.DataModelHelper.fetchDescendentsOfConcept;
4754
import static dev.ikm.komet.kview.mvvm.viewmodel.DescrNameViewModel.*;
55+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.ENTITY;
56+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.MODULES;
57+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.PATH;
58+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.PATHS;
59+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.PREV_STAMP;
60+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.STATUSES;
4861

4962
/**
5063
* The properties window providing tabs of Edit, Hierarchy, History, and Comments.
5164
* This view is associated with the view file history-change-selection.fxml.
5265
*/
5366
public class PropertiesController implements Serializable {
5467
private static final Logger LOG = LoggerFactory.getLogger(PropertiesController.class);
68+
5569
protected static final String HISTORY_CHANGE_FXML_FILE = "history-change-selection.fxml";
5670
protected static final String HIERARCHY_VIEW_FXML_FILE = "hierarchy-view.fxml";
5771

@@ -67,6 +81,8 @@ public class PropertiesController implements Serializable {
6781

6882
protected static final String ADD_FQN_FXML_FILE = "add-fully-qualified-name.fxml";
6983

84+
protected static final String ADD_STAMP_FXML_FILE = "stamp-add.fxml";
85+
7086
@FXML
7187
private SVGPath commentsButton;
7288

@@ -88,6 +104,10 @@ public class PropertiesController implements Serializable {
88104
@FXML
89105
private FlowPane propertiesTabsPane;
90106

107+
private Pane stampAddPane;
108+
109+
private StampAddController stampAddController;
110+
91111
private Pane historyTabsBorderPane;
92112
private HistoryChangeController historyChangeController;
93113

@@ -138,6 +158,8 @@ public class PropertiesController implements Serializable {
138158

139159
private Subscriber<ShowEditDescriptionPanelEvent> editDescriptionPaneSubscriber;
140160

161+
private Subscriber<AddStampEvent> addStampSubscriber;
162+
141163
private Subscriber<OpenPropertiesPanelEvent> propsPanelOpen;
142164

143165

@@ -160,6 +182,12 @@ public void initialize() throws IOException {
160182

161183
eventBus = EvtBusFactory.getDefaultEvtBus();
162184

185+
// Load Stamp add View Panel (FXML & Controller)
186+
Config stampConfig = new Config(PropertiesController.class.getResource(ADD_STAMP_FXML_FILE));
187+
JFXNode<Pane, StampAddController> stampJFXNode = FXMLMvvmLoader.make(stampConfig);
188+
stampAddPane = stampJFXNode.node();
189+
stampAddController = stampJFXNode.controller();
190+
163191
// Load History tabs View Panel (FXML & Controller)
164192
FXMLLoader loader = new FXMLLoader(getClass().getResource(HISTORY_CHANGE_FXML_FILE));
165193
historyTabsBorderPane = loader.load();
@@ -329,6 +357,32 @@ public void initialize() throws IOException {
329357
};
330358
eventBus.subscribe(conceptTopic, OpenPropertiesPanelEvent.class, propsPanelOpen);
331359

360+
addStampSubscriber = evt -> {
361+
contentBorderPane.setCenter(stampAddPane);
362+
editButton.setSelected(true);
363+
364+
stampJFXNode.updateViewModel("stampViewModel", stampViewModel -> {
365+
EntityVersion latestVersion = viewProperties.calculator().latest(entityFacade).get();
366+
StampEntity stampEntity = latestVersion.stamp();
367+
368+
stampViewModel.setPropertyValue(ENTITY, entityFacade)
369+
.setPropertyValue(PREV_STAMP, stampEntity)
370+
.setPropertyValue(StampViewModel2.StampProperties.STATUS, stampEntity.state())
371+
.setPropertyValue(StampViewModel2.StampProperties.MODULE, stampEntity.module())
372+
.setPropertyValue(PATH, stampEntity.path());
373+
374+
stampViewModel.setPropertyValues(MODULES, fetchDescendentsOfConcept(viewProperties, TinkarTerm.MODULE.publicId()))
375+
.setPropertyValues(PATHS, fetchDescendentsOfConcept(viewProperties, TinkarTerm.PATH.publicId()))
376+
.setPropertyValues(STATUSES, List.of(State.values()));
377+
// TODO:
378+
// LAST_MOD_DATE, // The previous stamp date time (read-only?) we could use PREV_STAMP's time
379+
// SAME_AS_PREVIOUS, // Custom validator
380+
// SUBMITTED, // Flag when user pressed submit.
381+
});
382+
};
383+
384+
eventBus.subscribe(conceptTopic, AddStampEvent.class, addStampSubscriber);
385+
332386
}
333387

334388
public ViewProperties getViewProperties() {
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
package dev.ikm.komet.kview.mvvm.view.properties;
2+
3+
import dev.ikm.komet.kview.mvvm.view.AbstractBasicController;
4+
import dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2;
5+
import dev.ikm.tinkar.common.util.text.NaturalOrder;
6+
import dev.ikm.tinkar.entity.ConceptEntity;
7+
import dev.ikm.tinkar.terms.EntityFacade;
8+
import dev.ikm.tinkar.terms.State;
9+
import javafx.beans.property.ObjectProperty;
10+
import javafx.collections.ListChangeListener;
11+
import javafx.collections.ObservableList;
12+
import javafx.event.ActionEvent;
13+
import javafx.fxml.FXML;
14+
import javafx.scene.control.ComboBox;
15+
import org.carlfx.cognitive.loader.InjectViewModel;
16+
17+
import java.util.Collections;
18+
import java.util.List;
19+
import java.util.stream.Collectors;
20+
21+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.MODULE;
22+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.MODULES;
23+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.PATH;
24+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.PATHS;
25+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.STATUS;
26+
import static dev.ikm.komet.kview.mvvm.viewmodel.StampViewModel2.StampProperties.STATUSES;
27+
28+
29+
public class StampAddController {
30+
31+
@FXML
32+
private ComboBox<String> statusComboBox;
33+
34+
@FXML
35+
private ComboBox<String> moduleComboBox;
36+
37+
@FXML
38+
private ComboBox<String> pathComboBox;
39+
40+
@InjectViewModel
41+
private StampViewModel2 stampViewModel;
42+
43+
@FXML
44+
public void initialize() {
45+
initModuleComboBox();
46+
initPathComboBox();
47+
initStatusComboBox();
48+
}
49+
50+
private void initStatusComboBox() {
51+
ObservableList<State> statuses = stampViewModel.getObservableList(STATUSES);
52+
statuses.addListener((ListChangeListener<State>) c -> {
53+
List<String> statusesStrings = statuses.stream()
54+
.map(this::toFirstLetterCapitalized)
55+
.collect(Collectors.toList());
56+
Collections.sort(statusesStrings, NaturalOrder.getObjectComparator());
57+
statusComboBox.getItems().setAll(statusesStrings);
58+
});
59+
60+
ObjectProperty<State> statusProperty = stampViewModel.getProperty(STATUS);
61+
statusProperty.subscribe(state -> {
62+
if (state != null) {
63+
statusComboBox.setValue(toFirstLetterCapitalized(state));
64+
}
65+
});
66+
}
67+
68+
private void initPathComboBox() {
69+
ObservableList<ConceptEntity> paths = stampViewModel.getObservableList(PATHS);
70+
paths.addListener((ListChangeListener<ConceptEntity>) c -> {
71+
List<String> pathStrings = paths.stream()
72+
.map(EntityFacade::description)
73+
.collect(Collectors.toList());
74+
Collections.sort(pathStrings, NaturalOrder.getObjectComparator());
75+
pathComboBox.getItems().setAll(pathStrings);
76+
});
77+
78+
ObjectProperty<ConceptEntity> pathProperty = stampViewModel.getProperty(PATH);
79+
pathProperty.subscribe(conceptEntity -> {
80+
if (conceptEntity != null) {
81+
pathComboBox.setValue(conceptEntity.description());
82+
}
83+
});
84+
}
85+
86+
private void initModuleComboBox() {
87+
// populate modules
88+
ObservableList<ConceptEntity> modules = stampViewModel.getObservableList(MODULES);
89+
90+
modules.addListener((ListChangeListener<ConceptEntity>) c -> {
91+
List<String> moduleStrings = modules.stream()
92+
.map(EntityFacade::description)
93+
.collect(Collectors.toList());
94+
Collections.sort(moduleStrings, NaturalOrder.getObjectComparator());
95+
moduleComboBox.getItems().setAll(moduleStrings);
96+
});
97+
98+
ObjectProperty<ConceptEntity> moduleProperty = stampViewModel.getProperty(MODULE);
99+
moduleProperty.subscribe(conceptEntity -> {
100+
if (conceptEntity != null) {
101+
moduleComboBox.setValue(conceptEntity.description());
102+
}
103+
});
104+
}
105+
106+
private String toFirstLetterCapitalized(State status) {
107+
String statusString = status.toString();
108+
return statusString.substring(0, 1).toUpperCase() + statusString.substring(1).toLowerCase();
109+
}
110+
111+
public void cancel(ActionEvent actionEvent) {
112+
113+
}
114+
115+
public void clearForm(ActionEvent actionEvent) {
116+
117+
}
118+
119+
public void confirm(ActionEvent actionEvent) {
120+
121+
}
122+
}

kview/src/main/java/dev/ikm/komet/kview/mvvm/view/stamp/StampEditController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ private void setupModuleSelections() {
141141
rb.setNodeOrientation(NodeOrientation.LEFT_TO_RIGHT);
142142
rb.setUserData(module);
143143
rb.setToggleGroup(moduleToggleGroup);
144+
144145
ObjectProperty<ConceptEntity> moduleProperty = getStampViewModel().getProperty(MODULE);
145146
if (moduleProperty.isNotNull().get() && moduleProperty.get().nid() == module.nid()) {
146147
rb.setSelected(true);

0 commit comments

Comments
 (0)