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

com.alkacon.geranium.client.util.StyleSaver 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.util;

import java.util.HashMap;
import java.util.Map;

import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style;

/**
 * This is a utility class for saving and restoring CSS style properties of a DOM element.

*/ public class StyleSaver { /** The element for which the CSS style properties are saved. */ private Element m_element; /** The values of the saved style properties. */ private Map m_propertyValues = new HashMap(); /** * Creates a new instance for an element and saves some of its style properties.

* * @param elem the DOM element * @param properties the style properties to save */ public StyleSaver(Element elem, String... properties) { m_element = elem; Style style = elem.getStyle(); for (String prop : properties) { String val = style.getProperty(prop); m_propertyValues.put(prop, val); } } /** * Restores all saved style properties on this instance's DOM element.

*/ public void restore() { Style style = m_element.getStyle(); for (Map.Entry entry : m_propertyValues.entrySet()) { style.setProperty(entry.getKey(), entry.getValue()); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy