Some clean code refactorings

Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
SirWayne
2016-05-19 17:28:45 +02:00
parent 0f75c63878
commit 79d604ca0b
10 changed files with 102 additions and 105 deletions

View File

@@ -50,13 +50,11 @@ import com.vaadin.ui.themes.ValoTheme;
/**
* Vaadin management UI.
*
*
*
*
*/
@SuppressWarnings("serial")
@Title("hawkBit Update Server")
public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(HawkbitUI.class);
private static final String EMPTY_VIEW = "";
@@ -139,7 +137,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
contentVerticalLayout.addComponent(content);
content.setStyleName("view-content");
content.setSizeFull();
rootLayout.setExpandRatio(contentVerticalLayout, 1.0f);
rootLayout.setExpandRatio(contentVerticalLayout, 1.0F);
contentVerticalLayout.setStyleName("main-content");
contentVerticalLayout.setExpandRatio(content, 1.0F);
setContent(rootLayout);
@@ -154,6 +152,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
}
final Navigator navigator = new Navigator(this, content);
navigator.addViewChangeListener(new ViewChangeListener() {
private static final long serialVersionUID = 1L;
@Override
public boolean beforeViewChange(final ViewChangeEvent event) {
return true;
@@ -197,7 +197,7 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
* as set
* @return String as preferred locale
*/
private String getLocaleId(final Set<String> availableLocalesInApp) {
private static String getLocaleId(final Set<String> availableLocalesInApp) {
final String[] localeChain = getLocaleChain();
String spLocale = SPUIDefinitions.DEFAULT_LOCALE;
if (null != localeChain) {
@@ -217,16 +217,18 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
*
* @return String as locales
*/
private String[] getLocaleChain() {
private static String[] getLocaleChain() {
String[] localeChain = null;
// Fetch all cookies from the request
final Cookie[] cookies = VaadinService.getCurrentRequest().getCookies();
if (cookies != null) {
for (final Cookie c : cookies) {
if (c.getName().equals(SPUIDefinitions.COOKIE_NAME) && !c.getValue().isEmpty()) {
localeChain = c.getValue().split("#");
break;
}
if (cookies == null) {
return localeChain;
}
for (final Cookie c : cookies) {
if (c.getName().equals(SPUIDefinitions.COOKIE_NAME) && !c.getValue().isEmpty()) {
localeChain = c.getValue().split("#");
break;
}
}
return localeChain;
@@ -234,6 +236,8 @@ public class HawkbitUI extends DefaultHawkbitUI implements DetachListener {
private class ManagementViewProvider implements ViewProvider {
private static final long serialVersionUID = 1L;
@Override
public String getViewName(final String viewAndParameters) {
return viewProvider.getViewName(getStartView(viewAndParameters));

View File

@@ -158,7 +158,7 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
detailAndUploadLayout.setComponentAlignment(dadw, Alignment.MIDDLE_CENTER);
}
detailAndUploadLayout.setExpandRatio(artifactDetailsLayout, 1.0f);
detailAndUploadLayout.setExpandRatio(artifactDetailsLayout, 1.0F);
detailAndUploadLayout.setSizeFull();
detailAndUploadLayout.addStyleName("group");
detailAndUploadLayout.setSpacing(true);
@@ -177,9 +177,9 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
mainLayout.addComponent(detailAndUploadLayout, 2, 0);
mainLayout.addComponent(deleteActionsLayout, 1, 1);
mainLayout.addComponent(uplaodButtonsLayout, 2, 1);
mainLayout.setRowExpandRatio(0, 1.0f);
mainLayout.setColumnExpandRatio(1, 0.5f);
mainLayout.setColumnExpandRatio(2, 0.5f);
mainLayout.setRowExpandRatio(0, 1.0F);
mainLayout.setColumnExpandRatio(1, 0.5F);
mainLayout.setColumnExpandRatio(2, 0.5F);
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
mainLayout.setComponentAlignment(uplaodButtonsLayout, Alignment.BOTTOM_CENTER);
return mainLayout;
@@ -201,8 +201,8 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private void maximizeSwTable() {
mainLayout.removeComponent(detailAndUploadLayout);
removeOtherComponents();
mainLayout.setColumnExpandRatio(1, 1f);
mainLayout.setColumnExpandRatio(2, 0f);
mainLayout.setColumnExpandRatio(1, 1F);
mainLayout.setColumnExpandRatio(2, 0F);
}
private void minimizeArtifactoryDetails() {
@@ -219,15 +219,15 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
mainLayout.removeComponent(smTableLayout);
detailAndUploadLayout.removeComponent(dadw);
removeOtherComponents();
mainLayout.setColumnExpandRatio(1, 0f);
mainLayout.setColumnExpandRatio(2, 1f);
mainLayout.setColumnExpandRatio(1, 0F);
mainLayout.setColumnExpandRatio(2, 1F);
}
private void addOtherComponents() {
mainLayout.addComponent(deleteActionsLayout, 1, 1);
mainLayout.addComponent(uplaodButtonsLayout, 2, 1);
mainLayout.setColumnExpandRatio(1, 0.5f);
mainLayout.setColumnExpandRatio(2, 0.5f);
mainLayout.setColumnExpandRatio(1, 0.5F);
mainLayout.setColumnExpandRatio(2, 0.5F);
mainLayout.setComponentAlignment(deleteActionsLayout, Alignment.BOTTOM_CENTER);
mainLayout.setComponentAlignment(uplaodButtonsLayout, Alignment.BOTTOM_CENTER);
}
@@ -240,6 +240,8 @@ public class UploadArtifactView extends VerticalLayout implements View, BrowserW
private void hideDropHints() {
UI.getCurrent().addClickListener(new ClickListener() {
private static final long serialVersionUID = 1L;
@Override
public void click(final com.vaadin.event.MouseEvents.ClickEvent event) {
eventBus.publish(this, DragEvent.HIDE_DROP_HINT);

View File

@@ -36,9 +36,9 @@ import org.vaadin.addons.lazyquerycontainer.QueryDefinition;
public class ArtifactBeanQuery extends AbstractBeanQuery<LocalArtifact> {
private static final long serialVersionUID = -333786310371208962L;
private Sort sort = new Sort(Direction.DESC, "filename");
private transient ArtifactManagement artifactManagement = null;
private transient Page<LocalArtifact> firstPagetArtifacts = null;
private Long baseSwModuleId = null;
private transient ArtifactManagement artifactManagement;
private transient Page<LocalArtifact> firstPagetArtifacts;
private Long baseSwModuleId;
/**
* Parametric Constructor.