Pārlūkot izejas kodu

More text to translate

Edgardo Palza 7 gadi atpakaļ
vecāks
revīzija
c1e9aa4889
3 mainītis faili ar 89 papildinājumiem un 44 dzēšanām
  1. 39 23
      src/ui/view/GUI.java
  2. 39 13
      src/ui/view/Languages.java
  3. 11 8
      src/ui/view/ShowedInformationPopUp.java

+ 39 - 23
src/ui/view/GUI.java

@@ -200,7 +200,7 @@ public class GUI<E> implements CategoryListener {
 	private final JToolBar toolBarHolonEl = new JToolBar();
 	private final JToolBar toolBarGraph = new JToolBar();
 
-	private final Languages languages = new Languages();
+	// private final Languages languages = new Languages();
 
 	// Languages
 	private final JMenuItem englishBtn = new JMenuItem("EN");
@@ -245,6 +245,11 @@ public class GUI<E> implements CategoryListener {
 	private String[] columnNamesMulti = { "Object", "Nr.", "Device", "Energy", "Quantity", "Activated" };
 	private String[] columnNamesSingle = { "Nr.", "Device", "Energy", "Quantity", "Activated" };
 	private String[] colNames = { "Field", "Information" };
+	private String[] comboBoxCat = { "Category", "Object", "Switch" };
+	private String warningText = "Warning";
+	private String saveBeforeNew = "Do you want to save your current data?";
+	private String eraseCategory = "Do you really want to delete the Category ";
+	private String selectObjBeforeErase = "Please select a Category or an Object in order to delete something.";
 
 	/**
 	 * Create the application.
@@ -725,7 +730,7 @@ public class GUI<E> implements CategoryListener {
 					unitGraph.repaintWithNewElement(selectedElements);
 				} // If any empty space is clicked
 				else {
-					elementGraph.setText("None ");
+					elementGraph.setText(Languages.getLanguage()[25]);
 					unitGraph.empty();
 				}
 				// if any HolonElement is double-clicked --> Edit-Mode started
@@ -737,7 +742,7 @@ public class GUI<E> implements CategoryListener {
 				// for single click and empty slot
 				if (e.getClickCount() == 1 && ele == null) {
 					selectedElements.clear();
-					holonEleNamesDisplayed = "None ";
+					holonEleNamesDisplayed = Languages.getLanguage()[25];
 				}
 				elementGraph.setText(holonEleNamesDisplayed);
 				yBTis = e.getY();
@@ -1080,8 +1085,8 @@ public class GUI<E> implements CategoryListener {
 
 		panel.add(toolBar);
 		toolBar.add(comboBox);
-		comboBox.setModel(new DefaultComboBoxModel(new String[] { "Category", "Object", "Switch" }));
-		// Add Button
+		comboBox.setModel(new DefaultComboBoxModel(comboBoxCat));
+		// Add Buttonnew DefaultComboBoxModel(comboBoxCat)
 		btnAdd.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
 
@@ -1145,11 +1150,11 @@ public class GUI<E> implements CategoryListener {
 			@Override
 			public void mousePressed(MouseEvent e) {
 				selectedElements.clear();
-				holonEleNamesDisplayed = "None ";
+				holonEleNamesDisplayed = Languages.getLanguage()[25];
 				// If any empty space is clicked
 				if (temp == null || temp.getID() != model.getSelectedObjectID()) {
 					unitGraph.empty();
-					elementGraph.setText("None ");
+					elementGraph.setText(Languages.getLanguage()[25]);
 				}
 				temp = getActualCps();
 				// Erase old data in the PropertyTable
@@ -1296,9 +1301,8 @@ public class GUI<E> implements CategoryListener {
 
 					switch (depthOfNode) {
 					case 1:
-						int dialogResult = JOptionPane.showConfirmDialog(null,
-								"Do you realy want to delete the Category " + nodeName + "?", "Warning",
-								JOptionPane.YES_NO_OPTION);
+						int dialogResult = JOptionPane.showConfirmDialog(null, eraseCategory + nodeName + "?",
+								warningText, JOptionPane.YES_NO_OPTION);
 						if (dialogResult == JOptionPane.YES_OPTION) {
 							controller.deleteCategory(nodeName);
 						}
@@ -1309,12 +1313,10 @@ public class GUI<E> implements CategoryListener {
 						break;
 
 					default:
-						JOptionPane.showMessageDialog(new JFrame(),
-								"Please select a Category or an Object in order to delete something.");
+						JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
 					}
 				} else {
-					JOptionPane.showMessageDialog(new JFrame(),
-							"Please select a Category or an Object in order to delete something.");
+					JOptionPane.showMessageDialog(new JFrame(), selectObjBeforeErase);
 				}
 				tree.repaint();
 			}
@@ -1327,13 +1329,22 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent arg0) {
+				if (model.getObjectsOnCanvas().size() != 0) {
+					int newWarning = JOptionPane.YES_NO_OPTION;
+					int dialogForNewWarning = JOptionPane.showConfirmDialog(null, saveBeforeNew, warningText,
+							newWarning);
+					if (dialogForNewWarning == JOptionPane.YES_OPTION) {
+						mntmSave.doClick();
+					}
+				}
+
 				model.getEdgesOnCanvas().removeAll(model.getEdgesOnCanvas());
 				model.getObjectsOnCanvas().removeAll(model.getObjectsOnCanvas());
 				controller.setSelectedObjectID(0);
 				controller.setSelecteEdge(null);
 				controller.setCurIteration(0);
 				unitGraph.empty();
-				elementGraph.setText("None ");
+				elementGraph.setText(Languages.getLanguage()[25]);
 				canvas.tempCps = null;
 				canvas.repaint();
 				IdCounter.resetCounter();
@@ -1415,7 +1426,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				languages.setLanguage(0);
+				Languages.setLanguage(0);
 				refreshLanguages();
 			}
 		});
@@ -1423,7 +1434,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				languages.setLanguage(1);
+				Languages.setLanguage(1);
 				refreshLanguages();
 			}
 		});
@@ -1431,7 +1442,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				languages.setLanguage(2);
+				Languages.setLanguage(2);
 				refreshLanguages();
 			}
 		});
@@ -1439,7 +1450,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				languages.setLanguage(3);
+				Languages.setLanguage(3);
 				refreshLanguages();
 			}
 		});
@@ -1447,7 +1458,7 @@ public class GUI<E> implements CategoryListener {
 
 			@Override
 			public void actionPerformed(ActionEvent e) {
-				languages.setLanguage(4);
+				Languages.setLanguage(4);
 				refreshLanguages();
 			}
 		});
@@ -1532,7 +1543,7 @@ public class GUI<E> implements CategoryListener {
 			public void stateChanged(ChangeEvent e) {
 				int i = model.getCurIteration();
 				controller.calculateStateForTimeStep(i);
-				
+
 				unitGraph.repaint();
 			}
 		});
@@ -1579,7 +1590,7 @@ public class GUI<E> implements CategoryListener {
 		if (dest.listFiles().length > 1) {
 			int dialogButton = JOptionPane.YES_NO_OPTION;
 			int dialogResult = JOptionPane.showConfirmDialog(null, "Old autosave file was found, should it be loaded?",
-					"Warning", dialogButton);
+					warningText, dialogButton);
 			if (dialogResult == JOptionPane.YES_OPTION) {
 				model.setAutoSaveNr(dest.listFiles().length - 1);
 				mntmRedo.doClick();
@@ -1880,7 +1891,7 @@ public class GUI<E> implements CategoryListener {
 	}
 
 	private void refreshLanguages() {
-		String[] tempArray = languages.getLanguage();
+		String[] tempArray = Languages.getLanguage();
 		// ToolBar
 		mnNewMenu.setText(tempArray[0]);
 		mntmNew.setText(tempArray[1]);
@@ -1916,6 +1927,11 @@ public class GUI<E> implements CategoryListener {
 		elementGraph.setText(tempArray[25]);
 		holonEleNamesDisplayed = tempArray[25];
 		resetGraphBtn.setText(tempArray[26]);
+		// Warning PopUps
+		warningText = tempArray[27];
+		saveBeforeNew = tempArray[28];
+		eraseCategory = tempArray[29];
+		selectObjBeforeErase = tempArray[30];
 	}
 
 }

+ 39 - 13
src/ui/view/Languages.java

@@ -2,18 +2,23 @@ package ui.view;
 
 public class Languages {
 
-	int languageVar = 0;
+	static int languageVar = 0;
 
-	String[] arrayEN = {
+	static String[] arrayEN = {
 			// ToolBar (0-16)
 			"File", "New", "Open", "Save", "Edit", "Undo", "Redo", "Find/Replace", "Edit showed Information", "Options",
 			"Reset Categories", "View", "View Size", "Help", "About Us", "Edit Edges", "Language",
 			// Tables (17-24)
 			"Object", "Nr.", "Device", "Energy", "Quantity", "Activated", "Field", "Information",
 			// Graph (25-26)
-			"None ", "Reset" };
+			"None ", "Reset",
+			// Warning PopUps (27-30)
+			"Warning", "Do you want to save your current data?", "Do you really want to delete the Category ",
+			"Please select a Category or an Object in order to delete something.",
+			// Edit Edges Pop Up
+			"Edit Showed Informations", "Show Total Energy of Objects", "Show Connection Properties", "Cancel" };
 
-	String[] arrayES = {
+	static String[] arrayES = {
 			// ToolBar (0-16)
 			"Archivo", "Nuevo", "Abrir", "Guardar", "Editar", "Deshacer", "Rehacer", "Buscar/Reemplazar",
 			"Editar Informacion a mostrar", "Opciones", "Resetear Categorias", "Vista", "Tamano de Vista", "Ayuda",
@@ -21,36 +26,57 @@ public class Languages {
 			// Tables (17-24)
 			"Objeto", "Nr.", "Equipo", "Enegia", "Cantidad", "Activo", "Campo", "Informacion",
 			// Graph (25-26)
-			"Vacio ", "Resetear" };
+			"Vacio ", "Resetear",
+			// Warning PopUps(27-30)
+			"Atencion", "Desea guardar su progreso?", "Esta seguro que quiere eliminar la categoria ",
+			"Por favor seleccione una categoria o un objecto para poder proceder a eliminarlo.",
+			// Edit Edges Pop Up
+			"Editar informacion a mostrar", "Mostrar energia total de los objetos",
+			"Mostrar propiedades de las conexiones", "Cancelar" };
 
-	String[] arrayDE = {
+	static String[] arrayDE = {
 			// ToolBar (0-16)
 			"File", "New", "Open", "Save", "Edit", "Undo", "Redo", "Find/Replace", "Edit showed Information", "Options",
 			"Reset Categories", "View", "View Size", "Help", "About Us", "Edit Edges", "Language",
 			// Tables (17-24)
 			"Object", "Nr.", "Device", "Energy", "Quantity", "Activated", "Field", "Information",
 			// Graph (25-26)
-			"None ", "Reset" };
+			"None ", "Reset",
+			// Warning PopUps(27-30)
+			"Warning", "Do you want to save your current data?", "Do you really want to delete the Category ",
+			"Please select a Category or an Object in order to delete something.",
+			// Edit Edges Pop Up
+			"Edit Showed Informations", "Show Total Energy of Objects", "Show Connection Properties", "Cancel" };
 
-	String[] arrayCZ = {
+	static String[] arrayCZ = {
 			// ToolBar (0-16)
 			"File", "New", "Open", "Save", "Edit", "Undo", "Redo", "Find/Replace", "Edit showed Information", "Options",
 			"Reset Categories", "View", "View Size", "Help", "About Us", "Edit Edges", "Language",
 			// Tables (17-24)
 			"Object", "Nr.", "Device", "Energy", "Quantity", "Activated", "Field", "Information",
 			// Graph (25-26)
-			"None ", "Reset" };
+			"None ", "Reset",
+			// Warning PopUps(27-30)
+			"Warning", "Do you want to save your current data?", "Do you really want to delete the Category ",
+			"Please select a Category or an Object in order to delete something.",
+			// Edit Edges Pop Up
+			"Edit Showed Informations", "Show Total Energy of Objects", "Show Connection Properties", "Cancel" };
 
-	String[] arrayZH = {
+	static String[] arrayZH = {
 			// ToolBar (0-16)
 			"File", "New", "Open", "Save", "Edit", "Undo", "Redo", "Find/Replace", "Edit showed Information", "Options",
 			"Reset Categories", "View", "View Size", "Help", "About Us", "Edit Edges", "Language",
 			// Tables (17-24)
 			"Object", "Nr.", "Device", "Energy", "Quantity", "Activated", "Field", "Information",
 			// Graph (25-26)
-			"None ", "Reset" };
+			"None ", "Reset",
+			// Warning PopUps(27-30)
+			"Warning", "Do you want to save your current data?", "Do you really want to delete the Category ",
+			"Please select a Category or an Object in order to delete something.",
+			// Edit Edges Pop Up
+			"Edit Showed Informations", "Show Total Energy of Objects", "Show Connection Properties", "Cancel" };
 
-	public String[] getLanguage() {
+	public static String[] getLanguage() {
 		switch (languageVar) {
 		case 0:
 			return arrayEN;
@@ -67,7 +93,7 @@ public class Languages {
 		}
 	}
 
-	public void setLanguage(int i) {
+	public static void setLanguage(int i) {
 		languageVar = i;
 	}
 }

+ 11 - 8
src/ui/view/ShowedInformationPopUp.java

@@ -5,6 +5,9 @@ import java.awt.BorderLayout;
 import javax.swing.JDialog;
 import javax.swing.JPanel;
 import javax.swing.border.EmptyBorder;
+
+import classes.IdCounter;
+
 import javax.swing.JCheckBox;
 import javax.swing.JButton;
 import java.awt.event.ActionListener;
@@ -33,20 +36,20 @@ public class ShowedInformationPopUp extends JDialog {
 	public ShowedInformationPopUp(MyCanvas canvas) {
 		super((java.awt.Frame) null, true);
 		setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
-		this.setTitle("Edit Showed Informations");
-		setBounds(100, 100, 277, 169);
+		this.setTitle(Languages.getLanguage()[31]);
+		setBounds(100, 100, 400, 169);
 		getContentPane().setLayout(new BorderLayout());
 		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
 		getContentPane().add(contentPanel, BorderLayout.CENTER);
 		contentPanel.setLayout(null);
 		this.canvas = canvas;
 
-		objectEnergyCheckbox = new JCheckBox("Show Total Energy of Objects");
-		objectEnergyCheckbox.setBounds(19, 19, 181, 23);
+		objectEnergyCheckbox = new JCheckBox(Languages.getLanguage()[32]);
+		objectEnergyCheckbox.setBounds(19, 19, 300, 23);
 		contentPanel.add(objectEnergyCheckbox);
 
-		connectionCheckbox = new JCheckBox("Show Connection Properties");
-		connectionCheckbox.setBounds(19, 57, 181, 23);
+		connectionCheckbox = new JCheckBox(Languages.getLanguage()[33]);
+		connectionCheckbox.setBounds(19, 57, 300, 23);
 		contentPanel.add(connectionCheckbox);
 
 		objectEnergyCheckbox.setSelected(canvas.getShowedInformation()[1]);
@@ -60,8 +63,8 @@ public class ShowedInformationPopUp extends JDialog {
 		btnOk.setBounds(169, 98, 82, 23);
 		contentPanel.add(btnOk);
 
-		JButton btnCancel = new JButton("Cancel");
-		btnCancel.setActionCommand("Cancel");
+		JButton btnCancel = new JButton(Languages.getLanguage()[34]);
+		btnCancel.setActionCommand(Languages.getLanguage()[34]);
 		btnCancel.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent arg0) {
 				dispose();