I am doing a JavaFx project . I have a table view which is populated by few names (e.g. BG Manager , User Management , Find Acl , ....) . Each time I click on each one of those names (or each row of that table ) it will open a new tab which is again populated with the information I set out earlier inside . Here is an example function that being called once I click on a row with the name of BG Management :
private void callBGManager(){
try {
Tab tab = new Tab ();
FXMLLoader bgm = new FXMLLoader(getClass().getResource("/views/BGMWindow.fxml"));
BGMController bgmc = new BGMController(_session);
bgm.setController(bgmc);
Parent root = bgm.load();
for (Tab tabs : TabPane1.getTabs()){
if (tabs.getText().equals(ListView1.getSelectionModel().getSelectedItem())){
SingleSelectionModel<Tab> selectionModel = TabPane1.getSelectionModel();
selectionModel.select(tab);
return;
}
}
tab.setContent(root);
tab.setText(ListView1.getSelectionModel().getSelectedItem());
tab.closableProperty().set(true);
TabPane1.setTabClosingPolicy(TabPane1.getTabClosingPolicy().SELECTED_TAB);
TabPane1.getTabs().add(tab);
SingleSelectionModel<Tab> selectionModel = TabPane1.getSelectionModel();
selectionModel.select(tab);
}catch(Exception e){
e.printStackTrace();
}
}
There is no problem in the compilation or operation of this code as it works well . Here is the scenario for the better understanding of the situation . I have lets say 5 rows in my list and every time I click on each if it's not already opened it will show up and if it's already open nothing happens . Lets say I am already in another tab view and the BG Manager is already open . How can I shift to BG Manager once I click re-click on it :)
Hello Danial u can use (row)cell.setUserData(); and by deafult set for each true value. And onClick on this row(cell) you should to check this data (row)cell.getUserData(); and if it is true than change it to false and open window in another case do nothing.
EXAMPLE:
table.setRowFactory( tv -> {
TableRow<MyType> row = new TableRow<>();
row.setOnMouseClicked(event ->{
boolean result = (boolean) row.getUserData();
if(result){
row.setUserData(false);
//There will be your method to open new window
methodToOpenNewWindow(row);
}else{
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information");
alert.setContentText("This entity already was opened.");
alert.show();
}
});
return row ;
});
In method methodToOpenNewWindow on close window set row userData back to true .
Related
I try the new Shell of Xamarin Form 4 for a small project.
I have a list of order, then someone chooses an order and start picking some inventory for this order with barcode. To be simple, I use 2 views and 2 viewmodel.
The process is:
1. User select an order the click a button "pickup"
2. I use ViewModelLocator (TinyIoc) to resolve the correct ViewModel of the pickup view
3. I call Initialize on the new ViewModel and pass some parameters needed. Like a list of items needed to be pickup.
4. Open the view in modal state.
I don't understand that if I change some qty in the list I pass on the second viewmodel, then hit the back button (modal view close). The quantity changed is now in the original viewmodel. How this is possible? I was thinking that passing parameter to a function do not share the same variable but just copy it??
Viewmodel of the first view (look at the Initialize function the List passed and the JobEnCours object)
private async Task GoPickup()
{
Device.BeginInvokeOnMainThread(async () =>
{
if (this.CodeJob != null && this.CodeJob != "")
{
this.IsBusy = true;
PrepChariotSP3ViewModel vm = ViewModelLocator.Resolve<PrepChariotSP3ViewModel>();
await vm.InitializeAsync(this._jobEnCours, this.ComposantesPick.ToList()) ;
await Shell.Current.Navigation.PushAsync(new PrepChariotSP3Page(vm));
this.IsBusy = false;
}
});
}
the the Initialize code on the second Viewmodel (look I set the JobEnCours.Description=Test)
public async Task InitialiseAsync(Job jobEnCours, List<ComposantePick> composantePick)
{
Title = "Ceuillette: " + jobEnCours.CodeProd;
this._jobEnCours = jobEnCours;
this.ComposantesPick = new ItemsChangeObservableCollection<ComposantePick>();
foreach(ComposantePick c in composantePick)
{
this.ComposantesPick.Add(c);
}
jobEnCours.Description = "test";
So, If I do the back button, then in the first VM the JobEnCours.Description is now set to "test" how this is possible?!
Any idea?
I have my test method in a test class. I use Coded UI.
Everything I tested so far seems good. Now I want to await a Ajax call on clicking the Save button, but I don't know how.
Is it possible to do that? And if my Ajax response is above 500ms the test should fail.
This is my sample class:
[TestInitialize]
public void TestInitialize()
{
string serviceName = "xxxxxxx.exe";
var binPath = Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory)));
string servicePath = #"\ServiceProjects\vvvvvv\bin\Debug\";
string absolutePath = String.Format("{0}{1}{2}", binPath, servicePath, serviceName);
Process.Start(absolutePath);
BrowserWindow.CurrentBrowser = "ie";
BrowserWindow.Launch(baseAddress);
}
[TestMethod]
public void ManagerTestMethod()
{
this.UIMap.ManagerTestMethod_MobilePrefix();
}
[TestCleanup]
public void TestCleanup()
{
this.UIMap.TestCleanup();
}
And in this ManagerTestMethod_MobilePrefix() method I click on the save button:
public void ManagerTestMethod_MobilePrefix()
{
#region Variable Declarations
HtmlDiv uISljedećizahtjevNoPane = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument.UISljedećizahtjevNoPane;
HtmlButton uIItemButton = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument.UIItemButton;
HtmlCustom uIItemCustom = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument1.UIŠifarniciCustom.UIItemCustom;
HtmlHyperlink uIMobilniprefiksHyperlink = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument1.UICodelistsSubMenuCustom.UIMobilniprefiksHyperlink;
HtmlDiv uIItemPane = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UIAps_mng_mobilephonepPane.UIItemPane;
HtmlSpan uIItemPane1 = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UIAps_mng_mobilephonepPane.UIItemPane1;
HtmlEdit uIApsmngmobilephonepreEdit = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UIApsmngmobilephonepreEdit;
HtmlEdit uIApsmngmobilephonepreEdit1 = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UIApsmngmobilephonepreEdit1;
HtmlEdit uIApsmngmobilephonepreEdit2 = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UIApsmngmobilephonepreEdit2;
HtmlButton uISačuvatiButton = this.UIAddikoAPSInternetExpWindow.UIAddikoAPSDocument2.UISačuvatiButton;
#endregion
// Click '+ Sljedeći zahtjev + No' pane
Mouse.Click(uISljedećizahtjevNoPane, new Point(1651, 234));
// Click '+ Sljedeći zahtjev + No' pane
Mouse.Click(uISljedećizahtjevNoPane, new Point(1778, 308));
// Click '+' button
Mouse.Click(uIItemButton, new Point(51, 23));
// Click custom control
Mouse.Click(uIItemCustom, new Point(48, 30));
// Click 'Mobilni prefiks' link
Mouse.Click(uIMobilniprefiksHyperlink, new Point(87, 18));
// Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
Playback.PlaybackSettings.ContinueOnError = true;
// Mouse hover pane at (1, 1)
Mouse.Hover(uIItemPane, new Point(1, 1));
// Reset flag to ensure that play back stops if there is an error.
Playback.PlaybackSettings.ContinueOnError = false;
// Click pane
Mouse.Click(uIItemPane1, new Point(6, 5));
// Type 'test1' in 'aps.mng.mobilephoneprefix.details.Code' text box
uIApsmngmobilephonepreEdit.Text = this.ManagerTestMethod_MobilePrefixParams.UIApsmngmobilephonepreEditText;
// Type '{Tab}' in 'aps.mng.mobilephoneprefix.details.Code' text box
Keyboard.SendKeys(uIApsmngmobilephonepreEdit, this.ManagerTestMethod_MobilePrefixParams.UIApsmngmobilephonepreEditSendKeys, ModifierKeys.None);
// Type 'test1' in 'aps.mng.mobilephoneprefix.details.CoreCode' text box
uIApsmngmobilephonepreEdit1.Text = this.ManagerTestMethod_MobilePrefixParams.UIApsmngmobilephonepreEdit1Text;
// Type '100' in 'aps.mng.mobilephoneprefix.details.Value' text box
uIApsmngmobilephonepreEdit2.Text = this.ManagerTestMethod_MobilePrefixParams.UIApsmngmobilephonepreEdit2Text;
// Click 'Sačuvati' button
Mouse.Click(uISačuvatiButton, new Point(52, 20));
}
The last step is crucial to me: Mouse.Click(uISačuvatiButton, new Point(52, 20)); in that step I am doing a Ajax call to my API controller in order to insert the data.
I want to be able to catch validations from my form, also I want to be able to catch the response from the Ajax call that is triggered by clicking on the save button.
I may have a idea you could try. I never had a situation like yours, so I can't confirm it will work.
You could provide a hidden control on that form with a value that will only be set if the Ajax call is completed. If you are able to find that control with your Coded UI test, you could run a timer for 500ms after clicking that save button.
So, I'm trying to delete the highlighted row in TableView in my program.
I've looked at loads of tutorials online, but really can't get my head around this.
I have followed the example from CodeMakery, which is in Eclipse, but I'm unable to get it to work on IntelliJ (because of some apparent JDK problems?)
This is the code from CodeMakery:
private void handleDeletePerson() {
int selectedIndex = personTable.getSelectionModel().getSelectedIndex();
if (selectedIndex >= 0) {
personTable.getItems().remove(selectedIndex);
} else {
// Nothing selected.
Alert alert = new Alert(AlertType.WARNING);
alert.initOwner(mainApp.getPrimaryStage());
alert.setTitle("No Selection");
alert.setHeaderText("No Person Selected");
alert.setContentText("Please select a person in the table.");
alert.showAndWait();
}
}
Could you please help me understand how to make selected row get deleted?
just add at the beginning of this method personTable.setEditable(true). Should work now.
I have a problem with my KendoGrid.
I have some commands in the last Column of my Grid. One of them calls up a delete function, in which a new KendoWindow opens up.
And now i need to display the Computer name (which is a field of the grid) of this row in the window.
In the delete function I tried to get the Data by:
function delete() {
var grid = $("#grid").data("kendoGrid");
var selectedRow = grid.selectedRow();
var data = this.dataItem(selectedRow);
var ComputerName = data.ComputerName;
//initialize and open window
.
.
};
And to show it in the window I tried an ASP data-bind:
Computername:<span id="ComputerName" data-bind="text: ComputerName"></span>
But it doesnt work.
I am new to this topic, so please apologize if my idea doesn't make any sense :D
Use the activate event of the window to actually bind the content of the window to that dataItem (called data in your case);
$('#windowName').data().kendoWindow.bind('activate',function(e){
kendo.bind(this.element,kendo.observable(data))
})
I am trying to switch to a New window which gets displayed when I click on the Debt Pricing Template. But I am unable to do that as a result of which I am not able to proceed with further scripting... The problem is I am not able to know what should I pass in the switchTo.window() because Pricing Approval Gateway window displays and following is the HTML for the new window:
<*h1 class="pageType noSecondHeader">Pricing Approval Gateway<*/h1>
Following is the code:
LoginPage2.driver.findElement(By.linkText("TEST ORG")).click();
System.out.println("3.Select Dept pricing template button from the organization detail page.");
if(LoginPage2.driver.findElement(By.name("debt_pricing_template")).isDisplayed())
System.out.println("User should able to navigate to Dept pricing template and template display few question, user have answer these question for further navigation.");
LoginPage2.driver.findElement(By.name("debt_pricing_template")).click();
LoginPage2.driver.manage().timeouts().implicitlyWait(100, TimeUnit.SECONDS);
LoginPage2.driver.switchTo().window("bPageTitle");
Please advise what needs to be added?
I never used it because in my tests I am not using any new windows, but this should help:
Set<string> handlers = driver.getWindowHandles();
if (driver.getWindowHandles().size()>= 1){
for(String handler : handlers){
driver.switchTo().window(handler);
if (driver.getElement(By.tagName("h1")).contains("Pricing")){
System.out.println("Get focus on Popup window");
break;
}
}
}
else System.out.println("No windows founded!");
I am not quite sure with the h1 approach. So if it does not help, try before opening new window storing current window to String:
String mainWindow = driver.getWindowHandle();
Then click the link (or do something else as you are doing now) to open new window. Then to switch to the new window:
Set<string> handlers = driver.getWindowHandles();
for (String handler : handlers){
if (!handler.equals(mainWindow)){
driver.switchTo(handler);
break;
}
}
And then to switch back to original window just do:
driver.switchTo(mainWindow);
Ofcourse the driver variable is expected live instance of
WebDriver
driver.findElement(By.linkText("Go to Billing Summary")).click();
driver.findElement(By.linkText("01 Mar 2016")).click();
Thread.sleep(5000);
driver.findElement(By.linkText("AMS TAX")).click();
driver.findElement(By.linkText("00842")).click();
Set<String> instancewindow= driver.getWindowHandles();
Iterator<String> it = instancewindow.iterator();
String parent =it.next();
String child = it.next();
driver.switchTo().window(child);
driver.switchTo().frame("modalSubWindow");
driver.findElement(By.linkText("View More Vehicle Details>>")).click();
driver.switchTo().window(parent);