Windows Phone 7 Toolkit: How to reload the data in the Loopingselector control? - windows-phone-7

I'm using the LoopingSelector to show a series of timestamps. As time progresses, I'd like to update the timestamps in the looping selector.
I have a class that implements the ILoopingSelectorDataSource interface, but I can't figure out how to force the data to reload while the control is showing.

Claus is partially correct, there doesn't seem to be a way to use binding to update the control, but in code behind, calling
LoopingSelector.DataSource = new MyLoopingSelectorDataSource()
// your implementation of the ILoopingSelectorDataSource interface
will cause the control to reload data.

Basically you can't. The control doesn't update the currently rendered controls. You would have to rewrite the control to fit your purpose.
While you can easily make it calculate the time relatively to a given point upon the call to GetNext() or GetPrevious(), updating the elements already on the screen would require a invoke of a kind, or a constant update per second/minute or whatever fast you want them to update.

Related

Keep Business Process Display State as collapsed

I am trying to keep the business process flow display state as collapsed.
I am currently making it collapsed at addOnStageChange
Xrm.Page.ui.process.setDisplayState('collapsed');
It works fine on Stage Change for me. But if I click on the same stage twice which means stage is not changing then the BPF gets expanded. I am assuming if it is the default behavior.
How can I prevent it from expanding permanently?
If you are using Unified Interface it will be collapsed by defualt.
But if you are using legacy web client.
Add onload event on your From (for ex.Opportunity entity) and add below lines of code.
function collapseOpporBusinessProcess(){setTimeout(collapseOpporBusinessProcessDelay,300)}
function collapseOpporBusinessProcessDelay(){Xrm.Page.ui.process!=null&&Xrm.Page.ui.process.setDisplayState(“collapsed”)}
BPF cannot be collapsed always in classic UI, but possible in UCI like popout behavior or flyout without expanding. It needs some unsupported DOM manipulation in classic UI to nullify the click event of stage chevron or simply user training not to click it at all. Or better create a similar UI using webresource if you want.
It fails the original purpose, and re-purposing the BPF raise these kind of questions. If you have built the necessary business logic already in some other means - then custom UI is better choice rather than bending the BPF.
BPF is for guided process advancement, we can add attributes/entities as steps to move forward and enforce the field value requirements for reaching next level. I know some clients use them as tabs, some use them as just chevron tracker, so they don't want to waste the real estate under the BPF as they don't need any fields under the stages.

Codename One - Improve Layout Animation Usage

Following the instructions in this documentation about Animations and Transitions, it is noted that animation done on the Form level requires taking the contentpane as the actual Container. So instead of
form.animateLayout(1000);
one has to do
form.getContentPane().animateLayout(1000);
While the documentation points out this exception, wouldnt it be easier and more user-friendly to update the animateLayout() function to check whether the intended Component to do the animation for is a Form itself and if so, automatically getting its content pane?
This would remove this exception handling from the user side and make it more intuitive.
Yes that makes sense. There are a lot of methods that constantly get added/changed and we still didn't add everything that needs adding. In this commit I added a few: https://github.com/codenameone/CodenameOne/commit/4b848039ec6619bf3d6dae3cfe6b8b8d9a7ff115

How to speed up dynamically adding user controls in wp7

I have a page in my WP7 app that I build dynamically. I create and add 60 user controls to a grid and it takes around 5 seconds. I need to find a way of speeding this up.
The process is as follows:
Create user control
Add new grid row definition
Set the value of the control row property
Add the control to the grid.Children collection.
It is step 4 that is taking the time. I'm guessing that each time I do this the visual tree is getting re-built.
Is there any way of telling the grid to only re-build the visual tree after I have finished updating the children collection?
Or is there another better way of doing this?
UPDATE: The List Picker control from the WP7 Toolkit was causing the problem. When I changed to one I wrote myself the time taken to display the page on a phone reduced from 25 seconds to 1 second.
The/your aim is to try and reduce the number of times you update the visualtree.
A few suggestions:
Try including (some of) the items in the page by default but just change their visibility depending on what you need.
Build the whole grid in code and add it to the page in one go (rather than a line at a time)
Depending on your content, you could try using a ListBox and alternating the template used for each row to get different content displayed.
The technique which will be best for you will depend on what you're actually adding to the UI. You'll need to test to see what is best for you.
If the UI virtualization (i.e. ListBox) helped, the problem must be in your controls. Templating, bindings, converters, using Xaml instead of C# code, unnecessary Xaml constructs (such as element names), overcomplicated visual tree (e.g. unneeded grids) etc. - those are the things that can degrade the performance.
If you suspect incremental visual tree rebuilds (I don't think so), then simply debug MeasureOverride/ArrangeOverride methods.
I guess this article might give you more tips. I described there how we optimized a similarly complex control - MonthCalendar with 126 sub-controls. Control load time decreased approx. 5x!

Custom editor in QAbstractTableModel

Does anyone have an example of using a QWidget as an editor in a QAbstractTableModel?
I have a column which when edited should create a QCombobox with the list of choices.
The docs seem to suggest I need to write a QAbstractItemDelegate and a custom paint function but that seems overkill to simply pop-up a standard QCombobox in Qt::EditRole.
Note - the combo box contents are the same for every row and it only needs to be shown when somebody clicks in the cell.
I know this should be simple but I can't get it to work. It's easy for a QTableWidget based table - but I need it for a very large data table.
The docs seem to suggest I need to write a QAbstractItemDelegate and a custom paint function but that seems overkill to simply pop-up a standard QCombobox in Qt::EditRole.
You don't need to go that far. One way is to subclass QStyledItemDelegate and then override createEditor() so that it returns your prepopulated combo box. Its setEditorData and setModelData functions will probably already suffice if you`re using basic Qt value types.
If you need something more generic that works across many different models, you can create a QItemEditorFactory that associates your editor with the correct type. This also works well with custom types.
When indicated by your view's EditTrigger, your view will get the delegate specific to the cell on which the edit is being invoked and call delegate->createEditor(...) which can then size the combo box according to the options parameter as well as set the current entry to the value specified by the model, although most of this should be handled by the QStyledItemDelegate. Thus, you won't have to worry about the Qt::EditRole directly as the view will handle that.
Did you try and have a look at the following example from Qt :
Spin Box Delegate Example
Maybe it will give you a much clearer view on the subject !
Hope it helps a bit !

Talking Among GWT Panels using UIBinder Layout

New to GWT here...
I'm using the UIBinder approach to layout an app, somewhat in the style of the GWT Mail sample. The app starts with a DockLayoutPanel added to RootLayoutPanel within the onModuleLoad() method. The DockLayoutPanel has a static North and a static South, using a custom center widget defined like:
public class BigLayoutWidget extends ResizeComposite {
...
}
This custom widget is laid out using BigLayoutWidget.ui.xml, which in turn consists of a TabLayoutPanel (3 tabs), the first of which contains a SplitLayoutPanel divided into WEST (Shortcuts.ui.xml) and CENTER (Workpanel.ui.xml). Shortcuts, in turn, consists of a StackLayoutPanel with 3 stacks, each defined in its own ui.xml file.
I want click events within one of Shortcuts' individual stacks to change the contents of Workpanel, but so far I've only been able to manipulate widgets within the same class. Using the simplest case, I can't get a button click w/in Shortcuts to clear the contents of Workpanel or make WorkPanel non-visible.
A few questions...
Is ResizeComposite the right type of class to extend for this? I'm following the approach from the Mail example for TopPanel, MailList, etc, so maybe not?
How can I make these clicks manipulate the contents of panels in which they do NOT reside?
Are listeners no longer recommended for handling events? I thought I saw somewhere during compilation that ClickHandlers are used these days, and the click listener "subscription" approach is being deprecated (I'm mostly using #UiHandler annotations)
Is there an easy way to get a handle to specific elements in my app/page? (Applying the "ID" field in the UI.XML file generates a deprecation warning). I'm looking for something like a document.getElementById() that get me a handle to specific elements. If that exists, how do I set the handle/ID on the element, and how can I then call that element by name/id?
Note that I have the layout itself pretty well nailed; it's the interaction from one ui.xml modularized panel to the next that I can't quite get.
Thanks in advance.
If you don't have a use for resizing events than just use Composite
What you want is what the GWT devs called message bus (implemented as HandlerManager). You can get a nice explanation in the widely discussed (for example, on the GWT Google Group, just search for 'mvp') presentation by Ray Ryan from Google I/O 2009 which can be found here. Basically, you "broadcast" an event on that message bus and then a Widget listening for that event gets the message and does its stuff.
Yep, *Handlers are the current way of handling events - the usage is basically the same so migration shouldn't be a problem (docs). They changed it so that they could introduce custom fields in the future, without breaking existing code.
If you've set an id for any DOM element (for Widgets I use someWidget.getElement().setId(id), usually in combination with DOM.createUniqueId()) you can get it via GWT.get(String id). You'll get then a RootPanel which you'll have to cast to the right Widget class - as you can see it can get a little 'hackish' (what if you change the type of the Widget by that id? Exceptions, or worse), so I'd recommend sticking with MVP (see the first point) and communicating via the message bus. Remember however, that sometimes it's also good to aggregate - not everything has to be handled via the message bus :)
Bottom line is I'd recommend embracing MVP (and History) as soon as possible - it makes GWT development much easier and less messy :) (I know from experience, that with time the code starts to look like a nightmare, if you don't divide it into presentation, view, etc.)

Resources