27
27
import ca .odell .glazedlists .FilterList ;
28
28
import ca .odell .glazedlists .swing .GlazedListsSwing ;
29
29
import com .jidesoft .swing .CheckBoxList ;
30
+ import com .jidesoft .swing .JideSplitButton ;
30
31
import mediathek .config .Daten ;
31
32
import mediathek .config .Konstanten ;
32
33
import mediathek .controller .SenderFilmlistLoadApprover ;
@@ -78,6 +79,10 @@ public class SwingFilterDialog extends JDialog {
78
79
* The "base" thema list
79
80
*/
80
81
private final EventList <String > sourceThemaList = new BasicEventList <>();
82
+ private final RenameFilterAction renameFilterAction = new RenameFilterAction ();
83
+ private final DeleteCurrentFilterAction deleteCurrentFilterAction = new DeleteCurrentFilterAction ();
84
+ private final AddNewFilterAction addNewFilterAction = new AddNewFilterAction ();
85
+ private final ResetCurrentFilterAction resetCurrentFilterAction = new ResetCurrentFilterAction ();
81
86
82
87
public SwingFilterDialog (@ NotNull Window owner , @ NotNull FilterSelectionComboBoxModel model ,
83
88
@ NotNull JToggleButton filterToggleButton ,
@@ -89,6 +94,9 @@ public SwingFilterDialog(@NotNull Window owner, @NotNull FilterSelectionComboBox
89
94
90
95
initComponents ();
91
96
97
+ btnSplit .setIcon (SVGIconUtilities .createSVGIcon ("icons/fontawesome/ellipsis-vertical.svg" ));
98
+ populateSplitButton ();
99
+
92
100
ToggleVisibilityKeyHandler handler = new ToggleVisibilityKeyHandler (this );
93
101
handler .installHandler (filterToggleButton .getAction ());
94
102
@@ -110,11 +118,16 @@ public SwingFilterDialog(@NotNull Window owner, @NotNull FilterSelectionComboBox
110
118
Daten .getInstance ().getFilmeLaden ().addAdListener (new FilmeLadenListener ());
111
119
}
112
120
121
+ private void populateSplitButton () {
122
+ btnSplit .add (renameFilterAction );
123
+ btnSplit .add (addNewFilterAction );
124
+ btnSplit .add (deleteCurrentFilterAction );
125
+ btnSplit .addSeparator ();
126
+ btnSplit .add (resetCurrentFilterAction );
127
+ }
128
+
113
129
private void setupButtons () {
114
- btnRenameFilter .setAction (new RenameFilterAction ());
115
- setupDeleteCurrentFilterButton ();
116
- setupResetCurrentFilterButton ();
117
- btnAddNewFilter .setAction (new AddNewFilterAction ());
130
+ checkDeleteCurrentFilterButtonState ();
118
131
btnResetThema .setAction (new ResetThemaAction ());
119
132
}
120
133
@@ -262,7 +275,7 @@ private void setupZeitraumSpinner() {
262
275
}
263
276
264
277
private void checkDeleteCurrentFilterButtonState () {
265
- btnDeleteCurrentFilter .setEnabled (filterConfig .getAvailableFilterCount () > 1 );
278
+ deleteCurrentFilterAction .setEnabled (filterConfig .getAvailableFilterCount () > 1 );
266
279
}
267
280
268
281
private void restoreConfigSettings () {
@@ -285,25 +298,14 @@ private void restoreConfigSettings() {
285
298
spZeitraum .restoreFilterConfig (filterConfig );
286
299
}
287
300
288
- private void setupResetCurrentFilterButton () {
289
- btnResetCurrentFilter .setIcon (SVGIconUtilities .createSVGIcon ("icons/fontawesome/recycle.svg" ));
290
- btnResetCurrentFilter .addActionListener (e -> {
291
- filterConfig .clearCurrentFilter ();
292
- restoreConfigSettings ();
293
- });
294
- }
295
-
296
- private void setupDeleteCurrentFilterButton () {
297
- checkDeleteCurrentFilterButtonState ();
298
- btnDeleteCurrentFilter .setAction (new DeleteCurrentFilterAction ());
299
- }
300
-
301
301
private void enableControls (boolean enable ) {
302
302
cboxFilterSelection .setEnabled (enable );
303
303
304
- btnRenameFilter .setEnabled (enable );
305
- btnAddNewFilter .setEnabled (enable );
306
- btnResetCurrentFilter .setEnabled (enable );
304
+ btnSplit .setEnabled (enable );
305
+ renameFilterAction .setEnabled (enable );
306
+ addNewFilterAction .setEnabled (enable );
307
+ resetCurrentFilterAction .setEnabled (enable );
308
+
307
309
btnResetThema .setEnabled (enable );
308
310
309
311
cbShowNewOnly .setEnabled (enable );
@@ -349,7 +351,7 @@ private void handleTableModelChangeEvent(TableModelChangeEvent e) {
349
351
enableControls (enable );
350
352
351
353
if (e .active ) {
352
- btnDeleteCurrentFilter .setEnabled (false );
354
+ deleteCurrentFilterAction .setEnabled (false );
353
355
} else {
354
356
checkDeleteCurrentFilterButtonState ();
355
357
}
@@ -397,6 +399,25 @@ public void installHandler(Action action) {
397
399
}
398
400
}
399
401
402
+ private class ResetCurrentFilterAction extends AbstractAction {
403
+ public ResetCurrentFilterAction () {
404
+ putValue (Action .SMALL_ICON , SVGIconUtilities .createSVGIcon ("icons/fontawesome/recycle.svg" ));
405
+ putValue (Action .SHORT_DESCRIPTION , "Aktuellen Filter zurücksetzen" );
406
+ putValue (Action .NAME , "Aktuellen Filter zurücksetzen" +"..." );
407
+ }
408
+
409
+ @ Override
410
+ public void actionPerformed (ActionEvent e ) {
411
+ var result = JOptionPane .showConfirmDialog (MediathekGui .ui (),
412
+ "Sind Sie sicher dass Sie den Filter zurücksetzen möchten?" , "Filter zurücksetzen" ,
413
+ JOptionPane .YES_NO_OPTION );
414
+ if (result == JOptionPane .YES_OPTION ) {
415
+ filterConfig .clearCurrentFilter ();
416
+ restoreConfigSettings ();
417
+ }
418
+ }
419
+ }
420
+
400
421
private class SenderCheckBoxList extends CheckBoxList {
401
422
private static final String CONFIG_SENDERLIST_VERTICAL_WRAP = "senderlist.vertical_wrap" ;
402
423
private final JCheckBoxMenuItem miVerticalWrap = new JCheckBoxMenuItem ("Senderliste vertikal umbrechen" , false );
@@ -489,6 +510,7 @@ private class AddNewFilterAction extends AbstractAction {
489
510
public AddNewFilterAction () {
490
511
putValue (Action .SMALL_ICON , SVGIconUtilities .createSVGIcon ("icons/fontawesome/plus.svg" ));
491
512
putValue (Action .SHORT_DESCRIPTION , STR_ACTION_NAME );
513
+ putValue (Action .NAME , STR_ACTION_NAME + "..." );
492
514
}
493
515
494
516
@ Override
@@ -512,9 +534,12 @@ public void actionPerformed(ActionEvent e) {
512
534
}
513
535
514
536
private class DeleteCurrentFilterAction extends AbstractAction {
537
+ private static final String STR_DELETE_CURRENT_FILTER = "Aktuellen Filter löschen" ;
538
+
515
539
public DeleteCurrentFilterAction () {
516
540
putValue (Action .SMALL_ICON , SVGIconUtilities .createSVGIcon ("icons/fontawesome/trash-can.svg" ));
517
- putValue (Action .SHORT_DESCRIPTION , "Aktuellen Filter löschen" );
541
+ putValue (Action .SHORT_DESCRIPTION , STR_DELETE_CURRENT_FILTER );
542
+ putValue (Action .NAME , STR_DELETE_CURRENT_FILTER +"..." );
518
543
}
519
544
520
545
@ Override
@@ -552,9 +577,12 @@ public ResetThemaButtonAction() {
552
577
}
553
578
554
579
private class RenameFilterAction extends AbstractAction {
580
+ private static final String STR_RENAME_FILTER = "Filter umbenennen" ;
581
+
555
582
public RenameFilterAction () {
556
583
putValue (Action .SMALL_ICON , SVGIconUtilities .createSVGIcon ("icons/fontawesome/pen-to-square.svg" ));
557
- putValue (Action .SHORT_DESCRIPTION , "Filter umbenennen" );
584
+ putValue (Action .SHORT_DESCRIPTION , STR_RENAME_FILTER );
585
+ putValue (Action .NAME , STR_RENAME_FILTER + "..." );
558
586
}
559
587
560
588
@ Override
@@ -676,11 +704,7 @@ private void initComponents() {
676
704
createUIComponents ();
677
705
678
706
var pnlFilterCommon = new JPanel ();
679
- btnRenameFilter = new JButton ();
680
- btnAddNewFilter = new JButton ();
681
- btnDeleteCurrentFilter = new JButton ();
682
- var separator1 = new JSeparator ();
683
- btnResetCurrentFilter = new JButton ();
707
+ btnSplit = new JideSplitButton ();
684
708
var separator2 = new JSeparator ();
685
709
var pnlShowOnly = new JPanel ();
686
710
cbShowNewOnly = new JCheckBox ();
@@ -752,10 +776,6 @@ private void initComponents() {
752
776
// columns
753
777
new AC ()
754
778
.grow ().fill ().gap ()
755
- .fill ().gap ()
756
- .fill ().gap ()
757
- .align ("left" ).gap () //NON-NLS
758
- .fill ().gap ()
759
779
.fill (),
760
780
// rows
761
781
new AC ()
@@ -766,17 +786,12 @@ private void initComponents() {
766
786
cboxFilterSelection .setPreferredSize (null );
767
787
cboxFilterSelection .setMinimumSize (new Dimension (50 , 10 ));
768
788
pnlFilterCommon .add (cboxFilterSelection , new CC ().cell (0 , 0 ));
769
- pnlFilterCommon .add (btnRenameFilter , new CC ().cell (1 , 0 ).alignX ("center" ).growX (0 )); //NON-NLS
770
- pnlFilterCommon .add (btnAddNewFilter , new CC ().cell (2 , 0 ).alignX ("center" ).growX (0 )); //NON-NLS
771
- pnlFilterCommon .add (btnDeleteCurrentFilter , new CC ().cell (3 , 0 ).alignX ("center" ).growX (0 )); //NON-NLS
772
789
773
- //---- separator1 ----
774
- separator1 .setOrientation (SwingConstants .VERTICAL );
775
- pnlFilterCommon .add (separator1 , new CC ().cell (4 , 0 ));
776
-
777
- //---- btnResetCurrentFilter ----
778
- btnResetCurrentFilter .setToolTipText ("Aktuellen Filter zur\u00fc cksetzen" ); //NON-NLS
779
- pnlFilterCommon .add (btnResetCurrentFilter , new CC ().cell (5 , 0 ).alignX ("center" ).growX (0 )); //NON-NLS
790
+ //======== btnSplit ========
791
+ {
792
+ btnSplit .setAlwaysDropdown (true );
793
+ }
794
+ pnlFilterCommon .add (btnSplit , new CC ().cell (1 , 0 ));
780
795
}
781
796
contentPane .add (pnlFilterCommon , new CC ().cell (0 , 0 ).growX ());
782
797
contentPane .add (separator2 , new CC ().cell (0 , 1 ).growX ());
@@ -968,10 +983,7 @@ private void initComponents() {
968
983
// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables @formatter:off
969
984
// Generated using JFormDesigner non-commercial license
970
985
private FilterSelectionComboBox cboxFilterSelection ;
971
- private JButton btnRenameFilter ;
972
- private JButton btnAddNewFilter ;
973
- private JButton btnDeleteCurrentFilter ;
974
- private JButton btnResetCurrentFilter ;
986
+ private JideSplitButton btnSplit ;
975
987
private JCheckBox cbShowNewOnly ;
976
988
private JCheckBox cbShowBookMarkedOnly ;
977
989
private JCheckBox cbShowOnlyHq ;
0 commit comments