Cannot access UICollectionView element - xcode7

Trying to automate some UI tests with Xcode 7.2 and the XCT UI FW.
View hierarchy is as follows:
SearchViewController
UIView
UITableView
CustomCell:UITableViewCell
UIView
UILabel
UICollectionView
CustomCell:UICollectionViewCell
UILabel
UIImageView
CustomCell:UITableViewCell
.
.
My problem is that I cannot access anything within the UICollectionView, nor can I actually access the UICollectionView itself (or verify that it exists).
Here some lldb cmds and output:
po app.tables.cells.count 3
As expected since I three of CustomCell:UITableViewCell
po app.tables.cells.elementBoundByIndex(0).staticTexts.count 1
Returning 1 for the UILabel within the first CustomCell:UITableViewCell. But should it not also include the UILabel further down the tree, inside the UICollectionViewCells since the .elementType notation is short for descendantsMatchingType(.elementType)?
po app.tables.collectionViews.count 0
po app.tables.cells.collectionViews.element.exists false
As you can see I cannot access the UICollectionView. When building and testing the app there are 8 UICollectionViewCells within each UITableViewCell and I have set the the Accessibility checkbox to enabled in Xcode.
What am I missing here?

I was able to identify cells within collection views in this fashion. Just replace 'sampletext' with any static text that uniquely identifies that cell.
let predicate = NSPredicate(format: "label BEGINSWITH 'sampletext'")
let cell = XCUIApplication().collectionViews.cells.element(matching: predicate)

Related

Need to get the 2sxc Field Type from an Entity

After getting everything working on this previous question Is there a way to Clone one or many Entities (records) in Code, I wanted to clean it up and make it more useful/reusable. So far, I am deciding how to copy/add the field using the content-type field names, so attribute.Key inside the foreach on Attributes. What I need instead is to know the Entity field's Type; meaning String, Number, Hyperlink, Entity, etc.
So I want something like if(AsEntity(original).FieldType == "HyperLink") { do this stuff }. I have explored the API docs but have not spotted how to get to the info. Is it possible?
I did figure out that the attribute.Value has a Type that I could use to answer most of them, but Hyperlink and String are both showing, System.String.
Here are, in order, String, Hyperlink, Entity, and Number:
atts: ToSic.Eav.Data.Attribute`1[System.String]
atts: ToSic.Eav.Data.Attribute`1[System.String]
atts: ToSic.Eav.Data.Attribute`1[ToSic.Eav.Data.EntityRelationship]
atts: ToSic.Eav.Data.Attribute`1[System.Nullable`1[System.Decimal]]
So is there a way from the Entity or its Attributes or some other pathway of object/methods/properties to just get the answer as the field Type name? Or is there a wrapper of some kind I can get to that will let me handle (convert to/from) Hyperlinks? I am open to other ideas. Since the fields.Add() is different by "FieldType" this would be really helpful.
It's kind of simple, but needs a bit more code because of the dynamic nature of Razor. Here's a sample code that should get you want you need:
#using System.Collections.Generic;
#using System.Linq;
#using ToSic.Eav.Data;
var type = AsEntity(Content).Type;
var attributes = type.Attributes as IEnumerable<IContentTypeAttribute>;
var typeOfAwards attributes.First(t => t.Name == "Awards").Type; // this will return "Entity"
I created a quick sample for you here: https://2sxc.org/dnn-tutorials/en/razor/data910/page

3ds Max TransNode not recognized as object

We're having some problems accessing the parent object (the TransNode) in our Forge viewer application. The TransNode is the object/node which contains all the materials used in the object.
Our research found that TransNodes are not recognized as objects by the Forge Viewer. We can still access its materials (Mat0, Mat1, Mat3 etc), but not the parent (the TransNode).
Would it be possible to define the TransNodes as objects in the API or is there any workaround we could use? Thanks a lot.
If in a 3ds Max scene, an object has applied a Multi-Material, upon translation, for each channel there will be created a subcomponent.
This becomes handy when you want to create selectable parts of a mesh, without breaking apart the mesh.
However, if you want to avoid this subcomponent selection and select the entire object upon subcomponent selection, there are 2 approaches:
At 3ds Max level, before translating the scene, replace the Multi-Material with a Basic/Single Material. To keep the texture/colour, just bake the MultiMat into a bitmap and use it as diffuse colour in the Basic Material.
At Forge Viewer level, you could tailor selection using algorithm like:
if I am selecting a child, select automatically the parent.
This is done by subscribing to selection event and at minimum, the code could look like this:
let viewer = viewerApp.getCurrentViewer();
let tree = viewer.model.getData().instanceTree;
viewer.addEventListener(Autodesk.Viewing.AGGREGATE_SELECTION_CHANGED_EVENT,
(event) => {
if (event.selections[] != undefined) {
let selectedNode = event.selections[0].dbIdArray[0];
console.log("selected a node with id = ", selectedNode);
if (tree.nodeAccess.getNumChildren(selectedNode) == 0) {
let parentId = tree.nodeAccess.getParentId(selectedNode);
console.log("parent of the selected node is ", parentId)
viewer.select(parentId);
}
}
})
Thus, any selection of a "leaf", will automatically select the parent of that "leaf" along with all that is under the parent node.
The second approach is derived from one of our blogpost discussing the idea of Controlling components selection in the Viewer.

issue with Apache POI when converting .docx to a json document format.

I am currntly parsing a 26 page .docx with images,tables,italics,underlines. I am able to clear
Using apache POI I created XWPF document format with list of XWPF paragraphs. When i iterate through XWPF paragraphs, I am not able to get styles (italics,underlines,bolds) for individual lines if a single paragraph contains different styles.
i have tried using XWPF.paragraph.getrun(). XWPF...run.getfamilyfont() i am getting null. But i get the data at the paragraph level when i run XWPF.paragraph.getstyle()
Please do let me know if you have encountered similar issues.
I hope these code can help you , you can get some style from CTRPr object.
CTRPr rPr = run.getCTR().getRPr();
if(rPr!=null){
CTFonts rFonts = rPr.getRFonts();
if(rFonts!=null){
String eastAsia = rFonts.getEastAsia();
String hAnsi = rFonts.getHAnsi();
Enum hAnsiTheme = rFonts.getHAnsiTheme();
}
}

Want help to create a list in as3/flash

I want to create a scrollable list in flash/as3 and the important thing is.... if the user wants to move some list item up or down... he can do that by dragging the item... so when he press and hold on an item... the item will become drag-able and as the user moves it up or down the list, the other items should slide to the empty space. Its the same behavior seen in smartphones....
I'll figure out the creation, data filling, scrolling, and other mouse interaction events.... i just want help with this one behavior....of changing the order of items by dragging them. If only someone can just provide the basic algorithm or any idea how this can be achieved.. it will be enough.
​Thanks in advance
EDITS :
First of all... i apologize for not posting any details about the question... (this is my first post to this site) and hence i am adding all the research and what i have done so far.
the list is part of a big project hence i cannot share the whole code.
WHAT I HAVE ALREADY DONE :
i have created a mask, a container, a scroll bar to scroll the container, items to add into the list, methods to add items, remove items and arrange them according to the order.
hence it is a scrallable and working list.
the whole thing is in as3 and flash only.
i don't know flex and i don't want to use it either.
WHAT I WANT NEXT :
i want to change the order of these items by (mouse_down on an item -> drag it up/down -> mouse_up at the position) sequence.
If anyone wants more details i can share it.
Thanks in advance.. :)
Add a simple List component to an application
In this example, the List consists of labels that identify car models and data fields that contain prices.
Create a new Flash (ActionScript 3.0) document.
Drag a List component from the Components panel to the Stage.
In the Property inspector, do the following:
Enter the instance name aList .
Assign a value of 200 to the W (width).
Use the Text tool to create a text field below aList and give it an instance name of aTf .
Open the Actions panel, select Frame 1 in the main Timeline, and enter the following ActionScript code:
import fl.controls.List;
import flash.text.TextField;
aTf.type = TextFieldType.DYNAMIC;
aTf.border = false;
// Create these items in the Property inspector when data and label
// parameters are available.
aList.addItem({label:"1956 Chevy (Cherry Red)", data:35000});
aList.addItem({label:"1966 Mustang (Classic)", data:27000});
aList.addItem({label:"1976 Volvo (Xcllnt Cond)", data:17000});
aList.allowMultipleSelection = true;
aList.addEventListener(Event.CHANGE, showData);
function showData(event:Event) {
aTf.text = "This car is priced at: $" + event.target.selectedItem.data;
}
This code uses the addItem() method to populate aList with three items, assigning each one a label value, which appears in the list, and a data value. When you select an item in the List, the event listener calls the showData() function, which displays the data value for the selected item.
Select Control > Test Movie to compile and run this application.
source: http://help.adobe.com/en_US/ActionScript/3.0_UsingComponentsAS3/WS5b3ccc516d4fbf351e63e3d118a9c65b32-7fa6.html
Finally i have got the answer from some other forum.
Here is the link to the example (behavior) that i want to add to my list :
http://www.learningactionscript3.com/2008/05/13/the-power-of-relative-positioning/
(at the bottom 'Advanced Align Example').

Create a Tab (call it MNOP) with a layout that contains textboxes that take data(numbers).

How do I create a tab in a PyQT UI that has a layout that contains the following, example.
tab name-MNOP
Layout has.
a1: textbox that can input data (numbers)
a2: textbox hat can input data
a3: textbox that can input data
a4: textbox that can input data
the data input will be stored in the db and used to create bar-graphs. right now I need to create the tab and textboxes.
right now, I am working with the following-incomplete but don't know how to proceed.
class RPBDlg(QDialog):
def __init__(self, parent=None):
super(RPBDlg, self).__init__(parent)
self.newcounter =0
grid = QGridLayout()
label = QLabel()
label.setText("<B>Plan Title:</B>")
self.titleEdit = QLineEdit()
grid.addWidget(label,0,0,1,1)
grid.addWidget(self.titleEdit,0,1,1,1)
label2 = QLabel("<B>Type of Plan</B>")
self.typeEdit = QComboBox()
self.typeEdit.addItems(["STI","LTI","STI and LTI"])
grid.addWidget(label2,1,0,1,1)
grid.addWidget(self.typeEdit,1,1,1,1)
self.bonusPool = QCheckBox("Bonus Pool")
grid.addWidget(self.bonusPool,1,4,1,1)
label3 = QLabel("<B>Sub-Type of Plan<B>")
self.subTypeEdit = QComboBox()
self.subTypeEdit.addItems(["Regular","Profit Sharing","Multiplier Based"])
grid.addWidget(label3,1,2,1,1)
grid.addWidget(self.subTypeEdit,1,3,1,1)
self.label4 = QLabel("<B>Are individual awards determined <br>through a performance formula?")
self.bonusPoolAdditional = QComboBox()
self.bonusPoolAdditional.addItems(["Yes - separate formula for individual awards","Yes - individual awards are proportional to bonus pool", "No - individual awards are discretionary","No - individual awards determined through negative discretion"])
grid.addWidget(self.label4,3,0,1,1)
grid.addWidget(self.bonusPoolAdditional,3,1,1,2)
Imports are present. This code is part of a much larger code.
If you want to use tabs in your UI you should create a QTabWidget. The basic steps for working with it are:
create a QTabWidget.
Create a QWidget with no parent for each of the pages in the tab dialog.
for them.
Insert child widgets into the page widget, using layouts to position them as normal.
Call addTab() or insertTab() to put the page widgets into the tab widget, giving each tab a suitable label with an optional keyboard shortcut.
You can find detailed information in the documentation page of the widget.