1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson and others
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Bernd Hufmann - Initial API and implementation
11 * Anna Dushistova(Montavista) - [382684] Allow reusing already defined connections that have Files and Shells subsystems
12 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
13 **********************************************************************/
14 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.handlers
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.window
.Window
;
19 import org
.eclipse
.remote
.core
.IRemoteConnection
;
20 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
21 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
.INewConnectionDialog
;
22 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
.TraceControlDialogFactory
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.ITraceControlComponent
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
25 import org
.eclipse
.ui
.IWorkbenchPage
;
26 import org
.eclipse
.ui
.IWorkbenchPart
;
27 import org
.eclipse
.ui
.IWorkbenchWindow
;
28 import org
.eclipse
.ui
.PlatformUI
;
32 * Command handler for creation new connection for trace control.
35 * @author Bernd Hufmann
37 public class NewConnectionHandler
extends BaseControlViewHandler
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * The parent trace control component the new node will be added to.
46 private ITraceControlComponent fRoot
= null;
49 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
50 assert (fRoot
!= null);
52 IWorkbenchWindow window
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow();
57 // Open dialog box for the node name and address
58 final INewConnectionDialog dialog
= TraceControlDialogFactory
.getInstance().getNewConnectionDialog();
60 if (dialog
.open() != Window
.OK
) {
64 IRemoteConnection host
= dialog
.getConnection();
68 // successful creation of host
69 TargetNodeComponent node
= null;
70 if (!fRoot
.containsChild(host
.getName())) {
71 node
= new TargetNodeComponent(host
.getName(), fRoot
, host
);
74 node
= (TargetNodeComponent
)fRoot
.getChild(host
.getName());
86 public boolean isEnabled() {
88 // Get workbench page for the Control View
89 IWorkbenchPage page
= getWorkbenchPage();
94 ITraceControlComponent root
= null;
96 // no need to verify part because it has been already done in getWorkbenchPage()
97 IWorkbenchPart part
= page
.getActivePart();
98 root
= ((ControlView
) part
).getTraceControlRoot();
100 boolean isEnabled
= root
!= null;