Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.tips.core/src/org/eclipse/tips/core/internal/TipManager.java42
-rw-r--r--org.eclipse.tips.ide/images/tips/navigate1.pngbin15133 -> 20209 bytes
-rw-r--r--org.eclipse.tips.ide/plugin.xml2
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/IDETipManager.java18
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/Startup.java8
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsHandler.java4
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/TipsPreferences.java41
-rw-r--r--org.eclipse.tips.ide/src/org/eclipse/tips/ide/internal/provider/Tip4_Navigate.java23
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java10
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java4
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java35
-rw-r--r--org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java2
-rw-r--r--org.eclipse.tips.ui/.settings/org.eclipse.jdt.core.prefs2
-rw-r--r--org.eclipse.tips.ui/icons/run.gifbin0 -> 379 bytes
-rw-r--r--org.eclipse.tips.ui/icons/stop.pngbin0 -> 326 bytes
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java15
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Messages.java3
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java64
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/messages.properties7
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java1
-rw-r--r--org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java1
21 files changed, 199 insertions, 83 deletions
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
@@ -40,6 +40,21 @@ public abstract class TipManager implements ITipManager {
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.
*/
public 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
diff --git a/org.eclipse.tips.ide/images/tips/navigate1.png b/org.eclipse.tips.ide/images/tips/navigate1.png
index 7867a3255..cd6c709d5 100644
--- a/org.eclipse.tips.ide/images/tips/navigate1.png
+++ b/org.eclipse.tips.ide/images/tips/navigate1.png
Binary files differ
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
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
index 85c016b27..ce823a2a6 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TestTipManager.java
@@ -20,18 +20,18 @@ import org.eclipse.tips.core.internal.TipManager;
@SuppressWarnings("restriction")
public class TestTipManager extends TipManager {
- private boolean fShouldRun = true;
private List<Integer> fReadList = new ArrayList<>();
+ private int fStartupBehavior = TipManager.START_DIALOG;
@Override
- public TipManager setRunAtStartup(boolean shouldRun) {
- fShouldRun = shouldRun;
+ public TipManager setStartupBehavior(int pStartupBehavior) {
+ fStartupBehavior = pStartupBehavior;
return this;
}
@Override
- public boolean isRunAtStartup() {
- return fShouldRun;
+ public int getStartupBehavior() {
+ return fStartupBehavior;
}
@Override
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java
index c182d09fe..6d52977de 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipImageURLTest.java
@@ -92,12 +92,12 @@ public class TipImageURLTest {
}
@Test
- public void testSetExtension() throws IOException {
+ public void testSetExtension() {
// assertTrue(getTipImage().getIMGAttributes(19, 10).contains("png"));
}
@Test
- public void testSetExtension2() throws IOException {
+ public void testSetExtension2() {
// assertTrue(getTipImage().setExtension("bmp").getBase64Image().contains("bmp"));
// assertTrue(getTipImage().getIMGAttributes(19, 10).contains("png"));
}
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
index 2ef74005e..dd3fd19c3 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/core/TipManagerTest.java
@@ -64,17 +64,20 @@ public class TipManagerTest {
}
@Test
- public void testIsRunAtStartup() {
- assertTrue(fManager.isRunAtStartup());
- fManager.setRunAtStartup(false);
- assertTrue(!fManager.isRunAtStartup());
- }
+ public void testGetStartupBeahvior() {
+ assertTrue(fManager.getStartupBehavior() == TipManager.START_DIALOG);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_BACKGROUND);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_DISABLE);
- @Test
- public void testSetRunAtStartup() {
- assertTrue(fManager.isRunAtStartup());
- fManager.setRunAtStartup(false);
- assertTrue(!fManager.isRunAtStartup());
+ fManager.setStartupBehavior(TipManager.START_BACKGROUND);
+ assertTrue(fManager.getStartupBehavior() == TipManager.START_BACKGROUND);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_DIALOG);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_DISABLE);
+
+ fManager.setStartupBehavior(TipManager.START_DISABLE);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_BACKGROUND);
+ assertTrue(fManager.getStartupBehavior() != TipManager.START_DIALOG);
+ assertTrue(fManager.getStartupBehavior() == TipManager.START_DISABLE);
}
@Test
@@ -147,8 +150,8 @@ public class TipManagerTest {
@Test
public void testIsRead() {
fManager.register(fProvider1);
- fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(),"<b>bold</b>", "Tip 1"),
- new TestTip(fProvider1.getID(),"<b>bold2</b>", "Tip 2")));
+ fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(), "<b>bold</b>", "Tip 1"),
+ new TestTip(fProvider1.getID(), "<b>bold2</b>", "Tip 2")));
fManager.setAsRead(fProvider1.getCurrentTip());
assertTrue(fManager.isRead(fProvider1.getCurrentTip()));
}
@@ -156,8 +159,8 @@ public class TipManagerTest {
@Test
public void testSetRead() {
fManager.register(fProvider1);
- fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(),"<b>bold</b>", "Tip 1"),
- new TestTip(fProvider1.getID(),"<b>bold2</b>", "Tip 2")));
+ fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(), "<b>bold</b>", "Tip 1"),
+ new TestTip(fProvider1.getID(), "<b>bold2</b>", "Tip 2")));
fManager.setAsRead(fProvider1.getCurrentTip());
assertTrue(fManager.isRead(fProvider1.getCurrentTip()));
}
@@ -165,8 +168,8 @@ public class TipManagerTest {
@Test
public void testSetServeUnread() {
fManager.register(fProvider1);
- fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(),"<b>bold</b>", "Tip 1"),
- new TestTip(fProvider1.getID(),"<b>bold2</b>", "Tip 2")));
+ fProvider1.setTips(Arrays.asList(new TestTip(fProvider1.getID(), "<b>bold</b>", "Tip 1"),
+ new TestTip(fProvider1.getID(), "<b>bold2</b>", "Tip 2")));
fManager.setAsRead(fProvider1.getCurrentTip());
assertTrue(fProvider1.getTips().size() + "", fProvider1.getTips().size() == 1);
fManager.setServeReadTips(true);
diff --git a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
index 9d2de1702..bca0a2179 100644
--- a/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
+++ b/org.eclipse.tips.tests/src/org/eclipse/tips/manual/tests/SleakTipManager.java
@@ -116,7 +116,7 @@ public class SleakTipManager extends TipManager {
}
@Override
- public TipManager setRunAtStartup(boolean pShouldRun) {
+ public TipManager setStartupBehavior(int pStartupBehavior) {
return this;
}
diff --git a/org.eclipse.tips.ui/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.tips.ui/.settings/org.eclipse.jdt.core.prefs
index 66e35d40c..622ae49bd 100644
--- a/org.eclipse.tips.ui/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.tips.ui/.settings/org.eclipse.jdt.core.prefs
@@ -52,7 +52,7 @@ org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=error
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
diff --git a/org.eclipse.tips.ui/icons/run.gif b/org.eclipse.tips.ui/icons/run.gif
new file mode 100644
index 000000000..57f410224
--- /dev/null
+++ b/org.eclipse.tips.ui/icons/run.gif
Binary files differ
diff --git a/org.eclipse.tips.ui/icons/stop.png b/org.eclipse.tips.ui/icons/stop.png
new file mode 100644
index 000000000..0d62b0d07
--- /dev/null
+++ b/org.eclipse.tips.ui/icons/stop.png
Binary files differ
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
index 22de17dfc..7744ed654 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/DefaultTipManager.java
@@ -38,6 +38,15 @@ public abstract class DefaultTipManager extends TipManager {
*/
@Override
public ITipManager open(boolean startUp) {
+ if (isOpen() && !isDialogOpen()) {
+ setOpen(false);
+ } else if (isOpen() && isDialogOpen()) {
+ if (fTipDialog.getShell().getMinimized()) {
+ fTipDialog.getShell().setMinimized(false);
+ }
+ fTipDialog.getShell().forceActive();
+ return this;
+ }
try {
Assert.isTrue(!isOpen(), Messages.DefaultTipManager_0);
} catch (Exception e) {
@@ -58,12 +67,16 @@ public abstract class DefaultTipManager extends TipManager {
return this;
}
+ private boolean isDialogOpen() {
+ return !(fTipDialog == null || fTipDialog.getShell() == null || fTipDialog.getShell().isDisposed());
+ }
+
// Open if not a startup call or if there are unread tips.
private boolean mustOpen(boolean startUp) {
if (!startUp) {
return true;
}
- if (startUp && isRunAtStartup()) {
+ if (startUp && getStartupBehavior() == TipManager.START_DIALOG) {
return hasContent();
}
return false;
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Messages.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Messages.java
index 3acad9a7a..b03d15f9d 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Messages.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/Messages.java
@@ -11,9 +11,12 @@ public class Messages extends NLS {
public static String TipComposite_10;
public static String TipComposite_11;
public static String TipComposite_12;
+ public static String TipComposite_13;
public static String TipComposite_2;
public static String TipComposite_3;
public static String TipComposite_4;
+ public static String TipComposite_5;
+ public static String TipComposite_6;
public static String TipComposite_7;
public static String TipComposite_8;
public static String TipComposite_9;
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
index a2edd3894..2716a18cc 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/TipComposite.java
@@ -14,6 +14,7 @@ import java.io.IOException;
import java.net.URL;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
@@ -45,6 +46,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.tips.core.IHtmlTip;
import org.eclipse.tips.core.IUrlTip;
import org.eclipse.tips.core.Tip;
@@ -66,7 +69,6 @@ public class TipComposite extends Composite implements ProviderSelectionListener
private Slider fSlider;
private TipManager fTipManager;
private Tip fCurrentTip;
- private Button fShowAtStart;
private Button fUnreadOnly;
private Button fPreviousTipButton;
private Pattern fGtkHackPattern = Pattern.compile("(.*?)([0-9]+)(.*?)([0-9]+)(.*?)"); //$NON-NLS-1$
@@ -84,6 +86,8 @@ public class TipComposite extends Composite implements ProviderSelectionListener
private Composite fContentComposite;
private List<Image> fActionImages = new ArrayList<>();
private Menu fActionMenu;
+ private ToolBar ftoolBar;
+ private ToolItem fStartupItem;
/**
* Constructor.
@@ -132,13 +136,15 @@ public class TipComposite extends Composite implements ProviderSelectionListener
fl_composite_3.spacing = 5;
preferenceBar.setLayout(fl_composite_3);
- fShowAtStart = new Button(preferenceBar, SWT.CHECK);
- fShowAtStart.setText(Messages.TipComposite_1);
- fShowAtStart.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fTipManager.setRunAtStartup(fShowAtStart.getSelection());
- }
+ final Menu menu = new Menu(getShell(), SWT.POP_UP);
+ menu.addListener(SWT.Show, event -> startupMenuAboutToShow(menu));
+
+ ftoolBar = new ToolBar(preferenceBar, SWT.FLAT | SWT.RIGHT);
+
+ fStartupItem = new ToolItem(ftoolBar, SWT.DROP_DOWN);
+ fStartupItem.setText(Messages.TipComposite_13);
+ fStartupItem.addListener(SWT.Selection, event -> {
+ showStartupOptions(menu);
});
fUnreadOnly = new Button(preferenceBar, SWT.CHECK);
@@ -252,6 +258,47 @@ public class TipComposite extends Composite implements ProviderSelectionListener
fSlider.addTipProviderListener(this);
}
+ private void showStartupOptions(final Menu menu) {
+ Rectangle rect = fStartupItem.getBounds();
+ Point pt = new Point(rect.x, rect.y + rect.height);
+ pt = ftoolBar.toDisplay(pt);
+ menu.setLocation(pt.x, pt.y);
+ menu.setVisible(true);
+ }
+
+ private Image getStartupItemImage(int startup) {
+ switch (startup) {
+ case 1:
+ return ResourceManager.getPluginImage("org.eclipse.tips.ui", "icons/lightbulb.png"); //$NON-NLS-1$ //$NON-NLS-2$
+ case 2:
+ return ResourceManager.getPluginImage("org.eclipse.tips.ui", "icons/stop.png"); //$NON-NLS-1$ //$NON-NLS-2$
+ default:
+ return ResourceManager.getPluginImage("org.eclipse.tips.ui", "icons/run.gif"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ private void startupMenuAboutToShow(final Menu menu) {
+ Arrays.asList(menu.getItems()).forEach(item -> item.dispose());
+
+ MenuItem item0 = new MenuItem(menu, SWT.CHECK);
+ item0.setText(Messages.TipComposite_1);
+ item0.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DIALOG);
+ item0.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DIALOG));
+ item0.setImage(getStartupItemImage(TipManager.START_DIALOG));
+
+ MenuItem item1 = new MenuItem(menu, SWT.CHECK);
+ item1.setText(Messages.TipComposite_5);
+ item1.setSelection(fTipManager.getStartupBehavior() == TipManager.START_BACKGROUND);
+ item1.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_BACKGROUND));
+ item1.setImage(getStartupItemImage(TipManager.START_BACKGROUND));
+
+ MenuItem item2 = new MenuItem(menu, SWT.CHECK);
+ item2.setText(Messages.TipComposite_6);
+ item2.setSelection(fTipManager.getStartupBehavior() == TipManager.START_DISABLE);
+ item2.addListener(SWT.Selection, event -> fTipManager.setStartupBehavior(TipManager.START_DISABLE));
+ item2.setImage(getStartupItemImage(TipManager.START_DISABLE));
+ }
+
private void showActionMenu() {
Rectangle rect = fMultiActionButton.getBounds();
Point pt = new Point(rect.x - 1, rect.y + rect.height);
@@ -564,7 +611,6 @@ public class TipComposite extends Composite implements ProviderSelectionListener
getDisplay().syncExec(() -> {
fSlider.setTipManager(fTipManager);
- fShowAtStart.setSelection(fTipManager.isRunAtStartup());
fUnreadOnly.setSelection(!fTipManager.mustServeReadTips());
fPreviousTipButton.setEnabled(fTipManager.mustServeReadTips());
});
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/messages.properties b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/messages.properties
index 5f0c48936..93565db12 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/messages.properties
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/messages.properties
@@ -1,13 +1,16 @@
DefaultTipManager_0=Tip of the Day already open.
Slider_13=not advanced graphics system
TipComposite_0=Loading next Tip...
-TipComposite_1=Show tips at startup
TipComposite_10=Running
TipComposite_11=Tip read timer
TipComposite_12=Unknown Tip implementation:
-TipComposite_2=&Unread only
+TipComposite_2=Unread only
TipComposite_3=More...
TipComposite_4=New Button
+TipComposite_1=&Show dialog on new tips
+TipComposite_13=&Startup Options
+TipComposite_5=&Indicate new tips in status bar
+TipComposite_6=&Disable
TipComposite_7=&Previous Tip
TipComposite_8=&Next Tip
TipComposite_9=&Close
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
index 605fa4561..e20fe6204 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/ResourceManager.java
@@ -128,7 +128,6 @@ public class ResourceManager extends SWTResourceManager {
* the corner to place decorator image.
* @return the resulting decorated {@link Image}.
*/
- @SuppressWarnings("unused")
public static Image decorateImage(final Image baseImage, final Image decorator, final int corner) {
if (corner <= 0 || corner >= LAST_CORNER_KEY) {
throw new IllegalArgumentException(Messages.ResourceManager_0);
diff --git a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
index cc612e009..8b80c2546 100644
--- a/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
+++ b/org.eclipse.tips.ui/src/org/eclipse/tips/ui/internal/util/SWTResourceManager.java
@@ -43,7 +43,6 @@ import org.eclipse.swt.widgets.Display;
* @author scheglov_ke
* @author Dan Rubel
*/
-@SuppressWarnings("unused")
public class SWTResourceManager {
////////////////////////////////////////////////////////////////////////////
//

Back to the top