blob: 98e7ac60318771f137a7291a2fdc15465d79a724 (
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
91
92
93
94
95
|
/*******************************************************************************
* 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.ide.internal.provider;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.tips.core.Tip;
import org.eclipse.tips.core.TipImage;
import org.eclipse.tips.core.internal.LogUtil;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
@SuppressWarnings("restriction")
public class TipsTipProvider extends org.eclipse.tips.core.TipProvider {
private TipImage fImage48;
@Override
public TipImage getImage() {
if (fImage48 == null) {
Bundle bundle = FrameworkUtil.getBundle(getClass());
try {
fImage48 = new TipImage(bundle.getEntry("icons/tips.png")).setAspectRatio(1);
} catch (IOException e) {
getManager().log(LogUtil.info(getClass(), e));
}
}
return fImage48;
}
@Override
public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) {
SubMonitor subMonitor = SubMonitor.convert(pMonitor);
subMonitor.beginTask("Loading Tips", -1);
List<Tip> tips = new ArrayList<>();
tips.add(new Tip1_Welcome(getID()));
tips.add(new Tip2_StartingTips(getID()));
tips.add(new Tip3_StartingTips(getID()));
tips.add(new Tip4_Navigate(getID()));
tips.add(new Tip5_Navigate(getID()));
tips.add(new Tip6_ActionsTip(getID()));
tips.add(new Tip7_Extend(getID()));
setTips(tips);
subMonitor.done();
return Status.OK_STATUS;
}
@Override
public String getDescription() {
return "Tips about Tips";
}
@Override
public String getID() {
return getClass().getName();
}
@Override
public void dispose() {
}
/**
* Convenience method that creates a date from a dd/mm/yy string.
*
* @param pYYMMDD the date in a dd/mm/yy format, e.g. "01/01/2017"
* @return the date
* @throws RuntimeException if the date is not correct
*/
public static Date getDateFromYYMMDD(String pYYMMDD) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
try {
return sdf.parse(pYYMMDD);
} catch (ParseException e) {
throw new RuntimeException(e);
}
}
}
|