blob: 28b288a4dd3b7456add5e0ed6e3f3bf5b73a30ff [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2018 Agence spatiale canadienne / Canadian Space Agency
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Pierre Allard,
* Regent L'Archeveque - initial API and implementation
*
* SPDX-License-Identifier: EPL-1.0
*******************************************************************************/
package org.eclipse.apogy.core.programs.controllers.impl;
import org.eclipse.apogy.common.emf.ApogyCommonEMFPackage;
import org.eclipse.apogy.common.emf.transaction.ApogyCommonTransactionFacade;
import org.eclipse.apogy.core.invocator.ApogyCoreInvocatorFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OperationCallControllerBindingCustomImpl extends OperationCallControllerBindingImpl {
private static final Logger Logger = LoggerFactory.getLogger(OperationCallControllerBindingImpl.class);
/**
* Whether or not the operation call is busy being executed. This is used to
* ensure that calls to the operation are NOT queued if the operation
* execution is not completed by the time it is called again. Queuing
* commands using controllers binding is typically not what we want.
*/
private boolean busy = false;
@Override
public void setStarted(boolean newStarted) {
if (isStarted() != newStarted) {
super.setStarted(newStarted);
if (getTrigger() != null) {
if (newStarted) {
getTrigger().start();
} else {
getTrigger().stop();
}
}
}
}
@Override
public void update() {
this.busy = false;
if (!this.busy && isStarted()) {
this.busy = true;
try {
ApogyCoreInvocatorFacade.INSTANCE.exec(this, isCreateResult());
} catch (Throwable t) {
Logger.error(t.getMessage(), t);
}
this.busy = false;
}
}
@Override
public void dispose() {
ApogyCommonTransactionFacade.INSTANCE.basicSet(this, ApogyCommonEMFPackage.Literals.STARTABLE__STARTED, false);
}
} // OperationCallControllerBindingImpl