org.apache.wicket.ajax.AjaxEventBehavior Java Examples
The following examples show how to use
org.apache.wicket.ajax.AjaxEventBehavior.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StartWidgetView.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onInitialize() { add(new WebMarkupContainer("step1").add(new PublicRoomsEventBehavior())); add(new WebMarkupContainer("step2").add(new PublicRoomsEventBehavior())); add(new WebMarkupContainer("step3").add(new WebMarkupContainer("avTest").add(AttributeModifier.append("href" , RequestCycle.get().urlFor(HashPage.class, new PageParameters().add(APP, APP_TYPE_SETTINGS)).toString())))); add(new WebMarkupContainer("step4").add(new PublicRoomsEventBehavior())); add(new Label("123msg", Application.getString("widget.start.desc")) //Application here is used to substitute {0} .setEscapeModelStrings(false)); add(new BootstrapButton("start", new ResourceModel("788"), Buttons.Type.Outline_Primary).add(new PublicRoomsEventBehavior())); add(new BootstrapButton("calendar", new ResourceModel("291"), Buttons.Type.Outline_Primary).add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { ((MainPage)getPage()).updateContents(CALENDAR, target); } })); super.onInitialize(); }
Example #2
Source File: FileItemPanel.java From openmeetings with Apache License 2.0 | 6 votes |
public FileItemPanel(String id, final IModel<BaseFileItem> model, final FileTreePanel fileTreePanel) { super(id, model, fileTreePanel); BaseFileItem f = model.getObject(); long errorCount = fileLogDao.countErrors(f); boolean visible = errorCount != 0; if (BaseFileItem.Type.RECORDING == f.getType()) { Recording r = (Recording)f; visible |= (Status.RECORDING != r.getStatus() && Status.CONVERTING != r.getStatus() && !f.exists()); } else { visible |= !f.exists(); } errors.add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { fileTreePanel.errorsDialog.setDefaultModel(model); fileTreePanel.errorsDialog.show(target); } }).setVisible(visible); add(errors); }
Example #3
Source File: ConfirmableAjaxBorder.java From openmeetings with Apache License 2.0 | 6 votes |
@Override protected void onInitialize() { super.onInitialize(); add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); ConfirmableAjaxBorder.this.updateAjaxAttributes(attributes); } @Override protected void onEvent(AjaxRequestTarget target) { if (isClickable()) { getDialog().show(target); } } }); addToBorder(getDialog()); }
Example #4
Source File: CurationPage.java From webanno with Apache License 2.0 | 6 votes |
@Override protected void onAfterRender() { super.onAfterRender(); // The sentence list is refreshed using AJAX. Unfortunately, the renderHead() method // of the AjaxEventBehavior created by AjaxLink does not seem to be called by Wicket // during an AJAX rendering, causing the sentence links to loose their functionality. // Here, we ensure that the callback scripts are attached to the sentence links even // during AJAX updates. if (isEnabledInHierarchy()) { RequestCycle.get().find(AjaxRequestTarget.class).ifPresent(_target -> { for (AjaxEventBehavior b : getBehaviors(AjaxEventBehavior.class)) { _target.appendJavaScript(b.getCallbackScript()); } }); } }
Example #5
Source File: SocialNetworkPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private ListView<OAuth2Service> createSocialNetworksServices(String id) { return new ListView<OAuth2Service>(id, getModel()) { @Override protected void populateItem(ListItem<OAuth2Service> item) { IOAuth2Provider provider = item.getModelObject().getProvider(); Image image = new Image("networkImage", provider.getIconResourceReference()); image.setOutputMarkupPlaceholderTag(true); image.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget target) { onSocialImageClick(target, item.getModel()); } }); image.add(new AttributeModifier("alt", new ResourceModel(provider.getLabel()).getObject())); item.add(image); } @Override protected void onInitialize() { super.onInitialize(); setReuseItems(true); } }; }
Example #6
Source File: AjaxExternalLink.java From sakai with Educational Community License v2.0 | 6 votes |
public AjaxExternalLink(String id, String url) { super(id, url); add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { onClick(target); } @Override protected void onComponentTag(ComponentTag tag) { // add the onclick handler only if link is enabled if (isLinkEnabled()) { super.onComponentTag(tag); } } }); }
Example #7
Source File: AjaxExternalLink.java From sakai with Educational Community License v2.0 | 6 votes |
public AjaxExternalLink(String id, String url) { super(id, url); add(new AjaxEventBehavior("onclick") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { onClick(target); } @Override protected void onComponentTag(ComponentTag tag) { // add the onclick handler only if link is enabled if (isLinkEnabled()) { super.onComponentTag(tag); } } }); }
Example #8
Source File: SearchClausePanel.java From syncope with Apache License 2.0 | 6 votes |
public void enableSearch(final IEventSink resultContainer) { this.resultContainer = resultContainer; this.searchButton.setEnabled(true); this.searchButton.setVisible(true); field.add(PREVENT_DEFAULT_RETURN); field.add(new AjaxEventBehavior(Constants.ON_KEYDOWN) { private static final long serialVersionUID = -7133385027739964990L; @Override protected void onEvent(final AjaxRequestTarget target) { if (resultContainer == null) { send(SearchClausePanel.this, Broadcast.BUBBLE, new SearchEvent(target)); } else { send(resultContainer, Broadcast.EXACT, new SearchEvent(target)); } } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); AJAX_SUBMIT_ON_RETURN.accept(attributes); } }); }
Example #9
Source File: IconPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * Enable Ajax onclick event. If clicked by the user {@link #onClick()} is called. */ @SuppressWarnings("serial") public IconPanel enableAjaxOnClick() { appendAttribute("style", "cursor: pointer;"); final AjaxEventBehavior behavior = new AjaxEventBehavior("onClick") { @Override protected void onEvent(final AjaxRequestTarget target) { IconPanel.this.onClick(); } }; div.add(behavior); return this; }
Example #10
Source File: ModalDialog.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * @param id */ @SuppressWarnings("serial") public ModalDialog(final String id) { super(id); actionButtons = new MyComponentsRepeater<Component>("actionButtons"); mainContainer = new WebMarkupContainer("mainContainer"); add(mainContainer.setOutputMarkupId(true)); mainContainer.add(mainSubContainer = new WebMarkupContainer("mainSubContainer")); gridContentContainer = new WebMarkupContainer("gridContent"); gridContentContainer.setOutputMarkupId(true); buttonBarContainer = new WebMarkupContainer("buttonBar"); buttonBarContainer.setOutputMarkupId(true); closeBehavior = new AjaxEventBehavior("hidden.bs.modal") { @Override protected void onEvent(final AjaxRequestTarget target) { handleCloseEvent(target); } @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setEventPropagation(AjaxRequestAttributes.EventPropagation.BUBBLE); } }; }
Example #11
Source File: LinkToSocialNetworkPanel.java From Orienteer with Apache License 2.0 | 5 votes |
private ListView<OAuth2Service> createSocialNetworksServices(String id) { return new ListView<OAuth2Service>(id, resolveNotLinkedOAuth2Services(getModelObject())) { @Override protected void onConfigure() { super.onConfigure(); setModelObject(resolveNotLinkedOAuth2Services(LinkToSocialNetworkPanel.this.getModelObject())); } @Override protected void populateItem(ListItem<OAuth2Service> item) { IOAuth2Provider provider = item.getModelObject().getProvider(); Image image = new Image("networkImage", provider.getIconResourceReference()); image.setOutputMarkupPlaceholderTag(true); image.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget target) { onSocialImageClick(target, item.getModel()); image.setVisible(false); target.add(image); } }); image.add(new AttributeModifier("alt", new ResourceModel(provider.getLabel()).getObject())); item.add(image); } @Override protected void onInitialize() { super.onInitialize(); setReuseItems(true); } }; }
Example #12
Source File: GbGradeTable.java From sakai with Educational Community License v2.0 | 5 votes |
public GbGradeTable(final String id, final IModel model) { super(id); setDefaultModel(model); component = new WebMarkupContainer("gradeTable").setOutputMarkupId(true); component.add(new AjaxEventBehavior("gbgradetable.action") { @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters() .add("return [{\"name\": \"ajaxParams\", \"value\": JSON.stringify(attrs.event.extraData)}]"); } @Override protected void onEvent(final AjaxRequestTarget target) { try { final ObjectMapper mapper = new ObjectMapper(); final JsonNode params = mapper.readTree(getRequest().getRequestParameters().getParameterValue("ajaxParams").toString()); final ActionResponse response = handleEvent(params.get("action").asText(), params, target); target.appendJavaScript(String.format("GbGradeTable.ajaxComplete(%d, '%s', %s);", params.get("_requestId").intValue(), response.getStatus(), response.toJson())); } catch (IOException e) { throw new RuntimeException(e); } } }); add(component); }
Example #13
Source File: AjaxDecoratedCheckbox.java From syncope with Apache License 2.0 | 5 votes |
public AjaxDecoratedCheckbox(final String id, final IModel<Boolean> model) { super(id, model); add(new AjaxEventBehavior(Constants.ON_CLICK) { private static final long serialVersionUID = -295188647830294610L; @Override protected void onEvent(final AjaxRequestTarget target) { refreshComponent(target); } }); }
Example #14
Source File: SelectPanel.java From projectforge-webapp with GNU General Public License v3.0 | 5 votes |
/** * Adds attribute onchange="javascript:submit();" * @return This for chaining. */ public SelectPanel<T> setAutoSubmit() { this.select.add(new AjaxEventBehavior("onChange") { @Override protected void onEvent(final AjaxRequestTarget target) { onChange(target); } }); return this; }
Example #15
Source File: DrawerManager.java From pm-wicket-utils with GNU Lesser General Public License v3.0 | 5 votes |
public ListItem(String id, final AbstractDrawer drawer, DrawerManager drawerManager, String css) { super(id); setOutputMarkupId(true); manager = drawerManager; item = new WebMarkupContainer("item"); if (null != css) { item.add(new AttributeAppender("class", Model.of(css), " ")); } add(item); this.drawer = drawer; item.add(drawer); add(new EmptyPanel("next").setOutputMarkupId(true)); item.add(new AjaxEventBehavior("hide-modal") { private static final long serialVersionUID = -6423164614673441582L; @Override protected void onEvent(AjaxRequestTarget target) { manager.eventPop(ListItem.this.drawer, target); } @Override protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setPreventDefault(true); } }); }
Example #16
Source File: GbGradeTable.java From sakai with Educational Community License v2.0 | 5 votes |
public GbGradeTable(final String id, final IModel model) { super(id); setDefaultModel(model); component = new WebMarkupContainer("gradeTable").setOutputMarkupId(true); component.add(new AjaxEventBehavior("gbgradetable.action") { @Override protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.getDynamicExtraParameters() .add("return [{\"name\": \"ajaxParams\", \"value\": JSON.stringify(attrs.event.extraData)}]"); } @Override protected void onEvent(final AjaxRequestTarget target) { try { final ObjectMapper mapper = new ObjectMapper(); final JsonNode params = mapper.readTree(getRequest().getRequestParameters().getParameterValue("ajaxParams").toString()); final ActionResponse response = handleEvent(params.get("action").asText(), params, target); target.appendJavaScript(String.format("GbGradeTable.ajaxComplete(%d, '%s', %s);", params.get("_requestId").intValue(), response.getStatus(), response.toJson())); } catch (IOException e) { throw new RuntimeException(e); } } }); add(component); }
Example #17
Source File: OpenDocumentDialogPanel.java From webanno with Apache License 2.0 | 5 votes |
private OverviewListChoice<DecoratedObject<SourceDocument>> createDocListChoice() { docListChoice = new OverviewListChoice<>("documents", Model.of(), listDocuments()); docListChoice.setChoiceRenderer(new ChoiceRenderer<DecoratedObject<SourceDocument>>() { private static final long serialVersionUID = 1L; @Override public Object getDisplayValue(DecoratedObject<SourceDocument> aDoc) { return defaultIfEmpty(aDoc.getLabel(), aDoc.get().getName()); } }); docListChoice.setOutputMarkupId(true); docListChoice.add(new OnChangeAjaxBehavior() { private static final long serialVersionUID = -8232688660762056913L; @Override protected void onUpdate(AjaxRequestTarget aTarget) { aTarget.add(buttonsContainer); } }).add(AjaxEventBehavior.onEvent("dblclick", _target -> actionOpenDocument(_target, null))); if (!docListChoice.getChoices().isEmpty()) { docListChoice.setModelObject(docListChoice.getChoices().get(0)); } return docListChoice; }
Example #18
Source File: RoomFilePanel.java From openmeetings with Apache License 2.0 | 5 votes |
@Override protected Component getUpload() { return super.getUpload() .setVisible(true) .add(new AjaxEventBehavior(EVT_CLICK) { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget target) { room.getSidebar().showUpload(target); } }); }
Example #19
Source File: ToggleContainerPanel.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @param id */ @SuppressWarnings("serial") public ToggleContainerPanel(final String id, final DivType... cssClasses) { super(id); panel = new WebMarkupContainer("panel"); panel.setOutputMarkupId(true); super.add(panel); if (cssClasses != null) { for (final DivType cssClass : cssClasses) { panel.add(AttributeModifier.append("class", cssClass.getClassAttrValue())); } } panel.add(toggleContainer = new WebMarkupContainer("toggleContainer")); toggleContainer.setOutputMarkupId(true); panel.add(toggleHeading = new WebMarkupContainer("heading")); toggleHeading.add(iconContainer = new WebMarkupContainer("icon")); iconContainer.setOutputMarkupId(true); setOpen(); if (wantsOnStatusChangedNotification()) { final AjaxEventBehavior behavior = new AjaxEventBehavior("onClick") { @Override protected void onEvent(final AjaxRequestTarget target) { if (toggleStatus == ToggleStatus.OPENED) { target.appendJavaScript("$('#" + toggleContainer.getMarkupId() + "').collapse('hide')"); toggleStatus = ToggleStatus.CLOSED; } else { target.appendJavaScript("$('#" + toggleContainer.getMarkupId() + "').collapse('show')"); toggleStatus = ToggleStatus.OPENED; } headingChanged = false; ToggleContainerPanel.this.onToggleStatusChanged(target, toggleStatus); if (headingChanged == true) { target.add(heading); } target.add(iconContainer); setIcon(); } }; toggleHeading.add(behavior); } else { toggleHeading.add(AttributeModifier.replace("onClick", "$('#" + toggleContainer.getMarkupId() + "').collapse('toggle'); toggleCollapseIcon($('#" + iconContainer.getMarkupId() + "'), '" + ICON_STATUS_OPENED + "','" + ICON_OPENED + "','" + ICON_CLOSED + "'); return false;")); } }
Example #20
Source File: DiffTextPanel.java From projectforge-webapp with GNU General Public License v3.0 | 4 votes |
/** * @see org.apache.wicket.Component#onInitialize() */ @SuppressWarnings("serial") @Override protected void onInitialize() { super.onInitialize(); if (showModalDialog == true && getPage() != null && getPage() instanceof AbstractSecuredPage) { final AbstractSecuredPage parentPage = (AbstractSecuredPage) getPage(); modalDialog = new ModalDialog(parentPage.newModalDialogId()) { @Override public void init() { setTitle(getString("changes")); init(new Form<String>(getFormId())); { final FieldsetPanel fs = gridBuilder.newFieldset(getString("history.oldValue")).setLabelSide(false); final TextArea<String> textArea = new TextArea<String>(fs.getTextAreaId(), oldText); fs.add(textArea).setAutogrow(1, 10); textArea.add(AttributeModifier.replace("onClick", "$(this).select();")); } { final FieldsetPanel fs = gridBuilder.newFieldset(getString("history.newValue")).setLabelSide(false); final TextArea<String> textArea = new TextArea<String>(fs.getTextAreaId(), newText); fs.add(textArea).setAutogrow(1, 10); textArea.add(AttributeModifier.replace("onClick", "$(this).select();")); } } }; modalDialog.setBigWindow(); modalDialog.setLazyBinding(); parentPage.add(modalDialog); final AjaxEventBehavior behavior = new AjaxEventBehavior("onClick") { @Override protected void onEvent(final AjaxRequestTarget target) { if (modalDialog.isBound() == false) { // First call, have to initialize it. modalDialog.init(); target.add(modalDialog.getMainContainer()); modalDialog.bind(target); } modalDialog.open(target); } }; label.add(behavior); label.add(AttributeModifier.append("style", "cursor: pointer;")); } }
Example #21
Source File: DocumentMetadataAnnotationSelectionPanel.java From inception with Apache License 2.0 | 4 votes |
private ListView<AnnotationListItem> createAnnotationList() { DocumentMetadataAnnotationSelectionPanel selectionPanel = this; return new ListView<AnnotationListItem>(CID_ANNOTATIONS, LoadableDetachableModel.of(this::listAnnotations)) { private static final long serialVersionUID = -6833373063896777785L; /** * Determines if new annotations should be rendered visible or not. * For the initialization of existing annotations this value should be false. * Afterwards when manually creating new annotations it should be true to immediately * open them afterwards. * If there are no annotations at initialization it is initialized with true else false. */ @Override protected void populateItem(ListItem<AnnotationListItem> aItem) { aItem.setModel(CompoundPropertyModel.of(aItem.getModel())); VID vid = new VID(aItem.getModelObject().addr); WebMarkupContainer container = new WebMarkupContainer("annotation"); aItem.add(container); DocumentMetadataAnnotationDetailPanel detailPanel = new DocumentMetadataAnnotationDetailPanel(CID_ANNOTATION_DETAILS, Model.of(vid), sourceDocument, username, jcasProvider, project, annotationPage, selectionPanel, actionHandler, state); aItem.add(detailPanel); container.add(new AjaxEventBehavior("click") { @Override protected void onEvent(AjaxRequestTarget aTarget) { actionSelect(aTarget, container, detailPanel); } }); detailPanel.add(visibleWhen(() -> selectedAnnotation == container)); if (createdAnnotationAddress == vid.getId()) { createdAnnotationAddress = -1; selectedAnnotation = container; selectedDetailPanel = detailPanel; } WebMarkupContainer close = new WebMarkupContainer("close"); close.add(visibleWhen(() -> !detailPanel.isVisible())); close.setOutputMarkupId(true); container.add(close); WebMarkupContainer open = new WebMarkupContainer("open"); open.add(visibleWhen(detailPanel::isVisible)); open.setOutputMarkupId(true); container.add(open); container.add(new Label(CID_TYPE, aItem.getModelObject().layer.getUiName())); container.add(new Label(CID_LABEL)); container.setOutputMarkupId(true); aItem.add(new LambdaAjaxLink(CID_DELETE, _target -> actionDelete(_target, detailPanel))); aItem.setOutputMarkupId(true); } }; }
Example #22
Source File: PivotAreaPanel.java From nextreports-server with Apache License 2.0 | 4 votes |
public PivotAreaPanel(String id, PivotField.Area area) { super(id); 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", "aggregator")); // } 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); }
Example #23
Source File: AjaxFallbackDataTable.java From syncope with Apache License 2.0 | 4 votes |
@Override protected Item<T> newRowItem(final String id, final int index, final IModel<T> model) { final OddEvenItem<T> item = new OddEvenItem<>(id, index, model); if (togglePanel != null) { final ActionsPanel<T> actions = getActions(model); if (actions != null && !actions.isEmpty()) { item.add(new AttributeModifier("style", "cursor: pointer;")); item.add(new AjaxEventBehavior(Constants.ON_CLICK) { private static final long serialVersionUID = -4609215765213990763L; @Override protected String findIndicatorId() { return StringUtils.EMPTY; } @Override protected void onEvent(final AjaxRequestTarget target) { final String lastFocussedElementId = target.getLastFocusedElementId(); if (lastFocussedElementId == null) { togglePanel.toggleWithContent(target, getActions(model), model.getObject()); } else { final AjaxDataTablePanel<?, ?> parent = findParent(AjaxDataTablePanel.class); final Model<Boolean> isCheck = Model.<Boolean>of(Boolean.FALSE); parent.visitChildren(CheckGroupSelector.class, (selector, ivisit) -> { if (selector.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) { isCheck.setObject(Boolean.TRUE); ivisit.stop(); } }); if (!isCheck.getObject()) { parent.visitChildren(Check.class, (check, ivisit) -> { if (check.getMarkupId().equalsIgnoreCase(lastFocussedElementId)) { isCheck.setObject(Boolean.TRUE); ivisit.stop(); } }); } if (!isCheck.getObject()) { togglePanel.toggleWithContent(target, getActions(model), model.getObject()); } } } }); } } return item; }
Example #24
Source File: PolicyRuleWizardBuilder.java From syncope with Apache License 2.0 | 4 votes |
public Profile(final PolicyRuleWrapper rule) { this.rule = rule; final AjaxDropDownChoicePanel<String> conf = new AjaxDropDownChoicePanel<>( "rule", "rule", new PropertyModel<>(rule, "implementationKey")); List<String> choices; switch (type) { case ACCOUNT: choices = ImplementationRestClient.list(IdRepoImplementationType.ACCOUNT_RULE).stream(). map(EntityTO::getKey).sorted().collect(Collectors.toList()); break; case PASSWORD: choices = ImplementationRestClient.list(IdRepoImplementationType.PASSWORD_RULE).stream(). map(EntityTO::getKey).sorted().collect(Collectors.toList()); break; default: choices = new ArrayList<>(); } conf.setChoices(choices); conf.addRequiredLabel(); conf.setNullValid(false); conf.setEnabled(rule.isNew()); conf.add(new AjaxEventBehavior(Constants.ON_CHANGE) { private static final long serialVersionUID = -7133385027739964990L; @Override protected void onEvent(final AjaxRequestTarget target) { ImplementationTO impl = ImplementationRestClient.read(implementationType, conf.getModelObject()); rule.setImplementationEngine(impl.getEngine()); if (impl.getEngine() == ImplementationEngine.JAVA) { try { RuleConf ruleConf = MAPPER.readValue(impl.getBody(), RuleConf.class); rule.setConf(ruleConf); } catch (Exception e) { LOG.error("During deserialization", e); } } } }); add(conf); }
Example #25
Source File: Topology.java From syncope with Apache License 2.0 | 4 votes |
private TopologyNodePanel topologyNodePanel(final String id, final TopologyNode node) { final TopologyNodePanel panel = new TopologyNodePanel(id, node); panel.setMarkupId(String.valueOf(node.getKey())); panel.setOutputMarkupId(true); final List<Behavior> behaviors = new ArrayList<>(); behaviors.add(new Behavior() { private static final long serialVersionUID = 2661717818979056044L; @Override public void renderHead(final Component component, final IHeaderResponse response) { response.render(OnDomReadyHeaderItem.forScript(String.format("setPosition('%s', %d, %d)", node.getKey(), node.getX(), node.getY()))); } }); behaviors.add(new AjaxEventBehavior(Constants.ON_CLICK) { private static final long serialVersionUID = -9027652037484739586L; @Override protected String findIndicatorId() { return StringUtils.EMPTY; } @Override protected void onEvent(final AjaxRequestTarget target) { togglePanel.toggleWithContent(target, node); target.appendJavaScript(String.format( "$('.window').removeClass(\"active-window\").addClass(\"inactive-window\"); " + "$(document.getElementById('%s'))." + "removeClass(\"inactive-window\").addClass(\"active-window\");", node.getKey())); } }); panel.add(behaviors.toArray(new Behavior[] {})); return panel; }
Example #26
Source File: PairwiseCodingAgreementTable.java From webanno with Apache License 2.0 | 4 votes |
private Behavior makeDownloadBehavior(final String aKey1, final String aKey2) { return new AjaxEventBehavior("click") { private static final long serialVersionUID = 1L; @Override protected void onEvent(AjaxRequestTarget aTarget) { AJAXDownload download = new AJAXDownload() { private static final long serialVersionUID = 1L; @Override protected IResourceStream getResourceStream() { return new AbstractResourceStream() { private static final long serialVersionUID = 1L; @Override public InputStream getInputStream() throws ResourceStreamNotFoundException { try { CodingAgreementResult result = PairwiseCodingAgreementTable.this .getModelObject().getStudy(aKey1, aKey2); switch (formatField.getModelObject()) { case CSV: return AgreementUtils.generateCsvReport(result); case DEBUG: return generateDebugReport(result); default: throw new IllegalStateException("Unknown export format [" + formatField.getModelObject() + "]"); } } catch (Exception e) { // FIXME Is there some better error handling here? LOG.error("Unable to generate agreement report", e); throw new ResourceStreamNotFoundException(e); } } @Override public void close() throws IOException { // Nothing to do } }; } }; getComponent().add(download); download.initiate(aTarget, "agreement" + formatField.getModelObject().getExtension()); } }; }