From 2c01c184e7de36d589674ff7f6438b296aa8d911 Mon Sep 17 00:00:00 2001
From: Dominique Marcadet <Dominique.Marcadet@centralesupelec.fr>
Date: Wed, 26 Jun 2019 08:52:26 +0200
Subject: [PATCH] add NSD files support

---
 .../RiseClipseValidatorSCLApplication.java    | 24 +++++++++++++++----
 .../validator/ui/component/SCLFilePane.java   |  9 ++++++-
 .../{OCLFilePane.java => TreeFilePane.java}   | 12 +++++-----
 3 files changed, 33 insertions(+), 12 deletions(-)
 rename fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/{OCLFilePane.java => TreeFilePane.java} (91%)

diff --git a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/application/RiseClipseValidatorSCLApplication.java b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/application/RiseClipseValidatorSCLApplication.java
index b19b74f..a6e562f 100644
--- a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/application/RiseClipseValidatorSCLApplication.java
+++ b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/application/RiseClipseValidatorSCLApplication.java
@@ -25,7 +25,7 @@ import java.util.ArrayList;
 import javax.swing.JFrame;
 import javax.swing.JTabbedPane;
 
-import fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui.component.OCLFilePane;
+import fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui.component.TreeFilePane;
 import fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui.component.SCLFilePane;
 
 import javax.swing.JScrollPane;
@@ -34,7 +34,8 @@ import javax.swing.JPanel;
 public class RiseClipseValidatorSCLApplication {
 
     private JFrame frame;
-    private OCLFilePane oclTree;
+    private TreeFilePane oclTree;
+    private TreeFilePane nsdTree;
 
     /**
      * Launch the application.
@@ -78,16 +79,29 @@ public class RiseClipseValidatorSCLApplication {
         JScrollPane oclPane = new JScrollPane();
         tabbedPane.addTab( "OCL Files", null, oclPane, null );
 
-        File fileRoot = new File( System.getProperty( "user.dir" ) + "/OCL" );
-        oclTree = new OCLFilePane( fileRoot );
+        File oclRoot = new File( System.getProperty( "user.dir" ) + "/OCL" );
+        oclTree = new TreeFilePane( oclRoot );
         oclPane.setViewportView( oclTree );
 
+        JScrollPane nsdPane = new JScrollPane();
+        tabbedPane.addTab( "NSD Files", null, nsdPane, null );
+
+        File nsdRoot = new File( System.getProperty( "user.dir" ) + "/NSD" );
+        nsdTree = new TreeFilePane( nsdRoot );
+        nsdPane.setViewportView( nsdTree );
+
     }
 
     public ArrayList< File > getOclFiles() {
         ArrayList< File > oclFiles = new ArrayList<>();
-        oclTree.getOclFiles( oclFiles );
+        oclTree.getSelectedFiles( oclFiles );
         return oclFiles;
     }
 
+    public ArrayList< File > getNsdFiles() {
+        ArrayList< File > nsdFiles = new ArrayList<>();
+        nsdTree.getSelectedFiles( nsdFiles );
+        return nsdFiles;
+    }
+
 }
diff --git a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/SCLFilePane.java b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/SCLFilePane.java
index 6c03ee3..82936d5 100644
--- a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/SCLFilePane.java
+++ b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/SCLFilePane.java
@@ -87,6 +87,13 @@ public class SCLFilePane extends JPanel implements ActionListener {
                     .map( f -> f.getAbsolutePath() )
                     .collect( Collectors.toList() );
             
+            ArrayList< File > nsdFiles = application.getNsdFiles();
+            List< String > nsdFileNames =
+                    nsdFiles
+                    .stream()
+                    .map( f -> f.getAbsolutePath() )
+                    .collect( Collectors.toList() );
+            
             ArrayList< String > sclFiles = sclFilesList.getSclFiles();
 
             ResultFrame result = new ResultFrame();
@@ -94,7 +101,7 @@ public class SCLFilePane extends JPanel implements ActionListener {
             IRiseClipseConsole console = result.getMainConsole();
             AbstractRiseClipseConsole.changeConsole( console );
             RiseClipseValidatorSCL.displayLegal( );
-            RiseClipseValidatorSCL.prepare( oclFileNames, null, false );
+            RiseClipseValidatorSCL.prepare( oclFileNames, nsdFileNames, false );
             result.repaint();
             for( int i = 0; i < sclFiles.size(); ++i ) {
                 console = result.getConsoleFor( sclFiles.get( i ));
diff --git a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/OCLFilePane.java b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/TreeFilePane.java
similarity index 91%
rename from fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/OCLFilePane.java
rename to fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/TreeFilePane.java
index ca0c74d..d5e5bf4 100644
--- a/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/OCLFilePane.java
+++ b/fr.centralesupelec.edf.riseclipse.iec61850.scl.validator.ui/src/fr/centralesupelec/edf/riseclipse/iec61850/scl/validator/ui/component/TreeFilePane.java
@@ -32,11 +32,11 @@ import javax.swing.tree.TreeCellRenderer;
 import javax.swing.tree.TreePath;
 
 @SuppressWarnings( "serial" )
-public class OCLFilePane extends JTree {
+public class TreeFilePane extends JTree {
 
     private DefaultMutableTreeNode root;
 
-    public OCLFilePane( File fileRoot ) {
+    public TreeFilePane( File fileRoot ) {
         root = new DefaultMutableTreeNode( new SclFileCheckBox( fileRoot ) );
         setModel( new DefaultTreeModel( root ) );
         setShowsRootHandles( true );
@@ -98,11 +98,11 @@ public class OCLFilePane extends JTree {
         }
     }
 
-    public void getOclFiles( ArrayList< File > oclFiles ) {
-        getOclFiles( root, oclFiles );
+    public void getSelectedFiles( ArrayList< File > oclFiles ) {
+        getSelectedFiles( root, oclFiles );
     }
 
-    private void getOclFiles( DefaultMutableTreeNode node, ArrayList< File > oclFiles ) {
+    private void getSelectedFiles( DefaultMutableTreeNode node, ArrayList< File > oclFiles ) {
         SclFileCheckBox checkbox = ( SclFileCheckBox ) node.getUserObject();
         if( checkbox.getFile().isFile() ) {
             if( checkbox.getCheckBox().isSelected() ) {
@@ -111,7 +111,7 @@ public class OCLFilePane extends JTree {
         }
         else {
             for( int i = 0; i < node.getChildCount(); ++i ) {
-                getOclFiles( ( DefaultMutableTreeNode ) node.getChildAt( i ), oclFiles );
+                getSelectedFiles( ( DefaultMutableTreeNode ) node.getChildAt( i ), oclFiles );
             }
         }
     }
-- 
GitLab