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;
14 import org.eclipse.core.commands.ExecutionEvent;
15 import org.eclipse.core.commands.ExecutionException;
16 import org.eclipse.ui.PlatformUI;
17 import org.simantics.db.Session;
18 import org.simantics.db.exception.DatabaseException;
19 import org.simantics.db.service.TeamSupport;
20 import org.simantics.team.Activator;
21 import org.simantics.team.Utils;
22 import org.simantics.team.ui.CommentDialog;
23 import org.simantics.ui.SimanticsUI;
24 import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;
26 public class StagingOutHandler extends AbstractPreferenceHandler {
27 public StagingOutHandler() {
28 super(Activator.getDefault());
31 public Object execute(ExecutionEvent event) throws ExecutionException {
32 System.out.println("push and exit");
33 // ISelection sel = HandlerUtil.getCurrentSelection(event);
34 // IStructuredSelection ss = StructuredSelection.EMPTY;
35 // if (sel instanceof IStructuredSelection)
36 // ss = (IStructuredSelection) sel;
38 Session session = SimanticsUI.getSession();
39 TeamSupport ts = session.getService(TeamSupport.class);
40 final CommentDialog.Data data = new CommentDialog.Data("Staging Comment");
41 if (!CommentDialog.openCommentDialog(data))
42 return null; // User cancelled operation.
43 ts.commit(data.comment, Utils.getTeamFolder(), false);
44 } catch (DatabaseException e) {
45 //throw new ExecutionException("Failed to publish.", e);
46 PlatformUI.getWorkbench().close();
49 PlatformUI.getWorkbench().close();