Commit | Line | Data |
---|---|---|
f14957a3 MAL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 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 | * Marc-Andre Laperle - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model; | |
14 | ||
15 | import java.util.ArrayList; | |
16 | import java.util.List; | |
17 | ||
18 | import org.eclipse.swt.graphics.Image; | |
19 | import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator; | |
20 | import org.eclipse.tracecompass.internal.tmf.ui.project.wizards.tracepkg.TracePackageElement; | |
21 | ||
22 | /** | |
23 | * An RemoteImportProfileElement representing a profile for importing traces remotely. | |
24 | * | |
25 | * @author Marc-Andre Laperle | |
26 | */ | |
27 | public class RemoteImportProfileElement extends TracePackageElement { | |
28 | ||
29 | private static final String IMAGE_PATH = "icons/obj/profile.gif"; //$NON-NLS-1$ | |
30 | private String fProfileName; | |
31 | ||
32 | /** | |
33 | * Constructs an instance of RemoteImportProfileElement | |
34 | * | |
35 | * @param parent | |
36 | * the parent of this element, can be set to null | |
37 | * @param profileName | |
38 | * the profile name | |
39 | */ | |
40 | public RemoteImportProfileElement(TracePackageElement parent, | |
41 | String profileName) { | |
42 | super(parent); | |
43 | fProfileName = profileName; | |
44 | } | |
45 | ||
46 | @Override | |
47 | public String getText() { | |
48 | return fProfileName; | |
49 | } | |
50 | ||
51 | @Override | |
52 | public Image getImage() { | |
53 | return Activator.getDefault().getImageFromImageRegistry(IMAGE_PATH); | |
54 | } | |
55 | ||
56 | /** | |
57 | * Get the name of the profile. | |
58 | * | |
59 | * @return the name of the profile | |
60 | */ | |
61 | public String getProfileName() { | |
62 | return fProfileName; | |
63 | } | |
64 | ||
65 | /** | |
66 | * Set the name of the profile. | |
67 | * | |
68 | * @param profileName the name of the profile | |
69 | */ | |
70 | public void setProfileName(String profileName) { | |
71 | fProfileName = profileName; | |
72 | } | |
73 | ||
74 | /** | |
75 | * Returns the list of remote connection elements | |
76 | * | |
77 | * @return a list of remote connection elements | |
78 | */ | |
79 | public List<RemoteImportConnectionNodeElement> getConnectionNodeElements() { | |
80 | List<RemoteImportConnectionNodeElement> remoteHosts = new ArrayList<>(); | |
81 | for (TracePackageElement element : getChildren()) { | |
82 | if (element instanceof RemoteImportConnectionNodeElement) { | |
83 | // only one node per profile is supported | |
84 | remoteHosts.add((RemoteImportConnectionNodeElement) element); | |
85 | } | |
86 | } | |
87 | return remoteHosts; | |
88 | } | |
89 | } |