From 22cef14145400b4f47d47c0f74e6f33a8dab1719 Mon Sep 17 00:00:00 2001 From: Wim Jongman Date: Thu, 17 May 2018 22:47:24 +0200 Subject: Bug 534376: [Tips] (fetch) job runs even if I have disabled tips * 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 --- .../org/eclipse/tips/core/internal/TipManager.java | 42 ++++++++++++++++------ 1 file changed, 31 insertions(+), 11 deletions(-) (limited to 'org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java') diff --git a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java index 564813b1c..f8bb83f7e 100644 --- a/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java +++ b/org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java @@ -39,6 +39,21 @@ public abstract class TipManager implements ITipManager { private boolean fIsDiposed; private PropertyChangeSupport fChangeSupport = new PropertyChangeSupport(this); + /** + * May start a dialog at startup. + */ + public static final int START_DIALOG = 0; + + /** + * May do background tasks but not show a dialog on startup. + */ + public static final int START_BACKGROUND = 1; + + /** + * Tips may only start on explicit user request. + */ + public static final int START_DISABLE = 2; + /** * Instantiates a new TipManager. */ @@ -63,7 +78,7 @@ public abstract class TipManager implements ITipManager { * call super, and then asynchronously call the * {@link TipProvider#loadNewTips(org.eclipse.core.runtime.IProgressMonitor)} * method. - * + * * This manager then starts listening to the a {@link TipProvider#PROP_READY} * property change event and resends it through its own change support. * @@ -74,7 +89,7 @@ public abstract class TipManager implements ITipManager { @Override public ITipManager register(TipProvider provider) { checkDisposed(); - String message = MessageFormat.format(Messages.TipManager_0, provider.getID() ,provider.getDescription()); + String message = MessageFormat.format(Messages.TipManager_0, provider.getID(), provider.getDescription()); log(LogUtil.info(message)); provider.setManager(this); addToMaps(provider, Integer.valueOf(getPriority(provider))); @@ -164,27 +179,32 @@ public abstract class TipManager implements ITipManager { /** * Determines if the Tips framework must run at startup. The default - * implementation returns true, subclasses should probably override this. + * implementation returns {@link #START_DIALOG} , subclasses should probably + * override this if they want to give users a choice. * - * @return true if the Tips framework should run at startup. - * @see TipManager#setRunAtStartup(boolean) + * @return Returns {@link #START_DIALOG}, {@link #START_BACKGROUND} or + * {@link #START_DISABLE}. + * @see TipManager#setStartUpBehavior(int) */ - public boolean isRunAtStartup() { + public int getStartupBehavior() { checkDisposed(); - return true; + return START_DIALOG; } /** - * Determines if the Tips framework must run at startup. + * Determines what level of startup actions the Tips framework may do. * - * @param shouldRun true if the tips should be displayed at startup, false - * otherwise. + * @param startupBehavior Use {@link TipManager#START_DIALOG} to allow a dialog + * at startup and possibly query for new content, + * {@link #START_BACKGROUND} to query for new content but + * not show a dialog or {@link #START_DISABLE} to not do + * startup actions at all. * * @return this * * @see #isRunAtStartup() */ - public abstract TipManager setRunAtStartup(boolean shouldRun); + public abstract TipManager setStartupBehavior(int startupBehavior); /** * The default implementation disposes of this manager and all the TipProviders -- cgit v1.2.3