Validator in ControlsFX Wizard last page - java

Is there any way of adding a Validator to the last page in ControlsFX Wizards?
I am currently using the following on the last page :
public void onEnteringPage(Wizard wizard) {
wizard.getValidationSupport().registerValidator(cb,
Validator.createEmptyValidator("The instance field is mandatory"));
But since this is the last page I am still able to click finish when the cb(choice box) is empty.

I had the same problem.
I think this is due to a bug in version 8.40.9 of ControlsFX where they forgot to check the FINISH Button against the invalid property, too.
Look here in the Issue Issue 521 at line 633. They have added the necessary call. Just wait for the next update, when the issue will be merged.
For a quick and dirty workaround just add another pane to your wizard. With a text "Finished" for example, because on the "next" buttons the validation works.

Related

How to "handle" an alert as per UnhandledAlertException?

This topic is sadly very poisoned by non-applying answers, e.g. 1, 2, 3, 4, etc. pp.
The issue:
One may do an action which, when successful, makes the website raise an alert.
E.g. click on a "logout" button to see an "Are you sure you want to logout?" alert:
public class Logout extends PageObject {
static final Target LOGOUT = /* logout button, which will display the alert when clicked */;
public Performable logout() {
return Task.where("{0} clicks on Logout"
, Ensure.that(LOGOUT).isDisplayed()
, Click.on(LOGOUT) // done manually: alert visible; done by Serenity: no alert
);
}
}
Serenity will cause an org.openqa.selenium.UnhandledAlertException during execution of Click.on and the alert will not be present after this task. If the next task would be "interact with alert" in any way or form (as done in all the linked articles and all others I have perused before posting this question), the next task will then always fail because there is no alert .
This can be easily observed in the browser window as well: The alert may show, if at all, for but a split second and immediately disappear.
The question:
Given that the alert has to be handled before the action causing it completes: How do I do that?
N.b.:
I have done a deeper analysis in this old bug report. Includes a call stack where one may place breakpoints inbetween the alert's appearance and disappearance.
Others have indicated that it is an issue pertaining to chromedriver - but using a different framework with the same chromedriver works just fine.
A workaround might be to disable screenshots, but
I do not want to do that!
Serenity indicates (via a log warning) that this is a user error. So I'd rather correct my error than work around it.

JavaFX: How to check if page available or not

In my project I use simple JavaFX browser, that works in background and do some stuff without displaying it.
More precisely it submitted some form to one online page.
So, I ran into a problem: when this page doesn't available, I can't figure it out from my Java code, it looks like form wasn't submitted and clicks on Submit button do nothing, but in Chrome for example I see that the page isn't available.
So, is there an option to check from Java code if page is available?
Thanks in advance and sorry for bad English.
So, I found an answer.
There is Worker class in JavaFX that associates with WebEngine and it has a field with State type.
State is enum that has 6 options:
READY
SCHEDULED
RUNNING
SUCCEEDED
CANCELLED
FAILED
So State.FAILED can be used for handling errors.
For example, something like that (we'll assume we have WebEngine instance):
webEngine.getLoadWorker().stateProperty().addListener((observable, oldState, newState) -> {
if (newState == Worker.State.FAILED) {
doOnError();
return;
}
doOnSuccess();
});
webEndgine.load("example.com");
So, every time state is changed ObservableValue#changed will be called with new State value as one of parameteres and if state become FAILED we do some error processing.

Handle Logout Button Action of JavaFX Application

Here is part of my code that shows error. This is done inside public void start method. I have already done the Login part, whenever user logs in the id and password remains in the TextField. Which is why I have created a logout button so that when user clicks on it, I want the useridtextfield & passwordtextfield to be empty.
LogoutButton.setOnAction(e->
UserIdTextField==null;
PasswordTextField==null;);
I have searched over the internet about this problem but got no solution regarding JavaFX Logout handling. I have no idea about FXML so I would appreciate any help.
The syntax for a lambda expression with multiple statements is
logoutButton.setOnAction(e -> {
/* statements */
});
(I.e. you need to delimit the statements with { ... }.)
As pointed out in the comments, comparing the text fields to null is probably not what you want to do here, but it will at least compile.

How to set seperate global action handler for multiple instance of eclipse form based plugin editor

I am working on eclipse form based editor. I have given support of handling of Undo Redo and dirty flag to my editor.Both of these feature working fine for single instances of plugin. Problem is coming when i open it with 2 or more files (2 or more instances of eclipse plugin). Now, undo redo starts working weird. They work only for instances that is opened at last.
for eg: Suppose my editor supports '.xeb' file. if i open test1.xeb and test2.xeb files one by one using with my editor. then undo redo only works for instances that is opened for test2.xeb file. If i switch back to other instances, then undo redo of first instance gets appear.
i have below entries in my editor's plugin.xml:
<plugin><extension
point="org.eclipse.ui.editors">
<editor
class="Testeditor"
default="true"
extensions="xeb"
icon="icons/sample.gif"
id="testeditor"
name="editor">
</editor>
</plugin>
i debugged the code and found that this weird behavior is happening due to handling of global action in wrong way.I used below code to set global action handler:
public void setUndoRedoActionHandlers() {
final IActionBars actionBars = getEditorSite().getActionBars();
actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(),
mUndoAction);
actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(),
mRedoAction);
actionBars.updateActionBars();
}
i went through some links related to this issue. but couldn't understood the concept to implement this behavior.
http://wiki.eclipse.org/FAQ_How_do_I_find_out_what_view_or_editor_is_selected%3F
http://wiki.eclipse.org/FAQ_How_do_I_hook_into_global_actions,_such_as_Copy_and_Delete%3F
Can any one look into this issue. Thanks in advance.
only override the setFocus() method of MultiPageEditorPart in you editor class and call the appropriate method of setting the global action handler,like this way:
#Override
public void setFocus() {
switch (getActivePage()) {
case 0:
pageOne.setUndoRedoActionHandlers();
break;
case 1:
pageTwo.setUndoRedoActionHandlers();
break;
}
super.setFocus();
}

Eclipse: Ctrl+Shift+Right is incorrect

Consider this simple class:
package net.zomis.test;
public class Test {
public Test() {
}
public void registerSomething(String key) {
}
}
When I have the cursor placed right before registerSomething and pressing CtrlShift→, I'm used to Eclipse only selecting register at first. But now, it selects the entire registerSomething text, when I press it again it selects the entire method (from public void to }), when I press it again it selects the entire class, and the last time the entire file is selected. The exactly same thing happens if I press CtrlShift←.
Also, when I simply click the End key, I get an option to choose: Line End or Text End.
What has gone wrong in my settings for this to happen? Where can I find these keybindings?
If it matters, I have this workspace within my Dropbox-folder to synchronize it between my PC and Mac.
Turns our that the fact that I had the workspace in my Dropbox folder matters a lot. Note to everybody else: Do not share your workspace between computers. How I solved this is the following:
Create a new workspace on each computer
In the computer-specific workspace, import projects from your shared Dropbox/other folder
I noticed that when having a shared workspace on the computers, the Mac somehow changed the key-bindings to the Mac-version, which made them not work on the PC. The correct Ctrl+Shift+→ key-binding on Mac is Alt+Shift+→.
So by using a separate workspace on each computer, I can use that computer's specific key-bindings, without mixing them up.
Open the preferences dialog from the Main Menu: Window->Preferences.
In the dialog, open General->Keys. You'll see a table of keybindings, with a field with type filter text. In that field, type: Ctrl+Shift+Right, and you'll narrow the table down to this key.
The behavior that you expect - only register is selected with the first keypress - is the behavior that I see when using Ctrl+Shift+Right, and the keybinding for me is: Select Next Word.
There is a Restore Command button that should reset this binding if it has been changed.

Categories

Resources