List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow ModalWindow
public ModalWindow(final String id)
From source file:org.wicketstuff.mbeanview.AttributeValuesPanel.java
License:Apache License
public AttributeValuesPanel(String id, final IModel<MBeanServer> server, final ObjectName objectName, MBeanAttributeInfo[] beanAttributeInfos) { super(id, server); add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form);/*from w w w.j a va2s . c o m*/ ListView<MBeanAttributeInfo> attributes = new ListView<MBeanAttributeInfo>("attributes", Arrays.asList(beanAttributeInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanAttributeInfo> item) { final MBeanAttributeInfo info = item.getModelObject(); item.add(new Label("name", info.getName())); final AttributeModel model = new AttributeModel(server, objectName, info) { @Override protected void onError(Throwable throwable) { item.error(throwable.toString()); } }; AjaxLink<Void> link = new AjaxLink<Void>("value") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), model)); modalOutput.setTitle(info.getName()); modalOutput.show(target); } @Override public boolean isEnabled() { return model.getObject() instanceof Collection || model.getObject() != null && model.getObject().getClass().isArray(); } @Override public boolean isVisible() { return !info.isWritable(); } }; item.add(link); link.add(new Label("label", model)); item.add(new TextField<Object>("editableValue", model, Object.class) { private static final long serialVersionUID = 1L; @Override public boolean isVisible() { return info.isWritable(); } @Override public <C> IConverter<C> getConverter(Class<C> type) { return new ValueConverter(item.getModelObject().getType()); } }); item.add(new FencedFeedbackPanel("feedback", item)); } }; attributes.setReuseItems(true); form.add(attributes); form.add(new Button("submit")); }
From source file:org.wicketstuff.mbeanview.OperationsPanel.java
License:Apache License
public OperationsPanel(String id, final IModel<MBeanServer> server, final ObjectName objectName, MBeanOperationInfo[] beanOperationInfos) { super(id);// ww w . ja v a 2 s. c o m this.objectName = objectName; add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setTitle("Operation result view."); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form); ListView<MBeanOperationInfo> operations = new ListView<MBeanOperationInfo>("operations", Arrays.asList(beanOperationInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanOperationInfo> item) { final MBeanOperationInfo info = item.getModelObject(); String returnLbl = info.getReturnType(); try { Class<?> c = Class.forName(info.getReturnType()); if (c.isArray()) { returnLbl = c.getComponentType().getSimpleName() + "[]"; } else { returnLbl = c.getSimpleName(); } } catch (ClassNotFoundException e) { } item.add(new Label("return", returnLbl)); IModel<Object[]> values = Model.of(new Object[info.getSignature().length]); ParameterRepeater parameterRepeater = new ParameterRepeater("parameters", info.getSignature(), values); item.add(parameterRepeater); final FencedFeedbackPanel feedback = new FencedFeedbackPanel("feedback", item); feedback.setOutputMarkupId(true); item.add(feedback); item.add(new OperationButton("method", server, info, values) { private static final long serialVersionUID = 1L; @Override protected void onFailure(Exception e, AjaxRequestTarget target) { List<String> returnList = new ArrayList<String>(); returnList.add(e.getMessage()); StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); returnList.add(sw.toString()); modalOutput.setTitle("Failure"); modalOutput.setContent( new DataViewPanel(modalOutput.getContentId(), Model.ofList(returnList))); modalOutput.show(target); } @Override protected void onSuccess(Object returnObj, AjaxRequestTarget target) { if (returnObj == null) { item.info("Success"); target.add(feedback); } else { modalOutput.setTitle("Success"); modalOutput.setContent(new DataViewPanel(modalOutput.getContentId(), Model.of((Serializable) returnObj))); modalOutput.show(target); } } }); } }; operations.setReuseItems(true); form.add(operations); }
From source file:org.wicketstuff.mbeanview.OperationsPanel2.java
License:Apache License
public OperationsPanel2(String id, final ObjectName objectName, MBeanOperationInfo[] beanOperationInfos, final MbeanServerLocator beanServerLocator) { super(id);//from w ww .j av a 2s . c o m this.beanServerLocator = beanServerLocator; this.objectName = objectName; add(modalOutput = new ModalWindow("modalOutput")); modalOutput.setTitle("Operation result view."); modalOutput.setCookieName("modalOutput"); Form<Void> form = new Form<Void>("form"); add(form); ListView<MBeanOperationInfo> operations = new ListView<MBeanOperationInfo>("operations", Arrays.asList(beanOperationInfos)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(final ListItem<MBeanOperationInfo> item) { final MBeanOperationInfo info = item.getModelObject(); String returnLbl = info.getReturnType(); try { Class<?> c = Class.forName(info.getReturnType()); if (c.isArray()) { returnLbl = c.getComponentType().getSimpleName() + "[]"; } else { returnLbl = c.getSimpleName(); } } catch (ClassNotFoundException e) { } item.add(new Label("return", returnLbl)); final ParameterRepeater parameterRepeater = new ParameterRepeater("parameters", info.getSignature()); item.add(parameterRepeater); final FeedbackPanel feedback = new ComponentFeedbackPanel("feedback", item); feedback.setOutputMarkupId(true); item.add(feedback); item.add(new OperationButton("method", parameterRepeater, info) { private static final long serialVersionUID = 1L; @Override protected void onSuccessful(Object returnObj, AjaxRequestTarget target) { if (returnObj == null) { item.info("Successful call"); target.add(feedback); } } }); } }; form.add(operations); }
From source file:org.wicketstuff.mbeanview.panels.OperationsPanel.java
License:Apache License
public OperationsPanel(final String id, final MBeanOperationInfo[] operations) { super(id);/* w w w.j a va 2 s. c o m*/ this.add(this.newOperationsList("operation", operations)); this.add(this.operationOutput = new ModalWindow("output")); }
From source file:org.wicketstuff.mbeanview.panels.ResultPanel.java
License:Apache License
public ResultPanel(final String id, final Object result, Class<?> resultType, final boolean outline, final boolean editable) { super(id);/* www . j a va 2s . c o m*/ this.result = result; this.resultType = resultType; this.outline = outline; this.editable = editable; this.add((this.detailWindow = new ModalWindow("detail")).setVisibilityAllowed(this.outline)); this.add(this.resultContainer(result, resultType)); }
From source file:org.wicketTutorial.modalwindow.HomePage.java
License:Apache License
public HomePage(final PageParameters parameters) { super(parameters); final ModalWindow modalWindow = new ModalWindow("modalWindow"); Label label = new Label(modalWindow.getContentId(), "I'm a modal window!"); modalWindow.setContent(label);//www . j av a2s . c o m modalWindow.setTitle("Modal window"); add(modalWindow); add(new AjaxLink("openWindow") { @Override public void onClick(AjaxRequestTarget target) { modalWindow.show(target); } }); }
From source file:ro.fortsoft.wicket.pivot.web.PivotAreaPanel.java
License:Apache License
public PivotAreaPanel(String id, PivotField.Area area) { super(id);/*from w w w .j ava 2s. c o m*/ this.area = area; modal = new ModalWindow("modal"); modal.setAutoSize(true); add(modal); add(new Label("name", new ResourceModel(area.getName()))); WebMarkupContainer fieldsContainer = new WebMarkupContainer("fieldsContainer"); fieldsContainer.setOutputMarkupId(true); fieldsContainer.setMarkupId("area-" + area.getName() + "-" + getSession().nextSequenceValue()); add(fieldsContainer); fieldsView = new ListView<PivotField>("fields") { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<PivotField> item) { final IModel<PivotField> itemModel = item.getModel(); final PivotField pivotField = itemModel.getObject(); final PivotField.Area area = PivotAreaPanel.this.area; Label fieldLabel = new Label("field", new AbstractReadOnlyModel<String>() { private static final long serialVersionUID = 1L; @Override public String getObject() { String title = pivotField.getTitle(); if (area.equals(PivotField.Area.DATA)) { title += " (" + pivotField.getCalculationDescription() + ")"; } return title; } }); if (pivotField.isNumber()) { item.add(AttributeModifier.append("class", "field-number")); } // add field actions panel if (!area.equals(PivotField.Area.UNUSED)) { PivotFieldActionsPanel pivotFieldActionsPanel = new PivotFieldActionsPanel("dropDownPanel", Model.of(pivotField), Model.of(getPivotModel())); pivotFieldActionsPanel.setRenderBodyOnly(true); item.add(pivotFieldActionsPanel); String markupId = "dropdown-" + pivotField.getIndex(); pivotFieldActionsPanel.get("dropdown").setMarkupId(markupId); fieldLabel.add(AttributeModifier.append("data-dropdown", "#" + markupId)); } else { item.add(new EmptyPanel("dropDownPanel").setVisible(false)); } item.add(fieldLabel); item.setOutputMarkupId(true); item.setMarkupId("field-" + pivotField.getIndex()); } }; fieldsView.setOutputMarkupPlaceholderTag(true); fieldsContainer.add(fieldsView); setOutputMarkupId(true); }
From source file:ro.fortsoft.wicket.pivot.web.PivotPanel.java
License:Apache License
@Override protected void onInitialize() { super.onInitialize(); // create a pivot model pivotModel = createPivotModel(getModelObject()); // create pivot field action factory pivotFieldActionsFactory = createPivotFieldActionsFactory(); pivotModel.calculate();//from ww w. j a v a 2s .c om areasContainer = new WebMarkupContainer("areas"); areasContainer.setOutputMarkupId(true); add(areasContainer); RepeatingView areaRepeater = new RepeatingView("area"); areasContainer.add(areaRepeater); List<PivotField.Area> areas = PivotField.Area.getValues(); for (PivotField.Area area : areas) { areaRepeater.add(new PivotAreaPanel(areaRepeater.newChildId(), area)); } pivotTable = createPivotTabel("pivotTable", pivotModel); add(pivotTable); modal = new ModalWindow("modal"); modal.setAutoSize(true); add(modal); AjaxLink<Void> configStoreButton = new AjaxLink<Void>("configStoreButton") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { modal.setTitle("Configuration"); modal.setContent( new PivotConfigStoragePanel(ModalWindow.CONTENT_ID, pivotModel, pivotConfigStorage)); modal.setAutoSize(true); modal.show(target); modal.setWindowClosedCallback(new WindowClosedCallback() { private static final long serialVersionUID = 1L; @Override public void onClose(AjaxRequestTarget target) { target.add(PivotPanel.this); if (pivotModel.isAutoCalculate()) compute(target); computeLink.setVisible(!pivotModel.isAutoCalculate()); } }); } @Override public boolean isVisible() { return super.isVisible() && pivotConfigStorage != null; } }; add(configStoreButton); AjaxCheckBox showGrandTotalForColumnCheckBox = new AjaxCheckBox("showGrandTotalForColumn", new PropertyModel<Boolean>(this, "pivotModel.showGrandTotalForColumn")) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (pivotModel.isAutoCalculate()) { compute(target); } } }; add(showGrandTotalForColumnCheckBox); AjaxCheckBox showGrandTotalForRowCheckBox = new AjaxCheckBox("showGrandTotalForRow", new PropertyModel<Boolean>(this, "pivotModel.showGrandTotalForRow")) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { if (pivotModel.isAutoCalculate()) { compute(target); } } }; add(showGrandTotalForRowCheckBox); AjaxCheckBox autoCalculateCheckBox = new AjaxCheckBox("autoCalculate", new PropertyModel<Boolean>(this, "pivotModel.autoCalculate")) { private static final long serialVersionUID = 1L; @Override protected void onUpdate(AjaxRequestTarget target) { computeLink.setVisible(!pivotModel.isAutoCalculate()); target.add(computeLink); if (pivotModel.isAutoCalculate() && !pivotTable.isVisible()) { compute(target); } } }; add(autoCalculateCheckBox); computeLink = new IndicatingAjaxLink<Void>("compute") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { compute(target); } /* * @Override public boolean isEnabled() { return verify(); } */ }; computeLink.setOutputMarkupPlaceholderTag(true); computeLink.add(AttributeModifier.append("class", new ButtonCssClassModel())); computeLink.setVisible(!pivotModel.isAutoCalculate()); add(computeLink); downloadContainer = new WebMarkupContainer("downloadContainer"); downloadContainer.setOutputMarkupPlaceholderTag(true); downloadContainer.setVisible(pivotTable.isVisible() && (pivotExporters.length > 0)); add(downloadContainer); RepeatingView downloadExports = new RepeatingView("downloadExport"); downloadContainer.add(downloadExports); for (final PivotExporter exporter : pivotExporters) { Link<Void> downloadLink = new Link<Void>(downloadExports.newChildId()) { private static final long serialVersionUID = 1L; @Override public void onClick() { pivotModel.calculate(); ByteArrayOutputStream out = new ByteArrayOutputStream(); try { exporter.exportPivot(getPivotModel(), out); } catch (IOException e) { throw new RuntimeException(e); } ResourceRequestHandler downloadHandler = new ResourceRequestHandler( new ByteArrayResource(exporter.getFormatMimetype(), out.toByteArray(), pivotExportFilename + "." + exporter.getFilenameExtension()), null); RequestCycle.get().scheduleRequestHandlerAfterCurrent(downloadHandler); } }; downloadExports.add(downloadLink); IModel<String> resourceModel = new StringResourceModel("downloadAs", downloadLink, Model.of(exporter.getFormatName())); downloadLink.add(new Label("label", resourceModel)); downloadLink.setOutputMarkupPlaceholderTag(true); downloadLink.add(AttributeModifier.append("class", new ButtonCssClassModel())); } add(new PivotResourcesBehavior()); if (pivotModel.isAutoCalculate()) { compute(null); } setOutputMarkupId(true); }
From source file:ro.nextreports.server.web.core.BasePage.java
License:Apache License
public BasePage(PageParameters parameters) { super(parameters); headerPanel = new HeaderPanel("headerPanel"); headerPanel.setRenderBodyOnly(true); add(headerPanel);//from w w w.j a v a2 s .co m footerPanel = new FooterPanel("footerPanel"); footerPanel.setRenderBodyOnly(true); add(footerPanel); add(new AjaxBusyIndicator()); dialog = new ModalWindow("dialog"); add(dialog); }
From source file:ro.nextreports.server.web.core.HeaderPanel.java
License:Apache License
public HeaderPanel(String id) { super(id);/*w ww . j a v a2 s . c o m*/ final WebMarkupContainer imageContainer = new WebMarkupContainer("imageContainer"); imageContainer.setOutputMarkupPlaceholderTag(true); imageContainer.add(new Image("logoImage", new LogoResource())); add(imageContainer); add(new Label("currentUser", NextServerSession.get().getUsername())); add(new Label("realName", NextServerSession.get().getRealName())); final ModalWindow dialog = new ModalWindow("modal"); add(dialog); Link<String> logoutLink = new Link<String>("logout") { private static final long serialVersionUID = 1L; @Override public void onClick() { NextServerSession.get().signOut(); if (CasUtil.isCasUsed()) { setResponsePage(new RedirectPage(CasUtil.getLogoutUrl())); } else { setResponsePage(getApplication().getHomePage()); } } }; add(logoutLink); AjaxLink<String> changePassword = new AjaxLink<String>("changePassord") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { dialog.setTitle(getString("ChangePassword.change")); dialog.setInitialWidth(350); dialog.setUseInitialHeight(false); dialog.setContent(new ChangePasswordPanel(dialog.getContentId()) { private static final long serialVersionUID = 1L; @Override public void onChange(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); try { User loggedUser = securityService.getUserByName(NextServerSession.get().getUsername()); loggedUser.setPassword(passwordEncoder.encodePassword(confirmPassword, null)); storageService.modifyEntity(loggedUser); } catch (Exception e) { e.printStackTrace(); add(new AlertBehavior(e.getMessage())); target.add(this); } } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } }); dialog.show(target); } }; add(changePassword); if (NextServerSession.get().isDemo()) { changePassword.setEnabled(false); } }