package com.intuso.housemate.web.client.bootstrap.widget.application.instance;

import com.intuso.housemate.web.client.bootstrap.extensions.CommandToggleSwitch;
import com.intuso.housemate.web.client.object.GWTProxyApplicationInstance;
import com.intuso.housemate.web.client.object.GWTProxyCommand;

/**
 * Created with IntelliJ IDEA.
 * User: tomc
 * Date: 10/02/14
 * Time: 18:49
 * To change this template use File | Settings | File Templates.
 */
public class AccessWidget extends CommandToggleSwitch {

    private GWTProxyApplicationInstance applicationInstance;

    public AccessWidget() {
        setOnText("Allowed");
        setOffText("Rejected");
    }

    public void setApplicationInstance(GWTProxyApplicationInstance applicationInstance) {
        this.applicationInstance = applicationInstance;
        setValue(applicationInstance.getStatusValue());
    }

    @Override
    protected boolean isTrue() {
        return applicationInstance.getStatus() == com.intuso.housemate.object.v1_0.api.ApplicationInstance.Status.Allowed;
    }

    @Override
    protected GWTProxyCommand getTrueCommand() {
        return applicationInstance.getRejectCommand();
    }

    @Override
    protected GWTProxyCommand getFalseCommand() {
        return applicationInstance.getAllowCommand();
    }
}

@@ -1147,22 +1147,21 @@
 ance.get
-Reject
+Allow
 Command(
@@ -1264,37 +1264,38 @@
 tionInstance.get
-Allow
+Reject
 Command();%0A    %7D

Fix allowing/rejecting application access through ui