Skip to content

Commit ad36252

Browse files
Merge pull request #228 from qbicsoftware/development
Prepare 1.1.0
2 parents dcd72bb + bdf6e73 commit ad36252

File tree

7 files changed

+345
-208
lines changed

7 files changed

+345
-208
lines changed

.github/workflows/build_package.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Build Maven Package
33
on:
44
push:
55
branches:
6-
- '*'
6+
- '**'
77
pull_request:
88
# The branches below must be a subset of the branches above
99
branches: [ main, master ]

.github/workflows/run_tests.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Run Maven Tests
33
on:
44
push:
55
branches:
6-
- '*'
6+
- '**'
77
pull_request:
88
# The branches below must be a subset of the branches above
99
branches: [ main, master ]

sample-tracking-status-overview-app/src/main/groovy/life/qbic/portal/sampletracking/components/MainPage.groovy

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ class MainPage extends VerticalLayout {
2020

2121
this.setMargin(false)
2222

23-
this.addComponents(projectLayout, sampleLayout)
23+
this.addComponentsAndExpand(projectLayout, sampleLayout)
2424
sampleLayout.setVisible(false)
25-
2625
listenToProjectSelectionChange()
26+
makeMainPageScrollable()
2727
}
2828

2929
private void listenToProjectSelectionChange() {
@@ -40,4 +40,10 @@ class MainPage extends VerticalLayout {
4040
sampleView.setVisible(!viewModel.projectViewEnabled)
4141
})
4242
}
43+
44+
private void makeMainPageScrollable () {
45+
this.setWidth("100%");
46+
this.setHeight("100%");
47+
this.addStyleName("scrollable-layout")
48+
}
4349
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package life.qbic.portal.sampletracking.components
2+
3+
import com.vaadin.ui.Grid
4+
5+
/**
6+
* <b>Indicate responsive behaviour in UI components</b>
7+
*
8+
* <p>These functions can be used to adapt vaadin grid functionality such as grid column resize-ability or grid responsiveness.</p>
9+
*
10+
* @since 1.0.2
11+
*/
12+
interface Responsive {
13+
14+
/**
15+
* Enables the possibility of manually resizing vaadin columns in a grid
16+
*
17+
* Manual resizing of grid columns in vaadin 8 disables the automatic calculation of column width upon screen resizing,
18+
* which either causes the grid to flow outside of the screen if the column width is increased or leave empty grid space if column width is decreased
19+
*
20+
* @param Grid grid the {@link com.vaadin.ui.Grid}, for which the columns should be resizable
21+
*
22+
* @since 1.0.2
23+
*/
24+
void enableResizableColumns()
25+
26+
/**
27+
* Disables the possibility of manually resizing vaadin columns in a grid
28+
*
29+
* Manual resizing of grid columns in vaadin 8 disables the automatic calculation of column width upon screen resizing,
30+
* which either causes the grid to flow outside of the screen if the column width is increased or leave empty grid space if column width is decreased
31+
*
32+
* @param Grid grid the {@link com.vaadin.ui.Grid}, for which the columns should be non-resizable
33+
*
34+
* @since 1.0.2
35+
*/
36+
void disableResizableColumns()
37+
38+
/**
39+
* Makes sure that the full grid width is used by the columns upon browser resizing
40+
*
41+
* Ensures that the grid width is allocated upon all the columns even if max-width attributes for individual columns are set
42+
* Without this recalculation the unused column width would show as empty space on the right side of the grid
43+
*
44+
* @param Grid grid the {@link com.vaadin.ui.Grid}, which should be responsive to browser window resizing
45+
*
46+
* @since 1.0.2
47+
*/
48+
void enableDynamicResizing()
49+
50+
/**
51+
* Disables adjustment of column width to fill grid width upon screen resizing
52+
*
53+
* The unused column width shows as empty space on the right side of the grid
54+
*
55+
* @param Grid grid the {@link com.vaadin.ui.Grid}, which should not be responsive to browser window resizing
56+
*
57+
* @since 1.0.2
58+
*/
59+
void disableDynamicResizing()
60+
61+
}

sample-tracking-status-overview-app/src/main/groovy/life/qbic/portal/sampletracking/components/projectoverview/ProjectView.groovy

+77-68
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import com.vaadin.server.StreamResource
1010
import com.vaadin.shared.data.sort.SortDirection
1111
import com.vaadin.shared.ui.ContentMode
1212
import com.vaadin.shared.ui.grid.HeightMode
13-
import com.vaadin.ui.Alignment
1413
import com.vaadin.ui.Component
1514
import com.vaadin.ui.Grid
1615
import com.vaadin.ui.TextField
@@ -20,6 +19,7 @@ import groovy.util.logging.Log4j2
2019
import life.qbic.business.project.subscribe.Subscriber
2120
import life.qbic.portal.sampletracking.Constants
2221
import life.qbic.portal.sampletracking.communication.notification.NotificationService
22+
import life.qbic.portal.sampletracking.components.Responsive
2323
import life.qbic.portal.sampletracking.components.ViewModel
2424
import life.qbic.portal.sampletracking.components.projectoverview.download.DownloadProjectController
2525
import life.qbic.portal.sampletracking.components.projectoverview.statusdisplay.SampleCount
@@ -30,7 +30,7 @@ import life.qbic.portal.sampletracking.components.projectoverview.subscribe.Subs
3030
import java.util.function.Consumer
3131

3232
@Log4j2
33-
class ProjectView extends ProjectDesign {
33+
class ProjectView extends ProjectDesign implements Responsive {
3434

3535
private final ViewModel viewModel
3636
private final DownloadProjectController downloadProjectController
@@ -45,13 +45,18 @@ class ProjectView extends ProjectDesign {
4545
this.subscriptionCheckboxFactory = new SubscriptionCheckboxFactory(subscribeProjectController, subscriber, notificationService)
4646
this.downloadProjectController = downloadProjectController
4747
this.notificationService = notificationService
48+
init()
49+
}
50+
51+
private void init(){
4852
bindData()
4953
addClickListener()
5054
setupDownloadButton()
5155
bindManifestToProjectSelection()
52-
makeProjectLayoutResponsive()
53-
makeProjectGridResponsive(projectGrid)
54-
setProjectGridStyles(projectGrid)
56+
setupLayoutResponsiveness()
57+
setProjectGridStyles()
58+
disableResizableColumns()
59+
enableDynamicResizing()
5560
addSorting()
5661
enableUserProjectFiltering()
5762
}
@@ -84,12 +89,7 @@ class ProjectView extends ProjectDesign {
8489

8590
refreshDataProvider()
8691
//specify size of grid and layout
87-
projectGrid.getColumn("ProjectTitle").setExpandRatio(5)
88-
projectGrid.getColumn("SamplesReceived").setExpandRatio(1)
89-
projectGrid.getColumn("SamplesPassedQc").setExpandRatio(1)
90-
projectGrid.getColumn("LibraryPrepFinished").setExpandRatio(1)
91-
projectGrid.getColumn("SampleDataAvailable").setExpandRatio(1)
92-
92+
projectGrid.setWidthFull()
9393
projectGrid.setHeightMode(HeightMode.ROW)
9494

9595
// remove manual sorting - any sorting in the code should probably done before disabling it
@@ -98,81 +98,42 @@ class ProjectView extends ProjectDesign {
9898
}
9999
}
100100

101-
private void setProjectGridStyles(Grid projectGrid) {
102-
setHeaderRowStyle(projectGrid.getDefaultHeaderRow())
103-
addTooltips(projectGrid.getDefaultHeaderRow())
104-
setColumnsStyle(projectGrid)
101+
private void setProjectGridStyles() {
102+
setHeaderRowStyle()
103+
addTooltips()
104+
setColumnsStyle()
105105
}
106106

107-
private void makeProjectLayoutResponsive() {
108-
//The layout has to be set responsive for the media breakpoints to function
109-
this.addStyleName("responsive-project-layout")
110-
this.setResponsive(true)
111-
}
112-
113-
private static void addTooltips(HeaderRow headerRow) {
107+
private void addTooltips() {
108+
HeaderRow headerRow = projectGrid.getDefaultHeaderRow()
114109
headerRow.getCell("Subscription").setDescription("Select a project to get status updates per email.")
115110
headerRow.getCell("SamplesReceived").setDescription("Number of samples that arrived in the processing facility.")
116111
headerRow.getCell("SamplesPassedQc").setDescription("Number of samples that passed quality control.")
117112
headerRow.getCell("LibraryPrepFinished").setDescription("Number of samples where library prep has been finished.")
118113
headerRow.getCell("SampleDataAvailable").setDescription("Number of available raw datasets.")
119114
}
120115

121-
private static void setHeaderRowStyle(HeaderRow headerRow) {
122-
headerRow.getCell("Subscription").setStyleName("project-cell-min-width header-with-tooltip")
123-
headerRow.getCell("SamplesReceived").setStyleName("project-cell-min-width header-with-tooltip")
124-
headerRow.getCell("SamplesPassedQc").setStyleName("project-cell-min-width header-with-tooltip")
125-
headerRow.getCell("LibraryPrepFinished").setStyleName("project-cell-min-width header-with-tooltip")
126-
headerRow.getCell("SampleDataAvailable").setStyleName("project-cell-min-width header-with-tooltip")
127-
headerRow.getCell("ProjectTitle").setStyleName("project-cell-min-width project-title-cell")
128-
headerRow.getCell("ProjectCode").setStyleName("project-cell-min-width")
116+
private void setHeaderRowStyle() {
117+
HeaderRow headerRow = projectGrid.getDefaultHeaderRow()
118+
headerRow.getCell("Subscription").setStyleName("cell-min-width header-with-tooltip")
119+
headerRow.getCell("SamplesReceived").setStyleName("cell-min-width header-with-tooltip")
120+
headerRow.getCell("SamplesPassedQc").setStyleName("cell-min-width header-with-tooltip")
121+
headerRow.getCell("LibraryPrepFinished").setStyleName("cell-min-width header-with-tooltip")
122+
headerRow.getCell("SampleDataAvailable").setStyleName("cell-min-width header-with-tooltip")
123+
headerRow.getCell("ProjectTitle").setStyleName("cell-min-width cell-max-width")
124+
headerRow.getCell("ProjectCode").setStyleName("cell-min-width")
129125
headerRow.getCell("Subscription").setStyleName("subscription-cell")
130126
}
131127

132-
private void setColumnsStyle(Grid projectGrid) {
133-
setComponentAlignment(projectGrid, Alignment.TOP_LEFT)
134-
projectGrid.setWidthFull()
128+
private void setColumnsStyle() {
135129
projectGrid.getColumn("ProjectTitle").setStyleGenerator(projectTitleColumn -> {
136-
return "project-cell-min-width project-title-cell"
130+
return "cell-min-width cell-max-width"
137131
})
138132
projectGrid.getColumn("Subscription").setStyleGenerator(projectTitleColumn -> {
139133
return "subscription-cell"
140134
})
141135
}
142136

143-
private void makeProjectGridResponsive(Grid projectGrid) {
144-
/*
145-
Defines the lower end on how small columns can be resized manually.
146-
Necessary to avoid overlapping the project/samples button with the download manifest button
147-
*/
148-
int browserWindowWidth = 0
149-
int maximumGridWidth = 0
150-
//add padding width for left and right side of grid
151-
final int gridPaddingWidth = 74
152-
addAttachListener(attachedEvent -> {
153-
browserWindowWidth = super.getUI().getPage().getBrowserWindowWidth()
154-
maximumGridWidth = browserWindowWidth - gridPaddingWidth
155-
})
156-
157-
//The grid width should adjust to the resizing preferences of the user
158-
projectGrid.addColumnResizeListener(columnListener -> {
159-
160-
double columnsWidth = 0
161-
projectGrid.getColumns().each { column ->
162-
columnsWidth += column.getWidth()
163-
}
164-
if (columnsWidth <= maximumGridWidth) {
165-
projectGrid.setWidth(Math.floor(columnsWidth).toString())
166-
hotbarLayout.setWidth(Math.floor(columnsWidth).toString())
167-
} else {
168-
//If projectGrid width is bigger than screen adjust grid to max screen size
169-
this.setWidth(maximumGridWidth.toString())
170-
projectGrid.setWidth(maximumGridWidth.toString())
171-
hotbarLayout.setWidth(maximumGridWidth.toString())
172-
}
173-
})
174-
}
175-
176137
private void addSorting(){
177138
sort.setItems(["Newest Changes", "Oldest Changes", "Subscribed", "Not Subscribed"])
178139

@@ -338,7 +299,7 @@ class ProjectView extends ProjectDesign {
338299
})
339300
}
340301

341-
void enableUserProjectFiltering() {
302+
private void enableUserProjectFiltering() {
342303
TextField searchField = this.searchField
343304
searchField.addValueChangeListener({
344305
if (it.getValue()) {
@@ -354,4 +315,52 @@ class ProjectView extends ProjectDesign {
354315
DataProvider<ProjectSummary, ?> dataProvider = this.projectGrid.getDataProvider()
355316
return dataProvider
356317
}
318+
319+
/**
320+
* Adds responsiveness to an abstractComponent
321+
*
322+
* <p>This applies the css class style .responsive-grid-layout to the provided abstractComponent allowing it to display it's content in a responsive manner</p>
323+
*
324+
* @param AbstractComponent the {@link com.vaadin.ui.AbstractComponent}, where the css style and responsiveness should be added
325+
* @since 1.0.2
326+
*/
327+
private void setupLayoutResponsiveness() {
328+
this.addStyleName("responsive-grid-layout")
329+
this.setWidthFull()
330+
}
331+
332+
@Override
333+
void enableResizableColumns() {
334+
projectGrid.getColumns().each { it ->
335+
{
336+
it.setResizable(true)
337+
}
338+
}
339+
}
340+
341+
@Override
342+
void disableResizableColumns() {
343+
projectGrid.getColumns().each { it ->
344+
{
345+
it.setResizable(false)
346+
}
347+
}
348+
}
349+
350+
@Override
351+
void enableDynamicResizing() {
352+
projectGrid.addAttachListener(attachEvent -> {
353+
projectGrid.getUI().getCurrent().getPage().addBrowserWindowResizeListener(resizeEvent -> {
354+
projectGrid.recalculateColumnWidths()
355+
})
356+
})
357+
}
358+
359+
@Override
360+
void disableDynamicResizing() {
361+
Collection<AttachListener> attachListeners = projectGrid.getListeners(AttachListener) as Collection<AttachListener>
362+
attachListeners.each {attachListener -> {
363+
projectGrid.removeAttachListener(attachListener)
364+
}}
365+
}
357366
}

0 commit comments

Comments
 (0)