Skip to content

Commit a33a375

Browse files
committed
Einige Verbesserungen und die Möglichkeit, Wahlzeilen mehrfach zu definieren. KonfliktRegeln werden nun auch in der Leistungs-/Prüfungsfach-Auswahl angewandt.
1 parent b1d33f9 commit a33a375

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+518
-548
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kurswahlApp.iml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules/resource-generator/Kurs-Check.resource-generator.test.iml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

+100-92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/drawables/calendar.svg

+1
Loading

app/assets/drawables/home.svg

+1
Loading

app/assets/drawables/info_outline.svg

+1-26
Loading

app/assets/drawables/person.svg

+1
Loading

app/assets/drawables/task_check.svg

+1-1
Loading

app/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ plugins {
1111
dependencies {
1212
implementation project(':lib')
1313

14-
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.13.3'
15-
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.13.3'
14+
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin:2.16.1'
15+
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.16.1'
1616
implementation 'org.jetbrains.kotlinx:kotlinx-cli:0.3.4'
1717
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4'
1818
implementation 'com.github.lgooddatepicker:LGoodDatePicker:11.2.1'

app/src/main/kotlin/gui/AusgabeLayout.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class AusgabeLayout(fachData: FachData, wahlData: KurswahlData) : JPanel(GridBag
135135
alignmentX = 0f
136136
border = TitledBorder(RoundedBorder(8), R.getString("your_infos"))
137137
}
138-
feldPanel.add(JLabel("${R.getString("type_of_pk5")}: <b>${wahlData.pf5_typ.repr}</b>".wrapHtml()))
138+
feldPanel.add(JLabel("${R.getString("type_of_pk5")}: <b>${wahlData.pf5Typ.repr}</b>".wrapHtml()))
139139

140140
// Wahlzeile
141141
feldPanel.add(JLabel("${R.getString("wahlzeile")}: <b>${wahlData.wahlzeile}</b>".wrapHtml()))
@@ -157,7 +157,7 @@ class AusgabeLayout(fachData: FachData, wahlData: KurswahlData) : JPanel(GridBag
157157
)
158158

159159
feldPanel.add(
160-
JLabel("${R.getString("nationality")}: <b>${wahlData.staatsangehoerigkeit}</b>".wrapHtml())
160+
JLabel("${R.getString("nationality")}: <b>${Locale(Locale.getDefault().language, wahlData.staatsangehoerigkeit).displayCountry}</b>".wrapHtml())
161161
)
162162

163163
checkboxPanel.add(feldPanel)

app/src/main/kotlin/gui/Extensions.kt

+1-45
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,14 @@
1717

1818
package com.kurswahlApp.gui
1919

20-
import com.kurswahlApp.getResourceURL
2120
import java.awt.*
2221
import java.awt.event.MouseAdapter
2322
import java.awt.event.MouseEvent
2423
import java.awt.geom.AffineTransform
2524
import java.awt.geom.Path2D
2625
import java.io.File
27-
import java.net.URL
28-
import javax.swing.ImageIcon
2926
import javax.swing.JComboBox
3027
import javax.swing.JComponent
31-
import kotlin.system.measureNanoTime
3228

3329
/**
3430
* Fügt den [Component] zu dem [Container] mit [GridBagLayout] hinzu
@@ -146,51 +142,11 @@ operator fun Dimension.component2() = height
146142

147143
fun Path2D.scale(sx: Double, sy: Double): Shape = createTransformedShape(AffineTransform.getScaleInstance(sx, sy))
148144

149-
fun <R> measureNanos(block: () -> R): R {
150-
val result: R
151-
println(measureNanoTime { result = block() })
152-
return result
153-
}
154-
155145
fun File.withExtension(ext: String): File = File(this.parentFile, "$nameWithoutExtension.$ext")
156146

157-
/**
158-
* Öffnet eine Webseite im Browser
159-
*/
160-
fun openWebpage(url: URL): Boolean {
161-
val desktop = if (Desktop.isDesktopSupported()) Desktop.getDesktop() else null
162-
if (desktop != null && desktop.isSupported(Desktop.Action.BROWSE)) {
163-
try {
164-
desktop.browse(url.toURI())
165-
return true
166-
} catch (_: Exception) {
167-
}
168-
}
169-
return false
170-
}
171-
172147
fun Color.hexString() = "#${Integer.toHexString(rgb and 0x00ffffff)}"
173148

174-
fun img(src: String, alt: String? = null) =
175-
if (alt != null) "<img src='${getResourceURL(src)}' alt='$alt'/>" else "<img src='${getResourceURL(src)}'/>"
176-
177-
fun img(src: String, width: Int, height: Int, alt: String? = null) =
178-
if (alt != null)
179-
"<img src='${getResourceURL(src)}' alt='$alt' width='$width' height='$height'/>"
180-
else
181-
"<img src='${getResourceURL(src)}' width='$width' height='$height'/>"
182-
183-
@Suppress("UNCHECKED_CAST")
149+
@Suppress("UNCHECKED_CAST", "UsePropertyAccessSyntax")
184150
val <E> JComboBox<E>.selectedItem: E?
185151
get() = this.getSelectedItem() as E?
186152

187-
/** Erstellt ein [ImageIcon] mit dem gegebenen [path] und einer optionalen [description]. */
188-
fun createImageIcon(path: String, description: String? = null): ImageIcon? {
189-
val imgURL: URL? = getResourceURL(path)
190-
return if (imgURL != null) {
191-
ImageIcon(imgURL, description)
192-
} else {
193-
System.err.println("Couldn't find file: $path")
194-
null
195-
}
196-
}

app/src/main/kotlin/gui/Fremdsprachen.kt

+4-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class Fremdsprachen(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
4242
}
4343
}
4444

45+
//#region Selection Components
4546
private val fsJahr1: SpinnerNumberModel
4647
private val fsJahr2: SpinnerNumberModel
4748
private val fsJahr3: SpinnerNumberModel
@@ -55,6 +56,7 @@ class Fremdsprachen(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
5556
private val wpf2: FachComboBox
5657

5758
private val klasse: JComboBox<String?>
59+
//#endregion
5860

5961
init {
6062
val container1 = JPanel(GridBagLayout())
@@ -228,7 +230,8 @@ class Fremdsprachen(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
228230

229231
add(container1, row = 0, fill = GridBagConstraints.BOTH)
230232
add(container2, row = 1, fill = GridBagConstraints.BOTH)
231-
add(container3, row = 2, fill = GridBagConstraints.BOTH)
233+
234+
if (fachData.klassen.isNotEmpty()) add(container3, row = 2, fill = GridBagConstraints.BOTH)
232235
add(Box.createHorizontalStrut(200), row = 0, column = 0)
233236
}
234237

app/src/main/kotlin/gui/GrundkursWahl.kt

+19-5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
150150
}
151151
}
152152
}
153+
154+
checkAndNotify()
153155
})
154156

155157
label.addComponentListener(object : ComponentAdapter() {
@@ -200,6 +202,8 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
200202
invalidRows++
201203
label.foreground = Consts.COLOR_ERROR
202204
}
205+
206+
checkAndNotify()
203207
}
204208

205209
add(
@@ -239,6 +243,13 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
239243
fun count(): Int = toWahlmoeglichkeit()?.n ?: 0
240244
}
241245

246+
private fun checkAndNotify(invalidate: Boolean = false) {
247+
notifier.invoke((invalidRows == 0) and checkData())
248+
if (invalidate) {
249+
regelLabelArray.forEach { invalidate() }
250+
}
251+
}
252+
242253
private fun checkData(): Boolean {
243254
val data = close()
244255
data.lock()
@@ -335,17 +346,12 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
335346

336347
private val checkboxPanel = ScrollablePanel(GridBagLayout()).apply { setScrollableWidth(ScrollablePanel.ScrollableSizeHint.FIT) }
337348

338-
private val checkButton = JButton("Überprüfen")
339-
340349
private val regelPanel = ScrollablePanel(null)
341350

342351
init {
343352
add(anzahlLabel, row = 1)
344353
add(anzahlInfoLabel, row = 1, column = 0, columnspan = 3)
345354

346-
checkButton.addActionListener { notifier.invoke((invalidRows == 0) and checkData()) }
347-
add(checkButton, row = 1, column = 2, anchor = GridBagConstraints.EAST)
348-
349355
buildCheckboxes()
350356

351357
val scrollPane =
@@ -405,7 +411,9 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
405411
/**
406412
* Erstellt Checkboxen mit Labels und versteckt jene, die der Schüler nicht wählen kann
407413
*/
414+
@Suppress("ConvertArgumentToSet")
408415
private fun buildCheckboxes() {
416+
wahlData.lock()
409417
// fremdsprachen & wpfs holen
410418
val fs = wahlData.fremdsprachen.map(Pair<Fach, *>::first)
411419

@@ -438,6 +446,10 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
438446
var af = Int.MIN_VALUE
439447
var offset = 1
440448

449+
val versteckte = fachData.regeln.filterIsInstance<KonfliktRegel>().mapNotNull {
450+
it.wildcardMembers.takeIf { m -> m.any { f -> f in wahlData.pfs } }
451+
}.flatten().minus(wahlData.pfs)
452+
441453
for ((i, fach) in fachData.faecher.withIndex()) {
442454
/* TODO Umsetzen:
443455
VO-GO Berlin - § 20 Kurse und Kursfolgen, Nr.2
@@ -446,6 +458,7 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
446458
worden sein müssen. (Schlussfolgerung aus Satz 1, da nicht definiert, wvl.
447459
Wochenstunden eine neue Fremdsprache in Sek II hätte) */
448460
if (!fach.isKurs
461+
|| fach in versteckte
449462
|| fach.isFremdsprache && fach !in fs
450463
|| !fach.checkKlasse(wahlData.klasse)
451464
|| (!fach.isGk && fach !in wahlData.lks)
@@ -480,6 +493,7 @@ class GrundkursWahl(wahlData: KurswahlData, fachData: FachData, notifier: (Boole
480493
weightx = 1.0
481494
)
482495
}
496+
wahlData.unlock()
483497
}
484498

485499
/**

0 commit comments

Comments
 (0)