Skip to main content
summaryrefslogtreecommitdiffstats
blob: e16c10fe8874b12ae7c14b6ee46dc1b205ab8590 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*******************************************************************************
 * Copyright (c) 2004, 2007 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ote.ui.test.manager.models;

import java.util.concurrent.ConcurrentLinkedQueue;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.osee.ote.ui.test.manager.connection.ScriptManager;
import org.eclipse.osee.ote.ui.test.manager.pages.scriptTable.ScriptTask;

/**
 * @author Andrew M. Finkbeiner
 *
 */
public class OutputModelJob extends Job {

   private static OutputModelJob singleton = null;
   private ScriptManager scriptManager;
   private ConcurrentLinkedQueue<ScriptTask> outputModels = new ConcurrentLinkedQueue<ScriptTask>(); 
   
   
   public static void createSingleton(ScriptManager scriptManager){
      if(singleton == null){
         singleton = new OutputModelJob(scriptManager);
      }
   }
   
   public static OutputModelJob getSingleton(){
      return singleton;
   }
   
   /**
    * @param name
    */
   private OutputModelJob(ScriptManager scriptManager) {
      super("Parsing OTE Output File");
      setUser(false);
      this.scriptManager = scriptManager;
   }

   /* (non-Javadoc)
    * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
    */
   @Override
   protected IStatus run(IProgressMonitor monitor) {
      while(!outputModels.isEmpty()){
         ScriptTask task = outputModels.remove();
         task.getScriptModel().getOutputModel().updateTestPointsFromOutfile();
         task.getPassFail();
         scriptManager.updateScriptTableViewerTimed(task);
      }
      return Status.OK_STATUS;
   }
   
   public void addTask(ScriptTask task){
      outputModels.add(task);
      schedule();
   }
   
}

Back to the top