package CDModeler.buttons; import gui.Constants; import gui.CoupledAnimateDialog; import gui.CoupledAnimateIf; import gui.InformDialog; import gui.OkCancelJDialog; import java.io.File; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; /** * * This class will execute the CDModeler Coupled Animation program. * @author Jing Cao * @see IWorkbenchWindowActionDelegate * @version 1.0 */ public class CoupledAnimationAction implements IWorkbenchWindowActionDelegate { //constructor public CoupledAnimationAction() { } /** * Called when the action is executed * @see IWorkbenchWindowActionDelegate#run */ public void run(IAction action) { CoupledAnimateDialog acoupledAnimateDialog = new CoupledAnimateDialog(null, "coupled animate", true); acoupledAnimateDialog.setLocationRelativeTo(null); acoupledAnimateDialog.setVisible(true); if (acoupledAnimateDialog.getReturnState() == OkCancelJDialog.OK_RETURN_STATE) { try { File model = new File(acoupledAnimateDialog.getModel()); File log = new File(acoupledAnimateDialog.getLog()); CoupledAnimateIf aCoupledAnimate = (CoupledAnimateIf)Class.forName(Constants.getInstance().getString("coupledAnimate", "gui.animate.coupled.CoupledAnimate")).newInstance(); aCoupledAnimate.init(model, log, acoupledAnimateDialog.getElapse()); aCoupledAnimate.setLocationRelativeTo(null); aCoupledAnimate.setVisible(true); } catch (Exception ex) { new InformDialog(ex.toString(),ex).setVisible(true); } } } /** * Called when objects in the editor are selected or deselected. * @see IWorkbenchWindowActionDelegate#selectionChanged */ public void selectionChanged(IAction action, ISelection selection) { } /** * Called when the action is discarded. * @see IWorkbenchWindowActionDelegate#dispose */ public void dispose() { } /** * Called when the action is created. * @see IWorkbenchWindowActionDelegate#init */ public void init(IWorkbenchWindow window) { } }