1 /**********************************************************************
2 * Copyright (c) 2012 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
.ui
.views
.control
.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
.ui
.views
.control
.ControlView
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TargetNodeState
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceControlComponent
;
24 import org
.eclipse
.ui
.IWorkbenchPage
;
27 * <b><u>RefreshHandler</u></b>
29 * Command handler implementation to refresh node configuration.
32 public class RefreshHandler
extends BaseControlViewHandler
{
34 // ------------------------------------------------------------------------
36 // ------------------------------------------------------------------------
38 * The node component reference.
40 private TargetNodeComponent fNode
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
48 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
51 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
58 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
61 public boolean isEnabled() {
64 // Get workbench page for the Control View
65 IWorkbenchPage page
= getWorkbenchPage();
70 // Check if one or more session are selected
71 ISelection selection
= page
.getSelection(ControlView
.ID
);
72 if (selection
instanceof StructuredSelection
) {
74 StructuredSelection structered
= ((StructuredSelection
) selection
);
75 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
76 Object element
= (Object
) iterator
.next();
77 if (element
instanceof TraceControlComponent
) {
78 TraceControlComponent component
= (TraceControlComponent
) element
;
79 boolean isConnected
= component
.getTargetNodeState() == TargetNodeState
.CONNECTED
;
81 while ((component
!= null) && component
.getClass() != TargetNodeComponent
.class) {
82 component
= (TraceControlComponent
) component
.getParent();
84 if (component
!= null) {
85 fNode
= (TargetNodeComponent
) component
;