public void runTask() {
        MainTask tasks[] = new MainTask[jTableAlgorithms.getModel().getRowCount() * jTableStreams.getModel().getRowCount()];
        int taskCount = 0;

        String dir = "";

        try {
            this.currentTask = (MainTask) ClassOption.cliStringToObject(
                    this.jTextFieldTask.getText(), MainTask.class, null);
        } catch (Exception ex) {
            Logger.getLogger(TaskManagerTabPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
        MainTask auxTask = (MainTask) this.currentTask.copy();

        dir += this.resultsPath;

        File f = new File(dir);
        if (f.exists()) {
            Object[] options = {"Yes", "No"};
            String cancel = "NO";
            int resp = JOptionPane.showOptionDialog(this,
                    "The selected folder is not empty. This action may overwrite "
                    + "previous experiment results. Do you want to continue?", "Warning",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, cancel);
            if (resp == JOptionPane.OK_OPTION) {
                ReadFile.deleteDrectory(f);

            } else {
                JOptionPane.showMessageDialog(this, "Please specify another directory", "Message",
                        JOptionPane.INFORMATION_MESSAGE);
                return;
            }
        }
        f.mkdir();

        String algNames = "";
        String streamNames = "";
        for (int i = 0; i < jTableAlgorithms.getModel().getRowCount(); i++) {
            String alg = jTableAlgorithms.getModel().getValueAt(i, 0).toString();
            String algFile = jTableAlgorithms.getModel().getValueAt(i, 1).toString();
            algNames += algFile;
            if (i != jTableAlgorithms.getModel().getRowCount() - 1) {
                algNames += ",";
            }
            for (int j = 0; j < jTableStreams.getModel().getRowCount(); j++) {
                String stream = jTableStreams.getModel().getValueAt(j, 0).toString();
                String streamFile = jTableStreams.getModel().getValueAt(j, 1).toString();
                streamNames += streamFile.split(" ")[0];
                if (j != jTableStreams.getModel().getRowCount() - 1) {
                    streamNames += ",";
                }
                if (i == 0) {
                    String sfile = FilenameUtils.separatorsToSystem(dir + "\\\\" + streamFile);
                    f = new File(sfile);
                    f.mkdir();
                }
                String task = " -l ";
                if (alg.split(" ") != null) {
                    task += "(" + alg + ") -s (" + stream + ")" + " -d (" + dir + File.separator
                            + streamFile.split(" ")[0] + File.separator + algFile + ".txt" + ")";
                } else {
                    task += alg + " -s (" + stream + ")" + " -d (" + dir + File.separator
                            + streamFile.split(" ")[0] + File.separator + algFile + ".txt" + ")";
                }
//                String task = FilenameUtils.separatorsToSystem(" -l (" + alg + ") -s (" + stream + ") " + " -d " + "(" + dir + "\\\\"
//                        + streamFile.split(" ")[0] + "\\\\" + algFile + ".txt" + ")");
                auxTask.getOptions().setViaCLIString(task);

                try {
                    tasks[taskCount] = (MainTask) auxTask.copy();
                } catch (Exception ex) {
                    Logger.getLogger(TaskManagerTabPanel.class.getName()).log(Level.SEVERE, null, ex);
                }

                taskCount++;
            }
        }
        this.jButtonRun.setEnabled(false);
        Buffer buffer = new Buffer(tasks);
        int proc = 1;
        if (!this.jTextFieldProcess.getText().equals("")) {
            proc = Integer.parseInt(this.jTextFieldProcess.getText());
        }
        if (proc > tasks.length) {
            proc = tasks.length;
        }
        for (int i = 0; i < proc; i++) {
            ExpTaskThread thread = new ExpTaskThread(buffer);
            thread.start();
            this.taskList.add(0, thread);
            this.taskTableModel.fireTableDataChanged();
            this.taskTable.setRowSelectionInterval(0, 0);

        }
        Thread obs = new Thread() {
            public void run() {
                while (true) {
                    int count = 0;
                    for (ExpTaskThread thread : TaskManagerTabPanel.this.taskList) {
                        if (thread.isCompleted == true) {
                            count++;
                            //System.out.println(count);
                        }
                    }
                    if (count == TaskManagerTabPanel.this.taskList.size()) {
                        TaskManagerTabPanel.this.summary.readData(resultsPath);
                        TaskManagerTabPanel.this.plot.readData(resultsPath);
                        TaskManagerTabPanel.this.analizeTab.readData(resultsPath);
                        TaskManagerTabPanel.this.jButtonRun.setEnabled(true);
                        break;
                    }
                }
            }
        };
        obs.start();
    }
public void runTask ( ) { MainTask tasks [ ] = new MainTask [ jTableAlgorithms . getModel ( ) . getRowCount ( ) * jTableStreams . getModel ( ) . getRowCount ( ) ] ; int taskCount = 0 ; String dir = "" ; try { this . currentTask = ( MainTask ) ClassOption . cliStringToObject ( this . jTextFieldTask . getText ( ) , MainTask . class , null ) ; } catch ( Exception ex ) { Logger . getLogger ( TaskManagerTabPanel . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } MainTask auxTask = ( MainTask ) this . currentTask . copy ( ) ; dir += this . resultsPath ; File f = new File ( dir ) ; if ( f . exists ( ) ) { Object [ ] options = { "Yes" , "No" } ; String cancel = "NO" ; int resp = JOptionPane . showOptionDialog ( this , "The selected folder is not empty. This action may overwrite " + "previous experiment results. Do you want to continue?" , "Warning" , JOptionPane . OK_CANCEL_OPTION , JOptionPane . QUESTION_MESSAGE , null , options , cancel ) ; if ( resp == JOptionPane . OK_OPTION ) { ReadFile . deleteDrectory ( f ) ; } else { JOptionPane . showMessageDialog ( this , "Please specify another directory" , "Message" , JOptionPane . INFORMATION_MESSAGE ) ; return ; } } f . mkdir ( ) ; String algNames = "" ; String streamNames = "" ; for ( int i = 0 ; i < jTableAlgorithms . getModel ( ) . getRowCount ( ) ; i ++ ) { String alg = jTableAlgorithms . getModel ( ) . getValueAt ( i , 0 ) . toString ( ) ; String algFile = jTableAlgorithms . getModel ( ) . getValueAt ( i , 1 ) . toString ( ) ; algNames += algFile ; if ( i != jTableAlgorithms . getModel ( ) . getRowCount ( ) - 1 ) { algNames += "," ; } for ( int j = 0 ; j < jTableStreams . getModel ( ) . getRowCount ( ) ; j ++ ) { String stream = jTableStreams . getModel ( ) . getValueAt ( j , 0 ) . toString ( ) ; String streamFile = jTableStreams . getModel ( ) . getValueAt ( j , 1 ) . toString ( ) ; streamNames += streamFile . split ( " " ) [ 0 ] ; if ( j != jTableStreams . getModel ( ) . getRowCount ( ) - 1 ) { streamNames += "," ; } if ( i == 0 ) { String sfile = FilenameUtils . separatorsToSystem ( dir + "\\\\" + streamFile ) ; f = new File ( sfile ) ; f . mkdir ( ) ; } String task = " -l " ; if ( alg . split ( " " ) != null ) { task += "(" + alg + ") -s (" + stream + ")" + " -d (" + dir + File . separator + streamFile . split ( " " ) [ 0 ] + File . separator + algFile + ".txt" + ")" ; } else { task += alg + " -s (" + stream + ")" + " -d (" + dir + File . separator + streamFile . split ( " " ) [ 0 ] + File . separator + algFile + ".txt" + ")" ; } auxTask . getOptions ( ) . setViaCLIString ( task ) ; try { tasks [ taskCount ] = ( MainTask ) auxTask . copy ( ) ; } catch ( Exception ex ) { Logger . getLogger ( TaskManagerTabPanel . class . getName ( ) ) . log ( Level . SEVERE , null , ex ) ; } taskCount ++ ; } } this . jButtonRun . setEnabled ( false ) ; Buffer buffer = new Buffer ( tasks ) ; int proc = 1 ; if ( ! this . jTextFieldProcess . getText ( ) . equals ( "" ) ) { proc = Integer . parseInt ( this . jTextFieldProcess . getText ( ) ) ; } if ( proc > tasks . length ) { proc = tasks . length ; } for ( int i = 0 ; i < proc ; i ++ ) { ExpTaskThread thread = new ExpTaskThread ( buffer ) ; thread . start ( ) ; this . taskList . add ( 0 , thread ) ; this . taskTableModel . fireTableDataChanged ( ) ; this . taskTable . setRowSelectionInterval ( 0 , 0 ) ; } Thread obs = new Thread ( ) { public void run ( ) { while ( true ) { int count = 0 ; for ( ExpTaskThread thread : TaskManagerTabPanel . this . taskList ) { if ( thread . isCompleted == true ) { count ++ ; } } if ( count == TaskManagerTabPanel . this . taskList . size ( ) ) { TaskManagerTabPanel . this . summary . readData ( resultsPath ) ; TaskManagerTabPanel . this . plot . readData ( resultsPath ) ; TaskManagerTabPanel . this . analizeTab . readData ( resultsPath ) ; TaskManagerTabPanel . this . jButtonRun . setEnabled ( true ) ; break ; } } } } ; obs . start ( ) ; }
Executes the Task