Premise Extending the Document Class

  • Thread starter Thread starter chucklyons
  • Start date Start date
Motorola Premise
C

chucklyons

Guest
I created a new topic, although it is really in my quest to make the iPhone module less tedious to install.

What I want to do:

Currently, I have extended TagEx and TagFolderEx in RoomList to give a user the ability to use different images vs the defined class images. works, but requires the user to manually insert the image of their choice. Prob for most installations, and for the iphone, not a bad method.

What I would like to do is create a second class image for each class. Seems relatively simple. So I thought I could create a second image for each selectorfolder via adding a second image to SelectionMenuFolder in TaskList/Classes/SelectionMenuFolder. However, to do so, I should be able to add a second linked image, which would(?) require extending the document class to add a second image ('image2'). No luck.

Anyone have any ideas on how to either do what I am trying to do, or a more elegant solution than manual inserting each image (ie , I'll do it one time and everyone else won't have to do it)
 
Correct me if I'm wrong but you're trying to provide alternate classimages for the iPhone UI. Your strategy is to augment each Location object with an alternate image. The end-user can select the alternate image to be used for the iPhone UI.

Here's an alternate solution. This strategy doesn't alter any classes, doesn't require any special installation trickery, and does not require the end-user to visit each object and specify an alternate image.
  1. Copy all existing classimages to a new sub-folder: ...\Premise\SYS\web\Classimages\iPhone.
  2. In the iPhone sub-folder, modify or replace the classimages to suit the needs of an iPhone. Just don't rename anything.
  3. Modify XBrowser so that whenever it is called by an iPhone, it pulls classimages from the iPhone sub-folder.
Step 3 is a bit tricky because you need to create a new WebRedirect called "iPhone". This is precisely what XBrowser does ("xb"). You'd call the iPhone-specific version of Xbrowser using http: //PremiseServer/iPhone. Xbrowser's code needs to be enhanced so that it detects how it was called ... if via the iPhone WebRedirect, then it grabs classimages from the iPhone sub-folder.

I just looked at how AutomationBrowser and XBrowser render an object's image. The HTML command looks like this:
<IMG class="ImageButton" SRC="/sys/{DC7BFD1E-1950-4534-ACB7-EBCDE613E2D3}!Image">
The IMG's SRC takes the following form: /sys/{ObjectID}!Image where ObjectID is the object's GUID.

The exclamation point followed by the word Image appears to be a method that is understood by Premise's web engine. This method gets the object's class name and returns the image file that represents that class. For example, if the object whose GUID is "DC7BFD1E-1950-4534-ACB7-EBCDE613E2D3" is in fact a Porch class, then its !Image method will return "\\PremiseServer\Images\ClassImages\Porch.gif". You can prove this to yourself very easily. Using Internet Explorer, right-click an object in XBrowser's UI and select Properties. Copy the URL from the Properties dialog box. Paste the URL in the browser's address box and press enter. Presto! The browser will display the object's image and the address bar will contain the image's file path.

In the XBrowser module, the xbRender method of the xbLocationEx class generates the HTML code for an object. I think you can replace this:
Code:
		if not imgProp is nothing then
			img = obj.Image
			if img <> "" then
				Output = Output & "<IMG class=""ImageButton"" "
				Output = Output & "WIDTH=45 HEIGHT=45 SRC=""" & obj.objectID & "!Image"">"
			else
				Output = Output & "<IMG class=""ImageButton"" "
				Output = Output & "SRC=""/sys/" & Image.objectID & "!Image"">"
			end if
		else
			Output = Output & "<IMG class=""ImageButton"" "
			Output = Output & "SRC=""/sys/" & Image.objectID & "!Image"">"
		end if
with this:
Code:
		if not imgProp is nothing then
				Output = Output & "<IMG class=""ImageButton"" "
				Output = Output & "SRC=""/Images/ClassImages/iPhone/" & Image.Class.Name & ".gif"">"
		end if

Actually, 'replace' is not the right word. The code needs to run only for iPhones so you need to put in the "iPhone-aware" logic somewhere.
 
I'll give that a try...I have the separate iphone class directory (with iPhone class images in both iphone flat and glossy), the iphone web redirect, and the iPhone aware logic...but couldn't get over the last hill....I'm sure your tip will work, that section of code is where I have been going nutz....thanks!
 
Nope. See attached - it seems to be somewhat right, but serves up only one image 'Image.gif'. I renamed a gif in the /images/classimages/iphone/ directory to 'image.gif' and it populated each of the three gifs on the ppc web page with the 'image.gif' i had just created.

So the directory is rightt; it must be something with the image.class.name...ideas?
 

Attachments

  • iphone.png
    iphone.png
    13.5 KB · Views: 22
  • iphone2.png
    iphone2.png
    72.3 KB · Views: 28
I've reviewed xbLocationEx's xbRenderPage method and I can't understand all the hocus pocus surrounding the "Image" object. They use a method called "sys.GetObjectsFromSelectors" that is not documented in Premise Help and the IDE's Intellisense doesn't explain its arguments. Bah!

However, I do know that in xbRenderPage, "obj" represents the current Location object so "obj.class.name" should work:
Code:
			Output = Output & "SRC=""/images/classimages/iphone" & obj.class.name & ".gif"">"

I tested it (see the attached image) without the iPhone sub-folder and it works correctly ... except for several classes like MediaZone, Garage, and others. Double bah! Garage's class name is "AttachedGarage" whereas its image file is called "Garage" ... so obj.class.name won't retrieve the correct image-file name. The MediaZone class uses an image file called MediaRoom. I thought that each image file's name simply had to match the class's name but apparently this is not the case.

I'll have to decipher what GetObjectsFromSelectors does in order to understand how it is used to retrieve the correct image file for each class.
 

Attachments

  • xbLocationEx___xbRenderPage.png
    xbLocationEx___xbRenderPage.png
    52 KB · Views: 25
I think I got it.

GetObjectsFromSelectors extracts all Selectors for a given object's class. So if the object is an "AttachedGarage", its Selector has an associated Image whose path is to the Garage.gif file (see attached image). In xbLocationEx's xbRenderPage method, "Image.Image" will return a string that points to the image file's location.

Image.Image is the full file path and we only need the file name so we have to do some string parsing to get what we want. This works correctly:
Code:
				ImageFile = mid(Image.Image, instrrev(Image.Image, "\")+1)
				Output = Output & "SRC=""/images/classimages/" & ImageFile & """>"
For your purposes, use "/images/classimages/iphone/".
 

Attachments

  • Selectors.png
    Selectors.png
    22 KB · Views: 17
  • xbLocationEx___xbRenderPage.png
    xbLocationEx___xbRenderPage.png
    54.4 KB · Views: 20
:)

We're not worthy; we're not worthy!

I'll give it a try and report back - which means I need another week!
 
Back
Top