List of usage examples for org.apache.wicket.markup.html WebMarkupContainer replace
public MarkupContainer replace(final Component child)
From source file:au.org.theark.core.web.StudyHelper.java
License:Open Source License
public void setStudyLogo(Study study, AjaxRequestTarget target, WebMarkupContainer studyNameMarkup, WebMarkupContainer studyLogoMarkup) { // Set the study logo Long sessionStudyId = (Long) SecurityUtils.getSubject().getSession() .getAttribute(au.org.theark.core.Constants.STUDY_CONTEXT_ID); if (sessionStudyId != null && study.getStudyLogoBlob() != null) { setStudyLogoImage(study, "studyLogoImage", studyLogoMarkup); studyNameMarkup.setVisible(false); studyLogoMarkup.setVisible(true); } else {/* www .j av a2 s. co m*/ // Only show study name, no logo studyNameLabel = new Label("studyNameLabel", new Model<String>(study.getName())); studyNameMarkup.replace(studyNameLabel); studyNameMarkup.setVisible(true); studyLogoMarkup.setVisible(false); } target.add(studyNameMarkup); target.add(studyLogoMarkup); }
From source file:com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel.java
License:Apache License
@Override protected void onPostSuccess(AjaxRequestTarget target) { WebMarkupContainer dashboardContent = getDashboardContent(); dashboardContent.replace(getMainComponent(ID_CONTENT)); PageBase page = (PageBase) getPage(); showResultIfError(page);/* ww w . jav a 2s.c o m*/ target.add(this, page.getFeedbackPanel()); }
From source file:com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel.java
License:Apache License
@Override protected void onUpdateError(AjaxRequestTarget target, Exception ex) { String message = "Error occurred while fetching data: " + ex.getMessage(); Label errorLabel = new Label(ID_CONTENT, message); WebMarkupContainer dashboardContent = getDashboardContent(); dashboardContent.replace(errorLabel); PageBase page = (PageBase) getPage(); showResultIfError(page);/* w w w . j a v a 2 s . com*/ target.add(this, page.getFeedbackPanel()); }
From source file:com.zh.snmp.snmpweb.config.ConfigDetailsPanel.java
License:Open Source License
public ConfigDetailsPanel(String id, IModel<DeviceConfigEntity> model) { super(id, model); //add(new LinkTree(id, )) Configuration conf = service.findConfigByCode(model.getObject().getId()); TreeModel treeModel = new DefaultTreeModel(conf.getRoot()); final WebMarkupContainer cont = new WebMarkupContainer("cont"); cont.setOutputMarkupId(true);//from ww w. ja va 2 s . c om add(cont); LinkTree tree; add(tree = new LinkTree("tree", treeModel) { @Override protected void onNodeLinkClicked(Object node, BaseTree tree, AjaxRequestTarget target) { cont.replace(new ConfigNodePanel("nodePanel", (ConfigNode) node)); target.addComponent(cont); } }); tree.getTreeState().expandAll(); cont.add(new Label("nodePanel")); }
From source file:name.martingeisse.webide.workbench.WorkbenchPage.java
License:Open Source License
/** * This method is used by the editor service to replace the current editor * with a new one. This happens when the user opens a file. */// w w w. java 2 s. co m void replaceEditor(final IEditor editor) { final WebMarkupContainer editorContainer = (WebMarkupContainer) get("editorContainer"); editorContainer.replace(editor.createComponent("editor")); AjaxRequestUtil.markForRender(editorContainer); }
From source file:ontopoly.components.FieldInstanceAssociationNaryField.java
License:Apache License
public FieldInstanceAssociationNaryField(String id, FieldInstanceAssociationNaryPanel _parentPanel, RoleFieldModel roleFieldModel, List<RoleFieldModel> otherRoleFieldModels, FieldValueModel _fieldValueModel, FieldsViewModel fieldsViewModel, final boolean readonly, boolean traversable, final int arity) { super(id);//from w w w . ja v a2s. c o m this.fieldValueModel = _fieldValueModel; this.parentPanel = _parentPanel; this.arity = arity; FieldInstanceModel fieldInstanceModel = fieldValueModel.getFieldInstanceModel(); // register current player this.currentFieldModel = roleFieldModel; this.currentTopicModel = new TopicModel<Topic>(fieldInstanceModel.getFieldInstance().getInstance()); selectedPlayers.put(roleFieldModel, currentTopicModel); RoleField.ValueIF fieldValue = (RoleField.ValueIF) fieldValueModel.getFieldValue(); RepeatingView rv = new RepeatingView("roles"); rv.setVisible(!readonly || fieldValueModel.isExistingValue()); add(rv); Iterator<RoleFieldModel> oiter = otherRoleFieldModels.iterator(); while (oiter.hasNext()) { final RoleFieldModel ofieldModel = oiter.next(); RoleField ofield = ofieldModel.getRoleField(); final WebMarkupContainer parent = new WebMarkupContainer(rv.newChildId()) { @Override public boolean isVisible() { // hide if read-only and not complete if (readonly && selectedPlayers.size() != arity) return false; else return true; } }; parent.setOutputMarkupId(true); rv.add(parent); parent.add(new Label("label", new Model<String>(ofield.getRoleType().getName()))); //! parent.add(new Label("label", new Model(ofield.getFieldName()))); // register other player Topic topic = (fieldValue == null ? null : fieldValue.getPlayer(ofield, fieldInstanceModel.getFieldInstance().getInstance())); final TopicModel<Topic> topicModel = new TopicModel<Topic>(topic); // NOTE: should not use same model as selected model as the model would then be updated immediately selectedPlayers.put(ofieldModel, new TopicModel<Topic>(topic)); TopicLink<Topic> playerLink = new TopicLink<Topic>("player", topicModel); playerLink.setEnabled(traversable); playerLink.setVisible(topic != null); parent.add(playerLink); EditMode editMode = ofield.getEditMode(); final boolean allowAdd = !editMode.isNewValuesOnly(); final boolean allowCreate = !editMode.isExistingValuesOnly(); if (readonly || fieldValueModel.isExistingValue() || !allowAdd) { // unused components parent.add(new Label("select").setVisible(false)); parent.add(new Label("find").setVisible(false)); parent.add(new Label("findModal").setVisible(false)); } else { InterfaceControl interfaceControl = ofield.getInterfaceControl(); if (interfaceControl.isAutoComplete()) { final AssociationFieldAutoCompleteTextField autoCompleteField = new AssociationFieldAutoCompleteTextField( "select", new TopicModel<Topic>(null), ofieldModel) { @Override protected void filterPlayers(List<Topic> players) { AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); page.filterTopics(players); } @Override protected void onTopicSelected(Topic topic) { topicModel.setObject(topic); boolean changesMade = onNewSelection(ofieldModel, topic); // replace ourselves with a topic link if (changesMade) parent.replace(new TopicLink<Topic>("select", new TopicModel<Topic>(topic))); } }; autoCompleteField.getTextField().add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { if (needsUpdate) FieldInstanceAssociationNaryField.this.onUpdate(target); else target.addComponent(parent); } }); autoCompleteField.setOutputMarkupId(true); parent.add(autoCompleteField); // unused components parent.add(new Label("find").setVisible(false)); parent.add(new Label("findModal").setVisible(false)); } else if (interfaceControl.isDropDownList()) { PossiblePlayersModel choicesModel = new PossiblePlayersModel(fieldInstanceModel, ofieldModel) { @Override protected void filterPlayers(Collection<Topic> players) { AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); page.filterTopics(players); } }; TopicDropDownChoice<Topic> choice = new TopicDropDownChoice<Topic>("select", topicModel, choicesModel) { @Override protected void onModelChanged() { super.onModelChanged(); onNewSelection(ofieldModel, getModel().getObject()); } }; choice.setOutputMarkupId(true); choice.add(new AjaxFormComponentUpdatingBehavior("onchange") { @Override protected void onUpdate(AjaxRequestTarget target) { FieldInstanceAssociationNaryField.this.onUpdate(target); } @Override protected void onError(AjaxRequestTarget target, RuntimeException e) { FieldInstanceAssociationNaryField.this.onError(target, e); } }); parent.add(choice); // unused components parent.add(new Label("find").setVisible(false)); parent.add(new Label("findModal").setVisible(false)); } else if (interfaceControl.isSearchDialog() || interfaceControl.isBrowseDialog()) { // unused components parent.add(new TopicLink<Topic>("select", topicModel)); // "search"/"browse" button final ModalWindow findModal = new ModalWindow("findModal"); parent.add(findModal); int activeTab = (interfaceControl.isSearchDialog() ? ModalFindPage.ACTIVE_TAB_SEARCH : ModalFindPage.ACTIVE_TAB_BROWSE); findModal.setContent( new ModalFindPage<String>(findModal.getContentId(), fieldInstanceModel, activeTab) { @Override protected boolean isMaxOneCardinality() { return true; } @Override protected void onSelectionConfirmed(AjaxRequestTarget target, Collection<String> selected) { if (!selected.isEmpty()) { String topicId = selected.iterator().next(); TopicMap topicMap = fieldValueModel.getFieldInstanceModel() .getFieldInstance().getInstance().getTopicMap(); Topic topic = topicMap.getTopicById(topicId); topicModel.setObject(topic); onNewSelection(ofieldModel, topic); if (needsUpdate) FieldInstanceAssociationNaryField.this.onUpdate(target); else target.addComponent(parent); } } @Override protected void onCloseCancel(AjaxRequestTarget target) { findModal.close(target); } @Override protected void onCloseOk(AjaxRequestTarget target) { findModal.close(target); } }); findModal.setTitle(new ResourceModel("ModalWindow.title.find.topic").getObject().toString()); findModal.setCookieName("findModal"); OntopolyImageLink findButton = new OntopolyImageLink("find", "search.gif", new ResourceModel("icon.search.find-topic")) { @Override public boolean isVisible() { return !readonly; } @Override public void onClick(AjaxRequestTarget target) { findModal.show(target); } }; parent.add(findButton); } else { throw new RuntimeException("Unsupported interface control: " + interfaceControl); } } // create button if (readonly || fieldValueModel.isExistingValue() || !allowCreate) { parent.add(new Label("create").setVisible(false)); } else { // always use popup window int createAction = FieldInstanceCreatePlayerPanel.CREATE_ACTION_POPUP; FieldInstanceCreatePlayerPanel createPanel = new FieldInstanceCreatePlayerPanel("create", fieldInstanceModel, fieldsViewModel, ofieldModel, parentPanel, createAction) { @Override protected Topic createInstance(TopicType topicType) { Topic currentTopic = currentTopicModel.getTopic(); RoleField currentField = currentFieldModel.getRoleField(); RoleField createField = ofieldModel.getRoleField(); Topic createdTopic = null; // check with page to see if add is allowed AbstractOntopolyPage page = (AbstractOntopolyPage) getPage(); if (page.isCreateAllowed(currentTopic, currentField, topicType, createField)) { // create a new topic instance createdTopic = topicType.createInstance(null); topicModel.setObject(createdTopic); performNewSelection(ofieldModel, createdTopic); } return createdTopic; } @Override protected void performNewSelection(RoleFieldModel ofieldModel, Topic selectedTopic) { FieldInstanceAssociationNaryField.this.performNewSelection(ofieldModel, selectedTopic); } @Override protected void hideInstancePage(AjaxRequestTarget target) { if (needsUpdate) FieldInstanceAssociationNaryField.this.onUpdate(target); else target.addComponent(parent); } }; createPanel.setOutputMarkupId(true); parent.add(createPanel); } } }
From source file:org.apache.syncope.client.console.panels.GroupTabPanel.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" })
public GroupTabPanel(final String id, final GroupTO selectedNode, final ModalWindow window,
final PageReference pageRef) {
super(id);// ww w .ja v a2 s .c o m
this.add(new Label("displayName", selectedNode.getDisplayName()));
final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
links.setOutputMarkupId(true);
this.add(links);
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
GroupTO groupTO = new GroupTO();
groupTO.setParent(selectedNode.getKey());
return new GroupModalPage(pageRef, window, groupTO);
}
});
window.show(target);
}
}, ActionLink.ActionType.CREATE, xmlRolesReader.getEntitlement("Groups", "create"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new StatusModalPage<GroupTO>(pageRef, window,
groupRestClient.read(selectedNode.getKey()));
}
});
window.show(target);
}
}, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getEntitlement("Groups", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
GroupTO groupTO = groupRestClient.read(selectedNode.getKey());
return new GroupModalPage(pageRef, window, groupTO);
}
});
window.show(target);
}
}, ActionLink.ActionType.EDIT, xmlRolesReader.getEntitlement("Groups", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
final GroupTO groupTO = groupRestClient.delete(selectedNode.getETagValue(),
selectedNode.getKey());
((Groups) pageRef.getPage()).setModalResult(true);
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ResultStatusModalPage.Builder(window, groupTO).build();
}
});
window.show(target);
} catch (SyncopeClientException e) {
error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
((Groups) pageRef.getPage()).getFeedbackPanel().refresh(target);
}
}
}, ActionLink.ActionType.DELETE, xmlRolesReader.getEntitlement("Groups", "delete"));
final Form form = new Form("groupForm");
form.setModel(new CompoundPropertyModel(selectedNode));
form.setOutputMarkupId(true);
final GroupPanel groupPanel = new GroupPanel.Builder("groupPanel").form(form).groupTO(selectedNode)
.groupModalPageMode(Mode.ADMIN).build();
groupPanel.setEnabled(false);
form.add(groupPanel);
final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");
userListContainer.setOutputMarkupId(true);
userListContainer.setEnabled(true);
userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
userListContainer.replace(new UserSearchResultPanel("userList", true,
SyncopeClient.getUserSearchConditionBuilder().inGroups(selectedNode.getKey()).query(),
pageRef, userRestClient));
target.add(userListContainer);
}
});
form.add(userListContainer);
add(form);
}
From source file:org.apache.syncope.client.console.panels.RoleTabPanel.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" })
public RoleTabPanel(final String id, final RoleTO selectedNode, final ModalWindow window,
final PageReference pageRef) {
super(id);/* w w w . j ava2s . co m*/
this.add(new Label("displayName", selectedNode.getDisplayName()));
final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
links.setOutputMarkupId(true);
this.add(links);
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
RoleTO roleTO = new RoleTO();
roleTO.setParent(selectedNode.getKey());
return new RoleModalPage(pageRef, window, roleTO);
}
});
window.show(target);
}
}, ActionLink.ActionType.CREATE, xmlRolesReader.getEntitlement("Roles", "create"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new StatusModalPage<RoleTO>(pageRef, window,
roleRestClient.read(selectedNode.getKey()));
}
});
window.show(target);
}
}, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getEntitlement("Roles", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
RoleTO roleTO = roleRestClient.read(selectedNode.getKey());
return new RoleModalPage(pageRef, window, roleTO);
}
});
window.show(target);
}
}, ActionLink.ActionType.EDIT, xmlRolesReader.getEntitlement("Roles", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
final RoleTO roleTO = roleRestClient.delete(selectedNode.getETagValue(), selectedNode.getKey());
((Roles) pageRef.getPage()).setModalResult(true);
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ResultStatusModalPage.Builder(window, roleTO).build();
}
});
window.show(target);
} catch (SyncopeClientException e) {
error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
((Roles) pageRef.getPage()).getFeedbackPanel().refresh(target);
}
}
}, ActionLink.ActionType.DELETE, xmlRolesReader.getEntitlement("Roles", "delete"));
final Form form = new Form("roleForm");
form.setModel(new CompoundPropertyModel(selectedNode));
form.setOutputMarkupId(true);
final RolePanel rolePanel = new RolePanel.Builder("rolePanel").form(form).roleTO(selectedNode)
.roleModalPageMode(Mode.ADMIN).build();
rolePanel.setEnabled(false);
form.add(rolePanel);
final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");
userListContainer.setOutputMarkupId(true);
userListContainer.setEnabled(true);
userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
userListContainer.replace(new UserSearchResultPanel("userList", true,
SyncopeClient.getUserSearchConditionBuilder().hasRoles(selectedNode.getKey()).query(),
pageRef, userRestClient));
target.add(userListContainer);
}
});
form.add(userListContainer);
add(form);
}
From source file:org.apache.syncope.console.pages.panels.RoleTabPanel.java
License:Apache License
@SuppressWarnings({ "unchecked", "rawtypes" })
public RoleTabPanel(final String id, final RoleTO selectedNode, final ModalWindow window,
final PageReference pageRef) {
super(id);/*from ww w. j av a2 s . co m*/
this.add(new Label("displayName", selectedNode.getDisplayName()));
final ActionLinksPanel links = new ActionLinksPanel("actionLinks", new Model(), pageRef);
links.setOutputMarkupId(true);
this.add(links);
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
RoleTO roleTO = new RoleTO();
roleTO.setParent(selectedNode.getId());
RoleModalPage form = new RoleModalPage(pageRef, window, roleTO);
return form;
}
});
window.show(target);
}
}, ActionLink.ActionType.CREATE, xmlRolesReader.getAllAllowedRoles("Roles", "create"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new StatusModalPage<RoleTO>(pageRef, window,
roleRestClient.read(selectedNode.getId()));
}
});
window.show(target);
}
}, ActionLink.ActionType.MANAGE_RESOURCES, xmlRolesReader.getAllAllowedRoles("Roles", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
RoleTO roleTO = roleRestClient.read(selectedNode.getId());
RoleModalPage form = new RoleModalPage(pageRef, window, roleTO);
return form;
}
});
window.show(target);
}
}, ActionLink.ActionType.EDIT, xmlRolesReader.getAllAllowedRoles("Roles", "update"));
links.addWithRoles(new ActionLink() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
final RoleTO roleTO = roleRestClient.delete(selectedNode.getETagValue(), selectedNode.getId());
((Roles) pageRef.getPage()).setModalResult(true);
window.setPageCreator(new ModalWindow.PageCreator() {
private static final long serialVersionUID = -7834632442532690940L;
@Override
public Page createPage() {
return new ResultStatusModalPage.Builder(window, roleTO).build();
}
});
window.show(target);
} catch (SyncopeClientException e) {
error(getString(Constants.OPERATION_ERROR) + ": " + e.getMessage());
((Roles) pageRef.getPage()).getFeedbackPanel().refresh(target);
}
}
}, ActionLink.ActionType.DELETE, xmlRolesReader.getAllAllowedRoles("Roles", "delete"));
final Form form = new Form("roleForm");
form.setModel(new CompoundPropertyModel(selectedNode));
form.setOutputMarkupId(true);
final RolePanel rolePanel = new RolePanel.Builder("rolePanel").form(form).roleTO(selectedNode)
.roleModalPageMode(RoleModalPage.Mode.ADMIN).build();
rolePanel.setEnabled(false);
form.add(rolePanel);
final WebMarkupContainer userListContainer = new WebMarkupContainer("userListContainer");
userListContainer.setOutputMarkupId(true);
userListContainer.setEnabled(true);
userListContainer.add(new UserSearchResultPanel("userList", true, null, pageRef, userRestClient));
userListContainer.add(new ClearIndicatingAjaxButton("search", new ResourceModel("search"), pageRef) {
private static final long serialVersionUID = -958724007591692537L;
@Override
protected void onSubmitInternal(final AjaxRequestTarget target, final Form<?> form) {
userListContainer.replace(new UserSearchResultPanel("userList", true,
SyncopeClient.getUserSearchConditionBuilder().hasRoles(selectedNode.getId()).query(),
pageRef, userRestClient));
target.add(userListContainer);
}
});
form.add(userListContainer);
add(form);
}
From source file:org.cast.isi.panel.ResponseEditor.java
License:Open Source License
@Override protected WebMarkupContainer getEditorFragment(String id, final IModel<Response> model, IResponseType type) { final WebMarkupContainer editor = super.getEditorFragment(id, model, type); // Replace the default Java audio recorder with WAMI if (type.getName().equals("AUDIO")) { // Superclass doesn't have a form for the title field to go in Form<Response> form = new Form<Response>("form", model); editor.add(form);/* w ww .ja va 2 s . c om*/ // Replace old audio applet with wami applet editor.replace(new RecorderResponsePanel("applet", model, AudioSkin.STANDARD, pageName)); // Replace standard audio "save" link with one that saves the form. Audio data will be automatically saved. AjaxSubmitLink saveLink = new AjaxSubmitLink("save", form) { private static final long serialVersionUID = 1L; @Override protected void onSubmit(AjaxRequestTarget target, Form<?> form) { cwmService.flushChanges(); onSave(target); } }; saveLink.setOutputMarkupId(true); editor.replace(saveLink); } // Add title field to all editor types ((Form<?>) editor.get("form")).add(new TitleFragment("titleFragment", model)); if (type.getName().equals("AUDIO")) { String propertyString; TypeMetadata typeMD = metadata.getType("AUDIO"); // Special case: use text sentence starters for audio if there are no audio-specific ones. if ((typeMD == null || typeMD.getFragments() == null || typeMD.getFragments().isEmpty())) { propertyString = new String("typeMap[HTML].fragments"); } else { propertyString = new String("typeMap[AUDIO].fragments"); } editor.add(new ListView<String>("starters", new PropertyModel<List<String>>(metadata, propertyString)) { private static final long serialVersionUID = 1L; @Override protected void populateItem(ListItem<String> item) { item.add(new Label("text", item.getModelObject())) .setVisible(!item.getModelObject().equals("default")); } @Override protected void onBeforeRender() { // If there are no starters, make the starters list invisible if (getModelObject() == null || getModelObject().isEmpty()) { setVisible(false); } super.onBeforeRender(); } }); } return editor; }