Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 29cc284043b014998f5a3359a5a7b8efdf6a7fce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/*******************************************************************************
 * Copyright (c) 2009, 2016 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/

package org.eclipse.ua.tests.help.other;

import java.util.ArrayList;
import java.util.List;

import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.help.IIndexEntry;
import org.eclipse.help.IIndexEntry2;
import org.eclipse.help.IIndexSee;
import org.eclipse.help.ITopic;
import org.eclipse.help.IUAElement;

/**
 * This class is used to test topics created using the IIndexEntry2 API
 */

public class UserIndexEntry implements IIndexEntry2 {

	private List<IIndexEntry> subentries = new ArrayList<>();
	private List<IIndexSee> sees = new ArrayList<>();
	private List<ITopic> topics = new ArrayList<>();
	private boolean isEnabled;
	private String keyword;

	@Override
	public IUAElement[] getChildren() {
		IUAElement[] subentries = getSubentries();
		IUAElement[] sees = getSees();
		IUAElement[] topics = getTopics();
		IUAElement[] result = new IUAElement[subentries.length + sees.length + topics.length];
		System.arraycopy(topics, 0, result, 0, topics.length);
		System.arraycopy(subentries, 0, result, topics.length, subentries.length);
		System.arraycopy(sees, 0, result, topics.length + subentries.length, sees.length);
		return result;
	}

	@Override
	public boolean isEnabled(IEvaluationContext context) {
		return isEnabled;
	}

	public void addSee(IIndexSee child) {
		sees.add(child);
	}

	public void addEntry(IIndexEntry child) {
		subentries.add(child);
	}

	public void addTopic(ITopic child) {
		topics.add(child);
	}

	public UserIndexEntry(String keyword, boolean isEnabled) {
		this.keyword = keyword;
		this.isEnabled = isEnabled;
	}

	@Override
	public IIndexSee[] getSees() {
		return sees.toArray(new IIndexSee[0]);
	}

	@Override
	public String getKeyword() {
		return keyword;
	}

	@Override
	public IIndexEntry[] getSubentries() {
		return subentries.toArray(new IIndexEntry[0]);
	}

	@Override
	public ITopic[] getTopics() {
		return topics.toArray(new ITopic[0]);
	}

}

Back to the top