Not logged in : Login

About: VirtSPASQLRDFDemoImageText     Goto   Sponge   NotDistinct   Permalink

An Entity of Type : atom:Entry, within Data Space : ods.openlinksw.com associated with source document(s)

AttributesValues
type
Date Created
Date Modified
label
  • VirtSPASQLRDFDemoImageText
maker
Title
  • VirtSPASQLRDFDemoImageText
isDescribedUsing
has creator
attachment
  • http://vos.openlinksw.com/wiki/main/VOS/VirtSPASQLRDFDemoImageText/ImageWindow.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtSPASQLRDFDemoImageText/MoreButton.png
  • http://vos.openlinksw.com/wiki/main/VOS/VirtSPASQLRDFDemoImageText/NotesForm.png
content
  • ---+Extending RDFDemo to Display Images and Longer Text Fields This document will guide you through extending<nowiki> RDFDemo</nowiki> so that longer text fields can be displayed as a block of text and so that links to images and web pages can be viewed in a browser window. ---+++Pre-requisites 1. A working copy of the RDFDemo application created in [[VirtSPASQLRDFDemoModifyNorthwind][Modifying the Northwind Ontology to Add Labels]]. ---++Modifying the Application. ---+++Displaying Text We will modify the form that show the details of the selected item so that when the text in the boxes is too long to be seen in full a button will appear beside the box on the form and if you click the button the complete text will be displayed in a separate window. 1. Add a new class, <nowiki>MoreButton</nowiki> that extends System.Windows.Forms.Button. * In the <b>Solution Explorer</b> right click on the <nowiki>RDFDemo</nowiki> project and select <b>Add</b> then <b>New Item</b>. * Add a new class called <nowiki>MoreButton.cs</nowiki>. <br><img src="%ATTACHURLPATH%/MoreButton.png" style="wikiautogen"/> * The following using statement goes at the top of the file: <verbatim> using System.Windows.Forms; </verbatim> * The <nowiki>MoreButton</nowiki> class must inherit from System.Windows.Forms.Button so the class definition line should look like this <verbatim> class MoreButton : Button </verbatim> * Add the following code to the body of the <nowiki>MoreButton</nowiki> class: <verbatim> String longText; public MoreButton(String text) { longText = text; this.Text = "More"; } protected override void OnClick(EventArgs e) { Form moreForm = new Form(); TextBox moreBox = new TextBox(); moreBox.Text = longText; moreBox.Width = 300; moreBox.Height = 250; moreBox.ScrollBars = ScrollBars.Vertical; moreBox.Multiline = true; moreBox.WordWrap = true; moreBox.Select(0, 0); moreBox.ReadOnly = true; moreForm.Controls.Add(moreBox); moreForm.Width = 320; moreForm.Height = 280; moreForm.ShowDialog(); } </verbatim> 1. In <nowiki>displayData</nowiki> in the <nowiki>ExtendedStringHandler</nowiki> class, when the labels and <nowiki>TextBoxes</nowiki> are added to the form check if the text is too big for the box. If it is then add a <nowiki>MoreButton</nowiki> that will display all the text in a separate window. <verbatim> if (textBoxList[i].DataBindings[0].DataSource.ToString().Length > 80 &amp;&amp; !(textBoxList[i].DataBindings[0].DataSource is SqlExtendedString)) { moreButtonList.Add(new MoreButton(textBoxList[i].DataBindings[0].DataSource.ToString())); moreButtonList[moreButtonList.Count - 1].Location = new Point(550, i * 22 + 50); describeForm.Controls.Add(moreButtonList[moreButtonList.Count -1]); } </verbatim> 1. We will also need a list to hold the buttons as they are created so the following needs to be added to the member variables at the top of the <nowiki>ExtendedStringHandler</nowiki> class. <verbatim> List<MoreButton> moreButtonList = new List<MoreButton>(); </verbatim> 1. Build and run the application. If you click through to an Employee page you will see the Notes field now has a button labeled More next to it. If you click on that button the text from the Notes field is displayed in a new window. <br><img src="%ATTACHURLPATH%/NotesForm.png" style="wikiautogen"/> ---+++Displaying Images and Web Pages Next we will modify the form so that item identified as images or web pages will be opened in a browser window. Again we will do this by adding a button beside the box on the form that will open the browser window. 1. Add a new class, <nowiki>OpenButton</nowiki> that extends System.Windows.Forms.Button. * In the <b>Solution Explorer</b> right click on the <nowiki>RDFDemo</nowiki> project and select <b>Add</b> then <b>New Item</b> * Add a new class called <nowiki>OpenButton.cs.</nowiki> * The following using statement goes at the top of the file: <verbatim> using System.Windows.Forms; </verbatim> * The <nowiki>OpenButton</nowiki> class must inherit from System.Windows.Forms.Button so the class definition line should look like this <verbatim> class OpenButton : Button </verbatim> * Add the following code to the body of the <nowiki>OpenButton</nowiki> class: <verbatim> String urlText; public OpenButton(String text) { urlText = text; this.Text = "Open"; } protected override void OnClick(EventArgs e) { System.Diagnostics.Process.Start(urlText); } </verbatim> 1. In <nowiki>displayData</nowiki> in the <nowiki>ExtendedStringHandler</nowiki> class, where we added the code to check for long text fields we now need to check for IRIs that identify images and web pages. As a simple first attempt we will check for matching labels. So for example, if a property label is 'image' or 'webpage', we will assume it can be opened in a browser window and put an <nowiki>OpenButton</nowiki> beside it. <verbatim> if (labelList[i].Text == "website" || labelList[i].Text == "image" || labelList[i].Text == "depiction" || labelList[i].Text == "page" || labelList[i].Text == "url" || labelList[i].Text == "image skyline") { openButtonList.Add(new OpenButton(textBoxList[i].DataBindings[0].DataSource.ToString())); openButtonList[openButtonList.Count - 1].Location = new Point (550, i * 22 + 50); describeForm.Controls.Add(openButtonList[openButtonList.Count - 1]); } </verbatim> 1. We will also need a list to hold the buttons as they are created so the following needs to be added to the member variables at the top of the <nowiki>ExtendedStringHandler</nowiki> class. <verbatim> List<OpenButton> openButtonList = new List<OpenButton>(); </verbatim> 1. Build and run the application. If you click through to an Employee page now you will see that the Image field now has a button labeled Open next to it. If you click on that button the image is opened in your default browser. <br><img src="%ATTACHURLPATH%/ImageWindow.png" style="wikiautogen"/> ---++ Next Steps It has already been mentioned that the property labels are also dereferenceable [[http://docs.openlinksw.com/virtuoso/rdfdatarepresentation.html#rdfiriidtype][IRIs]]. We used this feature to find a short name to display rather that the complete [[http://docs.openlinksw.com/virtuoso/rdfdatarepresentation.html#rdfiriidtype][IRI]]. The next step is to make the labels clickable so the ontology itself can also be explored. [[VirtSPASQLRDFDemoClickableLabels][Extending RDFDemo To Make The Property Labels Clickable]]
id
  • 4c7cecdc1afdf40a09805e1ec2756da7
link
has container
http://rdfs.org/si...ices#has_services
atom:title
  • VirtSPASQLRDFDemoImageText
links to
atom:source
atom:author
atom:published
  • 2017-06-13T05:49:15Z
atom:updated
  • 2017-06-13T05:49:15Z
topic
is made of
is container of of
is link of
is http://rdfs.org/si...vices#services_of of
is creator of of
is atom:entry of
is atom:contains of
Faceted Search & Find service v1.17_git132 as of May 12 2023


Alternative Linked Data Documents: iSPARQL | ODE     Content Formats:   [cxml] [csv]     RDF   [text] [turtle] [ld+json] [rdf+json] [rdf+xml]     ODATA   [atom+xml] [odata+json]     Microdata   [microdata+json] [html]    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3332 as of Sep 11 2024, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (15 GB total memory, 2 GB memory in use)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software