Search in sources :

Example 6 with Session

use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.

the class LoadResources method execute.

@Override
public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) {
    EObject element = selections.iterator().next();
    Session session = SessionManager.INSTANCE.getSession(element);
    for (Object p : parameters.values()) {
        URI uri = URI.createURI(p.toString());
        if (!SiriusCustomUtil.uriAlreadyLoaded(uri, session))
            session.addSemanticResource(uri, new NullProgressMonitor());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) EObject(org.eclipse.emf.ecore.EObject) EObject(org.eclipse.emf.ecore.EObject) URI(org.eclipse.emf.common.util.URI) Session(org.eclipse.sirius.business.api.session.Session)

Example 7 with Session

use of org.eclipse.sirius.business.api.session.Session in project Palladio-Editors-Sirius by PalladioSimulator.

the class AllocationCreationWizard method finish.

@Override
protected void finish() {
    Allocation allocation = (Allocation) modelObject;
    Session session = SessionManager.INSTANCE.getSession(modelObject);
    TransactionalEditingDomain domain = session.getTransactionalEditingDomain();
    String fileString = modelURI.toPlatformString(true);
    IPath path = new Path(fileString);
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
    List<IFile> list = new ArrayList<IFile>();
    list.add(file);
    AbstractTransactionalCommand command = new AbstractTransactionalCommand(domain, "Save Allocation model.", list) {

        @Override
        protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
            allocation.setTargetResourceEnvironment_Allocation(resourceEnvironmentSelectorpage.getSelectedResourceEnvironment(session));
            allocation.setSystem_Allocation(systemSelectorPage.getSelectedSystem(session));
            return CommandResult.newOKCommandResult();
        }
    };
    try {
        OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null);
    } catch (ExecutionException e) {
        System.out.println("Unable to save allocation model.");
        e.printStackTrace();
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IAdaptable(org.eclipse.core.runtime.IAdaptable) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) ArrayList(java.util.ArrayList) AbstractTransactionalCommand(org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TransactionalEditingDomain(org.eclipse.emf.transaction.TransactionalEditingDomain) Allocation(org.palladiosimulator.pcm.allocation.Allocation) ExecutionException(org.eclipse.core.commands.ExecutionException) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

Session (org.eclipse.sirius.business.api.session.Session)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 URI (org.eclipse.emf.common.util.URI)4 EObject (org.eclipse.emf.ecore.EObject)4 ArrayList (java.util.ArrayList)3 Viewpoint (org.eclipse.sirius.viewpoint.description.Viewpoint)3 HashSet (java.util.HashSet)2 DRepresentation (org.eclipse.sirius.viewpoint.DRepresentation)2 RepresentationDescription (org.eclipse.sirius.viewpoint.description.RepresentationDescription)2 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IFile (org.eclipse.core.resources.IFile)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 TransactionalEditingDomain (org.eclipse.emf.transaction.TransactionalEditingDomain)1 AbstractTransactionalCommand (org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand)1 Allocation (org.palladiosimulator.pcm.allocation.Allocation)1 PCMRandomVariable (org.palladiosimulator.pcm.core.PCMRandomVariable)1