All Downloads are FREE. Search and download functionalities are using the official Maven repository.

xworker.app.userflow.NewTaskNotifier Maven / Gradle / Ivy

The newest version!
package xworker.app.userflow;

import org.eclipse.swt.widgets.Shell;
import org.xmeta.ActionContext;
import org.xmeta.Thing;
import org.xmeta.World;
import xworker.dataObject.DataObject;
import xworker.lang.util.XWorkerUtils;

import java.util.ArrayList;

public class NewTaskNotifier implements UserFlowListener{
    private static final NewTaskNotifier instance = new NewTaskNotifier();
    static {
        UserFlowManager.addListener(instance);
    }
    ArrayList tasks = new ArrayList<>();

    private NewTaskNotifier(){

    }

    @Override
    public void started(Thing thing, DataObject task) {
        if(!tasks.contains(thing) && !thing.getBoolean("autoRun") && !"TaskGroup".equals(thing.getThingName())) {
            //autoRun的通常是后台任务
            tasks.add(thing);
        }
    }

    @Override
    public void finished(Thing thing, DataObject task) {
        tasks.remove(thing);
    }

    public static void clear(){
        instance.tasks.clear();
    }

    public static void showDialog(){
        Object parent = XWorkerUtils.getIde().getIDEShell();
        ActionContext actionContext = new ActionContext();
        actionContext.put("parent", parent);
        actionContext.put("tasks", instance.tasks);

        Thing thing;
        if(instance.tasks.size() > 0){
            thing = World.getInstance().getThing("xworker.app.userflow.swt.prototype.NewTaskArrivedDialog");

        } else {
            thing = World.getInstance().getThing("xworker.app.userflow.swt.prototype.NoTaskDialog");
        }

        Shell shell = thing.doAction("create", actionContext);
        shell.setVisible(true);
    }

    public static boolean hasTasks(){
        return instance.tasks.size() > 0;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy