/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package nl.fontys.sofa.limo.view;

import java.awt.event.ActionEvent;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.Action;
import nl.fontys.sofa.limo.view.wizard.importer.ImportWizardAction;
import org.netbeans.api.sendopts.CommandException;
import org.netbeans.spi.sendopts.Env;
import org.netbeans.spi.sendopts.Option;
import org.netbeans.spi.sendopts.OptionProcessor;
import org.openide.awt.Actions;
import org.openide.util.actions.SystemAction;
import org.openide.util.lookup.ServiceProvider;

/**
 *
 * @author nilsh
 */
@ServiceProvider(service = OptionProcessor.class)
public class StartupOptionProcessor extends OptionProcessor {

    private static final Logger logger = Logger.getLogger(StartupOptionProcessor.class.getName());
    private Option openOption = Option.defaultArguments();
    private Option openOption2 = Option.additionalArguments('o', "open");

    @Override
    protected Set<Option> getOptions() {
        HashSet set = new HashSet();
        set.add(openOption);
        set.add(openOption2);
        return set;
    }

    @Override
    protected void process(Env env, Map<Option, String[]> values) throws CommandException {

        List<String> filenameList = new ArrayList<>();
        Object obj = values.get(openOption);
        if (obj != null) {
            filenameList.addAll(Arrays.asList((String[]) obj));
        }
        obj = values.get(openOption2);
        if (obj != null) {
            filenameList.addAll(Arrays.asList((String[]) obj));
        }

        for (int i = 0; i < filenameList.size(); i++) {
            File file = new File(filenameList.get(i));
            if (!file.isAbsolute()) {
                file = new File(env.getCurrentDirectory(),
                        filenameList.get(i));
            }
            logger.log(Level.INFO, "Open file: {0}", file.getPath());

            String path = file.getAbsolutePath();

            if (path.endsWith(".lef")) {
                ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_FIRST, path);
                Action action = Actions.forID("Master Data", "nl.fontys.sofa.limo.view.wizard.importer.ImportWizardAction");
                action.actionPerformed(e);
                continue;
            }
            
            if(path.endsWith(".lsc")){
                ActionEvent e = new ActionEvent(this, ActionEvent.ACTION_FIRST, path);
                Action action =  Actions.forID("Window", "nl.fontys.sofa.limo.view.action.OpenChainAction");
               
                action.actionPerformed(e);
                continue;
            }
            

        }
    }

}

@@ -511,76 +511,8 @@
 on;%0A
-import nl.fontys.sofa.limo.view.wizard.importer.ImportWizardAction;%0A
 impo
@@ -723,54 +723,8 @@
 ns;%0A
-import org.openide.util.actions.SystemAction;%0A
 impo
@@ -1012,32 +1012,38 @@
 ));%0A    private 
+final 
 Option openOptio
@@ -1085,16 +1085,22 @@
 private 
+final 
 Option o
@@ -1798,22 +1798,30 @@
 or (
-int i = 0; i %3C
+String filenameList1 :
  fil
@@ -1833,20 +1833,8 @@
 List
-.size(); i++
 ) %7B%0A
@@ -1870,39 +1870,33 @@
 ile(filenameList
-.get(i)
+1
 );%0A            i
@@ -1982,32 +1982,8 @@
 y(),
-%0A                       
  fil
@@ -1995,15 +1995,9 @@
 List
-.get(i)
+1
 );%0A 
@@ -2079,17 +2079,16 @@
 ath());%0A
-%0A
         
@@ -2129,17 +2129,16 @@
 Path();%0A
-%0A
         
@@ -2465,29 +2465,16 @@
       %7D%0A
-            %0A
         
@@ -2479,16 +2479,17 @@
       if
+ 
 (path.en
@@ -2503,16 +2503,17 @@
 %22.lsc%22))
+ 
 %7B%0A      
@@ -2624,17 +2624,16 @@
 action =
- 
  Actions
@@ -2701,31 +2701,16 @@
 tion%22);%0A
-               
 %0A       
@@ -2761,49 +2761,9 @@
     
-    continue;%0A            %7D%0A            %0A
+%7D
 %0A   

Update module view, package: wizard