cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ntimof...@apache.org
Subject [3/5] cayenne git commit: Change listener to change listener on tabbed view.
Date Mon, 05 Nov 2018 14:27:13 GMT
Change listener to change listener on tabbed view.


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

Branch: refs/heads/master
Commit: ff95457be3b409f44eb52a0b225297b92c15142d
Parents: 62bf6c4
Author: kkomyak <const1993@gmail.com>
Authored: Fri Nov 2 15:11:43 2018 +0300
Committer: kkomyak <const1993@gmail.com>
Committed: Fri Nov 2 15:31:06 2018 +0300

----------------------------------------------------------------------
 .../modeler/editor/DataMapTabbedView.java       | 23 ++++++--
 .../modeler/editor/dbimport/DbImportView.java   | 62 +++++++-------------
 2 files changed, 41 insertions(+), 44 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/ff95457b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
index ed1b6f1..2cf6931 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/DataMapTabbedView.java
@@ -31,6 +31,8 @@ import org.apache.cayenne.modeler.editor.dbimport.DbImportView;
  */
 public class DataMapTabbedView extends JTabbedPane {
     ProjectController mediator;
+    private int lastSelectionIndex;
+    private DbImportView dbImportView1;
 
     /**
      * constructor
@@ -53,10 +55,23 @@ public class DataMapTabbedView extends JTabbedPane {
         // add panels to tabs
         // note that those panels that have no internal scrollable tables
         // must be wrapped in a scroll pane
-        JScrollPane dataMapView = new JScrollPane(new DataMapView(mediator));
-        JScrollPane dbImportView = new JScrollPane(new DbImportView(mediator));
-        addTab("DataMap", dataMapView);
-        addTab("DbImport", dbImportView);
+        JScrollPane dataMapScrollPane = new JScrollPane(new DataMapView(mediator));
+        dbImportView1 = new DbImportView(mediator);
+        JScrollPane dbImportScrollPane = new JScrollPane(dbImportView1);
+        addTab("DataMap", dataMapScrollPane);
+        addTab("DbImport", dbImportScrollPane);
+        addChangeListener(e -> {
+            lastSelectionIndex = getSelectedIndex();
+            updateTabs();
+        });
+    }
+
+    private void updateTabs() {
+        switch (lastSelectionIndex) {
+            case 1:
+                dbImportView1.initFromModel();
+            break;
+        }
     }
 }
 

http://git-wip-us.apache.org/repos/asf/cayenne/blob/ff95457b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
----------------------------------------------------------------------
diff --git a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
index f5e97b2..65641fc 100644
--- a/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
+++ b/modeler/cayenne-modeler/src/main/java/org/apache/cayenne/modeler/editor/dbimport/DbImportView.java
@@ -16,7 +16,6 @@
  *  specific language governing permissions and limitations
  *  under the License.
  ****************************************************************/
-
 package org.apache.cayenne.modeler.editor.dbimport;
 
 import com.jgoodies.forms.builder.DefaultFormBuilder;
@@ -33,8 +32,6 @@ import org.apache.cayenne.modeler.util.CayenneAction;
 import javax.swing.JButton;
 import javax.swing.JPanel;
 import javax.swing.JProgressBar;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
 import java.awt.BorderLayout;
 
 /**
@@ -61,47 +58,10 @@ public class DbImportView extends JPanel {
     public DbImportView(ProjectController projectController) {
         this.projectController = projectController;
         initFormElements();
-        initListeners();
         buildForm();
         draggableTreePanel.getSourceTree().repaint();
     }
 
-    private void initListeners() {
-
-        treePanel.addAncestorListener(new AncestorListener() {
-            @Override
-            public void ancestorAdded(AncestorEvent evPent) {
-                DataMap map = projectController.getCurrentDataMap();
-                treePanel.getReverseEngineeringTree().stopEditing();
-                if (map != null) {
-                    treeToolbar.unlockButtons();
-                    ReverseEngineering reverseEngineering = DbImportView.this.projectController.getApplication().
-                            getMetaData().get(map, ReverseEngineering.class);
-                    if (reverseEngineering == null) {
-                        reverseEngineering = new ReverseEngineering();
-                        DbImportView.this.projectController.getApplication().getMetaData().add(map,
reverseEngineering);
-                    }
-                    configPanel.fillCheckboxes(reverseEngineering);
-                    configPanel.initializeTextFields(reverseEngineering);
-                    treePanel.updateTree();
-                    DbImportTreeNode root = draggableTreePanel.getSourceTree().getRootNode();
-                    root.removeAllChildren();
-                    draggableTreePanel.updateTree(projectController.getCurrentDataMap());
-                    draggableTreePanel.getMoveButton().setEnabled(false);
-                    draggableTreePanel.getMoveInvertButton().setEnabled(false);
-                }
-            }
-
-            @Override
-            public void ancestorRemoved(AncestorEvent event) {
-            }
-
-            @Override
-            public void ancestorMoved(AncestorEvent event) {
-            }
-        });
-    }
-
     private void buildForm() {
         FormLayout buttonPanelLayout = new FormLayout(BUTTON_PANEL_LAYOUT);
         DefaultFormBuilder buttonBuilder = new DefaultFormBuilder(buttonPanelLayout);
@@ -191,6 +151,28 @@ public class DbImportView extends JPanel {
         configPanel = new ReverseEngineeringConfigPanel(projectController);
     }
 
+    public void initFromModel() {
+        DataMap map = projectController.getCurrentDataMap();
+        treePanel.getReverseEngineeringTree().stopEditing();
+        if (map != null) {
+            treeToolbar.unlockButtons();
+            ReverseEngineering reverseEngineering = DbImportView.this.projectController.getApplication().
+                    getMetaData().get(map, ReverseEngineering.class);
+            if (reverseEngineering == null) {
+                reverseEngineering = new ReverseEngineering();
+                DbImportView.this.projectController.getApplication().getMetaData().add(map,
reverseEngineering);
+            }
+            configPanel.fillCheckboxes(reverseEngineering);
+            configPanel.initializeTextFields(reverseEngineering);
+            treePanel.updateTree();
+            DbImportTreeNode root = draggableTreePanel.getSourceTree().getRootNode();
+            root.removeAllChildren();
+            draggableTreePanel.updateTree(projectController.getCurrentDataMap());
+            draggableTreePanel.getMoveButton().setEnabled(false);
+            draggableTreePanel.getMoveInvertButton().setEnabled(false);
+        }
+    }
+
     public boolean isSkipRelationshipsLoading() {
         return configPanel.getSkipRelationshipsLoading().isSelected();
     }


Mime
View raw message