Rehosting Workflow 4 Designer adding foreach activity to toolbox - .net-4.0

I am using the designer rehosting samples and am trying to put the generic types into the toolbox, however I can't seem to make it work.
I've tried XAML based:
<sapt:ToolboxItemWrapper AssemblyName="{StaticResource AssemblyName}">
<sapt:ToolboxItemWrapper.ToolName>
System.Activities.Statements.ForEach
</sapt:ToolboxItemWrapper.ToolName>
</sapt:ToolboxItemWrapper>
and code based:
Type t = Type.GetType("System.Activities.Statements.Foreach, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
ToolboxItemWrapper w = new ToolboxItemWrapper(t);
category.Add(w);
however neither of them seem to work. Any suggestions?

You are leaving out what isn't working but I assume you can't add a child activity to the ForEach in the designer.
If that is the case that is because the Body property is an ActivityAction not an Activity and it needs to be initialized. There are several ways of doing this but the easiest is to get started with the ForEachWithBodyFactory in the designer and drag that onto the design surface instead.
The following code works for me. I can drag the ForEach onto a workflow and add child items to it.
var cat = new ToolboxCategory("Standard Activities");
cat.Add(new ToolboxItemWrapper(typeof(ForEachWithBodyFactory<>)));

Related

Can we set the element ID for component created in the code like the ID in application model (e4xmi)?

I created a RCP app with a part. In the part, I created a TreeViewer. Can I set an ID for this viewer so that others plugins can find this viewer by ID? How can we acquire this?
No, you can't do this.
The contents of a part are not in the application model and can't have model ids.
You have to use the findPart method of EPartService to find the part and then call some method that you write in the part object to get the viewer.
MPart part = partService.findPart("part id");
MyPartClass myclass = (MyPartClass)part.getObject();
TreeViewer viewer = myclass.getViewer();

QTP - Checking dynamic pages

I'm trying to check if a value is contained in the innertext of a webelement but I'm having a little problem: frames seem to change at every refresh of the pages.
These are the steps I've recorded:
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebEdit("pdrBean.pdrPod").Set parameter("POD")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_appl").WebButton("Cerca").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_2").Image("show_files").Click
Browser("SystemPage").Page("SystemP").Frame("dme2_appl_6").Image("Lente").Click
cctype = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down").GetROProperty("innertext")<br>
DataAct = Browser("SystemPage").Page("SystemP").Frame("dme2_appl_7").WebElement("arrow_down_2").GetROProperty("innertext")<br>
Browser("SystemPage").Page("SystemP").Frame("dme2_header").Image("Gestione Anagrafiche").Click
The frames "dme2_appl6" and "dme2_appl7" changes at every refresh of the two pages.
The question is simple: how can I rewrite these two actions to make them universal?
I've tried to do something like:
Set objFrame = Frame("title:=dme2_appl_.")
and then
Browser("SystemPage").Page("SystemP").objFrame.Image("Lente").Click
But QTP gives me an error in return: "property or method not supported by the object"
Please try using the below code
Browser("SystemPage").Page("SystemP").Image("Lente").Click
Avoid using the "Frame" and if you really want to use it, put regex for name property of Frame.
Go to Object Properties--> Click on the Frame object --> Mandatory Properties--> Change name property as
like iFrame_213123123 to i.*
Hope this will solve your problem.
I don't think you can use a frame object that way. When you write Page().Frame() UFT sets the frame's parent in different way than if you first create the Frame.
Think of Frame() as a function that behaves differently when called on a Page or as a free function.
Try:
Browser("SystemPage").Page("SystemP").Frame("title:=dme2_appl_.")

netbeans rcp adding to topcomponent at runtime

I am working on a netbeans RCP desktop application and have a need to add components dynamically. For example, I have a button which if I click on the menu should add components to the window at runtime. I have an actionlistener for the button and I added the following code in the action performed, but am not seeing the new component added. Any help is appreciated.
TopComponent editorTopComponent = WindowManager.getDefault().findTopComponent("componentId");
editorTopComponent.add(new JButton("TEST"));
editorTopComponent.validate();
editorTopComponent.repaint();
editorTopComponent.updateUI();
Thanks
If you want create now instance (more then one), then you can use :
MyTopComponent my = new MyTopComponent();
my.open();
my.requestActive();
if you want open TC in one instance (only), then you can use:
TopComponent editor= WindowManager.getDefault().findTopComponent("componentId");
if(editor!=null){
JPanel x =editor.getMyPanel();
x.setVisible(false);
//some changes
x.setVisible(true);
if(!editor.isOpened())editor.open();
}
Jirka

Dojo dnd (drag and drop) 1.7.2 - How to maintain a separate (non-dojo-dnd) list?

I'm using Dojo dnd version 1.7.2 and it's generally working really well. I'm happy.
My app maintains many arrays of items, and as the user drags and drops items around, I need to ensure that my arrays are updated to reflect the contents the user is seeing.
In order to accomplish this, I think I need to run some code around the time of Source.onDndDrop
If I use dojo.connect to set up a handler on my Source for onDndDrop or onDrop, my code seems to get called too late. That is, the source that's passed to the handler doesn't actually have the item in it any more.
This is a problem because I want to call source.getItem(nodes[0].id) to get at the actual data that's being dragged around so I can find it in my arrays and update those arrays to reflect the change the user is making.
Perhaps I'm going about this wrong; and there's a better way?
Ok, I found a good way to do this. A hint was found in this answer to a different question:
https://stackoverflow.com/a/1635554/573110
My successful sequence of calls is basically:
var source = new dojo.dnd.Source( element, creationParams );
var dropHandler = function(source,nodes,copy){
var o = source.getItem(nodes[0].id); // 0 is cool here because singular:true.
// party on o.data ...
this.oldDrop(source,nodes,copy);
}
source.oldDrop = source.onDrop;
source.onDrop = dropHandler;
This ensures that the new implementation of onDrop (dropHandler) is called right before the previously installed one.
Kind'a shooting a blank i guess, there are a few different implementations of the dndSource. But there are a some things one needs to know about the events / checkfunctions that are called during the mouseover / dnddrop.
One approach would be to setup checkAcceptance(source, nodes) for any target you may have. Then keep a reference of the nodes currently dragged. Gets tricky though, with multiple containers that has dynamic contents.
Setup your Source, whilst overriding the checkAcceptance and use a known, (perhaps global) variable to keep track.
var lastReference = null;
var target = dojo.dnd.Source(node, {
checkAcceptance(source, nodes) : function() {
// this is called when 'nodes' are attempted dropped - on mouseover
lastReference = source.getItem(nodes[0].id)
// returning boolean here will either green-light or deny your drop
// use fallback (default) behavior like so:
return this.inhertied(arguments);
}
});
Best approach might just be like this - you get both target and source plus nodes at hand, however you need to find out which is the right stack to look for the node in. I believe it is published at same time as the event (onDrop) youre allready using:
dojo.subscribe("/dnd/drop", function(source, nodes, copy, target) {
// figure out your source container id and target dropzone id
// do stuff with nodes
var itemId = nodes[0].id
}
Available mechanics/topics through dojo.subscribe and events are listed here
http://dojotoolkit.org/reference-guide/1.7/dojo/dnd.html#manager

Semantic zoom grouped collection

IN my metro application i want to create a semantic view for the page.
For that i am manually creating a grouped collection object using foreach loop. I am not using LINQ to group the object collection because of some reason .
SO now when i try to populate semantic zoom it displays nothing(no semantic zoom).
How can i bind my own collection to grouped collection source
XAML
<CollectionViewSource x:Name="GroupedSource" IsSourceGrouped="true" />
Code behind file
GroupedSource.Source =context.Collection; // my own grouped collection..
When using LINQ it working fine.But i cant use lINQ because of some reasons
Is there anything else i need to do to get
Try using this code to set the source:
(semanticZoom.ZoomedOutView as ListViewBase).ItemsSource = GroupedSource.View.CollectionGroups;
Need a bit more detail, but. The IsSourceGrouped="true" is only half of the story unless you bind to a hierrachal datasource. You need to specify the property that contains the child collection - ItemsPath="myItems" as an xaml property of the CollectionViewSource. If that is not the issue it may be a case of precidence of execution. put a break point and check context.Collection is populated before it is used, if context.Collection is an ObservableCollection you should be able to populate at anytime (ie. async fill).
<CollectionViewSource x:Name="GroupedSource" IsSourceGrouped="true" ItemsPath="Items" />