Skip to content

Commit

Permalink
Merge branch 'new-modal-dialog'
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jul 15, 2021
2 parents 05622ed + b431f9d commit d6b2cde
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
import org.apache.wicket.devutils.debugbar.DebugBar;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.feedback.FeedbackMessage;
import org.apache.wicket.feedback.FeedbackMessages;
import org.apache.wicket.injection.Injector;
Expand Down Expand Up @@ -1001,10 +1000,8 @@ public String getObject() {
feedbackContainer.add(feedbackList);

MainPopupDialog mainPopup = new MainPopupDialog(ID_MAIN_POPUP);
mainPopup.setOutputMarkupId(true);
mainPopup.setOutputMarkupPlaceholderTag(true);
mainPopup.showUnloadConfirmation(false);
mainPopup.setResizable(false);
// mainPopup.showUnloadConfirmation(false);
// mainPopup.setResizable(false);
add(mainPopup);
}

Expand Down Expand Up @@ -1035,20 +1032,22 @@ public MainPopupDialog getMainPopup() {
}

public String getMainPopupBodyId() {
return getMainPopup().getContentId();
return getMainPopup().CONTENT_ID;
}

public void showMainPopup(Popupable popupable, AjaxRequestTarget target) {
getMainPopup().setTitle(popupable.getTitle());
getMainPopup().setInitialHeight(popupable.getHeight());
getMainPopup().setInitialWidth(popupable.getWidth());
getMainPopup().setHeightUnit(popupable.getHeightUnit());
getMainPopup().setWidthUnit(popupable.getWidthUnit());
getMainPopup().setContent(popupable.getComponent());
getMainPopup().setUseInitialHeight(true);
getMainPopup().setResizable(false);
getMainPopup().setMaskType(ModalWindow.MaskType.TRANSPARENT);
getMainPopup().show(target);
// getMainPopup().setTitle(popupable.getTitle());
// getMainPopup().setInitialHeight(popupable.getHeight());
// getMainPopup().setInitialWidth(popupable.getWidth());
// getMainPopup().setHeightUnit(popupable.getHeightUnit());
MainPopupDialog dialog = getMainPopup();
dialog.getDialogComponent().add(AttributeModifier.replace("style", dialog.generateWidthHeightParameter("" + popupable.getWidth(),
popupable.getWidthUnit(), "" + popupable.getHeight(), popupable.getHeightUnit())));
dialog.setContent(popupable.getComponent());
// getMainPopup().setUseInitialHeight(true);
// getMainPopup().setResizable(false);
// getMainPopup().setMaskType(ModalWindow.MaskType.TRANSPARENT);
dialog.open(target);
}

public void hideMainPopup(AjaxRequestTarget target) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,107 +7,47 @@

package com.evolveum.midpoint.web.component.dialog;

import org.apache.commons.lang3.StringUtils;
import org.apache.wicket.Component;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.core.request.handler.IPartialPageRequestHandler;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalWindow;
import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.model.Model;
import org.apache.wicket.util.string.AppendingStringBuffer;
import org.apache.wicket.extensions.ajax.markup.html.modal.ModalDialog;
import org.apache.wicket.extensions.ajax.markup.html.modal.theme.DefaultTheme;

/**
* @author Viliam Repan (lazyman)
* @author katkav
*/
public class MainPopupDialog extends ModalWindow {
public class MainPopupDialog extends ModalDialog {
private static final long serialVersionUID = 1L;

private static final String ID_MAIN_POPUP_BODY = "popupBody";

private boolean initialized;

public MainPopupDialog(String id) {
super(id);
}

// @Override
// protected void onInitialize() {
// super.onInitialize();
// setCssClassName(ModalWindow.CSS_CLASS_GRAY);
// showUnloadConfirmation(false);
// setResizable(false);
// setInitialWidth(350);
// setInitialHeight(150);
// setWidthUnit("px");
//
// setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean onCloseButtonClicked(AjaxRequestTarget target) {
// return true;
// }
// });
//
// setWindowClosedCallback(new ModalWindow.WindowClosedCallback() {
// private static final long serialVersionUID = 1L;
//
// @Override
// public void onClose(AjaxRequestTarget target) {
// MainPopupDialog.this.close(target);
// }
// });
//
// WebMarkupContainer content = new WebMarkupContainer(getContentId());
// content.setOutputMarkupId(true);
// content.setOutputMarkupPlaceholderTag(true);
// setContent(content);
//
// setOutputMarkupId(true);
// }
//
// @Override
// protected void onBeforeRender(){
// super.onBeforeRender();
//
// if(initialized){
// return;
// }
//
// Label initLabel = new Label(ID_MAIN_POPUP_BODY, new Model<>("Not initialized"));
// initLabel.setOutputMarkupPlaceholderTag(true);
// initLabel.setOutputMarkupId(true);
// setBody(initLabel);
// initialized = true;
// }
//
// private void setBody(Component component){
// WebMarkupContainer content = (WebMarkupContainer) get(getContentId());
// component.setOutputMarkupId(true);
// component.setOutputMarkupPlaceholderTag(true);
// content.setOutputMarkupPlaceholderTag(true);
// content.setOutputMarkupId(true);
// content.addOrReplace(component);
// }
//
// public void setBody(Popupable popupable){
// setTitle(popupable.getTitle());
// setInitialHeight(popupable.getHeight());
// setInitialWidth(popupable.getWidth());
// setHeightUnit(popupable.getHeightUnit());
// setWidthUnit(popupable.getWidthUnit());
// WebMarkupContainer content = (WebMarkupContainer) get(getContentId());
// content.setOutputMarkupPlaceholderTag(true);
// content.setOutputMarkupId(true);
// Component component = popupable.getComponent();
// component.setOutputMarkupId(true);
// component.setOutputMarkupPlaceholderTag(true);
// content.addOrReplace(component);
// }


@Override
protected void onInitialize() {
super.onInitialize();
setOutputMarkupId(true);
add(new DefaultTheme());
trapFocus();
setOutputMarkupPlaceholderTag(true);
}

public Component getDialogComponent() {
return get("overlay").get("dialog");
}

public String generateWidthHeightParameter(String width, String widthUnit, String height, String heightUnit) {
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotEmpty(width)) {
sb.append("width: " + width);
sb.append(StringUtils.isEmpty(widthUnit) ? "px" : widthUnit);
sb.append("; ");
}
// if (StringUtils.isNotEmpty(height)) {
// sb.append("height: " + height);
// sb.append(StringUtils.isEmpty(heightUnit) ? "px" : heightUnit);
// sb.append("; ");
// }
return sb.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -465,15 +465,16 @@ protected void okPerformed(AjaxRequestTarget target) {
};
testConnectionPanel.setOutputMarkupId(true);

getMainPopup().setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
private static final long serialVersionUID = 1L;

@Override
public boolean onCloseButtonClicked(AjaxRequestTarget target) {
refreshStatus(target);
return true;
}
});
//TODO fix
// getMainPopup().setCloseButtonCallback(new ModalWindow.CloseButtonCallback() {
// private static final long serialVersionUID = 1L;
//
// @Override
// public boolean onCloseButtonClicked(AjaxRequestTarget target) {
// refreshStatus(target);
// return true;
// }
// });

showMainPopup(testConnectionPanel, target);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ span.tree-content > table tr td:first-child {
}
}

.modal-dialog-content {
margin: 15px;
}


.manager-tools { // org tree manager buttons: HACK, need to figure out something better
float: right;
Expand Down

0 comments on commit d6b2cde

Please sign in to comment.