mirror of
https://github.com/anas-elgarhy/Ayah-intellij.git
synced 2024-08-15 00:43:43 +00:00
Compare commits
7 commits
0a5e9e4b50
...
148268704f
Author | SHA1 | Date | |
---|---|---|---|
|
148268704f | ||
|
8e7a83a0d7 | ||
|
b8453d362e | ||
4d67f7b2dc | |||
0e369b93fd | |||
|
7476c245c8 | ||
|
eaae0cef34 |
4 changed files with 26 additions and 169 deletions
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
|
@ -29,7 +29,7 @@ jobs:
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Gradle Wrapper Validation
|
- name: Gradle Wrapper Validation
|
||||||
uses: gradle/wrapper-validation-action@v1.0.6
|
uses: gradle/wrapper-validation-action@v1.1.0
|
||||||
|
|
||||||
# Run verifyPlugin and test Gradle tasks
|
# Run verifyPlugin and test Gradle tasks
|
||||||
test:
|
test:
|
||||||
|
|
|
@ -5,8 +5,8 @@ fun properties(key: String) = project.findProperty(key).toString()
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id("java")
|
id("java")
|
||||||
id("org.jetbrains.intellij") version "1.14.2"
|
id("org.jetbrains.intellij") version "1.15.0"
|
||||||
id("org.jetbrains.changelog") version "2.1.0"
|
id("org.jetbrains.changelog") version "2.1.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
version = properties("pluginVersion")
|
version = properties("pluginVersion")
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<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">
|
<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">
|
||||||
<margin top="10" left="10" bottom="10" right="10"/>
|
<margin top="10" left="10" bottom="10" right="10"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<xy x="48" y="54" width="836" height="472"/>
|
<xy x="48" y="54" width="577" height="355"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<maximumSize width="500" height="300"/>
|
<maximumSize width="500" height="300"/>
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<properties/>
|
<properties/>
|
||||||
<border type="none"/>
|
<border type="none"/>
|
||||||
<children>
|
<children>
|
||||||
<grid id="9538f" layout-manager="GridLayoutManager" row-count="3" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="9538f" layout-manager="GridLayoutManager" row-count="2" column-count="4" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<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"/>
|
<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,59 +60,18 @@
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="e3ffd" layout-manager="GridBagLayout">
|
<component id="69418" class="javax.swing.JButton" binding="previousButton">
|
||||||
<constraints>
|
<constraints>
|
||||||
<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"/>
|
<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"/>
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="c14dc" class="javax.swing.JLabel">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
<gridbag weightx="0.0" weighty="1.0"/>
|
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<text value="Tafseer/Translation"/>
|
<text value="Previous"/>
|
||||||
<verifyInputWhenFocusTarget value="false"/>
|
<toolTipText value="Previous Aah"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="1bfe0" class="javax.swing.JComboBox" binding="tafseerAndTranslationComboBox">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
<gridbag weightx="1.0" weighty="1.0"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
<component id="82c3f" class="javax.swing.JLabel">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
<gridbag weightx="0.0" weighty="1.0"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="Edition"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="3ac9d" class="javax.swing.JComboBox" binding="editionComboBox">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
<gridbag weightx="1.0" weighty="1.0"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
</component>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
<grid id="d5ada" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="b465c" class="javax.swing.JButton" binding="nextButton" default-binding="true">
|
<component id="b465c" class="javax.swing.JButton" binding="nextButton" default-binding="true">
|
||||||
<constraints>
|
<constraints>
|
||||||
<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"/>
|
<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"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
<properties>
|
<properties>
|
||||||
<hideActionText value="true"/>
|
<hideActionText value="true"/>
|
||||||
|
@ -120,17 +79,6 @@
|
||||||
<toolTipText value="Nexit ayah"/>
|
<toolTipText value="Nexit ayah"/>
|
||||||
</properties>
|
</properties>
|
||||||
</component>
|
</component>
|
||||||
<component id="69418" class="javax.swing.JButton" binding="previousButton">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="Previous"/>
|
|
||||||
<toolTipText value="Previous Aah"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<component id="893ab" class="javax.swing.JCheckBox" binding="autoPlayCheckBox" default-binding="true">
|
<component id="893ab" class="javax.swing.JCheckBox" binding="autoPlayCheckBox" default-binding="true">
|
||||||
|
@ -159,7 +107,7 @@
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
<grid id="e3588" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
<grid id="e3588" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
<margin top="0" left="0" bottom="0" right="0"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<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"/>
|
<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 @@
|
||||||
</component>
|
</component>
|
||||||
</children>
|
</children>
|
||||||
</scrollpane>
|
</scrollpane>
|
||||||
<scrollpane id="6058b">
|
|
||||||
<constraints>
|
|
||||||
<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"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="db36" class="javax.swing.JTextArea" binding="tafseerTextArea">
|
|
||||||
<constraints/>
|
|
||||||
<properties>
|
|
||||||
<editable value="false"/>
|
|
||||||
<focusable value="false"/>
|
|
||||||
<lineWrap value="true"/>
|
|
||||||
<preferredSize width="549" height="18"/>
|
|
||||||
<wrapStyleWord value="true"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
</children>
|
|
||||||
</scrollpane>
|
|
||||||
</children>
|
</children>
|
||||||
</grid>
|
</grid>
|
||||||
</children>
|
</children>
|
||||||
|
|
|
@ -2,19 +2,15 @@ package com.anas.intellij.plugins.ayah.dialogs;
|
||||||
|
|
||||||
import com.anas.alqurancloudapi.Ayah;
|
import com.anas.alqurancloudapi.Ayah;
|
||||||
import com.anas.alqurancloudapi.consts.Constants;
|
import com.anas.alqurancloudapi.consts.Constants;
|
||||||
import com.anas.alqurancloudapi.edition.Edition;
|
|
||||||
import com.anas.alqurancloudapi.edition.EditionFormat;
|
|
||||||
import com.anas.intellij.plugins.ayah.audio.AudioPlayer;
|
import com.anas.intellij.plugins.ayah.audio.AudioPlayer;
|
||||||
import com.anas.intellij.plugins.ayah.audio.PlayerListener;
|
import com.anas.intellij.plugins.ayah.audio.PlayerListener;
|
||||||
import com.anas.intellij.plugins.ayah.settings.userinterface.ReadableEdition;
|
import javazoom.jl.player.advanced.PlaybackEvent;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
|
* @author <a href="https://github.com/anas-elgarhy">Anas Elgarhy</a>
|
||||||
|
@ -32,9 +28,6 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
||||||
private JButton previousButton;
|
private JButton previousButton;
|
||||||
private JButton nextButton;
|
private JButton nextButton;
|
||||||
private JCheckBox autoPlayCheckBox;
|
private JCheckBox autoPlayCheckBox;
|
||||||
private JTextArea tafseerTextArea;
|
|
||||||
private JComboBox<ReadableEdition> tafseerAndTranslationComboBox;
|
|
||||||
private JComboBox<ReadableEdition> editionComboBox;
|
|
||||||
private boolean isPlaying;
|
private boolean isPlaying;
|
||||||
private AudioPlayer audioPlayer;
|
private AudioPlayer audioPlayer;
|
||||||
private Ayah ayah;
|
private Ayah ayah;
|
||||||
|
@ -44,55 +37,21 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
||||||
|
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
setModal(true);
|
setModal(true);
|
||||||
setSize(520, 320);
|
setSize(500, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
setLocationRelativeTo(null);
|
setLocationRelativeTo(null);
|
||||||
getRootPane().setDefaultButton(playButton);
|
getRootPane().setDefaultButton(playButton);
|
||||||
|
|
||||||
try {
|
updateAhaDetails();
|
||||||
setupTheUI();
|
|
||||||
} catch (final IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
JOptionPane.showMessageDialog(this, "Error while loading the ayah details",
|
|
||||||
"Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
addListeners();
|
addListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupTheUI() throws IOException {
|
private void updateAhaDetails() {
|
||||||
previousButton.setEnabled(ayah.getNumber() != 1 && ayah.getSurah().getNumber() != 1);
|
|
||||||
nextButton.setEnabled(ayah.getNumber() != Constants.AYAHS_COUNT && ayah.getSurah().getNumber() != Constants.SURAS_COUNT);
|
|
||||||
|
|
||||||
|
|
||||||
final var tafserAndTranslationComboBoxModel = new DefaultComboBoxModel<ReadableEdition>();
|
|
||||||
final var editionComboBoxModel = new DefaultComboBoxModel<ReadableEdition>();
|
|
||||||
|
|
||||||
Arrays.stream(Edition.getEditions()).forEach(edition -> {
|
|
||||||
if (edition.getFormat() == EditionFormat.AUDIO) {
|
|
||||||
editionComboBoxModel.addElement(new ReadableEdition(edition));
|
|
||||||
} else {
|
|
||||||
tafserAndTranslationComboBoxModel.addElement(new ReadableEdition(edition));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
tafseerAndTranslationComboBox.setModel(tafserAndTranslationComboBoxModel);
|
|
||||||
editionComboBox.setModel(editionComboBoxModel);
|
|
||||||
|
|
||||||
// Set the default selected item for the editionComboBox
|
|
||||||
editionComboBoxModel.setSelectedItem(new ReadableEdition(ayah.getEdition()));
|
|
||||||
// Set the actual information about the ayah in the UI
|
|
||||||
updateAyahDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateAyahDetails() {
|
|
||||||
// Update the ayah details
|
|
||||||
ayahTextArea.setText(ayah.getText());
|
ayahTextArea.setText(ayah.getText());
|
||||||
surahNameLabel.setText(ayah.getSurah().getName());
|
surahNameLabel.setText(ayah.getSurah().getName());
|
||||||
numberOfAyahInSuarhLabel.setText("آية رقم: " + ayah.getNumberInSurah());
|
numberOfAyahInSuarhLabel.setText("آية رقم: " + ayah.getNumberInSurah());
|
||||||
ayahRevelationType.setText(ayah.getSurah().getRevelationType().getArabicName());
|
ayahRevelationType.setText(ayah.getSurah().getRevelationType().getArabicName());
|
||||||
// Update the tafseer or translation
|
|
||||||
updateTheTauseerTextArea();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addListeners() {
|
private void addListeners() {
|
||||||
|
@ -133,24 +92,6 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tafseerAndTranslationComboBox.addActionListener(e -> {
|
|
||||||
updateTheTauseerTextArea();
|
|
||||||
});
|
|
||||||
|
|
||||||
editionComboBox.addActionListener(e -> {
|
|
||||||
final var selectedEdition = ((ReadableEdition) Objects.requireNonNull(
|
|
||||||
editionComboBox.getSelectedItem())).getEdition();
|
|
||||||
try {
|
|
||||||
ayah = Ayah.getAyah(ayah.getNumber(), selectedEdition);
|
|
||||||
updateAyahDetails();
|
|
||||||
} catch (final IOException ioException) {
|
|
||||||
ioException.printStackTrace();
|
|
||||||
JOptionPane.showMessageDialog(this,
|
|
||||||
"Error while loading the ayah - check your internet connection",
|
|
||||||
"Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttonCancel.addActionListener(l -> close());
|
buttonCancel.addActionListener(l -> close());
|
||||||
|
|
||||||
// call onCancel() when cross is clicked
|
// call onCancel() when cross is clicked
|
||||||
|
@ -167,19 +108,6 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
||||||
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTheTauseerTextArea() {
|
|
||||||
final var selectedEdition = ((ReadableEdition) Objects.requireNonNull(
|
|
||||||
tafseerAndTranslationComboBox.getSelectedItem())).getEdition();
|
|
||||||
try {
|
|
||||||
tafseerTextArea.setText(Ayah.getAyah(ayah.getNumber(), selectedEdition).getText());
|
|
||||||
} catch (final IOException ioException) {
|
|
||||||
ioException.printStackTrace();
|
|
||||||
JOptionPane.showMessageDialog(this,
|
|
||||||
"Error while loading the tafseer - check your internet connection",
|
|
||||||
"Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void close() {
|
private void close() {
|
||||||
if (audioPlayer != null) {
|
if (audioPlayer != null) {
|
||||||
audioPlayer.stop();
|
audioPlayer.stop();
|
||||||
|
@ -204,7 +132,7 @@ public class AyahDetailsDialog extends JDialog implements PlayerListener {
|
||||||
try {
|
try {
|
||||||
ayah = Ayah.getAyah(ayhNumber,
|
ayah = Ayah.getAyah(ayhNumber,
|
||||||
ayah.getEdition().getIdentifier());
|
ayah.getEdition().getIdentifier());
|
||||||
updateAyahDetails();
|
updateAhaDetails();
|
||||||
return true;
|
return true;
|
||||||
} catch (final IOException ex) {
|
} catch (final IOException ex) {
|
||||||
JOptionPane.showMessageDialog(this,
|
JOptionPane.showMessageDialog(this,
|
||||||
|
|
Loading…
Reference in a new issue