diff options
Diffstat (limited to 'org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework')
7 files changed, 483 insertions, 0 deletions
diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/GithubTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/GithubTip.java new file mode 100644 index 000000000..cad686913 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/GithubTip.java @@ -0,0 +1,90 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.awt.Desktop; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tips.core.IHtmlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipAction; +import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.core.internal.LogUtil; +import org.eclipse.tips.examples.DateUtil; + +public class GithubTip extends Tip implements IHtmlTip { + + public GithubTip(String providerId) { + super(providerId); + } + + @Override + public List<TipAction> getActions() { + Runnable runner = () -> Display.getDefault().asyncExec(() -> { + if (Platform.isRunning() && Platform.getWS().startsWith("gtk")) { + MessageDialog.openInformation(null, "Action", "Can't open a browser in GTK. It crashes the JVM."); + } else { + Desktop d = Desktop.getDesktop(); + try { + d.browse(new URI("https://github.com/wimjongman/tips")); + } catch (IOException | URISyntaxException e) { + e.printStackTrace(); + } + } + }); + + ArrayList<TipAction> actions = new ArrayList<>(); + actions.add(new TipAction("Show in Github", "Opens a browser.", runner, null)); + return actions; + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "On GitHub"; + } + + @Override + public String getHTML() { + return "<h2>Incubating on GitHub</h2>We are incubating this project on Github " + + "and we could use your help. Press the <b>More...</b> button to open the " + "GitHub repository. " + + "<br>" + "<br>" + "We are looking forward to your pull requests." + "<br>"; + } + + private TipImage fImage; + + @Override + public TipImage getImage() { + if (fImage == null) { + try { + fImage = new TipImage(new URL("https://assets-cdn.github.com/images/modules/logos_page/Octocat.png")) + .setAspectRatio(800, 665, true); + } catch (Exception e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/MatrixRainTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/MatrixRainTip.java new file mode 100644 index 000000000..c672a1bec --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/MatrixRainTip.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.net.URL; +import java.util.Date; + +import org.eclipse.tips.core.IUrlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.examples.DateUtil; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class MatrixRainTip extends Tip implements IUrlTip { + + public MatrixRainTip(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "Welcome to the Matrix"; + } + + @Override + public URL getURL() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + return bundle.getEntry("matrixrain/index.html"); + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate1Tip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate1Tip.java new file mode 100644 index 000000000..e39a02e2f --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate1Tip.java @@ -0,0 +1,101 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.swt.widgets.Display; +import org.eclipse.tips.core.IHtmlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipAction; +import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.core.internal.LogUtil; +import org.eclipse.tips.examples.DateUtil; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class Navigate1Tip extends Tip implements IHtmlTip { + + private TipImage fImage; + + @Override + public TipImage getImage() { + if (fImage == null) { + try { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + fImage = new TipImage(bundle.getEntry("images/tips/navigate1.png")).setAspectRatio(600, 200, true); + } catch (Exception e) { +// getProvider().getManager().log(LogUtil.info(getClass(), e)); + } + } + return fImage; + } + + public Navigate1Tip(String providerId) { + super(providerId); + } + + @Override + public List<TipAction> getActions() { + Runnable runnable = () -> Display.getDefault() + .syncExec(() -> MessageDialog.openConfirm(null, getSubject(), "We can do anything we want.")); + Runnable clock = () -> Display.getDefault().syncExec(() -> MessageDialog.openConfirm(null, getSubject(), + DateFormat.getTimeInstance().format(Calendar.getInstance().getTime()))); + Runnable runner2 = () -> Display.getDefault() + .syncExec(() -> MessageDialog.openConfirm(null, getSubject(), "Like open preferences...")); + ArrayList<TipAction> actions = new ArrayList<>(); + actions.add(new TipAction("Clock", "Some sort of clock action", clock, getImage("icons/clock.png"))); + actions.add( + new TipAction("Open Preferences", "Opens the preferences", runner2, getImage("icons/bug_link.png"))); + actions.add( + new TipAction("Cut or Paste", "Just another silly action", runnable, getImage("icons/lightbulb.png"))); + actions.add(new TipAction("Eclipse Rocks, Idea Scissors", "Paper", runnable, getImage("icons/cut.png"))); + actions.add(new TipAction("Totally Bonkers", "The quick brown fox", runnable, getImage("icons/notfound.png"))); + return actions; + } + + private TipImage getImage(String pIcon) { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry(pIcon)).setAspectRatio(1); + } catch (Exception e) { + return null; + } + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "Navigate Tip 1"; + } + + @Override + public String getHTML() { + return "<h2>Navigating Tips</h2>You can navigate tips by using the button bar. " + + "<br><b>Next Tip</b><br>Navigates to the next tip." + + "<br><b>Previous Tip</b></br>Navigates to the previous tip." + + "<br><b>Close</b></br>Closes the Dialog (<b>Escape</b> does the same)." + + "<br><b>Show tips at startup</b><br/>A toggle to show this dialog when you start Eclipse." + + "<br><br>" + + "If a tip can do something special then the <b>More...</b> button is activated, like with this tip." + + "<br>Go on, press it!"; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate2Tip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate2Tip.java new file mode 100644 index 000000000..e997e5102 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/Navigate2Tip.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.util.Date; + +import org.eclipse.tips.core.IHtmlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.core.internal.LogUtil; +import org.eclipse.tips.examples.DateUtil; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class Navigate2Tip extends Tip implements IHtmlTip { + + private TipImage fImage; + + public Navigate2Tip(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "Navigate Tip 2"; + } + + @Override + public String getHTML() { + return "<h2>Navigating Tips</h2>You can activate other Tip Providers by clicking on the big icons below." + + "<br>" + + "You are currently looking at the Tips tips but as you can see there are other providers. Go ahead and" + + " select some of the other providers. If you click on the lightbulb below you will return to this tip.<br><br>"; + } + + @Override + public TipImage getImage() { + if (fImage == null) { + try { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + fImage = new TipImage(bundle.getEntry("images/tips/navigate2.png")).setAspectRatio(650, 220, true); + } catch (Exception e) { +// getProvider().getManager().log(LogUtil.info(getClass(), e)); + } + } + return fImage; + } + +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/StartingTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/StartingTip.java new file mode 100644 index 000000000..f55cdacd5 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/StartingTip.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.util.Date; + +import org.eclipse.tips.core.IHtmlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.core.internal.LogUtil; +import org.eclipse.tips.examples.DateUtil; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class StartingTip extends Tip implements IHtmlTip { + + public StartingTip(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "Opening the Tips Dialog"; + } + + @Override + public String getHTML() { + return "<h2>Opening the Tips Dialog</h2>The tips are started automatically at startup but you can switch this off." + + " In case the tips are not loaded at startup you can active the tips manually from the Help menu." + + "<br><br>" + "Press <b><i>Next Tip</i></b> to see how to navigate Tips.<br><br>"; + } + + private TipImage fImage; + + @Override + public TipImage getImage() { + if (fImage == null) { + try { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + fImage = new TipImage(bundle.getEntry("images/tips/starttip.gif")).setAspectRatio(780, 430, true); + } catch (Exception e) { +// getProvider().getManager().log(LogUtil.info(getClass(), e)); + } + } + return fImage; + } + +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/TipsTipProvider.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/TipsTipProvider.java new file mode 100644 index 000000000..ff6a1299f --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/TipsTipProvider.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.io.IOException; +import java.util.ArrayList; +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; + +public class TipsTipProvider extends org.eclipse.tips.core.TipProvider { + + private TipImage fImage64, fImage48; + + @Override + public TipImage getImage() { + if (fImage48 == null) { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + fImage48 = new TipImage(bundle.getEntry("icons/48/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 WelcomeTip(getID())); + tips.add(new StartingTip(getID())); + tips.add(new Navigate1Tip(getID())); + tips.add(new Navigate2Tip(getID())); + tips.add(new GithubTip(getID())); + tips.add(new MatrixRainTip(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() { + // TODO Auto-generated method stub + + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/WelcomeTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/WelcomeTip.java new file mode 100644 index 000000000..f07436127 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tipsframework/WelcomeTip.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.examples.tipsframework; + +import java.util.Date; + +import org.eclipse.tips.core.IHtmlTip; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.core.TipImage; +import org.eclipse.tips.core.TipProvider; +import org.eclipse.tips.examples.DateUtil; + +public class WelcomeTip extends Tip implements IHtmlTip { + + public WelcomeTip(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("09/01/2018"); + } + + @Override + public String getSubject() { + return "Welcome to the tips framework"; + } + + @Override + public String getHTML() { + return "<h2>Welcome to the Tips Framework</h2>It can show tips from various tip providers. This provider has tips about tips which will show you how to navigate this UI." + + " The dialog is this Tip UI. Tips appear here in various forms. They can come from Twitter, a Wiki, a Website, a file or even from Java, like this one." + + "<br><br>" + "Press <b><i>Next Tip</i></b> to see how to start tips manually."; + } + + @Override + public TipImage getImage() { + return null; + } +}
\ No newline at end of file |