@Override public Object execute(final ExecutionEvent event) throws ExecutionException { final IEvaluationContext context = (IEvaluationContext) event.getApplicationContext(); /* Get the map */ final IWorkbenchWindow window = (IWorkbenchWindow) context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); final IWorkbenchPage activePage = window.getActivePage(); /* set input to gtt tables */ final IScenarioDataProvider dataProvider = KalypsoAFGUIFrameworkPlugin.getDataProvider(); final IFolder scenarioFolder = (IFolder) dataProvider.getScenarioFolder(); KalypsoCorePlugin.getDefault().getSelectionManager().clear(); WorkflowHandlerUtils.setGttInput( activePage, "NaNodes", "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:NaNodes:gtt", Messages.getString("ResultOutputManagementTaskHandler_0"), scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ WorkflowHandlerUtils.setGttInput( activePage, "Catchments", "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:Catchments:gtt", Messages.getString("ResultOutputManagementTaskHandler_1"), scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ WorkflowHandlerUtils.setGttInput( activePage, "StorageChannels", "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:StorageChannels:gtt", Messages.getString("ResultOutputManagementTaskHandler_2"), scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ WorkflowHandlerUtils.setGftInput( activePage, "Outputs", "urn:org.kalypso.model.rrm.resultOutputManagement:workflow:Outputs:gft", Messages.getString("ResultOutputManagementTaskHandler_3"), scenarioFolder); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return null; }
@Override public IStatus execute(final IProgressMonitor monitor) throws CoreException, InvocationTargetException { monitor.beginTask( Messages.getString("RemoveEventOperation_0"), m_treeSelection.length + 10); // $NON-NLS-1$ final Collection<IStatus> removeResults = new ArrayList<>(); try { for (final Object element : m_treeSelection) { final Feature featureToRemove = (Feature) element; monitor.subTask( String.format( String.format( Messages.getString("RemoveEventOperation_1"), featureToRemove.getName()))); // $NON-NLS-1$ final IStatus removeResult = removeEvent( featureToRemove, new SubProgressMonitor( monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK)); if (!removeResult.isOK()) removeResults.add(removeResult); } /* Save model, as undo is not possible here and the user should not be able to revert the changes */ monitor.subTask(Messages.getString("RemoveEventOperation_2")); // $NON-NLS-1$ m_provider.saveModel(IFloodModel.class.getName(), new SubProgressMonitor(monitor, 10)); } catch (final Exception e) { if (e instanceof CoreException) throw (CoreException) e; throw new InvocationTargetException(e); } if (removeResults.size() == 0) return Status.OK_STATUS; final IStatus[] children = removeResults.toArray(new IStatus[removeResults.size()]); return new MultiStatus( KalypsoModelFloodPlugin.PLUGIN_ID, 0, children, Messages.getString("RemoveEventOperation_3"), null); //$NON-NLS-1$ }
private IStatus removeEvent(final Feature featureToRemove, final IProgressMonitor monitor) throws CoreException, Exception { final String msg = String.format( Messages.getString("RemoveEventOperation_4"), featureToRemove.getName()); // $NON-NLS-1$ monitor.beginTask(msg, 100); final IRunoffEvent runoffEvent = (IRunoffEvent) featureToRemove.getAdapter(IRunoffEvent.class); IStatus removeResult = null; if (runoffEvent != null) { monitor.subTask(Messages.getString("RemoveEventOperation_5")); // $NON-NLS-1$ deleteThemes(m_wspThemes, runoffEvent); monitor.worked(10); /* Delete underlying tin files */ monitor.subTask(Messages.getString("RemoveEventOperation_6")); // $NON-NLS-1$ final ICoverageCollection resultCoverages = runoffEvent.getResultCoverages(); removeResult = FloodModelHelper.removeResultCoverages(m_provider, resultCoverages); monitor.worked(60); /* Delete event folder */ monitor.subTask(Messages.getString("RemoveEventOperation_7")); // $NON-NLS-1$ final IFolder eventFolder = EventManagementWidget.getEventFolder(runoffEvent); eventFolder.delete(true, new SubProgressMonitor(monitor, 20)); } /* Delete coverage from collection */ monitor.subTask(Messages.getString("RemoveEventOperation_8")); // $NON-NLS-1$ final CommandableWorkspace workspace = m_provider.getCommandableWorkSpace(IFloodModel.class.getName()); final DeleteFeatureCommand command = new DeleteFeatureCommand(featureToRemove); workspace.postCommand(command); monitor.worked(10); // TODO: Probably we need a more sophisticated error handling here if (removeResult != null) return removeResult; return Status.OK_STATUS; }