/** * ************************************************************************* The command has been * executed, so extract extract the needed information from the application context. * ************************************************************************ */ public CommandResult execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class); String instanceId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION); try { IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class); IProcedure proc = null; if (mgr.isLocallyLoaded(instanceId)) { proc = mgr.getProcedure(instanceId); } else { proc = mgr.getRemoteProcedure(instanceId); } List<AsRunFile> toExport = new LinkedList<AsRunFile>(); ExportAsRunFileJob job = new ExportAsRunFileJob(proc); CommandHelper.executeInProgress(job, true, true); if (job.result.equals(CommandResult.SUCCESS)) { toExport.add(job.asrunFile); if (!job.asrunFile.getChildren().isEmpty()) { boolean alsoChildren = MessageDialog.openQuestion( window.getShell(), "Export children ASRUN files", "This procedure has executed sub-procedures.\n\nDo you want to export these ASRUN files as well?"); if (alsoChildren) { gatherChildAsRunFiles(job.asrunFile, toExport); } } } DirectoryDialog dialog = new DirectoryDialog(window.getShell(), SWT.SAVE); dialog.setMessage( "Select directory to export ASRUN file(s) for '" + proc.getProcName() + "'"); dialog.setText("Export ASRUN"); String destination = dialog.open(); if (destination != null && !destination.isEmpty()) { SaveAsRunFileJob saveJob = new SaveAsRunFileJob(destination, toExport); CommandHelper.executeInProgress(saveJob, true, true); return saveJob.result; } else { return CommandResult.NO_EFFECT; } } catch (Exception ex) { ex.printStackTrace(); return CommandResult.FAILED; } }
@Override public Object execute(ExecutionEvent event) throws ExecutionException { /* * Retrieve data */ String procId = event.getParameter(ARG_PROCID); /* * Retrieve the procedure */ IProcedureManager mgr = (IProcedureManager) ServiceManager.get(IProcedureManager.class); IProcedure proc = mgr.getProcedure(procId); proc.getController().recover(); return CommandResult.SUCCESS; }
@Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { boolean result = false; IRuntimeSettings runtime = (IRuntimeSettings) ServiceManager.get(IRuntimeSettings.class); if (s_proc == null) { s_proc = (IProcedureManager) ServiceManager.get(IProcedureManager.class); } String procId = (String) runtime.getRuntimeProperty(RuntimeProperty.ID_PROCEDURE_SELECTION); if ((procId != null) && (procId.length() > 0) && (s_proc.isLocallyLoaded(procId))) { result = true; } return result; }
/** * ************************************************************************* Refresh the selected * procedure. In case of failure, refresh the whole list, since the procedure may habe disappeared * ************************************************************************ */ public void refresh(String procId) { try { IProcedure proc = s_procMgr.getProcedure(procId); Logger.debug("Refreshing procedure with id " + procId, Level.GUI, this); Logger.debug("Executor details " + proc.getProcId(), Level.GUI, this); Logger.debug(" instance " + proc, Level.GUI, this); Logger.debug( " controlling client " + proc.getRuntimeInformation().getControllingClient(), Level.GUI, this); Logger.debug( " monitoring clients " + proc.getRuntimeInformation().getMonitoringClients(), Level.GUI, this); refresh(proc); } catch (Exception ex) { refresh(); } }