dominik.rieder 8 anos atrás
pai
commit
8fe1bf7f90

+ 2 - 1
bin/.gitignore

@@ -1,5 +1,6 @@
+/Images/
 /Interfaces/
 /exceptions/
 /tests/
 /ui/
-/Images/
+/classes/

BIN
bin/exceptions/newException1.class


BIN
bin/tests/Tests1.class


BIN
bin/tests/praktikumHolonsTestMinimal.class


BIN
bin/ui/model/Model.class


BIN
bin/ui/view/GUI$1.class


BIN
bin/ui/view/GUI$2.class


BIN
bin/ui/view/GUI.class


BIN
bin/ui/view/MyCanvas.class


+ 1 - 1
src/Interfaces/CategoryListener.java

@@ -5,5 +5,5 @@ import java.util.ArrayList;
 import java.util.Locale.Category;
 
 public interface CategoryListener {
-	public void onChange(ArrayList<ui.model.Category> categories);
+	public void onChange(ArrayList<classes.Category> categories);
 }

+ 76 - 76
src/ui/model/Category.java → src/classes/Category.java

@@ -1,76 +1,76 @@
-package ui.model;
-
-import java.util.ArrayList;
-
-import Interfaces.ComparableObject;
-
-public class Category implements ComparableObject{
-	
-	private int id;
-	private ArrayList<CpsObject> objects;
-	private String name;
-	
-	public Category(String name){
-		this.setObjects(new ArrayList<CpsObject>());
-		this.setName(name);
-		id = -1;
-	}
-
-	/**
-	 * @return the objects
-	 */
-	public ArrayList<CpsObject> getObjects() {
-		return objects;
-	}
-
-	/**
-	 * @param objects the objects to set
-	 */
-	public void setObjects(ArrayList<CpsObject> objects) {
-		this.objects = objects;
-	}
-
-	/**
-	 * @return the name
-	 */
-	public String getName() {
-		return name;
-	}
-
-	/**
-	 * @param name the name to set
-	 */
-	public void setName(String name) {
-		this.name = name;
-	}
-
-	@Override
-	public String getCompareName() {
-		return getName();
-	}
-
-	@Override
-	public int getID() {
-		return id;
-	}
-	
-//	public void addObject(HolonObject toAdd){
-//		objects.add(toAdd);
-//	}
-//	
-//	public void deleteObject(int idx){
-//		objects.remove(idx);
-//	}
-//	
-//	public ArrayList<HolonObject> getObjects(){
-//		return objects;
-//	}
-//	
-//	public void changeName(String name){
-//		this.name = name;
-//	}
-//	
-//	public String getName(){
-//		return name;
-//	}
-}
+package classes;
+
+import java.util.ArrayList;
+
+import Interfaces.ComparableObject;
+
+public class Category implements ComparableObject{
+	
+	private int id;
+	private ArrayList<CpsObject> objects;
+	private String name;
+	
+	public Category(String name){
+		this.setObjects(new ArrayList<CpsObject>());
+		this.setName(name);
+		id = -1;
+	}
+
+	/**
+	 * @return the objects
+	 */
+	public ArrayList<CpsObject> getObjects() {
+		return objects;
+	}
+
+	/**
+	 * @param objects the objects to set
+	 */
+	public void setObjects(ArrayList<CpsObject> objects) {
+		this.objects = objects;
+	}
+
+	/**
+	 * @return the name
+	 */
+	public String getName() {
+		return name;
+	}
+
+	/**
+	 * @param name the name to set
+	 */
+	public void setName(String name) {
+		this.name = name;
+	}
+
+	@Override
+	public String getCompareName() {
+		return getName();
+	}
+
+	@Override
+	public int getID() {
+		return id;
+	}
+	
+//	public void addObject(HolonObject toAdd){
+//		objects.add(toAdd);
+//	}
+//	
+//	public void deleteObject(int idx){
+//		objects.remove(idx);
+//	}
+//	
+//	public ArrayList<HolonObject> getObjects(){
+//		return objects;
+//	}
+//	
+//	public void changeName(String name){
+//		this.name = name;
+//	}
+//	
+//	public String getName(){
+//		return name;
+//	}
+}

+ 1 - 1
src/ui/model/CpsObject.java → src/classes/CpsObject.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 import java.util.ArrayList;
 

+ 1 - 1
src/ui/model/HolonElement.java → src/classes/HolonElement.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 public class HolonElement {
 

+ 1 - 1
src/ui/model/HolonObject.java → src/classes/HolonObject.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 import java.util.ArrayList;
 

+ 1 - 1
src/ui/model/HolonSwitch.java → src/classes/HolonSwitch.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 public class HolonSwitch extends CpsObject {
 	/*True, if this wire is working (capable of carrying electricity), else false*/

+ 1 - 1
src/ui/model/HolonTransformer.java → src/classes/HolonTransformer.java

@@ -1,4 +1,4 @@
-package ui.model;
+package classes;
 
 public class HolonTransformer extends CpsObject {
 

+ 17 - 17
src/ui/model/Position.java → src/classes/Position.java

@@ -1,17 +1,17 @@
-package ui.model;
-
-public class Position {
-	public int x;
-	public int y;
-	
-	public Position(int x, int y){
-		this.x = x;
-		this.y = y;
-	}
-	
-	//default Constructor
-	public Position(){
-		this.x = -1;
-		this.y = -1;
-	}
-}
+package classes;
+
+public class Position {
+	public int x;
+	public int y;
+	
+	public Position(int x, int y){
+		this.x = x;
+		this.y = y;
+	}
+	
+	//default Constructor
+	public Position(){
+		this.x = -1;
+		this.y = -1;
+	}
+}

+ 6 - 0
src/ui/controller/CategoryController.java

@@ -3,6 +3,12 @@ package ui.controller;
 import java.util.ArrayList;
 import java.util.LinkedList;
 
+import classes.Category;
+import classes.CpsObject;
+import classes.HolonObject;
+import classes.HolonSwitch;
+import classes.HolonTransformer;
+
 import com.sun.xml.internal.bind.v2.schemagen.xmlschema.List;
 
 import Interfaces.CategoryListener;

+ 2 - 2
src/ui/controller/Control.java

@@ -1,13 +1,13 @@
 package ui.controller;
 
-import ui.model.Category;
-import ui.model.CpsObject;
 import ui.model.IdCounter;
 
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.util.LinkedList;
 
+import classes.Category;
+import classes.CpsObject;
 import Interfaces.CategoryListener;
 import ui.model.Model;
 import ui.view.GUI;

+ 2 - 0
src/ui/model/Model.java

@@ -6,6 +6,8 @@ import java.util.ArrayList;
 import java.util.LinkedList;
 import java.util.List;
 
+import classes.Category;
+import classes.CpsObject;
 import ui.controller.*;
 
 public class Model {

+ 1 - 0
src/ui/model/tests.java

@@ -2,6 +2,7 @@ package ui.model;
 
 import java.util.ArrayList;
 
+import classes.Category;
 import ui.controller.CategoryController;
 
 public class tests {

+ 8 - 1
src/ui/view/GUI.java

@@ -37,7 +37,11 @@ import javax.swing.DefaultComboBoxModel;
 import javax.swing.Icon;
 import javax.swing.ImageIcon;
 
+import classes.Category;
+import classes.CpsObject;
+import classes.HolonObject;
 import Interfaces.CategoryListener;
+
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
@@ -72,6 +76,7 @@ public class GUI implements CategoryListener {
 	private JTable table_2 = new JTable();
 	private final Model model;
 	private final Control controller;
+	private RealPopUp addObjectPopUP;
 
 	private final JPanel panel = new JPanel();
 	private final JComboBox comboBox = new JComboBox();
@@ -227,12 +232,14 @@ public class GUI implements CategoryListener {
 				
 					case "Category":
 						String catName = JOptionPane.showInputDialog("Please enter a Name for Category ");
-						if(catName != ""){
+						if(catName.length() != 0){
 						controller.addNewCategory(catName);
 						}
 						break;
 							
 					default :
+						addObjectPopUP = new RealPopUp();
+						addObjectPopUP.setVisible(true);
 						addObjectAction(selectedOption, selectedNode);
 						break;
 				}

+ 3 - 2
src/ui/view/MyCanvas.java

@@ -9,8 +9,9 @@ import java.util.LinkedList;
 
 import javax.swing.ImageIcon;
 import javax.swing.JPanel;
-import ui.model.CpsObject;
-import ui.model.HolonObject;
+
+import classes.CpsObject;
+import classes.HolonObject;
 
 class MyCanvas extends JPanel implements MouseListener, MouseMotionListener 
 {

+ 94 - 0
src/ui/view/RealPopUp.java

@@ -0,0 +1,94 @@
+package ui.view;
+
+import java.awt.BorderLayout;
+import java.awt.FlowLayout;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JPanel;
+import javax.swing.border.EmptyBorder;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import javax.swing.JList;
+import javax.swing.SwingConstants;
+
+public class RealPopUp extends JDialog {
+
+	private final JPanel contentPanel = new JPanel();
+	private JTextField textField;
+	private JTextField textField_1;
+
+	/**
+	 * Launch the application.
+	 */
+	public static void main(String[] args) {
+		try {
+			RealPopUp dialog = new RealPopUp();
+			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
+			dialog.setVisible(true);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	/**
+	 * Create the dialog.
+	 */
+	public RealPopUp() {
+		setBounds(100, 100, 450, 300);
+		getContentPane().setLayout(new BorderLayout());
+		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
+		getContentPane().add(contentPanel, BorderLayout.CENTER);
+		contentPanel.setLayout(null);
+		{
+			JLabel lblName = new JLabel("Name:");
+			lblName.setHorizontalAlignment(SwingConstants.CENTER);
+			lblName.setBounds(28, 11, 76, 14);
+			contentPanel.add(lblName);
+		}
+		{
+			textField = new JTextField();
+			textField.setBounds(135, 8, 86, 20);
+			contentPanel.add(textField);
+			textField.setColumns(10);
+		}
+		{
+			JButton btnBrowseImage = new JButton("Browse Image");
+			btnBrowseImage.setBounds(10, 50, 112, 23);
+			contentPanel.add(btnBrowseImage);
+		}
+		{
+			textField_1 = new JTextField();
+			textField_1.setBounds(135, 51, 271, 20);
+			contentPanel.add(textField_1);
+			textField_1.setColumns(10);
+		}
+		{
+			JList list = new JList();
+			list.setBounds(10, 98, 242, 130);
+			contentPanel.add(list);
+		}
+		{
+			JButton btnAddDefaultElement = new JButton("Add Default Element");
+			btnAddDefaultElement.setBounds(262, 95, 144, 23);
+			contentPanel.add(btnAddDefaultElement);
+		}
+		{
+			JPanel buttonPane = new JPanel();
+			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
+			getContentPane().add(buttonPane, BorderLayout.SOUTH);
+			{
+				JButton okButton = new JButton("OK");
+				okButton.setActionCommand("OK");
+				buttonPane.add(okButton);
+				getRootPane().setDefaultButton(okButton);
+			}
+			{
+				JButton cancelButton = new JButton("Cancel");
+				cancelButton.setActionCommand("Cancel");
+				buttonPane.add(cancelButton);
+			}
+		}
+	}
+
+}