diff options
Diffstat (limited to 'org.eclipse.tips.examples')
78 files changed, 2550 insertions, 0 deletions
diff --git a/org.eclipse.tips.examples/.classpath b/org.eclipse.tips.examples/.classpath new file mode 100644 index 000000000..eca7bdba8 --- /dev/null +++ b/org.eclipse.tips.examples/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/org.eclipse.tips.examples/.gitignore b/org.eclipse.tips.examples/.gitignore new file mode 100644 index 000000000..09e3bc9b2 --- /dev/null +++ b/org.eclipse.tips.examples/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/target/ diff --git a/org.eclipse.tips.examples/.project b/org.eclipse.tips.examples/.project new file mode 100644 index 000000000..13d6a0d84 --- /dev/null +++ b/org.eclipse.tips.examples/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.tips.examples</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.eclipse.tips.examples/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.tips.examples/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0c68a61dc --- /dev/null +++ b/org.eclipse.tips.examples/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/org.eclipse.tips.examples/META-INF/MANIFEST.MF b/org.eclipse.tips.examples/META-INF/MANIFEST.MF new file mode 100644 index 000000000..7dd6c1b4d --- /dev/null +++ b/org.eclipse.tips.examples/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Tip of the Day Examples +Bundle-SymbolicName: org.eclipse.tips.examples;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Vendor: Eclipse +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Require-Bundle: org.eclipse.core.runtime;bundle-version="3.13.0", + org.eclipse.tips.core;bundle-version="0.1.0", + org.eclipse.tips.json;bundle-version="0.1.0", + org.eclipse.swt, + org.eclipse.jface, + org.eclipse.tips.ui;bundle-version="0.1.0" +Eclipse-BundleShape: dir +Import-Package: org.osgi.framework;version="1.8.0" +Automatic-Module-Name: org.eclipse.tips.examples diff --git a/org.eclipse.tips.examples/build.properties b/org.eclipse.tips.examples/build.properties new file mode 100644 index 000000000..5e55821c1 --- /dev/null +++ b/org.eclipse.tips.examples/build.properties @@ -0,0 +1,18 @@ +############################################################################### +# 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 +############################################################################### +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + icons/,\ + matrixrain/,\ + images/ diff --git a/org.eclipse.tips.examples/icons/48/c++.png b/org.eclipse.tips.examples/icons/48/c++.png Binary files differnew file mode 100644 index 000000000..11e205e6d --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/c++.png diff --git a/org.eclipse.tips.examples/icons/48/ecf.png b/org.eclipse.tips.examples/icons/48/ecf.png Binary files differnew file mode 100644 index 000000000..af873b30f --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/ecf.png diff --git a/org.eclipse.tips.examples/icons/48/eclipse.png b/org.eclipse.tips.examples/icons/48/eclipse.png Binary files differnew file mode 100644 index 000000000..276f40be6 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/eclipse.png diff --git a/org.eclipse.tips.examples/icons/48/java.png b/org.eclipse.tips.examples/icons/48/java.png Binary files differnew file mode 100644 index 000000000..7129f6d73 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/java.png diff --git a/org.eclipse.tips.examples/icons/48/key.png b/org.eclipse.tips.examples/icons/48/key.png Binary files differnew file mode 100644 index 000000000..920d543e5 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/key.png diff --git a/org.eclipse.tips.examples/icons/48/nebula.png b/org.eclipse.tips.examples/icons/48/nebula.png Binary files differnew file mode 100644 index 000000000..80d5057cf --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/nebula.png diff --git a/org.eclipse.tips.examples/icons/48/pin.png b/org.eclipse.tips.examples/icons/48/pin.png Binary files differnew file mode 100644 index 000000000..a7bfc70e1 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/pin.png diff --git a/org.eclipse.tips.examples/icons/48/plugin.png b/org.eclipse.tips.examples/icons/48/plugin.png Binary files differnew file mode 100644 index 000000000..ef644a0a8 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/plugin.png diff --git a/org.eclipse.tips.examples/icons/48/pydev.png b/org.eclipse.tips.examples/icons/48/pydev.png Binary files differnew file mode 100644 index 000000000..72639f65c --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/pydev.png diff --git a/org.eclipse.tips.examples/icons/48/swt.png b/org.eclipse.tips.examples/icons/48/swt.png Binary files differnew file mode 100644 index 000000000..cc6a5ea3a --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/swt.png diff --git a/org.eclipse.tips.examples/icons/48/tips.png b/org.eclipse.tips.examples/icons/48/tips.png Binary files differnew file mode 100644 index 000000000..cd19de252 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/tips.png diff --git a/org.eclipse.tips.examples/icons/48/twitter.png b/org.eclipse.tips.examples/icons/48/twitter.png Binary files differnew file mode 100644 index 000000000..5f17261f9 --- /dev/null +++ b/org.eclipse.tips.examples/icons/48/twitter.png diff --git a/org.eclipse.tips.examples/icons/64/c++.png b/org.eclipse.tips.examples/icons/64/c++.png Binary files differnew file mode 100644 index 000000000..a948ccbef --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/c++.png diff --git a/org.eclipse.tips.examples/icons/64/ecf.png b/org.eclipse.tips.examples/icons/64/ecf.png Binary files differnew file mode 100644 index 000000000..57e09478a --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/ecf.png diff --git a/org.eclipse.tips.examples/icons/64/eclipse.png b/org.eclipse.tips.examples/icons/64/eclipse.png Binary files differnew file mode 100644 index 000000000..01aa23b91 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/eclipse.png diff --git a/org.eclipse.tips.examples/icons/64/java.png b/org.eclipse.tips.examples/icons/64/java.png Binary files differnew file mode 100644 index 000000000..36cbf25c2 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/java.png diff --git a/org.eclipse.tips.examples/icons/64/key.png b/org.eclipse.tips.examples/icons/64/key.png Binary files differnew file mode 100644 index 000000000..cc1694c12 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/key.png diff --git a/org.eclipse.tips.examples/icons/64/nebula.png b/org.eclipse.tips.examples/icons/64/nebula.png Binary files differnew file mode 100644 index 000000000..674fe6cb4 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/nebula.png diff --git a/org.eclipse.tips.examples/icons/64/pin.png b/org.eclipse.tips.examples/icons/64/pin.png Binary files differnew file mode 100644 index 000000000..c065db4cf --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/pin.png diff --git a/org.eclipse.tips.examples/icons/64/plugin.png b/org.eclipse.tips.examples/icons/64/plugin.png Binary files differnew file mode 100644 index 000000000..a75ab0593 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/plugin.png diff --git a/org.eclipse.tips.examples/icons/64/pydev.png b/org.eclipse.tips.examples/icons/64/pydev.png Binary files differnew file mode 100644 index 000000000..ece92aa5d --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/pydev.png diff --git a/org.eclipse.tips.examples/icons/64/swt.png b/org.eclipse.tips.examples/icons/64/swt.png Binary files differnew file mode 100644 index 000000000..6acbcb124 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/swt.png diff --git a/org.eclipse.tips.examples/icons/64/tips.png b/org.eclipse.tips.examples/icons/64/tips.png Binary files differnew file mode 100644 index 000000000..32fb73b60 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/tips.png diff --git a/org.eclipse.tips.examples/icons/64/twitter.png b/org.eclipse.tips.examples/icons/64/twitter.png Binary files differnew file mode 100644 index 000000000..dc874f378 --- /dev/null +++ b/org.eclipse.tips.examples/icons/64/twitter.png diff --git a/org.eclipse.tips.examples/icons/asterisk_yellow.png b/org.eclipse.tips.examples/icons/asterisk_yellow.png Binary files differnew file mode 100644 index 000000000..bab7cc9bc --- /dev/null +++ b/org.eclipse.tips.examples/icons/asterisk_yellow.png diff --git a/org.eclipse.tips.examples/icons/bug_link.png b/org.eclipse.tips.examples/icons/bug_link.png Binary files differnew file mode 100644 index 000000000..30e25abac --- /dev/null +++ b/org.eclipse.tips.examples/icons/bug_link.png diff --git a/org.eclipse.tips.examples/icons/clock.png b/org.eclipse.tips.examples/icons/clock.png Binary files differnew file mode 100644 index 000000000..e2672c206 --- /dev/null +++ b/org.eclipse.tips.examples/icons/clock.png diff --git a/org.eclipse.tips.examples/icons/cut.png b/org.eclipse.tips.examples/icons/cut.png Binary files differnew file mode 100644 index 000000000..f215d6f6b --- /dev/null +++ b/org.eclipse.tips.examples/icons/cut.png diff --git a/org.eclipse.tips.examples/icons/lightbulb.png b/org.eclipse.tips.examples/icons/lightbulb.png Binary files differnew file mode 100644 index 000000000..d22fde8ba --- /dev/null +++ b/org.eclipse.tips.examples/icons/lightbulb.png diff --git a/org.eclipse.tips.examples/images/eclipsetips/tip1.gif b/org.eclipse.tips.examples/images/eclipsetips/tip1.gif Binary files differnew file mode 100644 index 000000000..14a62bdd9 --- /dev/null +++ b/org.eclipse.tips.examples/images/eclipsetips/tip1.gif diff --git a/org.eclipse.tips.examples/images/eclipsetips/tip2.png b/org.eclipse.tips.examples/images/eclipsetips/tip2.png Binary files differnew file mode 100644 index 000000000..2e2fab32e --- /dev/null +++ b/org.eclipse.tips.examples/images/eclipsetips/tip2.png diff --git a/org.eclipse.tips.examples/images/eclipsetips/tip3.png b/org.eclipse.tips.examples/images/eclipsetips/tip3.png Binary files differnew file mode 100644 index 000000000..adbe9bdb3 --- /dev/null +++ b/org.eclipse.tips.examples/images/eclipsetips/tip3.png diff --git a/org.eclipse.tips.examples/images/java/duke.png b/org.eclipse.tips.examples/images/java/duke.png Binary files differnew file mode 100644 index 000000000..4a4e303d1 --- /dev/null +++ b/org.eclipse.tips.examples/images/java/duke.png diff --git a/org.eclipse.tips.examples/images/tips/navigate1.png b/org.eclipse.tips.examples/images/tips/navigate1.png Binary files differnew file mode 100644 index 000000000..4f4fc3a2d --- /dev/null +++ b/org.eclipse.tips.examples/images/tips/navigate1.png diff --git a/org.eclipse.tips.examples/images/tips/navigate2.png b/org.eclipse.tips.examples/images/tips/navigate2.png Binary files differnew file mode 100644 index 000000000..dcac33c9b --- /dev/null +++ b/org.eclipse.tips.examples/images/tips/navigate2.png diff --git a/org.eclipse.tips.examples/images/tips/starttip.gif b/org.eclipse.tips.examples/images/tips/starttip.gif Binary files differnew file mode 100644 index 000000000..045318617 --- /dev/null +++ b/org.eclipse.tips.examples/images/tips/starttip.gif diff --git a/org.eclipse.tips.examples/images/tips/tip2.gif b/org.eclipse.tips.examples/images/tips/tip2.gif Binary files differnew file mode 100644 index 000000000..d3850990f --- /dev/null +++ b/org.eclipse.tips.examples/images/tips/tip2.gif diff --git a/org.eclipse.tips.examples/images/tips/tipsfw.png b/org.eclipse.tips.examples/images/tips/tipsfw.png Binary files differnew file mode 100644 index 000000000..8eeb6009f --- /dev/null +++ b/org.eclipse.tips.examples/images/tips/tipsfw.png diff --git a/org.eclipse.tips.examples/matrixrain/index.html b/org.eclipse.tips.examples/matrixrain/index.html new file mode 100644 index 000000000..f3d53bd7c --- /dev/null +++ b/org.eclipse.tips.examples/matrixrain/index.html @@ -0,0 +1,26 @@ +<html> +<head> + <meta charset="UTF-8"> + <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script> + <!-- uncomment lines below to include extra p5 libraries --> + <script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/addons/p5.dom.min.js"></script> + <!--<script language="javascript" src="libraries/p5.sound.js"></script>--> + <script type="text/javascript" src="matrixrain.js"></script> + <script type="text/javascript" src="particle.js"></script> + <!-- this line removes any default padding and style. you might only need one of these values set. --> + <style type="text/css"> + body { + margin: 0px; + } + + canvas { + display: block; + } + + </style> +</head> + +<body> + +</body> +</html>
\ No newline at end of file diff --git a/org.eclipse.tips.examples/matrixrain/matrixrain.js b/org.eclipse.tips.examples/matrixrain/matrixrain.js new file mode 100644 index 000000000..a03ca729c --- /dev/null +++ b/org.eclipse.tips.examples/matrixrain/matrixrain.js @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +// Copyright 2017 Wim Jongman +// var nice = [200, 200, 0.02, 0.002, 10, 2000, 4]; +// var nice = [7280, 4320 , 0.02, 0.002, 10, 2000, 4]; +var nice = [ 1440, 900, 0.02, 0.002, 20, 50, 4 ]; +// var nice = [600, 600, 0.02, 0.002, 50, 1000, 3]; +var myX; +var myY; +var inc; +var incTime; +var scl; +var parts; +var magnitude; + +var fr; +var time = 0; +var iteration = 0; +var counter = 0; + +var particles = []; + +var flowField; + +var lanes = new Array(); + +var pg; + +function setup() { + + myX = nice[0]; + myY = nice[1]; + inc = nice[2]; + incTime = nice[3]; + scl = nice[4]; + parts = nice[5]; + magnitude = nice[6]; + + createCanvas(window.innerWidth, window.innerHeight); + document.body.scrollTop = 0; // <-- pull the page back up to the top + document.body.style.overflow = 'hidden'; // <-- relevant addition + + pixelDensity(1); + generateParticles(); +} + +function draw() { + background(0, 120); + updateParticles(); +} + +function generateParticles() { + for (var i = 0; i < parts; i++) { + particles[i] = new Particle(); + } +} + +function updateParticles() { + textSize(12); + textStyle(BOLD); + for (var i = 0; i < parts; i++) { + p = particles[i]; + if (p.isActive()) { + p.applyForce(); + p.update(); + show(p); + } + } +} + +function show(particle) { + doShow(particle, 0); + for (var i = 1; i < particle.fTrail.length; i++) { + doShow(particle, i, particle.fTrail.length); + } +} + +function doShow(particle, pos, len) { + if (pos == 0) { + fill(200, 255, 200, 255); + } else if ((len - pos) < 4) { + fill(255 - (len - pos) * 50, 255, 255 - (len - pos) * 50, + 200 - (len - pos) * 20); + } else { + fill(0, 255, 0, particle.getOpacity(pos)); + } + text(particle.getChar(pos), particle.getX(pos), particle.getY(pos)); +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/matrixrain/particle.js b/org.eclipse.tips.examples/matrixrain/particle.js new file mode 100644 index 000000000..d67254fc1 --- /dev/null +++ b/org.eclipse.tips.examples/matrixrain/particle.js @@ -0,0 +1,124 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +// Copyright 2017 Wim Jongman +function Particle() { + + this.init = function(first) { + this.fTrail = new Array(); + this.fChar = new Array(); + this.fOpac = new Array(); + this.scalar = 10; + this.fForce = createVector(0, this.scalar); + if (first) { + this.active = Math.floor(random(50)); + } + this.alive = 0; + this.laneNumber = this.getFreeLane(); + lanes[this.laneNumber] = true; + this.theY = 0; + if (first) { + this.theY = Math.floor(random(height / 2)); + } + this.pos = createVector(this.laneNumber * this.scalar, this.theY); + this.vel = createVector(0, 0); + this.acc = createVector(0, 0); + this.prv = createVector(0, 0); + this.speed = Math.floor(random(10) + 1); + this.char = this.getRandomChar(); + this.fTrail[this.fTrail.length] = this.pos; + this.fChar[this.fChar.length] = this.char; + this.fOpac[this.fOpac.length] = 255; + } + + this.getRandomChar = function() { + if (Math.round(random()) == 1) { + return char(Math.floor(12458 + random(74))); + } + return char(Math.floor(47 + random(43))); + } + + /** + * Become active after a while. + */ + this.isActive = function() { + if (this.active <= 0) { + return true; + } + this.active--; + return false; + } + + this.getFreeLane = function() { + var numberOfLanes = Math.floor(width / this.scalar); + var result = Math.floor(random(numberOfLanes)); + while (lanes[result] == true) { + result = Math.floor(random(numberOfLanes)); + } + return result; + } + + this.update = function() { + // console.log(this.alive, this.fTrail.length, this.pos.y); + if (this.pos.y > height + && (this.alive > 0 && (this.alive + 5) >= this.fTrail.length)) { + lanes[this.laneNumber] = false; + this.init(false); + } + + else if (this.pos.y <= height + 20) { + var copy = this.pos.copy(); + this.fTrail[this.fTrail.length] = copy; + this.fChar[this.fChar.length] = this.char; + this.fOpac[this.fOpac.length] = 200; + this.vel.add(this.acc); + this.pos.add(this.vel); + this.vel.limit(this.speed); + this.acc.mult(0); + this.char = this.getRandomChar(); + } + } + + this.getOpacity = function(pos) { + var count = this.fOpac[pos]; + this.fOpac[pos] -= this.speed; + if (this.fTrail[pos].y > height) { + this.fOpac[pos] = 0;// (this.speed * 100); + } + if (count > 0 && this.fOpac[pos] <= 0) { + this.alive += 2; + } + return this.fOpac[pos]; + } + + this.getX = function(pos) { + return this.fTrail[pos].x; + } + + this.getY = function(pos) { + return this.fTrail[pos].y; + } + + this.getChar = function(pos) { + if (Math.floor(random(10)) == 5) { + this.fChar[pos] = this.getRandomChar(); + } + if (pos == 0) { + return this.getRandomChar(); + } + return this.fChar[pos]; + } + + this.applyForce = function() { + this.acc.add(this.fForce); + } + + this.init(true); +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/plugin.xml b/org.eclipse.tips.examples/plugin.xml new file mode 100644 index 000000000..6c13e2410 --- /dev/null +++ b/org.eclipse.tips.examples/plugin.xml @@ -0,0 +1,96 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.4"?> +<!-- + 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 + --> + +<plugin> + <extension + point="org.eclipse.tips.core.tips"> + <category + id="org.eclipse.tips.examples.tips.tipsfw" + name="Tips Framework"> + </category> + <provider + category="org.eclipse.tips.examples.tips.tipsfw" + class="org.eclipse.tips.examples.tipsframework.TipsTipProvider" + description="Eclipse Tips" + id="org.eclipse.tips.examples.tips.tipsframework.TipsTipProvider"> + </provider> + <provider + category="org.eclipse.tips.examples.tips.tipsfw" + class="org.eclipse.tips.examples.json.JsonTipProviderPhoton" + description="Eclipse Photon New and Noteworthy" + id="org.eclipse.tips.examples.tips.tipsframework.photonnn"> + </provider> + </extension> + <extension + point="org.eclipse.tips.core.tips"> + <category + id="org.eclipse.tips.examples.tips.java" + name="Java"> + </category> + <category + id="org.eclipse.tips.examples.tips.java9" + name="Java9" + parentCategory="org.eclipse.tips.examples.tips.java9"> + </category> + <provider + category="org.eclipse.tips.examples.tips.java9" + class="org.eclipse.tips.examples.java.java9.Java9TipProvider" + description="Java 9 Tips" + id="org.eclipse.tips.examples.tips.java.java9.Java9TipProvider"> + <enablement> + <with + variable="activeWorkbenchWindow.activePerspective"> + <equals + value="org.eclipse.jdt.ui.JavaPerspective"> + </equals> + </with> + </enablement> + </provider> + </extension> + <extension + point="org.eclipse.tips.core.tips"> + <category + id="org.eclipse.tips.examples.tips.eclipsetips" + name="Eclipse IDE Tips"> + </category> + <provider + category="org.eclipse.tips.examples.tips.eclipsetips" + class="org.eclipse.tips.examples.eclipsetips.EclipseTipsProvider" + description="Eclipse Tips" + id="org.eclipse.tips.examples.tips.eclipsetips.EclipseTipsProvider"> + </provider> + </extension> + <extension + point="org.eclipse.tips.core.tips"> + <category + id="org.eclipse.tips.examples.tips.eclipsetips" + name="Eclipse IDE Tips"> + </category> + <provider + category="org.eclipse.tips.examples.tips.eclipsetips" + class="org.eclipse.tips.examples.test.TestProvider" + description="Test Provider" + id="org.eclipse.tips.examples.tips.test.TestProvider"> + </provider> + </extension> + <extension + point="org.eclipse.tips.core.tips"> + <provider + category="org.eclipse.tips.examples.tips.eclipsetips" + class="org.eclipse.tips.examples.swttip.SwtTipsProvider" + description="SWT Tips Provider" + id="org.eclipse.tips.examples.swttip.SWTTipsProvider"> + </provider> + </extension> + +</plugin> diff --git a/org.eclipse.tips.examples/pom.xml b/org.eclipse.tips.examples/pom.xml new file mode 100644 index 000000000..f18f8274c --- /dev/null +++ b/org.eclipse.tips.examples/pom.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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 + --> + +<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>eclipse.platform.ua</groupId> + <artifactId>eclipse.platform.ua</artifactId> + <version>4.8.0-SNAPSHOT</version> + </parent> + <groupId>org.eclipse.ui</groupId> + <artifactId>org.eclipse.tips.examples</artifactId> + <version>0.1.0-SNAPSHOT</version> + <packaging>eclipse-plugin</packaging> +</project> diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/DateUtil.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/DateUtil.java new file mode 100644 index 000000000..2d5226e7a --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/DateUtil.java @@ -0,0 +1,40 @@ +/******************************************************************************* + * 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; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * Date utilities. + * + */ +public class DateUtil { + + /** + * Convenience method that creates a date from a dd/mm/yy string. + * + * @param pYYMMDD + * the date in a dd/mm/yy format, e.g. "01/01/2017" + * @return the date + * @throws RuntimeException + * if the date is not correct + */ + public static Date getDateFromYYMMDD(String pYYMMDD) { + SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); + try { + return sdf.parse(pYYMMDD); + } catch (ParseException e) { + throw new RuntimeException(e); + } + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/EclipseTipsProvider.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/EclipseTipsProvider.java new file mode 100644 index 000000000..c9fdbbacc --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/EclipseTipsProvider.java @@ -0,0 +1,110 @@ +/******************************************************************************* + * 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.eclipsetips; + +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.eclipse.tips.examples.DateUtil; +import org.eclipse.tips.examples.tips.MediaWikiTip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class EclipseTipsProvider extends org.eclipse.tips.core.TipProvider { + + public int fCurrentTip; + + private Tip createTip1() { + return new org.eclipse.tips.examples.tips.TwitterTip(getID(), "https://twitter.com/EclipseJavaIDE/status/919915440041840641", DateUtil.getDateFromYYMMDD("08/12/017"), + "Twitter Tip"); + } + + private Tip createTip2() { + return new org.eclipse.tips.examples.tips.MediaWikiTip(getID(), "https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Show_In_System_Explorer", + DateUtil.getDateFromYYMMDD("08/01/2017"), "Show in Systems Explorer"); + } + + private MediaWikiTip createTip3() { + return new org.eclipse.tips.examples.tips.MediaWikiTip(getID(), + "https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Now_where_was_I", + DateUtil.getDateFromYYMMDD("08/01/2017"), "Where was I?"); + } + + private Tip createTip4() { + return new org.eclipse.tips.examples.tips.MediaWikiTip(getID(), + "https://twitter.com/EclipseJavaIDE/status/949238007051235328", + DateUtil.getDateFromYYMMDD("08/01/2017"), "Extract class"); + } + + private MediaWikiTip createTip5() { + return new org.eclipse.tips.examples.tips.MediaWikiTip(getID(), + "https://twitter.com/EclipseJavaIDE/status/919915440041840641", + DateUtil.getDateFromYYMMDD("08/01/2017"), "Junit Jupiter Test"); + } + + @Override + public String getDescription() { + return "General Eclipse IDE Tips"; + } + + @Override + public String getID() { + return getClass().getName(); + } + + private TipImage fImage48; + + @Override + public TipImage getImage() { + if (fImage48 == null) { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + fImage48 = new TipImage(bundle.getEntry("icons/48/eclipse.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(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 Tip1(getID())); + tips.add(new Tip2(getID())); + tips.add(new Tip3(getID())); + tips.add(createTip1()); + tips.add(createTip2()); + tips.add(createTip3()); + tips.add(createTip4()); + tips.add(createTip5()); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @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/eclipsetips/Tip1.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip1.java new file mode 100644 index 000000000..86903b0de --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip1.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.eclipsetips; + +import java.io.IOException; +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 Tip1 extends Tip implements IHtmlTip { + + public Tip1(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + @Override + public String getSubject() { + return "This is SwtTipImpl"; + } + + @Override + public String getHTML() { + return "<h1>Iterate with Iterator</h1>" // + + "Workbench editors keep a navigation history." // + + " If you open a second editor while you're editing," + + " you can press <b>Navigate > Backward (Alt+Left Arrow," + + " or the Left arrow icon back arrow icon on the" + + " workbench toolbar)</b> to go back to the last editor." + + " This makes working with several open editors a whole lot easier." + "<br/><br/>"; + } + + @Override + public TipImage getImage() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry("images/eclipsetips/tip1.gif")).setAspectRatio(560.0 / 266.0); + } catch (IOException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip2.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip2.java new file mode 100644 index 000000000..b6bd14322 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip2.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * 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.eclipsetips; + +import java.io.IOException; +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 Tip2 extends Tip implements IHtmlTip { + + + public Tip2(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + @Override + public String getSubject() { + return "Quick Access"; + } + + @Override + public String getHTML() { + return "<h1>Quick access</h1>You can quickly find all manner of" + + " user interface elements with the <b>Quick Access</b>" + + " search bar at the top of the workbench window. Click" + + " in the field or use the <b>Ctrl+3</b> binding to switch" + + " focus to it. Matching elements include (but are not limited to)" + + " open editors, available perspectives, views, preferences, wizards," + + " and commands. Simply start typing the name of the item you wish to" + + " invoke and we will attempt to find something in the Workbench that" + + " matches the provided string. "; + } + + @Override + public TipImage getImage() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry("images/eclipsetips/tip2.png")); + } catch (IOException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip3.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip3.java new file mode 100644 index 000000000..c67d4403f --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/Tip3.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * 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.eclipsetips; + +import java.io.IOException; +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 Tip3 extends Tip implements IHtmlTip { + + + public Tip3(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + @Override + public String getSubject() { + return "Auto Save"; + } + + @Override + public String getHTML() { + return "<h1>Automatic Save of dirty editors</h1>You can configure the automatic save of dirty editors in Eclipse via the <b>General > Editors > Autosave</b> preference page which allows you to enable/disable the autosave and change the interval of autosave."; + } + + @Override + public TipImage getImage() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry("images/eclipsetips/tip3.png")).setAspectRatio(658.0 / 581.0); + } catch (IOException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/TwitterTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/TwitterTip.java new file mode 100644 index 000000000..afe11e766 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/eclipsetips/TwitterTip.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.eclipsetips; + +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 TwitterTip extends Tip implements IHtmlTip { + + public TwitterTip(String providerId) { + super(providerId); + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + @Override + public String getSubject() { + return "CTRL+1 Quick Assists"; + } + + @Override + public String getHTML() { + return "<html><head><style>" + + "</style></head><body><div><blockquote class=\"twitter-tweet\" data-lang=\"en\"><p lang=\"en\" dir=\"ltr\">The 'Extract class...' refactoring (from Alt+Shift+T) extracts a group of fields into a separate class and replaces all occurrences to fit the new structure. See example. <a href=\"https://twitter.com/hashtag/EclipseTips?src=hash&ref_src=twsrc%5Etfw\">#EclipseTips</a> <a href=\"https://t.co/tEI7ic7C1g\">pic.twitter.com/tEI7ic7C1g</a></p>— Eclipse Java IDE (@EclipseJavaIDE) <a href=\"https://twitter.com/EclipseJavaIDE/status/949238007051235328?ref_src=twsrc%5Etfw\">January 5, 2018</a></blockquote>" + + "<script src=\"https://platform.twitter.com/widgets.js\" charset=\"utf-8\"></script></div></body></html>"; + } + + @Override + public TipImage getImage() { + return null; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Java9TipProvider.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Java9TipProvider.java new file mode 100644 index 000000000..16e532921 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Java9TipProvider.java @@ -0,0 +1,73 @@ +/******************************************************************************* + * 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.java.java9; + +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.TipProvider; +import org.eclipse.tips.core.internal.LogUtil; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +/** + * + + * + */ +public class Java9TipProvider extends TipProvider { + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public TipImage getImage() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry("icons/48/java.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + return null; + + } + + @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 Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public String getDescription() { + return "Java and Java Dev Tools Tips"; + } + + @Override + public void dispose() { + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Tip1.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Tip1.java new file mode 100644 index 000000000..5d9045522 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/java/java9/Tip1.java @@ -0,0 +1,109 @@ +/******************************************************************************* + * 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.java.java9; + +import java.io.IOException; +import java.util.ArrayList; +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; + +/** + * This is an example Tip class. + * + */ +public class Tip1 extends Tip implements IHtmlTip { + + /** + * Tips should be created fast. + * + * @param pProvider + * the associated {@link TipProvider} + */ + public Tip1(String providerId) { + super(providerId); + } + + @Override + public List<TipAction> getActions() { + Runnable runnable = () -> Display.getDefault() + .syncExec(() -> MessageDialog.openConfirm(null, getSubject(), "We can start an action from a Tip!")); + + ArrayList<TipAction> actions = new ArrayList<>(); + actions.add(new TipAction("Tip1 Action", "Just a silly action", runnable, null)); + return actions; + } + + /** + * Return the publish date of the tip. The {@link TipProvider} could decide to + * server newer tips first. + * + * @return the date this tip was published which may not be null. + */ + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + /** + * @return the subject which may not be null. + */ + @Override + public String getSubject() { + return "Java tip 1"; + } + + /** + * This method may both return the string representation of an URL or the + * descriptive HTML of the tip. If the html of the text is returned then an + * effort is made to also inline the image URL. If you supply an URL then + * {@link #getImage()} should return null. + * + * @return the HMTL or URL of the tip which is displayed in a browser widget. + * @see #getImage() + */ + @Override + public String getHTML() { + return "<h2>Javatip 1</h2>You see this tip because the Tip UI was opened when the java perspective " + + "was active or because you selected the Java icon below." + "<br><br>" + + "More java tips will be displayed here in the near future. For now, select one of the other providers" + + " by clicking on the icons below."; + } + + /** + * A getter for the {@link TipImage}. Subclasses may override, the default + * implementation returns null. + * + * @return a TipImage with information about the image or null if no image is + * provided. + */ + @Override + public TipImage getImage() { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + return new TipImage(bundle.getEntry("images/java/duke.png")).setAspectRatio(1); + } catch (IOException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/json/JsonTipProviderPhoton.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/json/JsonTipProviderPhoton.java new file mode 100644 index 000000000..d77193c1a --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/json/JsonTipProviderPhoton.java @@ -0,0 +1,27 @@ +/******************************************************************************* + * 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.json; + +import java.net.MalformedURLException; + +import org.eclipse.tips.json.JsonTipProvider; + +public class JsonTipProviderPhoton extends JsonTipProvider { + + public JsonTipProviderPhoton() throws MalformedURLException { + setJsonUrl("https://raw.githubusercontent.com/wimjongman/jsontips/master/photon/m3tips.json"); + } + + @Override + public String getID() { + return getClass().getName(); + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java new file mode 100644 index 000000000..faeb61c3b --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipImpl.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * 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.swttip; + +import java.util.Date; + +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Text; +import org.eclipse.tips.core.Tip; +import org.eclipse.tips.examples.DateUtil; +import org.eclipse.tips.ui.ISwtTip; + +public class SwtTipImpl extends Tip implements ISwtTip { + + private final class Beeper extends SelectionAdapter { + @Override + public void widgetSelected(SelectionEvent e) { + e.widget.getDisplay().beep(); + if (((Button) e.widget).getText().contains("2")) { + try { + Thread.sleep(600); + } catch (InterruptedException e1) { + } + e.widget.getDisplay().beep(); + } + } + } + + private String fSubject; + + public SwtTipImpl(String providerId, int number) { + super(providerId); + fSubject = "This is a tip " + number; + } + + @Override + public Date getCreationDate() { + return DateUtil.getDateFromYYMMDD("10/01/2018"); + } + + @Override + public String getSubject() { + return fSubject; + } + + @Override + public void createControl(Composite pParent) { + pParent.setLayout(new GridLayout(2, false)); + Group group = new Group(pParent, SWT.NONE); + GridDataFactory.fillDefaults().span(2, SWT.DEFAULT).grab(true, true).applyTo(group); + group.setLayout(new FillLayout()); + group.setText(fSubject); + Text text = new Text(group, SWT.MULTI | SWT.WRAP); + text.setText(fSubject + System.lineSeparator() + System.lineSeparator() + + "There are thousands of these tips. Just press next tip and you will see."); + Button button1 = new Button(pParent, SWT.PUSH); + button1.setText("Beep once"); + button1.addSelectionListener(new Beeper()); + GridDataFactory.fillDefaults().applyTo(button1); + Button button2 = new Button(pParent, SWT.PUSH); + button2.setText("Beep 2 times"); + button2.addSelectionListener(new Beeper()); + GridDataFactory.fillDefaults().applyTo(button2); + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipsProvider.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipsProvider.java new file mode 100644 index 000000000..5424fdd68 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/swttip/SwtTipsProvider.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * 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.swttip; + +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.core.runtime.jobs.Job; +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.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class SwtTipsProvider extends TipProvider { + + private TipImage fImage64, fImage48; + private int fCounter; + private boolean fFetching; + + @Override + public String getDescription() { + return "Never ending list of SWT Tips"; + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public synchronized List<Tip> getTips(boolean pFilter) { + List<Tip> tips = super.getTips(pFilter); + if (tips.size() <= 1) { + Job job = new Job(getDescription() + " is getting more tips.") { + + @Override + protected IStatus run(IProgressMonitor pMonitor) { + return loadNewTips(pMonitor); + } + }; + job.setUser(true); + job.schedule(); + } + return tips; + } + + @Override + public TipImage getImage() { + if (fImage48 == null) { + Bundle bundle = FrameworkUtil.getBundle(getClass()); + try { + fImage48 = new TipImage(bundle.getEntry("icons/48/swt.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + if (fFetching) { + return Status.CANCEL_STATUS; + } + try { + subMonitor.beginTask("Loading Tips for " + getDescription(), -1); + List<Tip> tips = new ArrayList<>(); + tips.add(new SwtTipImpl(getID(),1)); + tips.add(new SwtTipImpl(getID(),2)); + tips.add(new SwtTipImpl(getID(),3)); + tips.add(new SwtTipImpl(getID(),4)); + tips.add(new SwtTipImpl(getID(),5)); + addTips(tips); + return Status.OK_STATUS; + } finally { + fFetching = false; + subMonitor.done(); + } + } + + @Override + public void dispose() { + } + + public int getCounter() { + return ++fCounter; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider.java new file mode 100644 index 000000000..6036ace4d --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider.java @@ -0,0 +1,96 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider 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/c++.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + + if (System.getProperty("tips.test") == null) { + return Status.OK_STATUS; + } + + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + getManager().register(new TestProvider1()); + getManager().register(new TestProvider2()); + getManager().register(new TestProvider3()); + getManager().register(new TestProvider4()); + getManager().register(new TestProvider5()); + getManager().register(new TestProvider6()); + getManager().register(new TestProvider7()); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider1.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider1.java new file mode 100644 index 000000000..5e900cd70 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider1.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider1 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/key.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider2.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider2.java new file mode 100644 index 000000000..3bd6b11b2 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider2.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider2 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/key.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider3.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider3.java new file mode 100644 index 000000000..18ee0bf31 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider3.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider3 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/ecf.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider4.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider4.java new file mode 100644 index 000000000..d896afae1 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider4.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider4 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/pin.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider5.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider5.java new file mode 100644 index 000000000..cff85162c --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider5.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.test; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider5 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/plugin.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + int sleep = new Random().nextInt(10000) + 1000; + while (sleep > 0) { + try { + Thread.sleep(500); + sleep -= 500; + subMonitor.subTask("Sleeping " + sleep); + } catch (InterruptedException e) { + } + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider6.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider6.java new file mode 100644 index 000000000..6626d1b59 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider6.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * 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.test; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider6 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/pydev.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider7.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider7.java new file mode 100644 index 000000000..f3fe1fdee --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/test/TestProvider7.java @@ -0,0 +1,78 @@ +/******************************************************************************* + * 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.test; + +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.eclipse.tips.examples.java.java9.Tip1; +import org.eclipse.tips.examples.tipsframework.Navigate2Tip; +import org.osgi.framework.Bundle; +import org.osgi.framework.FrameworkUtil; + +public class TestProvider7 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/twitter.png")).setAspectRatio(1); + } catch (IOException e) { + getManager().log(LogUtil.error(getClass(), e)); + } + } + return fImage48; + } + + + @Override + public synchronized IStatus loadNewTips(IProgressMonitor pMonitor) { + SubMonitor subMonitor = SubMonitor.convert(pMonitor); + subMonitor.beginTask("Loading Tips", -1); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + } + List<Tip> tips = new ArrayList<>(); + tips.add(new Tip1(getID())); + tips.add(new Navigate2Tip(getID())); + setTips(tips); + subMonitor.done(); + return Status.OK_STATUS; + } + + @Override + public String getDescription() { + return "Test Provider " + getClass().getSimpleName(); + } + + @Override + public String getID() { + return getClass().getName(); + } + + @Override + public void dispose() { + // TODO Auto-generated method stub + + } +} diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java new file mode 100644 index 000000000..b43867fe0 --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/MediaWikiTip.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * 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.tips; + +import java.net.MalformedURLException; +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.core.internal.LogUtil; + +/** + * Specialisation of Tip that receives an URL of a mediawiki page (e.g. Eclipse + * wiki) and renders this URL as a tip. + * <p> + * For an example see: + * + * <a href= + * "https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Now_where_was_I">https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Now_where_was_I</a> + * + */ +public class MediaWikiTip extends Tip implements IUrlTip { + + private String fPageUrl; + private Date fCreationDate; + private String fSubject; + + /** + * Constructor. + * + * <p> + * For an example see: + * + * <a href= + * "https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Now_where_was_I">https://wiki.eclipse.org/Tip_of_the_Day/Eclipse_Tips/Now_where_was_I</a> + * </p> + * + * @param pProvider + * the {@link TipProvider} that created this Tip + * @param pPageUrl + * the Eclipse wiki page containing a simple tip + * @param pCreationDate + * creation date + * @param pSubject + * the tips' subject + */ + public MediaWikiTip(String providerId, String pPageUrl, Date pCreationDate, String pSubject) { + super(providerId); + fPageUrl = pPageUrl; + fCreationDate = pCreationDate; + fSubject = pSubject; + } + + @Override + public Date getCreationDate() { + return fCreationDate; + } + + @Override + public String getSubject() { + return fSubject; + } + + @Override + public URL getURL() { + try { + return new URL(fPageUrl.trim() + "?action=render"); + } catch (MalformedURLException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java new file mode 100644 index 000000000..0d1e2cbcc --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/TwitterTip.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * 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.tips; + +import java.net.MalformedURLException; +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.core.internal.LogUtil; + +/** + * Specialisation of Tip that receives an URL of a tweet in the constructor. The + * URL points directly to the tweet: + * <p> + * For an example see: <a href= + * "https://twitter.com/EclipseJavaIDE/status/919915440041840641">https://twitter.com/EclipseJavaIDE/status/919915440041840641</a> + * </p> + */ +public class TwitterTip extends Tip implements IUrlTip { + + private String fPageUrl; + private Date fCreationDate; + private String fSubject; + + /** + * Constructor. + * + * <p> + * For an example see: <a href= + * "https://twitter.com/EclipseJavaIDE/status/919915440041840641">https://twitter.com/EclipseJavaIDE/status/919915440041840641</a> + * </p> + * + * @param pProvider + * the {@link TipProvider} that created this Tip + * @param pTweetUrl + * the URL of the tweet + * @param pCreationDate + * creation date + * @param pSubject + * the tips' subject + */ + public TwitterTip(String providerId, String pTweetUrl, Date pCreationDate, String pSubject) { + super(providerId); + fPageUrl = pTweetUrl; + fCreationDate = pCreationDate; + fSubject = pSubject; + } + + @Override + public Date getCreationDate() { + return fCreationDate; + } + + @Override + public String getSubject() { + return fSubject; + } + + @Override + public URL getURL() { + try { + return new URL(fPageUrl); + } catch (MalformedURLException e) { +// getProvider().getManager().log(LogUtil.error(getClass(), e)); + } + return null; + } +}
\ No newline at end of file diff --git a/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/package-info.java b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/package-info.java new file mode 100644 index 000000000..77276a13c --- /dev/null +++ b/org.eclipse.tips.examples/src/org/eclipse/tips/examples/tips/package-info.java @@ -0,0 +1,15 @@ +/******************************************************************************* + * 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 + *******************************************************************************/ +/** + * Contains some example tip implementations, + * + */ +package org.eclipse.tips.examples.tips;
\ No newline at end of file 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 |