@@ -280,7 +280,7 @@ public class SnapshotController extends SaveAndRestoreBaseController implements
280280 @ FXML
281281 protected VBox progressIndicator ;
282282
283- protected final Map <String , SaveAndRestorePV > pvs = new HashMap <>();
283+ // protected final Map<String, SaveAndRestorePV> pvs = new HashMap<>();
284284
285285 protected Node configurationNode ;
286286
@@ -347,6 +347,7 @@ public class SnapshotController extends SaveAndRestoreBaseController implements
347347 * determine which elements in the {@link Map} to actually represent.
348348 */
349349 protected final Map <String , TableEntry > tableEntryItems = new LinkedHashMap <>();
350+ //protected final List<TableEntry> tableEntries = new ArrayList<>();
350351
351352 public SnapshotController (SnapshotTab snapshotTab ) {
352353 snapshotTab .textProperty ().bind (tabTitleProperty );
@@ -484,10 +485,17 @@ public void initialize() {
484485 this .showDeltaPercentage .set (n ));
485486
486487 hideEqualItemsButton .setGraphic (new ImageView (new Image (getClass ().getResourceAsStream ("/icons/hide_show_equal_items.png" ))));
488+ hideEqualItemsButton .selectedProperty ().bindBidirectional (hideEqualItemsProperty );
489+ hideEqualItemsProperty .addListener ((obs , o , n ) -> updateTable ());
490+ /*
487491 hideEqualItemsProperty.bind(hideEqualItemsButton.selectedProperty());
488492 hideEqualItemsButton.selectedProperty()
489493 .addListener((a, o, n) ->
494+
495+
490496 hideEqualItems());
497+
498+ */
491499
492500 logAction .selectedProperty ().bindBidirectional (logActionProperty );
493501
@@ -876,7 +884,8 @@ public boolean handleTabClosed() {
876884 * Releases PV resources.
877885 */
878886 private void dispose () {
879- pvs .values ().forEach (SaveAndRestorePV ::dispose );
887+ //pvs.values().forEach(SaveAndRestorePV::dispose);
888+ tableEntryItems .values ().forEach (tableEntry -> tableEntry .getSaveAndRestorePV ().dispose ());
880889 }
881890
882891 private void showLoggingError (String cause ) {
@@ -1265,11 +1274,14 @@ private void applyPreserveSelection(boolean preserve) {
12651274 }
12661275 }
12671276
1277+ /*
12681278 private void hideEqualItems() {
12691279 ArrayList<TableEntry> arrayList = new ArrayList<>(tableEntryItems.values());
12701280 Platform.runLater(() -> updateTable(arrayList));
12711281 }
12721282
1283+ */
1284+
12731285 /**
12741286 * Restores a snapshot from client or service.
12751287 *
@@ -1418,29 +1430,28 @@ private void addSnapshot(Snapshot snapshot) {
14181430 for (int s = 1 ; s < snapshots .size (); s ++) {
14191431 Node snapshotNode = snapshots .get (s ).getSnapshotNode ();
14201432 String snapshotName = snapshotNode .getName ();
1421-
14221433 List <SnapshotItem > entries = snapshot .getSnapshotData ().getSnapshotItems ();
14231434 String nodeName ;
14241435 TableEntry tableEntry ;
14251436 // Base snapshot data
14261437 List <TableEntry > baseSnapshotTableEntries = new ArrayList <>(tableEntryItems .values ());
1427- SnapshotItem entry ;
1438+ SnapshotItem snpshotItem ;
14281439 for (int i = 0 ; i < entries .size (); i ++) {
1429- entry = entries .get (i );
1430- nodeName = entry .getConfigPv ().getPvName ();
1440+ snpshotItem = entries .get (i );
1441+ nodeName = snpshotItem .getConfigPv ().getPvName ();
14311442 tableEntry = tableEntryItems .get (nodeName );
14321443 // tableEntry is null if the added snapshot has more items than the base snapshot.
14331444 if (tableEntry == null ) {
1434- tableEntry = new TableEntry ();
1445+ tableEntry = new TableEntry (snpshotItem );
14351446 tableEntry .idProperty ().setValue (tableEntryItems .size () + i + 1 );
1436- tableEntry .pvNameProperty ().setValue (nodeName );
1437- tableEntry .setConfigPv (entry .getConfigPv ());
1447+ // tableEntry.pvNameProperty().setValue(nodeName);
1448+ // tableEntry.setConfigPv(snpshotItem .getConfigPv());
14381449 tableEntryItems .put (nodeName , tableEntry );
1439- tableEntry .readbackNameProperty ().set (entry .getConfigPv ().getReadbackPvName ());
1450+ // tableEntry.readbackNameProperty().set(snpshotItem .getConfigPv().getReadbackPvName());
14401451 }
1441- tableEntry .setSnapshotValue (entry .getValue (), snapshots .size ());
1442- tableEntry .setStoredReadbackValue (entry .getReadbackValue (), snapshots .size ());
1443- tableEntry .readOnlyProperty ().set (entry .getConfigPv ().isReadOnly ());
1452+ tableEntry .setSnapshotValue (snpshotItem .getValue (), snapshots .size ());
1453+ tableEntry .setStoredReadbackValue (snpshotItem .getReadbackValue (), snapshots .size ());
1454+ // tableEntry.readOnlyProperty().set(snpshotItem .getConfigPv().isReadOnly());
14441455 baseSnapshotTableEntries .remove (tableEntry );
14451456 }
14461457 // If added snapshot has more items than base snapshot, the base snapshot's values for those
@@ -1487,8 +1498,8 @@ private void addSnapshot(Snapshot snapshot) {
14871498
14881499 snapshotTableView .getColumns ().addAll (columns );
14891500
1490- connectPVs ();
1491- updateTable (null );
1501+ // connectPVs();
1502+ updateTable ();
14921503 }
14931504
14941505 private void showSnapshotInTable () {
@@ -1498,36 +1509,43 @@ private void showSnapshotInTable() {
14981509 snapshots .set (0 , snapshot );
14991510 }
15001511 AtomicInteger counter = new AtomicInteger (0 );
1501- snapshot .getSnapshotData ().getSnapshotItems ().forEach (entry -> {
1502- TableEntry tableEntry = new TableEntry ();
1503- String name = entry .getConfigPv ().getPvName ();
1512+ snapshot .getSnapshotData ().getSnapshotItems ().forEach (snapshotItem -> {
1513+ TableEntry tableEntry = new TableEntry (snapshotItem );
1514+ String name = snapshotItem .getConfigPv ().getPvName ();
15041515 tableEntry .idProperty ().setValue (counter .incrementAndGet ());
1505- tableEntry .pvNameProperty ().setValue (name );
1506- tableEntry .setConfigPv (entry .getConfigPv ());
1507- tableEntry .setSnapshotValue (entry .getValue (), 0 );
1508- tableEntry .setStoredReadbackValue (entry .getReadbackValue (), 0 );
1509- tableEntry .setReadbackValue (entry .getReadbackValue ());
1510- if (entry .getValue () == null || entry .getValue ().equals (VDisconnectedData .INSTANCE )) {
1516+ //tableEntry.pvNameProperty().setValue(name);
1517+ //tableEntry.setConfigPv(snapshotItem.getConfigPv());
1518+ tableEntry .setSnapshotValue (snapshotItem .getValue (), 0 );
1519+ tableEntry .setStoredReadbackValue (snapshotItem .getReadbackValue (), 0 );
1520+ //tableEntry.setReadbackValue(snapshotItem.getReadbackValue());
1521+ /*
1522+ if (snapshotItem.getValue() == null || snapshotItem.getValue().equals(VDisconnectedData.INSTANCE)) {
15111523 tableEntry.setActionResult(ActionResult.FAILED);
15121524 }
15131525 else {
15141526 tableEntry.setActionResult(ActionResult.OK);
15151527 }
1516- if (entry .getConfigPv ().getReadbackPvName () != null ){
1517- if (entry .getReadbackValue () == null || entry .getReadbackValue ().equals (VDisconnectedData .INSTANCE )) {
1528+ if (snapshotItem .getConfigPv().getReadbackPvName() != null){
1529+ if(snapshotItem .getReadbackValue() == null || snapshotItem .getReadbackValue().equals(VDisconnectedData.INSTANCE)) {
15181530 tableEntry.setActionResultReadback(ActionResult.FAILED);
15191531 }
15201532 else{
15211533 tableEntry.setActionResultReadback(ActionResult.OK);
15221534 }
15231535 }
1524- tableEntry .readbackNameProperty ().set (entry .getConfigPv ().getReadbackPvName ());
1525- tableEntry .readOnlyProperty ().set (entry .getConfigPv ().isReadOnly ());
1536+
1537+ */
1538+ //tableEntry.readbackNameProperty().set(snapshotItem.getConfigPv().getReadbackPvName());
1539+ //tableEntry.readOnlyProperty().set(snapshotItem.getConfigPv().isReadOnly());
15261540 tableEntryItems .put (name , tableEntry );
15271541 });
15281542
1529- updateTable (null );
1530- connectPVs ();
1543+ updateTable ();
1544+ //connectPVs();
1545+ }
1546+
1547+ private void updateTable (){
1548+ updateTable (tableEntryItems .values ().stream ().toList ());
15311549 }
15321550
15331551 /**
@@ -1540,7 +1558,7 @@ private void updateTable(List<TableEntry> entries) {
15401558 final boolean notHide = hideEqualItemsProperty .not ().get ();
15411559 Platform .runLater (() -> {
15421560 items .clear ();
1543- tableEntryItems .forEach (( key , value ) -> {
1561+ entries .forEach (value -> {
15441562 // there is no harm if this is executed more than once, because only one line is allowed for these
15451563 // two properties (see SingleListenerBooleanProperty for more details)
15461564 value .liveStoredEqualProperty ().addListener ((a , o , n ) -> {
@@ -1579,6 +1597,7 @@ private int measureStringWidth(String text, Font font) {
15791597 * Attempts to connect to all the PVs of the configuration/snapshot and binds the created {@link SaveAndRestorePV} objects
15801598 * to the {@link TableEntry} objects matched on PV name.
15811599 */
1600+ /*
15821601 private void connectPVs() {
15831602 JobManager.schedule("Connect PVs", monitor -> tableEntryItems.values().forEach(e -> {
15841603 SaveAndRestorePV pv = pvs.get(e.getConfigPv().getPvName());
@@ -1590,6 +1609,8 @@ private void connectPVs() {
15901609 }));
15911610 }
15921611
1612+ */
1613+
15931614 /**
15941615 *
15951616 * @param configurationData {@link ConfigurationData} obejct of a {@link org.phoebus.applications.saveandrestore.model.Configuration}
0 commit comments