summaryrefslogtreecommitdiffstats
path: root/plugins/org.yocto.sdk.remotetools/src/org/yocto/sdk/remotetools/actions/DialogHandler.java
blob: 231de7733a19ea15c3373c23492b1797bd24c6be (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
/*******************************************************************************
 * Copyright (c) 2013 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.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.rse.core.model.IHost;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.handlers.HandlerUtil;
import org.yocto.remote.utils.TerminalHandler;

abstract public class DialogHandler extends TerminalHandler {

	protected BaseSettingDialog setting;

	abstract protected String getDialogTitle();

	protected void initialize(ExecutionEvent event) throws ExecutionException{
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		shell = window.getShell();
		setting = new SimpleSettingDialog(shell, getDialogTitle(), getConnnectionName());
	}

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		initialize(event);

		if(setting.open() == BaseSettingDialog.OK) {
			IHost currentHost = setting.getHost();
			execute(currentHost);
		}
		return null;
	}
}