Skip to main content
summaryrefslogtreecommitdiffstats
blob: 59ab3f1d4a846c137098f3c4c834c7cb9c5eb0f1 (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
/*******************************************************************************
 * Copyright (c) 2018 Remain Software
 * 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:
 *     wim.jongman@remainsoftware.com - initial API and implementation
 *******************************************************************************/
package org.eclipse.tips.core;

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

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;

public class TestTipManager extends TipManager {

	private boolean fShouldRun = true;
	private List<Integer> fReadList = new ArrayList<>();

	@Override
	public TipManager setRunAtStartup(boolean shouldRun) {
		fShouldRun = shouldRun;
		return this;
	}

	@Override
	public boolean isRunAtStartup() {
		return fShouldRun;
	}

	@Override
	public ITipManager register(TipProvider provider) {
		super.register(provider);
		load(provider);
		return this;
	}

	private void load(TipProvider provider) {
		provider.loadNewTips(new NullProgressMonitor());
	}

	@Override
	public boolean isRead(Tip tip) {
		return fReadList.contains(tip.hashCode());
	}

	@Override
	public TipManager setAsRead(Tip tip) {
		fReadList.remove((Integer) tip.hashCode());
		fReadList.add(tip.hashCode());
		return this;
	}

	@Override
	public ITipManager log(IStatus status) {
		System.out.println(status.toString());
		return this;
	}

	@Override
	public TipManager open(boolean startUp) {
		return this;
	}

	@Override
	public int getPriority(TipProvider provider) {
		return 20;
	}
}

Back to the top