blob: 22de17dfcdf481a93d21f78e6269bfb64074f1d1 (
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
|
/*******************************************************************************
* 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.ui.internal;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.widgets.Display;
import org.eclipse.tips.core.ITipManager;
import org.eclipse.tips.core.internal.LogUtil;
import org.eclipse.tips.core.internal.TipManager;
/**
* Class to manage the tip providers and start the tip of the day UI.
*
*/
@SuppressWarnings("restriction")
public abstract class DefaultTipManager extends TipManager {
private TipDialog fTipDialog;
/**
* Opens the Tip of the Day dialog. Subclasses may override if they want to
* present the Tips in a different way, e.g. in a view.
*
* @param startUp When called from a startup situation, true must be passed for
* <code>pStartup</code>. If in a manual starting situation,
* false must be passed. This enables the manager to decide to
* skip opening the dialog at startup (e.g., no new tip items).
*
* @see #isOpen()
*/
@Override
public ITipManager open(boolean startUp) {
try {
Assert.isTrue(!isOpen(), Messages.DefaultTipManager_0);
} catch (Exception e) {
log(LogUtil.error(getClass(), e));
throw e;
}
if (!mustOpen(startUp)) {
return this;
}
setOpen(true);
fTipDialog = new TipDialog(Display.getCurrent().getActiveShell(), this, TipDialog.DEFAULT_STYLE);
fTipDialog.open();
fTipDialog.getShell().addDisposeListener(pE -> {
dispose();
});
return this;
}
// Open if not a startup call or if there are unread tips.
private boolean mustOpen(boolean startUp) {
if (!startUp) {
return true;
}
if (startUp && isRunAtStartup()) {
return hasContent();
}
return false;
}
}
|