Commit | Line | Data |
---|---|---|
4ea599a5 BH |
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.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 | /** | |
23 | * Add Context dialog stub. | |
24 | */ | |
25 | public class AddContextDialogStub implements IAddContextDialog { | |
26 | ||
27 | private Set<String> fAvailableContexts = null; | |
28 | private List<String> fContexts = null; | |
29 | ||
30 | @Override | |
31 | public int open() { | |
32 | return 0; | |
33 | } | |
34 | ||
35 | @Override | |
36 | public void setAvalibleContexts(List<String> contexts) { | |
37 | fAvailableContexts = new HashSet<String>(); | |
38 | fAvailableContexts.addAll(contexts); | |
39 | } | |
40 | ||
41 | @Override | |
42 | public List<String> getContexts() { | |
43 | List<String> ret = new ArrayList<String>(); | |
44 | ret.addAll(fContexts); | |
45 | return ret; | |
46 | } | |
47 | ||
48 | public void setContexts(List<String> contexts) throws IllegalArgumentException{ | |
49 | fContexts = new ArrayList<String>(); | |
50 | fContexts.addAll(contexts); | |
51 | // If availableContexts are null we cannot verify | |
52 | if (fAvailableContexts != null) { | |
53 | for (Iterator<String> iterator = fContexts.iterator(); iterator.hasNext();) { | |
54 | String string = (String) iterator.next(); | |
55 | if (!fAvailableContexts.contains(string)) { | |
56 | throw new IllegalArgumentException(); | |
57 | } | |
58 | } | |
59 | } | |
60 | } | |
61 | } | |
62 |