Browse Source

checkstyle

Kevin Trometer 7 years ago
parent
commit
4291b98027
3 changed files with 100 additions and 22 deletions
  1. 21 7
      src/ui/view/AddElementPopUp.java
  2. 73 15
      src/ui/view/AddObjectPopUp.java
  3. 6 0
      src/ui/view/GUI.java

+ 21 - 7
src/ui/view/AddElementPopUp.java

@@ -4,8 +4,6 @@ import java.awt.BorderLayout;
 import java.awt.Color;
 import java.awt.FlowLayout;
 import java.awt.Image;
-import java.util.ArrayList;
-
 import javax.swing.JButton;
 import javax.swing.JDialog;
 import javax.swing.JPanel;
@@ -14,22 +12,26 @@ import javax.swing.JFrame;
 import javax.swing.JLabel;
 import javax.swing.JOptionPane;
 import javax.swing.JTextField;
-import javax.swing.JComboBox;
-import javax.swing.DefaultComboBoxModel;
 import javax.swing.ImageIcon;
 
 import classes.AbstractCpsObject;
 import classes.HolonElement;
 import classes.HolonObject;
-import ui.model.Model;
-
 import java.awt.event.ActionListener;
 import java.awt.event.KeyEvent;
 import java.awt.event.KeyListener;
 import java.awt.event.ActionEvent;
-
+/**
+ * popup for adding an Holon Element to a holon Object.
+ * 
+ * @author Gruppe14
+ */
 public class AddElementPopUp extends JDialog {
 
+	/**
+	 * Serial.
+	 */
+	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
 	private JTextField elementName;
 	private JTextField providedEnergy;
@@ -39,6 +41,8 @@ public class AddElementPopUp extends JDialog {
 
 	/**
 	 * Launch the application.
+	 * 
+	 * @param args standard
 	 */
 	public static void main(String[] args) {
 		try {
@@ -173,10 +177,20 @@ public class AddElementPopUp extends JDialog {
 
 	}
 
+	/**
+	 * Sets the actual Cps.
+	 * 
+	 * @param cps actual Cps
+	 */
 	public void setActualCps(AbstractCpsObject cps) {
 		this.tempCps = cps;
 	}
 
+	/**
+	 * Returns the created Element.
+	 * 
+	 * @return the Element
+	 */
 	public HolonElement getElement() {
 		return hl;
 	}

+ 73 - 15
src/ui/view/AddObjectPopUp.java

@@ -40,8 +40,14 @@ import classes.HolonElement;
 import classes.HolonObject;
 import ui.controller.Control;
 
+/**
+ * Popup for adding a Holon Object to a Category.
+ * 
+ * @author Gruppe14
+ */
 public class AddObjectPopUp extends JDialog {
 
+	private static final long serialVersionUID = 1L;
 	private final JPanel contentPanel = new JPanel();
 	private AddElementPopUp addElement;
 	private JTextField objectName;
@@ -62,6 +68,9 @@ public class AddObjectPopUp extends JDialog {
 
 	/**
 	 * Launch the application.
+	 * 
+	 * @param args
+	 *            standard
 	 */
 	public static void main(String[] args) {
 		try {
@@ -75,6 +84,13 @@ public class AddObjectPopUp extends JDialog {
 
 	/**
 	 * Create the dialog.
+	 * 
+	 * @param edit
+	 *            true if edit
+	 * @param obj
+	 *            the object
+	 * @param cat
+	 *            the categorie
 	 */
 	public AddObjectPopUp(boolean edit, AbstractCpsObject obj, String cat) {
 		toEdit = obj;
@@ -168,8 +184,8 @@ public class AddObjectPopUp extends JDialog {
 				sourcePath.setText(filePath);
 				ImageIcon icon = new ImageIcon(
 						new ImageIcon(filePath).getImage().getScaledInstance(50, 50, Image.SCALE_SMOOTH));
-				if(icon != null)
-				lblImagePreview.setIcon(icon);
+				if (icon != null)
+					lblImagePreview.setIcon(icon);
 			}
 			sourcePath.setBounds(148, 77, 271, 20);
 			contentPanel.add(sourcePath);
@@ -199,11 +215,11 @@ public class AddObjectPopUp extends JDialog {
 			{
 
 				listModel = new DefaultListModel();
-				HolonElement hel = new HolonElement("Test", 100, 5);
-				String name = hel.getEleName();
+
 				/*
-				 * for (int i = 0; i < 11; i++) { hel.setEleName(name + i);
-				 * addElement(hel); }
+				 * HolonElement hel = new HolonElement("Test", 100, 5); String
+				 * name = hel.getEleName(); for (int i = 0; i < 11; i++) {
+				 * hel.setEleName(name + i); addElement(hel); }
 				 */
 				list = new JList(listModel);
 				scrollPane.setViewportView(list);
@@ -228,7 +244,7 @@ public class AddObjectPopUp extends JDialog {
 			btnNewButton.setBounds(270, 182, 142, 27);
 			contentPanel.add(btnNewButton);
 		}
-		
+
 		{
 			JPanel buttonPane = new JPanel();
 			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
@@ -241,8 +257,8 @@ public class AddObjectPopUp extends JDialog {
 						if (objectName.getText().length() > 0) {
 							if (sourcePath.getText().equals(filePath)) {
 								imagePath = filePath;
-								if(imageChanged)
-								copieFile();
+								if (imageChanged)
+									copieFile();
 								imageChanged = false;
 								// theObject = new
 								// HolonObject(objectName.getText());
@@ -290,19 +306,28 @@ public class AddObjectPopUp extends JDialog {
 		}
 	}
 
+	/**
+	 * adds a Holon Element.
+	 * 
+	 * @param hl
+	 *            the HolonElement
+	 */
 	public void addElement(HolonElement hl) {
 		hElements.add(hl);
 		listModel.addElement(hl.getAmount() + "x: " + hl.getEleName() + " " + hl.getEnergy() + "U");
 	}
 
+	/**
+	 * Choose the file.
+	 */
 	protected void fileChooser() {
 		// TODO Auto-generated method stub
-		JFileChooser FileChooser = new JFileChooser();
+		JFileChooser fileChooser = new JFileChooser();
 		FileNameExtensionFilter filter = new FileNameExtensionFilter("png, jpg or jpeg", "png", "jpg", "jpeg");
-		FileChooser.setFileFilter(filter);
-		int returnValue = FileChooser.showOpenDialog(null);
+		fileChooser.setFileFilter(filter);
+		int returnValue = fileChooser.showOpenDialog(null);
 		if (returnValue == JFileChooser.APPROVE_OPTION) {
-			selectedFile = FileChooser.getSelectedFile();
+			selectedFile = fileChooser.getSelectedFile();
 			filePath = selectedFile.getAbsolutePath();
 			sourcePath.setText(filePath);
 			ImageIcon icon = new ImageIcon(
@@ -315,6 +340,9 @@ public class AddObjectPopUp extends JDialog {
 
 	}
 
+	/**
+	 * Copies the File.
+	 */
 	protected void copieFile() {
 		InputStream inStream = null;
 		OutputStream outStream = null;
@@ -339,15 +367,30 @@ public class AddObjectPopUp extends JDialog {
 			if (outStream != null)
 				outStream.close();
 			System.out.println("File Copied..");
-		} catch (IOException e1) {
-			e1.printStackTrace();
+		} catch (IOException eex) {
+			eex.printStackTrace();
 		}
 	}
 
+	/**
+	 * Edit the Information.
+	 * 
+	 * @param obj
+	 *            the CpsObject
+	 */
 	public void editInformation(HolonObject obj) {
 		objectName.setText(obj.getName());
 	}
 
+	/**
+	 * Get Jar Containing Folder.
+	 * 
+	 * @param aclass
+	 *            aClass
+	 * @return String
+	 * @throws Exception
+	 *             Exception
+	 */
 	public static String getJarContainingFolder(Class aclass) throws Exception {
 		CodeSource codeSource = aclass.getProtectionDomain().getCodeSource();
 
@@ -364,14 +407,29 @@ public class AddObjectPopUp extends JDialog {
 		return jarFile.getParentFile().getAbsolutePath();
 	}
 
+	/**
+	 * Return the Object.
+	 * 
+	 * @return the CpsObject
+	 */
 	public HolonObject getObject() {
 		return theObject;
 	}
 
+	/**
+	 * Sets the Controller.
+	 * 
+	 * @param controller the controller
+	 */
 	public void setController(Control controller) {
 		this.controller = controller;
 	}
 
+	/**
+	 * Set the Category.
+	 * 
+	 * @param cat the Category
+	 */
 	public void setCategory(String cat) {
 		givenCategory = cat;
 	}

+ 6 - 0
src/ui/view/GUI.java

@@ -73,6 +73,12 @@ import ui.model.Model;
 import ui.model.IdCounter;
 import ui.model.IdCounterElem;;
 
+/**
+ * Graphical User Interface.
+ * @author Gruppe14
+ * 
+ * @param <E> Generic
+ */
 public class GUI<E> implements CategoryListener {
 
 	private JFrame frmCyberPhysical;