/******************************************************************************* | |
* Copyright (c) 2004-2008 Andras Okros, Istvan Rath and Daniel Varro | |
* 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: | |
* Andras Okros - initial API and implementation | |
*******************************************************************************/ | |
package org.eclipse.viatra2.gtasm.trigger.view; | |
import org.eclipse.jface.resource.ImageDescriptor; | |
import org.eclipse.viatra2.framework.IFramework; | |
import org.eclipse.viatra2.frameworkgui.actions.AbstractFrameworkGUIAction; | |
import org.eclipse.viatra2.frameworkgui.views.FrameworkTreeView; | |
import org.eclipse.viatra2.gtasm.trigger.Activator; | |
import org.eclipse.viatra2.gtasm.trigger.engine.TriggerExecutionEngine; | |
/** | |
* An action for deleting triggers from the execution engine. | |
* @author Andr�s �kr�s | |
*/ | |
public class SwitchExecutionModeAction extends AbstractFrameworkGUIAction { | |
private FrameworkTreeView viewer; | |
private IFramework fw; | |
private TriggerExecutionEngine tee; | |
private static ImageDescriptor refresh_image = Activator.getImageDescriptor("icons/refresh.png"); | |
public SwitchExecutionModeAction(FrameworkTreeView part, IFramework f, TriggerExecutionEngine t ) { | |
super(); | |
setupInternals(part); | |
viewer = part; | |
fw = f; | |
tee = t; | |
setText("Switch execution mode"); | |
setToolTipText("Switches the execution mode in trigger execution engine"); | |
setImageDescriptor(refresh_image); | |
} | |
@Override | |
public boolean isEnabled() { | |
return true; | |
} | |
@Override | |
public void run() { | |
refreshSelection(); | |
Object o = getFirstSelected(); | |
if (o instanceof FrameworkViewExtension) | |
{ | |
if (!tee.isTrigger_running_flag()) | |
{ | |
boolean current = tee.isSerialExecutionMode(); | |
tee.setSerialExecutionMode(!current); | |
} else { | |
fw.getLogger().info("Trigger engine: the trigger engine mode cannot be changed during trigger processing."); | |
} | |
viewer.refreshViewer(o); | |
} | |
} | |
} | |