@@ -38,30 +38,6 @@ interface SurveyPin : Consumer<Int> {
3838 }
3939}
4040
41- // interface YearNotifier : Consumer<Int> {
42- // companion object {
43- // val YEAR_TOPIC = Topic.create("YEAR change", YearNotifier::class.java)
44- // }
45- // }
46-
47- // interface PeYearsNotifier : Consumer<Int> {
48- // companion object {
49- // val PE_YEARS_TOPIC = Topic.create("program experience years change", PeYearsNotifier::class.java)
50- // }
51- // }
52- //
53- // interface PeMonthsNotifier : Consumer<Int> {
54- // companion object {
55- // val PE_MONTHS_TOPIC = Topic.create("program experience months change", PeMonthsNotifier::class.java)
56- // }
57- // }
58-
59- // interface DifficultyNotifier : Consumer<Int> {
60- // companion object {
61- // val DIFFICULTY_TOPIC = Topic.create("difficulty change", DifficultyNotifier::class.java)
62- // }
63- // }
64-
6541interface CountryComparatorNotifier : Consumer <Comparator <Country >> {
6642 companion object {
6743 val COUNTRY_COMPARATOR_TOPIC = Topic .create(" country list change" , CountryComparatorNotifier ::class .java)
@@ -80,33 +56,6 @@ object SurveyUiData : LanguagePaneUiData() {
8056 private val programmingLanguages: List <Language > = PluginServer .programmingLanguages
8157
8258 val pin = UiField (- 1 , SurveyPin .PIN_NOTIFIER , StoredInfoHandler .getIntStoredField(UiLoggedDataHeader .PIN , - 1 ))
83- // val year = ListedUiField(
84- // // TODO: Change genders to years. This needs to be done in both the server and plugin
85- // genders,
86- // -1,
87- // YearNotifier.YEAR_TOPIC,
88- // initValue = StoredInfoHandler.getIndexByStoredKey(UiLoggedDataHeader.YEAR, genders, -1)
89- // )
90- // val peYears = UiField(
91- // -1,
92- // PeYearsNotifier.PE_YEARS_TOPIC,
93- // StoredInfoHandler.getIntStoredField(UiLoggedDataHeader.PROGRAM_EXPERIENCE_YEARS, -1)
94- //
95- // )
96- // val peMonths = UiField(
97- // -1,
98- // PeMonthsNotifier.PE_MONTHS_TOPIC,
99- // StoredInfoHandler.getIntStoredField(UiLoggedDataHeader.PROGRAM_EXPERIENCE_MONTHS, -1),
100- // false
101- // )
102- // val difficulty = ListedUiField(
103- // difficulties,
104- // -1,
105- // DifficultyNotifier.DIFFICULTY_TOPIC,
106- // compareBy { c -> c.translation.getOrDefault(language.currentValue, "") },
107- // CountryComparatorNotifier.COUNTRY_COMPARATOR_TOPIC,
108- // StoredInfoHandler.getIndexByStoredKey(UiLoggedDataHeader.DIFFICULTY, difficulties, -1)
109- // )
11059 val programmingLanguage = ListedUiField (
11160 programmingLanguages,
11261 0 ,
@@ -116,11 +65,6 @@ object SurveyUiData : LanguagePaneUiData() {
11665
11766 override fun getData () = listOf (
11867 pin,
119- // year,
120- // peYears,
121- // peMonths,
122- // difficulty,
123- // programmingLanguage,
12468 language
12569 )
12670}
@@ -134,68 +78,6 @@ class SurveyController(project: Project, scale: Double, fxPanel: JFXPanel, id: I
13478 @FXML
13579 private lateinit var pinTextField: TextField
13680
137- // Gender
138- // @FXML
139- // private lateinit var yearLabel: Label
140- //
141- // @FXML
142- // private lateinit var yearGroup: ToggleGroup
143- //
144- // @FXML
145- // private lateinit var year1: RadioButton
146- //
147- // @FXML
148- // private lateinit var year2: RadioButton
149- //
150- // @FXML
151- // private lateinit var year3: RadioButton
152- //
153- // @FXML
154- // private lateinit var year4: RadioButton
155- //
156- // @FXML
157- // private lateinit var year5: RadioButton
158- //
159- // @FXML
160- // private lateinit var year6: RadioButton
161- //
162- // @FXML
163- // private lateinit var yearRadioButtons: List<RadioButton>
164-
165- // Program Experience
166- // @FXML
167- // private lateinit var experienceLabel: Label
168- //
169- // @FXML
170- // private lateinit var peYearsLabel: Label
171- //
172- // @FXML
173- // private lateinit var peYearsTextField: TextField
174- //
175- // @FXML
176- // private lateinit var peMonthsHBox: HBox
177- //
178- // @FXML
179- // private lateinit var peMonthsLabel: Label
180- //
181- // @FXML
182- // private lateinit var peMonthsTextField: TextField
183-
184- // Country
185- // @FXML
186- // private lateinit var difficultyLabel: Label
187- //
188- // @FXML
189- // private lateinit var difficultyComboBox: ComboBox<Country>
190- // private lateinit var difficultyObservableList: ObservableList<Country>
191-
192- // Programming language
193- // @FXML
194- // private lateinit var programmingLanguageLabel: Label
195- //
196- // @FXML
197- // private lateinit var programmingLanguageComboBox: ComboBox<String>
198-
19981 // StartWorking
20082 @FXML
20183 private lateinit var startWorkingButton: Button
@@ -224,11 +106,6 @@ class SurveyController(project: Project, scale: Double, fxPanel: JFXPanel, id: I
224106 mainPane.styleProperty().bind(Bindings .concat(" -fx-font-size: ${scale} px;" ))
225107 scalePolygons(arrayListOf (orangePolygon, bluePolygon))
226108 initPin()
227- // initYear()
228- // initPeYears()
229- // initPeMonths()
230- // initDifficulty()
231- // initProgrammingLanguage()
232109 initStartWorkingButton()
233110 makeTranslatable()
234111 super .initialize(url, resource)
@@ -251,110 +128,6 @@ class SurveyController(project: Project, scale: Double, fxPanel: JFXPanel, id: I
251128 })
252129 }
253130
254- // private fun initYear() {
255- // yearRadioButtons = listOf(year1, year2, year3, year4, year5, year6)
256- // val gendersSize = paneUiData.year.dataList.size
257- // yearRadioButtons.forEachIndexed { i, rb -> rb.isVisible = i < gendersSize }
258- //
259- // yearGroup.selectedToggleProperty().addListener { _, _, new ->
260- // paneUiData.year.uiValue = yearRadioButtons.indexOf(new)
261- // }
262- // subscribe(YearNotifier.YEAR_TOPIC, object : YearNotifier {
263- // override fun accept(newGenderIndex: Int) {
264- // if (paneUiData.year.isValid(newGenderIndex)) {
265- // yearGroup.selectToggle(yearRadioButtons[newGenderIndex])
266- // startWorkingButton.isDisable = paneUiData.anyRequiredDataDefault()
267- // }
268- // }
269- // })
270- // }
271-
272- // private fun initPeYears() {
273- // peYearsTextField.addIntegerFormatter(regexFilter("0|[1-9][0-9]{0,1}"))
274- // peYearsTextField.textProperty().addListener { _, _, new ->
275- // paneUiData.peYears.uiValue = new.toIntOrNull() ?: paneUiData.peYears.defaultValue
276- // }
277- // subscribe(PeYearsNotifier.PE_YEARS_TOPIC, object : PeYearsNotifier {
278- // override fun accept(newPeYears: Int) {
279- // peYearsTextField.text = newPeYears.toString()
280- // val isPeMonthsRequired =
281- // !paneUiData.peYears.isUiValueDefault && newPeYears < PE_YEARS_NUMBER_TO_SHOW_MONTHS
282- // paneUiData.peMonths.isRequired = isPeMonthsRequired
283- // peMonthsHBox.isVisible = isPeMonthsRequired
284- // if (!isPeMonthsRequired) {
285- // paneUiData.peMonths.uiValue = paneUiData.peMonths.defaultValue
286- // }
287- // startWorkingButton.isDisable = paneUiData.anyRequiredDataDefault()
288- // }
289- // })
290- // }
291- //
292- // private fun initPeMonths() {
293- // peMonthsHBox.isVisible = paneUiData.peMonths.isRequired
294- // peMonthsTextField.addIntegerFormatter(regexFilter("[0-9]|1[01]"))
295- // peMonthsTextField.textProperty().addListener { _, old, new ->
296- // paneUiData.peMonths.uiValue = new.toIntOrNull() ?: paneUiData.peMonths.defaultValue
297- // }
298- // subscribe(PeMonthsNotifier.PE_MONTHS_TOPIC, object : PeMonthsNotifier {
299- // override fun accept(newPeMonths: Int) {
300- // peMonthsTextField.text = newPeMonths.toString()
301- // startWorkingButton.isDisable = paneUiData.anyRequiredDataDefault()
302- // }
303- // })
304- // }
305-
306- // private fun initDifficulty() {
307- // // Todo: make it autocomplete https://stackoverflow.com/questions/19924852/autocomplete-combobox-in-javafx
308- // difficultyObservableList = FXCollections.observableList(paneUiData.difficulty.dataList)
309- // difficultyComboBox.items = difficultyObservableList
310- //
311- // val cellFactory = Callback<ListView<Country>, ListCell<Country>> {
312- // object : ListCell<Country>() {
313- // override fun updateItem(item: Country?, empty: Boolean) {
314- // super.updateItem(item, empty)
315- // if (item == null || empty) {
316- // graphic = null;
317- // } else {
318- // text = item.translation.getOrDefault(LanguagePaneUiData.language.currentValue, "")
319- // }
320- // }
321- // }
322- // }
323- //
324- // difficultyComboBox.buttonCell = cellFactory.call(null)
325- // difficultyComboBox.cellFactory = cellFactory
326- //
327- // difficultyComboBox.selectionModel.selectedItemProperty().addListener { _ ->
328- // paneUiData.difficulty.uiValue = difficultyComboBox.selectionModel.selectedIndex
329- // }
330- // subscribe(DifficultyNotifier.DIFFICULTY_TOPIC, object : DifficultyNotifier {
331- // override fun accept(newCountryIndex: Int) {
332- // difficultyComboBox.selectionModel.select(newCountryIndex)
333- // startWorkingButton.isDisable = paneUiData.anyRequiredDataDefault()
334- // }
335- // })
336- //
337- // subscribe(CountryComparatorNotifier.COUNTRY_COMPARATOR_TOPIC, object : CountryComparatorNotifier {
338- // override fun accept(newComparator: Comparator<Country>) {
339- // difficultyComboBox.items = difficultyObservableList.sorted(newComparator)
340- // }
341- // })
342- // }
343-
344- // private fun initProgrammingLanguage() {
345- // programmingLanguageComboBox.items = FXCollections.observableList(paneUiData.programmingLanguage.dataList.map { it.key })
346- //
347- // programmingLanguageComboBox.selectionModel.selectedItemProperty().addListener { _ ->
348- // paneUiData.programmingLanguage.uiValue = programmingLanguageComboBox.selectionModel.selectedIndex
349- // }
350- // subscribe(ProgrammingLanguageNotifier.PROGRAMMING_LANGUAGE_TOPIC, object : ProgrammingLanguageNotifier {
351- // override fun accept(newLanguageIndex: Int) {
352- // programmingLanguageComboBox.selectionModel.select(newLanguageIndex)
353- // startWorkingButton.isDisable = paneUiData.anyRequiredDataDefault()
354- // }
355- // })
356- // }
357-
358131 private fun initStartWorkingButton () {
359132 startWorkingButton.onMouseClicked {
360133 ApplicationManager .getApplication().invokeLater {
@@ -373,19 +146,8 @@ class SurveyController(project: Project, scale: Double, fxPanel: JFXPanel, id: I
373146 val surveyPaneText = translations?.get(newLanguage)
374147 surveyPaneText?.let {
375148 pinLabel.text = it.pin
376- // yearLabel.text = it.year
377- // experienceLabel.text = it.experience
378- // peYearsLabel.text = it.years
379- // peMonthsLabel.text = it.months
380- // difficultyLabel.text = it.difficulty
381149 startWorkingText.text = it.startSession
382- // programmingLanguageLabel.text = it.programmingLanguage
383- // paneUiData.difficulty.dataListComparator =
384- // compareBy { c -> c.translation.getOrDefault(newLanguage, "") }
385150 }
386- // yearRadioButtons.zip(paneUiData.year.dataList) { rb, g ->
387- // rb.text = g.translation[newLanguage] ?: ""
388- // }
389151 }
390152 })
391153 }
0 commit comments