/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package it.cnr.iasi.giant.action;

import it.cnr.iasi.giant.Main;
import it.cnr.iasi.giant.thread.AttributesLoaderThread;
import java.io.File;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;

/**
 *
 * @author Fabio Cumbo
 * @info GIANT
 * @version v1.0
 * @organization IASI-CNR : Istituto di Analisi dei Sistemi ed Informatica 
 *                  "Antonio Ruberti" - Consiglio Nazionale delle Ricerche
 * 
 */
public class SelectAttributesAction extends Action {

    @Override
    public ArrayList<Object> execute(String command) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public ArrayList<Object> execute() {
        JFileChooser chooser = new JFileChooser();
        
        int code = chooser.showOpenDialog(Main.getApp().getFrameOverride());
        File file;
        if (code == JFileChooser.APPROVE_OPTION) {
            file = chooser.getSelectedFile();
            if (file.exists()) {
                AttributesLoaderThread loader = new AttributesLoaderThread(file);
                loader.start();
            }
            else {
                JOptionPane.showMessageDialog(Main.getApp().getFrameOverride(), "Specified file does not exist!", "ERROR", JOptionPane.ERROR_MESSAGE);
            }
        }
        
        System.out.println("SelectAttributesAction");
        return null;
    }
    
}
