All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alkacon.geranium.client.ui.input.FramePopup Maven / Gradle / Ivy

Go to download

A GWT UI framework. This component is used as a part of OpenCms, an enterprise-ready, easy to use website content management system based on Java and XML technology. Offering a complete set of features, OpenCms helps content managers worldwide to create and maintain beautiful websites fast and efficiently.

There is a newer version: 2.1
Show newest version
/*
 * This library is part of Geranium -
 * an open source UI library for GWT.
 *
 * Copyright (c) Alkacon Software GmbH (http://www.alkacon.com)-
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * For further information about Alkacon Software, please see the
 * company website: http://www.alkacon.com
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

package com.alkacon.geranium.client.ui.input;

import com.alkacon.geranium.client.ui.Popup;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.user.client.ui.Frame;

/**
 * This class represents a popup which displays an IFrame.

* * It also exports a Javascript function to close the popup when given the id of the popup.

*/ public class FramePopup extends Popup { /** The handler which is called when the popup closes itself. */ protected Runnable m_closeHandler; /** The iframe for the popup content. */ Frame m_frame; /** The id of this popup. */ private String m_id; /** * Constructor.

* * @param title the title of the popup dialog * @param url the URL which should be opened in the popup */ public FramePopup(String title, String url) { super(title); m_frame = new Frame(); add(m_frame); m_frame.setUrl(url); } /** * @see com.alkacon.geranium.client.ui.Popup#center() */ @Override public void center() { exportCloseFunction(); super.center(); } /** * Returns the frame contained in this popup.

* * @return a frame */ public Frame getFrame() { return m_frame; } /** * Hide the popup, but only after the current event has been processed.

*/ public void hideDelayed() { // The reason for using this function, instead of calling hide directly, is that // the latter leads to harmless but annoying Javascript errors when called from // Javascript inside the IFrame, since the IFrame is closed before the function returns. Scheduler.get().scheduleDeferred(new ScheduledCommand() { /** * @see com.google.gwt.core.client.Scheduler.ScheduledCommand#execute() */ public void execute() { if (m_closeHandler != null) { m_closeHandler.run(); } hide(); } }); } /** * Sets the handler which should be called when the popup closes itself.

* * @param closeHandler the "close" handler */ public void setCloseHandler(Runnable closeHandler) { m_closeHandler = closeHandler; } /** * Sets the id of this IFrame popup.

* * The popup can be closed by calling the cmsCloseDialog Javascript function with the same id as a parameter.

* * @param id the new id */ public void setId(String id) { m_id = id; } /** * @see com.alkacon.geranium.client.ui.Popup#show() */ @Override public void show() { exportCloseFunction(); super.show(); } /** * Exports a Javascript function 'cmsCloseDialog', which, when passed the id of a CmsFramePopup as a parameter, will close that dialog.

*/ protected native void exportCloseFunction() /*-{ var w = $wnd; w.CmsFramePopup_instances = w.CmsFramePopup_instances || {}; // register the current instance under its id w.CmsFramePopup_instances[[email protected]::m_id] = this; if (!w.cmsCloseDialog) { w.cmsCloseDialog = function(arg) { var instance = w.CmsFramePopup_instances[arg]; [email protected]::hideDelayed()(); // remove current instance delete w.CmsFramePopup_instances[[email protected]::m_id]; } // cmsCloseDialog } // if }-*/; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy