@@ -18,12 +18,9 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
|
|||||||
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
|
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.common.CoordinatesToColor;
|
|
||||||
import org.eclipse.hawkbit.ui.common.PopupWindowHelp;
|
|
||||||
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.SpColorPickerPreview;
|
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
@@ -35,22 +32,14 @@ import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
|||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
import com.vaadin.data.Property.ValueChangeListener;
|
|
||||||
import com.vaadin.server.Page;
|
|
||||||
import com.vaadin.shared.ui.colorpicker.Color;
|
import com.vaadin.shared.ui.colorpicker.Color;
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
|
|
||||||
import com.vaadin.ui.Alignment;
|
import com.vaadin.ui.Alignment;
|
||||||
import com.vaadin.ui.Button;
|
import com.vaadin.ui.Button;
|
||||||
import com.vaadin.ui.Button.ClickEvent;
|
import com.vaadin.ui.Button.ClickEvent;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.OptionGroup;
|
import com.vaadin.ui.OptionGroup;
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
@@ -61,7 +50,7 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout
|
||||||
implements ColorChangeListener, ColorSelector {
|
implements ColorChangeListener, ColorSelector {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5169398523815919367L;
|
private static final long serialVersionUID = -5169398523815919367L;
|
||||||
@@ -73,34 +62,19 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient UiProperties uiProperties;
|
private transient UiProperties uiProperties;
|
||||||
|
|
||||||
private VerticalLayout sliderLayout;
|
|
||||||
private HorizontalLayout colorLayout;
|
|
||||||
private String createTypeStr;
|
|
||||||
private String updateTypeStr;
|
|
||||||
private String singleAssignStr;
|
private String singleAssignStr;
|
||||||
private String multiAssignStr;
|
private String multiAssignStr;
|
||||||
private Label createType;
|
|
||||||
private Label updateType;
|
|
||||||
private Label singleAssign;
|
private Label singleAssign;
|
||||||
private Label multiAssign;
|
private Label multiAssign;
|
||||||
private Label comboLabel;
|
|
||||||
private TextField typeKey;
|
|
||||||
private OptionGroup createOptiongroup;
|
|
||||||
private OptionGroup assignOptiongroup;
|
private OptionGroup assignOptiongroup;
|
||||||
private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
|
||||||
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
|
||||||
private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
|
||||||
|
|
||||||
/** RGB color converter. */
|
@Override
|
||||||
private final Coordinates2Color rgbConverter = new CoordinatesToColor();
|
protected void createRequiredComponents() {
|
||||||
|
|
||||||
private void createComponents() {
|
|
||||||
createTypeStr = i18n.get("label.create.type");
|
createTypeStr = i18n.get("label.create.type");
|
||||||
updateTypeStr = i18n.get("label.update.type");
|
updateTypeStr = i18n.get("label.update.type");
|
||||||
singleAssignStr = i18n.get("label.singleAssign.type");
|
singleAssignStr = i18n.get("label.singleAssign.type");
|
||||||
multiAssignStr = i18n.get("label.multiAssign.type");
|
multiAssignStr = i18n.get("label.multiAssign.type");
|
||||||
createType = SPUIComponentProvider.getLabel(createTypeStr, null);
|
|
||||||
updateType = SPUIComponentProvider.getLabel(updateTypeStr, null);
|
|
||||||
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
|
||||||
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||||
@@ -138,9 +112,8 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
|
|
||||||
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||||
|
|
||||||
createUpdateOptionGroup();
|
|
||||||
|
|
||||||
singleMultiOptionGroup();
|
singleMultiOptionGroup();
|
||||||
|
createOptionGroup(permChecker.hasCreateDistributionPermission(), permChecker.hasUpdateDistributionPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -148,25 +121,7 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
|
|
||||||
super.buildLayout();
|
super.buildLayout();
|
||||||
getFormLayout().addComponent(typeKey, 4);
|
getFormLayout().addComponent(typeKey, 4);
|
||||||
getFormLayout().addComponent(assignOptiongroup, 5);
|
getFormLayout().addComponent(assignOptiongroup);
|
||||||
|
|
||||||
final HorizontalLayout mainLayout = new HorizontalLayout();
|
|
||||||
|
|
||||||
mainLayout.addComponent(getFormLayout());
|
|
||||||
|
|
||||||
colorLayout = new HorizontalLayout();
|
|
||||||
sliderLayout = new VerticalLayout();
|
|
||||||
final HorizontalLayout chooseColorLayout = new HorizontalLayout();
|
|
||||||
chooseColorLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
|
||||||
chooseColorLayout.setComponentAlignment(colorLabel, Alignment.TOP_CENTER);
|
|
||||||
chooseColorLayout.setComponentAlignment(tagColorPreviewBtn, Alignment.TOP_CENTER);
|
|
||||||
sliderLayout.addComponent(chooseColorLayout);
|
|
||||||
colorLayout.addComponent(sliderLayout);
|
|
||||||
|
|
||||||
final VerticalLayout mainWindowLayout = new VerticalLayout();
|
|
||||||
mainWindowLayout.addComponent(new PopupWindowHelp(uiProperties.getLinks().getDocumentation().getRoot()));
|
|
||||||
mainWindowLayout.addComponent(mainLayout);
|
|
||||||
mainWindowLayout.addComponent(colorLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,42 +137,16 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
* @param event
|
* @param event
|
||||||
* ValueChangeEvent
|
* ValueChangeEvent
|
||||||
*/
|
*/
|
||||||
private void createOptionValueChanged(final ValueChangeEvent event) {
|
@Override
|
||||||
|
protected void createOptionValueChanged(final ValueChangeEvent event) {
|
||||||
|
|
||||||
|
super.createOptionValueChanged(event);
|
||||||
|
|
||||||
if ("Update Type".equals(event.getProperty().getValue())) {
|
if ("Update Type".equals(event.getProperty().getValue())) {
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
typeKey.setEnabled(false);
|
|
||||||
tagName.setEnabled(false);
|
|
||||||
assignOptiongroup.setEnabled(false);
|
assignOptiongroup.setEnabled(false);
|
||||||
|
|
||||||
populateTagNameCombo();
|
|
||||||
// show target name combo
|
|
||||||
comboLayout.addComponent(comboLabel);
|
|
||||||
comboLayout.addComponent(tagNameComboBox);
|
|
||||||
} else {
|
} else {
|
||||||
typeKey.setEnabled(true);
|
|
||||||
tagName.setEnabled(true);
|
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
assignOptiongroup.setEnabled(true);
|
assignOptiongroup.setEnabled(true);
|
||||||
// hide target name combo
|
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(tagNameComboBox);
|
|
||||||
}
|
}
|
||||||
// close the color picker layout
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
// reset the selected color - Set defualt color
|
|
||||||
restoreComponentStyles();
|
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
getColorPickerLayout().getSelPreview()
|
|
||||||
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
// remove the sliders and color picker layout
|
|
||||||
|
|
||||||
// TODO MR
|
|
||||||
// fieldLayout.removeComponent(sliders);
|
|
||||||
// mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -227,37 +156,16 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
protected void reset() {
|
protected void reset() {
|
||||||
|
|
||||||
super.reset();
|
super.reset();
|
||||||
typeKey.clear();
|
|
||||||
assignOptiongroup.select(singleAssignStr);
|
assignOptiongroup.select(singleAssignStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void typeNameChosen(final ValueChangeEvent event) {
|
@Override
|
||||||
final String tagSelected = (String) event.getProperty().getValue();
|
protected void resetTagNameField() {
|
||||||
if (null != tagSelected) {
|
|
||||||
setTypeTagCombo(tagSelected);
|
|
||||||
} else {
|
|
||||||
resetTagNameField();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void resetTagNameField() {
|
|
||||||
tagName.setEnabled(false);
|
|
||||||
tagName.clear();
|
|
||||||
|
|
||||||
|
super.resetTagNameField();
|
||||||
typeKey.clear();
|
typeKey.clear();
|
||||||
tagDesc.clear();
|
tagDesc.clear();
|
||||||
restoreComponentStyles();
|
|
||||||
|
|
||||||
// fieldLayout.removeComponent(sliders);
|
|
||||||
// mainLayout.removeComponent(colorPickerLayout);
|
|
||||||
|
|
||||||
assignOptiongroup.select(singleAssignStr);
|
assignOptiongroup.select(singleAssignStr);
|
||||||
// Default green color
|
|
||||||
|
|
||||||
// TODO extra method
|
|
||||||
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
|
||||||
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
|
||||||
tagPreviewBtnClicked = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -267,7 +175,8 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
* @param targetTagSelected
|
* @param targetTagSelected
|
||||||
* as the selected tag from combo
|
* as the selected tag from combo
|
||||||
*/
|
*/
|
||||||
private void setTypeTagCombo(final String targetTagSelected) {
|
@Override
|
||||||
|
protected void setTagDetails(final String targetTagSelected) {
|
||||||
tagName.setValue(targetTagSelected);
|
tagName.setValue(targetTagSelected);
|
||||||
final SoftwareModuleType selectedTypeTag = swTypeManagementService
|
final SoftwareModuleType selectedTypeTag = swTypeManagementService
|
||||||
.findSoftwareModuleTypeByName(targetTagSelected);
|
.findSoftwareModuleTypeByName(targetTagSelected);
|
||||||
@@ -280,35 +189,9 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
assignOptiongroup.setValue(singleAssignStr);
|
assignOptiongroup.setValue(singleAssignStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO extra method
|
setColorPickerComponentsColor(selectedTypeTag.getColour());
|
||||||
if (null == selectedTypeTag.getColour()) {
|
|
||||||
getColorPickerLayout()
|
|
||||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
getColorPickerLayout()
|
|
||||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(selectedTypeTag.getColour()));
|
|
||||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, selectedTypeTag.getColour());
|
|
||||||
getPreviewButtonColor(selectedTypeTag.getColour());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void createUpdateOptionGroup() {
|
|
||||||
final List<String> optionValues = new ArrayList<>();
|
|
||||||
if (permChecker.hasCreateDistributionPermission()) {
|
|
||||||
optionValues.add(createType.getValue());
|
|
||||||
}
|
|
||||||
if (permChecker.hasUpdateDistributionPermission()) {
|
|
||||||
optionValues.add(updateType.getValue());
|
|
||||||
}
|
|
||||||
createOptionGroupByValues(optionValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void singleMultiOptionGroup() {
|
private void singleMultiOptionGroup() {
|
||||||
final List<String> optionValues = new ArrayList<>();
|
final List<String> optionValues = new ArrayList<>();
|
||||||
@@ -317,17 +200,6 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
assignOptionGroupByValues(optionValues);
|
assignOptionGroupByValues(optionValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOptionGroupByValues(final List<String> tagOptions) {
|
|
||||||
createOptiongroup = new OptionGroup("", tagOptions);
|
|
||||||
createOptiongroup.setCaption(null);
|
|
||||||
createOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
|
||||||
createOptiongroup.addStyleName("custom-option-group");
|
|
||||||
createOptiongroup.setNullSelectionAllowed(false);
|
|
||||||
if (!tagOptions.isEmpty()) {
|
|
||||||
createOptiongroup.select(tagOptions.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void assignOptionGroupByValues(final List<String> tagOptions) {
|
private void assignOptionGroupByValues(final List<String> tagOptions) {
|
||||||
assignOptiongroup = new OptionGroup("", tagOptions);
|
assignOptiongroup = new OptionGroup("", tagOptions);
|
||||||
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
assignOptiongroup.setStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||||
@@ -336,96 +208,35 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
assignOptiongroup.select(tagOptions.get(0));
|
assignOptiongroup.select(tagOptions.get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Value change listeners implementations of sliders.
|
|
||||||
*/
|
|
||||||
private void slidersValueChangeListeners() {
|
|
||||||
redSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = -8336732888800920839L;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
protected void save(final ClickEvent event) {
|
||||||
final double red = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color((int) red, selectedColor.getGreen(), selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
greenSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 1236358037766775663L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double green = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), (int) green, selectedColor.getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
blueSlider.addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 8466370763686043947L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double blue = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(selectedColor.getRed(), selectedColor.getGreen(), (int) blue);
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO extra method
|
|
||||||
private void setColorToComponents(final Color newColor) {
|
|
||||||
setColor(newColor);
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(newColor);
|
|
||||||
getPreviewButtonColor(newColor.getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, newColor.getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* reset the tag name and tag description component border color.
|
|
||||||
*/
|
|
||||||
private void restoreComponentStyles() {
|
|
||||||
tagName.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
tagDesc.removeStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
getPreviewButtonColor(DEFAULT_COLOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void save() {
|
|
||||||
if (mandatoryValuesPresent()) {
|
if (mandatoryValuesPresent()) {
|
||||||
final SoftwareModuleType existingType = swTypeManagementService
|
final SoftwareModuleType existingSMTypeByKey = swTypeManagementService
|
||||||
|
.findSoftwareModuleTypeByKey(typeKey.getValue());
|
||||||
|
final SoftwareModuleType existingSMTypeByName = swTypeManagementService
|
||||||
.findSoftwareModuleTypeByName(tagName.getValue());
|
.findSoftwareModuleTypeByName(tagName.getValue());
|
||||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
if (!checkIsKeyDuplicate(typeKey.getValue()) && !checkIsDuplicate(existingType)) {
|
if (!checkIsDuplicateByKey(existingSMTypeByKey) && !checkIsDuplicate(existingSMTypeByName)) {
|
||||||
createNewSWModuleType();
|
createNewSWModuleType();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
updateSWModuleType(existingType);
|
updateSWModuleType(existingSMTypeByName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIsKeyDuplicate(final String key) {
|
|
||||||
final SoftwareModuleType existingKeyType = swTypeManagementService.findSoftwareModuleTypeByKey(key);
|
|
||||||
if (existingKeyType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.type.key.swmodule.duplicate.check", new Object[] { existingKeyType.getKey() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
private Boolean mandatoryValuesPresent() {
|
protected Boolean mandatoryValuesPresent() {
|
||||||
if (Strings.isNullOrEmpty(tagName.getValue()) && Strings.isNullOrEmpty(typeKey.getValue())) {
|
if (Strings.isNullOrEmpty(tagName.getValue()) || Strings.isNullOrEmpty(typeKey.getValue())) {
|
||||||
if (createOptiongroup.getValue().equals(createTypeStr)) {
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
||||||
}
|
}
|
||||||
if (createOptiongroup.getValue().equals(updateTypeStr)) {
|
if (optiongroup.getValue().equals(updateTypeStr)) {
|
||||||
if (null == tagNameComboBox.getValue()) {
|
if (null == tagNameComboBox.getValue()) {
|
||||||
uiNotification.displayValidationError(i18n.get("message.error.missing.tagName"));
|
displayValidationError(i18n.get("message.error.missing.tagName"));
|
||||||
} else {
|
} else {
|
||||||
uiNotification.displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Boolean.FALSE;
|
return Boolean.FALSE;
|
||||||
@@ -433,21 +244,12 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean checkIsDuplicate(final SoftwareModuleType existingType) {
|
|
||||||
if (existingType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.tag.duplicate.check", new Object[] { existingType.getName() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new tag.
|
* Create new tag.
|
||||||
*/
|
*/
|
||||||
private void createNewSWModuleType() {
|
private void createNewSWModuleType() {
|
||||||
int assignNumber = 0;
|
int assignNumber = 0;
|
||||||
final String colorPicked = getColorPickedString();
|
final String colorPicked = ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview());
|
||||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
||||||
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
final String typeDescValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagDesc.getValue());
|
||||||
@@ -479,25 +281,6 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get color picked value in string.
|
|
||||||
*
|
|
||||||
* @return String of color picked value.
|
|
||||||
*/
|
|
||||||
private String getColorPickedString() {
|
|
||||||
return "rgb(" + getSelPreview().getColor().getRed() + "," + getSelPreview().getColor().getGreen() + ","
|
|
||||||
+ getSelPreview().getColor().getBlue() + ")";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Color view.
|
|
||||||
*
|
|
||||||
* @return ColorPickerPreview as UI
|
|
||||||
*/
|
|
||||||
public SpColorPickerPreview getSelPreview() {
|
|
||||||
return selPreview;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* update tag.
|
* update tag.
|
||||||
*/
|
*/
|
||||||
@@ -510,7 +293,7 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
|
|
||||||
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
|
existingType.setDescription(null != typeDescValue ? typeDescValue : null);
|
||||||
|
|
||||||
existingType.setColour(getColorPickedString());
|
existingType.setColour(ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview()));
|
||||||
swTypeManagementService.updateSoftwareModuleType(existingType);
|
swTypeManagementService.updateSoftwareModuleType(existingType);
|
||||||
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
|
uiNotification.displaySuccess(i18n.get("message.update.success", new Object[] { existingType.getName() }));
|
||||||
closeWindow();
|
closeWindow();
|
||||||
@@ -528,28 +311,27 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
* on target tag if already selected.
|
* on target tag if already selected.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
private void previewButtonClicked() {
|
protected void previewButtonClicked() {
|
||||||
if (!tagPreviewBtnClicked) {
|
if (!tagPreviewBtnClicked) {
|
||||||
final String selectedOption = (String) createOptiongroup.getValue();
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTypeStr)) {
|
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTypeStr)) {
|
||||||
if (null != tagNameComboBox.getValue()) {
|
if (null != tagNameComboBox.getValue()) {
|
||||||
|
|
||||||
final SoftwareModuleType typeSelected = swTypeManagementService
|
final SoftwareModuleType typeSelected = swTypeManagementService
|
||||||
.findSoftwareModuleTypeByName(tagNameComboBox.getValue().toString());
|
.findSoftwareModuleTypeByName(tagNameComboBox.getValue().toString());
|
||||||
if (null != typeSelected) {
|
if (null != typeSelected) {
|
||||||
selectedColor = typeSelected.getColour() != null ? rgbToColorConverter(typeSelected.getColour())
|
getColorPickerLayout().setSelectedColor(typeSelected.getColour() != null
|
||||||
: rgbToColorConverter(DEFAULT_COLOR);
|
? ColorPickerHelper.rgbToColorConverter(typeSelected.getColour())
|
||||||
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
selectedColor = rgbToColorConverter(DEFAULT_COLOR);
|
getColorPickerLayout().setSelectedColor(
|
||||||
|
ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
selPreview.setColor(selectedColor);
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
fieldLayout.addComponent(sliders);
|
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||||
mainLayout.addComponent(colorPickerLayout);
|
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
|
|
||||||
}
|
}
|
||||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
}
|
}
|
||||||
@@ -588,71 +370,11 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setColor(final Color color) {
|
|
||||||
if (color == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedColor = color;
|
|
||||||
selPreview.setColor(selectedColor);
|
|
||||||
final String colorPickedPreview = selPreview.getColor().getCSS();
|
|
||||||
if (tagName.isEnabled() && null != colorSelect) {
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, colorPickedPreview);
|
|
||||||
colorSelect.setColor(selPreview.getColor());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void colorChanged(final ColorChangeEvent event) {
|
|
||||||
setColor(event.getColor());
|
|
||||||
for (final ColorSelector select : selectors) {
|
|
||||||
if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(selectedColor)) {
|
|
||||||
select.setColor(selectedColor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
setRgbSliderValues(selectedColor);
|
|
||||||
getPreviewButtonColor(event.getColor().getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, event.getColor().getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set tag name and desc field border color based on chosen color.
|
|
||||||
*
|
|
||||||
* @param tagName
|
|
||||||
* @param tagDesc
|
|
||||||
* @param taregtTagColor
|
|
||||||
*/
|
|
||||||
private void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
|
|
||||||
final TextArea tagDesc, final String typeTagColor) {
|
|
||||||
getTargetDynamicStyles(typeTagColor);
|
|
||||||
tagName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
tagDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get target style - Dynamically as per the color picked, cannot be done
|
|
||||||
* from the static css.
|
|
||||||
*
|
|
||||||
* @param colorPickedPreview
|
|
||||||
*/
|
|
||||||
private void getTargetDynamicStyles(final String colorPickedPreview) {
|
|
||||||
Page.getCurrent().getJavaScript()
|
|
||||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void save(final ClickEvent event) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void populateTagNameCombo() {
|
protected void populateTagNameCombo() {
|
||||||
tagNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
tagNameComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
|
||||||
@@ -660,10 +382,4 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTagLayout
|
|||||||
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void setTagDetails(final String tagSelected) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,10 +75,11 @@ public class CommonDialogWindow extends Window {
|
|||||||
mainLayout.addComponent(buttonLayout);
|
mainLayout.addComponent(buttonLayout);
|
||||||
mainLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
|
mainLayout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);
|
||||||
|
|
||||||
setSizeUndefined();
|
setHeight("60%");
|
||||||
|
setWidth("50%");
|
||||||
setCaption(caption);
|
setCaption(caption);
|
||||||
setContent(mainLayout);
|
setContent(mainLayout);
|
||||||
setResizable(false);
|
setResizable(true);
|
||||||
center();
|
center();
|
||||||
setModal(true);
|
setModal(true);
|
||||||
}
|
}
|
||||||
@@ -108,6 +109,7 @@ public class CommonDialogWindow extends Window {
|
|||||||
}
|
}
|
||||||
hlayout.addComponent(cancelButton);
|
hlayout.addComponent(cancelButton);
|
||||||
hlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);
|
hlayout.setComponentAlignment(cancelButton, Alignment.MIDDLE_RIGHT);
|
||||||
|
hlayout.addStyleName("actionButtonsMargin");
|
||||||
|
|
||||||
return hlayout;
|
return hlayout;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.distributions.disttype;
|
package org.eclipse.hawkbit.ui.distributions.disttype;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -21,12 +20,11 @@ import org.eclipse.hawkbit.ui.UiProperties;
|
|||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
|
||||||
import org.eclipse.hawkbit.ui.common.PopupWindowHelp;
|
|
||||||
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
|
||||||
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
|
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
|
||||||
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum;
|
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent.DistributionSetTypeEnum;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
|
||||||
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
import org.eclipse.hawkbit.ui.utils.SPUIComponetIdProvider;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
@@ -38,13 +36,11 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
|
||||||
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
import com.vaadin.data.Item;
|
import com.vaadin.data.Item;
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
import com.vaadin.data.Property.ValueChangeEvent;
|
||||||
import com.vaadin.data.Property.ValueChangeListener;
|
|
||||||
import com.vaadin.data.util.IndexedContainer;
|
import com.vaadin.data.util.IndexedContainer;
|
||||||
import com.vaadin.server.FontAwesome;
|
import com.vaadin.server.FontAwesome;
|
||||||
import com.vaadin.server.Page;
|
|
||||||
import com.vaadin.shared.ui.colorpicker.Color;
|
|
||||||
import com.vaadin.spring.annotation.SpringComponent;
|
import com.vaadin.spring.annotation.SpringComponent;
|
||||||
import com.vaadin.spring.annotation.ViewScope;
|
import com.vaadin.spring.annotation.ViewScope;
|
||||||
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
|
import com.vaadin.ui.AbstractSelect.ItemDescriptionGenerator;
|
||||||
@@ -54,13 +50,8 @@ import com.vaadin.ui.Button.ClickEvent;
|
|||||||
import com.vaadin.ui.CheckBox;
|
import com.vaadin.ui.CheckBox;
|
||||||
import com.vaadin.ui.Component;
|
import com.vaadin.ui.Component;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Label;
|
|
||||||
import com.vaadin.ui.OptionGroup;
|
|
||||||
import com.vaadin.ui.Table;
|
import com.vaadin.ui.Table;
|
||||||
import com.vaadin.ui.TextArea;
|
|
||||||
import com.vaadin.ui.TextField;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeEvent;
|
|
||||||
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
|
||||||
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
import com.vaadin.ui.components.colorpicker.ColorSelector;
|
||||||
import com.vaadin.ui.themes.ValoTheme;
|
import com.vaadin.ui.themes.ValoTheme;
|
||||||
@@ -70,13 +61,12 @@ import com.vaadin.ui.themes.ValoTheme;
|
|||||||
*/
|
*/
|
||||||
@SpringComponent
|
@SpringComponent
|
||||||
@ViewScope
|
@ViewScope
|
||||||
public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout implements ColorChangeListener, ColorSelector {
|
public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout
|
||||||
|
implements ColorChangeListener, ColorSelector {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5169398523815877767L;
|
private static final long serialVersionUID = -5169398523815877767L;
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateDistSetTypeLayout.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateDistSetTypeLayout.class);
|
||||||
|
|
||||||
private static final String TYPE_NAME_DYNAMIC_STYLE = "new-tag-name";
|
|
||||||
private static final String TYPE_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
|
||||||
private static final String DIST_TYPE_NAME = "name";
|
private static final String DIST_TYPE_NAME = "name";
|
||||||
private static final String DIST_TYPE_DESCRIPTION = "description";
|
private static final String DIST_TYPE_DESCRIPTION = "description";
|
||||||
private static final String DIST_TYPE_MANDATORY = "mandatory";
|
private static final String DIST_TYPE_MANDATORY = "mandatory";
|
||||||
@@ -94,15 +84,6 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
@Autowired
|
@Autowired
|
||||||
private transient UiProperties uiProperties;
|
private transient UiProperties uiProperties;
|
||||||
|
|
||||||
private String createDistTypeStr;
|
|
||||||
private String updateDistTypeStr;
|
|
||||||
private Label createDistType;
|
|
||||||
private Label updateDistType;
|
|
||||||
private Label comboLabel;
|
|
||||||
private TextField typeKey;
|
|
||||||
|
|
||||||
private VerticalLayout sliderLayout;
|
|
||||||
private HorizontalLayout colorLayout;
|
|
||||||
private HorizontalLayout distTypeSelectLayout;
|
private HorizontalLayout distTypeSelectLayout;
|
||||||
private Table sourceTable;
|
private Table sourceTable;
|
||||||
private Table selectedTable;
|
private Table selectedTable;
|
||||||
@@ -112,10 +93,8 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void createRequiredComponents() {
|
protected void createRequiredComponents() {
|
||||||
createDistTypeStr = i18n.get("label.create.type");
|
createTypeStr = i18n.get("label.create.type");
|
||||||
updateDistTypeStr = i18n.get("label.update.type");
|
updateTypeStr = i18n.get("label.update.type");
|
||||||
createDistType = SPUIComponentProvider.getLabel(createDistTypeStr, null);
|
|
||||||
updateDistType = SPUIComponentProvider.getLabel(updateDistTypeStr, null);
|
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
|
||||||
madatoryLabel = getMandatoryLabel();
|
madatoryLabel = getMandatoryLabel();
|
||||||
|
|
||||||
@@ -144,18 +123,16 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
tagNameComboBox.setImmediate(true);
|
tagNameComboBox.setImmediate(true);
|
||||||
tagNameComboBox.setPageLength(SPUIDefinitions.DIST_TYPE_SIZE);
|
tagNameComboBox.setPageLength(SPUIDefinitions.DIST_TYPE_SIZE);
|
||||||
|
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
|
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
||||||
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
|
||||||
|
|
||||||
tagColorPreviewBtn = new Button();
|
tagColorPreviewBtn = new Button();
|
||||||
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
|
tagColorPreviewBtn.setId(SPUIComponetIdProvider.TAG_COLOR_PREVIEW_ID);
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
||||||
tagColorPreviewBtn.setStyleName("tag-color-preview");
|
tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
|
||||||
|
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
|
||||||
ColorPickerHelper.setRgbSliderValues(getColorPickerLayout());
|
|
||||||
|
|
||||||
createUpdateOptionGroup();
|
createOptionGroup(permChecker.hasCreateDistributionPermission(), permChecker.hasUpdateDistributionPermission());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -166,30 +143,15 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
distTypeSelectLayout = createTwinColumnLayout();
|
distTypeSelectLayout = createTwinColumnLayout();
|
||||||
|
|
||||||
final HorizontalLayout mainLayout = new HorizontalLayout();
|
|
||||||
final VerticalLayout twinTableLayout = new VerticalLayout();
|
final VerticalLayout twinTableLayout = new VerticalLayout();
|
||||||
twinTableLayout.setSizeFull();
|
twinTableLayout.setSizeFull();
|
||||||
twinTableLayout.addComponent(distTypeSelectLayout);
|
twinTableLayout.addComponent(distTypeSelectLayout);
|
||||||
|
|
||||||
mainLayout.addComponent(getFormLayout());
|
mainLayout.addComponent(twinTableLayout, 2, 0);
|
||||||
mainLayout.addComponent(twinTableLayout);
|
|
||||||
|
|
||||||
colorLayout = new HorizontalLayout();
|
|
||||||
sliderLayout = new VerticalLayout();
|
|
||||||
final HorizontalLayout chooseColorLayout = new HorizontalLayout();
|
|
||||||
chooseColorLayout.addComponents(colorLabel, tagColorPreviewBtn);
|
|
||||||
chooseColorLayout.setComponentAlignment(colorLabel, Alignment.TOP_CENTER);
|
|
||||||
chooseColorLayout.setComponentAlignment(tagColorPreviewBtn, Alignment.TOP_CENTER);
|
|
||||||
sliderLayout.addComponent(chooseColorLayout);
|
|
||||||
colorLayout.addComponent(sliderLayout);
|
|
||||||
|
|
||||||
final VerticalLayout mainWindowLayout = new VerticalLayout();
|
|
||||||
mainWindowLayout.addComponent(new PopupWindowHelp(uiProperties.getLinks().getDocumentation().getRoot()));
|
|
||||||
mainWindowLayout.addComponent(mainLayout);
|
|
||||||
mainWindowLayout.addComponent(colorLayout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HorizontalLayout createTwinColumnLayout() {
|
private HorizontalLayout createTwinColumnLayout() {
|
||||||
|
|
||||||
final HorizontalLayout twinColumnLayout = new HorizontalLayout();
|
final HorizontalLayout twinColumnLayout = new HorizontalLayout();
|
||||||
twinColumnLayout.setSizeFull();
|
twinColumnLayout.setSizeFull();
|
||||||
twinColumnLayout.setWidth("400px");
|
twinColumnLayout.setWidth("400px");
|
||||||
@@ -220,13 +182,13 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
twinColumnLayout.setExpandRatio(selectedTable, 0.48f);
|
twinColumnLayout.setExpandRatio(selectedTable, 0.48f);
|
||||||
sourceTable.setVisibleColumns(new Object[] { DIST_TYPE_NAME });
|
sourceTable.setVisibleColumns(new Object[] { DIST_TYPE_NAME });
|
||||||
return twinColumnLayout;
|
return twinColumnLayout;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void buildSelectedTable() {
|
private void buildSelectedTable() {
|
||||||
|
|
||||||
selectedTable = new Table();
|
selectedTable = new Table();
|
||||||
selectedTable.setId(SPUIDefinitions.TWIN_TABLE_SELECTED_ID);
|
selectedTable.setId(SPUIDefinitions.TWIN_TABLE_SELECTED_ID);
|
||||||
selectedTable.setSelectable(true);
|
selectedTable.setSelectable(true);
|
||||||
@@ -249,6 +211,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTooltTipToSelectedTable() {
|
private void addTooltTipToSelectedTable() {
|
||||||
|
|
||||||
selectedTable.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
|
selectedTable.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
|
||||||
private static final long serialVersionUID = 99432397408575324L;
|
private static final long serialVersionUID = 99432397408575324L;
|
||||||
|
|
||||||
@@ -270,6 +233,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void buildSourceTable() {
|
private void buildSourceTable() {
|
||||||
|
|
||||||
sourceTable = new Table();
|
sourceTable = new Table();
|
||||||
sourceTable.setId(SPUIDefinitions.TWIN_TABLE_SOURCE_ID);
|
sourceTable.setId(SPUIDefinitions.TWIN_TABLE_SOURCE_ID);
|
||||||
sourceTable.setSelectable(true);
|
sourceTable.setSelectable(true);
|
||||||
@@ -294,10 +258,10 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
getSourceTableData();
|
getSourceTableData();
|
||||||
addTooltip();
|
addTooltip();
|
||||||
sourceTable.select(sourceTable.firstItemId());
|
sourceTable.select(sourceTable.firstItemId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSelectedTableContainer() {
|
private void createSelectedTableContainer() {
|
||||||
|
|
||||||
selectedTablecontainer = new IndexedContainer();
|
selectedTablecontainer = new IndexedContainer();
|
||||||
selectedTablecontainer.addContainerProperty(DIST_TYPE_NAME, String.class, "");
|
selectedTablecontainer.addContainerProperty(DIST_TYPE_NAME, String.class, "");
|
||||||
selectedTablecontainer.addContainerProperty(DIST_TYPE_DESCRIPTION, String.class, "");
|
selectedTablecontainer.addContainerProperty(DIST_TYPE_DESCRIPTION, String.class, "");
|
||||||
@@ -306,16 +270,17 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void addSMType() {
|
private void addSMType() {
|
||||||
|
|
||||||
final Set<Long> selectedIds = (Set<Long>) sourceTable.getValue();
|
final Set<Long> selectedIds = (Set<Long>) sourceTable.getValue();
|
||||||
if (null != selectedIds && !selectedIds.isEmpty()) {
|
if (null != selectedIds && !selectedIds.isEmpty()) {
|
||||||
for (final Long id : selectedIds) {
|
for (final Long id : selectedIds) {
|
||||||
addTargetTableData(id);
|
addTargetTableData(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeSMType() {
|
private void removeSMType() {
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final Set<Long> selectedIds = (Set<Long>) selectedTable.getValue();
|
final Set<Long> selectedIds = (Set<Long>) selectedTable.getValue();
|
||||||
if (null != selectedIds && !selectedIds.isEmpty()) {
|
if (null != selectedIds && !selectedIds.isEmpty()) {
|
||||||
@@ -328,6 +293,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void getSourceTableData() {
|
private void getSourceTableData() {
|
||||||
|
|
||||||
sourceTablecontainer.removeAllItems();
|
sourceTablecontainer.removeAllItems();
|
||||||
final Iterable<SoftwareModuleType> moduleTypeBeans = softwareManagement
|
final Iterable<SoftwareModuleType> moduleTypeBeans = softwareManagement
|
||||||
.findSoftwareModuleTypesAll(new PageRequest(0, 1_000));
|
.findSoftwareModuleTypesAll(new PageRequest(0, 1_000));
|
||||||
@@ -340,6 +306,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTooltip() {
|
private void addTooltip() {
|
||||||
|
|
||||||
sourceTable.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
|
sourceTable.setItemDescriptionGenerator(new ItemDescriptionGenerator() {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@@ -356,12 +323,14 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addTargetTableData(final Long selectedId) {
|
private void addTargetTableData(final Long selectedId) {
|
||||||
|
|
||||||
getSelectedTableItemData(selectedId);
|
getSelectedTableItemData(selectedId);
|
||||||
sourceTable.removeItem(selectedId);
|
sourceTable.removeItem(selectedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void getSelectedTableItemData(final Long id) {
|
private void getSelectedTableItemData(final Long id) {
|
||||||
|
|
||||||
Item saveTblitem;
|
Item saveTblitem;
|
||||||
if (null != selectedTablecontainer) {
|
if (null != selectedTablecontainer) {
|
||||||
saveTblitem = selectedTablecontainer.addItem(id);
|
saveTblitem = selectedTablecontainer.addItem(id);
|
||||||
@@ -375,6 +344,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void addSourceTableData(final Long selectedId) {
|
private void addSourceTableData(final Long selectedId) {
|
||||||
|
|
||||||
if (null != sourceTablecontainer) {
|
if (null != sourceTablecontainer) {
|
||||||
Item saveTblitem;
|
Item saveTblitem;
|
||||||
saveTblitem = sourceTablecontainer.addItem(selectedId);
|
saveTblitem = sourceTablecontainer.addItem(selectedId);
|
||||||
@@ -386,48 +356,12 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void save() {
|
|
||||||
// if (mandatoryValuesPresent()) {
|
|
||||||
// final DistributionSetType existingDistTypeByKey =
|
|
||||||
// distributionSetManagement
|
|
||||||
// .findDistributionSetTypeByKey(typeKey.getValue());
|
|
||||||
// final DistributionSetType existingDistTypeByName =
|
|
||||||
// distributionSetManagement
|
|
||||||
// .findDistributionSetTypeByName(tagName.getValue());
|
|
||||||
// if (createOptiongroup.getValue().equals(createDistTypeStr)) {
|
|
||||||
// if (!checkIsDuplicateByKey(existingDistTypeByKey) &&
|
|
||||||
// !checkIsDuplicate(existingDistTypeByName)) {
|
|
||||||
// crateNewDistributionSetType();
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// updateDistributionSetType(existingDistTypeByKey);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
private Boolean checkIsDuplicate(final DistributionSetType existingDistType) {
|
|
||||||
if (existingDistType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.tag.duplicate.check", new Object[] { existingDistType.getName() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Boolean checkIsDuplicateByKey(final DistributionSetType existingDistType) {
|
|
||||||
if (existingDistType != null) {
|
|
||||||
uiNotification.displayValidationError(
|
|
||||||
i18n.get("message.type.key.duplicate.check", new Object[] { existingDistType.getKey() }));
|
|
||||||
return Boolean.TRUE;
|
|
||||||
}
|
|
||||||
return Boolean.FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create new DistSet Type tag.
|
* Create new DistSet Type tag.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void crateNewDistributionSetType() {
|
private void crateNewDistributionSetType() {
|
||||||
|
|
||||||
final String colorPicked = ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview());
|
final String colorPicked = ColorPickerHelper.getColorPickedString(getColorPickerLayout().getSelPreview());
|
||||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
||||||
@@ -447,14 +381,12 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
} else {
|
} else {
|
||||||
newDistType.addOptionalModuleType(swModuleType);
|
newDistType.addOptionalModuleType(swModuleType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (null != typeDescValue) {
|
if (null != typeDescValue) {
|
||||||
newDistType.setDescription(typeDescValue);
|
newDistType.setDescription(typeDescValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
newDistType.setColour(colorPicked);
|
newDistType.setColour(colorPicked);
|
||||||
|
|
||||||
newDistType = distributionSetManagement.createDistributionSetType(newDistType);
|
newDistType = distributionSetManagement.createDistributionSetType(newDistType);
|
||||||
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() }));
|
uiNotification.displaySuccess(i18n.get("message.save.success", new Object[] { newDistType.getName() }));
|
||||||
closeWindow();
|
closeWindow();
|
||||||
@@ -472,6 +404,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void updateDistributionSetType(final DistributionSetType existingType) {
|
private void updateDistributionSetType(final DistributionSetType existingType) {
|
||||||
|
|
||||||
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
|
final List<Long> itemIds = (List<Long>) selectedTable.getItemIds();
|
||||||
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
final String typeNameValue = HawkbitCommonUtil.trimAndNullIfEmpty(tagName.getValue());
|
||||||
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
final String typeKeyValue = HawkbitCommonUtil.trimAndNullIfEmpty(typeKey.getValue());
|
||||||
@@ -515,6 +448,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
|
|
||||||
private DistributionSetType removeSWModuleTypesFromDistSetType(final String selectedDistSetType) {
|
private DistributionSetType removeSWModuleTypesFromDistSetType(final String selectedDistSetType) {
|
||||||
|
|
||||||
final DistributionSetType distSetType = fetchDistributionSetType(selectedDistSetType);
|
final DistributionSetType distSetType = fetchDistributionSetType(selectedDistSetType);
|
||||||
if (!distSetType.getMandatoryModuleTypes().isEmpty()) {
|
if (!distSetType.getMandatoryModuleTypes().isEmpty()) {
|
||||||
for (final SoftwareModuleType smType : distSetType.getMandatoryModuleTypes()) {
|
for (final SoftwareModuleType smType : distSetType.getMandatoryModuleTypes()) {
|
||||||
@@ -525,117 +459,10 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
for (final SoftwareModuleType smType : distSetType.getOptionalModuleTypes()) {
|
for (final SoftwareModuleType smType : distSetType.getOptionalModuleTypes()) {
|
||||||
distSetType.removeModuleType(smType.getId());
|
distSetType.removeModuleType(smType.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return distSetType;
|
return distSetType;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Open color picker on click of preview button. Auto select the color based
|
|
||||||
* on target tag if already selected.
|
|
||||||
*/
|
|
||||||
// private void previewButtonClicked() {
|
|
||||||
// final String selectedOption = (String) createOptiongroup.getValue();
|
|
||||||
// if (null != selectedOption &&
|
|
||||||
// selectedOption.equalsIgnoreCase(updateDistTypeStr)
|
|
||||||
// && null != typeNameComboBox.getValue()) {
|
|
||||||
//
|
|
||||||
// final DistributionSetType existedDistType = distributionSetManagement
|
|
||||||
// .findDistributionSetTypeByKey(typeNameComboBox.getValue().toString());
|
|
||||||
// if (null != existedDistType) {
|
|
||||||
// getColorPickerLayout().setSelectedColor(existedDistType.getColour() !=
|
|
||||||
// null
|
|
||||||
// ? ColorPickerHelper.rgbToColorConverter(existedDistType.getColour())
|
|
||||||
// :
|
|
||||||
// ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
// } else {
|
|
||||||
// getColorPickerLayout()
|
|
||||||
// .setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
// sliderLayout.addComponent(sliders);
|
|
||||||
// colorLayout.addComponent(getColorPickerLayout());
|
|
||||||
// colorLayout.setComponentAlignment(getColorPickerLayout(),
|
|
||||||
// Alignment.MIDDLE_CENTER);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Value change listeners implementations of sliders.
|
|
||||||
*/
|
|
||||||
private void slidersValueChangeListeners() {
|
|
||||||
getColorPickerLayout().getRedSlider().addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = -8336732883300920839L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double red = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color((int) red, getColorPickerLayout().getSelectedColor().getGreen(),
|
|
||||||
getColorPickerLayout().getSelectedColor().getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getColorPickerLayout().getGreenSlider().addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 1236358037711775663L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double green = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(getColorPickerLayout().getSelectedColor().getRed(), (int) green,
|
|
||||||
getColorPickerLayout().getSelectedColor().getBlue());
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getColorPickerLayout().getBlueSlider().addValueChangeListener(new ValueChangeListener() {
|
|
||||||
private static final long serialVersionUID = 8466370744686043947L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void valueChange(final ValueChangeEvent event) {
|
|
||||||
final double blue = (Double) event.getProperty().getValue();
|
|
||||||
final Color newColor = new Color(getColorPickerLayout().getSelectedColor().getRed(),
|
|
||||||
getColorPickerLayout().getSelectedColor().getGreen(), (int) blue);
|
|
||||||
setColorToComponents(newColor);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setColorToComponents(final Color newColor) {
|
|
||||||
setColor(newColor);
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(newColor);
|
|
||||||
getPreviewButtonColor(newColor.getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, newColor.getCSS());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set tag name and desc field border color based on chosen color.
|
|
||||||
*
|
|
||||||
* @param tagName
|
|
||||||
* @param tagDesc
|
|
||||||
* @param taregtTagColor
|
|
||||||
*/
|
|
||||||
private void createDynamicStyleForComponents(final TextField tagName, final TextField typeKey,
|
|
||||||
final TextArea typeDesc, final String typeTagColor) {
|
|
||||||
tagName.removeStyleName(SPUIDefinitions.TYPE_NAME);
|
|
||||||
typeKey.removeStyleName(SPUIDefinitions.TYPE_KEY);
|
|
||||||
typeDesc.removeStyleName(SPUIDefinitions.TYPE_DESC);
|
|
||||||
getDistributionDynamicStyles(typeTagColor);
|
|
||||||
tagName.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeKey.addStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
|
||||||
typeDesc.addStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get target style - Dynamically as per the color picked, cannot be done
|
|
||||||
* from the static css.
|
|
||||||
*
|
|
||||||
* @param colorPickedPreview
|
|
||||||
*/
|
|
||||||
private void getDistributionDynamicStyles(final String colorPickedPreview) {
|
|
||||||
Page.getCurrent().getJavaScript()
|
|
||||||
.execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -647,7 +474,6 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
public void addColorChangeListener(final ColorChangeListener listener) {
|
public void addColorChangeListener(final ColorChangeListener listener) {
|
||||||
|
|
||||||
LOG.info("in side addColorChangeListener() ");
|
LOG.info("in side addColorChangeListener() ");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -670,8 +496,6 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
protected void reset() {
|
protected void reset() {
|
||||||
|
|
||||||
super.reset();
|
super.reset();
|
||||||
typeKey.clear();
|
|
||||||
restoreComponentStyles();
|
|
||||||
selectedTable.removeAllItems();
|
selectedTable.removeAllItems();
|
||||||
getSourceTableData();
|
getSourceTableData();
|
||||||
}
|
}
|
||||||
@@ -682,39 +506,22 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
* @param event
|
* @param event
|
||||||
* ValueChangeEvent
|
* ValueChangeEvent
|
||||||
*/
|
*/
|
||||||
private void createOptionValueChanged(final ValueChangeEvent event) {
|
@Override
|
||||||
|
protected void createOptionValueChanged(final ValueChangeEvent event) {
|
||||||
|
|
||||||
|
super.createOptionValueChanged(event);
|
||||||
|
|
||||||
if ("Update Type".equals(event.getProperty().getValue())) {
|
if ("Update Type".equals(event.getProperty().getValue())) {
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
selectedTable.getContainerDataSource().removeAllItems();
|
selectedTable.getContainerDataSource().removeAllItems();
|
||||||
getSourceTableData();
|
getSourceTableData();
|
||||||
|
|
||||||
typeKey.setEnabled(false);
|
|
||||||
tagName.setEnabled(false);
|
|
||||||
distTypeSelectLayout.setEnabled(false);
|
distTypeSelectLayout.setEnabled(false);
|
||||||
populateTagNameCombo();
|
|
||||||
comboLayout.addComponent(comboLabel);
|
|
||||||
comboLayout.addComponent(tagNameComboBox);
|
|
||||||
} else {
|
} else {
|
||||||
typeKey.setEnabled(true);
|
|
||||||
tagName.setEnabled(true);
|
|
||||||
window.setSaveButtonEnabled(true);
|
|
||||||
distTypeSelectLayout.setEnabled(true);
|
distTypeSelectLayout.setEnabled(true);
|
||||||
tagName.clear();
|
|
||||||
tagDesc.clear();
|
|
||||||
typeKey.clear();
|
|
||||||
selectedTable.setEnabled(true);
|
selectedTable.setEnabled(true);
|
||||||
selectedTable.getContainerDataSource().removeAllItems();
|
selectedTable.getContainerDataSource().removeAllItems();
|
||||||
sourceTable.getContainerDataSource().removeAllItems();
|
sourceTable.getContainerDataSource().removeAllItems();
|
||||||
getSourceTableData();
|
getSourceTableData();
|
||||||
comboLayout.removeComponent(comboLabel);
|
|
||||||
comboLayout.removeComponent(tagNameComboBox);
|
|
||||||
}
|
}
|
||||||
restoreComponentStyles();
|
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
getColorPickerLayout().getSelPreview()
|
|
||||||
.setColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -722,6 +529,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void populateTagNameCombo() {
|
public void populateTagNameCombo() {
|
||||||
|
|
||||||
tagNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
|
tagNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
|
||||||
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
tagNameComboBox.setItemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
|
||||||
}
|
}
|
||||||
@@ -732,6 +540,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
private LazyQueryContainer getDistSetTypeLazyQueryContainer() {
|
||||||
|
|
||||||
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil.createLazyQueryContainer(
|
final LazyQueryContainer disttypeContainer = HawkbitCommonUtil.createLazyQueryContainer(
|
||||||
new BeanQueryFactory<DistributionSetTypeBeanQuery>(DistributionSetTypeBeanQuery.class));
|
new BeanQueryFactory<DistributionSetTypeBeanQuery>(DistributionSetTypeBeanQuery.class));
|
||||||
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, "", true, true);
|
||||||
@@ -741,6 +550,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void resetTagNameField() {
|
protected void resetTagNameField() {
|
||||||
|
|
||||||
super.resetTagNameField();
|
super.resetTagNameField();
|
||||||
typeKey.setEnabled(false);
|
typeKey.setEnabled(false);
|
||||||
typeKey.clear();
|
typeKey.clear();
|
||||||
@@ -757,6 +567,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
protected void setTagDetails(final String distSetTypeSelected) {
|
protected void setTagDetails(final String distSetTypeSelected) {
|
||||||
|
|
||||||
tagName.setValue(distSetTypeSelected);
|
tagName.setValue(distSetTypeSelected);
|
||||||
getSourceTableData();
|
getSourceTableData();
|
||||||
selectedTable.getContainerDataSource().removeAllItems();
|
selectedTable.getContainerDataSource().removeAllItems();
|
||||||
@@ -783,22 +594,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
for (final SoftwareModuleType swModuleType : selectedTypeTag.getMandatoryModuleTypes()) {
|
for (final SoftwareModuleType swModuleType : selectedTypeTag.getMandatoryModuleTypes()) {
|
||||||
addTargetTableforUpdate(swModuleType, true);
|
addTargetTableforUpdate(swModuleType, true);
|
||||||
}
|
}
|
||||||
|
setColorPickerComponentsColor(selectedTypeTag.getColour());
|
||||||
if (null == selectedTypeTag.getColour()) {
|
|
||||||
getColorPickerLayout()
|
|
||||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
|
||||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
} else {
|
|
||||||
getColorPickerLayout()
|
|
||||||
.setSelectedColor(ColorPickerHelper.rgbToColorConverter(selectedTypeTag.getColour()));
|
|
||||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, selectedTypeTag.getColour());
|
|
||||||
getPreviewButtonColor(selectedTypeTag.getColour());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -809,6 +605,7 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private void addTargetTableforUpdate(final SoftwareModuleType swModuleType, final boolean mandatory) {
|
private void addTargetTableforUpdate(final SoftwareModuleType swModuleType, final boolean mandatory) {
|
||||||
|
|
||||||
Item saveTblitem;
|
Item saveTblitem;
|
||||||
if (null != selectedTablecontainer) {
|
if (null != selectedTablecontainer) {
|
||||||
saveTblitem = selectedTablecontainer.addItem(swModuleType.getId());
|
saveTblitem = selectedTablecontainer.addItem(swModuleType.getId());
|
||||||
@@ -818,70 +615,26 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.vaadin.ui.components.colorpicker.ColorSelector#setColor(com.vaadin.
|
|
||||||
* shared.ui.colorpicker .Color)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void setColor(final Color color) {
|
|
||||||
if (color == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
getColorPickerLayout().setSelectedColor(color);
|
|
||||||
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
final String colorPickedPreview = getColorPickerLayout().getSelPreview().getColor().getCSS();
|
|
||||||
if (tagName.isEnabled() && null != getColorPickerLayout().getColorSelect()) {
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, colorPickedPreview);
|
|
||||||
getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelPreview().getColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* com.vaadin.ui.components.colorpicker.ColorChangeListener#colorChanged(com
|
|
||||||
* .vaadin.ui.components .colorpicker.ColorChangeEvent)
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void colorChanged(final ColorChangeEvent event) {
|
|
||||||
setColor(event.getColor());
|
|
||||||
for (final ColorSelector select : getColorPickerLayout().getSelectors()) {
|
|
||||||
if (!event.getSource().equals(select) && select.equals(this)
|
|
||||||
&& !select.getColor().equals(getColorPickerLayout().getSelectedColor())) {
|
|
||||||
select.setColor(getColorPickerLayout().getSelectedColor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ColorPickerHelper.setRgbSliderValues(getColorPickerLayout());
|
|
||||||
getPreviewButtonColor(event.getColor().getCSS());
|
|
||||||
createDynamicStyleForComponents(tagName, typeKey, tagDesc, event.getColor().getCSS());
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* reset the tag name and tag description component border color.
|
* reset the tag name and tag description component border color.
|
||||||
*/
|
*/
|
||||||
private void restoreComponentStyles() {
|
@Override
|
||||||
tagName.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
protected void restoreComponentStyles() {
|
||||||
tagDesc.removeStyleName(TYPE_DESC_DYNAMIC_STYLE);
|
|
||||||
|
super.restoreComponentStyles();
|
||||||
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
typeKey.removeStyleName(TYPE_NAME_DYNAMIC_STYLE);
|
||||||
tagName.addStyleName(SPUIDefinitions.DIST_SET_TYPE_NAME);
|
|
||||||
tagDesc.addStyleName(SPUIDefinitions.DIST_SET_TYPE_DESC);
|
|
||||||
typeKey.addStyleName(SPUIDefinitions.DIST_SET_TYPE_KEY);
|
typeKey.addStyleName(SPUIDefinitions.DIST_SET_TYPE_KEY);
|
||||||
getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void save(final ClickEvent event) {
|
protected void save(final ClickEvent event) {
|
||||||
|
|
||||||
if (mandatoryValuesPresent()) {
|
if (mandatoryValuesPresent()) {
|
||||||
final DistributionSetType existingDistTypeByKey = distributionSetManagement
|
final DistributionSetType existingDistTypeByKey = distributionSetManagement
|
||||||
.findDistributionSetTypeByKey(typeKey.getValue());
|
.findDistributionSetTypeByKey(typeKey.getValue());
|
||||||
final DistributionSetType existingDistTypeByName = distributionSetManagement
|
final DistributionSetType existingDistTypeByName = distributionSetManagement
|
||||||
.findDistributionSetTypeByName(tagName.getValue());
|
.findDistributionSetTypeByName(tagName.getValue());
|
||||||
if (optiongroup.getValue().equals(createDistTypeStr)) {
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
if (!checkIsDuplicateByKey(existingDistTypeByKey) && !checkIsDuplicate(existingDistTypeByName)) {
|
if (!checkIsDuplicateByKey(existingDistTypeByKey) && !checkIsDuplicate(existingDistTypeByName)) {
|
||||||
crateNewDistributionSetType();
|
crateNewDistributionSetType();
|
||||||
}
|
}
|
||||||
@@ -898,27 +651,47 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTagLayout impleme
|
|||||||
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> save(event), event -> discard(event));
|
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, event -> save(event), event -> discard(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createUpdateOptionGroup() {
|
@Override
|
||||||
final List<String> optionValues = new ArrayList<>();
|
protected Boolean mandatoryValuesPresent() {
|
||||||
if (permChecker.hasCreateDistributionPermission()) {
|
if (Strings.isNullOrEmpty(tagName.getValue()) || Strings.isNullOrEmpty(typeKey.getValue())) {
|
||||||
optionValues.add(createDistType.getValue());
|
if (optiongroup.getValue().equals(createTypeStr)) {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TYPE_NAME_KEY);
|
||||||
}
|
}
|
||||||
if (permChecker.hasUpdateDistributionPermission()) {
|
if (optiongroup.getValue().equals(updateTypeStr)) {
|
||||||
optionValues.add(updateDistType.getValue());
|
if (null == tagNameComboBox.getValue()) {
|
||||||
|
displayValidationError(i18n.get("message.error.missing.tagName"));
|
||||||
|
} else {
|
||||||
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
}
|
}
|
||||||
createOptionGroupByValues(optionValues);
|
}
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOptionGroupByValues(final List<String> typeOptions) {
|
@Override
|
||||||
optiongroup = new OptionGroup("", typeOptions);
|
protected void previewButtonClicked() {
|
||||||
optiongroup.setId(SPUIDefinitions.CREATE_OPTION_GROUP_DISTRIBUTION_SET_TYPE_ID);
|
if (!tagPreviewBtnClicked) {
|
||||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
optiongroup.addStyleName("custom-option-group");
|
if (null != selectedOption && selectedOption.equalsIgnoreCase(updateTypeStr)
|
||||||
optiongroup.setNullSelectionAllowed(false);
|
&& null != tagNameComboBox.getValue()) {
|
||||||
optiongroup.setCaption(null);
|
|
||||||
if (!typeOptions.isEmpty()) {
|
final DistributionSetType existedDistType = distributionSetManagement
|
||||||
optiongroup.select(typeOptions.get(0));
|
.findDistributionSetTypeByKey(tagNameComboBox.getValue().toString());
|
||||||
|
if (null != existedDistType) {
|
||||||
|
getColorPickerLayout().setSelectedColor(existedDistType.getColour() != null
|
||||||
|
? ColorPickerHelper.rgbToColorConverter(existedDistType.getColour())
|
||||||
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
|
} else {
|
||||||
|
getColorPickerLayout().setSelectedColor(
|
||||||
|
ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
|
||||||
|
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||||
|
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||||
|
}
|
||||||
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,10 +6,7 @@
|
|||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.ui.management.tag;
|
package org.eclipse.hawkbit.ui.layouts;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.annotation.PreDestroy;
|
import javax.annotation.PreDestroy;
|
||||||
|
|
||||||
@@ -45,6 +42,7 @@ import com.vaadin.ui.Button;
|
|||||||
import com.vaadin.ui.ComboBox;
|
import com.vaadin.ui.ComboBox;
|
||||||
import com.vaadin.ui.CustomComponent;
|
import com.vaadin.ui.CustomComponent;
|
||||||
import com.vaadin.ui.FormLayout;
|
import com.vaadin.ui.FormLayout;
|
||||||
|
import com.vaadin.ui.GridLayout;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Label;
|
import com.vaadin.ui.Label;
|
||||||
import com.vaadin.ui.OptionGroup;
|
import com.vaadin.ui.OptionGroup;
|
||||||
@@ -65,14 +63,9 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateTagLayout.class);
|
private static final Logger LOG = LoggerFactory.getLogger(CreateUpdateTagLayout.class);
|
||||||
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";
|
||||||
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";
|
||||||
private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
protected static final String TAG_DYNAMIC_STYLE = "tag-color-preview";
|
||||||
protected static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname";
|
protected static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname";
|
||||||
|
|
||||||
protected String createTagNw;
|
|
||||||
protected String updateTagNw;
|
|
||||||
|
|
||||||
protected CommonDialogWindow window;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
protected I18N i18n;
|
protected I18N i18n;
|
||||||
|
|
||||||
@@ -90,7 +83,11 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
|
|
||||||
private final FormLayout formLayout = new FormLayout();
|
private final FormLayout formLayout = new FormLayout();
|
||||||
|
|
||||||
private Label comboLabel;
|
protected String createTagStr;
|
||||||
|
protected String updateTagStr;
|
||||||
|
protected Label comboLabel;
|
||||||
|
protected CommonDialogWindow window;
|
||||||
|
|
||||||
protected Label colorLabel;
|
protected Label colorLabel;
|
||||||
protected Label madatoryLabel;
|
protected Label madatoryLabel;
|
||||||
protected TextField tagName;
|
protected TextField tagName;
|
||||||
@@ -101,8 +98,8 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
|
|
||||||
protected final VerticalLayout comboLayout = new VerticalLayout();
|
protected final VerticalLayout comboLayout = new VerticalLayout();
|
||||||
protected final ColorPickerLayout colorPickerLayout = new ColorPickerLayout();
|
protected final ColorPickerLayout colorPickerLayout = new ColorPickerLayout();
|
||||||
private final HorizontalLayout mainLayout = new HorizontalLayout();
|
protected final GridLayout mainLayout = new GridLayout(4, 4);
|
||||||
final VerticalLayout contentLayout = new VerticalLayout();
|
protected final VerticalLayout contentLayout = new VerticalLayout();
|
||||||
|
|
||||||
protected boolean tagPreviewBtnClicked = false;
|
protected boolean tagPreviewBtnClicked = false;
|
||||||
|
|
||||||
@@ -157,8 +154,9 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void createRequiredComponents() {
|
protected void createRequiredComponents() {
|
||||||
createTagNw = i18n.get("label.create.tag");
|
|
||||||
updateTagNw = i18n.get("label.update.tag");
|
createTagStr = i18n.get("label.create.tag");
|
||||||
|
updateTagStr = i18n.get("label.update.tag");
|
||||||
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
|
||||||
madatoryLabel = getMandatoryLabel();
|
madatoryLabel = getMandatoryLabel();
|
||||||
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
|
||||||
@@ -208,10 +206,10 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
contentLayout.addComponent(colorLabelLayout);
|
contentLayout.addComponent(colorLabelLayout);
|
||||||
contentLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
|
contentLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
|
||||||
contentLayout.setComponentAlignment(colorLabelLayout, Alignment.MIDDLE_LEFT);
|
contentLayout.setComponentAlignment(colorLabelLayout, Alignment.MIDDLE_LEFT);
|
||||||
contentLayout.setSizeFull();
|
contentLayout.setSizeUndefined();
|
||||||
|
|
||||||
mainLayout.setSizeFull();
|
mainLayout.setSizeFull();
|
||||||
mainLayout.addComponent(contentLayout);
|
mainLayout.addComponent(contentLayout, 0, 0);
|
||||||
|
|
||||||
setCompositionRoot(mainLayout);
|
setCompositionRoot(mainLayout);
|
||||||
tagName.focus();
|
tagName.focus();
|
||||||
@@ -233,16 +231,15 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
protected void previewButtonClicked() {
|
protected void previewButtonClicked() {
|
||||||
if (!tagPreviewBtnClicked) {
|
if (!tagPreviewBtnClicked) {
|
||||||
setColor();
|
setColor();
|
||||||
colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
|
mainLayout.addComponent(colorPickerLayout, 1, 0);
|
||||||
mainLayout.addComponent(colorPickerLayout);
|
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
|
||||||
mainLayout.setComponentAlignment(colorPickerLayout, Alignment.BOTTOM_CENTER);
|
|
||||||
}
|
}
|
||||||
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
tagPreviewBtnClicked = !tagPreviewBtnClicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setColor() {
|
private void setColor() {
|
||||||
final String selectedOption = (String) optiongroup.getValue();
|
final String selectedOption = (String) optiongroup.getValue();
|
||||||
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagNw)) {
|
if (selectedOption == null || !selectedOption.equalsIgnoreCase(updateTagStr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -265,7 +262,6 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
? ColorPickerHelper.rgbToColorConverter(targetTagSelected.getColour())
|
? ColorPickerHelper.rgbToColorConverter(targetTagSelected.getColour())
|
||||||
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
: ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Label getMandatoryLabel() {
|
protected Label getMandatoryLabel() {
|
||||||
@@ -344,7 +340,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
comboLayout.removeComponent(tagNameComboBox);
|
comboLayout.removeComponent(tagNameComboBox);
|
||||||
mainLayout.removeComponent(colorPickerLayout);
|
mainLayout.removeComponent(colorPickerLayout);
|
||||||
|
|
||||||
optiongroup.select(createTagNw);
|
optiongroup.select(createTagStr);
|
||||||
|
|
||||||
// Default green color
|
// Default green color
|
||||||
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
|
||||||
@@ -401,7 +397,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
/**
|
/**
|
||||||
* reset the tag name and tag description component border color.
|
* reset the tag name and tag description component border color.
|
||||||
*/
|
*/
|
||||||
private void restoreComponentStyles() {
|
protected void restoreComponentStyles() {
|
||||||
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
|
tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
|
||||||
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
|
tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
|
||||||
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
|
tagName.addStyleName(SPUIDefinitions.TAG_NAME);
|
||||||
@@ -447,26 +443,22 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
/**
|
/**
|
||||||
* create option group with Create tag/Update tag based on permissions.
|
* create option group with Create tag/Update tag based on permissions.
|
||||||
*/
|
*/
|
||||||
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePersmission) {
|
protected void createOptionGroup(final boolean hasCreatePermission, final boolean hasUpdatePermission) {
|
||||||
final List<String> optionValues = new ArrayList<>();
|
|
||||||
if (hasCreatePermission) {
|
|
||||||
optionValues.add(createTagNw);
|
|
||||||
}
|
|
||||||
if (hasUpdatePersmission) {
|
|
||||||
optionValues.add(updateTagNw);
|
|
||||||
}
|
|
||||||
createOptionGroup(optionValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void createOptionGroup(final List<String> tagOptions) {
|
optiongroup = new OptionGroup("Select Action");
|
||||||
optiongroup = new OptionGroup("", tagOptions);
|
|
||||||
optiongroup.setCaption("Select Action");
|
|
||||||
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
optiongroup.addStyleName(ValoTheme.OPTIONGROUP_SMALL);
|
||||||
optiongroup.addStyleName("custom-option-group");
|
optiongroup.addStyleName("custom-option-group");
|
||||||
|
|
||||||
optiongroup.setNullSelectionAllowed(false);
|
optiongroup.setNullSelectionAllowed(false);
|
||||||
if (!tagOptions.isEmpty()) {
|
|
||||||
optiongroup.select(tagOptions.get(0));
|
if (hasCreatePermission) {
|
||||||
|
optiongroup.addItem(createTagStr);
|
||||||
|
optiongroup.select(createTagStr);
|
||||||
|
}
|
||||||
|
if (hasUpdatePermission) {
|
||||||
|
optiongroup.addItem(updateTagStr);
|
||||||
|
if (!hasCreatePermission) {
|
||||||
|
optiongroup.select(updateTagStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,7 +522,7 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setColorToComponents(final Color newColor) {
|
protected void setColorToComponents(final Color newColor) {
|
||||||
setColor(newColor);
|
setColor(newColor);
|
||||||
colorPickerLayout.getColorSelect().setColor(newColor);
|
colorPickerLayout.getColorSelect().setColor(newColor);
|
||||||
getPreviewButtonColor(newColor.getCSS());
|
getPreviewButtonColor(newColor.getCSS());
|
||||||
@@ -591,10 +583,10 @@ public abstract class CreateUpdateTagLayout extends CustomComponent implements C
|
|||||||
*/
|
*/
|
||||||
protected Boolean mandatoryValuesPresent() {
|
protected Boolean mandatoryValuesPresent() {
|
||||||
if (Strings.isNullOrEmpty(tagName.getValue())) {
|
if (Strings.isNullOrEmpty(tagName.getValue())) {
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
displayValidationError(SPUILabelDefinitions.MISSING_TAG_NAME);
|
||||||
}
|
}
|
||||||
if (optiongroup.getValue().equals(updateTagNw)) {
|
if (optiongroup.getValue().equals(updateTagStr)) {
|
||||||
if (null == tagNameComboBox.getValue()) {
|
if (null == tagNameComboBox.getValue()) {
|
||||||
displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME));
|
displayValidationError(i18n.get(MESSAGE_ERROR_MISSING_TAGNAME));
|
||||||
} else {
|
} else {
|
||||||
@@ -18,7 +18,7 @@ import org.eclipse.hawkbit.eventbus.event.DistributionSetTagUpdateEvent;
|
|||||||
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
import org.eclipse.hawkbit.repository.model.DistributionSetTag;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTagLayout;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
|
||||||
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
@@ -77,7 +77,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends CreateUpdateTagLayo
|
|||||||
public void save(final ClickEvent event) {
|
public void save(final ClickEvent event) {
|
||||||
if (mandatoryValuesPresent()) {
|
if (mandatoryValuesPresent()) {
|
||||||
final DistributionSetTag existingDistTag = tagManagement.findDistributionSetTag(tagName.getValue());
|
final DistributionSetTag existingDistTag = tagManagement.findDistributionSetTag(tagName.getValue());
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
if (!checkIsDuplicate(existingDistTag)) {
|
if (!checkIsDuplicate(existingDistTag)) {
|
||||||
crateNewTag();
|
crateNewTag();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import org.eclipse.hawkbit.eventbus.event.TargetTagUpdateEvent;
|
|||||||
import org.eclipse.hawkbit.repository.model.TargetTag;
|
import org.eclipse.hawkbit.repository.model.TargetTag;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerConstants;
|
||||||
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
import org.eclipse.hawkbit.ui.colorPicker.ColorPickerHelper;
|
||||||
import org.eclipse.hawkbit.ui.management.tag.CreateUpdateTagLayout;
|
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTagLayout;
|
||||||
import org.vaadin.spring.events.EventScope;
|
import org.vaadin.spring.events.EventScope;
|
||||||
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ public class CreateUpdateTargetTagLayoutWindow extends CreateUpdateTagLayout {
|
|||||||
public void save(final ClickEvent event) {
|
public void save(final ClickEvent event) {
|
||||||
if (mandatoryValuesPresent()) {
|
if (mandatoryValuesPresent()) {
|
||||||
final TargetTag existingTag = tagManagement.findTargetTag(tagName.getValue());
|
final TargetTag existingTag = tagManagement.findTargetTag(tagName.getValue());
|
||||||
if (optiongroup.getValue().equals(createTagNw)) {
|
if (optiongroup.getValue().equals(createTagStr)) {
|
||||||
if (!checkIsDuplicate(existingTag)) {
|
if (!checkIsDuplicate(existingTag)) {
|
||||||
createNewTag();
|
createNewTag();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,4 +161,8 @@
|
|||||||
.v-slot-bulk-upload-label{
|
.v-slot-bulk-upload-label{
|
||||||
line-height:0;
|
line-height:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.actionButtonsMargin {
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user