Skip to content

Commit 0e369b9

Browse files
authored
Revert "Add the tafseer/translation text box to the ayah details dialog and make the user able to change the player edition on the fly"
1 parent 739052b commit 0e369b9

File tree

2 files changed

+23
-166
lines changed

2 files changed

+23
-166
lines changed

src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.form

Lines changed: 18 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
6-
<xy x="48" y="54" width="836" height="472"/>
6+
<xy x="48" y="54" width="577" height="355"/>
77
</constraints>
88
<properties>
99
<maximumSize width="500" height="300"/>
@@ -18,7 +18,7 @@
1818
<properties/>
1919
<border type="none"/>
2020
<children>
21-
<grid id="9538f" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
21+
<grid id="9538f" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
2222
<margin top="0" left="0" bottom="0" right="0"/>
2323
<constraints>
2424
<grid row="0" column="0" row-span="1" col-span="6" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -60,77 +60,25 @@
6060
</component>
6161
</children>
6262
</grid>
63-
<grid id="e3ffd" layout-manager="GridBagLayout">
63+
<component id="69418" class="javax.swing.JButton" binding="previousButton">
6464
<constraints>
65-
<grid row="1" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
65+
<grid row="1" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
6666
</constraints>
67-
<properties/>
68-
<border type="none"/>
69-
<children>
70-
<component id="c14dc" class="javax.swing.JLabel">
71-
<constraints>
72-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
73-
<gridbag weightx="0.0" weighty="1.0"/>
74-
</constraints>
75-
<properties>
76-
<text value="Tafseer/Translation"/>
77-
<verifyInputWhenFocusTarget value="false"/>
78-
</properties>
79-
</component>
80-
<component id="1bfe0" class="javax.swing.JComboBox" binding="tafseerAndTranslationComboBox">
81-
<constraints>
82-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
83-
<gridbag weightx="1.0" weighty="1.0"/>
84-
</constraints>
85-
<properties/>
86-
</component>
87-
<component id="82c3f" class="javax.swing.JLabel">
88-
<constraints>
89-
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
90-
<gridbag weightx="0.0" weighty="1.0"/>
91-
</constraints>
92-
<properties>
93-
<text value="Edition"/>
94-
</properties>
95-
</component>
96-
<component id="3ac9d" class="javax.swing.JComboBox" binding="editionComboBox">
97-
<constraints>
98-
<grid row="0" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
99-
<gridbag weightx="1.0" weighty="1.0"/>
100-
</constraints>
101-
<properties/>
102-
</component>
103-
</children>
104-
</grid>
105-
<grid id="d5ada" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
106-
<margin top="0" left="0" bottom="0" right="0"/>
67+
<properties>
68+
<text value="Previous"/>
69+
<toolTipText value="Previous Aah"/>
70+
</properties>
71+
</component>
72+
<component id="b465c" class="javax.swing.JButton" binding="nextButton" default-binding="true">
10773
<constraints>
108-
<grid row="2" column="0" row-span="1" col-span="4" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
74+
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
10975
</constraints>
110-
<properties/>
111-
<border type="none"/>
112-
<children>
113-
<component id="b465c" class="javax.swing.JButton" binding="nextButton" default-binding="true">
114-
<constraints>
115-
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
116-
</constraints>
117-
<properties>
118-
<hideActionText value="true"/>
119-
<text value="Next"/>
120-
<toolTipText value="Nexit ayah"/>
121-
</properties>
122-
</component>
123-
<component id="69418" class="javax.swing.JButton" binding="previousButton">
124-
<constraints>
125-
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
126-
</constraints>
127-
<properties>
128-
<text value="Previous"/>
129-
<toolTipText value="Previous Aah"/>
130-
</properties>
131-
</component>
132-
</children>
133-
</grid>
76+
<properties>
77+
<hideActionText value="true"/>
78+
<text value="Next"/>
79+
<toolTipText value="Nexit ayah"/>
80+
</properties>
81+
</component>
13482
</children>
13583
</grid>
13684
<component id="893ab" class="javax.swing.JCheckBox" binding="autoPlayCheckBox" default-binding="true">
@@ -159,7 +107,7 @@
159107
</component>
160108
</children>
161109
</grid>
162-
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
110+
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
163111
<margin top="0" left="0" bottom="0" right="0"/>
164112
<constraints>
165113
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -189,25 +137,6 @@
189137
</component>
190138
</children>
191139
</scrollpane>
192-
<scrollpane id="6058b">
193-
<constraints>
194-
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
195-
</constraints>
196-
<properties/>
197-
<border type="none"/>
198-
<children>
199-
<component id="db36" class="javax.swing.JTextArea" binding="tafseerTextArea">
200-
<constraints/>
201-
<properties>
202-
<editable value="false"/>
203-
<focusable value="false"/>
204-
<lineWrap value="true"/>
205-
<preferredSize width="549" height="18"/>
206-
<wrapStyleWord value="true"/>
207-
</properties>
208-
</component>
209-
</children>
210-
</scrollpane>
211140
</children>
212141
</grid>
213142
</children>

src/main/java/com/anas/intellij/plugins/ayah/dialogs/AyahDetailsDialog.java

Lines changed: 5 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@
22

33
import com.anas.alqurancloudapi.Ayah;
44
import com.anas.alqurancloudapi.consts.Constants;
5-
import com.anas.alqurancloudapi.edition.Edition;
6-
import com.anas.alqurancloudapi.edition.EditionFormat;
75
import com.anas.intellij.plugins.ayah.audio.AudioPlayer;
86
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;
108

119
import javax.swing.*;
1210
import java.awt.event.KeyEvent;
1311
import java.awt.event.WindowAdapter;
1412
import java.awt.event.WindowEvent;
1513
import java.io.IOException;
16-
import java.util.Arrays;
17-
import java.util.Objects;
1814

1915
/**
2016
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
@@ -32,9 +28,6 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
3228
private JButton previousButton;
3329
private JButton nextButton;
3430
private JCheckBox autoPlayCheckBox;
35-
private JTextArea tafseerTextArea;
36-
private JComboBox<ReadableEdition> tafseerAndTranslationComboBox;
37-
private JComboBox<ReadableEdition> editionComboBox;
3831
private boolean isPlaying;
3932
private AudioPlayer audioPlayer;
4033
private Ayah ayah;
@@ -44,55 +37,21 @@ public AyahDetailsDialog(final Ayah ayah) {
4437

4538
setContentPane(contentPane);
4639
setModal(true);
47-
setSize(520, 320);
40+
setSize(500, 300);
4841
setResizable(false);
4942
setLocationRelativeTo(null);
5043
getRootPane().setDefaultButton(playButton);
5144

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();
5946

6047
addListeners();
6148
}
6249

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() {
9051
ayahTextArea.setText(ayah.getText());
9152
surahNameLabel.setText(ayah.getSurah().getName());
9253
numberOfAyahInSuarhLabel.setText("آية رقم: " + ayah.getNumberInSurah());
9354
ayahRevelationType.setText(ayah.getSurah().getRevelationType().getArabicName());
94-
// Update the tafseer or translation
95-
updateTheTauseerTextArea();
9655
}
9756

9857
private void addListeners() {
@@ -133,24 +92,6 @@ private void addListeners() {
13392
}
13493
});
13594

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-
15495
buttonCancel.addActionListener(l -> close());
15596

15697
// call onCancel() when cross is clicked
@@ -167,19 +108,6 @@ public void windowClosing(WindowEvent e) {
167108
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
168109
}
169110

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-
183111
private void close() {
184112
if (audioPlayer != null) {
185113
audioPlayer.stop();
@@ -204,7 +132,7 @@ private boolean loadTheAyah(final int ayhNumber) {
204132
try {
205133
ayah = Ayah.getAyah(ayhNumber,
206134
ayah.getEdition().getIdentifier());
207-
updateAyahDetails();
135+
updateAhaDetails();
208136
return true;
209137
} catch (final IOException ex) {
210138
JOptionPane.showMessageDialog(this,

0 commit comments

Comments
 (0)