Skip to main content
Jump to: navigation, search

Difference between revisions of "Tip of the Day/Extending/JSonTipProvider"

(Created page with "== JSon Tip Provider == A JSon Tip provider requires a JSon file with information. The TipProvider implementation can be very simple. An accompanying JSon file is dynamically...")
 
(JSon Schema)
Line 9: Line 9:
  
 
==JSon Schema==
 
==JSon Schema==
Tips can be retrieved from the Eclipse Wiki. The TipProvider may read tip URLs from a page and create Tip objects from a link. Examples in the framework provide tips from the following page:
+
{
 +
  "$id": "http://example.com/example.json",
 +
  "type": "object",
 +
  "properties": {
 +
    "provider": {
 +
      "$id": "/properties/provider",
 +
      "type": "object",
 +
      "properties": {
 +
        "image": {
 +
          "$id": "/properties/provider/properties/image",
 +
          "type": "string",
 +
          "title": "The Image Schema ",
 +
          "description": "ssss",
 +
          "default": "",
 +
          "examples": [
 +
            "data:image/png;base64,iV..C"
 +
          ]
 +
        },
 +
        "description": {
 +
          "$id": "/properties/provider/properties/description",
 +
          "type": "string",
 +
          "title": "The Description Schema ",
 +
          "description": "sss",
 +
          "default": "",
 +
          "examples": [
 +
            "JSon Tip Provider"
 +
          ]
 +
        },
 +
        "expression": {
 +
          "$id": "/properties/provider/properties/expression",
 +
          "type": "string",
 +
          "title": "The Expression Schema ",
 +
          "default": "",
 +
          "examples": [
 +
            "<with variable=\"activeWorkbenchWindow.activePerspective\"><equals value=\"org.eclipse.jdt.ui.JavaPerspective\"></equals></with>"
 +
          ]
 +
        },
 +
        "variables": {
 +
          "$id": "/properties/provider/properties/variables",
 +
          "type": "object",
 +
          "properties": {
 +
            "foo": {
 +
              "$id": "/properties/provider/properties/variables/properties/foo",
 +
              "type": "string",
 +
              "title": "The Foo Schema ",
 +
              "default": "",
 +
              "examples": [
 +
                "Example of substitution variable inside your url or html: ${tip.foo}"
 +
              ]
 +
            },
 +
            "bar": {
 +
              "$id": "/properties/provider/properties/variables/properties/bar",
 +
              "type": "string",
 +
              "title": "The Bar Schema ",
 +
              "default": "",
 +
              "examples": [
 +
                "Example of substitution variable inside your url or html: ${tip.bar}"
 +
              ]
 +
            }
 +
          }
 +
        },
 +
        "tips": {
 +
          "$id": "/properties/provider/properties/tips",
 +
          "type": "array",
 +
          "items": {
 +
            "$id": "/properties/provider/properties/tips/items",
 +
            "type": "object",
 +
            "properties": {
 +
              "subject": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/subject",
 +
                "type": "string",
 +
                "title": "The Subject Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "Embedded Full Screen YouTube video"
 +
                ]
 +
              },
 +
              "date": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/date",
 +
                "type": "string",
 +
                "title": "The Date Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "2018-02-12"
 +
                ]
 +
              },
 +
              "image": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/image",
 +
                "type": "string",
 +
                "title": "The Image Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "data:image/png;base64,iV..C"
 +
                ]
 +
              },
 +
              "ratio": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/ratio",
 +
                "type": "number",
 +
                "title": "The Ratio Schema ",
 +
                "default": 0,
 +
                "examples": [
 +
                  1.350000023841858
 +
                ]
 +
              },
 +
              "maxWidth": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/maxWidth",
 +
                "type": "integer",
 +
                "title": "The Maxwidth Schema ",
 +
                "default": 0,
 +
                "examples": [
 +
                  500
 +
                ]
 +
              },
 +
              "maxHeight": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/maxHeight",
 +
                "type": "integer",
 +
                "title": "The Maxheight Schema ",
 +
                "default": 0,
 +
                "examples": [
 +
                  300
 +
                ]
 +
              },
 +
              "actionId": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/actionId",
 +
                "type": "string",
 +
                "title": "The Actionid Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "preferences"
 +
                ]
 +
              },
 +
              "html": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/html",
 +
                "type": "string",
 +
                "title": "The Html Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "<h2>title<h2><p>html text</p>"
 +
                ]
 +
              },
 +
              "url": {
 +
                "$id": "/properties/provider/properties/tips/items/properties/url",
 +
                "type": "string",
 +
                "title": "The Url Schema ",
 +
                "default": "",
 +
                "examples": [
 +
                  "http://some.com/tip.html"
 +
                ]
 +
              }
 +
            },
 +
            "required": [
 +
              "subject",
 +
              "html",
 +
              "url"
 +
            ]
 +
          }
 +
        }
 +
      },
 +
      "required": [
 +
        "description",
 +
        "tips"
 +
      ]
 +
    }
 +
  }
 +
}

Revision as of 11:46, 8 May 2018

JSon Tip Provider

A JSon Tip provider requires a JSon file with information. The TipProvider implementation can be very simple. An accompanying JSon file is dynamically fetched from the internet or it is statically included with your bundle.

In case you pull it from the internet, make sure that you do not waste bandwidth by pulling a file that you already have (use the HTTP HEAD function).

Examples

JSon Schema

{
  "$id": "http://example.com/example.json",
  "type": "object",
  "properties": {
    "provider": {
      "$id": "/properties/provider",
      "type": "object",
      "properties": {
        "image": {
          "$id": "/properties/provider/properties/image",
          "type": "string",
          "title": "The Image Schema ",
          "description": "ssss",
          "default": "",
          "examples": [
            "data:image/png;base64,iV..C"
          ]
        },
        "description": {
          "$id": "/properties/provider/properties/description",
          "type": "string",
          "title": "The Description Schema ",
          "description": "sss",
          "default": "",
          "examples": [
            "JSon Tip Provider"
          ]
        },
        "expression": {
          "$id": "/properties/provider/properties/expression",
          "type": "string",
          "title": "The Expression Schema ",
          "default": "",
          "examples": [
            "<with variable=\"activeWorkbenchWindow.activePerspective\"><equals value=\"org.eclipse.jdt.ui.JavaPerspective\"></equals></with>"
          ]
        },
        "variables": {
          "$id": "/properties/provider/properties/variables",
          "type": "object",
          "properties": {
            "foo": {
              "$id": "/properties/provider/properties/variables/properties/foo",
              "type": "string",
              "title": "The Foo Schema ",
              "default": "",
              "examples": [
                "Example of substitution variable inside your url or html: ${tip.foo}"
              ]
            },
            "bar": {
              "$id": "/properties/provider/properties/variables/properties/bar",
              "type": "string",
              "title": "The Bar Schema ",
              "default": "",
              "examples": [
                "Example of substitution variable inside your url or html: ${tip.bar}"
              ]
            }
          }
        },
        "tips": {
          "$id": "/properties/provider/properties/tips",
          "type": "array",
          "items": {
            "$id": "/properties/provider/properties/tips/items",
            "type": "object",
            "properties": {
              "subject": {
                "$id": "/properties/provider/properties/tips/items/properties/subject",
                "type": "string",
                "title": "The Subject Schema ",
                "default": "",
                "examples": [
                  "Embedded Full Screen YouTube video"
                ]
              },
              "date": {
                "$id": "/properties/provider/properties/tips/items/properties/date",
                "type": "string",
                "title": "The Date Schema ",
                "default": "",
                "examples": [
                  "2018-02-12"
                ]
              },
              "image": {
                "$id": "/properties/provider/properties/tips/items/properties/image",
                "type": "string",
                "title": "The Image Schema ",
                "default": "",
                "examples": [
                  "data:image/png;base64,iV..C"
                ]
              },
              "ratio": {
                "$id": "/properties/provider/properties/tips/items/properties/ratio",
                "type": "number",
                "title": "The Ratio Schema ",
                "default": 0,
                "examples": [
                  1.350000023841858
                ]
              },
              "maxWidth": {
                "$id": "/properties/provider/properties/tips/items/properties/maxWidth",
                "type": "integer",
                "title": "The Maxwidth Schema ",
                "default": 0,
                "examples": [
                  500
                ]
              },
              "maxHeight": {
                "$id": "/properties/provider/properties/tips/items/properties/maxHeight",
                "type": "integer",
                "title": "The Maxheight Schema ",
                "default": 0,
                "examples": [
                  300
                ]
              },
              "actionId": {
                "$id": "/properties/provider/properties/tips/items/properties/actionId",
                "type": "string",
                "title": "The Actionid Schema ",
                "default": "",
                "examples": [
                  "preferences"
                ]
              },
              "html": {
                "$id": "/properties/provider/properties/tips/items/properties/html",
                "type": "string",
                "title": "The Html Schema ",
                "default": "",
                "examples": [
"

title<h2>

html text

"
                ]
              },
              "url": {
                "$id": "/properties/provider/properties/tips/items/properties/url",
                "type": "string",
                "title": "The Url Schema ",
                "default": "",
                "examples": [
                  "http://some.com/tip.html"
                ]
              }
            },
            "required": [
              "subject",
              "html",
              "url"
            ]
          }
        }
      },
      "required": [
        "description",
        "tips"
      ]
    }
  }
}

Back to the top