summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/Ust2Handler.java
blob: 9e18097c4c8763a2a4e34b035cda71159bc08b1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*******************************************************************************
 * Copyright (c) 2010 Intel Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * Intel - initial API and implementation
 *******************************************************************************/
package org.yocto.sdk.remotetools.actions;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
import org.eclipse.ui.progress.IProgressService;

import org.yocto.sdk.remotetools.Messages;

public class Ust2Handler extends AbstractHandler {

	public Object execute(ExecutionEvent event) throws ExecutionException {
		
		//if(UstModel.checkAvail()!=true) {
		//	return null;
		//}
		
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);

		Ust2SettingDialog setting=new Ust2SettingDialog(
				window.getShell()
				);
		
		if(setting.open()==BaseSettingDialog.OK) {
			IProgressService progressService = PlatformUI.getWorkbench().getProgressService();
			String project = setting.getProject();
			if (project == null) {
				MessageDialog.openError(window.getShell(), "Lttng-ust", Messages.ErrorUstProject);
				return null;
			}
			Ust2Model op=new Ust2Model(setting.getHost(),setting.getTrace(), project, window);
			try {
				progressService.busyCursorWhile(op);
			}catch (InterruptedException e) {
				//user cancelled
			}catch (Exception e) {
				e.printStackTrace();
				MessageDialog.openError(window.getShell(),
						"Ust",
						(e.getCause() != null) ? e.getCause().getMessage() : e.getMessage());
			}
		}
		return null;
	}
}