How to refactor a large xib file using Xcode 4? - xcode4

We have a large application that has 21 view controllers - all in a single xib. We'd like to refactor this into individual xib files - one per view controller. I don't see any obvious way to do this in Xcode 4. Is this possible or do I have to start from scratch?
(Answering my own question here...)
Ahah! (Eureka)
If I open a second xcode window (File->New->Window) and create an empty .xib file, I can drag objects from the xib in the main xcode window into the empty xib in my new xcode window!

You could copy and paste the views out of the big XIB and into new XIBs, but there's no automated way of doing that. By that I mean select the root view of each view controller, and paste it into the fresh XIB you'll create for each view controller.
I'm not really sure how you've managed to get 21 view controllers into a single XIB, though. There's only one "File's Owner". I suppose you could have multiple view controllers in there that end up being owned by the single file's owner, but it's a very strange way to do things. I suggest you move away ASAP (which I'm sure you're doing by asking this question!) and life will become a lot simpler.

Related

TornadoFX: Label text not updating

One of the issues I'm currently experiencing is that I can't seem to change the text of a Label which is implemented in a dynamically loaded AnchorPane. I assume this might be related to the controller and how JavaFX/TornadoFX works, but I can't seem to find what I'm doing wrong.
The issue itself occurs in this class, and happens in the showSystemDetails() method. What I would expect to happen is that upon pressing the "System Details" button in the sidebar, the labels would update to the required value, but this isn't happening for some reason.
Please feel free to point me to what I'm doing wrong, or provide any constructive criticism. The project is still in full development so a lot of things are still messy/broken.
The reason this isn't working is that you're manually loading a new version of the FMXL file every time you select something in your menu. The FXML file originally loaded by SystemDetailsViewProxy is updated correctly, but that's not the one you're showing on screen anymore.
To see the updated View, make sure you put the root node of the SystemDetailsViewProxy instance back.
You could for example change your DrawerMenuButton enum to contain references to SystemDetailsViewProxy::class instead of those two strings, and use add(viewClass) to add the correct root node to your view when clicking the menu buttons.
Furthermore, you should be using ViewModels and binding instead of manually updating the text property of the labels. You're doing an awful lot of manual/error prone work that the framework can help you with for free.
Your application is not using best practices in several important areas, and you're rolling your own solutions for stuff that the framework already does very well :)
Views are singletons when managed by the framework, but you instantiate them yourself instead of using inject/find. The result is that important life cycle methods are not being called.
I would also suggest looking into type safe builders instead of FXML.
Hope this helps :)

Complex UI with MVC

I'm trying to recreate a text editor I've made but using the MVC design pattern; I'm not totally sure about certain parts of it.
For example, I have a tree view displaying my project directory, and a text editor showing the contents of a file, along with this i have output from compilation of files being displayed as well as a tabbed interface.
Would this be split into a few different models or under one big model? If it's under 1 big model how would I go about using the Qt model classes for such a thing?
Open up Qt Designer and drag and drop all the stuff you need. It should get you pretty far.
I think the only model/view you should worry about is the QFileSystemModel and pairing it up with a QTreeView. Everything else Qt has some nice examples showing how to do it.
If you are showing multiple files at once in separate tabs, then you might want to look into the Tabbed Browser Example to see how its done.
http://doc.qt.io/qt-5/examples-mainwindow.html
http://doc.qt.io/qt-5/qtwidgets-richtext-syntaxhighlighter-example.html
http://doc.qt.io/qt-5/qtwidgets-widgets-codeeditor-example.html
http://doc.qt.io/qt-5/qtwebkitexamples-webkitwidgets-browser-example.html
I like QDockWidgets and using QActions and putting them on the QToolbar in a QMainWindow.
http://doc.qt.io/qt-5/model-view-programming.html
http://doc.qt.io/qt-5/qfilesystemmodel.html#details
http://doc.qt.io/qt-5/qmdiarea.html#details
http://doc.qt.io/qt-5/qtextedit.html
For the compilation part you will just need to create a QProcess and connect its output to a QTextEdit.
Hope that helps.

javafx - drag to filesystem - get path

I am relatively new to java and javafx. So my program is a product of my growing java skills:) and "thankfully" copying stuff from the growing quantity of javafx howto's.
Well now i am stuck on a problem and I have spent now quite a time looking for the solution before asking you guys. Basically I have builtin this application a very simple ftp-client using the apache common library, which does a connection and loads the ftpfiles into a tablerow and one can browse through the directories, what for I have implemented some FTPCLient functionalities on a seperate class. Well I already have set up a dragin-files functionality from the os's filesystem into the tableview, which does the upload of files part very well.
But know I would like to be implement the drag/copy file from the tableview to the filesystem. I am very thankful if anyone could give me a short description on how to do that. I think I could get that done, if I could get the path of the target-directory when dragging to it. Probably set up in a row- or cellfactory.
Thanks in advance guys,

Models are missing in strongly typed view drop-down

First of all, I apologize if this question is unclear, I am going to try and be as clear as possible.
My solution has 2 projects: Models and View/Controller. The View/Controller project knows what is in the Models project but not vice-versa.
I have created some Text Templates to automatically create CRUD Pages that work when I use the Add View dialog box to add new Views. This obviously happens in the View/Controller project. I've been using this without issues for a long time.
I am able to run the project without syntax errors or runtime errors, but when I use the Add View Dialog Box to try and create a new page, I choose the strongly typed option and I do not see anything from the Models project.
Things I have tried:
Reattaching the DLL for the Models as a reference to the View/Controller project again.
Build and Rebuild as well as Cleans
Manually typing everything in the dialog box (fails).
I do not want to create this page manually, as it will make errors/bugs very likely whereas the Template will reduce the amount of bugs I am likely to encounter.
Don't know how it did it, but I cleaned the project again (after failed attempts) and it finally works.
Before Adding View just Build the solution and then add view it will work. if it will not work then you can again concern with me i will give you another solution

Organizing WF4 workflow xaml

I have a rather large workflow defined in xaml, consisting of nested flow-charts and sequences.
It's a pain to click through the entire hierarchy to modify an activity which is deeply embedded in the workflow. After a project rebuild, the workflow designer resets to the top view, so I have to do this alot.
Is there a way to create separate xaml files containing parts of the main workflow and including them in the main file ? This way, I would be able to edit by simply opening the sub-flows from the solution explorer.
Would invoking a subflow xaml from a CodeActivity seem like a good idea ?
Any other hints to speed up workflow editing ?
Thanks in advance.
Janiek
Assuming you are talking about Visual Studio, Custom XAML Activities are a possible solution.
How to - you can create a separate file wrapping one of the flowcharts called e.g. FlowActivity1. When you build the project, you should see FlowActivity1 appears in the Visual Studio toolbox. You can then go to your main workflow, and replace the flowchart with FlowActivity1. You will also need to create Arguments on the FlowActivity1 activity in order to pass in variable values from the main workflow.

Resources