cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/3] cayenne git commit: CAY-2439
Date Sat, 07 Jul 2018 15:12:28 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 01112fe60 -> 0b1f5af0f


CAY-2439


Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/30041fe9
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/30041fe9
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/30041fe9

Branch: refs/heads/master
Commit: 30041fe958bbfc2a417732d22396081bd201621d
Parents: 22c2e78
Author: Arseni Bulatski <ancarseni@gmail.com>
Authored: Sat Jul 7 15:41:37 2018 +0300
Committer: Arseni Bulatski <ancarseni@gmail.com>
Committed: Sat Jul 7 15:41:37 2018 +0300

----------------------------------------------------------------------
 .../cayenne/modeler/ProjectTreeModel.java       | 48 +++++++++++++++-----
 .../modeler/dialog/datadomain/FilterDialog.java |  5 +-
 2 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/30041fe9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
index c09b6c4..4c0e898 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
@@ -19,22 +19,16 @@
 
 package org.apache.cayenne.modeler;
 
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.Map;
+import org.apache.cayenne.configuration.DataNodeDescriptor;
+import org.apache.cayenne.map.*;
+import org.apache.cayenne.project.Project;
 
 import javax.swing.tree.DefaultMutableTreeNode;
 import javax.swing.tree.DefaultTreeModel;
 import javax.swing.tree.MutableTreeNode;
-
-import org.apache.cayenne.configuration.DataNodeDescriptor;
-import org.apache.cayenne.map.DataMap;
-import org.apache.cayenne.map.DbEntity;
-import org.apache.cayenne.map.Embeddable;
-import org.apache.cayenne.map.ObjEntity;
-import org.apache.cayenne.map.Procedure;
-import org.apache.cayenne.map.QueryDescriptor;
-import org.apache.cayenne.project.Project;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.Map;
 
 /**
  * ProjectTreeModel is a model of Cayenne project tree.
@@ -186,6 +180,36 @@ public class ProjectTreeModel extends DefaultTreeModel {
 		return null;
 	}
 
+	private int getCount(Object parent, Object item) {
+		int cnt = -1;
+		for(int i = 0; i < super.getChildCount(parent); i++) {
+			DefaultMutableTreeNode child = (DefaultMutableTreeNode) super.getChild(parent, i);
+			if(filter.pass(child)) {
+				cnt++;
+			}
+			if(child == item){
+				return cnt;
+			}
+		}
+		return cnt;
+	}
+
+	public void removeNodeFromParent(MutableTreeNode node) {
+		MutableTreeNode parent = (MutableTreeNode)node.getParent();
+
+		if(parent == null) {
+			throw new IllegalArgumentException("node does not have a parent.");
+		}
+
+		int[] childIndex = new int[1];
+		Object[] removedArray = new Object[1];
+
+		childIndex[0] = getCount(parent, node);
+		parent.remove(parent.getIndex(node));
+		removedArray[0] = node;
+		nodesWereRemoved(parent, childIndex, removedArray);
+	}
+
 	class Filter {
 		private Map<String, Boolean> filterMap;
 		boolean pass = true;

http://git-wip-us.apache.org/repos/asf/cayenne/blob/30041fe9/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
index a34c72b..5be12a6 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
@@ -21,8 +21,7 @@ package org.apache.cayenne.modeler.dialog.datadomain;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.swing.BindingBuilder;
 
-import javax.swing.JCheckBox;
-import javax.swing.JPopupMenu;
+import javax.swing.*;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 
@@ -172,7 +171,7 @@ public class FilterDialog extends JPopupMenu {
 		public void actionPerformed(ActionEvent e) {
 			filterController.getFilterMap().put(key, ((JCheckBox) e.getSource()).isSelected());
 			filterController.getTreeModel().setFiltered(filterController.getFilterMap());
-            filterController.getTree().updateUI();
+			filterController.getTree().updateUI();
             checkAllStates();
 		}
 	}


Mime
View raw message