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

org.opencms.gwt.client.ui.CmsDialogNotificationWidget Maven / Gradle / Ivy

Go to download

OpenCms is 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: 18.0
Show newest version
/*
 * This library is part of OpenCms -
 * the Open Source Content Management System
 *
 * 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
 *
 * For further information about OpenCms, please see the
 * project website: http://www.opencms.org
 * 
 * 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 org.opencms.gwt.client.ui;

import org.opencms.gwt.client.ui.CmsNotification.Type;
import org.opencms.gwt.client.ui.css.I_CmsLayoutBundle;
import org.opencms.gwt.client.util.CmsFadeAnimation;

import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.ui.Widget;

/**
 * The toolbar notification widget.

* * @since 8.0.0 */ public class CmsDialogNotificationWidget extends A_CmsNotificationWidget { // TODO: improve for dialog /** * @see com.google.gwt.uibinder.client.UiBinder */ protected interface I_CmsNotificationWidgetUiBinder extends UiBinder { // GWT interface, nothing to do here } /** The ui-binder instance for this class. */ private static I_CmsNotificationWidgetUiBinder uiBinder = GWT.create(I_CmsNotificationWidgetUiBinder.class); /** The message. */ @UiField protected Element m_container; /** The message. */ @UiField protected Element m_message; /** * Constructor.

*/ public CmsDialogNotificationWidget() { initWidget(uiBinder.createAndBindUi(this)); restore(); } /** * @see org.opencms.gwt.client.ui.I_CmsNotificationWidget#setBlocking() */ public void setBlocking() { getElement().addClassName(I_CmsLayoutBundle.INSTANCE.notificationCss().blocking()); } /** * @see org.opencms.gwt.client.ui.A_CmsNotificationWidget#animateHide() */ @Override protected void animateHide() { setAnimation(CmsFadeAnimation.fadeOut(getElement(), new Command() { /** * @see com.google.gwt.user.client.Command#execute() */ public void execute() { onHideComplete(); } }, 200)); } /** * @see org.opencms.gwt.client.ui.A_CmsNotificationWidget#animateShow() */ @Override protected void animateShow() { getElement().getStyle().clearDisplay(); setAnimation(CmsFadeAnimation.fadeIn(getElement(), new Command() { /** * @see com.google.gwt.user.client.Command#execute() */ public void execute() { onShowComplete(); } }, 200)); } /** * @see org.opencms.gwt.client.ui.A_CmsNotificationWidget#getMessage() */ @Override protected String getMessage() { return m_message.getInnerHTML(); } /** * Should be called by the hide animation on complete.

*/ @Override protected void onHideComplete() { setAnimation(null); restore(); } /** * Should be called by the show animation on complete.

*/ @Override protected void onShowComplete() { setAnimation(null); } /** * @see org.opencms.gwt.client.ui.A_CmsNotificationWidget#setClassForType(org.opencms.gwt.client.ui.CmsNotification.Type) */ @Override protected void setClassForType(Type type) { if (type == null) { return; } // set the right class getElement().addClassName(classForType(type)); } /** * @see org.opencms.gwt.client.ui.A_CmsNotificationWidget#setMessage(java.lang.String) */ @Override protected void setMessage(String message) { m_message.setInnerHTML(message); } /** * Returns the class name for the given type.

* * @param type the type * * @return the class name */ private String classForType(Type type) { switch (type) { case ERROR: return I_CmsLayoutBundle.INSTANCE.notificationCss().notificationError(); case NORMAL: return I_CmsLayoutBundle.INSTANCE.notificationCss().notificationNormal(); case WARNING: return I_CmsLayoutBundle.INSTANCE.notificationCss().notificationWarning(); default: return null; } } /** * Restores the initial state.

*/ private void restore() { setVisible(false); // back to plain style without error or warning getElement().setClassName(""); m_container.setClassName(I_CmsLayoutBundle.INSTANCE.notificationCss().notificationContainer()); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy