cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [1/2] cayenne git commit: CAY-2295 Sync ObjEntity with DbEntity and View related DbEntity buttons aren't disabled, if DbEntity doesn't have ObjEntity
Date Fri, 05 May 2017 11:55:58 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 1c73a0463 -> d65baae37


CAY-2295 Sync ObjEntity with DbEntity and View related DbEntity buttons aren't disabled, if
DbEntity doesn't have ObjEntity


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

Branch: refs/heads/master
Commit: 93414bed750b168ef504b22a9beeb7a91a9ef8bd
Parents: a2e0452
Author: Anton Dreka <drekoas@gmail.com>
Authored: Thu May 4 14:48:52 2017 +0300
Committer: Anton Dreka <drekoas@gmail.com>
Committed: Thu May 4 14:48:52 2017 +0300

----------------------------------------------------------------------
 docs/doc/src/main/resources/RELEASE-NOTES.txt        |  1 +
 .../dbentity/DbEntityAttributeRelationshipTab.java   | 15 ++++++++++++---
 .../cayenne/modeler/editor/dbentity/DbEntityTab.java | 11 ++++++++++-
 3 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/93414bed/docs/doc/src/main/resources/RELEASE-NOTES.txt
----------------------------------------------------------------------
diff --git a/docs/doc/src/main/resources/RELEASE-NOTES.txt b/docs/doc/src/main/resources/RELEASE-NOTES.txt
index 40c9097..88c620e 100644
--- a/docs/doc/src/main/resources/RELEASE-NOTES.txt
+++ b/docs/doc/src/main/resources/RELEASE-NOTES.txt
@@ -35,6 +35,7 @@ CAY-2274 Modeler: Validate case when dependent PK is marked as “generated”
 CAY-2277 Create ClientRuntime with ClientRuntimeBuilder just like ServerRuntime
 CAY-2278 Extract cayenne-postcommit module from cayenne-lifecycle
 CAY-2280 Switch from commons-logging to slf4j
+CAY-2295 "Sync ObjEntity with DbEntity" and "View related DbEntity" buttons aren't disabled,
if DbEntity doesn't have ObjEntity
 
 Bug Fixes:
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/93414bed/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeRelationshipTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeRelationshipTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeRelationshipTab.java
index 8fed5be..428e9dd 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeRelationshipTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityAttributeRelationshipTab.java
@@ -18,6 +18,7 @@
  ****************************************************************/
 package org.apache.cayenne.modeler.editor.dbentity;
 
+import org.apache.cayenne.map.DbEntity;
 import org.apache.cayenne.map.DbRelationship;
 import org.apache.cayenne.map.event.DbEntityListener;
 import org.apache.cayenne.map.event.EntityEvent;
@@ -62,12 +63,14 @@ public class DbEntityAttributeRelationshipTab extends JPanel implements
DbEntity
     private CutAttributeRelationshipAction cut;
     private RemoveAttributeRelationshipAction remove;
     private CopyAttributeRelationshipAction copy;
+    private JToolBar toolBar;
 
     public DbEntityAttributeRelationshipTab(ProjectController mediator) {
         this.mediator = mediator;
 
         init();
         initToolBar();
+        mediator.addDbEntityDisplayListener(this);
     }
 
     private void init() {
@@ -96,7 +99,7 @@ public class DbEntityAttributeRelationshipTab extends JPanel implements
DbEntity
     }
 
     private void initToolBar() {
-        JToolBar toolBar = new JToolBar();
+        toolBar = new JToolBar();
         ActionManager actionManager = Application.getInstance().getActionManager();
 
         toolBar.add(actionManager.getAction(CreateObjEntityAction.class).buildButton());
@@ -165,7 +168,13 @@ public class DbEntityAttributeRelationshipTab extends JPanel implements
DbEntity
     }
 
     public void currentDbEntityChanged(EntityDisplayEvent e) {
-        attributePanel.currentDbEntityChanged(e);
-        relationshipPanel.currentDbEntityChanged(e);
+        DbEntity entity = (DbEntity) e.getEntity();
+        if(entity.getDataMap().getMappedEntities(entity).isEmpty()) {
+            toolBar.getComponentAtIndex(3).setEnabled(false);
+            toolBar.getComponentAtIndex(4).setEnabled(false);
+        } else {
+            toolBar.getComponentAtIndex(3).setEnabled(true);
+            toolBar.getComponentAtIndex(4).setEnabled(true);
+        }
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cayenne/blob/93414bed/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
index 197c773..9cbae0e 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbentity/DbEntityTab.java
@@ -82,6 +82,8 @@ public class DbEntityTab extends JPanel implements ExistingSelectionProcessor,
D
     protected JPanel pkGeneratorDetail;
     protected CardLayout pkGeneratorDetailLayout;
 
+    private JToolBar toolBar;
+
     public DbEntityTab(ProjectController mediator) {
         super();
         this.mediator = mediator;
@@ -92,7 +94,7 @@ public class DbEntityTab extends JPanel implements ExistingSelectionProcessor,
D
 
     private void initView() {
 
-        JToolBar toolBar = new JToolBar();
+        toolBar = new JToolBar();
         ActionManager actionManager = Application.getInstance().getActionManager();
         toolBar.add(actionManager.getAction(CreateObjEntityAction.class).buildButton());
         toolBar.add(actionManager.getAction(DbEntitySyncAction.class).buildButton());
@@ -240,6 +242,13 @@ public class DbEntityTab extends JPanel implements ExistingSelectionProcessor,
D
         pkGeneratorType.setSelectedItem(type);
         pkGeneratorDetailLayout.show(pkGeneratorDetail, type);
 
+        if(entity.getDataMap().getMappedEntities(entity).isEmpty()) {
+            toolBar.getComponentAtIndex(1).setEnabled(false);
+            toolBar.getComponentAtIndex(7).setEnabled(false);
+        } else {
+            toolBar.getComponentAtIndex(1).setEnabled(true);
+            toolBar.getComponentAtIndex(7).setEnabled(true);
+        }
     }
 
     void setEntityName(String newName) {


Mime
View raw message