In a Dolphin smalltalk treeview I'd like to use a custom icon, depending on the state of the item displayed, (differente state, different icon)
How can I do that ?
I cannot really understand how to use a "my" icon.
I've create a class "connection", with an instance variable "connected"
and two class methods "connectedIcon and unconnectedIcon that returns icon images.
Then an instance function "icon" that returns one or the other image based on the connection state.
I can add instances of this class to a tree view and see the name of the connections.
But how to show my Icons ?
I tried to sustitute the getImageBlock of my presenter view with the following expression [:obj | obj icon] but it doesn't work.
(nothing seems to happen).
this is made in my presenter initialize :
initialize
super initialize.
treePresenter view getImageBlock: [:obj | obj icon]
what's wrong with it ?
best regards
Maurizio
When you are editing a TreeView, one of the properties is getImageBlock. By default it is not really a block but another object that understands the message #'value:' (the class IconicListAbstract). You can replace this property with a code block (or other object that understands #'value:') and answer the image you want displayed.
In Microsoft Windows, icons are typically stored in a DLL. You should be able to use an icon explorer or editing tool to see the icons in a dll. For example, get IconExplorer from http://www.mitec.cz/iconex.html and try opening DolphinDR7.dll. Do the icons and numbers match what you see when you return a number in your application?
To determine (or override) the resource library used, see SessionManager>>#'defaultResLibPath'.
Typically, the getImageBlock is set using the property editor in the GUI editor, but setting it through code can work as well.
Wonderful Dolphin Smalltalk!
I had two problems
1) how and where to modify the getImageBlock method of my Treepresenter.
2) where to put the icons ad how to get the imageindex of each icon.
This is the solution :
1) it's not needed.
The treeview sends an #iconImageIndex" message to my model
this is handled by the default method (in the Object class) that send to my object the message #icon
and to the result of this message (an icon) the message #iconIndex.
This message is understood from the icon that answers with its own iconIndex.
So the only method I need to impement is #icon in my class Connection
that I implemented as follows:
icon
opened ifTrue: [^Connection connectedIcon] ifFalse: [^Connection unconnectedIcon]
In the class itself the two icons are imported in the image by evaluating the createIconMethod,
as explained in the blog article 'Beauty with less Beast'.
So my problems are solved.
Thanks to all.
Maurizio.
Related
I can not access an object in my testcase.
The object is a Tab, attached to a (Sub)Window in my application.
Befor and after the Testcase the Tab and the window the tab is attached to is found by the object spy fine, but while the testcase runs the Error below comes up .
Cannot find the "[ActiveX]" object's parent "[Window]" (class Window). Verify that parent properties match an object currently displayed in your application.
I access the object so :
VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab")
I am new to UFT, so I searched a while and found some solutions but they seem not to work for me, because they always related to browser testing, not application.
Warning: Long explanation follows, you can skip to the last paragraph for a suggested quick win.
When UFT identifies objects it does so from the top down, your object hierarchy is:
VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab")
And UFT said that:
Cannot find the "[ActiveX]" object's parent "[Window]" (class Window).
This means that id did find VbWindow("ApplicationWindow") but could not find the Window("SubWindow"). Try highlighting the VbWindow to make sure that UFT is identifying the object you expect. Then use the object spy to inspect the window you think UFT should find. Then compare the properties in the object repository to those of the window you see and find how these descriptions differ.
As a shortcut you can try using Maintenance Run Mode which should do these steps for you and suggest a way to fix the test.
Just a thought to identify the root cause of the problem.
1.Try with the top level container(skipping the next level container) and check your existence of parent.
VbWindow("ApplicationWindow").ActiveX("Tab")
2.Check the properties before and after. I meant side by side validation. There could be the chance of property mismatch.
3.Use Refresh Object method.
Window("Calculator").RefreshObject
4.Query your parent from the Tab object
Set objParent = VbWindow("ApplicationWindow").ActiveX("Tab").GetTOProperty("parent")
Msgbox objParent.GetROProperty("text")
Set objParent = VbWindow("ApplicationWindow").Window("SubWindow").ActiveX("Tab").GetTOProperty("parent")
Msgbox objParent.GetROProperty("text")
i'm facing one problem about attaching movieclip from loaded movie, so basically we have a Map
Map.loadMovie("SimpleMap.swf");
in this map there's a npc dialogue with its name "Dialogue1" I want to attach it to the client. It should be basically something like
_root.attachMovie("Map.Dialogue1", "dialogue", _root.getNextHighestDepth());
but it seems I can't get it to work. Anyone can help?
Note: Also I want to attach the movieclip to the client instead of the map, else I would use Map.attachMovie
it's been a while since I wrote any Actionscript 2 stuff, but have you tried removing the quotes around Map.Dialogue1 ? - If I remember correctly passing a string would make Flash look for the symbol in the library, not from the global or current scope...
_root.attachMovie(Map.Dialogue1, "dialogue", _root.getNextHighestDepth());
If you want you can import mx.core.UIObject and then use the method _root.createObject() (or if it is O-O use createClassObject()).
It is going to attach the "npc dialog" as an object... you need to specify the linkage name and give the instance a name. So for example if you called the dialog "npc_dialog" in the library then use:
_root.createObject("npc_dialog", "my_npc", _root.getNextHighestDepth());
Here is something else you can try... go to the library and drag a instance of the movie onto the stage somewhere where it will not be seen, like for instance on the next key frame or off the stage then try to run attachMovie().
What happens is flash will compile the clip in the most efficient way possible so if it sees you imported a package but did not use it then it will ignore this class in the compiled clip... so when you go to run and it tries to attach the movie it can't find it.
While executing my script in RFT, my script got failed due to the slight position change of a button. (This button's position slightly changes according to the option selected for previous combo box due to the label appearing near the button)
As there are 2 positions for this button in window, one of my script fails while other passes.
Please suggest how to identify this same object in 2 different places in RFT?
If you're alright with not using pre-mapped values and instead work with objects directly in code (which I've personally found to be extremely useful... it's allowed me to do great and wondrous things with RFT :), the following ought to work fine:
private void clickObject(String uniqueIdentifier) {
// Find object
RootTestObject root = RootTestObject.getRootTestObject();
TestObject[] matchingObjs = root.find(atProperty(".id", uniqueIdentifier));
if (matchingObjs.length > 0) {
// Click the object
((GuiTestObject) matchingObjs[0]).click();
}
// Clean-up
unregister(matchingObjs);
}
Feel free to replace ".id" with whatever property is best suited for the situation... since I work primarily with a web application, the ".id" property has worked splendidly for me.
Because the method finds the object anew each time, it'll grab the object's position wherever it's at at the time the method's called. The clean-up will also prevent any weird, horrible, and otherwise unfortunate UnregisteredObjectExceptions from cropping up.
Without looking at your pages I cannot be sure, but I think the buttons are actually two different buttons. Maybe they are generated by javascript, or they are just un-hidden after the option you select in the combobox.
If they are two different buttons (record them both and look at the recognition properties) you can either replace some properties with a regular expression or check wich button is visible/exists and then click it:
if (btn_button1.exists()) {
btn_button1.click();
} else if (btn_button2.exists()) {
btn_button1.click();
}
Here's a more complete tutorial on Object Recognition.
You can increase the tolerance of Rational Performance Tester AssureScript in the properties tab or you could set the description but hide the value. You can also make a custom code that updates the object map to prepare for this change in a java IF structure
Let's say I want to see how "copy" is implemented in the Dictionary class. Currently I use the system browser and manually traverse the inheritance hierarchy (bottom up) until I find the class that implements the given message. Is there a one-liner for the workspace, that would open the system browser at the right location?
( SomeClass whichClassIncludesSelector: #initialize ) browse
That will browse the class that implements the message #initialize.
Personally, I just type the #selector in a workspace, highlight it, and hit alt+m to pull up all implementors of the message. Much faster than typing all that code.
(SomeClass>>#someSelector) browse
works as well in my Pharo image.
works as well in my Pharo image.
And since you want to find a class first, you can combine it with previous example..
((SomeSubclass whichClassIncludesSelector: #someSelector)>>#someSelector) browse
to directly go to given method.
If you are using OmniBrowser, you can use the contextual menu Implementors in Hierarchy... to only browse the implementors of a selector in the hierarchy of the Dictionary.
OmniBrowser also provides an Inheritance Browser. Select any implementation of #copy and click on the Inheritance button in the toolbar. It will show you a hierarchical view of all implementors of #copy.
I'm familiar with the VisualWorks and Dolphin versions of Smalltalk, but have not previously used Squeak. I'm just familiarising myself with Pharo, which is a 'cleaned up' fork of Squeak.
I'm used to having the facility in the Class Browser to show either only the methods implemented by a class or both the methods inherited and the methods implemented.
Is this useful facility missing in Squeak, or have I just been unable to find it?
You can double-click on any class to open a Hierarchy Browser on that particular class. The hierarchy button in the toolbar and the menu entry browse hierarchy (Ctrl+H) open the same view.
There is the Inheritance Browser that shows you the hierarchal implementations of the currently selected method. Click on the inheritance button in the toolbar.
Furthermore there is the Protocol Browser that displays all methods and super methods of a class together. To open this browser select browse protocol (Ctrl+Shift+P) in the context menu of the class.
If you want to build a browser with that behaviour, you should take a look at the Glamour browser construction DSL.
I personally do not feel the need to see all 34 pages of method names defined in ProtoObject and Object, or the 5 pages of method categories. Object methods size prints 421.
AFAIK in the GemStoneTool there is such a thing, thre is a 1 or so and a # which seems to change the view to see all the methods available in a class (be it inherited or in the class itself) I'm as amazed as you that nothing like that exists in "standard images". Maybe the users know the libraries for ages, and maybe they remember enough to not bother. ....