I have Eclipse JFace wizard with five pages. In the first, I have check buttons to select which pages are to be shown - if you check all, you will pass through the whole wizard, but you can also select only specific pages, and then only that pages will be shown.
So far, I used iterator with enum objects representing each page. I called next object of iterator in getNextPage function and its if..else cases to return certain pages in proper order. The problem is, getNextPage is called not only when Next button is pressed, but also when pageComplete event firing, etc. so iterator does not update its cursor when I want, and it ends up to fast. This is snippet of my assumption:
else if(page == FirstPage )
{
// iterator contains SelectedAction - enum objects representing pages
this.pageIterator = page.getWizardPagesList().iterator();
if(pageIterator.hasNext())
{
return selectedActionToPage(pageIterator.next());
}
}
else
{
if(pageIterator.hasNext())
{
SelectedAction action = pageIterator.next();
if(!pageIterator.hasNext())
{
// we check if current page was last one
setFinished(true);
setLastPage(selectedActionToPage(action));
}
// selectedActionToPage converts enum object to WizardPage class
return selectedActionToPage(action);
}
else if((pageIterator != null) && !pageIterator.hasNext())
{
return page;
}
}
return page;
Especially, things I want to know are:
First, is there any other way to capture Next button click? I know there is NextPressed method in WizardDialog class, but I don't know how to call its instance from my Wizard class, or WizardPage.
Second, is there other way to customize navigation through pages, to go to specified pages?
No, you should not try to intercept the Next button click that logic is private to the wizard dialog and you should not be trying to interfere with it,
You can either override the WizardPage:
public IWizardPage getNextPage()
method or you can override the Wizard
public IWizardPage getNextPage(IWizardPage page)
You may also need to override the matching getPreviousPage method. You must make your code work regardless of when the method is called. You are given the information about which is the current page, your code should use that to determine the next page.
Related
I'm testing online Game here http://slotmachinescript.com/
I want to create a test to verify if credits value is the same after page refresh
public class VerifyGameAfterRefresh extends BaseTest{
#Test(invocationCount = 1)
public void testAfterRefresh(){
GamePage gamePage = new GamePage(driver);
gamePage.isLoaded();
int times = getRandInt(2,5);
//change bet value
gamePage.clickSpinUpButton(times);
//click on spin button
gamePage.clickSpinButton(times);
int creditsValue = gamePage.getCreditsValue();
gamePage.pageRefresh();
int creditsValueAfterRefresh = gamePage.getCreditsValue();
Assert.assertEquals(creditsValue,creditsValueAfterRefresh,"Credit after refresh are not the same");
Assert.assertTrue(gamePage.getBetValue() == 1, "Bet value was not set to default");
}
}
Method to get creditsValue :
public int getCreditsValue(){
//wait.until(ExpectedConditions.
int value = Integer.parseInt(creditsValue.getText());
return value;
}
Everything works perfect until the case when after last click on spin user wins. In this case <span id="credits">value</span> value is changing dynamically, but my method does not wait till the end of the changing and grab the value at the beginning that after leads to test fail.
May I use some functionality of
wait.until(ExpectedConditions.
just to wait for my value to be stable?
Or what would you recommend?
Unfortunately there is no easy way to track whether page was refreshed or not, you could do smthn like ExpectedConditions.refreshed and ExpectedConditions.stalenessOf(WebElement). However the problem is, there is now way for webdriver to find out whether refresh already happened or it's going to happen in the future.
Best way to do it is to wait for smthn that actually changes to change, i.e. you're clicking button and see that state of button changes back and forth. Or maybe some other elements on page change? Also, be aware of the fact if page itself remains the same you may end up having StaleReferenceException in this case it'll be necessary to implement custom ExpectedCondition.
Alternatively you could try to do following things:
Wait for document.ready state
Wait for ajax state by checking jQuery.active state
I am developing an IDE. I created a CustomTab.java class by extending the default JavaFX Tab. I wanted to add a color transition animation, but I ran into a problem. The method in TabPane named getTabs(), which returns ObservableList<Tab>, is final. This means I can't override it to return ObservableList<CustomTab>. It seems that constructions like this:
for (Tab tab : tabPane.getTabs()) {
((CustomTab) tab).stopFlash();
}
used in Controller.java are neck breaking and wrong.
What is the right way to do this?
I think my reply is quiete late, but I think there is a way to do so.
Use the function
tab.setUserData(Object c);
In that Object you can store all the informations you'll need to proceed.
so for example create an Object holding all the objects you need.
E.g. you can hold the reference to your webView.
Also if you need to have different informations you could use:
tab.getProperties().put(Object key, Object data);
// receive the value with
tab.getProperties().get(key);
Here a link to the documentation I found
Maybe the Javadoc is better, but I found this one.
Here is a little example that I wrote:
public SQLEditorTab getNewTab(){
SQLEditorTab tab = new SQLEditorTab("new Tab " + number);
tab.setId("newTab" + number);
tab.setOnCloseRequest(this);
tab.setUserData(tab.tabContent);
number ++;
return tab;
} // just to create the tab
In my listener I receive the result simply by:
sqlEditorPane.getTabs().forEach((Tab t) -> {
if(t.getUserData() != null){
System.out.print(t.getUserData().getClass());
}
});
I have a GXT 3 app and I'm trying to use a ToggleButtonCell to allow the user to modify a Boolean value.
Here's the code for the data:
public class InspectionListGridData {
private Boolean posted;
public InspectionListGridData(InspectionListGridData dataToCopy) {
setPosted(dataToCopy.getPosted());
}
public Boolean getPosted() {
return posted;
}
public void setPosted(Boolean posted) {
this.posted = posted;
}
}
For the grid to access the data, I provide this property access interface:
interface ListProperties extends PropertyAccess<InspectionListGridData> {
ValueProvider<InspectionListGridData, Boolean> posted();
}
The Grid & column config are declared like this:
final ListProperties properties = GWT.create(ListProperties.class);
final List<ColumnConfig<InspectionListGridData,?>> columnConfigList = new ArrayList<ColumnConfig<InspectionListGridData,?>>();
final ListStore<InspectionListGridData> store = new ListStore<InspectionListGridData>(
new ModelKeyProvider<InspectionListGridData>() {
#Override
public String getKey(InspectionListGridData item) {
return item.getInspectionDocumentId().toString();
}
}
});
final ColumnConfig<InspectionListGridData, Boolean> postedColumnConfig = new ColumnConfig<InspectionListGridData, Boolean>(properties.posted(), 5, "Posted");
ToggleButtonCell postedButtonCell = new ToggleButtonCell();
postedButtonCell.setText("posted");
postedButtonCell.setIcon(SafedoorPM.localizedResources.postedIcon());
postedButtonCell.setIconAlign(IconAlign.TOP);
postedColumnConfig.setCell(postedButtonCell);
postedColumnConfig.setSortable(false);
columnConfigList.add(postedColumnConfig);
Grid<InspectionListGridData> inspectionListGrid = new Grid<InspectionListGridData>(store, columnModel);
When I load this screen, the buttons do not initialize to the corresponding state indicated by the data. [EDIT: the failed loading of initial values was due to a different bug. Once I fixed that the initial values loaded correctly]
Once the screen is loaded, if I click a button it changes state just fine but the store doesn't get updated. I set breakpoint on the InspectionListGridData.setPosted() method, it is not called when I click on the button.
Can anyone see what I'm doing wrong? Or am I just wrong in thinking this is supposed to just work? I thought that was the point of the ValueProvider interfaces.
Bonus extra weirdness, the grid displays the red triangle in the corner to indicate that the cell is dirty when it is clicked and button does display properly when clicked i.e. it stays down or up. It just doesn't seem to read or update the data store.
Two questions here, at first I only keyed off of the first one (which I still can't answer, but more info might help), but the second is very clear.
When I load this screen, the buttons do not initialize to the corresponding state indicated by the data.
This is confusing, and contradicted by a quick sample I put together, as I indicated in my comment It could be that you are changing the data after drawing the grid and not informing the store or grid that the data has changed, but if you are building the data with both true and false values, the grid should be displaying with both true and false values.
I set breakpoint on the InspectionListGridData.setPosted() method, it is not called when I click on the button.
By default, this is expected while store.isAutoCommmit() is true, which is the default value. This tells the store that it should queue up changes rather than applying them directly to the objects in the store. These changed values are marked in the UI with the red triangle you noticed, and other code can check for changed values through the Store.getRecord(M) method or Store.getModifiedRecords() calls. Calling store.commitChanges() will apply all of them to the underlying models, or you can commit to specific models with Record.commit(). You can also reject changes with Store.rejectChanges() or Record.revert().
When this is turned off, the setPosted method should be called by clicking the button. No change tracking can occur, so no dirty flag will be set, either visually or in the store's records.
If you change an object that is already rendered, you have two (main) choices - you can modify the object directly via its setters and inform the store, or you can use the store's record objects. If autocommit is false and you invoke store.getRecord(object).addChange(properties.posted(), true), then instead of creating a new change to be committed, this will call setPosted(true), so these methods are effectively the same when autocommit is false. If you directly call a setter, be sure to inform the store that the object has changed via store.update.
I'm trying to create a menu screen, and I want to be able to create it, and any further permutations of it dynamically. I've created a MenuItem helper class to handle the menu items that show up, and it reads the name, image, and set the next state (something that is handled later). What I want to know is, how can I create the specific following Screens (they'll all be some subclass of my Screen class)?
What is the most efficient method to pass specific objects into the menuItems? Do I need to pre-create each possible Screen and then just read back in the serialized form of it, or can I create them dynamically. I'd hoped to be able to do something as simple as reading in a literal string "new SubClass(...)" and act off that, but I don't know how to go about that. Any other suggestions would be great!
If I understand correctly, what you want is a mechanism that reads a String command from a text file, and based on this command, displays a screen.
So, extract the interface of the "display screen" command into an interface. For example:
public interface ScreenDisplayer {
void displayScreen(Screen mainScreen);
}
Then build a Map<String, ScreenDisplayer>:
map.put("screen1", new ScreenDisplayer() {
#Override
void displayScreen(Screen mainScreen) {
// TODO display screen 1
});
// same for all the other commands
And when a "menu item" is clicked, get the DisplayScreen from the map and call it:
String command = selectedMenuItem.getCommand();
ScreenDisplayer displayer = map.get(command);
displayer.displayScreen(mainScreen);
I've been using this book as reference to creating my Blackberry application. So far I have a list of items and when I select one I get the side menu but next to my list item:
Just looking through my methods, I'm not sure which one causes this as I can remove the custom item (GetValue) from the Menu and it will still appear here when I select the list item!
I guess my question is, how can I stop this menu appearing and have a method fire instead? I can provide code if necessary but I don't know where to start with this one!
Thanks
Can you show your code when invoking the method.
When I override the navigationClick method of the ListField class like in the code below it works properly. (no menu pops)
protected boolean navigationClick(int status, int time){
return true;
}
#ing0
You can override default menu by using OnMenu() method
public boolean onMenu(int i)
{
return false;
}