blob: a6fb42a9be7c79d962534386285e73a44900ec4c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2009, 2019 Xored Software Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-v20.html
*
* Contributors:
* Xored Software Inc - initial API and implementation and/or initial documentation
*******************************************************************************/
package org.eclipse.rcptt.ecl.internal.core;
import static org.eclipse.rcptt.ecl.internal.core.GlobalService.getGlobals;
import static org.eclipse.rcptt.ecl.internal.core.ProcService.getProcs;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.rcptt.ecl.core.Command;
import org.eclipse.rcptt.ecl.core.CoreFactory;
import org.eclipse.rcptt.ecl.core.Declaration;
import org.eclipse.rcptt.ecl.core.Proc;
import org.eclipse.rcptt.ecl.core.SessionState;
import org.eclipse.rcptt.ecl.runtime.ICommandService;
import org.eclipse.rcptt.ecl.runtime.IProcess;
public class SaveStateService implements ICommandService {
public IStatus service(Command command, IProcess context)
throws InterruptedException, CoreException {
LocalProcManager procs = getProcs(context);
DeclarationContainer globals = getGlobals(context);
SessionState state = CoreFactory.eINSTANCE.createSessionState();
for (Proc proc : procs.declarations()) {
state.getProcs().add(EcoreUtil.copy(proc));
}
for (Declaration decl : globals.declarations()) {
state.getDecls().add(decl);
}
context.getOutput().write(state);
return Status.OK_STATUS;
}
}