diff options
author | Wim Jongman | 2018-05-17 20:47:24 +0000 |
---|---|---|
committer | Wim Jongman | 2018-05-21 15:52:11 +0000 |
commit | 22cef14145400b4f47d47c0f74e6f33a8dab1719 (patch) | |
tree | 7c68b5e64386d83cc1ade8ce6de4747ad66740e9 /org.eclipse.tips.ide | |
parent | 6c2c96714c5c1add856dc0baf9042d122e6e06a0 (diff) | |
download | eclipse.platform.ua-22cef14145400b4f47d47c0f74e6f33a8dab1719.tar.gz eclipse.platform.ua-22cef14145400b4f47d47c0f74e6f33a8dab1719.tar.xz eclipse.platform.ua-22cef14145400b4f47d47c0f74e6f33a8dab1719.zip |
Bug 534376: [Tips] (fetch) job runs even if I have disabled tipsI20180521-2000
* Added "Disabled" Option
* Tips startup default can be controlled by property
* Fixed internal api
* Fixed documentation
* Fixed tests
* V3 fixed preferences initializer
* V4 lightbulb in trim goes away in "Disabled" mode
* V5 replaced combo with menu
* V6 replaced tip to reflect new menu
Change-Id: I958c1d583948341ef3ef0587655bdf1b78a4f0a4
Signed-off-by: Wim Jongman <wim.jongman@remainsoftware.com>
Diffstat (limited to 'org.eclipse.tips.ide')
7 files changed, 63 insertions, 33 deletions
diff --git a/org.eclipse.tips.ide/images/tips/navigate1.png b/org.eclipse.tips.ide/images/tips/navigate1.png Binary files differindex 7867a3255..cd6c709d5 100644 --- a/org.eclipse.tips.ide/images/tips/navigate1.png +++ b/org.eclipse.tips.ide/images/tips/navigate1.png diff --git a/org.eclipse.tips.ide/plugin.xml b/org.eclipse.tips.ide/plugin.xml index df20b37f6..20849e37c 100644 --- a/org.eclipse.tips.ide/plugin.xml +++ b/org.eclipse.tips.ide/plugin.xml @@ -183,7 +183,7 @@ <extension point="org.eclipse.core.runtime.preferences"> <initializer - class="org.eclipse.tips.ide.internal.Preferences"> + class="org.eclipse.tips.ide.internal.TipsPreferences"> </initializer> </extension> <extension diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java index 65a3b6b6c..69064a165 100644 --- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java +++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java @@ -96,6 +96,7 @@ public class IDETipManager extends DefaultTipManager { @Override public ITipManager open(boolean startUp) { if (isOpen()) { + super.open(startUp); return this; } if (!fSourceProviderAdded) { @@ -109,7 +110,7 @@ public class IDETipManager extends DefaultTipManager { /** * Saves the tip read status to disk. - * + * * @param pReadTips the tips to save * */ @@ -146,13 +147,13 @@ public class IDETipManager extends DefaultTipManager { } @Override - public boolean isRunAtStartup() { - return TipsPreferences.isRunAtStartup(); + public int getStartupBehavior() { + return TipsPreferences.getStartupBehavior(); } @Override - public TipManager setRunAtStartup(boolean runAtStartup) { - TipsPreferences.setRunAtStartup(runAtStartup); + public TipManager setStartupBehavior(int startupBehavior) { + TipsPreferences.setStartupBehavior(startupBehavior); return this; } @@ -197,8 +198,9 @@ public class IDETipManager extends DefaultTipManager { protected synchronized IDETipManager setNewTips(boolean newTips) { log(LogUtil.info(MessageFormat.format(Messages.IDETipManager_6, newTips + EMPTY))); - if (fNewTips != newTips) { - fNewTips = newTips; + boolean newValue = newTips && getStartupBehavior() != START_DISABLE; + if (fNewTips != newValue) { + fNewTips = newValue; fSourceProvider.setStatus(fNewTips); } return this; @@ -271,7 +273,7 @@ public class IDETipManager extends DefaultTipManager { * Returns the state location of the IDE tips. First the property * "org.eclipse.tips.statelocation" is read. If it does not exist then the state * location will be <b>${user.home}/.eclipse/org.eclipse.tips.state</b> - * + * * @return the state location file * @throws Exception if something went wrong */ diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java index 698c0a9a0..b28d01315 100644 --- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java +++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java @@ -19,6 +19,7 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.core.internal.TipManager; import org.eclipse.ui.IStartup; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.progress.UIJob; @@ -29,6 +30,7 @@ import org.osgi.framework.FrameworkUtil; * Early startup to run the TipManager in the IDE. * */ +@SuppressWarnings("restriction") public class Startup implements IStartup { private static final String DBLQUOTE = "\""; //$NON-NLS-1$ @@ -41,6 +43,12 @@ public class Startup implements IStartup { @Override public void earlyStartup() { + if (!(TipsPreferences.getStartupBehavior() == TipManager.START_DISABLE)) { + start(); + } + } + + public void start() { loadProviders(); openManager(); } diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsHandler.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsHandler.java index f198068c3..b812e1bc8 100644 --- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsHandler.java +++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsHandler.java @@ -22,10 +22,10 @@ public class TipsHandler extends AbstractHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { - if (!IDETipManager.getInstance().isOpen()) { +// if (!IDETipManager.getInstance().isOpen()) { IDETipManager.getInstance().open(false); Startup.loadProviders(); - } +// } return null; } }
\ No newline at end of file diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsPreferences.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsPreferences.java index 4b4a85628..175180eb7 100644 --- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsPreferences.java +++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsPreferences.java @@ -25,6 +25,7 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.core.runtime.preferences.ConfigurationScope; import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.tips.core.internal.TipManager; import org.osgi.framework.Bundle; import org.osgi.framework.FrameworkUtil; import org.osgi.service.prefs.BackingStoreException; @@ -33,6 +34,7 @@ import org.osgi.service.prefs.BackingStoreException; * Internal class to store preferences. * */ +@SuppressWarnings("restriction") public class TipsPreferences extends AbstractPreferenceInitializer { private static final String FALSE = "false"; //$NON-NLS-1$ @@ -40,7 +42,7 @@ public class TipsPreferences extends AbstractPreferenceInitializer { /** * Preference store key to indicate showing tips at startup. */ - public static final String PREF_RUN_AT_STARTUP = "activate_at_startup"; //$NON-NLS-1$ + public static final String PREF_STARTUP_BEHAVIOR = "activate_at_startup"; //$NON-NLS-1$ /** * Preference store key to indicate serving tips that the user as already seen. @@ -53,7 +55,7 @@ public class TipsPreferences extends AbstractPreferenceInitializer { @Override public void initializeDefaultPreferences() { IEclipsePreferences node = getPreferences(); - node.putBoolean(PREF_RUN_AT_STARTUP, true); + node.putInt(PREF_STARTUP_BEHAVIOR, TipManager.START_DIALOG); node.putBoolean(PREF_SERVE_READ_TIPS, false); try { node.flush(); @@ -64,7 +66,7 @@ public class TipsPreferences extends AbstractPreferenceInitializer { /** * Loads the read tips from disk. - * + * * @return a map that stores the read tip hashes per provider. */ public static Map<String, List<Integer>> getReadState() { @@ -91,14 +93,11 @@ public class TipsPreferences extends AbstractPreferenceInitializer { } private static FilenameFilter getStateFileNameFilter(File stateLocation) { - return new FilenameFilter() { - @Override - public boolean accept(File pDir, String pName) { - if (pDir.equals(stateLocation) && pName.endsWith(".state")) { //$NON-NLS-1$ - return true; - } - return false; + return (pDir, pName) -> { + if (pDir.equals(stateLocation) && pName.endsWith(".state")) { //$NON-NLS-1$ + return true; } + return false; }; } @@ -112,7 +111,7 @@ public class TipsPreferences extends AbstractPreferenceInitializer { /** * Saves the list with read tips to disk. - * + * * @param pReadTips the list with read tips * @return the status of the call */ @@ -149,17 +148,29 @@ public class TipsPreferences extends AbstractPreferenceInitializer { } } - public static boolean isRunAtStartup() { - return getPreferences().getBoolean(PREF_RUN_AT_STARTUP, true); + public static int getStartupBehavior() { + return getPreferences().getInt(PREF_STARTUP_BEHAVIOR, getDefaultStartupBehavior()); + } + + private static int getDefaultStartupBehavior() { + String startupBehavior = System.getProperty("org.eclipse.tips.startup"); + if ("dialog".equals(startupBehavior)) { + return TipManager.START_DIALOG; + } else if ("background".equals(startupBehavior)) { + return TipManager.START_BACKGROUND; + } else if ("disable".equals(startupBehavior)) { + return TipManager.START_DISABLE; + } + return TipManager.START_DIALOG; } public static boolean isServeReadTips() { return getPreferences().getBoolean(PREF_SERVE_READ_TIPS, false); } - public static void setRunAtStartup(boolean runAtStartup) { + public static void setStartupBehavior(int startupBehavior) { IEclipsePreferences node = getPreferences(); - node.putBoolean(PREF_RUN_AT_STARTUP, runAtStartup); + node.putInt(PREF_STARTUP_BEHAVIOR, startupBehavior); try { node.flush(); } catch (BackingStoreException e) { diff --git a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip4_Navigate.java b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip4_Navigate.java index 4b0688a5d..d16793bff 100644 --- a/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip4_Navigate.java +++ b/org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip4_Navigate.java @@ -27,7 +27,7 @@ public class Tip4_Navigate extends Tip implements IHtmlTip { if (fImage == null) { try { Bundle bundle = FrameworkUtil.getBundle(getClass()); - fImage = new TipImage(bundle.getEntry("images/tips/navigate1.png")).setAspectRatio(570, 91, true); + fImage = new TipImage(bundle.getEntry("images/tips/navigate1.png")).setAspectRatio(640, 96, true); } catch (Exception e) { } } @@ -50,11 +50,20 @@ public class Tip4_Navigate extends Tip implements IHtmlTip { @Override public String getHTML() { - return "<h2>Navigating Tips</h2>You can navigate tips by using the button bar." - + "<br><br><b>Show tips at startup</b><br>A toggle to show this dialog when you start Eclipse." - + "<br><b>Unread only</b><br>Shows all Tips when unchecked or unread Tips when checked." - + "<br><b>Next Tip</b><br>Navigates to the next tip." - + "<br><b>Previous Tip</b><br>Navigates to the previous tip <i>if reading all tips</i>." - + "<br><b>Close</b><br>Closes the Dialog (<b>Escape</b> does the same)." + "<br><br><br>"; + return "<h2>Navigating Tips</h2>You can navigate tips by using the button bar." // + + "<br><br><b>Startup Options</b>" // + + "<ul style=\"margin: 5\">" // + + "<li>Show dialog on new tips - Opens the dialog on every start</li>" // + + "<li>Indicate new tips in status bar - When new tips arrive an icon appears</li>" // + + "<li>Disable - Only start tips when requested from the menu</li>" // + + "</ul>" // + + "<b>Unread only</b>" // + + "<ul style=\"margin: 5\"><li>Shows all tips when unchecked or unread tips when checked.</li></ul>" // + + "<b>Next Tip</b>" // + + "<ul style=\"margin: 5\"><li>Navigates to the next tip.</li></ul>" // + + "<b>Previous Tip</b>" // + + "<ul style=\"margin: 5\"><li>Navigates to the previous tip <i>if reading all tips</i>.</li></ul>" // + + "<b>Close</b>" // + + "<ul style=\"margin: 5\"><li>Closes the Dialog (<b>Escape</b> does the same).</i></ul><br>"; } }
\ No newline at end of file |