Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
stardat
stardat-ddieditor
Commits
e96c3c18
Commit
e96c3c18
authored
Nov 12, 2020
by
Nugraha, Sigit
Browse files
Fis StudySelection grids select
parent
d83acd89
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gesis/stardat/DDIEditor.java
View file @
e96c3c18
package
org.gesis.stardat
;
import
java.time.LocalDate
;
import
java.util.*
;
import
com.vaadin.annotations.Theme
;
import
com.vaadin.annotations.Title
;
import
com.vaadin.annotations.Widgetset
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.Navigator
;
import
com.vaadin.navigator.ViewChangeListener
;
import
com.vaadin.server.Page
;
import
com.vaadin.server.VaadinRequest
;
import
com.vaadin.server.VaadinSession
;
import
com.vaadin.spring.annotation.SpringUI
;
import
com.vaadin.spring.navigator.SpringViewProvider
;
import
com.vaadin.ui.*
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.themes.ValoTheme
;
import
org.gesis.logger.GesisLogEvent
;
import
org.gesis.stardat.config.Constants
;
import
org.gesis.stardat.entity.*
;
...
...
@@ -45,20 +56,8 @@ import org.vaadin.spring.i18n.support.Translatable;
import
org.vaadin.spring.i18n.support.TranslatableUI
;
import
org.vaadin.viritin.button.MButton
;
import
com.vaadin.annotations.Theme
;
import
com.vaadin.annotations.Title
;
import
com.vaadin.annotations.Widgetset
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.Navigator
;
import
com.vaadin.navigator.ViewChangeListener
;
import
com.vaadin.server.Page
;
import
com.vaadin.server.VaadinRequest
;
import
com.vaadin.server.VaadinSession
;
import
com.vaadin.spring.annotation.SpringUI
;
import
com.vaadin.spring.navigator.SpringViewProvider
;
import
com.vaadin.ui.*
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.themes.ValoTheme
;
import
java.time.LocalDate
;
import
java.util.*
;
/**
* @author klascr
...
...
@@ -705,10 +704,8 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
public
void
setCurrentInstrument
(
Instrument
currentInstrument
)
{
this
.
currentInstrument
=
currentInstrument
;
if
(
currentInstrument
!=
null
)
{
setStudyTitle
(
currentInstrument
.
getLabel
(),
null
);
}
}
public
String
getUser
()
{
...
...
src/main/java/org/gesis/stardat/helper/QuestionRatingComponent.java
View file @
e96c3c18
package
org.gesis.stardat.helper
;
import
java.util.Locale
;
import
org.gesis.stardat.entity.DDIElement
;
import
org.gesis.stardat.management.ManagementService
;
import
org.gesis.stardat.management.dto.StardatObjectDTO
;
...
...
@@ -17,6 +15,8 @@ import org.vaadin.teemu.ratingstars.RatingStars;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.ui.*
;
import
java.util.Locale
;
public
class
QuestionRatingComponent
extends
HorizontalLayout
implements
Translatable
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
QuestionRatingComponent
.
class
);
...
...
src/main/java/org/gesis/stardat/service/EntityCreationService.java
View file @
e96c3c18
package
org.gesis.stardat.service
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.function.Consumer
;
import
java.util.stream.Collectors
;
import
com.vaadin.ui.UI
;
import
org.gesis.stardat.DDIEditor
;
import
org.gesis.stardat.ddiflatdb.client.DDIStore
;
import
org.gesis.stardat.ddiflatdb.client.Document
;
...
...
@@ -19,7 +14,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.Scope
;
import
org.springframework.stereotype.Component
;
import
com.vaadin.ui.UI
;
import
java.lang.reflect.InvocationTargetException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
import
java.util.function.Consumer
;
import
java.util.stream.Collectors
;
@Component
@Scope
(
value
=
"singleton"
)
...
...
src/main/java/org/gesis/stardat/ui/view/study/StudySelectionView.java
View file @
e96c3c18
package
org.gesis.stardat.ui.view.study
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
import
com.vaadin.data.provider.ListDataProvider
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.View
;
import
com.vaadin.navigator.ViewChangeListener.ViewChangeEvent
;
import
com.vaadin.shared.ui.ContentMode
;
import
com.vaadin.spring.annotation.SpringView
;
import
com.vaadin.spring.annotation.UIScope
;
import
com.vaadin.ui.*
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.themes.ValoTheme
;
import
org.gesis.logger.GesisLogEvent
;
import
org.gesis.stardat.DDIEditor
;
import
org.gesis.stardat.VaadinGESISLogger
;
...
...
@@ -12,7 +17,6 @@ import org.gesis.stardat.domain.enumeration.StudyGroupRole;
import
org.gesis.stardat.entity.Instrument
;
import
org.gesis.stardat.entity.StudyGroup
;
import
org.gesis.stardat.entity.StudyUnit
;
import
org.gesis.stardat.events.LanguageSwitchedEvent
;
import
org.gesis.stardat.helper.TriggerableWindowMaster
;
import
org.gesis.stardat.security.DDIEditorSecurityUtils
;
import
org.gesis.stardat.security.oauth2.StardatOAuth2User
;
...
...
@@ -28,22 +32,13 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Lazy
;
import
org.vaadin.spring.events.EventBus
;
import
org.vaadin.spring.events.EventScope
;
import
org.vaadin.spring.events.annotation.EventBusListenerMethod
;
import
org.vaadin.spring.i18n.support.Translatable
;
import
org.vaadin.viritin.button.MButton
;
import
org.vaadin.viritin.layouts.MHorizontalLayout
;
import
com.vaadin.data.provider.ListDataProvider
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.View
;
import
com.vaadin.navigator.ViewChangeListener.ViewChangeEvent
;
import
com.vaadin.shared.ui.ContentMode
;
import
com.vaadin.spring.annotation.SpringView
;
import
com.vaadin.spring.annotation.UIScope
;
import
com.vaadin.ui.*
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.themes.ValoTheme
;
import
javax.annotation.PostConstruct
;
import
java.util.*
;
import
java.util.stream.Collectors
;
//import org.apache.fop.render.awt.viewer.PreviewPanel;
...
...
@@ -188,17 +183,28 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
List
<
StudyGroup
>
groups
=
getGroups
();
groupsGrid
.
setItems
(
groups
);
if
(
!
groups
.
isEmpty
()
)
groupsGrid
.
select
(
groups
.
get
(
0
)
);
updateHtmlPreview
();
if
(
!
groups
.
isEmpty
()
)
{
refreshStudy
(
groups
.
get
(
0
));
}
gesisLogger
.
createAndStoreDisplayEvent
(
VIEW_NAME
,
GesisLogEvent
.
DISPLAY_EVENT_TYPE_PAGE_SHOWN
,
""
);
updateMessageStrings
(
getLocale
()
);
checkStudyGroupActionRights
();
}
private
void
refreshStudy
(
StudyGroup
studyGroup
)
{
groupsGrid
.
select
(
studyGroup
);
studies
=
getStudies
(
studyGroup
);
getStudyUnitGrid
().
configure
(
studies
);
getDDIEditor
().
setCurrentStudyGroup
(
studyGroup
);
checkStudyGroupActionRights
();
if
(
!
studies
.
isEmpty
()
)
{
studyUnitGrid
.
select
(
studies
.
get
(
0
));
setCurrentStudyInformation
(
studies
.
get
(
0
));
}
}
protected
boolean
authorizeViewAccess
()
{
if
(
!
DDIEditorSecurityUtils
.
isAuthenticated
()
)
...
...
@@ -237,18 +243,6 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
return
studiesByGroup
;
}
/**
* Event (Bus) fires Method when Event is invoked. Methods invoke through Method in DDIEditor
* -Set WebLanguage
*
* @param event
*/
@EventBusListenerMethod
(
scope
=
EventScope
.
UI
)
private
void
languageChange
(
LanguageSwitchedEvent
event
)
{
updateMessageStrings
(
getLocale
()
);
}
public
DDIEditor
getDDIEditor
()
{
return
(
DDIEditor
)
UI
.
getCurrent
();
...
...
@@ -267,18 +261,14 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
hLayout
.
setSizeFull
();
groupsGrid
.
setDescription
(
I18N
.
get
(
"SelectionView.Group.Table.description"
)
);
getStudyUnitGrid
().
setDescription
(
I18N
.
get
(
"SelectionView.Study.Table.description"
)
);
groupsGrid
.
add
Selection
Listener
(
e
->
groupsGrid
.
add
ItemClick
Listener
(
e
->
{
if
(
groupsGrid
.
getSelectedItems
()
!=
null
&&
!
groupsGrid
.
getSelectedItems
().
isEmpty
()
)
{
studies
=
getStudies
(
groupsGrid
.
getSelectedItems
().
iterator
().
next
()
);
getStudyUnitGrid
().
configure
(
studies
);
getDDIEditor
().
setCurrentStudyGroup
(
groupsGrid
.
getSelectedItems
().
iterator
().
next
()
);
checkStudyGroupActionRights
();
}
refreshStudy
(
e
.
getItem
()
);
}
);
groupsGrid
.
addSelectionListener
(
e
->
{
if
(
getDDIEditor
().
getCurrentStudyGroup
()
!=
null
)
groupsGrid
.
select
(
getDDIEditor
().
getCurrentStudyGroup
());
});
getStudyUnitGrid
().
addItemClickListener
(
dE
->
{
...
...
@@ -311,13 +301,18 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
checkQuestionnaireActionRights
();
}
}
);
questionnairesGrid
.
addSelectionListener
(
e
->
{
if
(
getDDIEditor
().
getCurrentInstrument
()
!=
null
)
questionnairesGrid
.
select
(
getDDIEditor
().
getCurrentInstrument
());
});
previewPanel
=
new
Panel
();
previewPanel
.
setSizeUndefined
();
previewPanel
.
addStyleName
(
" previewMargin"
);
previewPanel
.
setWidth
(
"98%"
);
previewPanel
.
setHeight
(
750
,
Unit
.
PIXELS
);
htmlPreview
.
setValue
(
"<b>Please select a study to show preview
..
.</b>"
);
htmlPreview
.
setValue
(
"<b>Please select a study
with a questionnaire
to show preview.</b>"
);
htmlPreview
.
setContentMode
(
ContentMode
.
HTML
);
htmlPreview
.
setSizeUndefined
();
htmlPreview
.
setWidth
(
100
,
Unit
.
PERCENTAGE
);
...
...
@@ -474,14 +469,15 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
if
(
instruments
!=
null
&&
!
instruments
.
isEmpty
()
)
{
questionnairesGrid
.
select
(
instruments
.
get
(
0
));
setCurrentInstrument
(
instruments
.
get
(
0
));
}
else
{
htmlPreview
.
setValue
(
"<b>"
+
I18N
.
get
(
"SelectionView.Study.panel.description.preview"
)
+
"<b>"
);
}
}
private
void
setCurrentInstrument
(
Instrument
instrument
)
{
getDDIEditor
().
setCurrentInstrument
(
instrument
);
if
(
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
()
!=
null
)
updateHtmlPreview
();
updateHtmlPreview
();
}
private
void
initMenuBar
()
...
...
@@ -527,7 +523,6 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
editQustionnaire
.
setVisible
(
false
);
deleteQuestionnaire
.
setVisible
(
false
);
cloneQuestionnaire
.
setVisible
(
false
);
}
private
void
studyGroupContact
()
{
...
...
@@ -634,21 +629,17 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
{
if
(
getDDIEditor
().
getCurrentStudyUnit
()
!=
null
)
{
String
htmlDiv
=
getDDIEditor
().
getCurrentStudyUnit
().
createPreviewDiv
();
htmlDiv
=
recodeI18N
(
htmlDiv
);
mode
=
"study"
;
StudyUnit
selectedStudy
=
getDDIEditor
().
getCurrentStudyUnit
();
ArrayList
<
String
>
availableLanguages
=
null
;
availableLanguages
=
selectedStudy
.
getAvailableLanguages
();
availableLanguages
.
forEach
(
lang
->
{
htmlPreview
.
setValue
(
exportService
.
generateStudyPreviewByTemplate
(
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
lang
,
mode
));
}
);
if
(
!
availableLanguages
.
isEmpty
()
)
{
htmlPreview
.
setValue
(
exportService
.
generateStudyPreviewByTemplate
(
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
availableLanguages
.
get
(
0
)
,
mode
));
}
}
}
...
...
@@ -777,10 +768,6 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
entityService
.
clearCacheForStudyGroupsByGroupName
(
groupsGrid
.
getSelectedItems
().
iterator
().
next
().
getLabel
()
);
getStudyUnitGrid
().
removeStudy
(
studyToBeDeleted
);
if
(
!
getStudyUnitGrid
().
getStudyUnits
().
isEmpty
()
)
getStudyUnitGrid
().
select
(
studies
.
get
(
0
)
);
enter
(
null
);
getDDIEditor
().
processingSucceeded
();
break
;
...
...
@@ -807,8 +794,6 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
@Override
public
void
updateMessageStrings
(
Locale
locale
)
{
htmlPreview
.
setValue
(
"<b>"
+
I18N
.
get
(
"SelectionView.Study.panel.description.preview"
)
+
"<b>"
);
newQuestionnaireButton
.
setCaption
(
I18N
.
get
(
SELECTION_VIEW_STUDY_BUTTON_NEW_QUESTIONNAIRE
)
);
newStudyButton
.
setCaption
(
I18N
.
get
(
SELECTION_VIEW_STUDY_BUTTON_NEW_STUDY
)
);
cloneQuestionnaireButton
.
setCaption
(
I18N
.
get
(
SELECTION_VIEW_STUDY_BUTTON_CLONE_QUESTIONNAIRE
)
);
...
...
@@ -853,6 +838,13 @@ public class StudySelectionView extends VerticalLayout implements View, Translat
getStudyUnitGrid
().
updateMessageStrings
();
// TODO: fix for multiple call with Enter method
if
(
getDDIEditor
().
getCurrentInstrument
()
!=
null
)
{
updateHtmlPreview
();
}
else
{
htmlPreview
.
setValue
(
"<b>"
+
I18N
.
get
(
"SelectionView.Study.panel.description.preview"
)
+
"<b>"
);
}
}
public
StudyUnitGrid
getStudyUnitGrid
()
...
...
src/main/resources/locale_old/messages_de_DE.properties
View file @
e96c3c18
...
...
@@ -119,7 +119,7 @@ Login.label.password = Passwort
##StudySelectionView
SelectionView.Study.Table.label.title
=
Wähle eine Studie
SelectionView.Study.panel.description.preview
=
Wähle eine Studie um eine Vorschau zu generieren
SelectionView.Study.panel.description.preview
=
Wähle eine Studie
mit einem Fragebogen
um eine Vorschau zu generieren
SelectionView.Study.Notification.description.unselected
=
Wählen Sie bitte eine Studie aus um fortzufahren
SelectionView.Study.button.editQuestionnaire
=
Fragebogen editieren2
...
...
src/main/resources/locale_old/messages_en.properties
View file @
e96c3c18
...
...
@@ -92,7 +92,7 @@ Login.label.password = Password
##StudySelectionView
SelectionView.Group.Table.label.title
=
Select a study group:
SelectionView.Study.Table.label.title
=
Select a study:
SelectionView.Study.panel.description.preview
=
Please select a study to show preview
...
SelectionView.Study.panel.description.preview
=
<b>
Please select a study
with a questionnaire
to show preview
.</b>
SelectionView.Study.Table.Column.Header.name
=
Name
SelectionView.Study.Notification.description.unselected
=
Please select a study to continue ...
...
...
src/main/resources/org/vaadin/spring/i18n/messages_en.properties
View file @
e96c3c18
...
...
@@ -126,7 +126,7 @@ Login.label.password = Password
##StudySelectionView
SelectionView.Group.Table.label.title
=
Select a study group:
SelectionView.Study.Table.label.title
=
Select a study:
SelectionView.Study.panel.description.preview
=
Please select a study to show preview
..
.
SelectionView.Study.panel.description.preview
=
Please select a study
with a questionnaire
to show preview.
SelectionView.Study.Table.Column.Header.name
=
Name
SelectionView.Study.Notification.description.unselected
=
Please select a study to continue ...
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment