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

org.dominokit.domino.ui.dialogs.MessageDialog Maven / Gradle / Ivy

/*
 * Copyright © 2019 Dominokit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.dominokit.domino.ui.dialogs;

import static java.util.Objects.nonNull;
import static org.jboss.elemento.Elements.div;

import elemental2.dom.HTMLDivElement;
import elemental2.dom.HTMLElement;
import elemental2.dom.Node;
import java.util.function.Supplier;
import org.dominokit.domino.ui.Typography.Paragraph;
import org.dominokit.domino.ui.animations.Animation;
import org.dominokit.domino.ui.animations.Transition;
import org.dominokit.domino.ui.button.Button;
import org.dominokit.domino.ui.icons.BaseIcon;
import org.dominokit.domino.ui.icons.Icons;
import org.dominokit.domino.ui.modals.BaseModal;
import org.dominokit.domino.ui.style.Color;
import org.dominokit.domino.ui.style.Style;
import org.dominokit.domino.ui.utils.DominoElement;
import org.jboss.elemento.EventType;
import org.jboss.elemento.IsElement;

/**
 * A component to show message dialogs to the user with ability to make him take actions from those
 * dialogs
 *
 * 
 *     MessageDialog.createMessage(
 *         "Here\'s a message!", () -> Notification.create("Dialog closed").show();
 * 
*/ public class MessageDialog extends BaseModal { private DominoElement iconContainer = DominoElement.of(div()); private DominoElement icon; private Color iconColorStart; private Color iconColorEnd; private Transition iconStartTransition; private Transition iconEndTransition; private Button okButton; /** Creates a new instance */ public MessageDialog() { init(this); } /** * Creates an instance and initialize it with custom content * * @param content {@link Node} * @return new instance */ public static MessageDialog createMessage(Node content) { return createMessage(content, () -> {}); } /** * Creates an instance and initialize it with custom content and an Ok action button * * @param content {@link Node} * @param okButtonProvider {@link Supplier} of {@link Button} for the ok action * @return new instance */ public static MessageDialog createMessage(Node content, Supplier




© 2015 - 2025 Weber Informatics LLC | Privacy Policy