Displaying and editing XML data tree in nested uitableviews on iOS - ios

I need solution to display XML data tree (stored as plist) via UITableview on iOS
It's desirable to have:
ability to display XML data tree in nested tables
ability to re-arrange nodes in XML tree using WYSIWYG principle
ability to add new nodes and copy-paste existing
Any ready-to-use snippets/libraries?

Is there a reason why you'd want to use nested tables rather than a single table with indented rows? The single table approach should be much easier to set up and manage.
TLIndexPathTools has a great example of a hierarchical table with expandable levels. Try running the Outline sample project. TLIndexPathTools is a low-level library, so it should be easy to modify to your specific needs.

UPDATE: given solution doesn't work with iOS7 and greater
Did not found good solution nowhere, so made it by myself.
It uses nested UITableView in recursive mode.
Features:
displaying of XML data tree of any depth
supports custom sizes, rotation and both iPad/iPhone screens
supports re-arranging (move node up, move node down, delete, copy-paste, create new)
https://github.com/braginets/NestedTablesForXMLDataTree
NB: I am aware that this solution maybe not perfect, it's rather an attempt to make my modest input into this great community to thank for all for their knowledge sharing.

Related

Sharing model between documents in a document-based app

My app is a document-based and uses NSPersistentDocument to manage its Core Data stack.
It works great when each document has its own data, but now I want documents to share parts of their model.
In my case, the users import large files and I don't want to copy them for each document.
I want to have a model that is tight to the app itself and not to the particular document.
I'm not really sure how to go about it. NSPersistentDocument provides some methods to override for configuring Core Data stack but I don't know how to set it up.
Can anyone give me some tips how to achieve that?
very interesting case ,
NSPersistentDocument : A document object that can integrate with Core Data
https://developer.apple.com/documentation/appkit/nspersistentdocument#relationships
I would add my 2 pennies for MVC ideology:
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.
while its great for relational databases like SQL where cascade delete is possible, and other query based operations.
but the moment you want to couple data between 2 objects you will run into few issues.
if any of the document/record depends on other siblings, you need to sync them, which is usually a pain in a**.
if any document is very big, your DB will start sweating already, if it has cascade dependencies to other members of db.
Possible solutions
since the persistent document can integrate with the core data, try putting any new data to core data and calculate difference from there.
ideology behind design principles
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
here is the full pdf

TFS - Move tasks between Work Items

As a previous result of a bad TFS project management, several tasks has been created in the wrong work item. Now I need to move several tasks to different work items. Is there an easy way to do it?
So far, I have to edit each task, remove the previos link to primary element and create a new one, but this is taking a lot of my time.
I suspect that the easiest way to do it would be from Excel. Create a Tree-based query that shows everything, then move the child records in Excel using simple cut and insert cut cells. Excel will then allow you to publish the new structure in one go.
If you need to move items up to a higher or lower level, place the Title Field in the column representing the level.
See this little video I captured to show how it is done.
MS Project is extremely good with modifying hierarchies of work items. The steps are exactly the same as setting it up in Excel, but project inherently handles parent/child relationships, giving them a drag-and-drop interaction.
jessehouwing's Excel answer will be easier if you have never worked with project before.
Updated jesshouwing's comments are correct. Especially about the shivers.

how to implement redo in lua

I have just been introduced to the LUA language, and I am embarking on my first project. However, the biggest challenge I am facing now is how to implement or make an Undo and Redo.
However, to make issues clear, the project is a Custom Text Editor, and as a result, the Undo/Redo here is required for editing any input text. I have manage to handle issues like Cut,Copy, Clear, Find Word, as well as Changing Font, Text Colour, inserting tables and images among others, and all these were handled in the lua language. Obviously, there are several of the custom text editors, i believe the effort to cater for many will pave the way for future advancements or improvements. But the Undo/Redo actions are tearing me apart, which from my research is even the lack by most of the existing custom text editors.
I have searched several forums where they all seem to give the tip of using an associative kind of table to load the information, and retrieve them from there. Unbelievably, i think some of these sites are just sharing their knowledge acquired from other sites without any technical view point or whatsoever. This is because, most of the suggestions i come across seem to look alike and the same in all aspect. For about tens of sites visited, there is non where a user has tried to post an example, but all i see is the same complain about the majority of lua users. Undoubtedly, this will seem a bit easy to some respected gurus in this forum.
I don't seem to get the true picture of the suggestions.
Can someone provide me with an example?
Undo/redo is a perfect fit for command pattern.
First you need to write some of the text manipulation functionality per se. Just the do part, without worrying about un- or re-. That will be lots of work in itself.
You will then have a bunch of functions to manipulate your document. Things like insertText(), setFont(), insertJpgImage() and such. The trick is that now you need to wrap each of this functions in a so called command object. Each command class must have a method to do() itself, and to undo() itself.
Now that all your text manipulation operations are represented by command objects, you execute each operation (e.g. bold some text) by something like:
boldCommand = setTextPropertyCommand:new(document, selectedArea, textProperties.bold)
boldCommand:do() --actually modify text
table.insert(commandUndoStack, boldCommand) --keep the command for possible undoing later.
When you want to undo the bolding of some text you can then call:
command = table.remove(commandUndoStack)
command:undo()
NB, if your are using some GUI framework binding in Lua, then it might be the case that this framework has its own readymade undo/redo functionality. For example Qt (with qtlua bindings) offers QUndoStack class.

WinDirStat-like control in Delphi

The program WinDirStats (written in C++, see http://sourceforge.net/projects/windirstat/ ) has at the top a control that combines a tree-like structure (The column "Name", first on the left) with other types of data (graphic bar in column "Subtree percentage") and other text columns.
My question is, using Delphi 7, which control should I use to do something like that? It's the tree part that I find more difficult to get right.
The best control for this would most likely be Mike Lischkes Virtual Tree View.
Developers Homepage | Google Code Page
It's free
It gives you a tree connected with a list view
It allows for custom drawing
It's incredibly flexible
It's lightning fast
The only downside is that you have to learn a quite different paradigm than most Delphi controls have, but apart from that it is a teriffic control.
I myself have used it in various projects quite successfully and never hit a real roadblock while using it.
I also prefer Virtual Treeview, but here are some commercial alternatives:
ExpressQuantumTreeList
ElTree
TTreeList

Delphi: Mimicking MS OneNote's Data Structure

MS's OneNote uses a data hierarchy that is essentially a simple tree, even though the info is displayed via a tabbed interface rather than a treeview. You begin with "notebooks," which can have "sections," which have "pages." I'm trying to model this. In my case, a page would be linked to the contents of a RichEdit.
My problem is not that I can't figure out a way to do this. My problem is that I am unsure which of several possibilities will ultimately be simplest. That's where I am hoping you will come in.
I could, for example, use a regular [MyBase] database. A Page dataset would have fields for its name, and the RichEdit data. Pages would be nested inside Sections, and Sections would be nested inside Notebooks.
If I thought about it for awhile, it seems like this is something that could be modeled with simple stringLists as well, especially if each element in the list included comma separate values for an ID and position in the hierarchy, as well as notebook/section/page name.
But then this also seems like something that might be well suited for XML ... if I were to learn more about XML :-)
What do you more experienced folks think?
Thanks, as always ...
Whether you go with a database or XML, try putting your data access routines in a datamodule. Let your GUI unit(s) make calls to public methods of the datamodule, and ensure that those calls do not depend on how your data are stored. That way, you can start with one approach, and switch to the other just by editing your datamodule.
One thing you could try would be to use a structured storage system. The concept is simple, you work with a datafile much like you would a disk and folders...thing is that the folders and files are all under your exclusive control. The only issue is that it doesn't exactly scale well to multiple users, but then neither does XML. (a good structured storage library is available on gabr's blog)
For a "multi-user" system, your best option will be to implement using tables. You can probably get a good start at things using Microsoft Access and ADO, which migrates to MS Sql Server very easily. From your brief description, I would expect you to have three tables, NOTEBOOKS, SECTIONS, PAGES. The Pages would have a Foreign key relationship (detail/master) to Sections and sections would have a Foreign key relationship with Notebooks.
If you are storing it in a file system, why not use.... folders? That's what OneNote does. A "notebook" and a "section group" are simply regular file system folders. The only other level is a section which is the .one file. There is a very limited hierarchy in there (it's just pages, any of which can be marked as subpages but these are not really linked in any way to a parent.)
Inside the .one file you can use XML to represent your pages, though this is not what OneNote does. OneNote uses a binary file format in order to facilitate fast edits, object-level synchronization, multi-user access, and compact storage.
If you look around for info about "random access files" you can get an idea for how to do this. But try to avoid using XML if you think it can get large because it will become cumbersome to make edits. You'd need to load the entire XML file, make changes in-memory, then write the whole thing back out again.
I think it depends on how you want to save the data. If you plant to use a database for shared access, speed and large amounts of data: just normalize the data and create the structure you proposed.
If you want the user to save data locally on a filesystem, I do think that XML will be a good solution because it allows you to store the data in a structured file.
So... how do you want the user to store and use the data?
I think at your data like a tree.
node {
id
parent_id
content
type
}
nodes with paren_id = 0 are notebook.
type is optional but could be useful.
content on page and notebook will give you a page/notebook description for free :D
I will use a simple table on sqlite or MyBase or whatever.
I think a little db is better than Xml because xml force you to load all data in memory.

Resources