use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class ScreenSettingsManagerImpl method saveSettings.
@Override
public void saveSettings(Collection<Component> components, ScreenSettings screenSettings) {
Preconditions.checkNotNullArgument(components);
Preconditions.checkNotNullArgument(screenSettings);
boolean isModified = false;
for (Component component : components) {
if (!settingsRegistry.isSettingsRegisteredFor(component.getClass()) || component.getId() == null) {
continue;
}
log.trace("Saving settings for {} : {}", getComponentPath(component), component);
Class<? extends ComponentSettings> settingsClass = settingsRegistry.getSettingsClass(component.getClass());
ComponentSettings settings = screenSettings.getSettingsOrCreate(component.getId(), settingsClass);
ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
boolean settingsChanged = binder.saveSettings(component, new SettingsWrapperImpl(settings));
if (settingsChanged) {
isModified = true;
screenSettings.put(settings);
}
}
if (isModified || screenSettings.isModified()) {
if (screenSettings instanceof AbstractScreenSettings) {
((AbstractScreenSettings) screenSettings).commit();
}
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class ScreenSettingsManagerImpl method applyDataLoadingSettings.
@Override
public void applyDataLoadingSettings(Collection<Component> components, ScreenSettings screenSettings) {
Preconditions.checkNotNullArgument(components);
Preconditions.checkNotNullArgument(screenSettings);
for (Component component : components) {
if (!settingsRegistry.isSettingsRegisteredFor(component.getClass()) || component.getId() == null) {
continue;
}
log.trace("Applying settings for {} : {} ", getComponentPath(component), component);
Class<? extends ComponentSettings> settingsClass = settingsRegistry.getSettingsClass(component.getClass());
ComponentSettingsBinder binder = settingsRegistry.getSettingsBinder(component.getClass());
if (binder instanceof DataLoadingSettingsBinder) {
ComponentSettings settings = screenSettings.getSettingsOrCreate(component.getId(), settingsClass);
((DataLoadingSettingsBinder) binder).applyDataLoadingSettings(component, new SettingsWrapperImpl(settings));
}
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class FilterEditAction method execute.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void execute() {
if (filter.getFrame() == null) {
throw new IllegalStateException("Filter component is not attached to the Frame");
}
Filter.Configuration currentConfiguration = filter.getCurrentConfiguration();
boolean isNewConfiguration = Objects.equals(currentConfiguration.getId(), filter.getEmptyConfiguration().getId());
LogicalFilterComponent rootComponent = currentConfiguration.getRootLogicalFilterComponent();
Class modelClass = filterComponents.getModelClass(rootComponent.getClass());
FilterConverter converter = filterComponents.getConverterByComponentClass(rootComponent.getClass(), filter);
Map<String, Object> valuesMap = filterSupport.initConfigurationValuesMap(currentConfiguration);
LogicalFilterCondition model = (LogicalFilterCondition) converter.convertToModel(rootComponent);
Screen editScreen = createEditScreen(modelClass, model);
applyScreenConfigurer(editScreen);
ScreenFragment screenFragment = filterSupport.createFilterConfigurationFragment(editScreen.getWindow().getFrameOwner(), isNewConfiguration, currentConfiguration);
Fragment fragment = screenFragment.getFragment();
fragment.setWidthFull();
editScreen.getWindow().add(fragment, 0);
editScreen.getWindow().setCaption(messages.getMessage(FilterEditAction.class, "configurationEdit.caption"));
if (editScreen instanceof GroupFilterConditionEdit) {
Component groupConditionBox = editScreen.getWindow().getComponent("groupConditionBox");
if (groupConditionBox instanceof Component.HasCaption) {
((Component.HasCaption) groupConditionBox).setCaption(messages.getMessage(FilterEditAction.class, "configurationEdit.rootGroupCondition"));
}
}
editScreen.addAfterCloseListener(afterCloseEvent -> {
if (afterCloseEvent.closedWith(StandardOutcome.COMMIT)) {
LogicalFilterCondition filterCondition = (LogicalFilterCondition) ((FilterConditionEdit) afterCloseEvent.getSource()).getInstanceContainer().getItem();
onEditScreenAfterCommit(screenFragment, filterCondition, converter, isNewConfiguration, currentConfiguration, valuesMap);
} else {
filterSupport.resetConfigurationValuesMap(currentConfiguration, valuesMap);
}
});
editScreen.show();
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class AbstractAction method setEnabled.
@Override
public void setEnabled(boolean enabled) {
boolean oldValue = this.enabled;
if (oldValue != enabled) {
this.enabled = enabled;
for (ActionOwner owner : owners) {
if (owner instanceof Component) {
((Component) owner).setEnabled(enabled);
}
}
firePropertyChange(PROP_ENABLED, oldValue, enabled);
}
}
use of io.jmix.ui.component.Component in project jmix by jmix-framework.
the class AbstractAction method setVisible.
@Override
public void setVisible(boolean visible) {
boolean oldValue = this.visible;
if (oldValue != visible) {
this.visible = visible;
for (ActionOwner owner : owners) {
if (owner instanceof Component) {
((Component) owner).setVisible(visible);
}
}
firePropertyChange(PROP_VISIBLE, oldValue, visible);
}
}
Aggregations