]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.team.ui/src/org/simantics/team/ui/handlers/StagingOutHandler.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.team.ui / src / org / simantics / team / ui / handlers / StagingOutHandler.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.team.ui.handlers;
13
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;
25
26 public class StagingOutHandler extends AbstractPreferenceHandler {
27     public StagingOutHandler() {
28         super(Activator.getDefault());
29     }
30     @Override
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;
37         try {
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();
47             System.exit(1);
48         }
49         PlatformUI.getWorkbench().close();
50         System.exit(0);
51         return null;
52     }
53 }