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.ExecutionEvent;
17 import org.eclipse.core.commands.ExecutionException;
18 import org.simantics.Simantics;
19 import org.simantics.db.Session;
20 import org.simantics.db.exception.DatabaseException;
21 import org.simantics.db.service.TeamSupport;
22 import org.simantics.team.Activator;
23 import org.simantics.team.Utils;
24 import org.simantics.team.ui.CommentDialog;
25 import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;
27 public class CommitAllHandler extends AbstractPreferenceHandler {
29 public CommitAllHandler() {
30 super(Activator.getDefault());
33 public Object execute(ExecutionEvent event) throws ExecutionException {
34 System.out.println("CommitAllHandler");
35 // ISelection sel = HandlerUtil.getCurrentSelection(event);
36 // IStructuredSelection ss = StructuredSelection.EMPTY;
37 // if (sel instanceof IStructuredSelection)
38 // ss = (IStructuredSelection) sel;
40 File teamFolder = Utils.getTeamFolder();
41 commitAll(teamFolder, false); // Don't initialize.
42 } catch (DatabaseException e) {
43 throw new ExecutionException("Failed to commit.", e);
47 static CommentDialog.Data commitAll(File teamFolder, boolean init)
48 throws DatabaseException {
49 Session session = Simantics.getSession();
50 TeamSupport ts = session.getService(TeamSupport.class);
51 final CommentDialog.Data data = new CommentDialog.Data("Commit Comment");
52 if (CommentDialog.openCommentDialog(data))
53 ts.commit(data.comment, teamFolder, init);