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.eclipse.core.runtime.Platform;
19 import org.simantics.Simantics;
20 import org.simantics.db.Session;
21 import org.simantics.team.Activator;
22 import org.simantics.team.ui.CommentDialog;
23 import org.simantics.team.ui.StageInitWizard;
24 import org.simantics.ui.workbench.handler.AbstractPreferenceHandler;
25 import org.simantics.utils.ui.dialogs.ShowError;
27 public class StageInitHandler extends AbstractPreferenceHandler {
29 public StageInitHandler() {
30 super(Activator.getDefault());
32 private void showError(String msg, Throwable t) {
33 String title = "Staging Initialization";
34 ShowError.showError(title, msg, t);
37 public Object execute(ExecutionEvent event) throws ExecutionException {
38 System.out.println("DEBUG: " + this.getClass().getName());
40 Session session = Simantics.getSession();
41 File wsFolder = new File(Platform.getInstanceLocation().getURL().getFile());
42 File stFolder = new File(wsFolder, "staging");
43 final StageInitWizard.Data data = new StageInitWizard.Data(stFolder, null);
44 if (!StageInitWizard.openInitWizard(data))
45 return null; // User cancelled the operation.
46 File tf = data.teamFolder;
47 assert(null != tf && tf.isDirectory() && tf.list().length == 0);
48 CommentDialog.Data commentData = CommitAllHandler.commitAll(data.teamFolder, true); // init
50 return null; // User cancelled the operation.
51 //Utils.setTeamFolder(tf);
52 SynchroniseAllHandler.pullAll(session, tf, stFolder);
53 SynchroniseAllHandler.show(session, tf, stFolder);
54 } catch (Throwable t) {
55 showError("Failed!", t);