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
932d4fbb
Commit
932d4fbb
authored
Nov 16, 2020
by
Alexander Mühlbauer
Browse files
Merge branch 'master' into 407-refactor-ddielement-usage
parents
7c7e33a0
f1bbed46
Changes
26
Expand all
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/gesis/stardat/DDIEditor.java
View file @
932d4fbb
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.*
;
...
...
@@ -16,6 +27,7 @@ import org.gesis.stardat.security.oauth2.StardatOAuth2User;
import
org.gesis.stardat.service.*
;
import
org.gesis.stardat.service.db.UserData
;
import
org.gesis.stardat.service.db.UserDataRepository
;
import
org.gesis.stardat.service.dto.GroupDTO
;
import
org.gesis.stardat.ui.QuestionSearchView
;
import
org.gesis.stardat.ui.QuestionnaireEditorView
;
import
org.gesis.stardat.ui.QuestionnaireOverView
;
...
...
@@ -44,21 +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.Button.ClickEvent
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.themes.ValoTheme
;
import
java.time.LocalDate
;
import
java.util.*
;
/**
* @author klascr
...
...
@@ -132,6 +131,9 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
@Autowired
private
ElementManager
elementManager
;
@Autowired
private
GroupService
groupService
;
// @Autowired
// ManagementRestClient managementRestClient;
...
...
@@ -151,6 +153,7 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
private
StudyUnit
currentStudyUnit
;
private
Instrument
currentInstrument
;
private
Variable
currentSelectedVariable
;
private
GroupDTO
currentGroupDTO
;
private
MenuBar
menuBar
=
new
MenuBar
();
private
MenuItem
studySelectionMenuItem
;
...
...
@@ -170,6 +173,8 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
private
MButton
languageButton
=
new
MButton
();
private
Button
logout
=
new
Button
(
"Logout"
);
private
Button
login
=
new
Button
(
"Login"
);
private
Button
contactButton
=
new
Button
(
"Contact"
);
private
Button
helpButton
=
new
Button
(
"Help"
);
@Autowired
public
UserDataRepository
userDataRepository
;
...
...
@@ -258,6 +263,17 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
});
logout
.
setStyleName
(
ValoTheme
.
BUTTON_LINK
);
contactButton
.
addClickListener
(
e
->
{
getUI
().
getPage
()
.
setLocation
(
"https://www.gesis.org/kontakt"
);
});
contactButton
.
setStyleName
(
ValoTheme
.
BUTTON_LINK
);
helpButton
.
addClickListener
(
e
->
{
getUI
().
getPage
()
.
setLocation
(
"https://www.gesis.org/hilfe"
);
});
helpButton
.
setStyleName
(
ValoTheme
.
BUTTON_LINK
);
// login button
login
.
addClickListener
(
e
->
{
getUI
().
getPage
()
...
...
@@ -313,6 +329,10 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
layout
.
addComponent
(
logout
,
"logout"
);
layout
.
addComponent
(
contactButton
,
"contact"
);
layout
.
addComponent
(
helpButton
,
"help"
);
layout
.
addComponent
(
languageButton
,
"top"
);
setContent
(
layout
);
...
...
@@ -701,10 +721,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
()
{
...
...
@@ -813,6 +831,9 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
@Override
public
void
updateMessageStrings
(
Locale
locale
)
{
contactButton
.
setCaption
(
i18n
.
get
(
"menuItem.contact"
));
helpButton
.
setCaption
(
i18n
.
get
(
"menuItem.help"
));
logout
.
setCaption
(
i18n
.
get
(
"menuItem.logout"
));
languageButton
.
setCaption
(
i18n
.
get
(
"button.language.name"
));
studySelectionMenuItem
.
setText
(
i18n
.
get
(
MENU_ITEM
+
StudySelectionView
.
VIEW_NAME
));
userManagementMenutItem
.
setText
(
i18n
.
get
(
MENU_ITEM
+
AdminView
.
VIEW_NAME
));
...
...
@@ -855,9 +876,14 @@ public class DDIEditor extends TranslatableUI implements TriggerableWindowMaster
public
void
setCurrentStudyGroup
(
StudyGroup
studyGroup
)
{
this
.
currentStudyGroup
=
studyGroup
;
this
.
currentGroupDTO
=
groupService
.
findByGroupReference
(
this
.
currentStudyGroup
.
getId
());
}
public
StudyGroup
getCurrentStudyGroup
()
{
return
currentStudyGroup
;
}
public
GroupDTO
getCurrentGroup
()
{
return
currentGroupDTO
;
}
}
src/main/java/org/gesis/stardat/helper/QuestionRatingComponent.java
View file @
932d4fbb
...
...
@@ -9,12 +9,15 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.vaadin.spring.events.EventBus
;
import
org.vaadin.spring.events.EventBus.UIEventBus
;
import
org.vaadin.spring.i18n.support.Translatable
;
import
org.vaadin.teemu.ratingstars.RatingStars
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.ui.*
;
public
class
QuestionRatingComponent
extends
HorizontalLayout
import
java.util.Locale
;
public
class
QuestionRatingComponent
extends
HorizontalLayout
implements
Translatable
{
private
Logger
logger
=
LoggerFactory
.
getLogger
(
QuestionRatingComponent
.
class
);
...
...
@@ -62,4 +65,11 @@ public class QuestionRatingComponent extends HorizontalLayout
:
String
.
valueOf
(
stardatObjectDTO
.
getNoOfRating
()
)
);
userRating
.
setReadOnly
(
true
);
}
@Override
public
void
updateMessageStrings
(
Locale
locale
)
{
if
(
stardatObjectDTO
!=
null
)
numberOfRatings
.
setValue
(
stardatObjectDTO
.
getNoOfRating
()
==
0
?
I18N
.
get
(
"QuestionRatingComponent.no.rating"
)
:
String
.
valueOf
(
stardatObjectDTO
.
getNoOfRating
()
)
);
}
}
src/main/java/org/gesis/stardat/repository/GroupRepository.java
View file @
932d4fbb
...
...
@@ -19,4 +19,5 @@ public interface GroupRepository extends JpaRepository<Group, Long> {
@Query
(
"select g from Group g where g.name LIKE %:keyword% OR g.description LIKE %:keyword%"
)
public
List
<
Group
>
findAll
(
@Param
(
"keyword"
)
String
keyword
);
List
<
Group
>
findAllByGroupReference
(
String
groupReference
);
}
src/main/java/org/gesis/stardat/service/EntityCreationService.java
View file @
932d4fbb
This diff is collapsed.
Click to expand it.
src/main/java/org/gesis/stardat/service/ExportService.java
View file @
932d4fbb
...
...
@@ -6,6 +6,7 @@ import org.gesis.stardat.entity.*;
import
org.gesis.stardat.helper.ExportQuestion
;
import
org.gesis.stardat.helper.QuestionGridRow
;
import
org.gesis.stardat.helper.StudyPreview
;
import
org.gesis.stardat.service.dto.GroupDTO
;
import
org.gesis.stardat.ui.utils.PreviewUtils
;
import
org.springframework.stereotype.Service
;
import
org.thymeleaf.spring5.SpringTemplateEngine
;
...
...
@@ -44,28 +45,29 @@ public class ExportService
this
.
entityService
=
entityService
;
}
public
String
generatePreviewByTemplate
(
QuestionGridRow
questionRow
,
StudyUnit
studyUnit
,
Instrument
instrument
,
String
lang
,
String
mode
)
public
String
generatePreviewByTemplate
(
QuestionGridRow
questionRow
,
StudyUnit
studyUnit
,
Instrument
instrument
,
GroupDTO
currentGroup
,
String
lang
,
String
mode
)
{
if
(
mode
.
equals
(
"question"
))
{
return
generateThymeleafPreview
(
fillExportQuestion
(
questionRow
,
studyUnit
,
instrument
,
lang
),
mode
);
return
generateThymeleafPreview
(
fillExportQuestion
(
questionRow
,
studyUnit
,
instrument
,
lang
),
currentGroup
,
mode
);
}
else
{
return
generateThymeleafPreview
(
fillExportStatement
(
questionRow
,
studyUnit
,
instrument
,
lang
),
mode
);
return
generateThymeleafPreview
(
fillExportStatement
(
questionRow
,
studyUnit
,
instrument
,
lang
),
currentGroup
,
mode
);
}
}
public
String
generateStudyPreviewByTemplate
(
StudyUnit
studyUnit
,
Instrument
instrument
,
String
lang
,
String
mode
)
public
String
generateStudyPreviewByTemplate
(
StudyUnit
studyUnit
,
Instrument
instrument
,
GroupDTO
currentGroup
,
String
lang
,
String
mode
)
{
return
generateThymeleafPreviewForStudy
(
fillExportStudy
(
studyUnit
,
instrument
,
lang
),
mode
);
return
generateThymeleafPreviewForStudy
(
prepareStudyPreview
(
studyUnit
,
instrument
),
currentGroup
,
mode
);
}
private
String
generateThymeleafPreview
(
ExportQuestion
eq
,
String
mode
)
private
String
generateThymeleafPreview
(
ExportQuestion
eq
,
GroupDTO
currentGroup
,
String
mode
)
{
String
filledTemplate
=
null
;
org
.
thymeleaf
.
context
.
Context
ctx
=
new
org
.
thymeleaf
.
context
.
Context
();
ctx
.
setVariable
(
"q"
,
eq
);
if
(
currentGroup
.
getHeaderImage
()
!=
null
)
{
ctx
.
setVariable
(
"logo"
,
currentGroup
.
getHeaderImage
()
);
}
if
(
mode
.
equals
(
"question"
))
{
filledTemplate
=
templateEngine
.
process
(
"html/export_"
+
(
I18N
.
getCurrentUILocale
().
equals
(
Locale
.
GERMAN
)
?
"de"
:
"en"
)
+
"_html"
,
ctx
);
...
...
@@ -79,11 +81,14 @@ public class ExportService
return
onlyTemplateContent
;
}
private
String
generateThymeleafPreviewForStudy
(
StudyPreview
eq
,
String
mode
)
private
String
generateThymeleafPreviewForStudy
(
StudyPreview
eq
,
GroupDTO
currentGroup
,
String
mode
)
{
String
filledTemplate
=
null
;
org
.
thymeleaf
.
context
.
Context
ctx
=
new
org
.
thymeleaf
.
context
.
Context
();
ctx
.
setVariable
(
"q"
,
eq
);
if
(
currentGroup
.
getHeaderImage
()
!=
null
)
{
ctx
.
setVariable
(
"logo"
,
currentGroup
.
getHeaderImage
()
);
}
if
(
mode
.
equals
(
"study"
))
{
filledTemplate
=
templateEngine
.
process
(
"html/export_"
+
(
I18N
.
getCurrentUILocale
().
equals
(
Locale
.
GERMAN
)
?
"de"
:
"en"
)
+
"_html"
+
"_study"
,
ctx
);
...
...
@@ -116,14 +121,7 @@ public class ExportService
return
eq
;
}
private
StudyPreview
fillExportStudy
(
StudyUnit
studyUnit
,
Instrument
instrument
,
String
lang
)
{
StudyPreview
eq
=
prepareStudyPreview
(
studyUnit
,
instrument
);
return
eq
;
}
private
ExportQuestion
fillExportStatement
(
QuestionGridRow
questionRow
,
StudyUnit
studyUnit
,
Instrument
instrument
,
String
lang
)
{
ExportQuestion
eq
=
prepareExportQuestion
(
studyUnit
,
instrument
);
...
...
src/main/java/org/gesis/stardat/service/GroupService.java
View file @
932d4fbb
...
...
@@ -32,6 +32,14 @@ public interface GroupService {
*/
GroupDTO
findOne
(
Long
id
);
/**
* Get the "groupReference" group.
*
* @param groupReference the id of the entity
* @return the entity
*/
GroupDTO
findByGroupReference
(
String
groupReference
);
/**
* Delete the "id" group.
*
...
...
src/main/java/org/gesis/stardat/service/impl/GroupServiceImpl.java
View file @
932d4fbb
...
...
@@ -74,6 +74,15 @@ public class GroupServiceImpl implements GroupService {
return
groupMapper
.
toDto
(
group
);
}
@Override
public
GroupDTO
findByGroupReference
(
String
groupReference
)
{
log
.
debug
(
"Request to get Group by reference: {}"
,
groupReference
);
List
<
Group
>
groups
=
groupRepository
.
findAllByGroupReference
(
groupReference
);
GroupDTO
groupDTO
=
groups
.
stream
().
map
(
g
->
groupMapper
.
toDto
(
g
)).
findFirst
().
orElse
(
null
);
return
groupDTO
;
}
/**
* Delete the group by id.
*
...
...
src/main/java/org/gesis/stardat/ui/QuestionnaireEditorView.java
View file @
932d4fbb
package
org.gesis.stardat.ui
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Optional
;
import
java.util.Set
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.View
;
import
com.vaadin.navigator.ViewChangeListener.ViewChangeEvent
;
import
com.vaadin.shared.Registration
;
import
com.vaadin.shared.data.sort.SortDirection
;
import
com.vaadin.shared.ui.ContentMode
;
import
com.vaadin.spring.annotation.SpringView
;
import
com.vaadin.spring.annotation.ViewScope
;
import
com.vaadin.ui.*
;
import
com.vaadin.ui.Grid.SelectionMode
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.components.grid.HeaderRow
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.utils.URLEncodedUtils
;
import
org.gesis.logger.GesisLogEvent
;
...
...
@@ -23,19 +20,7 @@ import org.gesis.stardat.VaadinGESISLogger;
import
org.gesis.stardat.ddiflatdb.client.DDIStore
;
import
org.gesis.stardat.domain.enumeration.Language
;
import
org.gesis.stardat.domain.enumeration.StudyGroupRole
;
import
org.gesis.stardat.entity.CodeList
;
import
org.gesis.stardat.entity.Concept
;
import
org.gesis.stardat.entity.ControlConstructReference
;
import
org.gesis.stardat.entity.DDIElement
;
import
org.gesis.stardat.entity.Instrument
;
import
org.gesis.stardat.entity.InterviewerInstruction
;
import
org.gesis.stardat.entity.MultipleQuestionItem
;
import
org.gesis.stardat.entity.QuestionConstruct
;
import
org.gesis.stardat.entity.QuestionItem
;
import
org.gesis.stardat.entity.Sequence
;
import
org.gesis.stardat.entity.Statement
;
import
org.gesis.stardat.entity.StudyUnit
;
import
org.gesis.stardat.entity.Variable
;
import
org.gesis.stardat.entity.*
;
import
org.gesis.stardat.events.EditorEvent
;
import
org.gesis.stardat.events.ResourceDataChangedEvent
;
import
org.gesis.stardat.helper.QuestionGridRow
;
...
...
@@ -53,13 +38,7 @@ import org.gesis.stardat.report.QuestionListData;
import
org.gesis.stardat.report.ReportRestClient
;
import
org.gesis.stardat.security.DDIEditorSecurityUtils
;
import
org.gesis.stardat.security.oauth2.StardatOAuth2User
;
import
org.gesis.stardat.service.CachingDDIFlatDBRestClient
;
import
org.gesis.stardat.service.ConfigurationService
;
import
org.gesis.stardat.service.EntityCreationService
;
import
org.gesis.stardat.service.ExportService
;
import
org.gesis.stardat.service.I18N
;
import
org.gesis.stardat.service.QuestionCacheService
;
import
org.gesis.stardat.service.VariableService
;
import
org.gesis.stardat.service.*
;
import
org.gesis.stardat.ui.component.QuestionGrid
;
import
org.gesis.stardat.ui.component.TagTokenField
;
import
org.gesis.stardat.ui.view.instruction.ManageInterviewerInstructionWindow
;
...
...
@@ -74,11 +53,7 @@ import org.gesis.stardat.ui.view.questionnaire.OrderQuestionsWindow;
import
org.gesis.stardat.ui.view.questionnaire.QuestionsConfirmWindow
;
import
org.gesis.stardat.ui.view.statement.StatementTranslateWindow
;
import
org.gesis.stardat.ui.view.study.StudySelectionView
;
import
org.gesis.stardat.ui.windows.BasketWindow
;
import
org.gesis.stardat.ui.windows.CommentWindow
;
import
org.gesis.stardat.ui.windows.ManageAnswerCategorieWindow
;
import
org.gesis.stardat.ui.windows.StatementWindow
;
import
org.gesis.stardat.ui.windows.VariableSetWindow
;
import
org.gesis.stardat.ui.windows.*
;
import
org.gesis.stardat.utils.QuestionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -100,27 +75,11 @@ import org.vaadin.viritin.layouts.MCssLayout;
import
org.vaadin.viritin.layouts.MPanel
;
import
org.vaadin.viritin.layouts.MVerticalLayout
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.navigator.View
;
import
com.vaadin.navigator.ViewChangeListener.ViewChangeEvent
;
import
com.vaadin.shared.Registration
;
import
com.vaadin.shared.data.sort.SortDirection
;
import
com.vaadin.shared.ui.ContentMode
;
import
com.vaadin.spring.annotation.SpringView
;
import
com.vaadin.spring.annotation.ViewScope
;
import
com.vaadin.ui.Alignment
;
import
com.vaadin.ui.Button
;
import
com.vaadin.ui.Component
;
import
com.vaadin.ui.Grid.SelectionMode
;
import
com.vaadin.ui.HorizontalLayout
;
import
com.vaadin.ui.HorizontalSplitPanel
;
import
com.vaadin.ui.MenuBar
;
import
com.vaadin.ui.MenuBar.MenuItem
;
import
com.vaadin.ui.Notification
;
import
com.vaadin.ui.UI
;
import
com.vaadin.ui.VerticalLayout
;
import
com.vaadin.ui.Window
;
import
com.vaadin.ui.components.grid.HeaderRow
;
import
javax.annotation.PostConstruct
;
import
java.nio.charset.StandardCharsets
;
import
java.util.*
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
@ViewScope
@SpringView
(
name
=
QuestionnaireEditorView
.
VIEW_NAME
)
...
...
@@ -1155,16 +1114,22 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
{
questionGrid
.
getCurrentSelectedItems
().
forEach
(
item
->
{
final
String
SOURCE_LANG
=
item
.
getObject
().
getLanguage
();
String
SOURCE_LANG
=
item
.
getObject
().
getLanguage
();
ArrayList
<
String
>
availableLanguages
=
null
;
if
(
item
.
getObject
().
getType
().
equals
(
DDIElement
.
STATEMENT
)
)
{
if
(
SOURCE_LANG
.
contains
(
"en"
))
translateQuestion
.
setVisible
(
false
);
availableLanguages
=
((
Statement
)
item
.
getObject
()).
getAvailableLanguages
();
}
else
{
availableLanguages
=
((
QuestionConstruct
)
item
.
getObject
()).
getQuestion
().
getAvailableLanguages
();
final
QuestionConstruct
questionConstruct
=
(
QuestionConstruct
)
item
.
getObject
();
SOURCE_LANG
=
questionConstruct
.
getQuestion
().
getLanguage
();
if
(
SOURCE_LANG
.
contains
(
"en"
))
translateQuestion
.
setVisible
(
false
);
availableLanguages
=
questionConstruct
.
getQuestion
().
getAvailableLanguages
();
}
MVerticalLayout
questionPrev
=
new
MVerticalLayout
().
withFullWidth
().
withMargin
(
false
);
...
...
@@ -1172,32 +1137,33 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
MLabel
htmlPrev
=
new
MLabel
().
withFullWidth
().
withContentMode
(
ContentMode
.
HTML
);
questionPrev
.
add
(
mCssButtonLayout
,
htmlPrev
);
questionsPreview
.
add
(
questionPrev
);
availableLanguages
.
forEach
(
lang
->
{
mCssButtonLayout
.
add
(
new
MButton
(
Language
.
getIso3Map
().
get
(
lang
).
getFormatted
()
)
.
withListener
(
clickEvent
->
{
mCssButtonLayout
.
forEach
(
c
->
c
.
removeStyleName
(
"pressed"
)
);
clickEvent
.
getButton
().
addStyleNames
(
"pressed"
);
if
(
item
.
getObject
().
getType
().
equals
(
DDIElement
.
STATEMENT
)
)
{
mode
=
"statement"
;
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
lang
,
mode
)
);
}
else
if
(
availableLanguages
.
size
()
>
1
)
{
availableLanguages
.
forEach
(
lang
->
{
mCssButtonLayout
.
add
(
new
MButton
(
Language
.
getIso3Map
().
get
(
lang
).
getFormatted
())
.
withListener
(
clickEvent
->
{
mode
=
"question"
;
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
lang
,
mode
)
);
}
}
)
);
}
);
mCssButtonLayout
.
forEach
(
c
->
c
.
removeStyleName
(
"pressed"
));
clickEvent
.
getButton
().
addStyleNames
(
"pressed"
);
if
(
item
.
getObject
().
getType
().
equals
(
DDIElement
.
STATEMENT
))
{
mode
=
"statement"
;
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
lang
,
mode
));
}
else
{
mode
=
"question"
;
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
lang
,
mode
));
}
}));
});
}
if
(
mCssButtonLayout
.
getComponentCount
()
>
0
)
{
Component
component
=
mCssButtonLayout
.
getComponent
(
0
);
...
...
@@ -1210,6 +1176,7 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
SOURCE_LANG
,
mode
)
);
}
else
...
...
@@ -1218,6 +1185,7 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
htmlPrev
.
setValue
(
exportService
.
generatePreviewByTemplate
(
item
,
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentStudyUnit
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentInstrument
(),
((
DDIEditor
)
UI
.
getCurrent
()).
getCurrentGroup
(),
SOURCE_LANG
,
mode
)
);
}
}
);
...
...
@@ -1837,12 +1805,13 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
if
(
success
)
{
importElements
(
currentBasketWindow
.
getSelectedElements
()
);
}
}
else
if
(
goal
.
endsWith
(
"ImportElementWindow"
)
)
{
entityService
.
importElements
(
toImport
,
getCurrentSequence
(),
getUi
().
getUser
(),
cw
.
getComment
()
);
setQuestionGridAfterRefresh
();
}
else
{
...
...
@@ -1977,6 +1946,7 @@ public class QuestionnaireEditorView extends VerticalLayout implements View, Tra
I18N
.
get
(
"QuestionConstruct.InterviewerInstruction.label"
)
);
previewLabelMap
.
put
(
QuestionConstruct
.
FILTER_LABEL
,
I18N
.
get
(
"QuestionConstruct.Filter.label"
)
);
previewLabelMap
.
put
(
QuestionItem
.
VARIABLE_LABEL
,
I18N
.
get
(
"QuestionItem.Variable.label"
)
);
userRating
.
updateMessageStrings
(
locale
);
updateCurrentQuestionPreview
();
}
...
...
src/main/java/org/gesis/stardat/ui/view/instruction/InterviewerInstructionForm.java
View file @
932d4fbb
...
...
@@ -110,22 +110,24 @@ public class InterviewerInstructionForm extends MVerticalLayout
final
ArrayList
<
String
>
availableLanguages
=
selectedInstruction
.
getAvailableLanguages
();
mCssButtonLayout
.
removeAllComponents
();
availableLanguages
.
forEach
(
lang
->
{
mCssButtonLayout
.
add
(
new
MButton
(
Language
.
getIso3Map
().
get
(
lang
).
getFormatted
()
)
.
withListener
(
clickEvent
->
{
mCssButtonLayout
.
forEach
(
c
->
c
.
removeStyleName
(
"pressed"
));
clickEvent
.
getButton
().
addStyleNames
(
"pressed"
);
selectedInstruction
.
setLanguage
(
lang
);
htmlPreview
.
setValue
(
selectedInstruction
.
createPreview
());
// set back to default language
selectedInstruction
.
setLanguage
(
SOURCE_LANG
);
}
));
});
Component
component
=
mCssButtonLayout
.
getComponent
(
0
);
if
(
component
!=
null
)
component
.
addStyleNames
(
"pressed"
);
if
(
availableLanguages
.
size
()
>
1
)
{
availableLanguages
.
forEach
(
lang
->
{
mCssButtonLayout
.
add
(
new
MButton
(
Language
.
getIso3Map
().
get
(
lang
).
getFormatted
())
.
withListener
(
clickEvent
->
{
mCssButtonLayout
.
forEach
(
c
->
c
.
removeStyleName
(
"pressed"
));
clickEvent
.
getButton
().
addStyleNames
(
"pressed"
);
selectedInstruction
.
setLanguage
(
lang
);
htmlPreview
.
setValue
(
selectedInstruction
.
createPreview
());
// set back to default language
selectedInstruction
.
setLanguage
(
SOURCE_LANG
);
}
));
});
Component
component
=
mCssButtonLayout
.
getComponent
(
0
);
if
(
component
!=
null
)
component
.
addStyleNames
(
"pressed"
);
}
htmlPreview
.
setValue
(
selectedInstruction
.
createPreview
());
}
else
{
htmlPreview
.
setValue
(
""
);
...
...
src/main/java/org/gesis/stardat/ui/view/question/QuestionAnswerPanel.java
View file @
932d4fbb
package
org.gesis.stardat.ui.view.question
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.UUID
;
import
com.vaadin.data.provider.ListDataProvider
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.shared.ui.ContentMode
;
import
com.vaadin.ui.*
;
import
org.gesis.stardat.DDIEditor
;
import
org.gesis.stardat.config.Constants
;
import
org.gesis.stardat.domain.enumeration.Language
;
...
...
@@ -28,10 +27,9 @@ import org.vaadin.viritin.label.MLabel;
import
org.vaadin.viritin.layouts.MCssLayout
;
import
org.vaadin.viritin.layouts.MHorizontalLayout
;
import
com.vaadin.data.provider.ListDataProvider
;
import
com.vaadin.icons.VaadinIcons
;
import
com.vaadin.shared.ui.ContentMode
;