Skip to content

Commit aefcd07

Browse files
committed
Translation to English
1 parent 1352153 commit aefcd07

File tree

6 files changed

+231
-270
lines changed

6 files changed

+231
-270
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea
2+
*.iml
3+
out
4+
gen

README.md

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,40 @@
1-
# jxmlDixitAll
1+
# JXMLDixitAll
22

3-
## Resumen
3+
## Summary
44

5-
jxmlDixitAll es una aplicación Java con interfaz gráfica de usuario diseñada para gestionar un diccionario de términos y sus definiciones. Proporciona funcionalidades para agregar, modificar, eliminar y consultar términos y sus definiciones asociadas. Es una versión con la capacidad de acceso a datos en ficheros con formato XML, de tal manera que pueda ser importado y exportado fácilmente.
5+
JXMLDixitAll is a Java application with a graphical user interface designed to manage a dictionary of terms and their definitions. It provides functionalities to add, modify, delete, and consult terms and their associated definitions. It features the capability to access data in XML file format, allowing easy import and export.
66

7-
## Características
7+
## Installation
88

9-
- **Agregar Término y Definición:** Permite agregar fácilmente nuevos términos junto con sus definiciones.
10-
- **Modificar Término:** Modificar la definición de términos existentes.
11-
- **Eliminar Término:** Eliminar términos del diccionario.
12-
- **Consultar Término:** Buscar definiciones de términos específicos.
9+
To use JXMLDixitAll, you need to have Java installed on your system. Then you can download the source code of this repo and compile it using any Java IDE or compile it directly from the command line.
1310

14-
## Instalación
15-
16-
Para usar jDixitAll, necesitas tener Java instalado en tu sistema. Puedes descargar el código fuente y compilarlo utilizando cualquier IDE de Java o compilarlo directamente desde la línea de comandos.
17-
18-
1. Clona el repositorio:
11+
1. Clone the repository:
1912

2013
```bash
21-
git clone https://github.com/luisvazle/jxmlDixitAll.git
14+
git clone https://github.com/luisvazle/JXMLDixitAll.git
2215
```
23-
2. Compila el código fuente:
16+
2. Compile the source code:
2417

2518
```bash
26-
javac src/jxmlDixitAll/jxmlDixitAll.java
19+
javac src/JXMLDixitAll/JXMLDixitAll.java
2720
```
28-
3. Ejecuta la aplicación:
21+
3. Run the application:
2922

3023
```bash
31-
java src.jxmlDixitAll.jxmlDixitAll
24+
java src.JXMLDixitAll.JXMLDixitAll
3225
```
3326

34-
## Uso
35-
36-
Al ejecutar la aplicación, se mostrará una interfaz de usuario gráfica donde puedes realizar varias acciones:
27+
## Usage
3728

38-
- **Agregar:** Ingresa un término y su definición, luego haz clic en "Guardar" para agregarlo al diccionario.
39-
- **Modificar:** Ingresa el término cuya definición quieres modificar, actualiza la definición y haz clic en "Modificar".
40-
- **Eliminar:** Ingresa el término que deseas eliminar y haz clic en "Eliminar".
41-
- **Consultar:** Ingresa el término que deseas buscar y haz clic en "Consultar" para ver su definición.
29+
When you run the application, a graphical user interface will be displayed where you can perform actions described in the action buttons. Its functionality is highly intuitive.
4230

43-
La primera vez que se introduzca un término, se creará una carpeta con el archivo `datos.xml`. En cualquier uso posterior, este se actualizará.
31+
The first time a term is entered, a folder with the file `data.xml` will be created. In any subsequent use, this file will be updated.
4432

45-
## Autor
33+
## Author
4634

47-
El autor de este programa es Luís Vázquez Lema. Puedes contactar con el autor enviando un correo electrónico a la siguiente dirección: <[email protected]>
35+
The author of this programme is Luís Vázquez Lema. You can contact me by sending an email to the following address: <[email protected]>
4836

49-
## Licencia
37+
## Licence
5038

51-
Se adjunta una copia de la licencia MIT aplicable si clona el repositorio: sería el fichero `LICENSE`. Asimismo, en las primeras líneas comentadas de cada fichero `.java` también podrá visualizar el contenido de la licencia.
39+
A copy of the MIT licence is included if you clone the repository: it is the `LICENSE` file.
40+
```

src/JXMLDixitAll/JXMLDixitAll.java

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
package JXMLDixitAll;
2+
3+
import java.io.*;
4+
import javax.swing.*;
5+
import java.awt.*;
6+
import java.util.*;
7+
import javax.xml.parsers.*;
8+
import javax.xml.transform.*;
9+
import javax.xml.transform.dom.*;
10+
import javax.xml.transform.stream.*;
11+
import org.w3c.dom.*;
12+
public class JXMLDixitAll extends JFrame {
13+
private HashMap<String, String> data;
14+
private JTextField keyEntry, consultEntry;
15+
private JTextArea valueEntry, output;
16+
private JList<String> list;
17+
private DefaultListModel<String> listModel;
18+
19+
public JXMLDixitAll() {
20+
super("JXMLDixitAll");
21+
verifyDataFolder();
22+
loadData();
23+
24+
setLayout(new FlowLayout());
25+
26+
add(new JLabel("Term:"));
27+
keyEntry = new JTextField(20);
28+
add(keyEntry);
29+
30+
add(new JLabel("Definition:"));
31+
valueEntry = new JTextArea(10, 50);
32+
valueEntry.setWrapStyleWord(true);
33+
valueEntry.setLineWrap(true);
34+
JScrollPane valueEntryScroll = new JScrollPane(valueEntry);
35+
add(valueEntryScroll);
36+
37+
JButton storeButton = new JButton("Store");
38+
storeButton.addActionListener(e -> store());
39+
add(storeButton);
40+
41+
JButton modifyButton = new JButton("Modify");
42+
modifyButton.addActionListener(e -> modify());
43+
add(modifyButton);
44+
45+
JButton deleteButton = new JButton("Delete");
46+
deleteButton.addActionListener(e -> delete());
47+
add(deleteButton);
48+
49+
add(new JLabel("Term to consult:"));
50+
consultEntry = new JTextField(20);
51+
add(consultEntry);
52+
53+
JButton consultButton = new JButton("Consult");
54+
consultButton.addActionListener(e -> consult());
55+
add(consultButton);
56+
57+
add(new JLabel("Definition:"));
58+
output = new JTextArea(10, 50);
59+
output.setEditable(false);
60+
output.setWrapStyleWord(true);
61+
output.setLineWrap(true);
62+
JScrollPane outputScroll = new JScrollPane(output);
63+
add(outputScroll);
64+
65+
add(new JLabel("Stored terms:"));
66+
listModel = new DefaultListModel<>();
67+
list = new JList<>(listModel);
68+
JScrollPane listScroll = new JScrollPane(list);
69+
listScroll.setPreferredSize(new Dimension(500, 180));
70+
add(listScroll);
71+
72+
refreshList();
73+
setSize(600, 800);
74+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
75+
setVisible(true);
76+
}
77+
78+
private void verifyDataFolder() {
79+
File dir = new File("src/JXMLDixitAll/data");
80+
if (!dir.exists()) {
81+
dir.mkdirs();
82+
}
83+
}
84+
85+
private void loadData() {
86+
File xmlFile = new File("src/JXMLDixitAll/data/data.xml");
87+
if (!xmlFile.exists()) {
88+
data = new HashMap<>();
89+
return;
90+
}
91+
92+
try {
93+
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
94+
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
95+
Document doc = dBuilder.parse(xmlFile);
96+
doc.getDocumentElement().normalize();
97+
98+
data = new HashMap<>();
99+
NodeList nList = doc.getElementsByTagName("Term");
100+
101+
for (int i = 0; i < nList.getLength(); i++) {
102+
Node nNode = nList.item(i);
103+
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
104+
Element eElement = (Element) nNode;
105+
String key = eElement.getElementsByTagName("Key").item(0).getTextContent();
106+
String value = eElement.getElementsByTagName("Value").item(0).getTextContent();
107+
data.put(key, value);
108+
}
109+
}
110+
} catch (Exception e) {
111+
e.printStackTrace();
112+
}
113+
}
114+
115+
private void store() {
116+
String key = keyEntry.getText();
117+
String value = valueEntry.getText();
118+
data.put(key, value);
119+
storeData();
120+
refreshList();
121+
}
122+
123+
private void modify() {
124+
String key = keyEntry.getText();
125+
String value = valueEntry.getText();
126+
if (data.containsKey(key)) {
127+
data.put(key, value);
128+
storeData();
129+
refreshList();
130+
} else {
131+
output.setText("The term does not exist");
132+
}
133+
}
134+
135+
private void delete() {
136+
String key = keyEntry.getText();
137+
if (data.containsKey(key)) {
138+
data.remove(key);
139+
storeData();
140+
refreshList();
141+
} else {
142+
output.setText("The term does not exist");
143+
}
144+
}
145+
146+
private void consult() {
147+
String key = consultEntry.getText();
148+
if (data.containsKey(key)) {
149+
output.setText(data.get(key));
150+
} else {
151+
output.setText("The term does not exist");
152+
}
153+
}
154+
155+
private void storeData() {
156+
try {
157+
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
158+
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
159+
Document doc = dBuilder.newDocument();
160+
161+
Element rootElement = doc.createElement("List");
162+
doc.appendChild(rootElement);
163+
164+
for (Map.Entry<String, String> entry : data.entrySet()) {
165+
Element term = doc.createElement("Term");
166+
rootElement.appendChild(term);
167+
168+
Element key = doc.createElement("Key");
169+
key.appendChild(doc.createTextNode(entry.getKey()));
170+
term.appendChild(key);
171+
172+
Element value = doc.createElement("Value");
173+
value.appendChild(doc.createTextNode(entry.getValue()));
174+
term.appendChild(value);
175+
}
176+
177+
TransformerFactory transformerFactory = TransformerFactory.newInstance();
178+
Transformer transformer = transformerFactory.newTransformer();
179+
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
180+
DOMSource source = new DOMSource(doc);
181+
StreamResult result = new StreamResult(new File("src/JXMLDixitAll/data/data.xml"));
182+
183+
transformer.transform(source, result);
184+
} catch (Exception e) {
185+
e.printStackTrace();
186+
}
187+
}
188+
189+
private void refreshList() {
190+
listModel.clear();
191+
data.keySet().stream().sorted().forEach(listModel::addElement);
192+
}
193+
194+
public static void main(String[] args) {
195+
new JXMLDixitAll();
196+
}
197+
}

src/JXMLDixitAll/data/data.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<List>
3+
<Term>
4+
<Key>JXMLDixitAll</Key>
5+
<Value>The app you are now using.</Value>
6+
</Term>
7+
<Term>
8+
<Key>Luís Vázquez Lema</Key>
9+
<Value>Creator of this app.</Value>
10+
</Term>
11+
</List>

src/jxmlDixitAll/datos/datos.xml

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)