List of usage examples for org.apache.wicket.extensions.ajax.markup.html.modal ModalWindow getContentId
public String getContentId()
From source file:ro.nextreports.server.web.dashboard.WidgetPopupMenuModel.java
License:Apache License
private AjaxLink createEditLink(final IModel<Widget> model) { AjaxLink<Void> editLink = new AjaxLink<Void>(MenuPanel.LINK_ID) { @Override/*from w ww . j av a 2 s .c o m*/ public void onClick(AjaxRequestTarget target) { final Widget widget = model.getObject(); final ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(new StringResourceModel("WidgetPopupMenu.editSettings", null).getString()); dialog.setUseInitialHeight(false); dialog.setOutputMarkupId(true); final WidgetRuntimeModel runtimeModel; final ParameterRuntimePanel paramRuntimePanel; final EntityWidget entityWidget = (EntityWidget) widget; String userDataPath = WidgetUtil.getUserWidgetParametersPath(ServerUtil.getUsername()) + "/" + entityWidget.getId(); UserWidgetParameters wp = null; try { String dashboardId = getDashboardId(entityWidget.getId()); String owner = dashboardService.getDashboardOwner(dashboardId); String user = ServerUtil.getUsername(); boolean isDashboardLink = !owner.equals(user); boolean hasWrite = securityService.hasPermissionsById(user, PermissionUtil.getWrite(), dashboardId); if (isDashboardLink && !hasWrite) { wp = (UserWidgetParameters) storageService.getEntity(userDataPath); } } catch (NotFoundException e) { // nothing to do Log.info("There is no UserWidgetParameters for : " + userDataPath); System.out.println("----> NOT FOUND"); } final UserWidgetParameters fwp = wp; runtimeModel = ChartUtil.getRuntimeModel(storageService.getSettings(), entityWidget, reportService, dataSourceService, true, fwp); if ((widget instanceof ChartWidget) || ((widget instanceof DrillDownWidget) && (((DrillDownWidget) widget).getEntity() instanceof Chart))) { Chart chart = (Chart) entityWidget.getEntity(); paramRuntimePanel = new ChartRuntimePanel("chartRuntimePanel", chart, runtimeModel); } else if ((widget instanceof TableWidget) || ((widget instanceof DrillDownWidget) && (((DrillDownWidget) widget).getEntity() instanceof Report))) { paramRuntimePanel = new TableWidgetRuntimePanel("chartRuntimePanel", entityWidget.getEntity(), runtimeModel); } else { paramRuntimePanel = new GeneralWidgetRuntimePanel("chartRuntimePanel", entityWidget.getEntity(), runtimeModel); } boolean isDynamic = false; if (paramRuntimePanel instanceof DynamicParameterRuntimePanel) { if (((DynamicParameterRuntimePanel) paramRuntimePanel).hasDynamicParameter()) { isDynamic = true; } } if (paramRuntimePanel.hasPalette()) { if (isDynamic) { dialog.setInitialWidth(720); } else { dialog.setInitialWidth(685); } } else { if (isDynamic) { dialog.setInitialWidth(445); } else { dialog.setInitialWidth(435); } } final Component component = this; dialog.setContent(new WidgetSettingsPanel(dialog.getContentId(), paramRuntimePanel) { private static final long serialVersionUID = 1L; @Override public void onChange(AjaxRequestTarget target) { changeSettings(getFeedbackPanel(), component, widget, runtimeModel, target); } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } @Override public void onReset(AjaxRequestTarget target) { resetSettings(getFeedbackPanel(), component, widget, target); } }); dialog.show(target); } // @Override // public boolean isVisible() { // return hasWritePermission(model.getObject()); // } }; return editLink; }
From source file:ro.nextreports.server.web.dashboard.WidgetPopupMenuModel.java
License:Apache License
private AjaxLink createEmbedCodeLink(final IModel<Widget> model) { AjaxLink<Void> link = new AjaxLink<Void>(MenuPanel.LINK_ID) { private static final long serialVersionUID = 1L; @Override/*from w ww.ja va 2s . co m*/ public void onClick(AjaxRequestTarget target) { final Widget widget = model.getObject(); ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(new StringResourceModel("WidgetPopupMenu.embeddedCode", null).getString()); dialog.setInitialWidth(550); dialog.setUseInitialHeight(false); dialog.setContent(new WidgetEmbedCodePanel(dialog.getContentId(), widget.getId())); dialog.show(target); } }; return link; }
From source file:ro.nextreports.server.web.dashboard.WidgetPopupMenuModel.java
License:Apache License
private AjaxLink createMoveLink(final IModel<Widget> model) { AjaxLink<Void> moveLink = new AjaxLink<Void>(MenuPanel.LINK_ID) { @Override/*from w ww . j a va 2 s . c o m*/ public void onClick(AjaxRequestTarget target) { final Widget widget = model.getObject(); ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(new StringResourceModel("WidgetPopupMenu.copyMoveWidget", null).getString()); dialog.setInitialWidth(300); dialog.setUseInitialHeight(false); final Component component = this; dialog.setContent(new SelectDashboardPanel(dialog.getContentId()) { private static final long serialVersionUID = 1L; @Override public void onAction(String toDashboardId, boolean move, AjaxRequestTarget target) { try { int column = dashboardService.getWidgetColumn(widget.getId()); if (move) { dashboardService.moveWidget(DashboardUtil.getSelectedDashboardId(), toDashboardId, widget.getId()); DashboardColumnPanel columnPanel = component.findParent(DashboardPanel.class) .getColumnPanel(column); target.add(component.findParent(DashboardColumnPanel.class)); target.add(columnPanel); } else { dashboardService.copyWidget(DashboardUtil.getSelectedDashboardId(), toDashboardId, widget.getId()); } } catch (NotFoundException e) { e.printStackTrace(); // should never happen } finally { ModalWindow.closeCurrent(target); } } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } }); dialog.show(target); } @Override public boolean isVisible() { return hasWritePermission(model.getObject()); } }; return moveLink; }
From source file:ro.nextreports.server.web.pivot.PivotAreaPanel.java
License:Apache License
public PivotAreaPanel(String id, PivotField.Area area) { super(id);/*from w w w . j a v a2s. c o m*/ this.area = area; add(new Label("name", getString("pivot." + area.getName()).toUpperCase())); final ModalWindow modal = new ModalWindow("modal"); modal.setTitle(getString("pivot.aggregator")); add(modal); WebMarkupContainer fieldsContainer = new WebMarkupContainer("fieldsContainer"); fieldsContainer.setOutputMarkupId(true); fieldsContainer.setMarkupId("area-" + area.getName() + "-" + getSession().nextSequenceValue()); add(fieldsContainer); values = new ListView<PivotField>("values") { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<PivotField> item) { final IModel<PivotField> itemModel = item.getModel(); PivotField pivotField = itemModel.getObject(); String title = pivotField.getTitle(); if (pivotField.getArea().equals(PivotField.Area.DATA)) { title += " (" + pivotField.getAggregator().getFunction().toUpperCase() + ")"; } Label valueLabel = new Label("value", title); if (pivotField.isNumber()) { valueLabel.add(AttributeModifier.append("class", "label-info")); // } else { // valueLabel.add(AttributeModifier.append("class", "label-important")); } if (item.getModelObject().getArea().equals(PivotField.Area.DATA)) { valueLabel.add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; protected void onEvent(AjaxRequestTarget target) { final AggregatorPanel panel = new AggregatorPanel(modal.getContentId(), itemModel); modal.setUseInitialHeight(false); modal.setInitialWidth(200); modal.setContent(panel); /* modal.setWindowClosedCallback(new WindowClosedCallback() { private static final long serialVersionUID = 1L; public void onClose(AjaxRequestTarget target) { if (panel.isOkPressed()) { System.out.println(">>> " + itemModel.getObject().getAggregator()); } } }); */ modal.show(target); } }); valueLabel.add(AttributeModifier.append("style", "cursor: pointer;")); } item.add(valueLabel); item.setOutputMarkupId(true); item.setMarkupId("field-" + pivotField.getIndex()); } }; values.setOutputMarkupPlaceholderTag(true); fieldsContainer.add(values); // add dnd support // addSortableBehavior(); setOutputMarkupId(true); }
From source file:ro.nextreports.server.web.report.RunHistoryPanel.java
License:Apache License
protected List<IColumn<RunReportHistory, String>> createHistoryTableColumns() { List<IColumn<RunReportHistory, String>> columns = new ArrayList<IColumn<RunReportHistory, String>>(); columns.add(new AbstractColumn<RunReportHistory, String>( new Model<String>(getString("ActionContributor.EditParameters.parameterSelect"))) { public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { try { if (securityService.hasPermissionsById(ServerUtil.getUsername(), PermissionUtil.getDelete(), rowModel.getObject().getId())) { item.add(new CheckBoxPanel(componentId, rowModel, item)); } else { item.add(new Label(componentId)); }//from w w w .j a v a 2 s . c o m item.add(new AttributeModifier("width", "30px")); } catch (Exception e) { e.printStackTrace(); } } @Override public Component getHeader(String s) { return new CheckBoxHeaderPanel(s); } }); columns.add(new PropertyColumn<RunReportHistory, String>(new Model<String>(getString("Report")), "path", "path") { @Override public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { String path = rowModel.getObject().getPath(); String relativePath = path.substring(StorageConstants.REPORTS_ROOT.length(), path.indexOf("/runHistory")); String name = StorageUtil.getName(relativePath); Label label = new Label(componentId, name); label.add(new SimpleTooltipBehavior(relativePath)); item.add(label); } }); columns.add(new AbstractColumn<RunReportHistory, String>( new Model<String>(getString("ActionContributor.DataSource.url"))) { public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, final IModel<RunReportHistory> rowModel) { String url = rowModel.getObject().getUrl(); if ((url == null) || url.equals("")) { item.add(new Label(componentId)); return; } else if (url.equals(ReportConstants.ETL_FORMAT)) { item.add(new Label(componentId, Model.of(url))); return; } // dynamic url String fileName = url.substring(url.lastIndexOf("/") + 1); String dynamicUrl = reportService.getReportURL(fileName); item.add(new SimpleLink(componentId, dynamicUrl, getString("view"), true)); } }); columns.add(new PropertyColumn<RunReportHistory, String>( new Model<String>(getString("DashboardNavigationPanel.owner")), "runnerId", "runnerId") { @Override protected IModel<?> createLabelModel(IModel<RunReportHistory> rowModel) { try { // TODO optimization (getNameByUUID - no entity creation) Entity entity = storageService.getEntityById(rowModel.getObject().getRunnerId()); String owner; if (entity instanceof User) { owner = entity.getName(); } else { //SchedulerJob owner = entity.getCreatedBy(); } return new Model<String>(owner); } catch (NotFoundException ex) { // if user or scheduler was deleted return new Model<String>(); } } }); columns.add(new PropertyColumn<RunReportHistory, String>( new Model<String>(getString("ActionContributor.RunHistory.type")), "runnerType", "runnerType") { @Override public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { item.add(new Label(componentId, getString("MonitorPanel.runnerType." + rowModel.getObject().getRunnerType()))); } }); columns.add(new DateColumn<RunReportHistory>(new Model<String>(getString("startDate")), "startDate", "startDate")); columns.add(new PropertyColumn<RunReportHistory, String>(new Model<String>(getString("duration")), "duration", "duration") { @Override public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { super.populateItem(item, componentId, rowModel); item.add(new AttributeModifier("width", "70px")); } @Override protected IModel<?> createLabelModel(IModel<RunReportHistory> rowModel) { int runTime = rowModel.getObject().getDuration(); String text = ""; if (runTime >= 0) { DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm:ss").withZone(DateTimeZone.UTC); text = formatter.print(runTime * 1000); } return new Model<String>(text); } }); columns.add( new DateColumn<RunReportHistory>(new Model<String>(getString("endDate")), "endDate", "endDate")); columns.add(new ImageLinkPropertyColumn<RunReportHistory>(new Model<String>(getString("Query"))) { @Override public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { super.populateItem(item, componentId, rowModel); item.add(new AttributeModifier("width", "50px")); item.add(new SimpleTooltipBehavior(getString("Query"))); } @Override public void onImageClick(RunReportHistory runHistory, AjaxRequestTarget target) { ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(getString("Query")); dialog.setInitialWidth(600); dialog.setInitialHeight(400); dialog.setContent(new RunHistoryQueryPanel(dialog.getContentId(), runHistory)); dialog.show(target); } @Override public String getLinkImageName() { return "sql.png"; } }); columns.add(new BooleanImageLinkPropertyColumn<RunReportHistory>(new Model<String>(getString("success")), "success", "success") { @Override public void populateItem(Item<ICellPopulator<RunReportHistory>> item, String componentId, IModel<RunReportHistory> rowModel) { super.populateItem(item, componentId, rowModel); item.add(new AttributeModifier("width", "50px")); item.add(new SimpleTooltipBehavior(getString("details"))); } @Override public void onImageClick(RunReportHistory runHistory, AjaxRequestTarget target) { ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(getString("details")); dialog.setInitialWidth(350); dialog.setInitialHeight(200); dialog.setContent(new RunHistoryDetailPanel(dialog.getContentId(), runHistory)); dialog.show(target); } }); return columns; }
From source file:ro.nextreports.server.web.schedule.TemplatePanel.java
License:Apache License
private void init() { validator = createValidator();/*from w w w . ja v a2s . c o m*/ add(new Label("templateLabel", getString("ActionContributor.Run.template.name"))); ChoiceRenderer<ReportRuntimeTemplate> nameRenderer = new ChoiceRenderer<ReportRuntimeTemplate>("name") { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(ReportRuntimeTemplate template) { if (template == null) { return getString("nullValid"); } return template.getName(); } }; final DropDownChoice<ReportRuntimeTemplate> templateChoice = new DropDownChoice<ReportRuntimeTemplate>( "template", new PropertyModel<ReportRuntimeTemplate>(this, "template"), new LoadableDetachableModel<List<ReportRuntimeTemplate>>() { @Override protected List<ReportRuntimeTemplate> load() { List<ReportRuntimeTemplate> templates = new ArrayList<ReportRuntimeTemplate>(); try { templates = reportService.getReportTemplatesById(report.getId()); } catch (Exception e) { e.printStackTrace(); LOG.error(e.getMessage(), e); error(e.getMessage()); } return templates; } }, nameRenderer); templateChoice.setNullValid(true); templateChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { if (template != null) { new ChangeValuesTemplateEvent(templateChoice, report, template.getReportRuntime(), template.getShortcutType(), target).fire(); runtimeModel.setShortcutType(template.getShortcutType()); target.add(shortcutChoice); // when a template is changed then the shortcut is changed ShortcutType shortcutType = runtimeModel.getShortcutType(); new ChangeShortcutTemplateEvent(shortcutChoice, shortcutType, target).fire(); timeType = TimeShortcutType.getTypeName(runtimeModel.getShortcutType().getTimeType()); boolean visible = (runtimeModel.getShortcutType().getType() == -1); shortcutLastContainer.setVisible(visible); target.add(shortcutLastContainer); } else { runtimeModel.setShortcutType(ShortcutType.NONE); shortcutLastContainer.setVisible(false); target.add(shortcutChoice); target.add(shortcutLastContainer); } } }); add(templateChoice); final TextField<String> nameField = new TextField<String>("name", new PropertyModel<String>(this, "runtimeModel.templateName")); nameField.setRequired(false); nameField.setEnabled(false); nameField.setOutputMarkupId(true); nameField.setLabel(Model.of(getString("ActionContributor.Run.template.info"))); add(nameField); add(new Label("saveTemplateLabel", getString("ActionContributor.Run.template.save"))); final CheckBox saveTemplate = new CheckBox("saveTemplate", new PropertyModel<Boolean>(this, "runtimeModel.saveTemplate")); saveTemplate.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { boolean save = runtimeModel.isSaveTemplate(); nameField.setEnabled(save); nameField.setRequired(save); if (save) { nameField.add(validator); } else { nameField.remove(validator); } target.add(nameField); } }); add(saveTemplate); WebMarkupContainer shortcutContainer = new WebMarkupContainer("shortcutContainer"); boolean visible = ReportUtil.hasIntervalParameters(storageService.getSettings(), report); shortcutContainer.setVisible(visible); add(shortcutContainer); shortcutContainer.add(new Label("withShortcut", getString("ActionContributor.Run.template.interval"))); ChoiceRenderer<ShortcutType> shortcutRenderer = new ChoiceRenderer<ShortcutType>("name") { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(ShortcutType shortcut) { return getString( "ActionContributor.Run.template.interval." + ShortcutType.getName(shortcut.getType())); } }; shortcutChoice = new DropDownChoice<ShortcutType>("shortcutType", new PropertyModel<ShortcutType>(this, "runtimeModel.shortcutType"), ShortcutType.getTypes(), shortcutRenderer); shortcutChoice.setNullValid(false); shortcutChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { ShortcutType shortcutType = runtimeModel.getShortcutType(); new ChangeShortcutTemplateEvent(shortcutChoice, shortcutType, target).fire(); boolean visible = (runtimeModel.getShortcutType().getType() == -1); shortcutLastContainer.setVisible(visible); target.add(shortcutLastContainer); } }); shortcutChoice.setOutputMarkupId(true); shortcutContainer.add(shortcutChoice); shortcutLastContainer = new WebMarkupContainer("shortcutLastContainer"); shortcutLastContainer.setVisible(false); shortcutLastContainer.setOutputMarkupPlaceholderTag(true); shortcutContainer.add(shortcutLastContainer); timeUnitsField = new TextField<Integer>("timeUnits", new PropertyModel<Integer>(this, "runtimeModel.shortcutType.timeUnits")); timeUnitsField.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { new ChangeShortcutTemplateEvent(shortcutChoice, runtimeModel.getShortcutType(), target).fire(); } }); timeUnitsField.setRequired(false); shortcutLastContainer.add(timeUnitsField); ChoiceRenderer<String> timeTypeRenderer = new ChoiceRenderer<String>() { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(String type) { return getString(type.toLowerCase()); } }; timeTypeChoice = new DropDownChoice<String>("timeType", new PropertyModel<String>(this, "timeType"), TimeShortcutType.getTypeNames(), timeTypeRenderer); timeTypeChoice.add(new AjaxFormComponentUpdatingBehavior("onchange") { protected void onUpdate(AjaxRequestTarget target) { runtimeModel.getShortcutType().setTimeType(TimeShortcutType.getTypeUnit(timeType)); new ChangeShortcutTemplateEvent(shortcutChoice, runtimeModel.getShortcutType(), target).fire(); } }); shortcutLastContainer.add(timeTypeChoice); if (runtimeModel.getShortcutType().getType() == -1) { shortcutLastContainer.setVisible(true); } add(new AjaxLink<Void>("removeTemplate") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { ModalWindow dialog = findParent(BasePage.class).getDialog(); dialog.setTitle(getString("ActionContributor.Run.template.remove")); dialog.setInitialWidth(350); dialog.setInitialHeight(200); dialog.setResizable(true); final ManageTemplatesPanel panel = new ManageTemplatesPanel(dialog.getContentId(), report) { private static final long serialVersionUID = 1L; @Override public void onDelete(AjaxRequestTarget target, List<ReportRuntimeTemplate> selected) { ModalWindow.closeCurrent(target); if (selected.size() == 0) { return; } List<String> ids = new ArrayList<String>(); for (ReportRuntimeTemplate rt : selected) { ids.add(rt.getId()); } try { storageService.removeEntitiesById(ids); } catch (NotFoundException e) { e.printStackTrace(); LOG.error(e.getMessage(), e); error(e.getMessage()); } template = null; target.add(templateChoice); } @Override public void onCancel(AjaxRequestTarget target) { ModalWindow.closeCurrent(target); } }; dialog.setContent(panel); dialog.show(target); } }); }