use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class ScenePanel method initLayout.
private void initLayout() {
final IModel<SceneDto> model = getModel();
WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
box.add(AttributeModifier.append("class", new IModel<String>() {
@Override
public String getObject() {
SceneDto dto = model.getObject();
if (dto.getBoxClassOverride() != null) {
return dto.getBoxClassOverride();
}
if (dto.getChangeType() == null) {
return null;
}
switch(dto.getChangeType()) {
case ADD:
return "box-success";
case DELETE:
return "box-danger";
case MODIFY:
return "box-info";
default:
return null;
}
}
}));
add(box);
WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
box.add(headerPanel);
headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {
@Override
public void minimizeOnClick(AjaxRequestTarget target) {
headerOnClickPerformed(target, model);
}
});
Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
// headerChangeType.setRenderBodyOnly(true);
Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
// headerObjectType.setRenderBodyOnly(true);
IModel<String> nameModel = new IModel<String>() {
@Override
public String getObject() {
return model.getObject().getName(ScenePanel.this);
}
};
Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
AjaxLinkPanel headerNameLink = new AjaxLinkPanel(ID_HEADER_NAME_LINK, nameModel) {
@Override
public void onClick(AjaxRequestTarget target) {
PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
if (value != null && value.getParent() instanceof PrismObject) {
PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object, getPageBase().getPrismContext()), getPageBase(), false);
}
}
};
Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new IModel<String>() {
@Override
public String getObject() {
return model.getObject().getDescription(ScenePanel.this);
}
});
Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new IModel<String>() {
@Override
public String getObject() {
String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
}
});
headerPanel.add(headerChangeType);
headerPanel.add(headerObjectType);
headerPanel.add(headerNameLabel);
headerPanel.add(headerNameLink);
headerPanel.add(headerDescription);
headerPanel.add(headerWrapperDisplayName);
headerChangeType.add(createHeaderOnClickBehaviour(model));
headerObjectType.add(createHeaderOnClickBehaviour(model));
headerNameLabel.add(createHeaderOnClickBehaviour(model));
headerDescription.add(createHeaderOnClickBehaviour(model));
headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return getModelObject().isWrapper();
}
};
VisibleEnableBehaviour visibleIfExistingObjectAndAuthorized = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return isExistingViewableObject() && isAutorized();
}
};
VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized = new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
if (getModelObject().isWrapper()) {
return false;
}
return !isExistingViewableObject() || !isAutorized();
}
};
headerChangeType.add(visibleIfNotWrapper);
headerObjectType.add(visibleIfNotWrapper);
headerNameLabel.add(visibleIfNotWrapperAndNotExistingObjectAndNotAuthorized);
headerNameLink.add(visibleIfExistingObjectAndAuthorized);
headerDescription.add(visibleIfNotWrapper);
headerWrapperDisplayName.add(visibleIfWrapper);
WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
body.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
SceneDto wrapper = model.getObject();
return !wrapper.isMinimized();
}
});
box.add(body);
WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
itemsTable.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().getItems().isEmpty();
}
});
itemsTable.setOutputMarkupId(true);
ToggleIconButton<String> sortPropertiesButton = new ToggleIconButton<String>(ID_SORT_PROPERTIES, GuiStyleConstants.CLASS_ICON_SORT_ALPHA_ASC, GuiStyleConstants.CLASS_ICON_SORT_AMOUNT_ASC) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
onSortClicked(model, target);
}
@Override
public boolean isOn() {
return model.getObject().isSorted();
}
};
sortPropertiesButton.setOutputMarkupId(true);
sortPropertiesButton.setOutputMarkupPlaceholderTag(true);
itemsTable.add(sortPropertiesButton);
WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
oldValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(oldValueLabel);
WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
newValueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return model.getObject().containsDeltaItems();
}
});
itemsTable.add(newValueLabel);
WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
valueLabel.add(new VisibleEnableBehaviour() {
@Override
public boolean isVisible() {
return !model.getObject().containsDeltaItems();
}
});
itemsTable.add(valueLabel);
ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<>(model, SceneDto.F_ITEMS)) {
@Override
protected void populateItem(ListItem<SceneItemDto> item) {
SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
panel.add(new VisibleBehaviour(() -> !isOperationalItem(item.getModel()) || isOperationalItemsVisible()));
panel.setRenderBodyOnly(true);
item.add(panel);
}
};
items.setReuseItems(true);
itemsTable.add(items);
body.add(itemsTable);
ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<>(model, SceneDto.F_PARTIAL_SCENES)) {
@Override
protected void populateItem(ListItem<SceneDto> item) {
ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel()) {
private static final long serialVersionUID = 1L;
@Override
protected boolean isOperationalItemsVisible() {
ScenePanel parentScenePanel = findParent(ScenePanel.class);
if (parentScenePanel != null) {
return parentScenePanel.isOperationalItemsVisible();
} else {
return ScenePanel.this.operationalItemsVisible;
}
}
};
panel.add(new VisibleBehaviour(() -> !isOperationalPartialScene(item.getModel()) || operationalItemsVisible));
panel.setOutputMarkupPlaceholderTag(true);
item.add(panel);
}
};
partialScenes.setReuseItems(true);
body.add(partialScenes);
AjaxButton showOperationalItemsLink = new AjaxButton(ID_SHOW_OPERATIONAL_ITEMS_LINK) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
setOperationalItemsVisible(!operationalItemsVisible);
target.add(ScenePanel.this);
}
@Override
public IModel<?> getBody() {
return getShowOperationalItemsLinkLabel();
}
};
showOperationalItemsLink.setOutputMarkupId(true);
showOperationalItemsLink.add(AttributeAppender.append("style", "cursor: pointer;"));
showOperationalItemsLink.add(new VisibleBehaviour(() -> showOperationalItems));
body.add(showOperationalItemsLink);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class ProgressPanel method initLayout.
private void initLayout() {
MidpointForm progressForm = new MidpointForm<>(ID_PROGRESS_FORM, true);
add(progressForm);
contentsPanel = new WebMarkupContainer(ID_CONTENTS_PANEL);
contentsPanel.setOutputMarkupId(true);
progressForm.add(contentsPanel);
ListView statusItemsListView = new ListView<ProgressReportActivityDto>(ID_ACTIVITIES, new IModel<List<ProgressReportActivityDto>>() {
@Override
public List<ProgressReportActivityDto> getObject() {
ProgressReporter reporter = reporterModel.getProcessData();
ProgressDto progressDto = reporter.getProgress();
return progressDto.getProgressReportActivities();
}
}) {
@Override
protected void populateItem(ListItem<ProgressReportActivityDto> item) {
populateStatusItem(item);
}
};
contentsPanel.add(statusItemsListView);
statisticsPanel = new StatisticsPanel(ID_STATISTICS, new StatisticsDtoModel());
contentsPanel.add(statisticsPanel);
ListView logItemsListView = new ListView(ID_LOG_ITEMS, new IModel<List>() {
@Override
public List getObject() {
ProgressReporter reporter = reporterModel.getProcessData();
ProgressDto progressDto = reporter.getProgress();
return progressDto.getLogItems();
}
}) {
@Override
protected void populateItem(ListItem item) {
item.add(new Label(ID_LOG_ITEM, item.getModel()));
}
};
contentsPanel.add(logItemsListView);
Label executionTime = new Label(ID_EXECUTION_TIME, new IModel<String>() {
@Override
public String getObject() {
ProgressReporter reporter = reporterModel.getProcessData();
if (reporter.getOperationDurationTime() > 0) {
return getString("ProgressPanel.ExecutionTimeWhenFinished", reporter.getOperationDurationTime());
} else if (reporter.getOperationStartTime() > 0) {
return getString("ProgressPanel.ExecutionTimeWhenRunning", (System.currentTimeMillis() - reporter.getOperationStartTime()) / 1000);
} else {
return null;
}
}
});
contentsPanel.add(executionTime);
initButtons(progressForm);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class ResourceSchemaHandlingTabPanel method initLayout.
private void initLayout() {
MidpointForm<?> form = new MidpointForm<>(ID_FORM);
add(form);
MultivalueContainerListPanelWithDetailsPanel<ResourceObjectTypeDefinitionType> objectTypesPanel = new MultivalueContainerListPanelWithDetailsPanel<>(ID_TABLE, ResourceObjectTypeDefinitionType.class) {
@Override
protected MultivalueContainerDetailsPanel<ResourceObjectTypeDefinitionType> getMultivalueContainerDetailsPanel(ListItem<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>> item) {
return createMultivalueContainerDetailsPanel(ID_ITEM_DETAILS, item.getModel());
}
@Override
protected boolean isCreateNewObjectVisible() {
return false;
}
@Override
protected IModel<PrismContainerWrapper<ResourceObjectTypeDefinitionType>> getContainerModel() {
return PrismContainerWrapperModel.fromContainerWrapper(ResourceSchemaHandlingTabPanel.this.getModel(), SchemaHandlingType.F_OBJECT_TYPE);
}
@Override
protected UserProfileStorage.TableId getTableId() {
return null;
}
@Override
protected List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> createDefaultColumns() {
List<IColumn<PrismContainerValueWrapper<ResourceObjectTypeDefinitionType>, String>> columns = new ArrayList<>();
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DISPLAY_NAME, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_KIND, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_INTENT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DEFAULT, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
columns.add(new PrismPropertyWrapperColumn<>(getContainerModel(), ResourceObjectTypeDefinitionType.F_DESCRIPTION, AbstractItemWrapperColumn.ColumnType.STRING, getPageBase()));
List<InlineMenuItem> menuActionsList = getMultivalueContainerListPanel().getDefaultMenuActions();
columns.add(new InlineMenuButtonColumn(menuActionsList, getPageBase()) {
private static final long serialVersionUID = 1L;
@Override
public String getCssClass() {
return " col-md-1 ";
}
});
return columns;
}
};
form.add(objectTypesPanel);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class ActivitiesItemProcessingPanel method initLayoutNew.
private void initLayoutNew() {
ListView<ActivityItemProcessingDto> activitiesView = new ListView<>(ID_ACTIVITIES, new PropertyModel<>(getModel(), ActivitiesItemProcessingDto.F_ACTIVITIES)) {
@Override
protected void populateItem(ListItem<ActivityItemProcessingDto> listItem) {
IModel<ActivityItemProcessingDto> itemProcessingModel = listItem.getModel();
Label summary = new Label(ID_SUMMARY, PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_TITLE));
summary.setOutputMarkupId(true);
listItem.add(summary);
Label wallClockThroughput = new Label(ID_WALL_CLOCK_THROUGHPUT, PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_WALL_CLOCK_THROUGHPUT));
summary.setOutputMarkupId(true);
listItem.add(wallClockThroughput);
ChartJsPanel<PieChartConfiguration> chartPanel = new ChartJsPanel<>(ID_CHART, PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_CHART));
listItem.add(chartPanel);
chartPanel.add(new VisibleBehaviour(() -> itemProcessingModel.getObject().getTotalCount() > 0));
PropertyModel<List<ProcessedItemDto>> currentItemsModel = PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_CURRENT_ITEMS);
BoxedTablePanel<ProcessedItemDto> currentItems = new BoxedTablePanel<>(ID_CURRENT_ITEMS, new ListDataProvider<>(ActivitiesItemProcessingPanel.this, currentItemsModel), createCurrentItemsColumns()) {
@Override
protected boolean hideFooterIfSinglePage() {
return true;
}
@Override
public String getAdditionalBoxCssClasses() {
return " box-info ";
}
};
currentItems.setOutputMarkupId(true);
currentItems.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(currentItemsModel.getObject())));
listItem.add(currentItems);
listItem.add(createInfoBoxPanel(PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_SUCCESS_BOX), ID_SUCCESS_ITEM));
listItem.add(createInfoBoxPanel(PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_FAILED_BOX), ID_FAILED_ITEM));
listItem.add(createInfoBoxPanel(PropertyModel.of(itemProcessingModel, ActivityItemProcessingDto.F_SKIP_BOX), ID_SKIPPED_ITEM));
}
};
activitiesView.setOutputMarkupId(true);
add(activitiesView);
}
use of org.apache.wicket.markup.html.list.ListItem in project midpoint by Evolveum.
the class PolyStringEditorPanel method initLayout.
private void initLayout() {
setOutputMarkupId(true);
String localizedValue = getLocalizedPolyStringValue();
WebMarkupContainer localizedValueContainer = new WebMarkupContainer(ID_LOCALIZED_VALUE_CONTAINER);
localizedValueContainer.setOutputMarkupId(true);
localizedValueContainer.add(getInputFieldClassAppenderForContainer());
localizedValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isNotEmpty(localizedValue)));
add(localizedValueContainer);
Label localizedValueLabel = new Label(ID_LOCALIZED_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.localizedValue"));
localizedValueLabel.setOutputMarkupId(true);
localizedValueLabel.add(new VisibleBehaviour(() -> showFullData));
localizedValueContainer.add(localizedValueLabel);
WebMarkupContainer localizedValueWithButton = new WebMarkupContainer(ID_LOCALIZED_VALUE_WITH_BUTTON);
localizedValueWithButton.setOutputMarkupId(true);
localizedValueWithButton.add(getInputFieldClassAppender());
localizedValueContainer.add(localizedValueWithButton);
TextPanel<String> localizedValuePanel = new TextPanel<>(ID_LOCALIZED_VALUE_PANEL, Model.of(localizedValue));
localizedValuePanel.setOutputMarkupId(true);
localizedValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
localizedValuePanel.add(new EnableBehaviour(() -> false));
localizedValueWithButton.add(localizedValuePanel);
AjaxButton showHideLanguagesLocalizedButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_LOCALIZED) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesLocalizedButton.setOutputMarkupId(true);
// showHideLanguagesLocalizedButton.add(AttributeAppender.append("style", "cursor: pointer;"));
localizedValueWithButton.add(showHideLanguagesLocalizedButton);
WebMarkupContainer originValueContainer = new WebMarkupContainer(ID_ORIGIN_VALUE_CONTAINER);
originValueContainer.setOutputMarkupId(true);
originValueContainer.add(getInputFieldClassAppenderForContainer());
originValueContainer.add(new VisibleBehaviour(() -> showFullData || StringUtils.isEmpty(localizedValue)));
add(originValueContainer);
Label origValueLabel = new Label(ID_ORIG_VALUE_LABEL, ((PageBase) getPage()).createStringResource("PolyStringEditorPanel.origValue"));
origValueLabel.setOutputMarkupId(true);
origValueLabel.add(new VisibleBehaviour(() -> showFullData));
originValueContainer.add(origValueLabel);
WebMarkupContainer origValueWithButton = new WebMarkupContainer(ID_ORIG_VALUE_WITH_BUTTON);
origValueWithButton.add(getInputFieldClassAppender());
origValueWithButton.setOutputMarkupId(true);
originValueContainer.add(origValueWithButton);
InputPanel origValuePanel;
IModel<String> origValueModel = new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null ? getModelObject().getOrig() : null;
}
@Override
public void setObject(String object) {
PolyString oldModelObject = getModelObject();
if (oldModelObject != null && (oldModelObject.getTranslation() != null || MapUtils.isNotEmpty(oldModelObject.getLang()))) {
getModel().setObject(new PolyString(object, oldModelObject.getNorm(), oldModelObject.getTranslation(), oldModelObject.getLang()));
} else if (StringUtils.isNotBlank(object)) {
getModel().setObject(new PolyString(object));
} else {
getModel().setObject(null);
}
}
@Override
public void detach() {
}
};
if (predefinedValuesLookupTable == null) {
origValuePanel = new TextPanel<>(ID_ORIG_VALUE, origValueModel, String.class, false);
} else {
origValuePanel = new AutoCompleteTextPanel<String>(ID_ORIG_VALUE, origValueModel, String.class, hasValueEnumerationRef, predefinedValuesLookupTable) {
private static final long serialVersionUID = 1L;
@Override
public Iterator<String> getIterator(String input) {
return getPredefinedValuesIterator(input).iterator();
}
};
}
origValuePanel.setOutputMarkupId(true);
origValuePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
origValueWithButton.add(origValuePanel);
WebMarkupContainer fullDataContainer = new WebMarkupContainer(ID_FULL_DATA_CONTAINER);
fullDataContainer.setOutputMarkupId(true);
fullDataContainer.add(new VisibleBehaviour(() -> showFullData));
add(fullDataContainer);
TextPanel<String> keyValue = new TextPanel<>(ID_KEY_VALUE, new IModel<String>() {
private static final long serialVersionUID = 1L;
@Override
public String getObject() {
return getModelObject() != null && getModelObject().getTranslation() != null ? getModelObject().getTranslation().getKey() : null;
}
@Override
public void setObject(String object) {
if (getModelObject() == null) {
getModel().setObject(new PolyString(""));
}
if (getModelObject().getTranslation() == null) {
getModelObject().setTranslation(new PolyStringTranslationType());
}
getModelObject().getTranslation().setKey(object);
}
@Override
public void detach() {
}
});
keyValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour());
keyValue.setOutputMarkupId(true);
fullDataContainer.add(keyValue);
IModel<String> langChoiceModel = Model.of();
WebMarkupContainer languageEditorContainer = new WebMarkupContainer(ID_LANGUAGE_EDITOR);
languageEditorContainer.setOutputMarkupId(true);
languageEditorContainer.add(new VisibleBehaviour(() -> CollectionUtils.isNotEmpty(getLanguageChoicesModel().getObject())));
fullDataContainer.add(languageEditorContainer);
final DropDownChoicePanel<String> languageChoicePanel = new DropDownChoicePanel<>(ID_LANGUAGES_LIST, langChoiceModel, getLanguageChoicesModel(), true);
languageChoicePanel.setOutputMarkupId(true);
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior());
languageChoicePanel.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
removeLanguageValue(currentlySelectedLang.toString());
clearSelectedLanguageValue();
currentlySelectedLang.append(getLanguagesChoicePanel().getBaseFormComponent().getModelObject());
}
});
languageEditorContainer.add(languageChoicePanel);
final TextPanel<String> newLanguageValue = new TextPanel<>(ID_VALUE_TO_ADD, Model.of());
newLanguageValue.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
languageChoicePanel.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageChoicePanel.getBaseFormComponent().getModelObject(), newLanguageValue.getBaseFormComponent().getValue());
}
});
newLanguageValue.setOutputMarkupId(true);
languageEditorContainer.add(newLanguageValue);
AjaxLink<Void> addLanguageButton = new AjaxLink<Void>(ID_ADD_LANGUAGE_VALUE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
updateLanguageValue(languageChoicePanel.getModel().getObject(), newLanguageValue.getBaseFormComponent().getModelObject());
languageChoicePanel.getModel().setObject(null);
newLanguageValue.getBaseFormComponent().getModel().setObject(null);
clearSelectedLanguageValue();
target.add(PolyStringEditorPanel.this);
}
};
addLanguageButton.add(AttributeAppender.append("style", "cursor: pointer;"));
addLanguageButton.setOutputMarkupId(true);
languageEditorContainer.add(addLanguageButton);
ListView<String> languagesContainer = new ListView<String>(ID_LANGUAGES_REPEATER, getLanguagesListModel()) {
private static final long serialVersionUID = 1L;
@Override
protected void populateItem(ListItem<String> listItem) {
TextPanel<String> languageName = new TextPanel<>(ID_LANGUAGE_NAME, listItem.getModel());
languageName.add(new EnableBehaviour(() -> false));
languageName.setOutputMarkupId(true);
listItem.add(languageName);
TextPanel<String> translation = new TextPanel<>(ID_TRANSLATION, Model.of(getLanguageValueByKey(listItem.getModelObject())));
translation.getBaseFormComponent().add(new EmptyOnBlurAjaxFormUpdatingBehaviour() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget target) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
translation.setOutputMarkupId(true);
translation.getBaseFormComponent().add(new EmptyOnChangeAjaxFormUpdatingBehavior() {
private static final long serialVersionUID = 1L;
@Override
protected void onUpdate(AjaxRequestTarget ajaxRequestTarget) {
updateLanguageValue(languageName.getBaseFormComponent().getValue(), translation.getBaseFormComponent().getValue());
}
});
listItem.add(translation);
AjaxLink<Void> removeButton = new AjaxLink<Void>(ID_REMOVE_LANGUAGE_BUTTON) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
removeLanguageValue(listItem.getModelObject());
target.add(PolyStringEditorPanel.this);
}
};
removeButton.setOutputMarkupId(true);
listItem.add(removeButton);
}
};
languagesContainer.setOutputMarkupId(true);
fullDataContainer.add(languagesContainer);
AjaxButton showHideLanguagesButton = new AjaxButton(ID_SHOW_HIDE_LANGUAGES_ORIG) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
showHideLanguagesPerformed(target);
}
};
showHideLanguagesButton.setOutputMarkupId(true);
// showHideLanguagesButton.add(AttributeAppender.append("style", "cursor: pointer;"));
origValueWithButton.add(showHideLanguagesButton);
}
Aggregations