diff options
Diffstat (limited to 'org.eclipse.tips.core/schema/tips.exsd')
-rw-r--r-- | org.eclipse.tips.core/schema/tips.exsd | 341 |
1 files changed, 16 insertions, 325 deletions
diff --git a/org.eclipse.tips.core/schema/tips.exsd b/org.eclipse.tips.core/schema/tips.exsd index 93236edf6..a9d77ad84 100644 --- a/org.eclipse.tips.core/schema/tips.exsd +++ b/org.eclipse.tips.core/schema/tips.exsd @@ -24,7 +24,6 @@ This extension point allows bundles to hook into the eclipse tips framework. <complexType> <choice> <element ref="provider" minOccurs="1" maxOccurs="unbounded"/> - <element ref="category" minOccurs="1" maxOccurs="unbounded"/> </choice> <attribute name="point" type="string" use="required"> <annotation> @@ -82,54 +81,6 @@ This extension point allows bundles to hook into the eclipse tips framework. </appinfo> </annotation> </attribute> - <attribute name="category" type="string" use="required"> - <annotation> - <documentation> - - </documentation> - <appinfo> - <meta.attribute kind="identifier" basedOn="org.eclipse.tips.core.tips/category/@id"/> - </appinfo> - </annotation> - </attribute> - </complexType> - </element> - - <element name="category"> - <annotation> - <documentation> - A category to group tips in the UI. - </documentation> - </annotation> - <complexType> - <attribute name="id" type="string" use="required"> - <annotation> - <documentation> - a unique name that will be used to identify this category - </documentation> - </annotation> - </attribute> - <attribute name="name" type="string" use="required"> - <annotation> - <documentation> - a translatable name that will be used in the UI for this category - </documentation> - <appinfo> - <meta.attribute translatable="true"/> - </appinfo> - </annotation> - </attribute> - <attribute name="parentCategory" type="string"> - <annotation> - <documentation> - an optional path composed of category IDs separated by '/'. This -allows the creation of a hierarchy of categories. - </documentation> - <appinfo> - <meta.attribute kind="identifier" basedOn="org.eclipse.tips.core.tips/category/@id"/> - </appinfo> - </annotation> - </attribute> </complexType> </element> @@ -140,295 +91,35 @@ allows the creation of a hierarchy of categories. </appinfo> <documentation> <p> -This extension defines a parent category "Java"and a child category "Java9". Then the provider -is defined within category "Java9". +This extension defines a tip provider. The provider is given higher priority if the current active perspective is the java perspective. <pre> - <extension + &lt;extension point="org.eclipse.tips.ide.tips"> - <category - id="org.eclipse.tips.examples.java" - name="Java"> - </category> - <category - id="org.eclipse.tips.examples.java9" - name="Java9" - parentCategory="org.eclipse.tips.examples.java9"> - </category> - <provider - category="org.eclipse.tips.examples.java9" + &lt;provider class="org.eclipse.tips.examples.java.java9.Java9TipProvider" description="Java 9 Tips" id="org.eclipse.tips.examples.java.java9.Java9TipProvider"> - <enablement> - <with + &lt;enablement> + &lt;with variable="activeWorkbenchWindow.activePerspective"> - <equals + &lt;equals value="org.eclipse.jdt.ui.JavaPerspective"> - </equals> - </with> - </enablement> - </provider> - </extension> + &lt;/equals> + &lt;/with> + &lt;/enablement> + &lt;/provider> + &lt;/extension> </pre> </p> <p> -<b>Sample implementation TipProvider</b> +<b>Example Tip Providers</b> </p> -<p> - -<h1>The Implementation of a TipProvider</h1> -This is an example of a TipProvider. The framework also contains an JSon TipProvider that fetches tips inside a JSon file from a remote URL. -<b> -The example below instantiates Tips from Java. -<pre> - -/** - * Class to provide tips to the tip framework. It is the job of this provider to - * manage its tips. Examples of managing tips are: - * - * <ul> - * <li>Loading tips from the internet</li> - * <li>Serve next, previous and current tip on request</li> - * </ul> - * - * After the TipProvider is instantiated by the {@link TipManager}, the - * TipManager will insert itself by calling {@link #setManager(TipManager)}. - * Then the TipManager will asynchronous call this providers' {@link #load()} - * method. The job of the load() method is to do long work like fetching new - * tips from the internet and storing them locally. There is no defined method - * on how tips should be stored locally, implementers are free to do what is - * needed. - * - * The constructor must return fast, meaning that tips may not be fetched from - * the internet in the constructor. This should be done in the - * {@link #load(IProgressMonitor)} method. - * - * To indicate that this provider is ready to serve tips, it should call the - * {@link #setTips(List)} method which then sets its <code>ready</code> flag. - * - */ -public class Java9TipProvider extends TipProvider { - - @Override - /** - * The Id is used (for example) to manage the read state of this providers tips. - * It should be unique. - * - * @return the ID of this provider - */ - public String getID() { - return "org.eclipse.tips.examples.Java9TipProvider"; - } - - /** - * The 48x48 image may be used by the UI for low resolution displays. - * - * @return a 48x48 {@link TipImage} - */ - @Override - public TipImage getImage48() { - Bundle bundle = FrameworkUtil.getBundle(getClass()); - try { - return new TipImage(bundle.getEntry("icons/48/java.png")).setAspectRatio(1); - } catch (IOException e) { - getManager().log(getClass(), e); - } - return null; - - } - - /** - * The 64x64 image may be used by the UI for higher resolution displays. - * - * @return a 64x64 {@link TipImage} - */ - @Override - public TipImage getImage64() { - Bundle bundle = FrameworkUtil.getBundle(getClass()); - try { - return new TipImage(bundle.getEntry("icons/64/java.png")).setAspectRatio(1); - } catch (IOException e) { - getManager().log(getClass(), e); - } - return null; - - } - - /** - * Is called asynchronously during startup of the TipManager to gather new tips. - * The provider is not available to the UI unless it has called it's - * {@link #setTips(List)} method. It is therefore possible that the provider is - * not immediately visible in the tip UI but will be added later. - * - * One strategy is to do a long running fetch in this method and then store the - * tips locally. On the next run of the TipManager, the fetched tips can be - * served from the constructor (i.e. by calling {@link #setTips(List)}), making - * it immediately available. - * - * @param pMonitor - * The monitor to report back progress. - * @see TipProvider#setTips(List) - * @see TipProvider#isReady() - */ - @Override - public synchronized void load(IProgressMonitor pMonitor) { - SubMonitor subMonitor = SubMonitor.convert(pMonitor); - subMonitor.beginTask("Loading Tips", -1); - List<Tip> tips = new ArrayList<>(); - tips.add(new Tip1(this)); - tips.add(new Navigate2Tip(this)); - setTips(tips); - subMonitor.done(); - } - - /** - * @return the short description of this provider. - */ - @Override - public String getDescription() { - return "Java and Java Dev Tools Tips"; - } - - /** - * Provides the opportunity to release all held resources. - */ - @Override - public void dispose() { - } -} - -</pre> - -<h1>The Implementation of a Tip</h1> -This is an example implementation of a Tip -<pre> -/** - * This is an example Tip class. - * - */ -public class Tip1 extends Tip { - - /** - * Tips should be created fast. - * - * @param pProvider - * the associated {@link TipProvider} - */ - public Tip1(TipProvider pProvider) { - super(pProvider); - } - - /** - * A getter for a {@link Runnable} action for this tip. Clients may override or - * call {@link #setAction(Runnable)}. - * - * @return the action or null if not set by {@link Tip#setAction(Runnable)}. - * @see Tip#setAction(Runnable) - */ - @Override - public Runnable getAction() { - return new Runnable() { - @Override - public void run() { - Display.getDefault().syncExec(new Runnable() { - @Override - public void run() { - MessageDialog.openConfirm(null, getSubject(), "We can start an action from a Tip!"); - } - }); - } - }; - } - - /** - * 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(getClass(), e); - } - return null; - } -} -</pre> - -<h1>Example of a TipImage</h1> -TipImage objects are UI agnostic representations of an Image. You may pass a URL to a TipImage or a full base64 string (e.g. "data:image/png;base64,iVBORw0KGgo.....CYII="). -<br> -One import aspect of the TipImage is it's aspect ratio. The Tip UI may use a browser to display it's UI. Therefore it can be scaled to the available space. Images look best when they use a 3:2 (1.5) ratio. -<br> -<h4>Set an image that is a square (aspect ratio = 1:1 (1)) -<pre> -TipImage img = new TipImage(bundle.getEntry("images/java/duke.png")).setAspectRatio(1) -</pre> - -<h4>Set an image that is a square (aspect ratio = 1:1 (1)) -<pre> - /** - * Sets the aspect ratio of this image. If the image is 300 wide and 600 high - * then the aspect ratio is 300/600 = 0,5 (1:2). If your image is 1200 wide and - * 250 high then the aspect ratio (1200/250) = 4,8. With the supplied values the - * best dimensions for the image can be calculated give the available space in - * the UI. - * <p> - * In case you pass true for <code>pSetAsMax</code> then the image can not be - * up-scaled beyond the specified size. So if your image is 200x200 and you want - * a maximum up-scale of 2 then pass 400x400 to this method to maintain the - * aspect ratio but allow the image to be resized to maximum it's double size. - * <p> - * The recommended aspect ratio is around 3:2 (1.5) to be comfortably displayed - * in the Tip UI. - ** - TipImage img = new TipImage("data:image/png;base64,3ff4..eFW"); - img.setAspectRatio(800, 400, true); // Image can not be scaled up higer than 800:400 -</pre> - +<ul> +<li> <a href="https://git.eclipse.org/c/platform/eclipse.platform.ua.git">Repository with example tips.</a></li> +<li> <a href="https://wiki.eclipse.org/Tip_of_the_Day">Eclipse Wiki</a></li> +</ul> </p> </documentation> </annotation> |