001/*
002 * JPPF.
003 * Copyright (C) 2005-2016 JPPF Team.
004 * http://www.jppf.org
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *   http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.jppf.node.screensaver.impl;
019
020import org.jppf.node.event.NodeLifeCycleEvent;
021import org.jppf.node.screensaver.*;
022
023/**
024 * Instances of this class represent information about a node.
025 * @since 4.0
026 */
027public class NodeState extends NodeIntegrationAdapter {
028  /**
029   * The node panel to update.
030   */
031  protected NodePanel nodePanel = null;
032
033  @Override
034  public void nodeStarting(final NodeLifeCycleEvent event) {
035    if (nodePanel != null) {
036      nodePanel.updateConnectionStatus(true);
037      nodePanel.updateExecutionStatus(false);
038    }
039  }
040
041  @Override
042  public void nodeEnding(final NodeLifeCycleEvent event) {
043    if (nodePanel != null) {
044      nodePanel.updateConnectionStatus(false);
045      nodePanel.updateExecutionStatus(false);
046    }
047  }
048
049  @Override
050  public void jobStarting(final NodeLifeCycleEvent event) {
051    if (nodePanel != null) nodePanel.updateExecutionStatus(true);
052  }
053
054  @Override
055  public void jobEnding(final NodeLifeCycleEvent event) {
056    if (nodePanel != null) {
057      nodePanel.updateExecutionStatus(false);
058      nodePanel.incTaskCount(event.getTasks().size());
059    }
060  }
061
062  @Override
063  public void setUiComponent(final JPPFScreenSaver screensaver) {
064    this.nodePanel = ((JPPFScreenSaverImpl) screensaver).getNodePanel();
065  }
066}