Skip to content

Commit

Permalink
- pset getName refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
derreisende77 committed Sep 21, 2023
1 parent 115d530 commit 8e5a993
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/main/java/mediathek/daten/DatenPset.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,14 @@ public boolean istAbo() {
public boolean isLabel() {
//if program list is empty AND there is a name -> label
if (this.listeProg.isEmpty()) {
return !this.arr[PROGRAMMSET_NAME].isEmpty();
return !getName().isEmpty();
}
return false;
}

public boolean isFreeLine() {
//Wenn die Programmgruppe keinen Namen hat, leere Zeile
return this.arr[PROGRAMMSET_NAME].isEmpty();
return getName().isEmpty();
}

public void setAbspielen() {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mediathek/daten/ListeDownloads.java
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,9 @@ public synchronized void abosSuchen(JFrame parent) {

//diesen Film in die Downloadliste eintragen
abo.setDownDatum(todayDateStr);
if (!abo.getPsetName().equals(pSet.arr[DatenPset.PROGRAMMSET_NAME])) {
if (!abo.getPsetName().equals(pSet.getName())) {
// nur den Namen anpassen, falls geändert
abo.setPsetName(pSet.arr[DatenPset.PROGRAMMSET_NAME]);
abo.setPsetName(pSet.getName());
}

//dann in die Liste schreiben
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mediathek/daten/ListePset.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public DatenPset getPsetAbo(String name) {
} else {
for (DatenPset pset : this) {
if (pset.istAbo()) {
if (pset.arr[DatenPset.PROGRAMMSET_NAME].equals(name)) {
if (pset.getName().equals(name)) {
ret = pset;
}
}
Expand Down Expand Up @@ -148,7 +148,7 @@ public String[] getObjectDataCombo() {
int i = 0;
object = new String[this.size()];
for (DatenPset datenPset : this) {
object[i] = datenPset.arr[DatenPset.PROGRAMMSET_NAME];
object[i] = datenPset.getName();
++i;
}
return object;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mediathek/gui/dialog/DialogAddDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ private void setupPSetComboBox() {

jComboBoxPset.setModel(new DefaultComboBoxModel<>(listeSpeichern.getObjectDataCombo()));
if (pSet != null) {
jComboBoxPset.setSelectedItem(pSet.arr[DatenPset.PROGRAMMSET_NAME]);
jComboBoxPset.setSelectedItem(pSet.getName());
} else {
pSet = listeSpeichern.get(jComboBoxPset.getSelectedIndex());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void init() {
pSet = null;
}
if (pSet != null) {
jTextFieldName.setText(pSet.arr[DatenPset.PROGRAMMSET_NAME]);
jTextFieldName.setText(pSet.getName());
jTextArea1.setText(pSet.arr[DatenPset.PROGRAMMSET_BESCHREIBUNG]);
if (!pSet.istSpeichern() && pSet.arr[DatenPset.PROGRAMMSET_ZIEL_PFAD].equals("")) {
jTextFieldZiel.setEditable(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ private void init() {
if (row != -1) {
datenPset = listePset.get(tabellePset.convertRowIndexToModel(row));
tabellePset.getModel().setValueAt(jTextFieldSetName.getText(), tabellePset.convertRowIndexToModel(row), DatenPset.PROGRAMMSET_NAME);
jTabbedPane.setTitleAt(0, "Set Name: " + datenPset.arr[DatenPset.PROGRAMMSET_NAME]);
jTabbedPane.setTitleAt(0, "Set Name: " + datenPset.getName());
}
}
}
Expand Down Expand Up @@ -428,7 +428,7 @@ public void programmePruefen() {
if (!datenPset.isFreeLine() && !datenPset.isLabel()) {
// nur wenn kein Label oder freeline
text.append("++++++++++++++++++++++++++++++++++++++++++++" + '\n');
text.append(PIPE + "Programmgruppe: ").append(datenPset.arr[DatenPset.PROGRAMMSET_NAME]).append('\n');
text.append(PIPE + "Programmgruppe: ").append(datenPset.getName()).append('\n');
String zielPfad = datenPset.arr[DatenPset.PROGRAMMSET_ZIEL_PFAD];
if (datenPset.progsContainPath()) {
// beim nur Abspielen wird er nicht gebraucht
Expand Down Expand Up @@ -552,7 +552,7 @@ private void tabelleProgramme() {
GuiFunktionen.enableComponents(jTabbedPane, pSet != null);
jButtonAbspielen.setBackground(null);
if (pSet != null) {
jTabbedPane.setTitleAt(0, "Set Name: " + pSet.arr[DatenPset.PROGRAMMSET_NAME]);
jTabbedPane.setTitleAt(0, "Set Name: " + pSet.getName());
if (pSet.arr[DatenPset.PROGRAMMSET_MAX_LAENGE].equals("")) {
jSpinnerLaenge.setValue(Konstanten.LAENGE_DATEINAME);
pSet.arr[DatenPset.PROGRAMMSET_MAX_LAENGE] = String.valueOf(Konstanten.LAENGE_DATEINAME);
Expand All @@ -572,8 +572,8 @@ private void tabelleProgramme() {
jCheckBoxSubtitle.setSelected(Boolean.parseBoolean(pSet.arr[DatenPset.PROGRAMMSET_SUBTITLE]));
jCheckBoxSpotlight.setEnabled(SystemUtils.IS_OS_MAC_OSX);
jCheckBoxSpotlight.setSelected(Boolean.parseBoolean(pSet.arr[DatenPset.PROGRAMMSET_SPOTLIGHT]));
jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Set Name: " + pSet.arr[DatenPset.PROGRAMMSET_NAME], javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.TOP));
jTextFieldSetName.setText(pSet.arr[DatenPset.PROGRAMMSET_NAME]);
jScrollPane1.setBorder(BorderFactory.createTitledBorder(null, "Set Name: " + pSet.getName(), TitledBorder.LEFT, TitledBorder.TOP));
jTextFieldSetName.setText(pSet.getName());
tfGruppeDirektSuffix.setText(pSet.arr[DatenPset.PROGRAMMSET_SUFFIX_DIREKT]);
tfGruppeDirektPraefix.setText(pSet.arr[DatenPset.PROGRAMMSET_PRAEFIX_DIREKT]);
tfGruppeZielName.setText(pSet.arr[DatenPset.PROGRAMMSET_ZIEL_DATEINAME]);
Expand Down Expand Up @@ -718,7 +718,7 @@ private void setLoeschen() {
String text;
if (rows.length == 1) {
pSet = listePset.get(tabellePset.convertRowIndexToModel(rows[0]));
text = pSet.arr[DatenPset.PROGRAMMSET_NAME];
text = pSet.getName();
} else {
text = rows.length + " Set löschen?";
}
Expand Down Expand Up @@ -750,7 +750,7 @@ private void setExport() {
}
}

final var entryName = liste.get(0).arr[DatenPset.PROGRAMMSET_NAME];
final var entryName = liste.get(0).getName();
String name = entryName.isEmpty() ? "Name.xml" : entryName + ".xml";
var fileName = FilenameUtils.replaceLeerDateiname(name, false,
Boolean.parseBoolean(MVConfig.get(MVConfig.Configs.SYSTEM_USE_REPLACETABLE)),
Expand Down Expand Up @@ -870,7 +870,7 @@ private void setNamePruefen() {
if (row != -1) {
int foundgruppe = 0;
for (DatenPset gruppe : listePset) {
if (jTextFieldSetName.getText().equals(gruppe.arr[DatenPset.PROGRAMMSET_NAME])) {
if (jTextFieldSetName.getText().equals(gruppe.getName())) {
++foundgruppe;
}
}
Expand All @@ -892,7 +892,7 @@ private void eingabe() {
datenPset.arr[psetIndex] = textComponent.getText();
if (psetIndex == DatenPset.PROGRAMMSET_NAME) {
tabellePset.getModel().setValueAt(jTextFieldSetName.getText(), modelIndex, DatenPset.PROGRAMMSET_NAME);
jTabbedPane.setTitleAt(0, "Set Name: " + datenPset.arr[DatenPset.PROGRAMMSET_NAME]);
jTabbedPane.setTitleAt(0, "Set Name: " + datenPset.getName());
}
if (fireUpdate)
notifyProgramSetChanged();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mediathek/gui/tabs/tab_film/GuiFilme.java
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ private void showMenu(MouseEvent evt) {
jPopupMenu.add(submenue);
ListePset liste = Daten.listePset.getListeButton();
for (DatenPset pset : liste) {
if (pset.getListeProg().isEmpty() && pset.arr[DatenPset.PROGRAMMSET_NAME].isEmpty()) {
if (pset.getListeProg().isEmpty() && pset.getName().isEmpty()) {
// ein "leeres" Pset, Platzhalter
continue;
}
Expand Down
19 changes: 8 additions & 11 deletions src/main/java/mediathek/gui/tabs/tab_film/PsetButtonsPanel.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mediathek.gui.tabs.tab_film;

import mediathek.config.Daten;
import mediathek.daten.DatenPset;
import mediathek.gui.messages.ProgramSetChangedEvent;
import mediathek.tool.MessageBus;
import net.engio.mbassy.listener.Handler;
Expand Down Expand Up @@ -50,21 +49,19 @@ protected void setupButtonLayout() {
btnPanel.removeAll();

for (var pset : Daten.listePset.getListeButton()) {
final var psetName = pset.arr[DatenPset.PROGRAMMSET_NAME];
final var psetColor = pset.getFarbe();
if (!pset.isFreeLine()) {
JComponent comp;

if (pset.isLabel()) {
var l = new JLabel(psetName);
if (psetColor != null)
l.setForeground(psetColor);
btnPanel.add(l);
comp = new JLabel(pset.getName());
} else {
var b = new JButton(psetName);
if (psetColor != null)
b.setBackground(psetColor);
var b = new JButton(pset.getName());
b.addActionListener(l -> guiFilme.playerStarten(pset));
btnPanel.add(b);
comp = b;
}

pset.getForegroundColor().ifPresent(comp::setForeground);
btnPanel.add(comp);
} else {
btnPanel.add(new JLabel(""));
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/mediathek/update/ProgramUpdateCheck.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ private void checkForPsetUpdates() {
}
// damit man sie auch findet :)
String date = new SimpleDateFormat("dd.MM.yyyy").format(new Date());
listePsetStandard.forEach((psNew) -> psNew.arr[DatenPset.PROGRAMMSET_NAME] = psNew.arr[DatenPset.PROGRAMMSET_NAME] + ", neu: " + date);
listePsetStandard.forEach((psNew) -> psNew.arr[DatenPset.PROGRAMMSET_NAME] = psNew.getName() + ", neu: " + date);
}
GuiFunktionenProgramme.addSetVorlagen(MediathekGui.ui(), Daten.getInstance(), listePsetStandard, true); // damit auch AddOns geladen werden
logger.info("Setanlegen: OK");
Expand Down

0 comments on commit 8e5a993

Please sign in to comment.