Canel the drag event in DualList when a record is moved in GXT - gxt

I want to cancel an event where a record is moved from FromDualList to ToDualList if validation fails in GXT
DualListFrom.getStore().addStoreListener(
new StoreListener<Model>() {
#Override
public void storeRemove( StoreEvent<Model> se ) {
if(!validation){
se.setCancelled( true ); // this doesnt cancel the event
}
}
}
);
But se.setCancelled( true ); doesnt prevent moving the record from fromList to ToList.

Related

Clean up bound property

I have IVector collection property which is bound with xaml element.
using PlatformStringVector = Windows::Foundation::Collections::IVector<Platform::String^>^;
The collection member :
PlatformStringVector m_dataCollection = ref new Platform::Collections::Vector<Platform::String^>();
The Property :
property PlatformStringVector DataCollection
{
PlatformStringVector get() { return m_dataCollection; }
void set(PlatformStringVector value) { SetProperty(m_dataCollection, value, "DataCollection");}
}
I am trying to clean the collection from background thread. If i am clearing the bound property i am getting error from xaml is null.
DataCollection->Clear();
But if the clean up is done by
m_dataCollection->Clear().
Everything works fine.
What is the difference between Property Clear and data driven clear?
/// <summary>Initializes the session asynchronous.</summary>
void App::InitSessionAsync()
{
concurrency::create_task([this]
{
WaitForDevice();
}).then([this](concurrency::task<void> task)
{
try
{
task.get();
}
catch (const Polytec::IO::CommunicationException & ex)
{
..
}
AppData::ViewModel->DataCollection->Clear(); // This clear does not work.
//AppData::ViewModel->ClearCollection(); // It actually clears the data collection member. And this works
auto rootFrame = dynamic_cast<Frame^>(Window::Current->Content);
rootFrame->Navigate(TypeName(MainPage::typeid), nullptr, ref new Animation::SuppressNavigationTransitionInfo);
}, concurrency::task_continuation_context::use_current());
}

Xamarin.IOS UIBarbuttonItem added as in Recipe does not work. No error no button

Using Xamarin IOS app derived from The Tabbed Application template. Targeting IOS 11+; testing in simulator for 12.1.
I added a UINavigationBar to one of The UIView tabs and tried to add a save and cancel button into The bar.
No error, no joy, The NavigationItem is NOT null, and shows The correct Navigation Item. Here is The outline:
--UIViewController MyInfoController
----UIView InfoView
------UINavigationBar NavBar
--------UINavigationItem [no name]
------UIView ContentView
------A bunch of constraints
----UITabBar
and here is a relevant snippet of The code:
public partial class MyInfoController : UIViewController
{
protected MyInfoController(IntPtr handle) : base(handle)
{
// Note: this .ctor should not contain any initialization logic.
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
// Perform any additional setup after loading the view, typically from a nib.
this.NavigationItem.SetRightBarButtonItem(
new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) =>
{
// Handle Save Button Click here.
//Create Alert
var okAlertController = UIAlertController.Create("Click", "Right Button Clicked.", UIAlertControllerStyle.Alert);
//Add Action
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
// Present Alert
PresentViewController(okAlertController, true, null);
}), true);
// Try another way...
var button = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, e) =>
{
//Put Something here
});
button.SetTitleTextAttributes(new UITextAttributes()
{
TextColor = UIColor.White,
TextShadowColor = UIColor.Clear
}, UIControlState.Normal);
this.NavigationItem.SetLeftBarButtonItem(button, true);
// Create and add Views
No error messages issue. I don't see anything wrong, but I also don't see The bar button items.
What am I missing? (:-S)
If you use ios designer to add UINavigationBar and UINavigationItem ,you'd better set name for them ,like this
------UINavigationBar NavBar
--------UINavigationItem BarItem
So , in the controller , bar will show normally.
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
this.BarItem.SetRightBarButtonItem(
new UIBarButtonItem(UIBarButtonSystemItem.Save, (sender, args) =>
{
// Handle Save Button Click here.
//Create Alert
var okAlertController = UIAlertController.Create("Click", "Right Button Clicked.", UIAlertControllerStyle.Alert);
//Add Action
okAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
// Present Alert
PresentViewController(okAlertController, true, null);
}), true);
// Try another way...
var button = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (sender, e) =>
{
//Put Something here
});
button.SetTitleTextAttributes(new UITextAttributes()
{
TextColor = UIColor.Black,
TextShadowColor = UIColor.Clear
}, UIControlState.Normal);
this.BarItem.SetLeftBarButtonItem(button, true);
}
More info:
If you use this.NavigationItem ,this commonly used in root controller is UINavigationController .

MVVMCross Data Binding after returning from ViewController

I am using MVVMCross 3.2.2 as part of an iOS/Android app. One of my screens has multiple views that are displayed depending upon the selection in a Tab bar like row of buttons. Different data is displayed in each of these these views individual UITableView. The data binding works perfectly.
I also have a menu, that has a "profile" selection. Changing the profile fires an MvxMessage that my HomeView receives and then uses the message to set the ViewModel up to filter the data to be displayed. This all seems to work perfectly and the data is displayed correctly.
If I do something in the HomeView that displays another view using ShowViewModel(). When I return back to the home view the binding no longer works properly when a profile changes is made. The message gets handled, the data gets filtered, but a call to ReloadDataTable on the UITableView does not change the data.
ViewModel
#region Groupings
public IList<Group> Groups{
get { return _groupService.GetAll(); }
}
public void SetupSubGroups(Group group)
{
if (group == null)
{
_groups = new ObservableCollection<Group> ();
if (_profileService.SelectedProfile != null)
{
var grp = _groupService.GetByGroupName (_profileService.SelectedProfile.Name);
if (grp == null)
grp = new Group { Name = _profileService.SelectedProfile.Name };
_groups.Add (grp);
}
}
else
{
var litsOfGroups = _groupService.GetSubGroups (group);
foreach (var grp in litsOfGroups)
_groups.Add (grp);
}
RaisePropertyChanged(() => AvailableGroups);
}
private ObservableCollection <Group> _groups;
public ObservableCollection<Group> AvailableGroups {
get { return _groups; }
}
#endregion
ViewController
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
var groupSource = new GroupTableViewDataSource (TableViewGroups);
TableViewGroups.Source = groupSource;
_localViewModel.SetupSubGroups (null);
_bindingSet = this.CreateBindingSet<HomeViewController, HomeViewModel> ();
_bindingSet.Bind (groupSource).To (vm => vm.AvailableGroups);
_bindingSet.Apply ();
TableViewReportTags.ReloadData ();
NavigationController.NavigationBarHidden = false;
}
private void OnProfileChanged(ProfileChangedMessage message)
{
_localViewModel.SetupSubGroups (null);
TableViewGroups.ReloadData ();
}
private HomeViewModel _localViewModel { get { return ViewModel as HomeViewModel; } }
Any ideas what I can look at, or change would be really useful. I have spend many hours on this, and have made no progress.

Cannot capture javafx CheckBoxTableCell CellEditEvent

I have defined a CheckBoc TableColumn as
#FXML private TableColumn<Batch, Boolean> sltd;
And have defined the CellValueFactory & CellFactory
sltd.setCellValueFactory(new PropertyValueFactory<Batch, Boolean>("pr"));
sltd.setCellFactory(CheckBoxTableCell.forTableColumn(sltd));
My problem is i am not able to capture the edit column event for the checkbox. I use the following code:
sltd.setOnEditStart(new EventHandler<TableColumn.CellEditEvent<Batch, Boolean>>() {
#Override
public void handle(TableColumn.CellEditEvent<Batch, Boolean> t) {
//System.out.println("CheckBox clicked.");
}
});
I don't think the check boxes in the CheckBoxTableCell invoke the startEdit(...) method on the table.
The only thing that can happen in an edit is that the boolean property of one of the items in the table changes from true to false, or vice versa. So you can check for this just by listening directly to those boolean properties.
If you want a single listener that will catch changes to any of the properties, you can create an observableList with an "extractor" and register a list change listener with the list. This looks like:
ObservableList<Batch> items = FXCollections.observableArrayList(new Callback<Batch, Observable[]>() {
#Override
public Observable[] call(Batch batch) {
return new Observable[] { batch.prProperty() } ;
}
}
// populate items
table.setItems(items);
items.addListener(new ListChangeListener<Batch>() {
#Override
public void onChanged(Change<? extends Batch> change) {
while (change.hasNext()) {
if (change.wasUpdated()) {
System.out.println("Item at "+change.getFrom()+" changed value");
}
}
}
});

disabling sound in a single application in blackberry

I just did a dictionary application in blackberry along with a speech to text conversion support .Everything is working fine. Now i wanted to disable the sound when the user needs So how can i do it programmatically .Please help me
Try this
use the flag value as reference
if flag value is true then user click on item then it will play the sound
else sound wont play and display one dialog that Do you want enable sound with two options yes or no
if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
in your list item click listener write condition as following
if(flag==true)
{
write your logic to play
}
sample code is
public class app extends UiApplication{
public static void main(String[] args) {
new app().enterEventDispatcher();
}
public app() {
pushScreen(new SampleScreen());
}
}
class SampleScreen extends MainScreen
{
static boolean flag=true;
MenuItem item=null;
public SampleScreen() {
// use the flag value as reference
// if flag value is true then user click on item then it will play the sound
// else sound wont play and display one dialog that Do you want enable sound with two options yes or no
// if user click on yes then make flag value as true and item.setText("Voice Disable"); otherwise no action means no changes in flag
// in your list item click listner write condition as following
// if(flag==true)
// {
// write your logic to play
// }
// you already implement
item=new MenuItem("Voice Disable",0,100) {
public void run() {
if(flag)
{
flag=false;
item.setText("Voice Enable");
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.inform("Voice Disable succesfully");
}
});
}else{
flag=true;
item.setText("Voice Disable");
UiApplication.getUiApplication().invokeLater(new Runnable() {
public void run() {
Dialog.inform("Voice Enable succesfully");
}
});
}
}
};
addMenuItem(item);
}
}

Resources