Search in sources :

Example 1 with IDockerImageHierarchyContainerNode

use of org.eclipse.linuxtools.docker.core.IDockerImageHierarchyContainerNode in project linuxtools by eclipse.

the class ContainerPropertyTester method test.

@Override
public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
    if (receiver instanceof IDockerContainer) {
        IDockerContainer container = (IDockerContainer) receiver;
        /*
			 * The 'receiver' is not updated if the selection remains unchanged
			 * but a context menu command may have modified container state
			 * requiring a change in menu items.
			 */
        final IDockerContainer newContainer = container.getConnection().getContainer(container.id());
        if (newContainer != null) {
            container = newContainer;
        }
        switch(property) {
            case IS_RUNNING:
                return checkIfStateMatchesExpectation(container, EnumDockerStatus.RUNNING, expectedValue);
            case IS_STOPPED:
                return checkIfStateMatchesExpectation(container, EnumDockerStatus.STOPPED, expectedValue);
            case IS_UNKNOWN:
                return checkIfStateMatchesExpectation(container, EnumDockerStatus.UNKNOWN, expectedValue);
            case IS_PAUSED:
                return checkIfStateMatchesExpectation(container, EnumDockerStatus.PAUSED, expectedValue);
            case IS_REMOVABLE:
                return checkIfStateMatchesExpectation(container, EnumDockerStatus.STOPPED, expectedValue) || checkIfStateMatchesExpectation(container, EnumDockerStatus.UNKNOWN, expectedValue);
        }
    } else if (receiver instanceof IDockerImageHierarchyContainerNode) {
        return test(((IDockerImageHierarchyContainerNode) receiver).getElement(), property, args, expectedValue);
    }
    return false;
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) IDockerImageHierarchyContainerNode(org.eclipse.linuxtools.docker.core.IDockerImageHierarchyContainerNode)

Aggregations

IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)1 IDockerImageHierarchyContainerNode (org.eclipse.linuxtools.docker.core.IDockerImageHierarchyContainerNode)1