66
66
import org .zephyrsoft .sdb2 .model .AddressablePart ;
67
67
import org .zephyrsoft .sdb2 .model .ExportFormat ;
68
68
import org .zephyrsoft .sdb2 .model .FilterTypeEnum ;
69
+ import org .zephyrsoft .sdb2 .model .PresentCommandResult ;
69
70
import org .zephyrsoft .sdb2 .model .ScreenContentsEnum ;
70
71
import org .zephyrsoft .sdb2 .model .SelectableDisplay ;
71
72
import org .zephyrsoft .sdb2 .model .Song ;
@@ -1474,51 +1475,66 @@ protected void handleSongPresent() {
1474
1475
*/
1475
1476
protected void presentSong (Song song , SongPresentationPosition presentationPosition ) {
1476
1477
// not in a "contentChange" block because else the sections wouldn't be displayed:
1477
- boolean success = controller .present (new Presentable (song , null ), presentationPosition );
1478
+ PresentCommandResult result = controller .present (new Presentable (song , null ), presentationPosition );
1478
1479
1479
1480
controller .contentChange (() -> {
1480
1481
controller .stopSlideShow ();
1481
- if (success ) {
1482
- clearSectionButtons ();
1483
- if (controller .hasParts ()) {
1484
- List <AddressablePart > parts = controller .getParts ();
1485
- Boolean showTitle = settingsModel .get (SettingKey .SHOW_TITLE , Boolean .class );
1486
- int partIndex = showTitle ? 0 : 1 ;
1487
- for (AddressablePart part : parts ) {
1488
- PartButtonGroup buttonGroup = new PartButtonGroup (part , partIndex , controller , this );
1489
- panelSectionButtons .add (buttonGroup , panelSectionButtonsHints );
1490
- listSectionButtons .add (buttonGroup );
1491
- partIndex ++;
1482
+ if (result .wasSuccessful () && result .wasStateChanged ()) {
1483
+ btnJumpToPresented .setEnabled (true );
1484
+ Boolean showTitle = settingsModel .get (SettingKey .SHOW_TITLE , Boolean .class );
1485
+
1486
+ if (result != PresentCommandResult .ONLY_SCOLLED ) {
1487
+ clearSectionButtons ();
1488
+ if (controller .hasParts ()) {
1489
+ List <AddressablePart > parts = controller .getParts ();
1490
+ int partIndex = showTitle ? 0 : 1 ;
1491
+ for (AddressablePart part : parts ) {
1492
+ PartButtonGroup buttonGroup = new PartButtonGroup (part , partIndex , controller , this );
1493
+ panelSectionButtons .add (buttonGroup , panelSectionButtonsHints );
1494
+ listSectionButtons .add (buttonGroup );
1495
+ partIndex ++;
1496
+ }
1492
1497
}
1498
+ }
1493
1499
1500
+ if (controller .hasParts ()) {
1494
1501
// mark active line
1495
1502
if (!listSectionButtons .isEmpty ()) {
1496
- listSectionButtons
1497
- .get (presentationPosition != null && presentationPosition .getPartIndex () != null
1498
- ? Math .max (0 , presentationPosition .getPartIndex () - (showTitle ? 0 : 1 ))
1499
- : 0 )
1500
- .setActiveLine (presentationPosition != null && presentationPosition .getLineIndex () != null
1501
- ? presentationPosition .getLineIndex ()
1502
- : 0 );
1503
+ int activePartIndex = presentationPosition != null && presentationPosition .getPartIndex () != null
1504
+ ? Math .max (0 , presentationPosition .getPartIndex () - (showTitle ? 0 : 1 ))
1505
+ : 0 ;
1506
+ int activeLineIndex = presentationPosition != null && presentationPosition .getLineIndex () != null
1507
+ ? presentationPosition .getLineIndex ()
1508
+ : 0 ;
1509
+
1510
+ for (int partIndex = 0 ; partIndex < listSectionButtons .size (); partIndex ++) {
1511
+ if (partIndex == activePartIndex ) {
1512
+ listSectionButtons .get (partIndex ).setActiveLine (activeLineIndex );
1513
+ } else {
1514
+ listSectionButtons .get (partIndex ).setInactive ();
1515
+ }
1516
+ }
1517
+
1503
1518
}
1519
+ }
1504
1520
1505
- // add empty component to consume any space that is left (so the parts appear at the top of the
1506
- // scrollpane view)
1521
+ if (result != PresentCommandResult .ONLY_SCOLLED ) {
1522
+ // add empty component to consume any space that is left
1523
+ // (so the parts appear at the top of the scrollpane view)
1507
1524
panelSectionButtons .add (new JLabel ("" ), panelSectionButtonsLastRowHints );
1508
1525
1509
1526
panelSectionButtons .revalidate ();
1510
1527
panelSectionButtons .repaint ();
1511
- btnJumpToPresented .setEnabled (true );
1512
1528
}
1513
1529
}
1514
1530
});
1515
1531
}
1516
1532
1517
1533
protected void handleBlankScreen () {
1518
1534
controller .contentChange (() -> {
1519
- boolean success = controller .present (BLANK_SCREEN , null );
1535
+ PresentCommandResult result = controller .present (BLANK_SCREEN , null );
1520
1536
controller .stopSlideShow ();
1521
- if (success ) {
1537
+ if (result . wasSuccessful () ) {
1522
1538
clearSectionButtons ();
1523
1539
btnJumpToPresented .setEnabled (false );
1524
1540
}
@@ -1527,9 +1543,9 @@ protected void handleBlankScreen() {
1527
1543
1528
1544
protected void handleLogoPresent () {
1529
1545
controller .contentChange (() -> {
1530
- boolean success = controller .present (new Presentable (null , controller .loadLogo ()), null );
1546
+ PresentCommandResult result = controller .present (new Presentable (null , controller .loadLogo ()), null );
1531
1547
controller .stopSlideShow ();
1532
- if (success ) {
1548
+ if (result . wasSuccessful () ) {
1533
1549
clearSectionButtons ();
1534
1550
btnJumpToPresented .setEnabled (false );
1535
1551
}
@@ -2306,10 +2322,10 @@ public void keyReleased(KeyEvent e) {
2306
2322
menuPresentSelectedSong .setRenderer (new TextLineCellRenderer (btnPresentSelectedSong ));
2307
2323
menuPresentSelectedSong .setMaximumRowCount (50 );
2308
2324
menuPresentSelectedSong .addActionListener (actionEvent -> {
2309
- NamedSongPresentationPosition nssp = (NamedSongPresentationPosition ) menuPresentSelectedSong .getSelectedItem ();
2325
+ NamedSongPresentationPosition nspp = (NamedSongPresentationPosition ) menuPresentSelectedSong .getSelectedItem ();
2310
2326
2311
- if (nssp != null && nssp .getPartIndex () != null ) {
2312
- present (presentListSelected , nssp );
2327
+ if (nspp != null && nspp .getPartIndex () != null ) {
2328
+ present (presentListSelected , nspp );
2313
2329
}
2314
2330
2315
2331
if (menuPresentSelectedSong .getModel ().getSize () > 0 ) {
0 commit comments