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

it.tidalwave.integritychecker.ui.impl.action.ScanActionEnablerActor Maven / Gradle / Ivy

The newest version!
/*
 * #%L
 * *********************************************************************************************************************
 * 
 * SolidBlue - open source safe data
 * http://solidblue.tidalwave.it - hg clone https://bitbucket.org/tidalwave/solidblue-src
 * %%
 * Copyright (C) 2011 - 2014 Tidalwave s.a.s. (http://tidalwave.it)
 * %%
 * *********************************************************************************************************************
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations under the License.
 * 
 * *********************************************************************************************************************
 * 
 * $Id$
 * 
 * *********************************************************************************************************************
 * #L%
 */
package it.tidalwave.integritychecker.ui.impl.action;

import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.annotation.concurrent.NotThreadSafe;
import it.tidalwave.messagebus.annotation.ListensTo;
import it.tidalwave.actor.CollaborationCompletedMessage;
import it.tidalwave.actor.CollaborationStartedMessage;
import it.tidalwave.actor.annotation.Actor;
import it.tidalwave.actor.annotation.OriginatedBy;
import it.tidalwave.integritychecker.archive.ScanArchiveCreatedMessage;
import it.tidalwave.integritychecker.archive.ScanArchiveOpenedMessage;
import it.tidalwave.integritychecker.archive.ScanRequest;
import it.tidalwave.netbeans.action.ActionProxy;
import lombok.extern.slf4j.Slf4j;

/***********************************************************************************************************************
 * 
 * This actor manages the enablement status of actions of this module.
 * 
 * @stereotype Actor
 * @stereotype Control
 * 
 * FIXME: possibly push this to the UI module independent of NetBeans
 * 
 * @author  Fabrizio Giudici
 * @version $Id$
 *
 **********************************************************************************************************************/
@Actor(threadSafe=false) @NotThreadSafe @Slf4j
public class ScanActionEnablerActor
  {
//    private final ActionProxy openActionProxy = new ActionProxy(OpenAction.class);
//    private final ActionProxy scanActionProxy = new ActionProxy(ScanAction.class);
    private final ActionProxy openActionProxy = new ActionProxy("File", "it-tidalwave-integritychecker-ui-impl-action-OpenAction");
    private final ActionProxy scanActionProxy = new ActionProxy("Tools", "it-tidalwave-integritychecker-ui-impl-action-ScanAction");
    
    @PostConstruct
    public void initialize()
      {
        openActionProxy.setEnabled(true);  
        scanActionProxy.setEnabled(false);  
      }
    
    void onScanArchiveOpened (final @ListensTo @Nonnull ScanArchiveOpenedMessage message)
      {
        scanActionProxy.setEnabled(true);
      }
    
    void onScanArchiveCreated (final @ListensTo @Nonnull ScanArchiveCreatedMessage message)
      {
        scanActionProxy.setEnabled(true);
      }
    
    void onScanStarted (final @ListensTo @Nonnull CollaborationStartedMessage cMessage,
                        final @OriginatedBy @Nonnull ScanRequest message)
      {
        openActionProxy.setEnabled(false);
        scanActionProxy.setEnabled(false);
      }
    
    void onScanCompleted (final @ListensTo @Nonnull CollaborationCompletedMessage cMessage,
                          final @OriginatedBy @Nonnull ScanRequest message)
      {
        openActionProxy.setEnabled(true);
        scanActionProxy.setEnabled(true);
      }
  }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy