Merge branch 'master' into

fix_dialog_window_must_not_close_after_save_if_duplicate_exists

Conflicts:
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/artifacts/smtable/SoftwareModuleAddUpdateWindow.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/common/CommonDialogWindow.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/decorators/SPUIWindowDecorator.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/AbstractCreateUpdateTagLayout.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/layouts/CreateUpdateTypeLayout.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/dstable/DistributionAddUpdateWindowLayout.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/management/targettable/TargetAddUpdateWindowLayout.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/rollout/rollout/AddUpdateRolloutWindowLayout.java
	hawkbit-ui/src/main/java/org/eclipse/hawkbit/ui/utils/HawkbitCommonUtil.java


Signed-off-by: Melanie Retter <melanie.retter@bosch-si.com>
This commit is contained in:
Melanie Retter
2016-08-19 14:29:15 +02:00
106 changed files with 1615 additions and 2021 deletions

View File

@@ -8,6 +8,11 @@
*/
package org.eclipse.hawkbit.ui.artifacts.details;
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
import static org.springframework.data.domain.Sort.Direction.ASC;
import static org.springframework.data.domain.Sort.Direction.DESC;
import java.util.List;
import java.util.Map;
@@ -15,7 +20,6 @@ import org.eclipse.hawkbit.repository.ArtifactManagement;
import org.eclipse.hawkbit.repository.EntityFactory;
import org.eclipse.hawkbit.repository.OffsetBasedPageRequest;
import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.Page;
@@ -39,7 +43,7 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
/**
* Parametric Constructor.
*
*
* @param definition
* as Def
* @param queryConfig
@@ -51,18 +55,18 @@ public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
*/
public ArtifactBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (isNotNullOrEmpty(queryConfig)) {
baseSwModuleId = (Long) queryConfig.get(SPUIDefinitions.BY_BASE_SOFTWARE_MODULE);
}
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort.
if (!isEmpty(sortStates)) {
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
}
}
}

View File

@@ -24,6 +24,7 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent.SoftwareModuleEventType;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -149,8 +150,8 @@ public class ArtifactDetailsLayout extends VerticalLayout {
final SoftwareModule softwareModule = artifactUploadState.getSelectedBaseSoftwareModule().get();
labelStr = HawkbitCommonUtil.getFormattedNameVersion(softwareModule.getName(), softwareModule.getVersion());
}
titleOfArtifactDetails = SPUIComponentProvider.getLabel(
HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr), SPUILabelDefinitions.SP_WIDGET_CAPTION);
titleOfArtifactDetails = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(labelStr))
.buildCaptionLabel();
titleOfArtifactDetails.setContentMode(ContentMode.HTML);
titleOfArtifactDetails.setSizeFull();
titleOfArtifactDetails.setImmediate(true);

View File

@@ -43,7 +43,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
/**
* Parametric Constructor.
*
*
* @param definition
* as Def
* @param queryConfig
@@ -56,7 +56,7 @@ public class BaseSwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSoftwareMo
public BaseSwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(searchText)) {

View File

@@ -17,9 +17,11 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleEvent;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
@@ -118,26 +120,17 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
}
private void createRequiredComponents() {
/* name textfield */
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
nameTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_NAME);
/* version text field */
versionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
versionTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VERSION);
nameTextField = createTextField("textfield.name", SPUIComponentIdProvider.SOFT_MODULE_NAME);
/* Vendor text field */
vendorTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.vendor"), "", ValoTheme.TEXTFIELD_TINY,
false, null, i18n.get("textfield.vendor"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
vendorTextField.setId(SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
versionTextField = createTextField("textfield.version", SPUIComponentIdProvider.SOFT_MODULE_VERSION);
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION);
vendorTextField = createTextField("textfield.vendor", SPUIComponentIdProvider.SOFT_MODULE_VENDOR);
vendorTextField.setRequired(false);
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
.prompt(i18n.get("textfield.description")).id(SPUIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION)
.buildTextComponent();
typeComboBox = SPUIComponentProvider.getComboBox(i18n.get("upload.swmodule.type"), "", "", null, null, true,
null, i18n.get("upload.swmodule.type"));
@@ -148,6 +141,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
populateTypeNameCombo();
}
private TextField createTextField(final String in18Key, final String id) {
return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key))
.immediate(true).id(id).buildTextComponent();
}
private void populateTypeNameCombo() {
typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(
new BeanQueryFactory<SoftwareModuleTypeBeanQuery>(SoftwareModuleTypeBeanQuery.class)));
@@ -181,8 +179,11 @@ public class SoftwareModuleAddUpdateWindow extends CustomComponent {
setCompositionRoot(formLayout);
window = SPUIWindowDecorator.getWindow(i18n.get("upload.caption.add.new.swmodule"), null,
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get("upload.caption.add.new.swmodule")).content(this)
.layout(formLayout).i18n(i18n)
.buildCommonDialogWindow();
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@Override

View File

@@ -52,8 +52,8 @@ import com.vaadin.ui.UI;
/**
* Header of Software module table.
*/
@SpringComponent
@ViewScope
@SpringComponent
public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModule, Long> {
private static final long serialVersionUID = 6469417305487144809L;
@@ -66,7 +66,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@Autowired
private UploadViewAcceptCriteria uploadViewAcceptCriteria;
@Autowired
private SwMetadataPopupLayout swMetadataPopupLayout;
@@ -162,7 +162,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final UploadArtifactUIEvent event) {
if (event == UploadArtifactUIEvent.DELETED_ALL_SOFWARE) {
UI.getCurrent().access(() -> refreshFilter());
UI.getCurrent().access(this::refreshFilter);
}
}
@@ -197,12 +197,12 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
final String nameVersionStr = getNameAndVerion(itemId);
final Button manageMetaDataBtn = createManageMetadataButton(nameVersionStr);
manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId, nameVersionStr));
manageMetaDataBtn.addClickListener(event -> showMetadataDetails((Long) itemId));
return manageMetaDataBtn;
}
});
}
@Override
protected List<TableColumn> getTableVisibleColumns() {
final List<TableColumn> columnList = super.getTableVisibleColumns();
@@ -237,8 +237,7 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
artifactUploadState.setNoDataAvilableSoftwareModule(!available);
}
private Button createManageMetadataButton(String nameVersionStr) {
private Button createManageMetadataButton(final String nameVersionStr) {
final Button manageMetadataBtn = SPUIComponentProvider.getButton(
SPUIComponentIdProvider.SW_TABLE_MANAGE_METADATA_ID + "." + nameVersionStr, "", "", null, false,
FontAwesome.LIST_ALT, SPUIButtonStyleSmallNoBorder.class);
@@ -246,17 +245,17 @@ public class SoftwareModuleTable extends AbstractNamedVersionTable<SoftwareModul
manageMetadataBtn.setDescription(i18n.get("tooltip.metadata.icon"));
return manageMetadataBtn;
}
private String getNameAndVerion(final Object itemId) {
final Item item = getItem(itemId);
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
final String version = (String) item.getItemProperty(SPUILabelDefinitions.VAR_VERSION).getValue();
return name + "." + version;
}
private void showMetadataDetails(Long itemId, String nameVersionStr) {
SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
/* display the window */
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule,null));
private void showMetadataDetails(final Long itemId) {
final SoftwareModule swmodule = softwareManagement.findSoftwareModuleWithDetails(itemId);
/* display the window */
UI.getCurrent().addWindow(swMetadataPopupLayout.getWindow(swmodule, null));
}
}

View File

@@ -18,7 +18,9 @@ import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent;
import org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.common.SoftwareModuleTypeBeanQuery;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.layouts.CreateUpdateTypeLayout;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
@@ -34,6 +36,7 @@ import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.Label;
import com.vaadin.ui.OptionGroup;
import com.vaadin.ui.TextField;
import com.vaadin.ui.components.colorpicker.ColorChangeListener;
import com.vaadin.ui.themes.ValoTheme;
@@ -73,29 +76,28 @@ public class CreateUpdateSoftwareTypeLayout extends CreateUpdateTypeLayout<Softw
singleAssignStr = i18n.get("label.singleAssign.type");
multiAssignStr = i18n.get("label.multiAssign.type");
singleAssign = SPUIComponentProvider.getLabel(singleAssignStr, null);
multiAssign = SPUIComponentProvider.getLabel(multiAssignStr, null);
singleAssign = new LabelBuilder().name(singleAssignStr).buildLabel();
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_NAME, true, "", i18n.get("textfield.name"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
multiAssign = new LabelBuilder().name(multiAssignStr).buildLabel();
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_KEY, true, "", i18n.get("textfield.key"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
typeKey.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
tagName = createTextField("textfield.name", SPUIDefinitions.TYPE_NAME, SPUIDefinitions.NEW_SOFTWARE_TYPE_NAME);
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC, false, "",
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
tagDesc.setId(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC);
tagDesc.setImmediate(true);
typeKey = createTextField("textfield.key", SPUIDefinitions.TYPE_KEY, SPUIDefinitions.NEW_SOFTWARE_TYPE_KEY);
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TYPE_DESC)
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_SOFTWARE_TYPE_DESC)
.buildTextComponent();
tagDesc.setNullRepresentation("");
singleMultiOptionGroup();
}
private TextField createTextField(final String in18Key, final String styleName, final String id) {
return new TextFieldBuilder().caption(i18n.get(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
.required(true).prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
}
@Override
protected void buildLayout() {

View File

@@ -8,6 +8,9 @@
*/
package org.eclipse.hawkbit.ui.artifacts.upload;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.FAILED;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.SUCCESS;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -23,6 +26,7 @@ import org.eclipse.hawkbit.repository.model.LocalArtifact;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.artifacts.state.CustomFile;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleTiny;
@@ -56,13 +60,13 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Artifact upload confirmation popup.
*
*
*/
public class UploadConfirmationwindow implements Button.ClickListener {
public class UploadConfirmationWindow implements Button.ClickListener {
private static final long serialVersionUID = -1679035890140031740L;
private static final Logger LOG = LoggerFactory.getLogger(UploadConfirmationwindow.class);
private static final Logger LOG = LoggerFactory.getLogger(UploadConfirmationWindow.class);
private static final String MD5_CHECKSUM = "md5Checksum";
@@ -114,13 +118,13 @@ public class UploadConfirmationwindow implements Button.ClickListener {
/**
* Initialize the upload confirmation window.
*
*
* @param artifactUploadView
* reference of upload layout.
* @param artifactUploadState
* reference of session variable {@link ArtifactUploadState}.
*/
public UploadConfirmationwindow(final UploadLayout artifactUploadView,
public UploadConfirmationWindow(final UploadLayout artifactUploadView,
final ArtifactUploadState artifactUploadState) {
this.uploadLayout = artifactUploadView;
this.artifactUploadState = artifactUploadState;
@@ -245,29 +249,27 @@ public class UploadConfirmationwindow implements Button.ClickListener {
deleteIcon.setData(itemId);
newItem.getItemProperty(ACTION).setValue(deleteIcon);
final TextField sha1 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
sha1.setId(swNameVersion + "/" + customFile.getFileName() + "/sha1");
final TextField sha1 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/sha1");
final TextField md5 = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
md5.setId(swNameVersion + "/" + customFile.getFileName() + "/md5");
final TextField md5 = createTextField(swNameVersion + "/" + customFile.getFileName() + "/md5");
createTextField(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
final TextField customFileName = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
customFileName.setId(swNameVersion + "/" + customFile.getFileName() + "/customFileName");
newItem.getItemProperty(SHA1_CHECKSUM).setValue(sha1);
newItem.getItemProperty(MD5_CHECKSUM).setValue(md5);
newItem.getItemProperty(CUSTOM_FILE).setValue(customFile);
}
}
private static TextField createTextField(final String id) {
return new TextFieldBuilder().immediate(true).id(id).buildTextComponent();
}
private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
final String customFileName, final String itemId) {
final HorizontalLayout horizontalLayout = new HorizontalLayout();
final TextField fileNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY,
false, null, null, true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
fileNameTextField.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
final TextField fileNameTextField = createTextField(
baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
fileNameTextField.setValue(customFileName);
@@ -615,6 +617,7 @@ public class UploadConfirmationwindow implements Button.ClickListener {
private void createLocalArtifact(final String itemId, final String filePath,
final ArtifactManagement artifactManagement, final SoftwareModule baseSw) {
final File newFile = new File(filePath);
final Item item = tabelContainer.getItem(itemId);
final String sha1Checksum = ((TextField) item.getItemProperty(SHA1_CHECKSUM).getValue()).getValue();
@@ -624,27 +627,25 @@ public class UploadConfirmationwindow implements Button.ClickListener {
final String[] itemDet = itemId.split("/");
final String swModuleNameVersion = itemDet[0];
FileInputStream fis = null;
try {
fis = new FileInputStream(newFile);
try (FileInputStream fis = new FileInputStream(newFile)) {
artifactManagement.createLocalArtifact(fis, baseSw.getId(), providedFileName,
HawkbitCommonUtil.trimAndNullIfEmpty(md5Checksum),
HawkbitCommonUtil.trimAndNullIfEmpty(sha1Checksum), true, customFile.getMimeType());
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.SUCCESS, "");
} catch (final FileNotFoundException e) {
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
} catch (final ArtifactUploadFailedException e) {
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
} catch (final InvalidSHA1HashException e) {
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
} catch (final InvalidMD5HashException e) {
saveUploadStatus(providedFileName, swModuleNameVersion, SPUILabelDefinitions.FAILED, e.getMessage());
saveUploadStatus(providedFileName, swModuleNameVersion, SUCCESS, "");
} catch (final ArtifactUploadFailedException | InvalidSHA1HashException | InvalidMD5HashException
| FileNotFoundException e) {
saveUploadStatus(providedFileName, swModuleNameVersion, FAILED, e.getMessage());
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
} catch (final IOException ex) {
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, ex);
} finally {
closeFileStream(fis, newFile);
if (newFile.exists() && !newFile.delete()) {
LOG.error("Could not delete temporary file: {}", newFile);
}
}
}
@@ -659,21 +660,6 @@ public class UploadConfirmationwindow implements Button.ClickListener {
}
private static void closeFileStream(final FileInputStream fis, final File newFile) {
if (fis != null) {
try {
fis.close();
} catch (final IOException e) {
LOG.error(ARTIFACT_UPLOAD_EXCEPTION, e);
}
}
if (newFile.exists() && !newFile.delete()) {
LOG.error("Could not delete temporary file: {}", newFile);
}
}
public Table getUploadDetailsTable() {
return uploadDetailsTable;
}

View File

@@ -110,7 +110,7 @@ public class UploadLayout extends VerticalLayout {
private Button discardBtn;
private UploadConfirmationwindow currentUploadConfirmationwindow;
private UploadConfirmationWindow currentUploadConfirmationwindow;
private VerticalLayout dropAreaLayout;
@@ -639,7 +639,7 @@ public class UploadLayout extends VerticalLayout {
if (artifactUploadState.getFileSelected().isEmpty()) {
uiNotification.displayValidationError(i18n.get("message.error.noFileSelected"));
} else {
currentUploadConfirmationwindow = new UploadConfirmationwindow(this, artifactUploadState);
currentUploadConfirmationwindow = new UploadConfirmationWindow(this, artifactUploadState);
UI.getCurrent().addWindow(currentUploadConfirmationwindow.getUploadConfrimationWindow());
setConfirmationPopupHeightWidth(Page.getCurrent().getBrowserWindowWidth(),
Page.getCurrent().getBrowserWindowHeight());
@@ -661,7 +661,7 @@ public class UploadLayout extends VerticalLayout {
return spInfo;
}
void setCurrentUploadConfirmationwindow(final UploadConfirmationwindow currentUploadConfirmationwindow) {
void setCurrentUploadConfirmationwindow(final UploadConfirmationWindow currentUploadConfirmationwindow) {
this.currentUploadConfirmationwindow = currentUploadConfirmationwindow;
}

View File

@@ -57,11 +57,7 @@ import elemental.json.JsonValue;
/**
* Shows upload status during upload.
*
*
*
*/
@ViewScope
@SpringComponent
public class UploadStatusInfoWindow extends Window {
@@ -369,7 +365,7 @@ public class UploadStatusInfoWindow extends Window {
/**
* Called when each file upload is success.
*
*
* @param filename
* of the uploaded file.
* @param softwareModule
@@ -444,7 +440,7 @@ public class UploadStatusInfoWindow extends Window {
}
private void resizeWindow(final ClickEvent event) {
if (event.getButton().getIcon() == FontAwesome.EXPAND) {
if (FontAwesome.EXPAND.equals(event.getButton().getIcon())) {
event.getButton().setIcon(FontAwesome.COMPRESS);
setWindowMode(WindowMode.MAXIMIZED);
resetColumnWidth();

View File

@@ -16,15 +16,18 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.exception.EntityNotFoundException;
import org.eclipse.hawkbit.repository.model.MetaData;
import org.eclipse.hawkbit.repository.model.NamedVersionedEntity;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.customrenderers.renderers.HtmlButtonRenderer;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
@@ -48,7 +51,6 @@ import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.ui.themes.ValoTheme;
/**
*
@@ -115,10 +117,24 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
public CommonDialogWindow getWindow(final E entity, final M metaData) {
selectedEntity = entity;
final String nameVersion = HawkbitCommonUtil.getFormattedNameVersion(entity.getName(), entity.getVersion());
metadataWindow = SPUIWindowDecorator.getWindow(getMetadataCaption(nameVersion), null,
SPUIDefinitions.CUSTOM_METADATA_WINDOW, this, event -> onSave(), event -> onCancel(), null, mainLayout,
i18n);
metadataWindow.setId(SPUIComponentIdProvider.METADATA_POPUP_ID);
metadataWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(getMetadataCaption(nameVersion)).content(this).cancelButtonClickListener(event -> onCancel())
.id(SPUIComponentIdProvider.METADATA_POPUP_ID).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
metadataWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@Override
public void saveOrUpdate() {
onSave();
}
@Override
public boolean canWindowClose() {
return false;
}
});
metadataWindow.setHeight(550, Unit.PIXELS);
metadataWindow.setWidth(800, Unit.PIXELS);
metadataWindow.getMainLayout().setSizeFull();
@@ -204,9 +220,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
}
private TextField createKeyTextField() {
final TextField keyField = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
ValoTheme.TEXTFIELD_TINY, true, "", i18n.get("textfield.key"), true, 128);
keyField.setId(SPUIComponentIdProvider.METADATA_KEY_FIELD_ID);
final TextField keyField = new TextFieldBuilder().caption(i18n.get("textfield.key")).required(true)
.prompt(i18n.get("textfield.key")).immediate(true).id(SPUIComponentIdProvider.METADATA_KEY_FIELD_ID)
.maxLengthAllowed(128).buildTextComponent();
keyField.addTextChangeListener(event -> onKeyChange(event));
keyField.setTextChangeEventMode(TextChangeEventMode.EAGER);
keyField.setWidth("100%");
@@ -214,9 +230,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
}
private TextArea createValueTextField() {
valueTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.value"), null, ValoTheme.TEXTAREA_TINY,
true, null, i18n.get("textfield.value"), 4000);
valueTextArea.setId(SPUIComponentIdProvider.METADATA_VALUE_ID);
valueTextArea = new TextAreaBuilder().caption(i18n.get("textfield.value")).required(true)
.prompt(i18n.get("textfield.value")).immediate(true).id(SPUIComponentIdProvider.METADATA_VALUE_ID)
.maxLengthAllowed(4000).buildTextComponent();
valueTextArea.setNullRepresentation("");
valueTextArea.setSizeFull();
valueTextArea.setHeight(100, Unit.PERCENTAGE);
@@ -301,7 +317,7 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(i18n.get("caption.metadata"), SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(i18n.get("caption.metadata")).buildCaptionLabel();
}
private static IndexedContainer getMetadataContainer() {
@@ -407,9 +423,9 @@ public abstract class AbstractMetadataPopupLayout<E extends NamedVersionedEntity
private String getMetadataCaption(final String nameVersionStr) {
final StringBuilder caption = new StringBuilder();
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION + i18n.get("caption.metadata.popup") + " "
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_START + i18n.get("caption.metadata.popup") + " "
+ HawkbitCommonUtil.getBoldHTMLText(nameVersionStr));
caption.append(HawkbitCommonUtil.DIV_CLOSE);
caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_END);
return caption.toString();
}

View File

@@ -13,10 +13,6 @@ import com.vaadin.ui.AbstractColorPicker.Coordinates2Color;
/**
* Converts 2d-coordinates to a Color.
*
*
*
*
*/
public class CoordinatesToColor implements Coordinates2Color {
@@ -30,32 +26,31 @@ public class CoordinatesToColor implements Coordinates2Color {
@Override
public int[] calculate(final Color color) {
final float[] hsv = color.getHSV();
final int x = Math.round(hsv[0] * 220f);
int y = 0;
y = calculateYCoordinateOfColor(hsv);
final int x = Math.round(hsv[0] * 220F);
final int y = calculateYCoordinateOfColor(hsv);
return new int[] { x, y };
}
private Color calculateHSVColor(final int x, final int y) {
final float h = x / 220f;
float s = 1f;
float v = 1f;
private static Color calculateHSVColor(final int x, final int y) {
final float h = x / 220F;
float s = 1F;
float v = 1F;
if (y < 110) {
s = y / 110f;
s = y / 110F;
} else if (y > 110) {
v = 1f - (y - 110f) / 110f;
v = 1F - (y - 110F) / 110F;
}
return new Color(Color.HSVtoRGB(h, s, v));
}
private int calculateYCoordinateOfColor(final float[] hsv) {
private static int calculateYCoordinateOfColor(final float[] hsv) {
int y;
// lower half
/* Assuming hsv[] array value will have in the range of 0 to 1 */
if (hsv[1] < 1f) {
y = Math.round(hsv[1] * 110f);
if (hsv[1] < 1F) {
y = Math.round(hsv[1] * 110F);
} else {
y = Math.round(110f - (hsv[1] + hsv[2]) * 110f);
y = Math.round(110F - (hsv[1] + hsv[2]) * 110F);
}
return y;
}

View File

@@ -0,0 +1,151 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.builder;
import org.apache.commons.lang3.StringUtils;
import com.vaadin.ui.AbstractTextField;
/**
* Abstract Text field builder.
*
* @param <E>
* the concrete text component
*/
public abstract class AbstractTextFieldBuilder<E extends AbstractTextField> {
private String caption;
private String style;
private String styleName;
private String prompt;
private String id;
private boolean immediate;
private boolean required;
private int maxLengthAllowed;
/**
* @param caption
* the caption to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> caption(final String caption) {
this.caption = caption;
return this;
}
/**
* @param style
* the style to set * @return the builder
* @return the builder
*/
public AbstractTextFieldBuilder<E> style(final String style) {
this.style = style;
return this;
}
/**
* @param styleName
* the styleName to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> styleName(final String styleName) {
this.styleName = styleName;
return this;
}
/**
* @param required
* the required to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> required(final boolean required) {
this.required = required;
return this;
}
/**
* @param prompt
* the prompt to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> prompt(final String prompt) {
this.prompt = prompt;
return this;
}
/**
* @param immediate
* the immediate to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> immediate(final boolean immediate) {
this.immediate = immediate;
return this;
}
/**
* @param maxLengthAllowed
* the maxLengthAllowed to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> maxLengthAllowed(final int maxLengthAllowed) {
this.maxLengthAllowed = maxLengthAllowed;
return this;
}
/**
* @param id
* the id to set
* @return the builder
*/
public AbstractTextFieldBuilder<E> id(final String id) {
this.id = id;
return this;
}
/**
* Build a textfield
*
* @return textfield
*/
public E buildTextComponent() {
final E textComponent = createTextComponent();
textComponent.setRequired(required);
textComponent.setImmediate(immediate);
if (StringUtils.isNotEmpty(caption)) {
textComponent.setCaption(caption);
}
if (StringUtils.isNotEmpty(style)) {
textComponent.setStyleName(style);
}
if (StringUtils.isNotEmpty(styleName)) {
textComponent.addStyleName(styleName);
}
if (StringUtils.isNotEmpty(prompt)) {
textComponent.setInputPrompt(prompt);
}
if (maxLengthAllowed > 0) {
textComponent.setMaxLength(maxLengthAllowed);
}
if (StringUtils.isNotEmpty(id)) {
textComponent.setId(id);
}
return textComponent;
}
protected abstract E createTextComponent();
}

View File

@@ -0,0 +1,96 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.builder;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.ValoTheme;
/**
* Label Builder.
*
*/
public class LabelBuilder {
private String name;
private String id;
private boolean visible = true;
/**
* @param name
* the name to set
* @return builder
*/
public LabelBuilder name(final String name) {
this.name = name;
return this;
}
/**
* @param id
* the id to set
* @return builder
*/
public LabelBuilder id(final String id) {
this.id = id;
return this;
}
/**
* @param visible
* the visible to set
* @return builder
*/
public LabelBuilder visible(final boolean visible) {
this.visible = visible;
return this;
}
/**
* Build caption label.
*
* @return Label
*/
public Label buildCaptionLabel() {
final Label label = createLabel();
label.setValue(name);
label.addStyleName("header-caption");
return label;
}
/**
* Build label.
*
* @return Label
*/
public Label buildLabel() {
final Label label = createLabel();
label.setImmediate(false);
label.setWidth("-1px");
label.setHeight("-1px");
return label;
}
private Label createLabel() {
final Label label = new Label(name);
label.setVisible(visible);
final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
style.append(' ');
style.append(ValoTheme.LABEL_BOLD);
label.addStyleName(style.toString());
if (id != null) {
label.setId(id);
}
return label;
}
}

View File

@@ -0,0 +1,37 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.builder;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.themes.ValoTheme;
/**
* TextArea builder.
*
*/
public class TextAreaBuilder extends AbstractTextFieldBuilder<TextArea> {
private static final int TEXT_AREA_DEFAULT_MAX_LENGTH = 512;
/**
* Constructor.
*/
public TextAreaBuilder() {
maxLengthAllowed(TEXT_AREA_DEFAULT_MAX_LENGTH);
styleName(ValoTheme.TEXTAREA_TINY);
}
@Override
protected TextArea createTextComponent() {
final TextArea textArea = new TextArea();
textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
return textArea;
}
}

View File

@@ -0,0 +1,68 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.builder;
import com.vaadin.event.FieldEvents.TextChangeListener;
import com.vaadin.server.Sizeable.Unit;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.TextField;
import com.vaadin.ui.themes.ValoTheme;
/**
* Textfield builder.
*
*/
public class TextFieldBuilder extends AbstractTextFieldBuilder<TextField> {
private static final int TEXT_FIELD_DEFAULT_MAX_LENGTH = 64;
/**
* Constructor.
*/
public TextFieldBuilder() {
this(null);
}
/**
* Constructor.
*
* @param id
* the id
*/
public TextFieldBuilder(final String id) {
maxLengthAllowed(TEXT_FIELD_DEFAULT_MAX_LENGTH);
styleName(ValoTheme.TEXTAREA_TINY);
id(id);
}
/**
* Create a search text field.
*
* @param textChangeListener
* listener when text is changed.
* @return the textfield
*/
public TextField createSearchField(final TextChangeListener textChangeListener) {
final TextField textField = style("filter-box").styleName("text-style filter-box-hide").buildTextComponent();
textField.setWidth(100.0F, Unit.PERCENTAGE);
textField.addTextChangeListener(textChangeListener);
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
// 1 seconds timeout.
textField.setTextChangeTimeout(1000);
return textField;
}
@Override
protected TextField createTextComponent() {
final TextField textField = new TextField();
textField.addStyleName(ValoTheme.TEXTFIELD_SMALL);
return textField;
}
}

View File

@@ -0,0 +1,205 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.common.builder;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Window;
/**
* Builder for Window.
*/
public class WindowBuilder {
private String caption;
private Component content;
private ClickListener cancelButtonClickListener;
private String helpLink;
private AbstractLayout layout;
private I18N i18n;
private final String type;
private String id;
private SaveDialogCloseListener saveDialogCloseListener;
/**
* Constructor.
*
* @param type
* window type
*/
public WindowBuilder(final String type) {
this.type = type;
}
/**
* Set the SaveDialogCloseListener.
*
* @param saveDialogCloseListener
* the saveDialogCloseListener
* @return the window builder
*/
public WindowBuilder saveDialogCloseListener(final SaveDialogCloseListener saveDialogCloseListener) {
this.saveDialogCloseListener = saveDialogCloseListener;
return this;
}
/**
* Set the caption.
*
* @param caption
* the caption
* @return the window builder
*/
public WindowBuilder caption(final String caption) {
this.caption = caption;
return this;
}
/**
* Set the content.
*
* @param content
* the content
* @return the window builder
*/
public WindowBuilder content(final Component content) {
this.content = content;
return this;
}
/**
* Set the cancelButtonClickListener.
*
* @param cancelButtonClickListener
* the cancelButtonClickListener
* @return the window builder
*/
public WindowBuilder cancelButtonClickListener(final ClickListener cancelButtonClickListener) {
this.cancelButtonClickListener = cancelButtonClickListener;
return this;
}
/**
* Set the helpLink.
*
* @param helpLink
* the helpLink
* @return the window builder
*/
public WindowBuilder helpLink(final String helpLink) {
this.helpLink = helpLink;
return this;
}
/**
* Set the layout.
*
* @param layout
* the layout
* @return the window builder
*/
public WindowBuilder layout(final AbstractLayout layout) {
this.layout = layout;
return this;
}
/**
* Set the i18n.
*
* @param i18n
* the i18n
* @return the window builder
*/
public WindowBuilder i18n(final I18N i18n) {
this.i18n = i18n;
return this;
}
/**
* @param id
* the id to set * @return the window builder
*/
public WindowBuilder id(final String id) {
this.id = id;
return this;
}
/**
* Build the common dialog window.
*
* @return the window.
*/
public CommonDialogWindow buildCommonDialogWindow() {
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
layout, i18n);
window.setSaveDialogCloseListener(saveDialogCloseListener);
decorateWindow(window);
return window;
}
/**
* Build the common dialog window.
*
* @return the window.
*/
public CommonDialogWindow buildConfirmationWindow() {
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
layout, i18n);
window.setSaveDialogCloseListener(saveDialogCloseListener);
decorateWindow(window);
return window;
}
private void decorateWindow(final Window window) {
if (id != null) {
window.setId(id);
}
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
window.setDraggable(false);
window.setClosable(true);
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
window.setDraggable(true);
window.setClosable(true);
}
}
/**
* Build window based on type.
*
* @return Window
*/
public Window buildWindow() {
final Window window = new Window(caption);
window.setContent(content);
window.setSizeUndefined();
window.setModal(true);
window.setResizable(false);
decorateWindow(window);
if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
window.setClosable(false);
}
return window;
}
}

View File

@@ -13,6 +13,7 @@ import java.util.Map.Entry;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.I18N;
@@ -51,6 +52,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
@Autowired
protected transient EventBus.SessionEventBus eventBus;
/**
* PostConstruct.
*/
@PostConstruct
public void initialize() {
removeAllComponents();
@@ -65,10 +69,9 @@ public abstract class AbstractConfirmationWindowLayout extends VerticalLayout {
}
private void createActionMessgaeLabel() {
actionMessage = SPUIComponentProvider.getLabel("", null);
actionMessage = new LabelBuilder().name("").id(SPUIComponentIdProvider.ACTION_LABEL).visible(false)
.buildLabel();
actionMessage.addStyleName(SPUIStyleDefinitions.CONFIRM_WINDOW_INFO_BOX);
actionMessage.setId(SPUIComponentIdProvider.ACTION_LABEL);
actionMessage.setVisible(false);
}
private void createAccordian() {

View File

@@ -17,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEvent;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
@@ -25,7 +26,6 @@ import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -183,7 +183,7 @@ public abstract class AbstractTableDetailsLayout<T extends NamedEntity> extends
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(getDefaultCaption(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(getDefaultCaption()).buildCaptionLabel();
}
protected VerticalLayout getTabLayout() {

View File

@@ -33,7 +33,7 @@ import com.vaadin.ui.UI;
import com.vaadin.ui.themes.ValoTheme;
/**
*
*
* DistributionSet Metadata details layout.
*
*/
@@ -44,14 +44,14 @@ public class DistributionSetMetadatadetailslayout extends Table {
private static final long serialVersionUID = 2913758299611837718L;
private DistributionSetManagement distributionSetManagement;
private DsMetadataPopupLayout dsMetadataPopupLayout;
private static final String METADATA_KEY = "Key";
private static final String VIEW = "view";
private transient DistributionSetManagement distributionSetManagement;
private DsMetadataPopupLayout dsMetadataPopupLayout;
private SpPermissionChecker permissionChecker;
private transient EntityFactory entityFactory;
@@ -61,7 +61,7 @@ public class DistributionSetMetadatadetailslayout extends Table {
private Long selectedDistSetId;
/**
* Initialize the component.
*
* @param i18n
* @param permissionChecker
* @param distributionSetManagement
@@ -82,7 +82,7 @@ public class DistributionSetMetadatadetailslayout extends Table {
/**
* Populate software module metadata.
*
*
* @param distributionSet
*/
public void populateDSMetadata(final DistributionSet distributionSet) {

View File

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.ui.common.filterlayout;
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.NO_TAG_BUTTON_ID;
import java.util.ArrayList;
import java.util.List;
@@ -50,7 +52,7 @@ public abstract class AbstractFilterButtons extends Table {
/**
* Initialize layout of filter buttons.
*
*
* @param filterButtonClickBehaviour
* click behaviour of filter buttons.
*/
@@ -95,16 +97,12 @@ public abstract class AbstractFilterButtons extends Table {
container.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.class, null, true, true);
}
@SuppressWarnings("serial")
protected void addColumn() {
addGeneratedColumn(FILTER_BUTTON_COLUMN, (source, itemId, columnId) -> addGeneratedCell(itemId));
}
/**
* @param itemId
* @return
*/
private DragAndDropWrapper addGeneratedCell(final Object itemId) {
final Item item = getItem(itemId);
final Long id = (Long) item.getItemProperty(SPUILabelDefinitions.VAR_ID).getValue();
final String name = (String) item.getItemProperty(SPUILabelDefinitions.VAR_NAME).getValue();
@@ -116,16 +114,18 @@ public abstract class AbstractFilterButtons extends Table {
? item.getItemProperty(SPUILabelDefinitions.VAR_COLOR).getValue().toString() : DEFAULT_GREEN;
final Button typeButton = createFilterButton(id, name, desc, color, itemId);
typeButton.addClickListener(event -> filterButtonClickBehaviour.processFilterButtonClick(event));
if (typeButton.getData().equals(SPUIDefinitions.NO_TAG_BUTTON_ID) && isNoTagSateSelected()) {
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
} else if (id != null && isClickedByDefault(name)) {
if ((NO_TAG_BUTTON_ID.equals(typeButton.getData()) && isNoTagStateSelected())
|| (id != null && isClickedByDefault(name))) {
filterButtonClickBehaviour.setDefaultClickedButton(typeButton);
}
return createDragAndDropWrapper(typeButton, name, id);
}
protected boolean isNoTagSateSelected() {
return Boolean.FALSE;
protected boolean isNoTagStateSelected() {
return false;
}
private DragAndDropWrapper createDragAndDropWrapper(final Button tagButton, final String name, final Long id) {
@@ -195,21 +195,21 @@ public abstract class AbstractFilterButtons extends Table {
/**
* Id of the buttons table to be used in test cases.
*
*
* @return Id of the Button table.
*/
protected abstract String getButtonsTableId();
/**
* create new lazyquery container to display the buttons.
*
*
* @return reference of {@link LazyQueryContainer}
*/
protected abstract LazyQueryContainer createButtonsLazyQueryContainer();
/**
* Check if button should be displayed as clicked by default.
*
*
* @param buttonCaption
* button caption
* @return true if button is clicked
@@ -218,7 +218,7 @@ public abstract class AbstractFilterButtons extends Table {
/**
* Get filter button Id.
*
*
* @param name
* @return
*/
@@ -226,7 +226,7 @@ public abstract class AbstractFilterButtons extends Table {
/**
* Get Drop Handler for Filter Buttons.
*
*
* @return
*/
protected abstract DropHandler getFilterButtonDropHandler();
@@ -234,14 +234,14 @@ public abstract class AbstractFilterButtons extends Table {
/**
* Get prefix Id of Button Wrapper to be used for drag and drop, delete and
* test cases.
*
*
* @return prefix Id of Button Wrapper
*/
protected abstract String getButttonWrapperIdPrefix();
/**
* Get info to be set for the button wrapper.
*
*
* @return button wrapper info.
*/
protected abstract String getButtonWrapperData();

View File

@@ -9,6 +9,7 @@
package org.eclipse.hawkbit.ui.common.filterlayout;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
@@ -91,7 +92,7 @@ public abstract class AbstractFilterHeader extends VerticalLayout {
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(getTitle(), SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(getTitle()).buildCaptionLabel();
}
/**

View File

@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
@@ -215,11 +216,10 @@ public abstract class AbstractDeleteActionsLayout extends VerticalLayout impleme
if (!hasUnsavedActions()) {
return;
}
unsavedActionsWindow = SPUIComponentProvider.getWindow(getUnsavedActionsWindowCaption(),
SPUIComponentIdProvider.SAVE_ACTIONS_POPUP, SPUIDefinitions.CONFIRMATION_WINDOW);
unsavedActionsWindow = new WindowBuilder(SPUIDefinitions.CONFIRMATION_WINDOW)
.caption(getUnsavedActionsWindowCaption()).id(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID)
.content(getUnsavedActionsWindowContent()).buildWindow();
unsavedActionsWindow.addCloseListener(event -> unsavedActionsWindowClosed());
unsavedActionsWindow.setContent(getUnsavedActionsWindowContent());
unsavedActionsWindow.setId(SPUIComponentIdProvider.CONFIRMATION_POPUP_ID);
UI.getCurrent().addWindow(unsavedActionsWindow);
}

View File

@@ -8,16 +8,15 @@
*/
package org.eclipse.hawkbit.ui.common.grid;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.google.common.base.Strings;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
@@ -61,7 +60,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
private void createComponents() {
headerCaptionLayout = getHeaderCaptionLayout();
if (isRollout()) {
searchField = createSearchField();
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText()));
searchResetIcon = createSearchResetIcon();
addButton = createAddButton();
}
@@ -92,7 +91,7 @@ public abstract class AbstractGridHeader extends VerticalLayout {
addStyleName("no-border-bottom");
}
private HorizontalLayout createHeaderFilterIconLayout() {
private static HorizontalLayout createHeaderFilterIconLayout() {
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
titleFilterIconsLayout.setSpacing(false);
@@ -101,17 +100,6 @@ public abstract class AbstractGridHeader extends VerticalLayout {
return titleFilterIconsLayout;
}
private TextField createSearchField() {
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
textField.setId(getSearchBoxId());
textField.setWidth(100.0f, Unit.PERCENTAGE);
textField.addTextChangeListener(event -> searchBy(event.getText()));
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
textField.setTextChangeTimeout(1000);
return textField;
}
private SPUIButton createSearchResetIcon() {
final SPUIButton button = (SPUIButton) SPUIComponentProvider.getButton(getSearchRestIconId(), "", "", null,
false, FontAwesome.SEARCH, SPUIButtonStyleSmallNoBorder.class);

View File

@@ -12,20 +12,20 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import com.vaadin.event.dd.DropHandler;
import com.vaadin.server.FontAwesome;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.DragAndDropWrapper;
@@ -86,7 +86,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
private void createComponents() {
headerCaption = createHeaderCaption();
searchField = createSearchField();
searchField = new TextFieldBuilder(getSearchBoxId()).createSearchField(event -> searchBy(event.getText()));
searchResetIcon = createSearchResetIcon();
@@ -203,21 +203,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
}
private Label createHeaderCaption() {
final Label captionLabel = SPUIComponentProvider.getLabel(getHeaderCaption(),
SPUILabelDefinitions.SP_WIDGET_CAPTION);
return captionLabel;
}
private TextField createSearchField() {
final TextField textField = SPUIComponentProvider.getTextField("", "filter-box", "text-style filter-box-hide",
false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
textField.setId(getSearchBoxId());
textField.setWidth(100.0f, Unit.PERCENTAGE);
textField.addTextChangeListener(event -> searchBy(event.getText()));
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);
// 1 seconds timeout.
textField.setTextChangeTimeout(1000);
return textField;
return new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel();
}
private SPUIButton createSearchResetIcon() {
@@ -322,7 +308,7 @@ public abstract class AbstractTableHeader extends VerticalLayout {
maxMinIcon.setData(Boolean.FALSE);
}
private HorizontalLayout createHeaderFilterIconLayout() {
private static HorizontalLayout createHeaderFilterIconLayout() {
final HorizontalLayout titleFilterIconsLayout = new HorizontalLayout();
titleFilterIconsLayout.addStyleName(SPUIStyleDefinitions.WIDGET_TITLE);
titleFilterIconsLayout.setSpacing(false);

View File

@@ -21,7 +21,7 @@ import com.vaadin.ui.VerticalLayout;
/**
* Attributes Vertical layout for Target.
*
*
*
*
*/
@@ -30,10 +30,10 @@ public class SPTargetAttributesLayout {
/**
* Parametric constructor.
*
*
* @param controllerAttibs
* controller attributes
*
*
*/
public SPTargetAttributesLayout(final Map<String, String> controllerAttibs) {
targetAttributesLayout = new VerticalLayout();
@@ -44,7 +44,7 @@ public class SPTargetAttributesLayout {
/**
* Custom Decorate.
*
*
* @param controllerAttibs
*/
private void decorate(final Map<String, String> controllerAttibs) {
@@ -52,7 +52,7 @@ public class SPTargetAttributesLayout {
final Label title = new Label(i18n.get("label.target.controller.attrs"), ContentMode.HTML);
title.addStyleName(SPUIDefinitions.TEXT_STYLE);
targetAttributesLayout.addComponent(title);
if (HawkbitCommonUtil.mapCheckStrings(controllerAttibs)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(controllerAttibs)) {
for (final Map.Entry<String, String> entry : controllerAttibs.entrySet()) {
targetAttributesLayout.addComponent(
SPUIComponentProvider.createNameValueLabel(entry.getKey() + ": ", entry.getValue()));
@@ -62,7 +62,7 @@ public class SPTargetAttributesLayout {
/**
* GET Target Attributes Layout.
*
*
* @return VerticalLayout as UI
*/
public VerticalLayout getTargetAttributesLayout() {

View File

@@ -17,11 +17,6 @@ import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.ui.common.UserDetailsFormatter;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIComboBoxDecorator;
import org.eclipse.hawkbit.ui.decorators.HeaderLayoutDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUILabelDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextAreaDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUITextFieldDecorator;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.slf4j.Logger;
@@ -34,15 +29,11 @@ import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.CheckBox;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.Link;
import com.vaadin.ui.Panel;
import com.vaadin.ui.TabSheet;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
/**
@@ -61,152 +52,9 @@ public final class SPUIComponentProvider {
}
/**
* @param className
* @return
*/
public static HorizontalLayout getHorizontalLayout(final Class<? extends HorizontalLayout> className) {
HorizontalLayout hLayout = null;
try {
hLayout = className.newInstance();
} catch (final InstantiationException exception) {
LOG.error("Error occured while creating HorizontalLayout-" + className, exception);
} catch (final IllegalAccessException exception) {
LOG.error("Error occured while acessing HorizontalLayout-" + className, exception);
}
return hLayout;
}
/**
* Get HorizontalLayout UI component.
*
* @param className
* as Layout
* @return HorizontalLayout as UI
*/
public static HorizontalLayout getHorizontalLayout() {
HorizontalLayout hLayout = null;
try {
hLayout = HorizontalLayout.class.newInstance();
} catch (final InstantiationException exception) {
LOG.error("Error occured while creating HorizontalLayout-", exception);
} catch (final IllegalAccessException exception) {
LOG.error("Error occured while acessing HorizontalLayout-", exception);
}
return hLayout;
}
/**
* @param tableHeaderLayoutDecorator
* @return
*/
public static HorizontalLayout getHeaderLayout(
final Class<? extends HeaderLayoutDecorator> tableHeaderLayoutDecorator) {
// Do we really need this???
HorizontalLayout hLayout = getHorizontalLayout(new SPUIHorizontalLayout().getUiHorizontalLayout().getClass());
if (tableHeaderLayoutDecorator == null) {
return hLayout;
}
try {
final HeaderLayoutDecorator layoutDecorator = tableHeaderLayoutDecorator.newInstance();
hLayout = layoutDecorator.decorate(hLayout);
} catch (final InstantiationException | IllegalAccessException exception) {
LOG.error("Error occured while creating horizontal decorator " + HeaderLayoutDecorator.class,
exception);
}
return hLayout;
}
/**
* Get Label UI component.
*
* @param name
* label caption
* @param type
* string simple|Confirm|Message
* @return Label
*/
public static Label getLabel(final String name, final String type) {
return SPUILabelDecorator.getDeocratedLabel(name, type);
}
/**
* Get window component.
*
* @param caption
* window caption
* @param id
* window id
* @param type
* type of window
* @return Window
*/
public static Window getWindow(final String caption, final String id, final String type) {
return SPUIWindowDecorator.getDeocratedWindow(caption, id, type);
}
/**
* Get Label UI component.
*
* @param caption
* set the caption of the textfield
* @param style
* set style
* @param styleName
* add style
* @param required
* to set field as mandatory
* @param data
* component data
* @param prompt
* prompt user for input
* @param immediate
* set component's immediate mode specified mode
* @param maxLengthAllowed
* maximum characters allowed
* @return TextField text field
*/
public static TextField getTextField(final String caption, final String style, final String styleName,
final boolean required, final String data, final String prompt, final boolean immediate,
final int maxLengthAllowed) {
return SPUITextFieldDecorator.decorate(caption, style, styleName, required, data, prompt, immediate,
maxLengthAllowed);
}
/**
* Get Label UI component. *
*
* @param caption
* set the caption of the textArea
* @param style
* set style
* @param styleName
* add style
* @param required
* to set field as mandatory
* @param data
* component data
* @param promt
* prompt user for input
* @param maxLength
* maximum characters allowed
* @return TextArea text area
*/
public static TextArea getTextArea(final String caption, final String style, final String styleName,
final boolean required, final String data, final String promt, final int maxLength) {
return SPUITextAreaDecorator.decorate(caption, style, styleName, required, data, promt, maxLength);
}
/**
* Get Label UI component.
*
* @param caption
* caption of the combo box
* @param height
@@ -252,7 +100,7 @@ public final class SPUIComponentProvider {
/**
* Get Button - Factory Approach for decoration.
*
*
* @param id
* as string
* @param buttonName
@@ -289,7 +137,7 @@ public final class SPUIComponentProvider {
/**
* Get the style required.
*
*
* @return String
*/
public static String getPinButtonStyle() {
@@ -305,7 +153,7 @@ public final class SPUIComponentProvider {
/**
* Get DistributionSet Info Panel.
*
*
* @param distributionSet
* as DistributionSet
* @param caption
@@ -323,7 +171,7 @@ public final class SPUIComponentProvider {
/**
* Method to CreateName value labels.
*
*
* @param label
* as string
* @param values
@@ -356,7 +204,7 @@ public final class SPUIComponentProvider {
/**
* Create label which represents the {@link BaseEntity#getCreatedBy()} by
* user name
*
*
* @param i18n
* the i18n
* @param baseEntity
@@ -371,7 +219,7 @@ public final class SPUIComponentProvider {
/**
* Create label which represents the
* {@link BaseEntity#getLastModifiedBy()()} by user name
*
*
* @param i18n
* the i18n
* @param baseEntity
@@ -385,7 +233,7 @@ public final class SPUIComponentProvider {
/**
* Get Bold Text.
*
*
* @param text
* as String
* @return String as bold
@@ -396,7 +244,7 @@ public final class SPUIComponentProvider {
/**
* Get the layout for Target:Controller Attributes.
*
*
* @param controllerAttibs
* as Map
* @return VerticalLayout
@@ -407,7 +255,7 @@ public final class SPUIComponentProvider {
/**
* Get Tabsheet.
*
*
* @return SPUITabSheet
*/
public static TabSheet getDetailsTabSheet() {
@@ -416,7 +264,7 @@ public final class SPUIComponentProvider {
/**
* Layout of tabs in detail tabsheet.
*
*
* @return VerticalLayout
*/
public static VerticalLayout getDetailTabLayout() {
@@ -429,7 +277,7 @@ public final class SPUIComponentProvider {
/**
* Method to create a link.
*
*
* @param id
* of the link
* @param name
@@ -465,10 +313,10 @@ public final class SPUIComponentProvider {
/**
* Generates help/documentation links from within management UI.
*
*
* @param uri
* to documentation site
*
*
* @return generated link
*/
public static Link getHelpLink(final String uri) {

View File

@@ -1,49 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.components;
import com.vaadin.ui.HorizontalLayout;
/**
* Plain Horizontal Layout.
*
*
*
*/
public class SPUIHorizontalLayout {
private final HorizontalLayout uiHorizontalLayout;
/**
* Default constructor.
*/
public SPUIHorizontalLayout() {
uiHorizontalLayout = new HorizontalLayout();
decorate();
}
/**
* Decorate.
*/
private void decorate() {
uiHorizontalLayout.setImmediate(false);
uiHorizontalLayout.setMargin(false);
uiHorizontalLayout.setSpacing(true);
}
/**
* Get HorizontalLayout.
*
* @return HorizontalLayout as UI
*/
public HorizontalLayout getUiHorizontalLayout() {
return uiHorizontalLayout;
}
}

View File

@@ -17,21 +17,22 @@ import com.vaadin.client.renderers.ClickableRenderer.RendererClickHandler;
import com.vaadin.shared.ui.Connect;
import elemental.json.JsonObject;
/**
* A connector for {@link CustomObjectRenderer }.
*
*/
@Connect(org.eclipse.hawkbit.ui.customrenderers.renderers.RolloutRenderer.class)
public class RolloutRendererConnector extends ClickableRendererConnector<RolloutRendererData> {
private static final long serialVersionUID = 7734682321931830566L;
private static final long serialVersionUID = 7734682321931830566L;
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
}
@Override
public org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer getRenderer() {
return (org.eclipse.hawkbit.ui.customrenderers.client.renderers.RolloutRenderer) super.getRenderer();
}
@Override
protected HandlerRegistration addClickHandler(
RendererClickHandler<JsonObject> handler) {
@Override
protected HandlerRegistration addClickHandler(final RendererClickHandler<JsonObject> handler) {
return getRenderer().addClickHandler(handler);
}
}
}

View File

@@ -11,52 +11,49 @@ package org.eclipse.hawkbit.ui.customrenderers.client.renderers;
import java.io.Serializable;
/**
* RendererData class with Name and Status.
*
* RendererData class with name and status.
*/
public class RolloutRendererData implements Serializable {
private static final long serialVersionUID = -5018181529953620263L;
private String name;
private static final long serialVersionUID = -5018181529953620263L;
private String status;
private String name;
/**
* Initialize the RendererData.
*/
public RolloutRendererData() {
private String status;
}
/**
* Initialize the RendererData empty.
*/
public RolloutRendererData() {
// Needed by Vaadin for compiling the widget set.
}
/**
* Initialize the RendererData.
*
* @param name
* Name of the Rollout.
* @param status
* Status of Rollout.
*/
public RolloutRendererData(String name, String status) {
super();
this.name = name;
this.status = status;
}
/**
* Initialize the RendererData.
*
* @param name
* Name of the Rollout.
* @param status
* Status of Rollout.
*/
public RolloutRendererData(final String name, final String status) {
this.name = name;
this.status = status;
}
public String getName() {
return name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void setName(final String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getStatus() {
return status;
}
public void setStatus(final String status) {
this.status = status;
}
}

View File

@@ -16,46 +16,44 @@ import com.vaadin.ui.renderers.ClickableRenderer;
import elemental.json.JsonValue;
/**
* Renders button with provided CustomObject.
* Used to display button with link.
*
* Renders button with provided CustomObject. Used to display button with link.
*/
public class RolloutRenderer extends ClickableRenderer<RolloutRendererData> {
private static final long serialVersionUID = -8754180585906263554L;
private static final long serialVersionUID = -8754180585906263554L;
/**
* Creates a new custom object renderer.
*/
public RolloutRenderer() {
super(RolloutRendererData.class, null);
}
/**
* Initialize custom object renderer with {@link Class<CustomObject>}
*
* @param presentationType
* Class<CustomObject>
*/
/**
* Creates a new custom object renderer.
*/
public RolloutRenderer() {
super(RolloutRendererData.class, null);
}
public RolloutRenderer(Class<RolloutRendererData> presentationType) {
super(presentationType);
}
/**
* Initialize custom object renderer with the given type.
*
* @param presentationType
* Class<CustomObject>
*/
/**
* Creates a new custom object renderer and adds the given click listener to it.
*
* @param listener
* the click listener to register
*/
public RolloutRenderer(RendererClickListener listener) {
this();
addClickListener(listener);
}
public RolloutRenderer(final Class<RolloutRendererData> presentationType) {
super(presentationType);
}
@Override
public JsonValue encode(RolloutRendererData resource) {
return super.encode(resource, RolloutRendererData.class);
}
/**
* Creates a new custom object renderer and adds the given click listener to
* it.
*
* @param listener
* the click listener to register
*/
public RolloutRenderer(final RendererClickListener listener) {
this();
addClickListener(listener);
}
@Override
public JsonValue encode(final RolloutRendererData resource) {
return super.encode(resource, RolloutRendererData.class);
}
}

View File

@@ -1,65 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.decorators;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Label;
import com.vaadin.ui.themes.ValoTheme;
/**
* Simple Decorator for the label.
*
*
*
*
*
*/
public final class SPUILabelDecorator {
/**
* Private Constructor.
*/
private SPUILabelDecorator() {
}
/**
* Simple decorator.
*
* @param name
* as String
* @param type
* as String
* @return Label
*/
public static Label getDeocratedLabel(final String name, final String type) {
final Label spUILabel = new Label(name);
// Set style.
final StringBuilder style = new StringBuilder(ValoTheme.LABEL_SMALL);
style.append(' ');
style.append(ValoTheme.LABEL_BOLD);
spUILabel.addStyleName(style.toString());
if (SPUILabelDefinitions.SP_WIDGET_CAPTION.equalsIgnoreCase(type)) {
spUILabel.setValue(name);
spUILabel.addStyleName("header-caption");
} else if (SPUILabelDefinitions.SP_LABEL_MESSAGE.equalsIgnoreCase(type)) {
spUILabel.setContentMode(ContentMode.HTML);
spUILabel.addStyleName(SPUILabelDefinitions.SP_LABEL_MESSAGE_STYLE);
} else {
spUILabel.setImmediate(false);
spUILabel.setWidth("-1px");
spUILabel.setHeight("-1px");
}
return spUILabel;
}
}

View File

@@ -1,81 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.decorators;
import org.apache.commons.lang3.StringUtils;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.themes.ValoTheme;
/**
* TextArea with required style.
*
*
*
*/
public final class SPUITextAreaDecorator {
/**
* Private Constrcutor.
*/
private SPUITextAreaDecorator() {
}
/**
* Decorate.
*
* @param style
* set style
* @param styleName
* add style
* @param required
* to set field as mandatory
* @param data
* component data
* @param prompt
* as user for input
* @param maxLength
* maximum characters allowed
* @return TextArea as comp
*/
public static TextArea decorate(final String caption, final String style, final String styleName,
final boolean required, final String data, final String prompt, final int maxLength) {
final TextArea spUITxtArea = new TextArea();
// Default settings
spUITxtArea.setRequired(false);
spUITxtArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
if (StringUtils.isNotEmpty(caption)) {
spUITxtArea.setCaption(caption);
}
if (required) {
spUITxtArea.setRequired(true);
}
// Add style
if (StringUtils.isNotEmpty(style)) {
spUITxtArea.setStyleName(style);
}
// Add style Name
if (StringUtils.isNotEmpty(styleName)) {
spUITxtArea.addStyleName(styleName);
}
if (StringUtils.isNotEmpty(prompt)) {
spUITxtArea.setInputPrompt(prompt);
}
if (StringUtils.isNotEmpty(data)) {
spUITxtArea.setData(data);
}
if (maxLength > 0) {
spUITxtArea.setMaxLength(maxLength);
}
return spUITxtArea;
}
}

View File

@@ -1,88 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.decorators;
import org.apache.commons.lang3.StringUtils;
import com.vaadin.ui.TextField;
import com.vaadin.ui.themes.ValoTheme;
/**
* Decorate TextField with required style.
*
*
*
*/
public final class SPUITextFieldDecorator {
/**
* Constructor.
*/
private SPUITextFieldDecorator() {
}
/**
*
* @param caption
* set the caption of the textfield
* @param style
* set style
* @param styleName
* add style
* @param required
* to set field as mandatory
* @param data
* component data
* @param prompt
* prompt user for input
* @param immediate
* as for display
* @param maxLengthAllowed
* maximum characters allowed
* @return Text field as decorated
*/
public static TextField decorate(final String caption, final String style, final String styleName,
final boolean required, final String data, final String prompt, final boolean immediate,
final int maxLengthAllowed) {
final TextField spUITxtFld = new TextField();
if (StringUtils.isNotEmpty(caption)) {
spUITxtFld.setCaption(caption);
}
// Default settings
spUITxtFld.setRequired(false);
spUITxtFld.addStyleName(ValoTheme.TEXTFIELD_SMALL);
if (required) {
spUITxtFld.setRequired(true);
}
if (immediate) {
spUITxtFld.setImmediate(true);
}
// Add style
if (StringUtils.isNotEmpty(style)) {
spUITxtFld.setStyleName(style);
}
// Add style Name
if (StringUtils.isNotEmpty(styleName)) {
spUITxtFld.addStyleName(styleName);
}
if (StringUtils.isNotEmpty(prompt)) {
spUITxtFld.setInputPrompt(prompt);
}
if (StringUtils.isNotEmpty(data)) {
spUITxtFld.setData(data);
}
if (maxLengthAllowed > 0) {
spUITxtFld.setMaxLength(maxLengthAllowed);
}
return spUITxtFld;
}
}

View File

@@ -1,158 +0,0 @@
/**
* Copyright (c) 2015 Bosch Software Innovations GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*/
package org.eclipse.hawkbit.ui.decorators;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import com.vaadin.ui.AbstractLayout;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.Window;
/**
* Decorator for Window.
*
*
*
*/
public final class SPUIWindowDecorator {
/**
* Private Constructor.
*/
private SPUIWindowDecorator() {
}
/**
* Decorates window based on type.
*
* @param caption
* window caption
* @param id
* window id
* @param type
* window type
* @param content
* content in the window
* @param cancelButtonClickListener
* cancel button
* @param helpLink
* help link
* @param layout
* layout in the window
* @param i18n
* i18n for internationalization
* @return Window
*
*/
public static CommonDialogWindow getWindow(final String caption, final String id, final String type,
final Component content, final ClickListener cancelButtonClickListener, final String helpLink,
final AbstractLayout layout, final I18N i18n) {
return getWindow(caption, id, type, content, null, cancelButtonClickListener, helpLink, layout, i18n);
}
/**
* @param caption
* window caption
* @param id
* window id
* @param type
* window type
* @param content
* content in the window
* @param saveButtonClickListener
* save button
* @param cancelButtonClickListener
* cancel button
* @param helpLink
* help link
* @param layout
* layout in the window
* @param i18n
* i18n for internationalization
* @return window
*/
public static CommonDialogWindow getWindow(final String caption, final String id, final String type,
final Component content, final ClickListener saveButtonClickListener,
final ClickListener cancelButtonClickListener, final String helpLink, final AbstractLayout layout,
final I18N i18n) {
final CommonDialogWindow window = new CommonDialogWindow(caption, content, helpLink, cancelButtonClickListener,
layout, i18n);
if (SPUIDefinitions.CUSTOM_METADATA_WINDOW.equals(type)) {
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@Override
public void saveOrUpdate() {
saveButtonClickListener.buttonClick(null);
}
@Override
public boolean canWindowClose() {
return false;
}
});
window.setDraggable(true);
window.setClosable(true);
} else {
if (null != id) {
window.setId(id);
}
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
window.setDraggable(false);
window.setClosable(true);
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
window.setDraggable(true);
window.setClosable(true);
}
}
return window;
}
/**
* Decorates window based on type.
*
* @param caption
* window caption
* @param id
* window id
* @param type
* window type
* @return Window
*/
public static Window getDeocratedWindow(final String caption, final String id, final String type) {
final Window window = new Window(caption);
window.setSizeUndefined();
window.setModal(true);
window.setResizable(false);
if (null != id) {
window.setId(id);
}
if (SPUIDefinitions.CONFIRMATION_WINDOW.equals(type)) {
window.setDraggable(false);
window.setClosable(true);
window.addStyleName(SPUIStyleDefinitions.CONFIRMATION_WINDOW_CAPTION);
} else if (SPUIDefinitions.CREATE_UPDATE_WINDOW.equals(type)) {
window.setDraggable(true);
window.setClosable(false);
}
return window;
}
}

View File

@@ -18,6 +18,8 @@ import org.eclipse.hawkbit.repository.model.DistributionSetType;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.distributions.event.DistributionSetTypeEvent;
@@ -44,6 +46,7 @@ import com.vaadin.ui.CheckBox;
import com.vaadin.ui.Component;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Table;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
@@ -83,24 +86,24 @@ public class CreateUpdateDistSetTypeLayout extends CreateUpdateTypeLayout<Distri
super.createRequiredComponents();
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_NAME, true, "",
i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
tagName = createTextField("textfield.name", SPUIDefinitions.DIST_SET_TYPE_NAME,
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_NAME);
typeKey = SPUIComponentProvider.getTextField(i18n.get("textfield.key"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_KEY, true, "", i18n.get("textfield.key"),
true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
typeKey.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
typeKey = createTextField("textfield.key", SPUIDefinitions.DIST_SET_TYPE_KEY,
SPUIDefinitions.NEW_DISTRIBUTION_TYPE_KEY);
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC, false, "",
i18n.get("textfield.description"), SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
tagDesc.setId(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC);
tagDesc.setImmediate(true);
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.DIST_SET_TYPE_DESC)
.prompt(i18n.get("textfield.description")).immediate(true)
.id(SPUIDefinitions.NEW_DISTRIBUTION_TYPE_DESC).buildTextComponent();
tagDesc.setNullRepresentation("");
}
private TextField createTextField(final String in18Key, final String styleName, final String id) {
return new TextFieldBuilder().caption(i18n.get(in18Key)).styleName(ValoTheme.TEXTFIELD_TINY + " " + styleName)
.required(true).prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
}
@Override
protected void buildLayout() {

View File

@@ -117,5 +117,4 @@ public class DSTypeFilterButtons extends AbstractFilterButtons {
private void refreshTypeTable() {
setContainerDataSource(createButtonsLazyQueryContainer());
}
}

View File

@@ -50,7 +50,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
private DistributionSetType distributionSetType = null;
/**
*
*
* @param definition
* @param queryConfig
* @param sortPropertyIds
@@ -60,7 +60,7 @@ public class ManageDistBeanQuery extends AbstractBeanQuery<ProxyDistribution> {
final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(searchText)) {
searchText = String.format("%%%s%%", searchText);

View File

@@ -15,11 +15,9 @@ import org.eclipse.hawkbit.repository.SoftwareManagement;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleMetadata;
import org.eclipse.hawkbit.ui.artifacts.state.ArtifactUploadState;
import org.eclipse.hawkbit.ui.common.AbstractMetadataPopupLayout;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent;
import org.eclipse.hawkbit.ui.distributions.event.MetadataEvent.MetadataUIEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -27,7 +25,6 @@ import com.vaadin.spring.annotation.ViewScope;
/**
* Pop up layout to display software module metadata.
*
*/
@SpringComponent
@ViewScope
@@ -39,39 +36,35 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
private transient SoftwareManagement softwareManagement;
@Autowired
private ArtifactUploadState artifactUploadState;
@Autowired
private EntityFactory entityFactory;
@Autowired
private ManageDistUIState manageDistUIState;
private transient EntityFactory entityFactory;
@Autowired
protected SpPermissionChecker permChecker;
@Override
protected void checkForDuplicate(SoftwareModule entity, String value) {
protected void checkForDuplicate(final SoftwareModule entity, final String value) {
softwareManagement.findSoftwareModuleMetadata(entity, value);
}
/**
* Create metadata for SWModule.
*/
* Create metadata for SWModule.
*/
@Override
protected SoftwareModuleMetadata createMetadata(SoftwareModule entity, String key, String value) {
SoftwareModuleMetadata swMetadata = softwareManagement.createSoftwareModuleMetadata(entityFactory
.generateSoftwareModuleMetadata(entity, key, value));
protected SoftwareModuleMetadata createMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = softwareManagement
.createSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
setSelectedEntity(swMetadata.getSoftwareModule());
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.CREATE_SOFTWARE_MODULE_METADATA, swMetadata));
return swMetadata;
}
/**
* Update metadata for SWModule.
* Update metadata for SWModule.
*/
@Override
protected SoftwareModuleMetadata updateMetadata(SoftwareModule entity, String key, String value) {
SoftwareModuleMetadata swMetadata = softwareManagement.updateSoftwareModuleMetadata(entityFactory
.generateSoftwareModuleMetadata(entity, key, value));
protected SoftwareModuleMetadata updateMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = softwareManagement
.updateSoftwareModuleMetadata(entityFactory.generateSoftwareModuleMetadata(entity, key, value));
setSelectedEntity(swMetadata.getSoftwareModule());
return swMetadata;
}
@@ -80,25 +73,24 @@ public class SwMetadataPopupLayout extends AbstractMetadataPopupLayout<SoftwareM
protected List<SoftwareModuleMetadata> getMetadataList() {
return getSelectedEntity().getMetadata();
}
/**
* delete metadata for SWModule.
*/
@Override
protected void deleteMetadata(SoftwareModule entity, String key, String value) {
SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
protected void deleteMetadata(final SoftwareModule entity, final String key, final String value) {
final SoftwareModuleMetadata swMetadata = entityFactory.generateSoftwareModuleMetadata(entity, key, value);
softwareManagement.deleteSoftwareModuleMetadata(entity, key);
eventBus.publish(this, new MetadataEvent(MetadataUIEvent.DELETE_SOFTWARE_MODULE_METADATA, swMetadata));
}
@Override
protected boolean hasCreatePermission() {
return permChecker.hasCreateDistributionPermission();
}
@Override
protected boolean hasUpdatePermission() {
return permChecker.hasUpdateDistributionPermission();
}
}

View File

@@ -42,7 +42,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
/**
* Parametric Constructor.
*
*
* @param definition
* as Def
* @param queryConfig
@@ -55,7 +55,7 @@ public class SwModuleBeanQuery extends AbstractBeanQuery<ProxyBaseSwModuleItem>
public SwModuleBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
type = (SoftwareModuleType) queryConfig.get(SPUIDefinitions.BY_SOFTWARE_MODULE_TYPE);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(searchText)) {

View File

@@ -8,6 +8,11 @@
*/
package org.eclipse.hawkbit.ui.distributions.smtype;
import static org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE;
import static org.eclipse.hawkbit.ui.artifacts.event.SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE;
import static org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_NAME;
import java.util.HashMap;
import java.util.Map;
@@ -19,7 +24,6 @@ import org.eclipse.hawkbit.ui.distributions.event.SaveActionWindowEvent;
import org.eclipse.hawkbit.ui.distributions.state.ManageDistUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -35,10 +39,9 @@ import com.vaadin.spring.annotation.ViewScope;
/**
* Software Module Type filter buttons.
*
*/
@SpringComponent
@ViewScope
@SpringComponent
public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private static final long serialVersionUID = 6804534533362387433L;
@@ -51,7 +54,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected String getButtonsTableId() {
return SPUIComponentIdProvider.SW_MODULE_TYPE_TABLE_ID;
return SW_MODULE_TYPE_TABLE_ID;
}
@Override
@@ -60,7 +63,7 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
final BeanQueryFactory<SoftwareModuleTypeBeanQuery> typeQF = new BeanQueryFactory<>(
SoftwareModuleTypeBeanQuery.class);
typeQF.setQueryConfiguration(queryConfig);
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, SPUILabelDefinitions.VAR_NAME), typeQF);
return new LazyQueryContainer(new LazyQueryDefinition(true, 20, VAR_NAME), typeQF);
}
@Override
@@ -70,8 +73,8 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@Override
protected boolean isClickedByDefault(final String typeName) {
return manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent()
&& manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().get().getName().equals(typeName);
return manageDistUIState.getSoftwareModuleFilters().getSoftwareModuleType().isPresent() && manageDistUIState
.getSoftwareModuleFilters().getSoftwareModuleType().get().getName().equals(typeName);
}
@Override
@@ -104,13 +107,16 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SoftwareModuleTypeEvent event) {
if (event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.ADD_SOFTWARE_MODULE_TYPE
|| event.getSoftwareModuleTypeEnum() == SoftwareModuleTypeEvent.SoftwareModuleTypeEnum.UPDATE_SOFTWARE_MODULE_TYPE
&& event.getSoftwareModuleType() != null) {
if (isCreateOrUpdate(event) && event.getSoftwareModuleType() != null) {
refreshTypeTable();
}
}
private boolean isCreateOrUpdate(final SoftwareModuleTypeEvent event) {
return event.getSoftwareModuleTypeEnum() == ADD_SOFTWARE_MODULE_TYPE
|| event.getSoftwareModuleTypeEnum() == UPDATE_SOFTWARE_MODULE_TYPE;
}
@EventBusListenerMethod(scope = EventScope.SESSION)
void onEvent(final SaveActionWindowEvent event) {
if (event == SaveActionWindowEvent.SAVED_DELETE_SW_MODULE_TYPES) {
@@ -121,6 +127,4 @@ public class DistSMTypeFilterButtons extends AbstractFilterButtons {
private void refreshTypeTable() {
setContainerDataSource(createButtonsLazyQueryContainer());
}
}

View File

@@ -8,8 +8,9 @@
*/
package org.eclipse.hawkbit.ui.distributions.state;
import static java.util.Collections.emptySet;
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -49,7 +50,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
private DistributionSetIdName lastSelectedDistribution;
private Set<Long> selectedSoftwareModules = Collections.emptySet();
private Set<Long> selectedSoftwareModules = emptySet();
private Set<String> selectedDeleteDistSetTypes = new HashSet<>();
@@ -57,23 +58,23 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
private Long selectedBaseSwModuleId;
private boolean distTypeFilterClosed = Boolean.FALSE;
private boolean distTypeFilterClosed;
private boolean swTypeFilterClosed = Boolean.FALSE;
private boolean swTypeFilterClosed;
private final Map<Long, String> deleteSofwareModulesList = new HashMap<>();
private boolean swModuleTableMaximized = Boolean.FALSE;
private boolean swModuleTableMaximized;
private boolean dsTableMaximized = Boolean.FALSE;
private boolean dsTableMaximized;
private final Map<String, SoftwareModuleIdName> assignedSoftwareModuleDetails = new HashMap<>();
private final Map<DistributionSetIdName, HashMap<Long, HashSet<SoftwareModuleIdName>>> consolidatedDistSoftwarewList = new HashMap<>();
private boolean noDataAvilableSwModule = Boolean.FALSE;
private boolean noDataAvilableSwModule;
private boolean noDataAvailableDist = Boolean.FALSE;
private boolean noDataAvailableDist;
/**
* @return the manageDistFilters
@@ -117,6 +118,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
this.lastSelectedDistribution = value;
}
@Override
public void setSelectedEnitities(final Set<DistributionSetIdName> values) {
selectedDistributions = values;
}
@@ -223,7 +225,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
/***
* Set isDsModuleTableMaximized.
*
* @param isDsModuleTableMaximized
* @param dsModuleTableMaximized
*/
public void setDsTableMaximized(final boolean dsModuleTableMaximized) {
dsTableMaximized = dsModuleTableMaximized;
@@ -241,7 +243,7 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
}
/**
* @param isSwModuleTableMaximized
* @param swModuleTableMaximized
* the isSwModuleTableMaximized to set
*/
public void setSwModuleTableMaximized(final boolean swModuleTableMaximized) {
@@ -271,8 +273,8 @@ public class ManageDistUIState implements ManagmentEntityState<DistributionSetId
}
/**
* @param noDilableDist
* the noDataAvailableDist to set
* @param noDataAvailableDist
* the isNoDataAvailableDist to set
*/
public void setNoDataAvailableDist(final boolean noDataAvailableDist) {
this.noDataAvailableDist = noDataAvailableDist;

View File

@@ -18,6 +18,8 @@ import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.repository.TargetFilterQueryManagement;
import org.eclipse.hawkbit.repository.model.TargetFilterQuery;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -217,10 +219,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
breadcrumbButton = createBreadcrumbButton();
headerCaption = SPUIComponentProvider.getLabel(SPUILabelDefinitions.VAR_CREATE_FILTER,
SPUILabelDefinitions.SP_WIDGET_CAPTION);
headerCaption = new LabelBuilder().name(SPUILabelDefinitions.VAR_CREATE_FILTER).buildCaptionLabel();
nameLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
nameLabel = new LabelBuilder().name("").buildLabel();
nameLabel.setId(SPUIComponentIdProvider.TARGET_FILTER_QUERY_NAME_LABEL_ID);
nameTextField = createNameTextField();
@@ -249,10 +250,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
}
private TextField createNameTextField() {
final TextField nameField = SPUIComponentProvider.getTextField(i18n.get("textfield.customfiltername"), "",
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.customfiltername"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
nameField.setId(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME);
final TextField nameField = new TextFieldBuilder().caption(i18n.get("textfield.customfiltername"))
.prompt(i18n.get("textfield.customfiltername")).immediate(true)
.id(SPUIComponentIdProvider.CUSTOM_FILTER_ADD_NAME).buildTextComponent();
nameField.setPropertyDataSource(nameLabel);
nameField.addTextChangeListener(this::onFilterNameChange);
return nameField;
@@ -307,7 +307,7 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
breadcrumbLayout = new HorizontalLayout();
breadcrumbLayout.addComponent(breadcrumbButton);
breadcrumbLayout.addComponent(new Label(">"));
breadcrumbName = SPUIComponentProvider.getLabel(null, SPUILabelDefinitions.SP_WIDGET_CAPTION);
breadcrumbName = new LabelBuilder().buildCaptionLabel();
breadcrumbLayout.addComponent(breadcrumbName);
breadcrumbName.addStyleName("breadcrumbPaddingLeft");
@@ -450,10 +450,9 @@ public class CreateOrUpdateFilterHeader extends VerticalLayout implements Button
return button;
}
private TextField createSearchField() {
final TextField textField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, "",
"", true, SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
textField.setId("custom.query.text.Id");
private static TextField createSearchField() {
final TextField textField = new TextFieldBuilder().immediate(true).id("custom.query.text.Id")
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
textField.addStyleName("target-filter-textfield");
textField.setWidth(900.0F, Unit.PIXELS);
textField.setTextChangeEventMode(TextChangeEventMode.LAZY);

View File

@@ -19,7 +19,7 @@ import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.DistributionSet;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.AssignInstalledDSTooltipGenerator;
@@ -209,7 +209,7 @@ public class CreateOrUpdateFilterTable extends Table {
final Item row1 = getItem(itemId);
final TargetUpdateStatus targetStatus = (TargetUpdateStatus) row1
.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).getValue();
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label label = new LabelBuilder().name("").buildLabel();
label.setContentMode(ContentMode.HTML);
if (targetStatus == TargetUpdateStatus.PENDING) {
label.setDescription("Pending");

View File

@@ -8,6 +8,12 @@
*/
package org.eclipse.hawkbit.ui.filtermanagement;
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.FILTER_BY_QUERY;
import static org.springframework.data.domain.Sort.Direction.ASC;
import static org.springframework.data.domain.Sort.Direction.DESC;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -47,7 +53,7 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
/**
* Parametric Constructor.
*
*
* @param definition
* as Def
* @param queryConfig
@@ -61,38 +67,25 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
filterQuery = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_QUERY);
if (isNotNullOrEmpty(queryConfig)) {
filterQuery = (String) queryConfig.get(FILTER_BY_QUERY);
}
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort.
if (!isEmpty(sortStates)) {
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
}
}
}
/*
* (non-Javadoc)
*
* @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#constructBean()
*/
@Override
protected ProxyTarget constructBean() {
return new ProxyTarget();
}
/*
* (non-Javadoc)
*
* @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
* int)
*/
@Override
protected List<ProxyTarget> loadBeans(final int startIndex, final int count) {
Slice<Target> targetBeans;
@@ -131,23 +124,11 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
return proxyTargetBeans;
}
/*
* (non-Javadoc)
*
* @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
* .util.List, java.util.List, java.util.List)
*/
@Override
protected void saveBeans(final List<ProxyTarget> arg0, final List<ProxyTarget> arg1, final List<ProxyTarget> arg2) {
// CRUD operations on Target will be done through repository methods
}
/*
* (non-Javadoc)
*
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
*/
@Override
public int size() {
long size = 0;
@@ -184,5 +165,4 @@ public class CustomTargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
}
return i18N;
}
}

View File

@@ -44,7 +44,7 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
private transient TargetFilterQueryManagement targetFilterQueryManagement;
/**
*
*
* @param definition
* @param queryConfig
* @param sortPropertyIds
@@ -53,7 +53,7 @@ public class TargetFilterBeanQuery extends AbstractBeanQuery<ProxyTargetFilter>
public TargetFilterBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
if (!Strings.isNullOrEmpty(searchText)) {
searchText = String.format("%%%s%%", searchText);

View File

@@ -11,6 +11,8 @@ package org.eclipse.hawkbit.ui.filtermanagement;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -18,7 +20,6 @@ import org.eclipse.hawkbit.ui.filtermanagement.event.CustomFilterUIEvent;
import org.eclipse.hawkbit.ui.filtermanagement.state.FilterManagementUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -26,7 +27,6 @@ import org.vaadin.spring.events.EventBus;
import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.AbstractTextField.TextChangeEventMode;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.HorizontalLayout;
@@ -78,8 +78,7 @@ public class TargetFilterHeader extends VerticalLayout {
}
private Label createHeaderCaption() {
return SPUIComponentProvider.getLabel(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION,
SPUILabelDefinitions.SP_WIDGET_CAPTION);
return new LabelBuilder().name(SPUIDefinitions.TARGET_FILTER_LIST_HEADER_CAPTION).buildCaptionLabel();
}
private void buildLayout() {
@@ -121,14 +120,9 @@ public class TargetFilterHeader extends VerticalLayout {
}
private TextField createSearchField() {
final TextField campSearchTextField = SPUIComponentProvider.getTextField(null, "filter-box",
"text-style filter-box-hide", false, "", "", false, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
campSearchTextField.setId("target.filter.search.text.Id");
campSearchTextField.setWidth(500.0f, Unit.PIXELS);
campSearchTextField.addTextChangeListener(event -> searchBy(event.getText()));
campSearchTextField.setTextChangeEventMode(TextChangeEventMode.LAZY);
// 1 seconds timeout.
campSearchTextField.setTextChangeTimeout(1000);
final TextField campSearchTextField = new TextFieldBuilder("target.filter.search.text.Id")
.createSearchField(event -> searchBy(event.getText()));
campSearchTextField.setWidth(500.0F, Unit.PIXELS);
return campSearchTextField;
}
@@ -156,7 +150,6 @@ public class TargetFilterHeader extends VerticalLayout {
}
private void openSearchTextField() {
//
searchResetIcon.addStyleName(SPUIDefinitions.FILTER_RESET_ICON);
searchResetIcon.togleIcon(FontAwesome.TIMES);
searchResetIcon.setData(Boolean.TRUE);

View File

@@ -21,13 +21,15 @@ import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerLayout;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -113,10 +115,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
/**
* Discard the changes and close the popup.
*
* @param event
*/
protected void discard(final Button.ClickEvent event) {
protected void discard() {
UI.getCurrent().removeWindow(window);
}
@@ -148,20 +148,20 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
createTagStr = i18n.get("label.create.tag");
updateTagStr = i18n.get("label.update.tag");
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag"), null);
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.tag.color"), null);
comboLabel = new LabelBuilder().name(i18n.get("label.choose.tag")).buildLabel();
colorLabel = new LabelBuilder().name(i18n.get("label.choose.tag.color")).buildLabel();
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
tagName = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME, true, "", i18n.get("textfield.name"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
tagName.setId(SPUIDefinitions.NEW_TARGET_TAG_NAME);
tagName = new TextFieldBuilder().caption(i18n.get("textfield.name"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true)
.prompt(i18n.get("textfield.name")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_NAME)
.buildTextComponent();
tagDesc = new TextAreaBuilder().caption(i18n.get("textfield.description"))
.styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC)
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIDefinitions.NEW_TARGET_TAG_DESC)
.buildTextComponent();
tagDesc = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "",
ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC, false, "", i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
tagDesc.setId(SPUIDefinitions.NEW_TARGET_TAG_DESC);
tagDesc.setImmediate(true);
tagDesc.setNullRepresentation("");
tagNameComboBox = SPUIComponentProvider.getComboBox(null, "", "", null, null, false, "",
@@ -461,8 +461,8 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
public CommonDialogWindow getWindow() {
reset();
window = SPUIWindowDecorator.getWindow(getWindowCaption(), null, SPUIDefinitions.CREATE_UPDATE_WINDOW, this,
this::discard, null, mainLayout, i18n);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(getWindowCaption()).content(this)
.cancelButtonClickListener(event -> discard()).layout(mainLayout).i18n(i18n).buildCommonDialogWindow();
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@@ -475,7 +475,6 @@ public abstract class AbstractCreateUpdateTagLayout<E extends NamedEntity> exten
} else {
updateEntity(findEntityByName());
}
}
@Override

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.layouts;
import org.eclipse.hawkbit.repository.model.NamedEntity;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerConstants;
import org.eclipse.hawkbit.ui.colorpicker.ColorPickerHelper;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
@@ -51,8 +52,8 @@ public abstract class CreateUpdateTypeLayout<E extends NamedEntity> extends Abst
createTagStr = i18n.get("label.create.type");
updateTagStr = i18n.get("label.update.type");
comboLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type"), null);
colorLabel = SPUIComponentProvider.getLabel(i18n.get("label.choose.type.color"), null);
comboLabel = new LabelBuilder().name(i18n.get("label.choose.type")).buildLabel();
colorLabel = new LabelBuilder().name(i18n.get("label.choose.type.color")).buildLabel();
colorLabel.addStyleName(SPUIDefinitions.COLOR_LABEL_STYLE);
tagNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, null, false,

View File

@@ -10,6 +10,7 @@ package org.eclipse.hawkbit.ui.management.actionhistory;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIButton;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -17,7 +18,6 @@ import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -63,8 +63,9 @@ public class ActionHistoryHeader extends VerticalLayout {
private void buildComponent() {
// create default title - it will be shown even when no data is
// available
titleOfActionHistory = SPUIComponentProvider.getLabel(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""),
SPUILabelDefinitions.SP_WIDGET_CAPTION);
titleOfActionHistory = new LabelBuilder().name(HawkbitCommonUtil.getArtifactoryDetailsLabelId(""))
.buildCaptionLabel();
titleOfActionHistory.setImmediate(true);
titleOfActionHistory.setContentMode(ContentMode.HTML);

View File

@@ -25,6 +25,7 @@ import org.eclipse.hawkbit.repository.model.ActionStatus;
import org.eclipse.hawkbit.repository.model.ActionWithStatusCount;
import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.ui.common.ConfirmationDialog;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -36,7 +37,6 @@ import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPDateTimeUtil;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.UINotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -357,7 +357,7 @@ public class ActionHistoryTable extends TreeTable {
private Component getForcedColumn(final Object itemId) {
final Action actionWithActiveStatus = (Action) hierarchicalContainer.getItem(itemId)
.getItemProperty(SPUIDefinitions.ACTION_HIS_TBL_FORCED).getValue();
final Label actionLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label actionLabel = new LabelBuilder().name("").buildCaptionLabel();
actionLabel.setContentMode(ContentMode.HTML);
actionLabel.setStyleName("action-history-table-col-forced-label");
if (actionWithActiveStatus != null && actionWithActiveStatus.getActionType() == ActionType.FORCED) {
@@ -522,7 +522,7 @@ public class ActionHistoryTable extends TreeTable {
* @return Label as UI
*/
private Label getStatusIcon(final Action.Status status) {
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label label = new LabelBuilder().name("").buildLabel();
final String statusIconPending = "statusIconPending";
label.setContentMode(ContentMode.HTML);
if (Action.Status.FINISHED == status) {
@@ -576,13 +576,11 @@ public class ActionHistoryTable extends TreeTable {
final long currentTimeMillis = System.currentTimeMillis();
final HorizontalLayout hLayout = new HorizontalLayout();
final Label autoForceLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label autoForceLabel = new LabelBuilder().name("").id("action.history.table.timedforceId").buildLabel();
actionLabel.setValue(FontAwesome.BOLT.getHtml());
autoForceLabel.setContentMode(ContentMode.HTML);
autoForceLabel.setValue(FontAwesome.HISTORY.getHtml());
// setted Id for TimedForced.
autoForceLabel.setId("action.history.table.timedforceId");
hLayout.addComponent(actionLabel);
hLayout.addComponent(autoForceLabel);
@@ -608,8 +606,8 @@ public class ActionHistoryTable extends TreeTable {
* as String
* @return Labeal as UI
*/
private Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) {
final Label label = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
private static Label createActiveStatusLabel(final String activeValue, final boolean endedWithError) {
final Label label = new LabelBuilder().name("").buildLabel();
label.setContentMode(ContentMode.HTML);
if (SPUIDefinitions.SCHEDULED.equals(activeValue)) {
label.setDescription("Scheduled");

View File

@@ -26,9 +26,11 @@ import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.DistributionSetTypeBeanQuery;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.distributions.dstable.DistributionSetTable;
import org.eclipse.hawkbit.ui.management.event.DistributionTableEvent;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
@@ -126,16 +128,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
* Create required UI components.
*/
private void createRequiredComponents() {
distNameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
true, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distNameTextField.setId(SPUIComponentIdProvider.DIST_ADD_NAME);
distNameTextField.setNullRepresentation("");
distVersionTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.version"), "",
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("textfield.version"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
distVersionTextField.setId(SPUIComponentIdProvider.DIST_ADD_VERSION);
distVersionTextField.setNullRepresentation("");
distNameTextField = createTextField("textfield.name", SPUIComponentIdProvider.DIST_ADD_NAME);
distVersionTextField = createTextField("textfield.version", SPUIComponentIdProvider.DIST_ADD_VERSION);
distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.get("label.combobox.type"), "", "", null, "",
false, "", i18n.get("label.combobox.type"));
@@ -144,10 +138,9 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
distsetTypeNameComboBox.setId(SPUIComponentIdProvider.DIST_ADD_DISTSETTYPE);
populateDistSetTypeNameCombo();
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponentIdProvider.DIST_ADD_DESC);
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIComponentIdProvider.DIST_ADD_DESC)
.buildTextComponent();
descTextArea.setNullRepresentation("");
reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.get("checkbox.dist.required.migration.step"),
@@ -156,6 +149,13 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
reqMigStepCheckbox.setId(SPUIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
}
private TextField createTextField(final String in18Key, final String id) {
final TextField buildTextField = new TextFieldBuilder().caption(i18n.get(in18Key)).required(true)
.prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
buildTextField.setNullRepresentation("");
return buildTextField;
}
/**
* Get the LazyQueryContainer instance for DistributionSetTypes.
*
@@ -335,8 +335,8 @@ public class DistributionAddUpdateWindowLayout extends CustomComponent {
resetComponents();
populateDistSetTypeNameCombo();
populateValuesOfDistribution(editDistId);
window = SPUIWindowDecorator.getWindow(i18n.get("caption.add.new.dist"), null,
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.dist"))
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {

View File

@@ -65,7 +65,7 @@ public class DistributionBeanQuery extends AbstractBeanQuery<ProxyDistribution>
final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (HawkbitCommonUtil.isNotNullOrEmpty(queryConfig)) {
distributionTags = (Collection<String>) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
searchText = (String) queryConfig.get(SPUIDefinitions.FILTER_BY_TEXT);
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);

View File

@@ -120,12 +120,10 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
/**
* RESET.
*
* @param event
*/
@Override
public void discard(final ClickEvent event) {
super.discard(event);
public void discard() {
super.discard();
resetDistTagValues();
}
@@ -146,7 +144,7 @@ public class CreateUpdateDistributionTagLayoutWindow extends AbstractCreateUpdat
/**
* Select tag & set tag name & tag desc values corresponding to selected
* tag.
*
*
* @param distTagSelected
* as the selected tag from combo
*/

View File

@@ -121,7 +121,7 @@ public class DistributionTagButtons extends AbstractFilterButtons {
}
@Override
protected boolean isNoTagSateSelected() {
protected boolean isNoTagStateSelected() {
return managementUIState.getDistributionTableFilters().isNoTagSelected();
}

View File

@@ -34,6 +34,7 @@ import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
import org.vaadin.spring.events.annotation.EventBusListenerMethod;
import com.google.common.base.Strings;
import com.vaadin.server.FontAwesome;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.spring.annotation.SpringComponent;
@@ -43,7 +44,7 @@ import com.vaadin.ui.Label;
/**
* Count message label which display current filter details and details on
* pinning.
*
*
*
*/
@SpringComponent
@@ -82,7 +83,7 @@ public class CountMessageLabel extends Label {
/**
* Event Listener to show the message count.
*
*
* @param event
*/
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -104,7 +105,7 @@ public class CountMessageLabel extends Label {
/**
* Event Listener for Pinning Distribution.
*
*
* @param event
*/
@EventBusListenerMethod(scope = EventScope.SESSION)
@@ -119,7 +120,7 @@ public class CountMessageLabel extends Label {
}
/**
*
*
*/
private void applyStyle() {
/* Create label for Targets count message displaying below the table */
@@ -220,7 +221,7 @@ public class CountMessageLabel extends Label {
/**
* Get Status Message.
*
*
* @param status
* as status
* @return String as msg.
@@ -231,7 +232,7 @@ public class CountMessageLabel extends Label {
/**
* Get Tags Message.
*
*
* @param noTargetTagSelected
* @param tags
* as tags
@@ -244,18 +245,18 @@ public class CountMessageLabel extends Label {
/**
* Get Search Text Message.
*
*
* @param searchTxt
* as search text
* @return String as msg.
*/
private static String getSerachMsg(final String searchTxt, final String param) {
return HawkbitCommonUtil.checkValidString(searchTxt) ? param : HawkbitCommonUtil.SP_STRING_SPACE;
return Strings.isNullOrEmpty(searchTxt) ? HawkbitCommonUtil.SP_STRING_SPACE : param;
}
/**
* Get Dist set Message.
*
*
* @param distId
* as serach
* @return String as msg.
@@ -266,7 +267,7 @@ public class CountMessageLabel extends Label {
/**
* Get the custom target filter message.
*
*
* @param targetFilterQuery
* @param param
* @return

View File

@@ -390,22 +390,22 @@ public class BulkUploadHandler extends CustomComponent
eventBus.publish(this, new BulkUploadValidationMessageEvent(errorMessage.toString()));
}
}
}
private void addNewTarget(final String controllerId, final String name) {
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) {
final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(name);
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
private void addNewTarget(final String controllerId, final String name) {
final String newControllerId = HawkbitCommonUtil.trimAndNullIfEmpty(controllerId);
if (mandatoryCheck(newControllerId) && duplicateCheck(newControllerId)) {
final String newName = HawkbitCommonUtil.trimAndNullIfEmpty(name);
final String newDesc = HawkbitCommonUtil.trimAndNullIfEmpty(descTextArea.getValue());
/* create new target entity */
final Target newTarget = entityFactory.generateTarget(newControllerId);
setTargetValues(newTarget, newName, newDesc);
targetManagement.createTarget(newTarget);
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId);
successfullTargetCount++;
}
/* create new target entity */
final Target newTarget = entityFactory.generateTarget(newControllerId);
setTargetValues(newTarget, newName, newDesc);
targetManagement.createTarget(newTarget);
managementUIState.getTargetTableFilters().getBulkUpload().getTargetsCreated().add(newControllerId);
successfullTargetCount++;
}
}
private static void setTargetValues(final Target target, final String name, final String description) {

View File

@@ -17,16 +17,16 @@ import org.eclipse.hawkbit.repository.model.Target;
import org.eclipse.hawkbit.repository.model.TargetIdName;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.common.table.BaseEntityEventType;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.management.event.DragEvent;
import org.eclipse.hawkbit.ui.management.event.TargetTableEvent;
import org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIStyleDefinitions;
import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.eclipse.hawkbit.ui.utils.UINotification;
@@ -39,8 +39,8 @@ import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.TextArea;
import com.vaadin.ui.TextField;
import com.vaadin.ui.UI;
import com.vaadin.ui.Window;
import com.vaadin.ui.themes.ValoTheme;
/**
* Add and Update Target.
@@ -83,30 +83,22 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
}
private void createRequiredComponents() {
/* Textfield for controller Id */
controllerIDTextField = SPUIComponentProvider.getTextField(i18n.get("prompt.target.id"), "",
ValoTheme.TEXTFIELD_TINY, true, null, i18n.get("prompt.target.id"), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
controllerIDTextField.setId(SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
/* Textfield for target name */
nameTextField = SPUIComponentProvider.getTextField(i18n.get("textfield.name"), "", ValoTheme.TEXTFIELD_TINY,
false, null, i18n.get("textfield.name"), true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
nameTextField.setId(SPUIComponentIdProvider.TARGET_ADD_NAME);
controllerIDTextField = createTextField("prompt.target.id", SPUIComponentIdProvider.TARGET_ADD_CONTROLLER_ID);
nameTextField = createTextField("textfield.name", SPUIComponentIdProvider.TARGET_ADD_NAME);
nameTextField.setRequired(false);
/* Textarea for target description */
descTextArea = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"), "text-area-style",
ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descTextArea.setId(SPUIComponentIdProvider.TARGET_ADD_DESC);
descTextArea = new TextAreaBuilder().caption(i18n.get("textfield.description")).style("text-area-style")
.prompt(i18n.get("textfield.description")).immediate(true).id(SPUIComponentIdProvider.TARGET_ADD_DESC)
.buildTextComponent();
descTextArea.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
}
private void buildLayout() {
private TextField createTextField(final String in18Key, final String id) {
return new TextFieldBuilder().caption(i18n.get(in18Key)).required(true).prompt(i18n.get(in18Key))
.immediate(true).id(id).buildTextComponent();
}
/*
* The main layout of the window contains mandatory info, textboxes
* (controller Id, name & description) and action buttons layout
*/
private void buildLayout() {
setSizeUndefined();
formLayout = new FormLayout();
formLayout.addComponent(controllerIDTextField);
@@ -160,8 +152,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
public Window getWindow() {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);
window = SPUIWindowDecorator.getWindow(i18n.get("caption.add.new.target"), null,
SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null, null, formLayout, i18n);
window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.get("caption.add.new.target"))
.content(this).layout(formLayout).i18n(i18n).buildCommonDialogWindow();
window.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@Override
@@ -169,9 +161,8 @@ public class TargetAddUpdateWindowLayout extends CustomComponent {
if (editTarget) {
updateTarget();
} else {
addNewTarget();
UI.getCurrent().access(() -> addNewTarget());
}
}
@Override

View File

@@ -8,6 +8,12 @@
*/
package org.eclipse.hawkbit.ui.management.targettable;
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.isNotNullOrEmpty;
import static org.eclipse.hawkbit.ui.utils.SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER;
import static org.springframework.data.domain.Sort.Direction.ASC;
import static org.springframework.data.domain.Sort.Direction.DESC;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -30,7 +36,6 @@ import org.eclipse.hawkbit.ui.utils.SpringContextHelper;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Slice;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
@@ -39,11 +44,12 @@ import com.google.common.base.Strings;
/**
* Simple implementation of generics bean query which dynamically loads a batch
* of beans.
*
*/
public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
private static final long serialVersionUID = -5645680058303167558L;
private Sort sort = new Sort(SPUIDefinitions.TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
private Sort sort = new Sort(TARGET_TABLE_CREATE_AT_SORT_ORDER, "createdAt");
private transient Collection<TargetUpdateStatus> status = null;
private String[] targetTags = null;
private Long distributionId = null;
@@ -57,7 +63,7 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
/**
* Parametric Constructor.
*
*
* @param definition
* as Def
* @param queryConfig
@@ -69,9 +75,10 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
*/
public TargetBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortIds, final boolean[] sortStates) {
super(definition, queryConfig, sortIds, sortStates);
if (HawkbitCommonUtil.mapCheckStrKey(queryConfig)) {
if (isNotNullOrEmpty(queryConfig)) {
status = (Collection<TargetUpdateStatus>) queryConfig.get(SPUIDefinitions.FILTER_BY_STATUS);
targetTags = (String[]) queryConfig.get(SPUIDefinitions.FILTER_BY_TAG);
noTagClicked = (Boolean) queryConfig.get(SPUIDefinitions.FILTER_BY_NO_TAG);
@@ -84,12 +91,12 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
pinnedDistId = (Long) queryConfig.get(SPUIDefinitions.ORDER_BY_DISTRIBUTION);
}
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort.
if (!isEmpty(sortStates)) {
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortIds[0]);
for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortIds[targetId]));
}
}
}
@@ -220,5 +227,4 @@ public class TargetBeanQuery extends AbstractBeanQuery<ProxyTarget> {
}
return i18N;
}
}

View File

@@ -19,6 +19,8 @@ import org.eclipse.hawkbit.repository.DeploymentManagement;
import org.eclipse.hawkbit.repository.TargetManagement;
import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
import org.eclipse.hawkbit.ui.management.dstable.DistributionBeanQuery;
@@ -192,10 +194,9 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
}
private TextArea getDescriptionTextArea() {
final TextArea description = SPUIComponentProvider.getTextArea(i18n.get("textfield.description"),
"text-area-style", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
description.setId(SPUIComponentIdProvider.BULK_UPLOAD_DESC);
final TextArea description = new TextAreaBuilder().caption(i18n.get("textfield.description"))
.style("text-area-style").prompt(i18n.get("textfield.description")).immediate(true)
.id(SPUIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent();
description.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
description.setWidth("100%");
return description;
@@ -358,10 +359,11 @@ public class TargetBulkUpdateWindowLayout extends CustomComponent {
*/
public Window getWindow() {
managementUIState.setBulkUploadWindowMinimised(false);
bulkUploadWindow = SPUIComponentProvider.getWindow("", null, SPUIDefinitions.CREATE_UPDATE_WINDOW);
bulkUploadWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption("").content(this)
.buildWindow();
bulkUploadWindow.addStyleName("bulk-upload-window");
bulkUploadWindow.setImmediate(true);
bulkUploadWindow.setContent(this);
if (isNoBulkUploadInProgress()) {
bulkUploader.getUpload().setEnabled(true);
}

View File

@@ -8,6 +8,15 @@
*/
package org.eclipse.hawkbit.ui.management.targettable;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_DISTRIBUTION;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TAG;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.FILTER_BY_TEXT;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TAG;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
import static org.eclipse.hawkbit.ui.management.event.TargetFilterEvent.REMOVE_FILTER_BY_TEXT;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -143,7 +152,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
onTargetInfoUpdateEvents((List<TargetInfoUpdateEvent>) events);
} else if (TargetDeletedEvent.class.isInstance(firstEvent)) {
onTargetDeletedEvent((List<TargetDeletedEvent>) events);
} else if(TargetUpdatedEvent.class.isInstance(firstEvent)){
} else if (TargetUpdatedEvent.class.isInstance(firstEvent)) {
onTargetUpdateEvents((List<TargetUpdatedEvent>) events);
}
}
@@ -239,12 +248,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return targetTableContainer;
}
/*
* (non-Javadoc)
*
* @see hawkbit.server.ui.common.table.AbstractTable#addContainerProperties
* (com.vaadin.data.Container )
*/
@Override
protected void addContainerProperties(final Container container) {
HawkbitCommonUtil.addTargetTableContainerProperties(container);
@@ -266,10 +269,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
@Override
protected Object getItemIdToSelect() {
if (managementUIState.getSelectedTargetIdName().isPresent()) {
return managementUIState.getSelectedTargetIdName().get();
}
return null;
return managementUIState.getSelectedTargetIdName().orElse(null);
}
@Override
@@ -306,7 +306,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
columnList.add(new TableColumn(SPUIDefinitions.TARGET_STATUS_PIN_TOGGLE_ICON, "", 0.0F));
}
return columnList;
}
@Override
@@ -440,14 +439,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
private boolean isPinned(final String targetId) {
boolean result;
if (managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get())) {
result = true;
} else {
result = false;
}
return result;
return managementUIState.getDistributionTableFilters().getPinnedTargetId().isPresent()
&& targetId.equals(managementUIState.getDistributionTableFilters().getPinnedTargetId().get());
}
/**
@@ -464,7 +457,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
} else {
unPinTarget(event.getButton());
}
}
/**
@@ -519,9 +511,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
/**
* Set style of target table.
*
*/
@SuppressWarnings("serial")
private void styleTargetTable() {
setCellStyleGenerator((source, itemId, propertyId) -> null);
}
@@ -533,7 +523,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
&& isNoTagAssigned(event)) {
tagAssignment(event);
}
}
private Boolean isNoTagAssigned(final DragAndDropEvent event) {
@@ -730,24 +719,22 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
private static boolean checkFilterEvent(final TargetFilterEvent filterEvent) {
boolean isFilterEvent;
boolean isFilter;
boolean isRemoveFilters;
boolean isStatusFilter;
isFilter = filterEvent == TargetFilterEvent.FILTER_BY_TEXT || filterEvent == TargetFilterEvent.FILTER_BY_TAG
|| filterEvent == TargetFilterEvent.FILTER_BY_DISTRIBUTION
|| filterEvent == TargetFilterEvent.FILTER_BY_TARGET_FILTER_QUERY;
return isNormalFilter(filterEvent) || isRemoveFilterEvent(filterEvent) || isStatusFilterEvent(filterEvent);
}
isRemoveFilters = filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TEXT
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TAG
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_DISTRIBUTION
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
isStatusFilter = filterEvent == TargetFilterEvent.FILTER_BY_STATUS
private static boolean isStatusFilterEvent(final TargetFilterEvent filterEvent) {
return filterEvent == TargetFilterEvent.FILTER_BY_STATUS
|| filterEvent == TargetFilterEvent.REMOVE_FILTER_BY_STATUS;
}
isFilterEvent = isFilter || isRemoveFilters || isStatusFilter;
private static boolean isRemoveFilterEvent(final TargetFilterEvent filterEvent) {
return filterEvent == REMOVE_FILTER_BY_TEXT || filterEvent == REMOVE_FILTER_BY_TAG
|| filterEvent == REMOVE_FILTER_BY_DISTRIBUTION || filterEvent == REMOVE_FILTER_BY_TARGET_FILTER_QUERY;
}
return isFilterEvent;
private static boolean isNormalFilter(final TargetFilterEvent filterEvent) {
return filterEvent == FILTER_BY_TEXT || filterEvent == FILTER_BY_TAG || filterEvent == FILTER_BY_DISTRIBUTION
|| filterEvent == FILTER_BY_TARGET_FILTER_QUERY;
}
private String getTargetTableStyle(final Long assignedDistributionSetId, final Long installedDistributionSetId) {
@@ -760,14 +747,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return SPUIDefinitions.HIGHTLIGHT_ORANGE;
}
return null;
}
/**
* @param itemId
* @param propertyId
* @return
*/
private String createTargetTableStyle(final Object itemId, final Object propertyId) {
if (null == propertyId) {
final Item item = getItem(itemId);
@@ -778,7 +759,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
return getTargetTableStyle(assignedDistributionSetId, installedDistributionSetId);
}
return null;
}
private void styleTargetTableOnPinning() {
@@ -803,12 +783,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
});
}
/**
* To add new target to the table on Top.
*
* @param newTarget
* as reference
*/
private void refreshTargets() {
final LazyQueryContainer targetContainer = (LazyQueryContainer) getContainerDataSource();
final int size = targetContainer.size();
@@ -834,8 +808,8 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
final Item item = targetContainer.getItem(targetIdName);
item.getItemProperty(SPUILabelDefinitions.VAR_NAME).setValue(target.getName());
if (targetInfo != null) {
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP).setValue(
HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
item.getItemProperty(SPUILabelDefinitions.VAR_POLL_STATUS_TOOL_TIP)
.setValue(HawkbitCommonUtil.getPollStatusToolTip(targetInfo.getPollStatus(), i18n));
item.getItemProperty(SPUILabelDefinitions.VAR_TARGET_STATUS).setValue(targetInfo.getUpdateStatus());
}
}
@@ -869,9 +843,7 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
}
// workaround until push is available for action history, re-select
// the
// updated target so
// the action history gets refreshed.
// the updated target so the action history gets refreshed.
if (isLastSelectedTarget(targetIdName)) {
lastSelectedTarget = target;
}
@@ -884,13 +856,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
}
private void onTargetUpdateEvents(List<TargetUpdatedEvent> events) {
private void onTargetUpdateEvents(final List<TargetUpdatedEvent> events) {
final List<Object> visibleItemIds = (List<Object>) getVisibleItemIds();
boolean shoulTargetsUpdated = false;
Target lastSelectedTarget = null;
for (final TargetUpdatedEvent targetUpdatedEvent : events) {
Target target = targetUpdatedEvent.getEntity();
final Target target = targetUpdatedEvent.getEntity();
final TargetIdName targetIdName = target.getTargetIdName();
if (Filters.or(getTargetTableFilters(target)).doFilter()) {
shoulTargetsUpdated = true;
@@ -911,8 +882,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
}
}
private void onTargetCreatedEvents() {
refreshTargets();
}
@@ -935,7 +904,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
*/
@Override
public void selectAll() {
// As Vaadin Table only returns the current ItemIds which are visible
// you don't need to search explicit for them.
setValue(getItemIds());
@@ -957,7 +925,6 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
* Set total target count and count of targets truncated in target table.
*/
private void resetTargetCountDetails() {
final long size;
final long totalTargetsCount = getTotalTargetsCount();
managementUIState.setTargetsCountAll(totalTargetsCount);
@@ -965,11 +932,10 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
String[] targetTags = null;
Long distributionId = null;
String searchText = null;
Boolean noTagClicked;
Long pinnedDistId = null;
if (isFilteredByTags()) {
targetTags = (String[]) managementUIState.getTargetTableFilters().getClickedTargetTags().toArray();
targetTags = managementUIState.getTargetTableFilters().getClickedTargetTags().toArray(new String[0]);
}
if (isFilteredByStatus()) {
status = managementUIState.getTargetTableFilters().getClickedStatusTargetTags();
@@ -980,12 +946,12 @@ public class TargetTable extends AbstractTable<Target, TargetIdName> {
if (isFilteredByText()) {
searchText = String.format("%%%s%%", managementUIState.getTargetTableFilters().getSearchText().get());
}
noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
final boolean noTagClicked = managementUIState.getTargetTableFilters().isNoTagSelected();
if (managementUIState.getTargetTableFilters().getPinnedDistId().isPresent()) {
pinnedDistId = managementUIState.getTargetTableFilters().getPinnedDistId().get();
}
size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
final long size = getTargetsCountWithFilter(totalTargetsCount, status, targetTags, distributionId, searchText,
noTagClicked, pinnedDistId);
if (size > SPUIDefinitions.MAX_TABLE_ENTRIES) {

View File

@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.management.event.ManagementUIEvent;
@@ -20,7 +21,6 @@ import org.eclipse.hawkbit.ui.management.state.ManagementUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIButtonDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -84,8 +84,8 @@ public class FilterByStatusLayout extends VerticalLayout implements Button.Click
addStyleName("target-status-filters");
setMargin(false);
final Label targetFilterStatusLabel = SPUIComponentProvider.getLabel(i18n.get("label.filter.by.status"),
SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label targetFilterStatusLabel = new LabelBuilder().name(i18n.get("label.filter.by.status")).buildLabel();
targetFilterStatusLabel.addStyleName("target-status-filters-title");
addComponent(targetFilterStatusLabel);

View File

@@ -131,7 +131,7 @@ public class TargetTagFilterButtons extends AbstractFilterButtons {
}
@Override
protected boolean isNoTagSateSelected() {
protected boolean isNoTagStateSelected() {
return managementUIState.getTargetTableFilters().isNoTagSelected();
}

View File

@@ -37,6 +37,7 @@ import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.UIScope;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.Component;
import com.vaadin.ui.CustomComponent;
@@ -52,14 +53,11 @@ import com.vaadin.ui.themes.ValoTheme;
* A responsive menu component providing user information and the controls for
* primary navigation between the views.
*/
@SpringComponent
@UIScope
@SpringComponent
public final class DashboardMenu extends CustomComponent {
private static final String STYLE_VISIBLE = "valo-menu-visible";
public static final String ID = "dashboard-menu";
public static final String REPORTS_BADGE_ID = "dashboard-menu-reports-badge";
public static final String NOTIFICATIONS_BADGE_ID = "dashboard-menu-notifications-badge";
private static final String ID = "dashboard-menu";
@Autowired
private I18N i18n;
@@ -208,13 +206,7 @@ public final class DashboardMenu extends CustomComponent {
}
private Component buildToggleButton() {
final Button valoMenuToggleButton = new Button("Menu", (ClickListener) event -> {
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
} else {
getCompositionRoot().addStyleName(STYLE_VISIBLE);
}
});
final Button valoMenuToggleButton = new Button("Menu", new MenuToggleClickListenerMyClickListener());
valoMenuToggleButton.setIcon(FontAwesome.LIST);
valoMenuToggleButton.addStyleName("valo-menu-toggle");
valoMenuToggleButton.addStyleName(ValoTheme.BUTTON_BORDERLESS);
@@ -244,7 +236,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* Returns all views which are currently accessible by the current logged in
* user.
*
*
* @return a list of all views which are currently visible and accessible
* for the current logged in user
*/
@@ -264,7 +256,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* Returns the view name for the start page after login.
*
*
* @return the initialViewName of the start page
*/
public String getInitialViewName() {
@@ -273,7 +265,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* Is a View available.
*
*
* @return the accessibleViewsEmpty <true> no rights for any view <false> a
* view is available
*/
@@ -284,7 +276,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* notifies the dashboard that the view has been changed and the button
* needs to be re-styled.
*
*
* @param event
* the post view change event
*/
@@ -294,7 +286,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* Returns the dashboard view type by a given view name.
*
*
* @param viewName
* the name of the view to retrieve
* @return the dashboard view for a given viewname or {@code null} if view
@@ -313,7 +305,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* Is the given view accessible.
*
*
* @param viewName
* the view name
* @return <true> = denied, <false> = accessible
@@ -329,15 +321,28 @@ public final class DashboardMenu extends CustomComponent {
return accessDeined;
}
private class MenuToggleClickListenerMyClickListener implements ClickListener {
private static final long serialVersionUID = 1L;
private static final String STYLE_VISIBLE = "valo-menu-visible";
@Override
public void buttonClick(final ClickEvent event) {
if (getCompositionRoot().getStyleName().contains(STYLE_VISIBLE)) {
getCompositionRoot().removeStyleName(STYLE_VISIBLE);
} else {
getCompositionRoot().addStyleName(STYLE_VISIBLE);
}
}
}
/**
* An menu item button wrapper for the dashboard menu item.
*
*
*
*
*/
public static final class ValoMenuItemButton extends Button {
private static final long serialVersionUID = 1L;
private static final String STYLE_SELECTED = "selected";
private final DashboardMenuItem view;
@@ -345,7 +350,7 @@ public final class DashboardMenu extends CustomComponent {
/**
* creates a new button in case of pressed switches to the given
* {@code view}.
*
*
* @param view
* the view to switch to in case the button is pressed
*/
@@ -358,12 +363,11 @@ public final class DashboardMenu extends CustomComponent {
/* Avoid double click */
setDisableOnClick(true);
addClickListener(event -> event.getComponent().getUI().getNavigator().navigateTo(view.getViewName()));
}
/**
* notifies the button to change his style.
*
*
* @param event
* the post view change event
*/

View File

@@ -20,6 +20,7 @@ import org.vaadin.alump.distributionbar.gwt.client.GwtDistributionBar;
*
*/
public final class DistributionBarHelper {
private static final String HTML_DIV_END = "</div>";
private static final int PARENT_SIZE_IN_PCT = 100;
private static final double MINIMUM_PART_SIZE = 10;
private static final String DISTRIBUTION_BAR_PART_MAIN_STYLE = GwtDistributionBar.CLASSNAME + "-part";
@@ -38,23 +39,23 @@ public final class DistributionBarHelper {
*
* @return string of format "status1:count,status2:count"
*/
public static String getDistributionBarAsHTMLString(Map<Status, Long> statusTotalCountMap) {
StringBuilder htmlString = new StringBuilder();
Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
Long totalValue = getTotalSizes(statusTotalCountMap);
public static String getDistributionBarAsHTMLString(final Map<Status, Long> statusTotalCountMap) {
final StringBuilder htmlString = new StringBuilder();
final Map<Status, Long> statusMapWithNonZeroValues = getStatusMapWithNonZeroValues(statusTotalCountMap);
final Long totalValue = getTotalSizes(statusTotalCountMap);
if (statusMapWithNonZeroValues.size() <= 0) {
return getUnintialisedBar();
}
int partIndex = 1;
htmlString.append(getParentDivStart());
for (Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
for (final Map.Entry<Status, Long> entry : statusMapWithNonZeroValues.entrySet()) {
if (entry.getValue() > 0) {
htmlString.append(getPart(partIndex, entry.getKey(), entry.getValue(), totalValue,
statusMapWithNonZeroValues.size()));
partIndex++;
}
}
htmlString.append(getParentDivEnd());
htmlString.append(HTML_DIV_END);
return htmlString.toString();
}
@@ -65,7 +66,7 @@ public final class DistributionBarHelper {
* map with status and count
* @return map with non zero values
*/
public static Map<Status, Long> getStatusMapWithNonZeroValues(Map<Status, Long> statusTotalCountMap) {
public static Map<Status, Long> getStatusMapWithNonZeroValues(final Map<Status, Long> statusTotalCountMap) {
return statusTotalCountMap.entrySet().stream().filter(p -> p.getValue() > 0)
.collect(Collectors.toMap(p -> p.getKey(), p -> p.getValue()));
}
@@ -77,19 +78,20 @@ public final class DistributionBarHelper {
* map with status and count details
* @return tool tip
*/
public static String getTooltip(Map<Status, Long> statusCountMap) {
Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper.getStatusMapWithNonZeroValues(statusCountMap);
StringBuilder tooltip = new StringBuilder();
for (Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
public static String getTooltip(final Map<Status, Long> statusCountMap) {
final Map<Status, Long> nonZeroStatusCountMap = DistributionBarHelper
.getStatusMapWithNonZeroValues(statusCountMap);
final StringBuilder tooltip = new StringBuilder();
for (final Entry<Status, Long> entry : nonZeroStatusCountMap.entrySet()) {
tooltip.append(entry.getKey().toString().toLowerCase()).append(" : ").append(entry.getValue())
.append("<br>");
}
return tooltip.toString();
}
private static String getPartStyle(int partIndex, int noOfParts, String customStyle) {
StringBuilder mainStyle = new StringBuilder();
StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
private static String getPartStyle(final int partIndex, final int noOfParts, final String customStyle) {
final StringBuilder mainStyle = new StringBuilder();
final StringBuilder styleName = new StringBuilder(GwtDistributionBar.CLASSNAME);
if (noOfParts == 1) {
styleName.append("-only");
} else if (partIndex == 1) {
@@ -108,15 +110,16 @@ public final class DistributionBarHelper {
return mainStyle.toString();
}
private static String getPartWidth(Long value, Long totalValue, int noOfParts) {
private static String getPartWidth(final Long value, final Long totalValue, final int noOfParts) {
final double minTotalSize = MINIMUM_PART_SIZE * noOfParts;
final double availableSize = PARENT_SIZE_IN_PCT - minTotalSize;
double val = MINIMUM_PART_SIZE + (double) value / totalValue * availableSize;
final double val = MINIMUM_PART_SIZE + (double) value / totalValue * availableSize;
return String.format("%.3f", val) + "%";
}
private static String getPart(int partIndex, Status status, Long value, Long totalValue, int noOfParts) {
String partValue = status.toString().toLowerCase();
private static String getPart(final int partIndex, final Status status, final Long value, final Long totalValue,
final int noOfParts) {
final String partValue = status.toString().toLowerCase();
return "<div class=\"" + getPartStyle(partIndex, noOfParts, partValue) + "\" style=\"width: "
+ getPartWidth(value, totalValue, noOfParts) + ";\"><span class=\""
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">" + value + "</span></div>";
@@ -127,9 +130,9 @@ public final class DistributionBarHelper {
+ DISTRIBUTION_BAR_PART_VALUE_CLASSNAME + "\">uninitialized</span></div>";
}
private static Long getTotalSizes(Map<Status, Long> statusTotalCountMap) {
private static Long getTotalSizes(final Map<Status, Long> statusTotalCountMap) {
Long total = 0L;
for (Long value : statusTotalCountMap.values()) {
for (final Long value : statusTotalCountMap.values()) {
total = total + value;
}
return total;
@@ -139,8 +142,4 @@ public final class DistributionBarHelper {
return "<div class=\"" + GwtDistributionBar.CLASSNAME
+ "\" style=\"width: 100%; height: 100%;\" id=\"rollout.status.progress.bar.id\">";
}
private static String getParentDivEnd() {
return "</div>";
}
}

View File

@@ -31,8 +31,11 @@ import org.eclipse.hawkbit.ui.UiProperties;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow;
import org.eclipse.hawkbit.ui.common.CommonDialogWindow.SaveDialogCloseListener;
import org.eclipse.hawkbit.ui.common.DistributionSetIdName;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextAreaBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.common.builder.WindowBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIWindowDecorator;
import org.eclipse.hawkbit.ui.filtermanagement.TargetFilterBeanQuery;
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout;
import org.eclipse.hawkbit.ui.management.footer.ActionTypeOptionGroupLayout.ActionTypeOption;
@@ -153,7 +156,7 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
/**
* Get the window.
*
*
* @param rolloutId
* the rollout id
* @return the window
@@ -166,9 +169,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
public CommonDialogWindow getWindow() {
resetComponents();
final CommonDialogWindow commonDialogWindow = SPUIWindowDecorator.getWindow(
i18n.get("caption.configure.rollout"), null, SPUIDefinitions.CREATE_UPDATE_WINDOW, this, null,
uiProperties.getLinks().getDocumentation().getRolloutView(), this, i18n);
final CommonDialogWindow commonDialogWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW)
.caption(i18n.get("caption.configure.rollout")).content(this).layout(this).i18n(i18n)
.helpLink(uiProperties.getLinks().getDocumentation().getRolloutView()).buildCommonDialogWindow();
commonDialogWindow.setSaveDialogCloseListener(new SaveDialogCloseListener() {
@Override
@@ -280,15 +283,23 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private Label getLabel(final String key) {
return SPUIComponentProvider.getLabel(i18n.get(key), SPUILabelDefinitions.SP_LABEL_SIMPLE);
return new LabelBuilder().name(i18n.get(key)).buildLabel();
}
private TextField getTextfield(final String key) {
return SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null, i18n.get(key), true,
SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
private TextField createTextField(final String in18Key, final String id) {
return new TextFieldBuilder().prompt(i18n.get(in18Key)).immediate(true).id(id).buildTextComponent();
}
private Label getPercentHintLabel() {
private TextField createIntegerTextField(final String in18Key, final String id) {
final TextField textField = createTextField(in18Key, id);
textField.setNullRepresentation("");
textField.setConverter(new StringToIntegerConverter());
textField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
textField.setSizeUndefined();
return textField;
}
private static Label getPercentHintLabel() {
final Label percentSymbol = new Label("%");
percentSymbol.addStyleName(ValoTheme.LABEL_TINY + " " + ValoTheme.LABEL_BOLD);
percentSymbol.setSizeUndefined();
@@ -304,31 +315,31 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
populateTargetFilterQuery();
noOfGroups = createNoOfGroupsField();
groupSizeLabel = createGroupSizeLabel();
groupSizeLabel = createCountLabel();
triggerThreshold = createTriggerThreshold();
errorThreshold = createErrorThreshold();
description = createDescription();
errorThresholdOptionGroup = createErrorThresholdOptionGroup();
setDefaultSaveStartGroupOption();
actionTypeOptionGroupLayout.selectDefaultOption();
totalTargetsLabel = createTotalTargetsLabel();
totalTargetsLabel = createCountLabel();
targetFilterQuery = createTargetFilterQuery();
actionTypeOptionGroupLayout.addStyleName(SPUIStyleDefinitions.ROLLOUT_ACTION_TYPE_LAYOUT);
}
private Label createGroupSizeLabel() {
final Label groupSize = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
private static Label createCountLabel() {
final Label groupSize = new LabelBuilder().visible(false).name("").buildLabel();
groupSize.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message");
groupSize.setImmediate(true);
groupSize.setVisible(false);
groupSize.setSizeUndefined();
return groupSize;
}
private TextArea createTargetFilterQuery() {
final TextArea filterField = SPUIComponentProvider.getTextArea(null, "text-area-style",
ValoTheme.TEXTFIELD_TINY, false, null, null,
SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH);
private static TextArea createTargetFilterQuery() {
final TextArea filterField = new TextAreaBuilder().style("text-area-style")
.id(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD)
.maxLengthAllowed(SPUILabelDefinitions.TARGET_FILTER_QUERY_TEXT_FIELD_LENGTH).buildTextComponent();
filterField.setId(SPUIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
filterField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
filterField.setEnabled(false);
@@ -336,15 +347,6 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
return filterField;
}
private Label createTotalTargetsLabel() {
final Label targetCountLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
targetCountLabel.addStyleName(ValoTheme.LABEL_TINY + " " + "rollout-target-count-message");
targetCountLabel.setImmediate(true);
targetCountLabel.setVisible(false);
targetCountLabel.setSizeUndefined();
return targetCountLabel;
}
private OptionGroup createErrorThresholdOptionGroup() {
final OptionGroup errorThresoldOptions = new OptionGroup();
for (final ERRORTHRESOLDOPTIONS option : ERRORTHRESOLDOPTIONS.values()) {
@@ -527,49 +529,35 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private TextArea createDescription() {
final TextArea descriptionField = SPUIComponentProvider.getTextArea(null, "text-area-style",
ValoTheme.TEXTAREA_TINY, false, null, i18n.get("textfield.description"),
SPUILabelDefinitions.TEXT_AREA_MAX_LENGTH);
descriptionField.setId(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID);
final TextArea descriptionField = new TextAreaBuilder().style("text-area-style")
.prompt(i18n.get("textfield.description")).id(SPUIComponentIdProvider.ROLLOUT_DESCRIPTION_ID)
.buildTextComponent();
descriptionField.setNullRepresentation(HawkbitCommonUtil.SP_STRING_EMPTY);
descriptionField.setSizeUndefined();
return descriptionField;
}
private TextField createErrorThreshold() {
final TextField errorField = getTextfield("prompt.error.threshold");
errorField.setNullRepresentation("");
final TextField errorField = createIntegerTextField("prompt.error.threshold",
SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
errorField.addValidator(new ThresholdFieldValidator());
errorField.setConverter(new StringToIntegerConverter());
errorField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
errorField.setId(SPUIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
errorField.setMaxLength(7);
errorField.setSizeUndefined();
return errorField;
}
private TextField createTriggerThreshold() {
final TextField thresholdField = getTextfield("prompt.tigger.threshold");
thresholdField.setId(SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
thresholdField.setNullRepresentation("");
final TextField thresholdField = createIntegerTextField("prompt.tigger.threshold",
SPUIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
thresholdField.addValidator(new ThresholdFieldValidator());
thresholdField.setConverter(new StringToIntegerConverter());
thresholdField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
thresholdField.setSizeUndefined();
thresholdField.setMaxLength(3);
return thresholdField;
}
private TextField createNoOfGroupsField() {
final TextField noOfGroupsField = getTextfield("prompt.number.of.groups");
noOfGroupsField.setId(SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
final TextField noOfGroupsField = createIntegerTextField("prompt.number.of.groups",
SPUIComponentIdProvider.ROLLOUT_NO_OF_GROUPS_ID);
noOfGroupsField.addValidator(new GroupNumberValidator());
noOfGroupsField.setSizeUndefined();
noOfGroupsField.setMaxLength(3);
noOfGroupsField.setConverter(new StringToIntegerConverter());
noOfGroupsField.setConversionError(i18n.get(MESSAGE_ENTER_NUMBER));
noOfGroupsField.addValueChangeListener(this::onGroupNumberChange);
noOfGroupsField.setNullRepresentation("");
return noOfGroupsField;
}
@@ -607,8 +595,8 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
private TextField createRolloutNameField() {
final TextField rolloutNameField = getTextfield("textfield.name");
rolloutNameField.setId(SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
final TextField rolloutNameField = createTextField("textfield.name",
SPUIComponentIdProvider.ROLLOUT_NAME_FIELD_ID);
rolloutNameField.setSizeUndefined();
return rolloutNameField;
}
@@ -700,9 +688,9 @@ public class AddUpdateRolloutWindowLayout extends GridLayout {
}
/**
*
*
* Populate rollout details.
*
*
* @param rolloutId
* rollout id
*/

View File

@@ -8,6 +8,8 @@
*/
package org.eclipse.hawkbit.ui.rollout.rollout;
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -34,7 +36,7 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
import com.google.common.base.Strings;
/**
*
*
* Simple implementation of generics bean query which dynamically loads a batch
* of {@link ProxyRollout} beans.
*
@@ -55,7 +57,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
/**
* Parametric Constructor.
*
*
* @param definition
* as QueryDefinition
* @param queryConfig
@@ -71,10 +73,10 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
searchText = getSearchText();
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
if (!isEmpty(sortStates)) {
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortIds[0]);
// Add sort.
for (int targetId = 1; targetId < sortIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC, (String) sortIds[targetId]));
}
@@ -95,7 +97,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
/*
* (non-Javadoc)
*
*
* @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#loadBeans(int,
* int)
@@ -149,7 +151,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
/*
* (non-Javadoc)
*
*
* @see
* org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#saveBeans(java
* .util.List, java.util.List, java.util.List)
@@ -164,7 +166,7 @@ public class RolloutBeanQuery extends AbstractBeanQuery<ProxyRollout> {
/*
* (non-Javadoc)
*
*
* @see org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery#size()
*/
@Override

View File

@@ -8,10 +8,15 @@
*/
package org.eclipse.hawkbit.ui.rollout.rollout;
import static org.eclipse.hawkbit.ui.rollout.DistributionBarHelper.getTooltip;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_LI_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_CLOSE_TAG;
import static org.eclipse.hawkbit.ui.utils.HawkbitCommonUtil.HTML_UL_OPEN_TAG;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.ACTION;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_DIST_NAME_VERSION;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_STATUS;
import static org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS;
import java.util.ArrayList;
import java.util.Arrays;
@@ -122,7 +127,7 @@ public class RolloutListGrid extends AbstractGrid {
/**
* Handles the RolloutChangeEvent to refresh the item in the grid.
*
*
* @param rolloutChangeEvent
* the event which contains the rollout which has been changed
*/
@@ -428,19 +433,22 @@ public class RolloutListGrid extends AbstractGrid {
}
private String getDescription(final CellReference cell) {
if (SPUILabelDefinitions.VAR_STATUS.equals(cell.getPropertyId())) {
return cell.getProperty().getValue().toString().toLowerCase();
} else if (SPUILabelDefinitions.ACTION.equals(cell.getPropertyId())) {
return SPUILabelDefinitions.ACTION.toLowerCase();
String description = null;
if (VAR_STATUS.equals(cell.getPropertyId())) {
description = cell.getProperty().getValue().toString().toLowerCase();
} else if (ACTION.equals(cell.getPropertyId())) {
description = ACTION.toLowerCase();
} else if (ROLLOUT_RENDERER_DATA.equals(cell.getPropertyId())) {
return ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
return DistributionBarHelper
.getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else if (SPUILabelDefinitions.VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
return getDSDetails(cell.getItem());
description = ((RolloutRendererData) cell.getProperty().getValue()).getName();
} else if (VAR_TOTAL_TARGETS_COUNT_STATUS.equals(cell.getPropertyId())) {
description = getTooltip(((TotalTargetCountStatus) cell.getValue()).getStatusTotalCountMap());
} else if (VAR_DIST_NAME_VERSION.equals(cell.getPropertyId())) {
description = getDSDetails(cell.getItem());
}
return null;
return description;
}
private static String getDSDetails(final Item rolloutItem) {
@@ -497,7 +505,7 @@ public class RolloutListGrid extends AbstractGrid {
/**
* Constructor
*
*
* @param containerDataSource
* the container
*/
@@ -548,7 +556,7 @@ public class RolloutListGrid extends AbstractGrid {
}
/**
*
*
* Converter to convert {@link RolloutStatus} to string.
*
*/

View File

@@ -11,13 +11,12 @@ package org.eclipse.hawkbit.ui.rollout.rollout;
import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.SpPermissionChecker;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUIDefinitions;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
@@ -134,8 +133,7 @@ public class RolloutListHeader extends AbstractGridHeader {
@Override
protected HorizontalLayout getHeaderCaptionLayout() {
final Label headerCaption = SPUIComponentProvider.getLabel(getHeaderCaption(),
SPUILabelDefinitions.SP_WIDGET_CAPTION);
final Label headerCaption = new LabelBuilder().name(getHeaderCaption()).buildCaptionLabel();
final HorizontalLayout headerCaptionLayout = new HorizontalLayout();
headerCaptionLayout.addComponent(headerCaption);

View File

@@ -8,6 +8,10 @@
*/
package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import static org.apache.commons.lang3.ArrayUtils.isEmpty;
import static org.springframework.data.domain.Sort.Direction.ASC;
import static org.springframework.data.domain.Sort.Direction.DESC;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -52,7 +56,7 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
/**
* Parametric Constructor.
*
*
* @param definition
* as QueryDefinition
* @param queryConfig
@@ -64,24 +68,21 @@ public class RolloutGroupBeanQuery extends AbstractBeanQuery<ProxyRolloutGroup>
*/
public RolloutGroupBeanQuery(final QueryDefinition definition, final Map<String, Object> queryConfig,
final Object[] sortPropertyIds, final boolean[] sortStates) {
super(definition, queryConfig, sortPropertyIds, sortStates);
rolloutId = getRolloutId();
if (HawkbitCommonUtil.checkBolArray(sortStates)) {
// Initalize Sor
sort = new Sort(sortStates[0] ? Direction.ASC : Direction.DESC, (String) sortPropertyIds[0]);
// Add sort.
if (!isEmpty(sortStates)) {
sort = new Sort(sortStates[0] ? ASC : DESC, (String) sortPropertyIds[0]);
for (int targetId = 1; targetId < sortPropertyIds.length; targetId++) {
sort.and(new Sort(sortStates[targetId] ? Direction.ASC : Direction.DESC,
(String) sortPropertyIds[targetId]));
sort.and(new Sort(sortStates[targetId] ? ASC : DESC, (String) sortPropertyIds[targetId]));
}
}
}
/**
* @return
*/
private Long getRolloutId() {
return getRolloutUIState().getRolloutId().isPresent() ? getRolloutUIState().getRolloutId().get() : null;
}

View File

@@ -49,10 +49,11 @@ import com.vaadin.server.FontAwesome;
import com.vaadin.spring.annotation.SpringComponent;
import com.vaadin.spring.annotation.ViewScope;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickEvent;
import com.vaadin.ui.renderers.ClickableRenderer.RendererClickListener;
import com.vaadin.ui.renderers.HtmlRenderer;
/**
*
*
* Rollout group list grid component.
*
*/
@@ -86,10 +87,10 @@ public class RolloutGroupListGrid extends AbstractGrid {
}
/**
*
*
* Handles the RolloutGroupChangeEvent to refresh the item in the grid.
*
*
*
*
* @param rolloutGroupChangeEvent
* the event which contains the rollout group which has been
* change
@@ -238,7 +239,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
getColumn(SPUILabelDefinitions.VAR_TOTAL_TARGETS_COUNT_STATUS).setRenderer(new HtmlRenderer(),
new TotalTargetCountStatusConverter());
if (permissionChecker.hasRolloutTargetsReadPermission()) {
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(this::onClickOfRolloutGroupName));
getColumn(ROLLOUT_RENDERER_DATA).setRenderer(new RolloutRenderer(new RolloutGroupClickListener()));
}
}
@@ -261,12 +262,6 @@ public class RolloutGroupListGrid extends AbstractGrid {
return this::getDescription;
}
private void onClickOfRolloutGroupName(final RendererClickEvent event) {
rolloutUIState
.setRolloutGroup(rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
private void createRolloutGroupStatusToFontMap() {
statusIconMap.put(RolloutGroupStatus.FINISHED,
new StatusFontIcon(FontAwesome.CHECK_CIRCLE, SPUIStyleDefinitions.STATUS_ICON_GREEN));
@@ -310,11 +305,22 @@ public class RolloutGroupListGrid extends AbstractGrid {
});
}
private class RolloutGroupClickListener implements RendererClickListener {
private static final long serialVersionUID = 1L;
@Override
public void click(final RendererClickEvent event) {
rolloutUIState.setRolloutGroup(
rolloutGroupManagement.findRolloutGroupWithDetailedStatus((Long) event.getItemId()));
eventBus.publish(this, RolloutEvent.SHOW_ROLLOUT_GROUP_TARGETS);
}
}
/**
*
*
* Converts {@link TotalTargetCountStatus} into formatted string with status
* and count details.
*
*/
class TotalTargetCountStatusConverter implements Converter<String, TotalTargetCountStatus> {
@@ -322,15 +328,13 @@ public class RolloutGroupListGrid extends AbstractGrid {
@Override
public TotalTargetCountStatus convertToModel(final String value,
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
final Class<? extends TotalTargetCountStatus> targetType, final Locale locale) {
return null;
}
@Override
public String convertToPresentation(final TotalTargetCountStatus value,
final Class<? extends String> targetType, final Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
final Class<? extends String> targetType, final Locale locale) {
return DistributionBarHelper.getDistributionBarAsHTMLString(value.getStatusTotalCountMap());
}
@@ -346,9 +350,7 @@ public class RolloutGroupListGrid extends AbstractGrid {
}
/**
*
* Converts {@link RolloutGroupStatus} to string.
*
*/
class RolloutGroupStatusConverter implements Converter<String, RolloutGroupStatus> {

View File

@@ -11,6 +11,7 @@ package org.eclipse.hawkbit.ui.rollout.rolloutgroup;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -18,7 +19,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -149,8 +149,8 @@ public class RolloutGroupsListHeader extends AbstractGridHeader {
@Override
protected HorizontalLayout getHeaderCaptionLayout() {
headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION);
headerCaption.setId(SPUIComponentIdProvider.ROLLOUT_GROUP_HEADER_CAPTION);
headerCaption = new LabelBuilder().id(SPUIComponentIdProvider.ROLLOUT_GROUP_HEADER_CAPTION).name("")
.buildCaptionLabel();
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
SPUIButtonStyleSmallNoBorder.class);
rolloutsListViewLink.setStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link rollout-caption-links");

View File

@@ -12,6 +12,7 @@ import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import org.eclipse.hawkbit.repository.model.RolloutGroup;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.grid.AbstractGridHeader;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorder;
@@ -19,7 +20,6 @@ import org.eclipse.hawkbit.ui.rollout.event.RolloutEvent;
import org.eclipse.hawkbit.ui.rollout.state.RolloutUIState;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUIComponentIdProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import org.vaadin.spring.events.EventBus;
import org.vaadin.spring.events.EventScope;
@@ -164,7 +164,7 @@ public class RolloutGroupTargetsListHeader extends AbstractGridHeader {
@Override
protected HorizontalLayout getHeaderCaptionLayout() {
headerCaption = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_WIDGET_CAPTION);
headerCaption = new LabelBuilder().name("").buildCaptionLabel();
headerCaption.setStyleName(ValoTheme.LABEL_BOLD + " " + ValoTheme.LABEL_SMALL);
final Button rolloutsListViewLink = SPUIComponentProvider.getButton(null, "", "", null, false, null,
SPUIButtonStyleSmallNoBorder.class);

View File

@@ -161,13 +161,13 @@ public class AuthenticationConfigurationView extends BaseConfigurationView
final CheckBox checkBox = (CheckBox) event.getProperty();
AuthenticationConfigurationItem configurationItem;
if (checkBox == gatewaySecTokenCheckBox) {
if (gatewaySecTokenCheckBox.equals(checkBox)) {
configurationItem = gatewaySecurityTokenAuthenticationConfigurationItem;
} else if (checkBox == targetSecTokenCheckBox) {
} else if (targetSecTokenCheckBox.equals(checkBox)) {
configurationItem = targetSecurityTokenAuthenticationConfigurationItem;
} else if (checkBox == certificateAuthCheckbox) {
} else if (certificateAuthCheckbox.equals(checkBox)) {
configurationItem = certificateAuthenticationConfigurationItem;
} else if (checkBox == downloadAnonymousCheckBox) {
} else if (downloadAnonymousCheckBox.equals(checkBox)) {
configurationItem = anonymousDownloadAuthenticationConfigurationItem;
} else {
return;

View File

@@ -13,9 +13,8 @@ import java.util.List;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.utils.I18N;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.ui.VerticalLayout;
@@ -58,7 +57,7 @@ abstract class AbstractAuthenticationTenantConfigurationItem extends VerticalLay
*/
protected void init(final String labelText) {
setImmediate(true);
addComponent(SPUIComponentProvider.getLabel(i18n.get(labelText), SPUILabelDefinitions.SP_LABEL_SIMPLE));
addComponent(new LabelBuilder().name(i18n.get(labelText)).buildLabel());
}
@Override

View File

@@ -12,8 +12,8 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.spring.annotation.SpringComponent;
@@ -22,7 +22,6 @@ import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Label;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.ValoTheme;
/**
* This class represents the UI item for the certificate authenticated by an
@@ -61,15 +60,12 @@ public class CertificateAuthenticationConfigurationItem extends AbstractAuthenti
final HorizontalLayout caRootAuthorityLayout = new HorizontalLayout();
caRootAuthorityLayout.setSpacing(true);
final Label caRootAuthorityLabel = SPUIComponentProvider.getLabel("SSL Issuer Hash:",
SPUILabelDefinitions.SP_LABEL_SIMPLE);
final Label caRootAuthorityLabel = new LabelBuilder().name("SSL Issuer Hash:").buildLabel();
caRootAuthorityLabel.setDescription(
"The SSL Issuer iRules.X509 hash, to validate against the controller request certifcate.");
caRootAuthorityTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
"", true, 128);
caRootAuthorityTextField = new TextFieldBuilder().immediate(true).maxLengthAllowed(128).buildTextComponent();
caRootAuthorityTextField.setWidth("500px");
caRootAuthorityTextField.setImmediate(true);
caRootAuthorityTextField.addTextChangeListener(event -> caRootAuthorityChanged());
caRootAuthorityLayout.addComponent(caRootAuthorityLabel);

View File

@@ -13,9 +13,10 @@ import javax.annotation.PostConstruct;
import org.eclipse.hawkbit.repository.TenantConfigurationManagement;
import org.eclipse.hawkbit.security.SecurityTokenGenerator;
import org.eclipse.hawkbit.tenancy.configuration.TenantConfigurationKey;
import org.eclipse.hawkbit.ui.common.builder.LabelBuilder;
import org.eclipse.hawkbit.ui.common.builder.TextFieldBuilder;
import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmall;
import org.eclipse.hawkbit.ui.utils.SPUILabelDefinitions;
import org.springframework.beans.factory.annotation.Autowired;
import com.vaadin.server.FontAwesome;
@@ -45,12 +46,12 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
private Label gatewayTokenkeyLabel;
private boolean configurationEnabled = false;
private boolean configurationEnabledChange = false;
private boolean configurationEnabled;
private boolean configurationEnabledChange;
private boolean keyNameChanged = false;
private boolean keyNameChanged;
private boolean keyChanged = false;
private boolean keyChanged;
private VerticalLayout detailLayout;
@@ -74,9 +75,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
detailLayout = new VerticalLayout();
detailLayout.setImmediate(true);
gatewayTokenNameTextField = SPUIComponentProvider.getTextField(null, "", ValoTheme.TEXTFIELD_TINY, false, null,
"", true, SPUILabelDefinitions.TEXT_FIELD_MAX_LENGTH);
gatewayTokenNameTextField.setImmediate(true);
gatewayTokenNameTextField = new TextFieldBuilder().immediate(true).buildTextComponent();
// hide text field until we support multiple gateway tokens for a tenan
gatewayTokenNameTextField.setVisible(false);
gatewayTokenNameTextField.addTextChangeListener(event -> doKeyNameChanged());
@@ -87,8 +86,7 @@ public class GatewaySecurityTokenAuthenticationConfigurationItem extends Abstrac
gatewaytokenBtn.setIcon(FontAwesome.REFRESH);
gatewaytokenBtn.addClickListener(event -> generateGatewayToken());
gatewayTokenkeyLabel = SPUIComponentProvider.getLabel("", SPUILabelDefinitions.SP_LABEL_SIMPLE);
gatewayTokenkeyLabel.setId("gatewaysecuritytokenkey");
gatewayTokenkeyLabel = new LabelBuilder().id("gatewaysecuritytokenkey").name("").buildLabel();
gatewayTokenkeyLabel.addStyleName("gateway-token-label");
gatewayTokenkeyLabel.setImmediate(true);

View File

@@ -8,15 +8,12 @@
*/
package org.eclipse.hawkbit.ui.utils;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TimeZone;
import org.eclipse.hawkbit.repository.EntityFactory;
@@ -30,10 +27,7 @@ import org.eclipse.hawkbit.repository.model.SoftwareModule;
import org.eclipse.hawkbit.repository.model.SoftwareModuleType;
import org.eclipse.hawkbit.repository.model.TargetUpdateStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus;
import org.eclipse.hawkbit.repository.model.TotalTargetCountStatus.Status;
import org.eclipse.hawkbit.ui.rollout.StatusFontIcon;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.vaadin.addons.lazyquerycontainer.AbstractBeanQuery;
import org.vaadin.addons.lazyquerycontainer.BeanQueryFactory;
import org.vaadin.addons.lazyquerycontainer.LazyQueryContainer;
@@ -53,9 +47,6 @@ import com.vaadin.ui.UI;
/**
* Common util class.
*
*
*
*/
public final class HawkbitCommonUtil {
@@ -78,13 +69,11 @@ public final class HawkbitCommonUtil {
public static final String HTML_UL_CLOSE_TAG = "</ul>";
public static final String HTML_UL_OPEN_TAG = "<ul>";
private static final Logger LOG = LoggerFactory.getLogger(HawkbitCommonUtil.class);
private static final String JS_DRAG_COUNT_REM_CHILD = " if(x) { document.head.removeChild(x); } ";
public static final String DIV_DESCRIPTION = "<div id=\"desc-length\"><p id=\"desciption-p\">";
public static final String DIV_DESCRIPTION_START = "<div id=\"desc-length\"><p id=\"desciption-p\">";
public static final String DIV_CLOSE = "</p></div>";
public static final String DIV_DESCRIPTION_END = "</p></div>";
private static final String DRAG_COUNT_ELEMENT = "var x = document.getElementById('sp-drag-count'); ";
private static final String CLOSE_BRACE = "\"; }';";
@@ -112,129 +101,25 @@ public final class HawkbitCommonUtil {
private static final String ASSIGN_DIST_SET = "assignedDistributionSet";
private static final String INSTALL_DIST_SET = "installedDistributionSet";
/**
* Define empty string.
*/
/**
* Private Constructor.
*/
private HawkbitCommonUtil() {
}
/**
* Check Map is valid.
*
* @param mapCheck
* as Map
* @return boolean as flag
* Check wether the given map is not {@code null} and not empty.
*
* @param mapToCheck
* the map to validate
* @return {@code true} if the given map is not {@code null} and not empty.
* Otherwise {@code false}
*/
public static boolean mapCheckObjKey(final Map<Object, Object> mapCheck) {
boolean validMap = false;
if (mapCheck != null && !mapCheck.isEmpty()) {
validMap = true;
}
return validMap;
}
/**
* Check Map is valid.
*
* @param mapCheck
* as Map
* @return boolean as flag
*/
public static boolean mapCheckStrKey(final Map<String, Object> mapCheck) {
boolean validMap = false;
if (mapCheck != null && !mapCheck.isEmpty()) {
validMap = true;
}
return validMap;
}
/**
* Check Map is valid.
*
* @param mapCheck
* as Map
* @return boolean as flag
*/
public static boolean mapCheckStrings(final Map<String, String> mapCheck) {
boolean validMap = false;
if (mapCheck != null && !mapCheck.isEmpty()) {
validMap = true;
}
return validMap;
}
/**
* Check List is valid.
*
* @param listCheck
* as List
* @return boolean as flag
*/
public static boolean listCheckObj(final List<Object> listCheck) {
boolean validList = false;
if (listCheck != null && !listCheck.isEmpty()) {
validList = true;
}
return validList;
}
/**
* Check Boolean Array is valid.
*
* @param bolArray
* as List
* @return boolean as flag
*/
public static boolean checkBolArray(final boolean[] bolArray) {
boolean validBolArray = false;
if (bolArray != null && bolArray.length > 0) {
validBolArray = true;
}
return validBolArray;
}
/**
* Check String null, return empty.
*
* @param nString
* as String
* @return String
*/
public static String getEmptyString(final String nString) {
String emptyStr = SP_STRING_SPACE;
if (nString != null && nString.length() > 0) {
emptyStr = nString;
}
return emptyStr;
}
/**
* Check valid String.
*
* @param nString
* as String
* @return boolean as flag
*/
public static boolean checkValidString(final String nString) {
boolean strValid = false;
if (nString != null && nString.length() > 0) {
strValid = true;
}
return strValid;
public static boolean isNotNullOrEmpty(final Map<?, ?> mapToCheck) {
return mapToCheck != null && !mapToCheck.isEmpty();
}
/**
* Trim the text and convert into null in case of empty string.
*
*
* @param text
* as text to be trimed
* @return null if the text is null or if the text is blank, text.trim() if
@@ -251,7 +136,7 @@ public final class HawkbitCommonUtil {
/**
* Concatenate the given text all the string arguments with the given
* delimiter.
*
*
* @param delimiter
* the delimiter text to be used while concatenation.
* @param texts
@@ -277,7 +162,7 @@ public final class HawkbitCommonUtil {
/**
* Returns the input text within html bold tag <b>..</b>.
*
*
* @param text
* is the text to be converted in to Bold
* @return null if the input text param is null returns text with <b>...</b>
@@ -296,16 +181,13 @@ public final class HawkbitCommonUtil {
/**
* Get target label Id.
*
*
* @param controllerId
* as String
* @return String as label name
*/
public static String getTargetLabelId(final String controllerId) {
final StringBuilder labelId = new StringBuilder("target");
labelId.append('.');
labelId.append(controllerId);
return labelId.toString();
return new StringBuilder("target").append('.').append(controllerId).toString();
}
/**
@@ -318,12 +200,7 @@ public final class HawkbitCommonUtil {
* @return String distribution label id
*/
public static String getDistributionLabelId(final String name, final String version) {
final StringBuilder labelId = new StringBuilder("dist");
labelId.append('.');
labelId.append(name);
labelId.append('.');
labelId.append(version);
return labelId.toString();
return new StringBuilder("dist").append('.').append(name).append('.').append(version).toString();
}
/**
@@ -336,12 +213,7 @@ public final class HawkbitCommonUtil {
* @return String software module label id
*/
public static String getSwModuleLabelId(final String name, final String version) {
final StringBuilder labelId = new StringBuilder("swModule");
labelId.append('.');
labelId.append(name);
labelId.append('.');
labelId.append(version);
return labelId.toString();
return new StringBuilder("swModule").append('.').append(name).append('.').append(version).toString();
}
/**
@@ -354,28 +226,26 @@ public final class HawkbitCommonUtil {
* @return String
*/
public static String getSwModuleNameDescLabel(final String name, final String desc) {
final StringBuilder labelDesc = new StringBuilder();
labelDesc.append(DIV_DESCRIPTION + getBoldHTMLText(getFormattedName(name)) + "<br>" + getFormattedName(desc));
labelDesc.append(DIV_CLOSE);
return labelDesc.toString();
return new StringBuilder().append(
DIV_DESCRIPTION_START + getBoldHTMLText(getFormattedName(name)) + "<br>" + getFormattedName(desc))
.append(DIV_DESCRIPTION_END).toString();
}
/**
* Get Label for Artifact Details.
*
*
* @param name
* @return
*/
public static String getArtifactoryDetailsLabelId(final String name) {
final StringBuilder labelDesc = new StringBuilder();
labelDesc.append(DIV_DESCRIPTION + "Artifact Details of " + getBoldHTMLText(getFormattedName(name)));
labelDesc.append(DIV_CLOSE);
return labelDesc.toString();
return new StringBuilder()
.append(DIV_DESCRIPTION_START + "Artifact Details of " + getBoldHTMLText(getFormattedName(name)))
.append(DIV_DESCRIPTION_END).toString();
}
/**
* Get Label for Artifact Details.
*
*
* @param caption
* as caption of the details
* @param name
@@ -383,28 +253,26 @@ public final class HawkbitCommonUtil {
* @return
*/
public static String getSoftwareModuleName(final String caption, final String name) {
final StringBuilder labelDesc = new StringBuilder();
labelDesc.append(DIV_DESCRIPTION + caption + " : " + getBoldHTMLText(getFormattedName(name)));
labelDesc.append(DIV_CLOSE);
return labelDesc.toString();
return new StringBuilder()
.append(DIV_DESCRIPTION_START + caption + " : " + getBoldHTMLText(getFormattedName(name)))
.append(DIV_DESCRIPTION_END).toString();
}
/**
* Get Label for Action History Details.
*
*
* @param name
* @return
*/
public static String getActionHistoryLabelId(final String name) {
final StringBuilder labelDesc = new StringBuilder();
labelDesc.append(DIV_DESCRIPTION + "Action History For " + getBoldHTMLText(getFormattedName(name)));
labelDesc.append(DIV_CLOSE);
return labelDesc.toString();
return new StringBuilder()
.append(DIV_DESCRIPTION_START + "Action History For " + getBoldHTMLText(getFormattedName(name)))
.append(DIV_DESCRIPTION_END).toString();
}
/**
* Get tool tip for Poll status.
*
*
* @param pollStatus
* @param i18N
* @return
@@ -434,14 +302,14 @@ public final class HawkbitCommonUtil {
/**
* Find extra height required to increase by all the components to utilize
* the full height of browser for the responsive UI.
*
*
* @param newBrowserHeight
* as current browser height.
* @return extra height required to increase.
*/
public static float findRequiredExtraHeight(final float newBrowserHeight) {
return newBrowserHeight > SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT
? newBrowserHeight - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT : 0;
? (newBrowserHeight - SPUIDefinitions.REQ_MIN_BROWSER_HEIGHT) : 0;
}
/**
@@ -453,7 +321,7 @@ public final class HawkbitCommonUtil {
*/
public static float findRequiredSwModuleExtraHeight(final float newBrowserHeight) {
return newBrowserHeight > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT
? newBrowserHeight - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT : 0;
? (newBrowserHeight - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_HEIGHT) : 0;
}
/**
@@ -465,7 +333,7 @@ public final class HawkbitCommonUtil {
*/
public static float findRequiredSwModuleExtraWidth(final float newBrowserWidth) {
return newBrowserWidth > SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH
? newBrowserWidth - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH : 0;
? (newBrowserWidth - SPUIDefinitions.REQ_MIN_UPLOAD_BROWSER_WIDTH) : 0;
}
/**
@@ -528,7 +396,7 @@ public final class HawkbitCommonUtil {
*/
public static float findExtraWidth(final float newBrowserWidth) {
return newBrowserWidth > SPUIDefinitions.REQ_MIN_BROWSER_WIDTH
? newBrowserWidth - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH : 0;
? (newBrowserWidth - SPUIDefinitions.REQ_MIN_BROWSER_WIDTH) : 0;
}
/**
@@ -570,7 +438,7 @@ public final class HawkbitCommonUtil {
final float requiredExtraWidth = findExtraWidth(newBrowserWidth);
float expectedDistWidth = minTableWidth;
if (requiredExtraWidth > 0) {
expectedDistWidth = expectedDistWidth + Math.round(requiredExtraWidth * 0.5f);
expectedDistWidth = expectedDistWidth + Math.round(requiredExtraWidth * 0.5F);
}
return expectedDistWidth;
}
@@ -600,17 +468,16 @@ public final class HawkbitCommonUtil {
* @return String name
*/
public static String removePrefix(final String text, final String prefix) {
String str = null;
if (null != text) {
str = text.replaceFirst(prefix, "");
if (text != null) {
return text.replaceFirst(prefix, "");
}
return str;
return null;
}
/**
* Create javascript to display number of targets or distributions your are
* dragging in the drag image.
*
*
* @param count
* @return
*/
@@ -630,7 +497,7 @@ public final class HawkbitCommonUtil {
/**
* Get formatted label.Appends ellipses if content does not fit the label.
*
*
* @param labelContent
* content
* @return Label
@@ -640,7 +507,6 @@ public final class HawkbitCommonUtil {
labelValue.setSizeFull();
labelValue.addStyleName(SPUIDefinitions.TEXT_STYLE);
labelValue.addStyleName("label-style");
return labelValue;
}
@@ -669,14 +535,11 @@ public final class HawkbitCommonUtil {
final float extraBrowserHeight = HawkbitCommonUtil.findRequiredSwModuleExtraHeight(newHeight);
final float tableHeight = SPUIDefinitions.MIN_UPLOAD_ARTIFACT_TABLE_HEIGHT + extraBrowserHeight;
artifactDetailsLayout.setHeight(tableHeight, Unit.PIXELS);
}
/**
* Set height of artifact details table and drop area layout.
*
* @param dropLayout
* drop area layout
* @param artifactDetailsLayout
* artifact details table
* @param newHeight
@@ -687,28 +550,32 @@ public final class HawkbitCommonUtil {
final float tableHeight = SPUIDefinitions.MIN_TARGET_DIST_TABLE_HEIGHT
+ HawkbitCommonUtil.findRequiredExtraHeight(newHeight) + 62;
artifactDetailsLayout.setHeight(tableHeight, Unit.PIXELS);
}
/**
* Close output stream.
<<<<<<< HEAD
=======
* Duplicate check - Unique Key.
*
* @param fos
* out stream to be closed
* @param name
* as string
* @param version
* as string
* @param type
* key as string
* @return boolean as flag
*/
public static void closeOutoutStream(final FileOutputStream fos) {
try {
if (fos != null) {
fos.close();
}
} catch (final IOException ioe) {
LOG.error("Colud not close output stream", ioe);
}
public static boolean isDuplicate(final String name, final String version, final String type) {
final SoftwareManagement swMgmtService = SpringContextHelper.getBean(SoftwareManagement.class);
final SoftwareModule swModule = swMgmtService.findSoftwareModuleByNameAndVersion(name, version,
swMgmtService.findSoftwareModuleTypeByName(type));
return swModule != null;
}
/**
>>>>>>> refs/heads/master
* Add new base software module.
*
*
* @param bsname
* base software module name
* @param bsversion
@@ -719,6 +586,8 @@ public final class HawkbitCommonUtil {
* base software module type
* @param description
* base software module description
* @param entityFactory
* the entity factory to create new entity instances
* @return BaseSoftwareModule new base software module
*/
public static SoftwareModule addNewBaseSoftware(final EntityFactory entityFactory, final String bsname,
@@ -749,20 +618,16 @@ public final class HawkbitCommonUtil {
* @return
*/
public static String getDistributionNameAndVersion(final String distName, final String distVersion) {
final StringBuilder stringBuilder = new StringBuilder(distName);
stringBuilder.append(':').append(distVersion);
return stringBuilder.toString();
return new StringBuilder(distName).append(':').append(distVersion).toString();
}
/**
* Display Target Tag action message.
*
*
* @param tagName
* as tag name
* @param result
* as TargetTagAssigmentResult
* @param tagsClickedList
* as clicked tag list
* @param i18n
* I18N
* @return message
@@ -803,7 +668,7 @@ public final class HawkbitCommonUtil {
/**
* Create a lazy query container for the given query bean factory with empty
* configurations.
*
*
* @param queryFactory
* is reference of {@link BeanQueryFactory<? extends
* AbstractBeanQuery>} on which lazy container should create.
@@ -817,9 +682,9 @@ public final class HawkbitCommonUtil {
}
/**
*
*
* Create lazy query container for DS type.
*
*
* @param queryFactory
* @return LazyQueryContainer
*/
@@ -832,7 +697,7 @@ public final class HawkbitCommonUtil {
/**
* Set distribution table column properties.
*
*
* @param container
* table container
*/
@@ -850,7 +715,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the software module table rows highlight css.
*
*
* @return javascript to rest software module table rows highlight css.
*/
public static String getScriptSMHighlightReset() {
@@ -859,73 +724,66 @@ public final class HawkbitCommonUtil {
/**
* Highlight software module rows with the color of sw-type.
*
*
* @param colorCSS
* color to generate the css script.
* @return javascript to append software module table rows with highlighted
* color.
*/
public static String getScriptSMHighlightWithColor(final String colorCSS) {
final StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append(SM_HIGHLIGHT_SCRIPT_CURRENT).append("smHighlightStyle = smHighlightStyle + \"")
.append(colorCSS).append("\";").append(SM_HIGHLIGHT_SCRIPT_APPEND);
return scriptBuilder.toString();
return new StringBuilder().append(SM_HIGHLIGHT_SCRIPT_CURRENT)
.append("smHighlightStyle = smHighlightStyle + \"").append(colorCSS).append("\";")
.append(SM_HIGHLIGHT_SCRIPT_APPEND).toString();
}
/**
* Get javascript to reflect new color selection in color picker preview for
* name and description fields .
*
*
* @param colorPickedPreview
* changed color
* @return javascript for the selected color.
*/
public static String changeToNewSelectedPreviewColor(final String colorPickedPreview) {
final StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT)
return new StringBuilder().append(NEW_PREVIEW_COLOR_REMOVE_SCRIPT).append(NEW_PREVIEW_COLOR_CREATE_SCRIPT)
.append("var newColorPreviewStyle = \".v-app .new-tag-name{ border: solid 3px ")
.append(colorPickedPreview)
.append(" !important; width:138px; margin-left:2px !important; box-shadow:none !important; } \"; ")
.append("newColorPreviewStyle = newColorPreviewStyle + \".v-app .new-tag-desc{ border: solid 3px ")
.append(colorPickedPreview)
.append(" !important; width:138px; height:75px !important; margin-top:4px !important; margin-left:2px !important;;box-shadow:none !important;} \"; ")
.append(NEW_PREVIEW_COLOR_SET_STYLE_SCRIPT);
return scriptBuilder.toString();
.append(NEW_PREVIEW_COLOR_SET_STYLE_SCRIPT).toString();
}
/**
* Get javascript to reflect new color selection for preview button.
*
*
* @param color
* changed color
* @return javascript for the selected color.
*/
public static String getPreviewButtonColorScript(final String color) {
final StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT)
return new StringBuilder().append(PREVIEW_BUTTON_COLOR_REMOVE_SCRIPT).append(PREVIEW_BUTTON_COLOR_CREATE_SCRIPT)
.append("var tagColorPreviewStyle = \".v-app .tag-color-preview{ height: 15px !important; padding: 0 10px !important; border: 0px !important; margin-left:12px !important; margin-top: 4px !important; border-width: 0 !important; background: ")
.append(color)
.append(" } .v-app .tag-color-preview:after{ border-color: none !important; box-shadow:none !important;} \"; ")
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT);
return scriptBuilder.toString();
.append(PREVIEW_BUTTON_COLOR_SET_STYLE_SCRIPT).toString();
}
/**
* Java script to display drop hints for tags.
*
*
* @return javascript
*/
public static String dispTargetTagsDropHintScript() {
final String targetDropStyle = "document.getElementById('show-filter-drop-hint').innerHTML = '."
+ UI.getCurrent().getTheme() + " .target-tag-drop-hint { border: 1px dashed #26547a !important; }';";
final StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append(TARGET_TAG_DROP_CREATE_SCRIPT).append(targetDropStyle);
return scriptBuilder.toString();
return new StringBuilder().append(TARGET_TAG_DROP_CREATE_SCRIPT).append(targetDropStyle).toString();
}
/**
* Java script to hide drop hints for tags.
*
*
* @return javascript
*/
public static String hideTargetTagsDropHintScript() {
@@ -934,20 +792,18 @@ public final class HawkbitCommonUtil {
/**
* Java script to display drop hint for Delete button.
*
*
* @return javascript
*/
public static String dispDeleteDropHintScript() {
final String deleteTagDropStyle = "document.getElementById('show-delete-drop-hint').innerHTML = '."
+ UI.getCurrent().getTheme() + " .show-delete-drop-hint { border: 1px dashed #26547a !important; }';";
final StringBuilder scriptBuilder = new StringBuilder();
scriptBuilder.append(DELETE_DROP_CREATE_SCRIPT).append(deleteTagDropStyle);
return scriptBuilder.toString();
return new StringBuilder().append(DELETE_DROP_CREATE_SCRIPT).append(deleteTagDropStyle).toString();
}
/**
* Java script to hide drop hint for delete button.
*
*
* @return javascript
*/
public static String hideDeleteDropHintScript() {
@@ -955,9 +811,8 @@ public final class HawkbitCommonUtil {
}
/**
*
* Add target table container properties.
*
*
* @param container
* table container
*/
@@ -989,13 +844,11 @@ public final class HawkbitCommonUtil {
targetTableContainer.addContainerProperty(ASSIGN_DIST_SET, DistributionSet.class, null, false, true);
targetTableContainer.addContainerProperty(INSTALL_DIST_SET, DistributionSet.class, null, false, true);
}
/**
*
* Apply style for status label in target table.
*
*
* @param targetTable
* target table
* @param pinBtn
@@ -1025,7 +878,7 @@ public final class HawkbitCommonUtil {
/**
* Set status progress bar value.
*
*
* @param bar
* DistributionBar
* @param statusName
@@ -1044,7 +897,7 @@ public final class HawkbitCommonUtil {
/**
* Initialize status progress bar with values and number of parts on load.
*
*
* @param bar
* DistributionBar
* @param item
@@ -1063,7 +916,6 @@ public final class HawkbitCommonUtil {
0);
HawkbitCommonUtil.setBarPartSize(bar, TotalTargetCountStatus.Status.FINISHED.toString().toLowerCase(), 0,
1);
} else {
bar.setNumberOfParts(6);
setProgressBarDetails(bar, item);
@@ -1073,7 +925,7 @@ public final class HawkbitCommonUtil {
/**
* Formats the finished percentage of a rollout group into a string with one
* digit after comma.
*
*
* @param rolloutGroup
* the rollout group
* @param finishedPercentage
@@ -1102,7 +954,7 @@ public final class HawkbitCommonUtil {
/**
* Reset the values of status progress bar on change of values.
*
*
* @param bar
* DistributionBar
* @param item
@@ -1126,38 +978,17 @@ public final class HawkbitCommonUtil {
}
private static boolean isNoTargets(final Long... statusCount) {
if (Arrays.asList(statusCount).stream().filter(value -> value > 0).toArray().length > 0) {
return false;
}
return true;
return (Arrays.asList(statusCount).stream().filter(value -> value > 0).toArray().length) == 0;
}
private static Long getStatusCount(final String propertName, final Item item) {
return (Long) item.getItemProperty(propertName).getValue();
}
/**
* Get the formatted string of status and target count details.
*
* @param details
* details of status and count
* @return String
*/
public static String getFormattedString(final Map<Status, Long> details) {
final StringBuilder val = new StringBuilder();
if (details == null || details.isEmpty()) {
return null;
}
for (final Entry<Status, Long> entry : details.entrySet()) {
val.append(entry.getKey()).append(":").append(entry.getValue()).append(",");
}
return val.substring(0, val.length() - 1);
}
/**
* Returns a formatted string as needed by label custom render .This string
* holds the properties of a status label.
*
*
* @param value
* label value
* @param style
@@ -1174,13 +1005,12 @@ public final class HawkbitCommonUtil {
if (!Strings.isNullOrEmpty(style)) {
val.append("style:").append(style).append(",");
}
val.append("id:").append(id);
return val.toString();
return val.append("id:").append(id).toString();
}
/**
* Receive the code point of a given StatusFontIcon.
*
*
* @param statusFontIcon
* the status font icon
* @return the code point of the StatusFontIcon
@@ -1192,5 +1022,4 @@ public final class HawkbitCommonUtil {
return statusFontIcon.getFontIcon() != null ? Integer.toString(statusFontIcon.getFontIcon().getCodepoint())
: null;
}
}

View File

@@ -1013,22 +1013,17 @@ public final class SPUIDefinitions {
* Rollout action column property.
*/
public static final String ROLLOUT_ACTION = "rollout-action";
/**
* DistributionSet Metadata tab Id
*/
public static final String DISTRIBUTIONSET_METADATA_TAB_ID = "distSet.metadata.tab.id";
/**
* SoftwareModule Metadata tab Id
*/
public static final String SOFTWAREMODULE_METADATA_TAB_ID = "swModule.metadata.tab.id";
/***
* Custom window for metadata.
*/
public static final String CUSTOM_METADATA_WINDOW = "custom.metadata.window";
/**
* /** Constructor.
*/

View File

@@ -20,18 +20,6 @@ import com.vaadin.ui.themes.ValoTheme;
*/
public final class SPUILabelDefinitions {
/**
* Label - Table.
*/
public static final String SP_WIDGET_CAPTION = "Label-table";
/**
* Label - Simple.
*/
public static final String SP_LABEL_SIMPLE = "Label-simple";
/**
* Label - Message.
*/
public static final String SP_LABEL_MESSAGE = "Label-message";
/**
* Label - Message hint.
*/
@@ -280,15 +268,6 @@ public final class SPUILabelDefinitions {
*/
public static final String UPDATE_CUSTOM_FILTER = "Update Custom Filter";
/**
* Text area and text field max allowed length.
*/
public static final int TEXT_FIELD_MAX_LENGTH = 64;
/**
* Text area and text field max allowed length.
*/
public static final int TEXT_AREA_MAX_LENGTH = 512;
/**
* Yes label.
*/

View File

@@ -15,9 +15,7 @@ import org.eclipse.hawkbit.ui.components.SPUIComponentProvider;
import org.eclipse.hawkbit.ui.decorators.SPUIButtonStyleSmallNoBorderUH;
import org.junit.Test;
import com.vaadin.shared.ui.label.ContentMode;
import com.vaadin.ui.Button;
import com.vaadin.ui.Label;
import ru.yandex.qatools.allure.annotations.Features;
import ru.yandex.qatools.allure.annotations.Stories;
@@ -46,22 +44,4 @@ public class SPUIComponentProviderTest {
assertThat(placeHolderButton.getStyleName()).isEqualTo(SPUIButtonDefinitions.SP_BUTTON_STATUS_STYLE);
}
/**
* Test case for check Label factory.
*
* @throws Exception
*/
@Test
public void checkLabelFactory() throws Exception {
Label placeHolderLabel = null;
placeHolderLabel = SPUIComponentProvider.getLabel("TestTable", SPUILabelDefinitions.SP_WIDGET_CAPTION);
assertThat(placeHolderLabel).isInstanceOf(Label.class);
assertThat(placeHolderLabel.getValue()).isEqualTo("TestTable");
assertThat(placeHolderLabel.getContentMode()).isNotEqualTo(ContentMode.HTML);
placeHolderLabel = SPUIComponentProvider.getLabel("TestMSG", SPUILabelDefinitions.SP_LABEL_MESSAGE);
assertThat(placeHolderLabel.getValue()).isEqualTo("TestMSG");
assertThat(placeHolderLabel.getContentMode()).isEqualTo(ContentMode.HTML);
}
}