1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.handlers
;
14 import java
.util
.Iterator
;
16 import org
.eclipse
.core
.commands
.ExecutionEvent
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.jface
.viewers
.ISelection
;
19 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TargetNodeState
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.ControlView
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceControlComponent
;
24 import org
.eclipse
.ui
.IWorkbenchPage
;
28 * Command handler implementation to refresh node configuration.
31 * @author Bernd Hufmann
33 public class RefreshHandler
extends BaseControlViewHandler
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
40 * The node component reference.
42 private TargetNodeComponent fNode
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
49 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
60 public boolean isEnabled() {
62 // Get workbench page for the Control View
63 IWorkbenchPage page
= getWorkbenchPage();
68 TargetNodeComponent node
= null;
69 // Check if one or more session are selected
70 ISelection selection
= page
.getSelection(ControlView
.ID
);
71 if (selection
instanceof StructuredSelection
) {
73 StructuredSelection structered
= ((StructuredSelection
) selection
);
74 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
75 Object element
= iterator
.next();
76 if (element
instanceof TraceControlComponent
) {
77 TraceControlComponent component
= (TraceControlComponent
) element
;
78 boolean isConnected
= component
.getTargetNodeState() == TargetNodeState
.CONNECTED
;
80 while ((component
!= null) && component
.getClass() != TargetNodeComponent
.class) {
81 component
= (TraceControlComponent
) component
.getParent();
83 if (component
!= null) {
84 node
= (TargetNodeComponent
) component
;
91 boolean isEnabled
= node
!= null;