How to retrieve title and url of a openned com.google.gwt.user.client.Window - gwt

I opened a window with com.google.gwt.user.client.Window.open()
How to retrieve the title and URL of this new window after navigating in it ?
After openned a new window with "http://www.google.com" and searching "Stackoverflow" the title become "Stackoverflow - Google Search" and the URL change to "http://www.google.com/&q=stackoverflow"
I would like to retrieve these two informations in the parent window.
How do I do it with GWT ?
Example :
private void myMethod() {
Window.open("http://google.com", "Google")
// ... searching "Stackoverflow"
Button b1 = new Button(getTitleOfPopupWindow()); // Stackoverflow - Google Search
Button b2 = new Button(getUrlOfPopupWindow()); // http://www.google.com/&q=stackoverflow
}

Once you open a new window, it becomes a totally different window that your app cannot access - unless you have total control over its contents (i.e. it's on your domain). It would be a huge security and privacy hole if an app in one browser window/tab had access to the information in all the other windows/tabs.
You can let your users open an iFrame within your app and see where they navigate within that iFrame, if your users don't mind it.
If you have a total control over the new window, then you can insert a script in the child page to call the parent page using Window.opener. However, it looks like this is not your use case.

Related

Firefox sdk - access popup opened

I'm currently working on a Firefox addon, and I was wondering if is there any way to access pop-up, in other words a window that was open using Javascript function .open().
If I access all tabs the popups are not there, if I access all windows the popups windows are not there.
//
var allWindows = window_utils.windows(null);
//
var tabs = require('sdk/tabs');
for (let tab of tabs)
console.log(tab.title);
If you know the popup's url you can use a PageMod to detect when it loads, its url, etc.

Sahi not able to recognize popup window

My application has several popup windows opening from javascript validations. Sahi is not recognizing those. If I manually add it like
_popup("windowTitle"),
It says no such window found. The windows are not javascript popups but normal html pages opening as popups.
the exact error message is:
_popup("Error Window")._click(_button("CERRAR"));
Window/Domain not found: popupNameFromStep=Error Window; derivedName=; windowName=; windowTitle=Happy Time; wasOpened=0
Here the title it is recognizing is actually the parent window title.
What does the controller records it as? If it is a popup or a different window, the controller will record it correctly.
You can use the API _selectWindow which will use to select popup.
// switch to popWin popup window
_selectWindow("popWin");
// perform actions on popWin
_assertEqual("Link Test", _getText(_link(0))); // no mention of popWin needed
var $href;
_set($href, _link(0).href); // no mention of popWin needed
...
// switch back to base window
_selectWindow();
// perform actions on base window
For more details you can visit this link: https://sahipro.com/docs/sahi-apis/popup-windows.html#_selectWindow

Open Eclipse Welcome Page To Page Other Than "home-page-id"

I have a properly functioning Eclipse RCP program which opens the org.eclipse.ui.intro extension to a home-page-id of root.xhtml. Inside of the root.xhtml home page, there are links to other XHTML pages to offer help.
I am trying to create buttons throuhout my GUI which, when you click them, they would take you to the correct XHTML documentation page. All I can figure out so far is how to get the buttons to take me to the root.xhtml page, but I cannot figure out how to tell the intro page to navigate to a different page. Here is the code I am using now to open the intro page:
help_button.addSelectionListener(new SelectionAdapter()
{
public void widgetSelected(SelectionEvent event)
{
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run();
}
})
For example, I am trying to do something like this where the hyperlink string in quotes is exactly the same as the hyperlink in the root.xhtml file:
ActionFactory.INTRO.create(DataStore.getInstance().getCurrentWorkbenchPage().getWorkbenchWindow()).run().navigateTo("http://org.eclipse.ui.intro/showPage?id=setuplogging");
I was able to figure this out, it was rather time consuming and painful to do so - hopefully it helps someone out. At least the answer is a few lines of code.
You have to show the intro site getIntroSite() first before changing the URL otherwise you will get a null pointer exception in IntroURL. If you get the null pointer exception when calling createIntroURL(), it may have to do with an intro site not being already open in your GUI, not necessarily that your link is bad. Also, if the intro is already open, don't try to reopen it because it will change the page to the home page rather than your page identified with page_id. So, for this class, I made the help button a toggle button meaning if the intro window is open, then the button is pressed. In some cases I close the intro site if it is already open when the button is pressed (example below), in other cases I just don't update the intro site so it won't go to the home page (example not shown, but just omit the first part of the if block).
If you try the ActionFactory run() code in my question, that will display the intro site in the entire Window. I wanted the intro site to be a sub-window within the perspective, so I used the method below by setting showIntro(null, true) - true meaning don't take up the entire window (they call the Boolean standby).
The page_id corresponds to the page id setup in your documentation XML file when setting up your extension point org.eclipse.ui.intro.config content variable.
final IIntroPart
intro = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
getIntro();
if (PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
isIntroStandby(intro))
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
closeIntro(intro);
help_button.setSelection(false);
}
else
{
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().
getWorkbenchWindow().getWorkbench().getIntroManager().
showIntro(null, true).getIntroSite();
IIntroURL
introURL = IntroURLFactory.createIntroURL(
"http://org.eclipse.ui.intro/showPage?id=" + page_id);
introURL.execute();
help_button.setSelection(true);
}

How to create a "New xxx" popup?

I have a Grid object and added a [ (+) New Client ] button which I'd like to open a popup form to create the new client with a couple fields.
I've looked at the code examples in the website but haven't found how to do it (sorry if I've missed something).
This is the current page code:
function page_clients_listing($p){
$g = $p->add('Grid');
$g->addColumn('text','first_name');
$g->addColumn('text','last_name');
$g->addColumn('inline','telephone');
$g->addColumn('expander','comments');
$g->setSource('client');
$g->addButton('With Icon')->set('Add New Client')->setIcon('Plus');
}
Thanks in advance!
You can either create a popup or a dialog. Dialog is based on jQuery UI dialog implementation. Popups are likely to be blocked and are harder to control.
This is actually working for any object (you can apply to view, button, image, icon, etc), but I'll use button).
$b=$g->addButton('Add New Client')->setIcon('Plus');
$b->js('click')->univ()->frameURL($title,$url);
// OR
$b->js('click')->univ()->dialogURL($title,$url);
$url would most likely be returned by api->getDestinationURL(). The other page would be loaded and scripts on that page will be evaluated. Let's say you are on other page and now need to close the window.
$result = $this->addButton('Close')->js('click')->univ()->closeDialog();
closeDialog() returns a jQuery chain object pointing to a view which originally opened the frame. As a result if you do $result->hide(); then after dialog is closed, the original button ('add new client') will also be hidden.
Here is example to show some additional things you can do with frames, reloading and custom event handlers:
http://agiletoolkit.org/example/refresh1

replace Twitter link by Read more

In my app I have a WebView Containing a Twitter account for and every tweet there is a link take you to a specific website
my question : can I replace the links of those webpages by read more ?
You can override the link itself so that when the user clicks, instead of it jumping to that website, it calls your method.
Create an instance of UIWebViewDelegate,and implement the method:
"webView:shouldStartLoadWithRequest:navigationType:
Sent before a web view begins loading
content."
...and return "false" when the link clicked is one of those external links.
Then, also, do whatever custom action you wanted to do - e.g. popup a new UIView that contains the "read more" content you wanted to display