Package controller.tools.flowmanager.push

Source Code of controller.tools.flowmanager.push.ActionManagerPusher

package controller.tools.flowmanager.push;

import java.util.List;

import model.tools.flowmanager.Action;
import model.tools.flowmanager.Flow;

import org.eclipse.swt.widgets.TableItem;

public class ActionManagerPusher {

  public static void addAction(TableItem[] items, Action action, Flow flow) {

      List<Action> actions = flow.getActions();
     
      if(actions.contains(action)){
          modifyAction(items, action);
      }
      else{
        // Construct the action
        if(action.getType().equals("enqueue")) {
                    action = new Action(items[2].getText(1), items[0].getText(1)
                        + ":" + items[1].getText(1));
                    actions.add(action);
        } else if (action.getType().equals("strip-vlan")) {
                    action = new Action(items[0].getText(1));
                    actions.add(action);
        } else {
                    action = new Action(items[1].getText(1), items[0].getText(1));
                    actions.add(action);
       
      }
  }
 
  public static void modifyAction(TableItem[] items, Action action){
        String actionType = action.getType();
       
        // Construct the action
        if(actionType.equals("enqueue")) {
                action.setValue(items[0].getText(1)
                        + ":" + items[1].getText(1));
        } else {
                action.setValue(items[0].getText(1));
        }
  }
 

  public static void removeAction(Flow flow, Action action) {
    List<Action> actions = flow.getActions();
    if(actions.contains(action)){
        actions.remove(action);
    }
  }

  // Removes all the actions
  public static void removeAllActions(Flow flow) {
    List<Action> actions = flow.getActions();
    actions.clear();
  }
}
TOP

Related Classes of controller.tools.flowmanager.push.ActionManagerPusher

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.