From f78fef2c587784852f276725876c2b1e1f370563 Mon Sep 17 00:00:00 2001 From: Kuersat Akmaz Date: Sat, 17 Oct 2020 14:00:30 +0200 Subject: [client] added small html Editor in LectureCreationpage Issue : #3727 --- .../wizard/layout/LectureCreationPageLayout.java | 45 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java index 5df21c1d..c184b3e2 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java @@ -4,10 +4,13 @@ import java.util.Calendar; import javax.swing.JScrollPane; import javax.swing.JSpinner; -import javax.swing.JTextArea; import javax.swing.JTextField; +import javax.swing.JPanel; +import javax.swing.JButton; +import javax.swing.JEditorPane; import javax.swing.SpinnerDateModel; import javax.swing.text.DateFormatter; +import javax.swing.text.StyledEditorKit; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.QDatePickerImpl; @@ -16,22 +19,28 @@ import org.openslx.dozmod.gui.helper.GridManager; import org.openslx.dozmod.gui.wizard.Wizard; import org.openslx.dozmod.gui.wizard.WizardPage; +import java.awt.Dimension; +import java.awt.GridLayout; + @SuppressWarnings("serial") public abstract class LectureCreationPageLayout extends WizardPage { protected final JTextField txtName; - protected final JTextArea txtDescription; + protected final JEditorPane txtDescription; protected final QDatePickerImpl dtpStartDate; protected final QDatePickerImpl dtpEndDate; protected final JSpinner spnStartTime; protected final JSpinner spnEndTime; protected final QLabel lblCalcPeriod; + protected final JButton btnBold; + protected final JButton btnItalic; + protected final JButton btnUnderline; + /** * Page for creating lectures * - * @param editExistingLecture whether to edit existing lecture or create new - * one + * @param editExistingLecture whether to edit existing lecture or create new one */ public LectureCreationPageLayout(Wizard wizard, String title) { super(wizard, title); @@ -44,9 +53,31 @@ public abstract class LectureCreationPageLayout extends WizardPage { grid.add(txtName, 2).fill(true, false).expand(true, false); grid.nextRow(); - txtDescription = new JTextArea(3, 50); - txtDescription.setLineWrap(true); - txtDescription.setWrapStyleWord(true); + // buttons for text editing + JPanel editingPanel = new JPanel(); + editingPanel.setLayout(new GridLayout(1, 3)); + JPanel emptyPanel = new JPanel(); + grid.add(emptyPanel); + btnBold = new JButton(new StyledEditorKit.BoldAction()); + btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 24, this)); + btnBold.setText(""); + btnItalic = new JButton(new StyledEditorKit.ItalicAction()); + btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 24, this)); + btnItalic.setText(""); + btnUnderline = new JButton(new StyledEditorKit.UnderlineAction()); + btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 24, this)); + btnUnderline.setText(""); + editingPanel.add(btnBold); + editingPanel.add(btnItalic); + editingPanel.add(btnUnderline); + grid.add(editingPanel); + grid.add(emptyPanel); + grid.nextRow(); + + // description + txtDescription = new JEditorPane(); + txtDescription.setContentType("text/html"); + txtDescription.setPreferredSize(new Dimension(600,800)); JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); txtDescription.setMinimumSize(Gui.getScaledDimension(0, 60)); -- cgit v1.2.3-55-g7522