Browse Source

Merge branch 'Ohne_Drag_and_Drop' of https://git.tk.informatik.tu-darmstadt.de/carlos.garcia/praktikum-holons.git into Ohne_Drag_and_Drop

Kevin Trometer 8 years ago
parent
commit
d36cb9e8d4
2 changed files with 46 additions and 2 deletions
  1. 25 0
      src/ui/view/DefaulTable.java
  2. 21 2
      src/ui/view/GUI.java

+ 25 - 0
src/ui/view/DefaulTable.java

@@ -0,0 +1,25 @@
+package ui.view;
+
+import javax.swing.table.DefaultTableModel;
+
+public class DefaulTable extends DefaultTableModel {
+	private boolean[][] editable_cells; // 2d array to represent rows and
+										// columns
+
+	DefaulTable(int rows, int cols) { // constructor
+		super(rows, cols);
+		this.editable_cells = new boolean[rows][cols];
+	}
+
+	@Override
+	public boolean isCellEditable(int row, int column) { // custom //
+														// isCellEditable
+															// function
+		return this.editable_cells[row][column];
+	}
+
+	public void setCellEditable(int row, int col, boolean value) {
+		this.editable_cells[row][col] = value; // set cell true/false
+		this.fireTableCellUpdated(row, col);
+	}
+}

+ 21 - 2
src/ui/view/GUI.java

@@ -115,7 +115,7 @@ public class GUI implements CategoryListener {
 
 	private JTable tableProperties = new JTable();
 	private JPanel graphLabel = new JPanel();
-	private DefaultTableModel tableModelProperties = new DefaultTableModel();
+	private DefaulTable tableModelProperties;
 	private final JScrollPane scrollProperties = new JScrollPane();
 
 	// In this section is the graph for the selected HolonElement of the clicked
@@ -263,12 +263,12 @@ public class GUI implements CategoryListener {
 
 		// Set up of the Properties section
 		Object[] colNames = { "Field", "Information" };
+		tableModelProperties = new DefaulTable(100, colNames.length);
 		tableModelProperties.setColumnIdentifiers(colNames);
 		tableProperties.setModel(tableModelProperties);
 		tableProperties.setFillsViewportHeight(true);
 		tableProperties.setCellSelectionEnabled(true);
 		tableProperties.setColumnSelectionAllowed(true);
-
 		// Set up of the Graph section
 
 		Object[] tempText = { "Here comes the graph for each clicked HolonElement" };
@@ -351,6 +351,17 @@ public class GUI implements CategoryListener {
 				}
 			}
 		});
+
+		tableProperties.addMouseListener(new MouseAdapter() {
+			public void mousePressed(MouseEvent e) {
+				int selectedX = (int) Math
+						.floor(e.getX() / (tableProperties.getColumnModel().getTotalColumnWidth() / 2));
+				int selectedY = (int) Math.floor(e.getY() / 16);
+				if (tableModelProperties.isCellEditable(selectedY, selectedX) && e.getClickCount() == 2) {
+					System.out.println("QUEEE");
+				}
+			}
+		});
 		frmCyberPhysical.getContentPane().setLayout(new BorderLayout(0, 0));
 
 		TreeCellRenderer customRenderer = new TreeCellRenderer() {
@@ -558,6 +569,7 @@ public class GUI implements CategoryListener {
 				if (canvas.tempCps != null) {
 					Object[] tempName = { "Name", canvas.tempCps.getName() };
 					tableModelProperties.addRow(tempName);
+					tableModelProperties.setCellEditable(0, 1, true);
 					Object[] tempId = { "ID", canvas.tempCps.getID() };
 					tableModelProperties.addRow(tempId);
 					if (canvas.tempCps.getClass() == HolonObject.class) {
@@ -863,11 +875,18 @@ public class GUI implements CategoryListener {
 		deleteRows();
 		if (canvas.dataSelected != null) {
 			fillElementTable(canvas.dataSelected);
+<<<<<<< HEAD
+		} /**
+			 * hinzugef�gt damit man auch nach dem objekt platziert wurde
+			 * elemente von Objekten in Kategorien ansehen kann
+			 */
+=======
 		}
 		/**
 		 * hinzugef�gt damit man auch nach dem objekt platziert wurde elemente
 		 * von Objekten in Kategorien ansehen kann
 		 */
+>>>>>>> 20576a4b5d0fa38909435f477849c16d57f2d047
 		canvas.dataSelected = null;
 
 	}