Commit | Line | Data |
---|---|---|
4ea599a5 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
cfdb727a | 3 | * |
4ea599a5 BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
4ea599a5 BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
12 | package org.eclipse.linuxtools.internal.lttng2.stubs.dialogs; | |
13 | ||
14 | import java.util.ArrayList; | |
15 | import java.util.HashSet; | |
16 | import java.util.Iterator; | |
17 | import java.util.List; | |
18 | import java.util.Set; | |
19 | ||
20 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IAddContextDialog; | |
21 | ||
22 | /** | |
cfdb727a | 23 | * Add Context dialog stub. |
4ea599a5 | 24 | */ |
cfdb727a | 25 | @SuppressWarnings("javadoc") |
4ea599a5 BH |
26 | public class AddContextDialogStub implements IAddContextDialog { |
27 | ||
28 | private Set<String> fAvailableContexts = null; | |
29 | private List<String> fContexts = null; | |
30 | ||
31 | @Override | |
32 | public int open() { | |
33 | return 0; | |
34 | } | |
35 | ||
36 | @Override | |
37 | public void setAvalibleContexts(List<String> contexts) { | |
38 | fAvailableContexts = new HashSet<String>(); | |
39 | fAvailableContexts.addAll(contexts); | |
40 | } | |
41 | ||
42 | @Override | |
43 | public List<String> getContexts() { | |
44 | List<String> ret = new ArrayList<String>(); | |
45 | ret.addAll(fContexts); | |
46 | return ret; | |
47 | } | |
48 | ||
49 | public void setContexts(List<String> contexts) throws IllegalArgumentException{ | |
50 | fContexts = new ArrayList<String>(); | |
51 | fContexts.addAll(contexts); | |
cfdb727a | 52 | // If availableContexts are null we cannot verify |
4ea599a5 BH |
53 | if (fAvailableContexts != null) { |
54 | for (Iterator<String> iterator = fContexts.iterator(); iterator.hasNext();) { | |
cfdb727a | 55 | String string = iterator.next(); |
4ea599a5 BH |
56 | if (!fAvailableContexts.contains(string)) { |
57 | throw new IllegalArgumentException(); | |
58 | } | |
59 | } | |
60 | } | |
61 | } | |
62 | } | |
63 |