1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.team.ui.handlers;
16 import org.eclipse.core.commands.AbstractHandler;
17 import org.eclipse.core.commands.ExecutionEvent;
18 import org.eclipse.core.commands.ExecutionException;
19 import org.eclipse.core.runtime.Platform;
20 import org.eclipse.jface.viewers.ISelection;
21 import org.eclipse.jface.viewers.IStructuredSelection;
22 import org.eclipse.ui.handlers.HandlerUtil;
23 import org.simantics.db.ChangeSetIdentifier;
24 import org.simantics.db.Session;
25 import org.simantics.db.common.utils.Logger;
26 import org.simantics.db.service.ManagementSupport;
27 import org.simantics.db.service.TeamSupport;
28 import org.simantics.team.ui.Command;
29 import org.simantics.ui.SimanticsUI;
31 public class DumpToSelectedRevisionHandler extends AbstractHandler {
32 public DumpToSelectedRevisionHandler() {
35 public Object execute(ExecutionEvent event) throws ExecutionException {
36 ISelection sel = HandlerUtil.getCurrentSelection(event);
37 if (sel instanceof IStructuredSelection) {
38 IStructuredSelection ss = (IStructuredSelection)sel;
40 Object o = ss.getFirstElement();
41 if (null == o || !(o instanceof Command))
43 Command command = (Command)o;
44 ChangeSetIdentifier csi = command.getChangeSetIdentifier();
47 long csid = csi.getId();
48 Session session = SimanticsUI.getSession();
49 ManagementSupport ms = session.getService(ManagementSupport.class);
50 ms.dumpRevision(csid);
51 File wsFolder = new File(Platform.getInstanceLocation().getURL().getFile());
52 File frFolder = new File(wsFolder, "db");
53 File toFolder = new File(wsFolder, "Dump-ws");
54 TeamSupport ts = session.getService(TeamSupport.class);
55 ts.dump(frFolder, toFolder, csid);
56 SynchroniseAllHandler.show(session, null, toFolder);
57 } catch (Exception e) {
58 Logger.defaultLogError(e);