cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r1515560 - in /cayenne/main/trunk/modeler/cayenne-modeler/src/main: java/org/apache/cayenne/modeler/ java/org/apache/cayenne/modeler/action/ java/org/apache/cayenne/modeler/dialog/datadomain/ java/org/apache/cayenne/modeler/editor/ resource...
Date Mon, 19 Aug 2013 19:05:10 GMT
Author: aadamchik
Date: Mon Aug 19 19:05:10 2013
New Revision: 1515560

URL: http://svn.apache.org/r1515560
Log:
CAY-1841 Filters for Left-hand project navigator (kind of like Eclipse panel filters) to show/hide
everything/objentities/dbentities/queries

patch by Ilya Vasiuk (original by Artiom Kravchenko)

Added:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CollapseTreeAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExpandTreeAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FilterAction.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-filter.png
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-collapse.png
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-expand.png
Modified:
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
    cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java?rev=1515560&r1=1515559&r2=1515560&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/CayenneModelerController.java
Mon Aug 19 19:05:10 2013
@@ -60,6 +60,7 @@ public class CayenneModelerController ex
     protected ProjectController projectController;
 
     protected CayenneModelerFrame frame;
+	private EditorView editorView;
     
     public CayenneModelerController(){}
 
@@ -211,7 +212,8 @@ public class CayenneModelerController ex
 
         projectController.setProject(project);
 
-        frame.setView(new EditorView(projectController));
+        editorView = new EditorView(projectController);
+        frame.setView(editorView);
 
         projectController.projectOpened();
         application.getActionManager().projectOpened();
@@ -260,7 +262,11 @@ public class CayenneModelerController ex
         }
     }
 
-    /** Adds path to the list of last opened projects in preferences. */
+    public EditorView getEditorView() {
+    	return editorView;
+    }
+
+	/** Adds path to the list of last opened projects in preferences. */
     public void addToLastProjListAction(String path) {
 
         Preferences frefLastProjFiles = ModelerPreferences.getLastProjFilesPref();
@@ -359,4 +365,6 @@ public class CayenneModelerController ex
         getLastDirectory().setDirectory(new File(newPath));
         frame.fireRecentFileListChanged();
     }
+
+	
 }

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java?rev=1515560&r1=1515559&r2=1515560&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeModel.java
Mon Aug 19 19:05:10 2013
@@ -21,20 +21,30 @@ package org.apache.cayenne.modeler;
 
 import java.util.Comparator;
 import java.util.Enumeration;
+import java.util.HashMap;
 
 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.project.Project;
+import org.apache.cayenne.query.Query;
+
 
 /**
  * ProjectTreeModel is a model of Cayenne project tree.
  */
 public class ProjectTreeModel extends DefaultTreeModel {
 
-   
-    /**
+	private Filter filter=new Filter();
+
+	/**
      * Constructor for ProjectTreeModel.
      */
     public ProjectTreeModel(Project project) {
@@ -104,9 +114,13 @@ public class ProjectTreeModel extends De
                     ins--;
                 }
             }
-
+           try{
             // insert
             insertNodeInto(treeNode, parent, ins);
+           }
+           catch(NullPointerException e){
+        	   
+           }
         }
     }
 
@@ -152,4 +166,75 @@ public class ProjectTreeModel extends De
 
         return currentNode;
     }
-}
+    
+    
+    public void setFiltered(HashMap<String,Boolean> filterMap) {
+    	
+    	filter.setFilterMap(filterMap);
+        Object[] path = {root};
+        int[] childIndices  = new int[root.getChildCount()];      
+        Object[] children  = new Object[root.getChildCount()];
+       
+        for (int i = 0; i < root.getChildCount(); i++) {
+        	childIndices[i] = i;
+        	children[i] = root.getChildAt(i);
+        }
+        
+        fireTreeStructureChanged(this,path,childIndices, children);	
+    }
+    
+    
+      public int getChildCount(Object parent) {
+    	  int realCount = super.getChildCount(parent), filterCount =0;
+        
+    	  for (int i=0; i<realCount; i++) {
+    		  DefaultMutableTreeNode dmtn = (DefaultMutableTreeNode)super.getChild(parent,i);
+    		  if (filter.pass(dmtn)) { 
+    			  filterCount++;
+    		  }
+    	  }
+    	  return filterCount;
+      }
+      
+      public Object getChild(Object parent, int index) {
+    	  int cnt=-1;
+    	  for (int i=0; i<super.getChildCount(parent); i++) {
+    		  Object child = super.getChild(parent,i);
+    		  if (filter.pass(child)) { 
+    			  cnt++;
+    		  }
+    		  if (cnt==index) { 
+    			  return child;
+    		  }
+    	  }
+    	  return null;
+      }
+      
+      class Filter {
+    	  private HashMap<String, Boolean> filterMap;
+    	  boolean pass=true;
+		
+    	  public void setFilterMap(HashMap<String, Boolean> filterMap) {
+    		  this.filterMap=filterMap;
+    		  pass=false;
+    	  }
+    	  
+    	  public boolean pass(Object obj) { 
+    		 Object root = ((DefaultMutableTreeNode) obj).getUserObject();
+    		 Object firstLeaf = ((DefaultMutableTreeNode) obj).getFirstLeaf().getUserObject();
+    		 
+    		 return ((pass) ||
+    				 (root instanceof DataMap) ||
+    				 (root instanceof DataNodeDescriptor) ||
+    				 (firstLeaf instanceof DbEntity   && filterMap.get("dbEntity"))   ||
+    				 (firstLeaf instanceof ObjEntity  && filterMap.get("objEntity"))  ||
+    				 (firstLeaf instanceof Embeddable && filterMap.get("embeddable")) ||
+    				 (firstLeaf instanceof Query      && filterMap.get("query"))      ||
+    				 (firstLeaf instanceof Procedure  && filterMap.get("procedure")));
+    	  }
+    	  
+    	  public boolean isFiltered() { 
+    		  return pass; 
+    	  }
+    	}   
+}
\ No newline at end of file

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java?rev=1515560&r1=1515559&r2=1515560&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/ProjectTreeView.java
Mon Aug 19 19:05:10 2013
@@ -204,7 +204,7 @@ public class ProjectTreeView extends JTr
     /**
      * Returns tree model cast to ProjectTreeModel.
      */
-    ProjectTreeModel getProjectModel() {
+    public ProjectTreeModel getProjectModel() {
         return (ProjectTreeModel) getModel();
     }
 

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CollapseTreeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CollapseTreeAction.java?rev=1515560&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CollapseTreeAction.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/CollapseTreeAction.java
Mon Aug 19 19:05:10 2013
@@ -0,0 +1,27 @@
+package org.apache.cayenne.modeler.action;
+
+import java.awt.event.ActionEvent;
+
+import org.apache.cayenne.modeler.Application;
+import org.apache.cayenne.modeler.util.CayenneAction;
+
+public class CollapseTreeAction extends CayenneAction {
+	private final static String COLLAPSE = "collapse";
+	
+	public static String getActionName() {
+		return "Collapse tree";
+	}
+	 
+	public String getIconName() {
+		return "icon-tree-collapse.png";
+	}
+
+	public CollapseTreeAction(Application application) {
+		super(getActionName(), application);
+	}
+
+	@Override
+	public void performAction(ActionEvent e) {	
+		getApplication().getFrameController().getEditorView().getFilterController().treeExpOrCollPath(COLLAPSE);
	
+	}
+}

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java?rev=1515560&r1=1515559&r2=1515560&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/DefaultActionManager.java
Mon Aug 19 19:05:10 2013
@@ -132,6 +132,10 @@ public class DefaultActionManager implem
 
         registerAction(new CreateEmbeddableAction(application));
         registerAction(new ShowGraphEntityAction(application));
+        
+        registerAction(new CollapseTreeAction(application));
+        registerAction(new ExpandTreeAction(application));
+        registerAction(new FilterAction(application));
     }
 
     private void initActions() {

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExpandTreeAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExpandTreeAction.java?rev=1515560&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExpandTreeAction.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/ExpandTreeAction.java
Mon Aug 19 19:05:10 2013
@@ -0,0 +1,29 @@
+package org.apache.cayenne.modeler.action;
+
+import java.awt.event.ActionEvent;
+
+import org.apache.cayenne.modeler.Application;
+
+import org.apache.cayenne.modeler.util.CayenneAction;
+
+public class ExpandTreeAction extends CayenneAction {
+	private final static String EXPAND = "expand";
+	
+    public static String getActionName() {
+        return "Expand tree";
+    }
+    
+    @Override
+    public String getIconName() {
+        return "icon-tree-expand.png";
+    }
+
+    public ExpandTreeAction(Application application) {
+        super(getActionName(), application);
+    }
+
+	@Override
+	public void performAction(ActionEvent e) {	
+		getApplication().getFrameController().getEditorView().getFilterController().treeExpOrCollPath(EXPAND);

+	}
+}

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FilterAction.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FilterAction.java?rev=1515560&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FilterAction.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/action/FilterAction.java
Mon Aug 19 19:05:10 2013
@@ -0,0 +1,36 @@
+package org.apache.cayenne.modeler.action;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.JButton;
+import org.apache.cayenne.modeler.Application;
+
+import org.apache.cayenne.modeler.dialog.datadomain.FilterDialog;
+import org.apache.cayenne.modeler.util.CayenneAction;
+
+public class FilterAction extends CayenneAction{
+    
+	private FilterDialog filterDialog = null;
+	
+    public static String getActionName() {
+        return "Filter tree";
+    }
+
+	public FilterAction(Application application) {
+        super(getActionName(), application);
+    }
+	
+    @Override
+    public String getIconName() {
+        return "icon-filter.png";
+    }
+
+	@Override
+	public void performAction(ActionEvent e) {
+		JButton source = (JButton)e.getSource();
+        if(filterDialog == null)
+        	filterDialog  = new FilterDialog(getApplication().getFrameController().getEditorView().getFilterController());
+		filterDialog.pack();
+		filterDialog.show(source, 0, source.getHeight());
+	}	
+}
\ No newline at end of file

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterController.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterController.java?rev=1515560&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterController.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterController.java
Mon Aug 19 19:05:10 2013
@@ -0,0 +1,74 @@
+package org.apache.cayenne.modeler.dialog.datadomain;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+
+import javax.swing.JTree;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
+
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.modeler.ProjectTreeModel;
+import org.apache.cayenne.modeler.ProjectTreeView;
+
+public class FilterController {
+	
+	private HashMap<String,Boolean> filterMap = new HashMap<String, Boolean>();
+	private ProjectTreeView tree;
+	private ProjectController eventController;
+	private ProjectTreeModel treeModel;
+	
+	public ProjectTreeView getTree() {
+		return tree;
+	}
+
+	public ProjectTreeModel getTreeModel() {
+		return treeModel;
+	}
+
+	public ProjectController getEventController() {
+		return eventController;
+	}
+
+	public HashMap<String, Boolean> getFilterMap() {
+		return filterMap;
+	}
+
+	public FilterController(ProjectController eventController, ProjectTreeView treePanel) {
+	
+		this.eventController = eventController;
+		this.tree = treePanel;
+		this.treeModel = tree.getProjectModel();
+		
+		filterMap.put("dbEntity",true);
+		filterMap.put("objEntity",true);
+		filterMap.put("embeddable",true);
+		filterMap.put("procedure",true);
+		filterMap.put("query",true);
+	}
+	
+	
+	public void treeExpOrCollPath(String action) {
+		TreeNode root = (TreeNode) treeModel.getRoot();
+		expandAll(tree, new TreePath(root),action);
+	}
+
+	private void expandAll(JTree tree, TreePath parent, String action) {
+		TreeNode node = (TreeNode) parent.getLastPathComponent();
+		
+		if (node.getChildCount() >= 0) {
+			for (Enumeration e = node.children(); e.hasMoreElements();) {
+				TreeNode n = (TreeNode) e.nextElement();
+				TreePath path = parent.pathByAddingChild(n);
+				expandAll(tree, path, action);
+			}
+		}
+		if(action == "expand") {
+			tree.expandPath(parent);
+		}
+		else if(action == "collapse") {
+			tree.collapsePath(parent);
+		}
+	}
+	
+}
\ No newline at end of file

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java?rev=1515560&view=auto
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
(added)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/dialog/datadomain/FilterDialog.java
Mon Aug 19 19:05:10 2013
@@ -0,0 +1,204 @@
+package org.apache.cayenne.modeler.dialog.datadomain;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.util.Set;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComponent;
+import javax.swing.JPopupMenu;
+import javax.swing.JSeparator;
+import javax.swing.MenuSelectionManager;
+import javax.swing.plaf.ComponentUI;
+import javax.swing.plaf.basic.BasicCheckBoxMenuItemUI;
+
+import org.apache.cayenne.modeler.ProjectController;
+import org.apache.cayenne.swing.BindingBuilder;
+
+public class FilterDialog extends JPopupMenu {
+	
+	private String SELECT_ALL = "Select all";
+	private String UNSELECT_ALL = "Unselect all";
+	
+	private JCheckBoxMenuItem dbEntity;
+	private JCheckBoxMenuItem objEntity;
+	private JCheckBoxMenuItem embeddable;
+	private JCheckBoxMenuItem procedure;
+	private JCheckBoxMenuItem query;
+	private JCheckBoxMenuItem all;
+	private ProjectController eventController;
+	private FilterController filterController;
+	
+	public Boolean getDbEntityFilter() {
+		return filterController.getFilterMap().get("dbEntity");
+	}
+	public void setDbEntityFilter(Boolean value) {
+		filterController.getFilterMap().put("dbEntity", value);
+	}
+	
+	public Boolean getObjEntityFilter() {
+		return filterController.getFilterMap().get("objEntity");
+	}
+
+	public void setObjEntityFilter(Boolean value) {
+		filterController.getFilterMap().put("objEntity", value);
+	}
+	
+	public Boolean getEmbeddableFilter() {
+		return filterController.getFilterMap().get("embeddable");
+	}
+	public void setEmbeddableFilter(Boolean value) {
+		filterController.getFilterMap().put("embeddable", value);
+	}
+	
+	public Boolean getProcedureFilter() {
+		return filterController.getFilterMap().get("procedure");
+	}
+
+	public void setProcedureFilter(Boolean value) {
+		filterController.getFilterMap().put("procedure", value);
+	}
+	
+	public Boolean getQueryFilter() {
+		return filterController.getFilterMap().get("query");
+	}
+	public void setQueryFilter(Boolean value) {
+		filterController.getFilterMap().put("query", value);
+	}
+
+	public Boolean getAllFilter() {
+		Set<String> keys=filterController.getFilterMap().keySet();
+		
+		for(String key : keys) {
+			if(filterController.getFilterMap().get(key) != true) {
+				return false;
+			}
+		}
+		
+		return true;
+	}
+	
+	public void setAllFilter(Boolean value) {
+		
+	}
+	
+	public FilterDialog(FilterController filterController){
+		super();
+		this.filterController=filterController;
+		this.eventController=filterController.getEventController();
+		initView(); 
+		initController();
+	}
+	
+	public void initView(){
+		
+		all = new JCheckBoxMenuItem(UNSELECT_ALL);
+		dbEntity = new JCheckBoxMenuItem("DbEntity");	
+		objEntity = new JCheckBoxMenuItem("ObjEntity");
+		embeddable = new JCheckBoxMenuItem("Embeddable");
+		procedure = new JCheckBoxMenuItem("Procedure");
+		query = new JCheckBoxMenuItem("Query");
+		
+		all.setUI(new StayOpenCheckBoxMenuItemUI());
+		dbEntity.setUI(new StayOpenCheckBoxMenuItemUI());
+		objEntity.setUI(new StayOpenCheckBoxMenuItemUI());
+		embeddable.setUI(new StayOpenCheckBoxMenuItemUI());
+		procedure.setUI(new StayOpenCheckBoxMenuItemUI());
+		query.setUI(new StayOpenCheckBoxMenuItemUI());
+		
+		add(all);
+		add(new JSeparator());
+		add(dbEntity);
+		add(objEntity);
+		add(embeddable);
+		add(procedure);
+		add(query);
+	}
+
+	private void initController() {
+		BindingBuilder builder = new BindingBuilder(
+			  eventController.getApplication().getBindingFactory(),
+			  this);
+	
+		builder.bindToStateChange(dbEntity, "dbEntityFilter").updateView();
+		builder.bindToStateChange(objEntity, "objEntityFilter").updateView();
+		builder.bindToStateChange(embeddable, "embeddableFilter").updateView();
+		builder.bindToStateChange(procedure, "procedureFilter").updateView();
+		builder.bindToStateChange(query, "queryFilter").updateView();
+		builder.bindToStateChange(all, "allFilter").updateView();
+
+		dbEntity.addActionListener(new CheckListener("dbEntity"));
+		objEntity.addActionListener(new CheckListener("objEntity"));
+		embeddable.addActionListener(new CheckListener("embeddable"));
+		procedure.addActionListener(new CheckListener("procedure"));
+		query.addActionListener(new CheckListener("query"));
+	  
+		all.addActionListener(new ActionListener() {
+		
+			public void actionPerformed(ActionEvent e) {
+				dbEntity.setState(all.getState());
+				objEntity.setState(all.getState());
+				embeddable.setState(all.getState());
+				procedure.setState(all.getState());
+				query.setState(all.getState());
+				all.setText(all.getState() ? UNSELECT_ALL : SELECT_ALL);
+
+				filterController.getTreeModel().setFiltered(filterController.getFilterMap());			
+				filterController.treeExpOrCollPath("expand");
+			}
+		});
+	}	
+
+	void checkAllStates() {
+		if(isAll(true)) {
+			all.setState(false);
+			all.setText(SELECT_ALL);
+		}
+		else if(isAll(false)) {
+			all.setState(true);
+			all.setText(UNSELECT_ALL);
+		}
+	}
+	
+	private boolean isAll(boolean state) {
+		Set<String> keys=filterController.getFilterMap().keySet();
+		
+		for(String key : keys) {
+			if(filterController.getFilterMap().get(key) == state) {
+				return false;
+			}
+		}
+		
+		return true;
+	}
+	
+	
+	private class CheckListener implements ActionListener {
+
+		String key;
+		
+		public CheckListener(String key) {
+			this.key = key;
+		}
+		
+		@Override
+		public void actionPerformed(ActionEvent e) {
+			filterController.getFilterMap().put(key, ((JCheckBoxMenuItem)e.getSource()).getState());
+			filterController.getTreeModel().setFiltered(filterController.getFilterMap());
+			filterController.treeExpOrCollPath("expand");
+			checkAllStates();
+		}
+	}
+	
+	public static class StayOpenCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {  
+		  
+		   @Override  
+		   protected void doClick(MenuSelectionManager msm) {  
+		      menuItem.doClick();  
+		   }  
+		  
+		   public static ComponentUI createUI(JComponent c) {  
+		      return new StayOpenCheckBoxMenuItemUI();  
+		   }  
+		}  
+}
\ No newline at end of file

Modified: cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java?rev=1515560&r1=1515559&r2=1515560&view=diff
==============================================================================
--- cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java
(original)
+++ cayenne/main/trunk/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/EditorView.java
Mon Aug 19 19:05:10 2013
@@ -25,14 +25,22 @@ import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
 
+import javax.swing.Action;
+import javax.swing.Box;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
 import javax.swing.JSplitPane;
 import javax.swing.JTabbedPane;
+import javax.swing.JToolBar;
 
 import org.apache.cayenne.modeler.Application;
 import org.apache.cayenne.modeler.ProjectController;
 import org.apache.cayenne.modeler.ProjectTreeView;
+import org.apache.cayenne.modeler.action.ActionManager;
+import org.apache.cayenne.modeler.action.CollapseTreeAction;
+import org.apache.cayenne.modeler.action.ExpandTreeAction;
+import org.apache.cayenne.modeler.action.FilterAction;
+import org.apache.cayenne.modeler.dialog.datadomain.FilterController;
 import org.apache.cayenne.modeler.editor.datanode.DataNodeEditor;
 import org.apache.cayenne.modeler.editor.dbentity.DbEntityTabbedView;
 import org.apache.cayenne.modeler.event.DataMapDisplayEvent;
@@ -98,8 +106,16 @@ public class EditorView extends JPanel i
     private SQLTemplateTabbedView sqlTemplateView;
     private EjbqlTabbedView ejbqlQueryView;
     private JTabbedPane dataNodeView;
+    
 
-    public SelectQueryTabbedView getSelectQueryView() {
+    protected ActionManager actionManager;
+	private FilterController filterController;
+    
+	public FilterController getFilterController() {
+		return filterController;
+	}
+
+	public SelectQueryTabbedView getSelectQueryView() {
         return selectQueryView;
     }
 
@@ -142,19 +158,50 @@ public class EditorView extends JPanel i
     public JTabbedPane getDataNodeView() {
         return dataNodeView;
     }
+    
+    public ProjectTreeView getTreePanel() {
+		return treePanel;
+	}
 
     public EditorView(ProjectController eventController) {
         this.eventController = eventController;
+        this.actionManager= eventController.getApplication().getActionManager();
         initView();
         initController();
+       
     }
 
-    private void initView() {
+    public ProjectController getEventController() {
+		return eventController;
+	}
 
-        // init widgets
-        treePanel = new ProjectTreeView(eventController);
-        treePanel.setMinimumSize(new Dimension(50, 200));
+	private void initView() {
 
+        // init widgets
+        treePanel = new ProjectTreeView(eventController);            
+        JToolBar bar = new JToolBar();
+        
+        bar.setFloatable(false);
+        bar.setPreferredSize(new Dimension(100,30));
+        
+        bar.add(Box.createHorizontalGlue());
+        bar.add(getAction(ExpandTreeAction.class).buildButton());
+        bar.add(getAction(CollapseTreeAction.class).buildButton());
+        bar.add(getAction(FilterAction.class).buildButton());
+        actionManager.getAction(ExpandTreeAction.class).setAlwaysOn(true);
+        actionManager.getAction(CollapseTreeAction.class).setAlwaysOn(true);
+        actionManager.getAction(FilterAction.class).setAlwaysOn(true);
+        
+        JPanel treeNavigatePanel = new JPanel();      
+        treeNavigatePanel.setMinimumSize(new Dimension(50,200));
+        treeNavigatePanel.setLayout(new BorderLayout());
+        treeNavigatePanel.add(bar, BorderLayout.NORTH);       
+        treeNavigatePanel.add(treePanel, BorderLayout.CENTER);
+
+        
+        
+        treePanel.setMinimumSize(new Dimension(50, 180));
+                 
         this.detailPanel = new JPanel();
         this.splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true);
 
@@ -204,14 +251,23 @@ public class EditorView extends JPanel i
         dbDetailView = new DbEntityTabbedView(eventController);
         detailPanel.add(dbDetailView, DB_VIEW);
 
-        splitPane.setLeftComponent(new JScrollPane(treePanel));
+        splitPane.setLeftComponent(new JScrollPane(treeNavigatePanel));
         splitPane.setRightComponent(detailPanel);
 
         setLayout(new BorderLayout());
         add(splitPane, BorderLayout.CENTER);
+        
+       
     }
+    
+    private <T extends Action> T getAction(Class<T> type) {
+        return actionManager.getAction(type);
+    }
+
 
-    private void initController() {
+	private void initController() {
+		this.filterController = new FilterController(eventController,treePanel);
+		 
         eventController.addDomainDisplayListener(this);
         eventController.addDataNodeDisplayListener(this);
         eventController.addDataMapDisplayListener(this);
@@ -221,7 +277,7 @@ public class EditorView extends JPanel i
         eventController.addQueryDisplayListener(this);
         eventController.addMultipleObjectsDisplayListener(this);
         eventController.addEmbeddableDisplayListener(this);
-
+          
         /**
          * Moving this to try-catch block per CAY-940. Exception will be stack-traced
          */
@@ -312,4 +368,4 @@ public class EditorView extends JPanel i
         else
             detailLayout.show(detailPanel, EMBEDDABLE_VIEW);
     }
-}
+}
\ No newline at end of file

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-filter.png
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-filter.png?rev=1515560&view=auto
==============================================================================
Files cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-filter.png
(added) and cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-filter.png
Mon Aug 19 19:05:10 2013 differ

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-collapse.png
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-collapse.png?rev=1515560&view=auto
==============================================================================
Files cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-collapse.png
(added) and cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-collapse.png
Mon Aug 19 19:05:10 2013 differ

Added: cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-expand.png
URL: http://svn.apache.org/viewvc/cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-expand.png?rev=1515560&view=auto
==============================================================================
Files cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-expand.png
(added) and cayenne/main/trunk/modeler/cayenne-modeler/src/main/resources/org/apache/cayenne/modeler/images/icon-tree-expand.png
Mon Aug 19 19:05:10 2013 differ



Mime
View raw message