final FieldScreenTab fieldScreenTab = fieldScreenManager.getFieldScreenTab(tabId); fieldScreenTab.getFieldScreen().removeFieldScreenLayoutItem(getFieldId()); final FieldScreenTab fieldScreenTab = fieldScreenManager.getFieldScreenTab(tabId); fieldScreenTab.addFieldScreenLayoutItem(getFieldId());
public ServiceOutcomeImpl<List<Long>> removeFromScreenTabs(final ApplicationUser user, final Long customFieldId, final List<Long> tabIds) { Preconditions.checkArgument(customFieldId != null, "customFieldId can not be null."); Preconditions.checkArgument(tabIds != null && !tabIds.isEmpty(), "List of tabs can not be null or empty."); final ErrorCollection errorCollection = new SimpleErrorCollection(); final I18nHelper i18nBean = i18nFactory.getInstance(user); if (user == null || !permissionManager.hasPermission(Permissions.ADMINISTER, user)) { errorCollection.addErrorMessage(i18nBean.getText("admin.customfields.service.no.admin.permission")); return new ServiceOutcomeImpl<List<Long>>(errorCollection, Collections.EMPTY_LIST); } for (final Long screenId : tabIds) { final FieldScreenTab fieldScreenTab = fieldScreenManager.getFieldScreenTab(screenId); fieldScreenTab.getFieldScreen().removeFieldScreenLayoutItem("customfield_" + customFieldId); } return new ServiceOutcomeImpl<List<Long>>(errorCollection, getListOfCurrentTabs(customFieldId)); }
public ServiceOutcomeImpl<List<Long>> addToScreenTabs(final ApplicationUser user, final Long customFieldId, final List<Long> tabIds) { Preconditions.checkArgument(customFieldId != null, "customFieldId can not be null."); Preconditions.checkArgument(tabIds != null && !tabIds.isEmpty(), "List of tabs can not be null or empty."); final ErrorCollection errorCollection = new SimpleErrorCollection(); final I18nHelper i18nBean = i18nFactory.getInstance(user); if (user == null || !permissionManager.hasPermission(Permissions.ADMINISTER, user)) { errorCollection.addErrorMessage(i18nBean.getText("admin.customfields.service.no.admin.permission")); return new ServiceOutcomeImpl<List<Long>>(errorCollection, Collections.EMPTY_LIST); } for (final Long screenId : tabIds) { final FieldScreenTab fieldScreenTab = fieldScreenManager.getFieldScreenTab(screenId); final String customFieldKey = "customfield_" + customFieldId; if (!fieldScreenTab.isContainsField(customFieldKey)) { fieldScreenTab.addFieldScreenLayoutItem(customFieldKey); } else { errorCollection.addErrorMessage(i18nBean.getText("admin.errors.field.with.id.already.exists", customFieldKey)); return new ServiceOutcomeImpl<List<Long>>(errorCollection, getListOfCurrentTabs(customFieldId)); } } return new ServiceOutcomeImpl<List<Long>>(errorCollection, getListOfCurrentTabs(customFieldId)); }