onConsoleMessage() only returns first Console - android-webview

Here's my code
webV.setWebChromeClient(new WebChromeClient(){
#Override
public void onConsoleMessage(String message, int line, String ID){
textView.append("\n"+message+" at line "+Integer.toString(line));
}
});
So, it returns console message to the TextView but unfortunately I only get the first console log. Where I've did two error in js myself to test. How can I get the rests.
Notice
I've searched in Google & SO but didn't found methods that can help me or my search query wasn't clear enough.

Related

TestNG Optional Parameters are being initialized as "not-found" despite specifying default values on Eclipse

Here is a fragment of my code:
#Test
#Parameters({"author","searchKey"})
public void testParameterWithXML(#Optional("You") String author, String searchKey) throws InterruptedException {
System.out.println(author);
Upon running this, the output of the first print statement is "not-found" even though I have set a default value (You) for it.
Can someone please explain why?

How do I get to use Model1.foo instead of Model1.edmx, and invoke IModelConversionExtension callbacks

I have a VSIX and a associated MEF DLL using IModelConversionExtension Class as per the documentation, and a pkgdef file setting up .foo as an extension to invoke the EF Designer.
[PartCreationPolicy(CreationPolicy.Shared)]
[Export(typeof(IModelConversionExtension))]
[ModelFileExtension(".foo")]
public class MyConversionCallback : IModelConversionExtension
{
public void OnAfterFileLoaded(ModelConversionExtensionContext context)
{
//How does this get called?
return;
}
public void OnBeforeFileSaved(ModelConversionExtensionContext context)
{
//How does this get called?
return;
}
}
[$RootKey$\Editors\{c99aea30-8e36-4515-b76f-496f5a48a6aa}\Extensions]
"foo"=dword:00000032
[$RootKey$\Projects]
[$RootKey$\Projects\{F184B08F-C81C-45F6-A57F-5ABD9991F28F}]
[$RootKey$\Projects\{F184B08F-C81C-45F6-A57F-5ABD9991F28F}\RelatedFiles]
[$RootKey$\Projects\{F184B08F-C81C-45F6-A57F-5ABD9991F28F}\RelatedFiles\.foo]
".diagram"=dword:00000002
[$RootKey$\Projects]
[$RootKey$\Projects\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}]
[$RootKey$\Projects\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\RelatedFiles]
[$RootKey$\Projects\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\RelatedFiles\.foo]
".diagram"=dword:00000002
I can get both the similar Transform and Generation MEF Classes to work fine.
And my Model1.foo does invoke the EF Designer, but
1. OnAfterFileLoaded and OnBeforeFileSaved never fire, and
2. I get an error message when I try to save Model1.foo, which says to see errors in the Error List but there are none.
What am not doing to get this to work.
Thanks
OnAfterFileLoaded is supposed to be invoked if you load a file whose extension is different than edmx and the IEntityDesignerConversionData.FileExtension returns a value that matches your extension. OnBeforeFileSaved works the opposite way - on save. However - I looked at code in this area today and concluded that it actually cannot work. I filed a work item for this: https://entityframework.codeplex.com/workitem/1371

GWT JSNI method call failing, but there are no errors

I'm trying to implement Mozilla's Persona in a GWT App. Here's part of the code from a dummy app I set up to test it:
public class OpenId implements EntryPoint {
private native void callWatch(String email)
/*-{
$wnd.navigator.id.watch({
loggedInUser: email,
onlogin: function(assertion){
$wnd.alert("Calling method");
this.#com.gallup.openid.client.OpenId::processLogin(Ljava/lang/String;)(assertion);
$wnd.alert("Called Java Method");
},
onlogout: function(){alert("Logged Out!");}
});
}-*/;
private void processLogin(String assertion){
Window.alert("Logged in!");
personaStatus.setText("Log In Complete.");
}
}
When I call the callWatch method, only the "Calling method" alert box shows up. Neither of the other ones are ever called. So for some reason the code appears to be stopping at the JSNI call right below the first alert. But there are no errors in Dev Mode.
I don't understand why the processLogin method doesn't get called.
I thought I followed Google's Documentation correctly.
I did try writing
this.#com.gallup.openid.client.OpenId::processLogin(Ljava/lang/String;)(assertion);
as OpenID.#... and instance.#... due to this post.
I'm not sure what else to try.
The variable this points to the function that immediately surrounds it, which is in this case your onlogin JavaScript function. You need to use a temporary that variable (a typical JavaScript idiom, by the way)
private native void callWatch(String email)
/*-{
var that = this;
...
onlogin: function(assertion){
that.#com...
And then, ideally use $entry(...), so you will see error messages, if you have registered an UncaughtExceptionHandler.
See also: https://stackoverflow.com/a/5235580/291741

SWTbot tests not behaving as expected

So I'm testing an eclipse plugin with SWTbot and I'm not getting the result I'm expect - when I cut the test down it turns out that the problem isn't with the bot it's with some code that I've copied accross from another part of the program (where it was fully functional)
The following code...
#RunWith(SWTBotJunit4ClassRunner.class)
public class Tests {
private static SWTWorkbenchBot bot;
#BeforeClass
public static void beforeClass() throws Exception {
bot = new SWTWorkbenchBot();
bot.viewByTitle("Welcome").close();
}
#Test
public void maybeThisWillWork(){
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
System.out.println("A");
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
System.out.println("B");
}
#AfterClass
public static void sleep() {
System.out.println("In the sleep function");
bot.sleep(10000);
}
}
Gives me the output -
A
In the sleep function
Rather than the expected
A
B
In the sleep function
Any ideas?
you may need to run your test as JUnit plugin test. Have you tried that?
So it turns out that the answer is thus (also a nice advantage of stackoverflow is that I actually solved this somewhere else, remembered I'd had a similar problem and then had to come back to stackoverflow to remind myself of the details)
SWTBot isn't running in the UI thread proper hence the null pointer errors, what I had to do was use effectively:
Display display = bot.getDisplay();
display.syncExec(objectThatdoesthethingiwanttogetdoneintheUIthread);
System.out.println(objectThatdoesthethingiwanttogetdoneintheUIthread.results);
...and that got things working...

Fundamental GWT asynchronous call misunderstanding

I seem to be suffering from some fundamental misunderstanding of the way that GWT async calls work and/or how widgets are updated upon receipt of a callback.
I've created the two interfaces as well as the implementation and they seem to be communicating with one another. I make this claim based on reasonable looking data observed while stepping through with the eclipse debugger: the result variable in the onSuccess method below contains what I expect it to and the grid that I am attempting to populate ends up being filled with the data from results upon exit from the loop. However when the onSuccess call returns, no grid is displayed in my GUI as per the uhpScrollPanel.setWidget(uhpGrid) call, and no exceptions of any sort are thrown.
I must be be overlooking something obvious, has anyone got any ideas about where to look?
final ScrollPanel uhpScrollPanel = new ScrollPanel();
uhpVert.add(uhpScrollPanel);
uhpScrollPanel.setSize("100%", "100%");
//build and populate grid
UpdateHistoryServiceAsync uhpService = UpdateHistoryService.Util.getInstance();
uhpService.getUpdateHistory(new AsyncCallback<List<UpdateHistoryEntryBean>>() {
public void onFailure(Throwable caught) {
System.out.println("OnFailure");
caught.printStackTrace();
final Label uhpErrorLabel = new Label("Server Unable to Grab History...");
uhpScrollPanel.setWidget(uhpErrorLabel);
uhpErrorLabel.setSize("100%", "100%");
}
public void onSuccess(List<UpdateHistoryEntryBean> result) {
int length = result.size();
final Grid uhpGrid = new Grid();
uhpScrollPanel.setWidget(uhpGrid);
uhpGrid.setBorderWidth(1);
uhpGrid.setSize("100%", "100%");
uhpGrid.resize(length, 3);
int i = 0;
for (UpdateHistoryEntryBean entry : result) {
uhpGrid.setText(i, 0, String.valueOf(entry.getSourceId()));
uhpGrid.setText(i, 1, entry.getTitle());
uhpGrid.setText(i, 2, entry.getBody());
i++;
}
}
});
Your onSuccess() method is not defined correctly, as a parameter it receives an Object, and you must downcast it afterwards.
Meaning, the signature should be:
public void onSuccess(Object result)
After that, you can explicitly downcast the object you know you got back like so:
List<UpdateHistoryEntryBean> resultList = (List<UpdateHistoryEntryBean>) result;
Well it turns out that the quick fix is to add the grid to a VerticalPanel rather than a ScrollPanel. The question now becomes - why should that matter, and how do we get around this dilemma?