c9291861d3aa173b728db402468da86553785ced
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.control.ui.tests / stubs / org / eclipse / tracecompass / internal / lttng2 / control / stubs / dialogs / AddContextDialogStub.java
1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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.tracecompass.internal.lttng2.control.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.tracecompass.internal.lttng2.control.ui.views.dialogs.IAddContextDialog;
21
22 /**
23 * Add Context dialog stub.
24 */
25 @SuppressWarnings("javadoc")
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<>();
39 fAvailableContexts.addAll(contexts);
40 }
41
42 @Override
43 public List<String> getContexts() {
44 List<String> ret = new ArrayList<>();
45 ret.addAll(fContexts);
46 return ret;
47 }
48
49 public void setContexts(List<String> contexts) throws IllegalArgumentException{
50 fContexts = new ArrayList<>();
51 fContexts.addAll(contexts);
52 // If availableContexts are null we cannot verify
53 if (fAvailableContexts != null) {
54 for (Iterator<String> iterator = fContexts.iterator(); iterator.hasNext();) {
55 String string = iterator.next();
56 if (!fAvailableContexts.contains(string)) {
57 throw new IllegalArgumentException();
58 }
59 }
60 }
61 }
62 }
63
This page took 0.032433 seconds and 4 git commands to generate.