2
2
3
3
import com .anas .alqurancloudapi .Ayah ;
4
4
import com .anas .alqurancloudapi .consts .Constants ;
5
- import com .anas .alqurancloudapi .edition .Edition ;
6
- import com .anas .alqurancloudapi .edition .EditionFormat ;
7
5
import com .anas .intellij .plugins .ayah .audio .AudioPlayer ;
8
6
import com .anas .intellij .plugins .ayah .audio .PlayerListener ;
9
- import com . anas . intellij . plugins . ayah . settings . userinterface . ReadableEdition ;
7
+ import javazoom . jl . player . advanced . PlaybackEvent ;
10
8
11
9
import javax .swing .*;
12
10
import java .awt .event .KeyEvent ;
13
11
import java .awt .event .WindowAdapter ;
14
12
import java .awt .event .WindowEvent ;
15
13
import java .io .IOException ;
16
- import java .util .Arrays ;
17
- import java .util .Objects ;
18
14
19
15
/**
20
16
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
@@ -32,9 +28,6 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
32
28
private JButton previousButton ;
33
29
private JButton nextButton ;
34
30
private JCheckBox autoPlayCheckBox ;
35
- private JTextArea tafseerTextArea ;
36
- private JComboBox <ReadableEdition > tafseerAndTranslationComboBox ;
37
- private JComboBox <ReadableEdition > editionComboBox ;
38
31
private boolean isPlaying ;
39
32
private AudioPlayer audioPlayer ;
40
33
private Ayah ayah ;
@@ -44,55 +37,21 @@ public AyahDetailsDialog(final Ayah ayah) {
44
37
45
38
setContentPane (contentPane );
46
39
setModal (true );
47
- setSize (520 , 320 );
40
+ setSize (500 , 300 );
48
41
setResizable (false );
49
42
setLocationRelativeTo (null );
50
43
getRootPane ().setDefaultButton (playButton );
51
44
52
- try {
53
- setupTheUI ();
54
- } catch (final IOException e ) {
55
- e .printStackTrace ();
56
- JOptionPane .showMessageDialog (this , "Error while loading the ayah details" ,
57
- "Error" , JOptionPane .ERROR_MESSAGE );
58
- }
45
+ updateAhaDetails ();
59
46
60
47
addListeners ();
61
48
}
62
49
63
- private void setupTheUI () throws IOException {
64
- previousButton .setEnabled (ayah .getNumber () != 1 && ayah .getSurah ().getNumber () != 1 );
65
- nextButton .setEnabled (ayah .getNumber () != Constants .AYAHS_COUNT && ayah .getSurah ().getNumber () != Constants .SURAS_COUNT );
66
-
67
-
68
- final var tafserAndTranslationComboBoxModel = new DefaultComboBoxModel <ReadableEdition >();
69
- final var editionComboBoxModel = new DefaultComboBoxModel <ReadableEdition >();
70
-
71
- Arrays .stream (Edition .getEditions ()).forEach (edition -> {
72
- if (edition .getFormat () == EditionFormat .AUDIO ) {
73
- editionComboBoxModel .addElement (new ReadableEdition (edition ));
74
- } else {
75
- tafserAndTranslationComboBoxModel .addElement (new ReadableEdition (edition ));
76
- }
77
- });
78
-
79
- tafseerAndTranslationComboBox .setModel (tafserAndTranslationComboBoxModel );
80
- editionComboBox .setModel (editionComboBoxModel );
81
-
82
- // Set the default selected item for the editionComboBox
83
- editionComboBoxModel .setSelectedItem (new ReadableEdition (ayah .getEdition ()));
84
- // Set the actual information about the ayah in the UI
85
- updateAyahDetails ();
86
- }
87
-
88
- private void updateAyahDetails () {
89
- // Update the ayah details
50
+ private void updateAhaDetails () {
90
51
ayahTextArea .setText (ayah .getText ());
91
52
surahNameLabel .setText (ayah .getSurah ().getName ());
92
53
numberOfAyahInSuarhLabel .setText ("آية رقم: " + ayah .getNumberInSurah ());
93
54
ayahRevelationType .setText (ayah .getSurah ().getRevelationType ().getArabicName ());
94
- // Update the tafseer or translation
95
- updateTheTauseerTextArea ();
96
55
}
97
56
98
57
private void addListeners () {
@@ -133,24 +92,6 @@ private void addListeners() {
133
92
}
134
93
});
135
94
136
- tafseerAndTranslationComboBox .addActionListener (e -> {
137
- updateTheTauseerTextArea ();
138
- });
139
-
140
- editionComboBox .addActionListener (e -> {
141
- final var selectedEdition = ((ReadableEdition ) Objects .requireNonNull (
142
- editionComboBox .getSelectedItem ())).getEdition ();
143
- try {
144
- ayah = Ayah .getAyah (ayah .getNumber (), selectedEdition );
145
- updateAyahDetails ();
146
- } catch (final IOException ioException ) {
147
- ioException .printStackTrace ();
148
- JOptionPane .showMessageDialog (this ,
149
- "Error while loading the ayah - check your internet connection" ,
150
- "Error" , JOptionPane .ERROR_MESSAGE );
151
- }
152
- });
153
-
154
95
buttonCancel .addActionListener (l -> close ());
155
96
156
97
// call onCancel() when cross is clicked
@@ -167,19 +108,6 @@ public void windowClosing(WindowEvent e) {
167
108
JComponent .WHEN_ANCESTOR_OF_FOCUSED_COMPONENT );
168
109
}
169
110
170
- private void updateTheTauseerTextArea () {
171
- final var selectedEdition = ((ReadableEdition ) Objects .requireNonNull (
172
- tafseerAndTranslationComboBox .getSelectedItem ())).getEdition ();
173
- try {
174
- tafseerTextArea .setText (Ayah .getAyah (ayah .getNumber (), selectedEdition ).getText ());
175
- } catch (final IOException ioException ) {
176
- ioException .printStackTrace ();
177
- JOptionPane .showMessageDialog (this ,
178
- "Error while loading the tafseer - check your internet connection" ,
179
- "Error" , JOptionPane .ERROR_MESSAGE );
180
- }
181
- }
182
-
183
111
private void close () {
184
112
if (audioPlayer != null ) {
185
113
audioPlayer .stop ();
@@ -204,7 +132,7 @@ private boolean loadTheAyah(final int ayhNumber) {
204
132
try {
205
133
ayah = Ayah .getAyah (ayhNumber ,
206
134
ayah .getEdition ().getIdentifier ());
207
- updateAyahDetails ();
135
+ updateAhaDetails ();
208
136
return true ;
209
137
} catch (final IOException ex ) {
210
138
JOptionPane .showMessageDialog (this ,
0 commit comments