add support for multiline run titles. resolves #7
This commit is contained in:
parent
016ecd8acd
commit
fd84ef242f
|
@ -49,7 +49,7 @@ implements ActionListener, ListSelectionListener {
|
||||||
/**
|
/**
|
||||||
* Zone d’édition du titre de la course.
|
* Zone d’édition du titre de la course.
|
||||||
*/
|
*/
|
||||||
private JTextField runTitle;
|
private JTextArea runTitle;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Étiquette du {@link runTitle}.
|
* Étiquette du {@link runTitle}.
|
||||||
|
@ -126,7 +126,7 @@ implements ActionListener, ListSelectionListener {
|
||||||
|
|
||||||
String delayedStartString = new Time(run.getDelayedStart()).toString(Accuracy.HUNDREDTH);
|
String delayedStartString = new Time(run.getDelayedStart()).toString(Accuracy.HUNDREDTH);
|
||||||
|
|
||||||
runTitle = new JTextField(run.getName(), 61);
|
runTitle = new JTextArea(run.getName(), 2, 61);
|
||||||
runTitleLabel = new JLabel(Language.RUN_TITLE.get());
|
runTitleLabel = new JLabel(Language.RUN_TITLE.get());
|
||||||
runSubTitle = new JTextField(run.getSubTitle(), 61);
|
runSubTitle = new JTextField(run.getSubTitle(), 61);
|
||||||
runDelayedStart = new JTextField(delayedStartString, 5);
|
runDelayedStart = new JTextField(delayedStartString, 5);
|
||||||
|
|
|
@ -1,26 +1,18 @@
|
||||||
package org.fenix.llanfair.gui;
|
package org.fenix.llanfair.gui;
|
||||||
|
|
||||||
import java.awt.Color;
|
import org.fenix.llanfair.Run;
|
||||||
import java.awt.Font;
|
import org.fenix.llanfair.Run.State;
|
||||||
import java.awt.GridBagLayout;
|
import org.fenix.llanfair.config.Settings;
|
||||||
|
import org.fenix.utils.gui.GBC;
|
||||||
|
import org.fenix.utils.locale.LocaleEvent;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.TableModelEvent;
|
||||||
|
import java.awt.*;
|
||||||
import java.beans.PropertyChangeEvent;
|
import java.beans.PropertyChangeEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.event.TableModelEvent;
|
|
||||||
|
|
||||||
import org.fenix.llanfair.Language;
|
|
||||||
import org.fenix.llanfair.Run;
|
|
||||||
import org.fenix.llanfair.Segment;
|
|
||||||
import org.fenix.llanfair.config.Settings;
|
|
||||||
import org.fenix.llanfair.Run.State;
|
|
||||||
import org.fenix.llanfair.Time;
|
|
||||||
import org.fenix.utils.gui.GBC;
|
|
||||||
import org.fenix.utils.locale.LocaleEvent;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A panel representing informations on a given run. This panel uses numerous
|
* A panel representing informations on a given run. This panel uses numerous
|
||||||
* sub-component to given different kind of informations like a graph or a
|
* sub-component to given different kind of informations like a graph or a
|
||||||
|
@ -154,6 +146,9 @@ public class RunPane extends JPanel {
|
||||||
footer = new Footer(run);
|
footer = new Footer(run);
|
||||||
separators = new ArrayList<JLabel>();
|
separators = new ArrayList<JLabel>();
|
||||||
|
|
||||||
|
title.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
subTitle.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
placeComponents();
|
placeComponents();
|
||||||
setRun(run);
|
setRun(run);
|
||||||
|
|
||||||
|
@ -291,7 +286,7 @@ public class RunPane extends JPanel {
|
||||||
* Places the sub-components within this component.
|
* Places the sub-components within this component.
|
||||||
*/
|
*/
|
||||||
private void placeComponents() {
|
private void placeComponents() {
|
||||||
add(title, GBC.grid(0, 0).insets(3, 0, 1, 0));
|
add(title, GBC.grid(0, 0).insets(3, 0, 1, 0).fill(GBC.B));
|
||||||
add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0));
|
add(subTitle, GBC.grid(0, 1).insets(3, 0, 0, 0));
|
||||||
add(attemptCounter, GBC.grid(0, 2).insets(1, 0, 1, 3).anchor(GBC.LE));
|
add(attemptCounter, GBC.grid(0, 2).insets(1, 0, 1, 3).anchor(GBC.LE));
|
||||||
add(createSeparator(), GBC.grid(0, 3).insets(3, 0).fill(GBC.H));
|
add(createSeparator(), GBC.grid(0, 3).insets(3, 0).fill(GBC.H));
|
||||||
|
@ -310,7 +305,7 @@ public class RunPane extends JPanel {
|
||||||
*/
|
*/
|
||||||
private void updateValues(int identifier) {
|
private void updateValues(int identifier) {
|
||||||
if ((identifier & TITLE) == TITLE) {
|
if ((identifier & TITLE) == TITLE) {
|
||||||
title.setText("" + run.getName());
|
title.setText("<html><div style='text-align: center;'>" + sanitizeTitleString(run.getName()) + "</div></html>");
|
||||||
subTitle.setText(run.getSubTitle());
|
subTitle.setText(run.getSubTitle());
|
||||||
}
|
}
|
||||||
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
if ((identifier & ATTEMPTS) == ATTEMPTS) {
|
||||||
|
@ -423,4 +418,11 @@ public class RunPane extends JPanel {
|
||||||
repaint();
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String sanitizeTitleString(String title) {
|
||||||
|
return title
|
||||||
|
.replace("<", "<")
|
||||||
|
.replace(">", ">")
|
||||||
|
.replace("\n", "<br/>");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue