cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mgen...@apache.org
Subject cayenne-modeler git commit: Added some initial right-click support in the project tree view.
Date Sat, 01 Jul 2017 12:58:31 GMT
Repository: cayenne-modeler
Updated Branches:
  refs/heads/master 4b66c8b1f -> 9fc39d3e8


Added some initial right-click support in the project tree view.


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

Branch: refs/heads/master
Commit: 9fc39d3e877e5f357a073422de57a9744a6aa4bd
Parents: 4b66c8b
Author: mrg <blacknext@gmail.com>
Authored: Sat Jul 1 08:59:09 2017 -0400
Committer: mrg <blacknext@gmail.com>
Committed: Sat Jul 1 08:59:09 2017 -0400

----------------------------------------------------------------------
 .../modeler/layout/MainWindowLayout.java        | 12 +++++++
 .../modeler/project/CayenneTreeItem.java        | 13 ++++++++
 .../modeler/project/DataDomainTreeItem.java     | 14 +++++++++
 .../modeler/project/DataMapTreeItem.java        | 14 +++++++++
 .../modeler/project/DataNodeTreeItem.java       | 14 +++++++++
 .../modeler/project/DatabaseEntityTreeItem.java | 14 +++++++++
 .../modeler/project/ObjectEntityTreeItem.java   | 33 ++++++++++++++++++++
 .../modeler/project/ProjectTreeCell.java        | 24 ++++++++++++++
 8 files changed, 138 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java b/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
index 5bc7be7..c32fc9c 100644
--- a/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
+++ b/src/main/java/org/apache/cayenne/modeler/layout/MainWindowLayout.java
@@ -38,6 +38,7 @@ import org.apache.cayenne.modeler.project.DataMapTreeItem;
 import org.apache.cayenne.modeler.project.DataNodeTreeItem;
 import org.apache.cayenne.modeler.project.DatabaseEntityTreeItem;
 import org.apache.cayenne.modeler.project.ObjectEntityTreeItem;
+import org.apache.cayenne.modeler.project.ProjectTreeCell;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -48,10 +49,12 @@ import javafx.scene.Node;
 import javafx.scene.control.Alert;
 import javafx.scene.control.Alert.AlertType;
 import javafx.scene.control.ButtonType;
+import javafx.scene.control.TreeCell;
 import javafx.scene.control.TreeItem;
 import javafx.scene.control.TreeView;
 import javafx.scene.layout.AnchorPane;
 import javafx.stage.Stage;
+import javafx.util.Callback;
 
 public class MainWindowLayout
     extends AbstractWindowLayout
@@ -174,6 +177,15 @@ public class MainWindowLayout
         treeView.setRoot(treeRoot);
         treeView.setShowRoot(false);
 
+        treeView.setCellFactory(new Callback<TreeView<String>, TreeCell<String>>()
+        {
+            @Override
+            public TreeCell<String> call(TreeView<String> p)
+            {
+                return new ProjectTreeCell();
+            }
+        });
+
         // addDataDomain(CayenneModelManager.getModels().get(0));
         // System.out.println(CayenneModelManager.getModels().size());
 

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/CayenneTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/CayenneTreeItem.java b/src/main/java/org/apache/cayenne/modeler/project/CayenneTreeItem.java
index eefbddc..a6eed36 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/CayenneTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/CayenneTreeItem.java
@@ -21,10 +21,23 @@ package org.apache.cayenne.modeler.project;
 
 import org.apache.cayenne.modeler.adapters.CayennePropertyAdapter;
 
+import javafx.scene.control.ContextMenu;
+
 //public class CayenneTreeItem<T> extends TreeItem<T>
 public interface CayenneTreeItem<T extends CayennePropertyAdapter>
 {
+//    static final Log LOGGER = LogFactory.getLog(CayenneTreeItem.class);
+
     public static final String TREE_ICON_SIZE = "16px";
 
     T getPropertyAdapter();
+
+    ContextMenu getContextMenu();
+
+//    default ContextMenu getContextMenu()
+//    {
+//        MenuItem addInbox = new MenuItem("add inbox");
+//        addInbox.setOnAction(event -> LOGGER.debug("default context menu - event: "
+ event));
+//        return new ContextMenu(addInbox);
+//    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/DataDomainTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/DataDomainTreeItem.java b/src/main/java/org/apache/cayenne/modeler/project/DataDomainTreeItem.java
index baa2f3f..8a18f87 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/DataDomainTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/DataDomainTreeItem.java
@@ -20,14 +20,20 @@
 package org.apache.cayenne.modeler.project;
 
 import org.apache.cayenne.modeler.adapters.DataDomainAdapter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
 import javafx.scene.control.TreeItem;
 
 //public class DataDomainTreeItem extends CayenneTreeItem<String>
 public class DataDomainTreeItem extends TreeItem<String> implements CayenneTreeItem<DataDomainAdapter>
 {
+    private static final Log LOGGER = LogFactory.getLog(DataDomainTreeItem.class);
+
     private final DataDomainAdapter dataDomainAdapter;
 
     public DataDomainTreeItem(final DataDomainAdapter dataDomainAdapter, final TreeItem<String>
treeRoot)
@@ -52,4 +58,12 @@ public class DataDomainTreeItem extends TreeItem<String> implements
CayenneTreeI
     {
         return dataDomainAdapter;
     }
+
+    @Override
+    public ContextMenu getContextMenu()
+    {
+      MenuItem addInbox = new MenuItem("Data Domain Menu");
+      addInbox.setOnAction(event -> LOGGER.debug("Data Domain Context Menu Event: " +
event));
+      return new ContextMenu(addInbox);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/DataMapTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/DataMapTreeItem.java b/src/main/java/org/apache/cayenne/modeler/project/DataMapTreeItem.java
index 4f5a446..d22fdb1 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/DataMapTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/DataMapTreeItem.java
@@ -20,13 +20,19 @@
 package org.apache.cayenne.modeler.project;
 
 import org.apache.cayenne.modeler.adapters.DataMapAdapter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
 import javafx.scene.control.TreeItem;
 
 public class DataMapTreeItem extends TreeItem<String> implements CayenneTreeItem<DataMapAdapter>
 {
+    private static final Log LOGGER = LogFactory.getLog(DataMapTreeItem.class);
+
     private final DataMapAdapter dataMapAdapter;
 
     public DataMapTreeItem(final DataMapAdapter dataMapAdapter, final TreeItem<String>
parent)
@@ -44,4 +50,12 @@ public class DataMapTreeItem extends TreeItem<String> implements
CayenneTreeItem
     {
         return dataMapAdapter;
     }
+
+    @Override
+    public ContextMenu getContextMenu()
+    {
+      MenuItem addInbox = new MenuItem("Data Map Menu");
+      addInbox.setOnAction(event -> LOGGER.debug("Data Map Context Menu Event: " + event));
+      return new ContextMenu(addInbox);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/DataNodeTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/DataNodeTreeItem.java b/src/main/java/org/apache/cayenne/modeler/project/DataNodeTreeItem.java
index 0d48e45..7ae1ed5 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/DataNodeTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/DataNodeTreeItem.java
@@ -20,13 +20,19 @@
 package org.apache.cayenne.modeler.project;
 
 import org.apache.cayenne.modeler.adapters.DataNodeAdapter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
 import javafx.scene.control.TreeItem;
 
 public class DataNodeTreeItem extends TreeItem<String> implements CayenneTreeItem<DataNodeAdapter>
 {
+    private static final Log LOGGER = LogFactory.getLog(DataNodeTreeItem.class);
+
     private final DataNodeAdapter dataNodeAdapter;
 
     public DataNodeTreeItem(final DataNodeAdapter dataNodeAdapter, final TreeItem<String>
parent)
@@ -44,4 +50,12 @@ public class DataNodeTreeItem extends TreeItem<String> implements
CayenneTreeIte
     {
         return dataNodeAdapter;
     }
+
+    @Override
+    public ContextMenu getContextMenu()
+    {
+      MenuItem addInbox = new MenuItem("Data Node Menu");
+      addInbox.setOnAction(event -> LOGGER.debug("Data Node Context Menu Event: " + event));
+      return new ContextMenu(addInbox);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/DatabaseEntityTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/DatabaseEntityTreeItem.java
b/src/main/java/org/apache/cayenne/modeler/project/DatabaseEntityTreeItem.java
index c957b71..64e5434 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/DatabaseEntityTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/DatabaseEntityTreeItem.java
@@ -20,13 +20,19 @@
 package org.apache.cayenne.modeler.project;
 
 import org.apache.cayenne.modeler.adapters.DatabaseEntityAdapter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
 import javafx.scene.control.TreeItem;
 
 public class DatabaseEntityTreeItem extends TreeItem<String> implements CayenneTreeItem<DatabaseEntityAdapter>
 {
+    private static final Log LOGGER = LogFactory.getLog(DatabaseEntityTreeItem.class);
+
     private final DatabaseEntityAdapter databaseEntityAdapter;
 
     public DatabaseEntityTreeItem(final DatabaseEntityAdapter databaseEntityAdapter, final
TreeItem<String> parent)
@@ -44,4 +50,12 @@ public class DatabaseEntityTreeItem extends TreeItem<String> implements
CayenneT
     {
         return databaseEntityAdapter;
     }
+
+    @Override
+    public ContextMenu getContextMenu()
+    {
+      MenuItem addInbox = new MenuItem("Database Entity Menu");
+      addInbox.setOnAction(event -> LOGGER.debug("Database Entity Context Menu Event:
" + event));
+      return new ContextMenu(addInbox);
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/ObjectEntityTreeItem.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/ObjectEntityTreeItem.java b/src/main/java/org/apache/cayenne/modeler/project/ObjectEntityTreeItem.java
index 851631e..0b8aa63 100644
--- a/src/main/java/org/apache/cayenne/modeler/project/ObjectEntityTreeItem.java
+++ b/src/main/java/org/apache/cayenne/modeler/project/ObjectEntityTreeItem.java
@@ -19,14 +19,22 @@
 
 package org.apache.cayenne.modeler.project;
 
+import org.apache.cayenne.map.ObjEntity;
 import org.apache.cayenne.modeler.adapters.ObjectEntityAdapter;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 import de.jensd.fx.glyphs.GlyphsDude;
 import de.jensd.fx.glyphs.fontawesome.FontAwesomeIcon;
+import javafx.scene.control.ContextMenu;
+import javafx.scene.control.MenuItem;
 import javafx.scene.control.TreeItem;
 
 public class ObjectEntityTreeItem extends TreeItem<String> implements CayenneTreeItem<ObjectEntityAdapter>
 {
+    private static final Log LOGGER = LogFactory.getLog(DataDomainTreeItem.class);
+
     private final ObjectEntityAdapter objectEntityAdapter;
 
     public ObjectEntityTreeItem(final ObjectEntityAdapter objectEntityAdapter, final TreeItem<String>
parent)
@@ -44,4 +52,29 @@ public class ObjectEntityTreeItem extends TreeItem<String> implements
CayenneTre
     {
         return objectEntityAdapter;
     }
+
+    @Override
+    public ContextMenu getContextMenu()
+    {
+        ContextMenu contextMenu  = new ContextMenu();
+        ObjEntity   objectEntity = (ObjEntity) getPropertyAdapter().getWrappedObject();
+
+        getPropertyAdapter().getDataMapAdapter().getDatabaseEntityAdapters().stream().forEach(databaseEntity
->
+            {
+                if (StringUtils.equals(databaseEntity.getName(), objectEntity.getDbEntityName()))
+                {
+                    MenuItem jumpTo = new MenuItem("Jump To Database Entity: " + databaseEntity.getName());
+
+                    jumpTo.setMnemonicParsing(false);
+                    jumpTo.setOnAction(event ->
+                        {
+                            LOGGER.debug("Jumping to DB Entity: " + databaseEntity.getName());
+                        });
+
+                    contextMenu.getItems().add(jumpTo);
+                }
+            });
+
+      return contextMenu;
+    }
 }

http://git-wip-us.apache.org/repos/asf/cayenne-modeler/blob/9fc39d3e/src/main/java/org/apache/cayenne/modeler/project/ProjectTreeCell.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/cayenne/modeler/project/ProjectTreeCell.java b/src/main/java/org/apache/cayenne/modeler/project/ProjectTreeCell.java
new file mode 100644
index 0000000..8f93f6f
--- /dev/null
+++ b/src/main/java/org/apache/cayenne/modeler/project/ProjectTreeCell.java
@@ -0,0 +1,24 @@
+package org.apache.cayenne.modeler.project;
+
+import javafx.scene.control.TreeCell;
+
+public class ProjectTreeCell extends TreeCell<String>
+{
+    @Override
+    public void updateItem(String item, boolean empty)
+    {
+        super.updateItem(item, empty);
+
+        if (empty)
+        {
+            setText(null);
+            setGraphic(null);
+        }
+        else
+        {
+            setText(getItem() == null ? "" : getItem().toString());
+            setGraphic(getTreeItem().getGraphic());
+            setContextMenu(((CayenneTreeItem<?>) getTreeItem()).getContextMenu());
+        }
+    }
+}


Mime
View raw message