| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Bernd Hufmann - Initial API and implementation |
| 11 | **********************************************************************/ |
| 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
| 13 | |
| 14 | import java.util.Iterator; |
| 15 | import java.util.List; |
| 16 | |
| 17 | import org.eclipse.core.commands.ExecutionException; |
| 18 | import org.eclipse.core.runtime.IProgressMonitor; |
| 19 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
| 21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; |
| 22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
| 23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
| 24 | |
| 25 | /** |
| 26 | * <p> |
| 27 | * Implementation of the trace provider group. |
| 28 | * </p> |
| 29 | * |
| 30 | * @author Bernd Hufmann |
| 31 | */ |
| 32 | public class TraceProviderGroup extends TraceControlComponent { |
| 33 | // ------------------------------------------------------------------------ |
| 34 | // Constants |
| 35 | // ------------------------------------------------------------------------ |
| 36 | /** |
| 37 | * Path to icon file for this component. |
| 38 | */ |
| 39 | public static final String TRACE_PROVIDERS_ICON_FILE = "icons/obj16/providers.gif"; //$NON-NLS-1$ |
| 40 | |
| 41 | // ------------------------------------------------------------------------ |
| 42 | // Attributes |
| 43 | // ------------------------------------------------------------------------ |
| 44 | |
| 45 | // ------------------------------------------------------------------------ |
| 46 | // Constructors |
| 47 | // ------------------------------------------------------------------------ |
| 48 | /** |
| 49 | * Constructor |
| 50 | * @param name - the name of the component. |
| 51 | * @param parent - the parent of this component. |
| 52 | */ |
| 53 | public TraceProviderGroup(String name, ITraceControlComponent parent) { |
| 54 | super(name, parent); |
| 55 | setImage(TRACE_PROVIDERS_ICON_FILE); |
| 56 | } |
| 57 | |
| 58 | // ------------------------------------------------------------------------ |
| 59 | // Accessors |
| 60 | // ------------------------------------------------------------------------ |
| 61 | |
| 62 | // ------------------------------------------------------------------------ |
| 63 | // Operations |
| 64 | // ------------------------------------------------------------------------ |
| 65 | |
| 66 | /** |
| 67 | * Gets the provider information from the target node. |
| 68 | * @throws ExecutionException If the command fails |
| 69 | */ |
| 70 | public void getProviderFromNode() throws ExecutionException { |
| 71 | getProviderFromNode(new NullProgressMonitor()); |
| 72 | } |
| 73 | |
| 74 | /** |
| 75 | * Gets the provider information from the target node. |
| 76 | * @param monitor - a progress monitor |
| 77 | * @throws ExecutionException If the command fails |
| 78 | */ |
| 79 | public void getProviderFromNode(IProgressMonitor monitor) throws ExecutionException { |
| 80 | |
| 81 | List<IBaseEventInfo> eventInfos = getControlService().getKernelProvider(monitor); |
| 82 | KernelProviderComponent component = new KernelProviderComponent(Messages.TraceControl_KernelProviderDisplayName, this); |
| 83 | addChild(component); |
| 84 | component.setEventInfo(eventInfos); |
| 85 | |
| 86 | List<IUstProviderInfo> allProviders = getControlService().getUstProvider(monitor); |
| 87 | |
| 88 | for (Iterator<IUstProviderInfo> iterator = allProviders.iterator(); iterator.hasNext();) { |
| 89 | IUstProviderInfo ustProviderInfo = iterator.next(); |
| 90 | UstProviderComponent ustComponent = new UstProviderComponent(ustProviderInfo.getName(), this); |
| 91 | addChild(ustComponent); |
| 92 | ustComponent.setUstProvider(ustProviderInfo); |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |