Browse Source

Fixes PopertyTable staying editable, when Table is closed

Andreas T. Meyer-Berg 6 years ago
parent
commit
738dd4c31d
3 changed files with 35 additions and 0 deletions
  1. 20 0
      src/ui/model/Model.java
  2. 14 0
      src/ui/view/AbstractCanvas.java
  3. 1 0
      src/ui/view/GUI.java

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

@@ -5,15 +5,18 @@ import TypeAdapter.ColorAdapter;
 import TypeAdapter.PairAdapter;
 import TypeAdapter.PositionAdapter;
 import classes.*;
+
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.JsonObject;
+
 import interfaces.CategoryListener;
 import interfaces.GraphListener;
 import interfaces.ObjectListener;
 import ui.view.*;
 
 import javax.swing.*;
+
 import java.awt.*;
 import java.util.*;
 import java.util.List;
@@ -54,6 +57,9 @@ public class Model {
     private float maxCapacity;
     // Table for HolonElements --> all cells are editable
     private JTable tableHolonElement;
+    /** Table for the properties of HolonObjects, Edges etc */
+    private JTable propertyTable;
+    
     private ArrayList<GraphListener> graphListeners = new ArrayList();
     // Iteration Speed
     private int timerSpeed = 1000;
@@ -697,6 +703,20 @@ public class Model {
     public void setTableHolonElement(JTable tableHolonElement) {
         this.tableHolonElement = tableHolonElement;
     }
+    
+	/**
+	 * @return the tableProperties
+	 */
+	public JTable getTableProperties() {
+		return propertyTable;
+	}
+	
+	/**
+	 * @return the tableProperties
+	 */
+	public void setTableProperties(JTable propertyTable) {
+		this.propertyTable = propertyTable;
+	}
 
     /**
      * Returns the sCale (Scale for the Images).

+ 14 - 0
src/ui/view/AbstractCanvas.java

@@ -661,6 +661,9 @@ public abstract class AbstractCanvas extends JPanel {
 		cps.setPosition(p.x-x_off, p.y-y_off);
 	}
 	
+	/**
+	 * Stops Editing in HolonElementTable and PropertyTable
+	 */
 	protected void stopEditing() {
 		/**
 		 * Stop Editing, if mouse exits the Table
@@ -675,5 +678,16 @@ public abstract class AbstractCanvas extends JPanel {
 		        cellEditor.cancelCellEditing();
 		    }
 		}
+		
+		JTable propertys = model.getTableProperties();
+		cellEditor = propertys.getCellEditor();
+		if (cellEditor != null) {
+		    if (cellEditor.getCellEditorValue() != null) {
+		    	/** TODO: Maybe try to save current Data */
+		        cellEditor.stopCellEditing();
+		    } else {
+		        cellEditor.cancelCellEditing();
+		    }
+		}
 	}
 }

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

@@ -300,6 +300,7 @@ public class GUI implements CategoryListener {
 		control.initListener(this);
 		controller.setCanvas(canvas);
 		model.setConsole(console);
+		model.setTableProperties(tableProperties);
 		algorithmMenu = new AlgorithmMenu(model, control, this);
 		initialize();
 		updateCategories(model.getCategories());