Adding a selection provider to a view that contains only widgets? - eclipse

Can we Add a selection provider to a view that contains only widgets?If so how What should be the setSelection's Parameter.

This totally depends on the kind of implementation that you have done. If you are using widgets as some kind of select-able entities in the view then you can provide setSelection implementations.
The setSelection takes an ISelection instance, and it can contain any kind of object. So for example if your view has a form, with many labels and editable fields, you might want to "set focus and scroll to" any of the fields depending on the situation from the outside programmatically. Your setSelection would receive an object (maybe just even an integer index) wrapped in a ISelection object. It would be up to the implementation of the setSelection to move focus to the specific control and scroll to it.

Related

Flutter: why using controllers instead of registering event listeners in widgets directly?

Sometimes having to create controller, registering it in widget and then registering listener in controller looks like overengineering. I'm trying to understand why Flutter Team decided to go this path for some widgets, i.e. for text field, list view, while for others, i.e. for button widgets we can simply register onPress listener right in the widget itself, which obviously is easier and requires less boilerplate code.
Any reason why having controllers is a better thing compared to simple event listeners?
Controllers are used to store state higher up in the widget tree so a parent widget can both react to it as well as change it.
In the case of a text field, it wouldn’t be convenient to have a callback when a user presses a key and then have the parent construct the new text that should be displayed and rebuild the text field with that. (And it is not just key presses because you can paste text as well.) So the text field stores the text, so it always knows what to display and the onChange callback can report the whole text after the user changes it.
But then you might want to change to text from the parent as well. They could have made it such that the parent would have to rebuild the text field with a new text in such as case. However, for some use cases where you don’t just want to overwrite what a user typed, the parent would have to stored the text as well. Which would duplicate the state.
In the end it is simpler to have the controller own the state (the text) and allow both the parent and text field to change it and to read it.
For a ScrollController the situation is similar: both the scroll view and its parent might want the change the scroll position. And both might want to read it (surely the scroll view does).
Another advantage of the controller pattern is that the “parent” could be several widgets higher and you’d only have to pass a single controller through the intermediate widgets instead of several callbacks and several pieces of data.
I think this is because of 1st principal of S.O.L.I.D. which means single responsibility. Each object should be responsible for its own specific functionality. TextField serves text input, ListView serves item browsing nothing more. If you need some other (optional) data you need to ask someone other who responsible for it. Indeed, it is a controller.
From other side this approach gives some flexibility. You may change controller on runtime.

Extend Eclipse XML Editor's Design View to display certain Content

As soon as a schema is attached to an XML document the design view of Eclipse XML editor displays the possible children of a node on the right-hands side.
I'm interested in changing this when an element has a certain attribute to display the attributes content instead.
Is it possible to extend Eclipses XML editor to implement this behaviour?
At the moment I can only hide certain nodes, but I can't find the method to override for the displayed content per node.
Does anybody have an idea?
For completeness: I found a way to display the information I want in my custom XML editors design view.
It requires an own implementation of XMLTableTreeContentProvider. The method getColumnText(Object object, int column) is responsible for the text being displayed both on the left (column 0) and the right side (column 1) in the design view.
In this method the result of the call to the super method may be easily overridden / changed / adapted.

Add/remove usercontrol in panorama item using MVVM - Windows Phone

I have a panorama app that has two panorama items so far, "recent" and "popular." These get populated with data using binding from a viewmodel. I would like to add a third ("search") panorama item that initially shows just a text box and a button.
When the user inputs text and clicks on the button, I want the text box and button to be replaced with the ListBox control that shows the search results.
I cannot find any examples on how to do this using the MVVM pattern. I am not using a MVVM framework and would like not to since I am just learning all this.
If you can explain or better, point me to examples that will allow me to do this, I would very much appreciate the help. If I left out any required info in my request, please let me know.
Sincerely,
Kamal
Typically for something like this you would have a property in your ViewModel that would tell the view what to show. You have lots of different options for how you could do this.
One option would be to have a Results property that your list box is bound to. Put the textbox and button in a Grid and bind the Visibility property of the grid to a property that is Visible is there are no results and not visible if there are.
Lots of different ways to do this.
Examples here and here.
You could probably bind a list of a custom class to the panorama ite .
The custom class contains a title and/or description and a page class.
You can maintain your views in your main viewmodel.
Another solution would be adding the items in xaml and using the same viewmodel for the whole panorama item control. With a property you can control the visibility of each item.
Like Bryant said: there are so many solutions. It depends on your application and requirements... :)

Accessibility Focus

Working with Accessibility
While VoiceOver reads the elements in the application in an order,Is there anyway to shift the focus between the elements?
I tried working with "nextResponder",but it is not working.
As of iOS 6, you can set the focus to a specific element with a UIAccessibilityLayoutChangedNotification, passing the element
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, firstBottom);
but if you're trying to completely change the “tab order” I don’t know of a way to do it.
This is a shot in the dark, but have you tried changing the accessibilityLabel or accessibilityHint in accordance when you want the order to change? If you can trick the VoiceOver to believe the text has changed, I would expect that it would change focus to it appropriately.
The timing would be the hard part, since it doesn't appear there are any delegate callbacks for when VoiceOver is crawling your view, so you may have to estimate the time to pass before trying to update the accessibility hint/value.
My last thought would be to mark the UIView that you want to bring attention to with the UIAccessibilityTraitUpdatesFrequently accessibility trait. That might be the closest you can get without tapping into hidden Apple libraries.
Check out this post for how to handle special ordering of elements for voice over. I just used this approach in the app I'm working on.
I tried UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, elementName); to change the focus on a different element. The behavior was that the focus got shifted to new element, but Voice Over would first announce the page title and then the accessible label value of the new element.
Customise Accessibility for a View:
You can customise the order(in which voice over should traverse the screen elements) by overriding accessibilityElements property of parent view in below manner.
self.accessibilityElements = [childView1, childView2, childView3]
With that voice over will follow the sequence like childView1 -> childView2 -> childView3.
Changing Accessibility focus to other element programatically:
At any time you can shift the focus to another element by using below code.
UIAccessibility.post(notification: .layoutChanged, argument: childView2)
With above code, voice over focus would be shifted to childView2 and then will follow the same sequence defined by accessibilityElements i.e. childView2 -> childView3 -> childView1... and so on
Customising Accessibility Order for Complex Views:
You can customise it further and If a view has multiple child views with further grand children views, then you can achieve accessibility order by defining accessibilityElements of main parent view by using accessibilityElements of all child views.
For example, for below view hierarchy, we have
View Controller Example
To define custom order of accessibility elements for such views, we can define in below manner.
var customElements = childView1.accessibilityElements
customElements.append(contentsOf: childView2.accessibilityElements)
customElements.append(contentsOf: childView3.accessibilityElements)
parentView.accessibilityElements = customElements

View state, new activity start

I use the MVP pattern in my project. According to it Place define view after a new Activity starts. In some cases when I have to save the content of some Text areas after change of Place. I think that it is not a good idea to put these text areas in Place, because they don't define business logic. To save them in View elements is not good either. How do I resolve this situation?
GUI elements (GWT widgets) belong in Views. Why do you think otherwise?
Then your View interface (or is it Display?) can have getTextData()/setTextData() methods to retrieve data in your TextBox.