diff options
Diffstat (limited to 'dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java')
-rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java index 9bb91409..a3bf0a71 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/LectureCreationPage.java @@ -4,9 +4,17 @@ import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Date; +import java.io.IOException; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import javax.swing.Action; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.StyledEditorKit; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; import org.apache.log4j.Logger; import org.openslx.dozmod.gui.helper.DateTimeHelper; @@ -65,8 +73,102 @@ public class LectureCreationPage extends LectureCreationPageLayout { dtpStartDate.addActionListener(actionListener); dtpEndDate.addActionListener(actionListener); calculateDatePeriod(); + + cbTxtSize.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int size = Integer.parseInt((String) cbTxtSize.getSelectedItem()); + Action act = new StyledEditorKit.FontSizeAction(String.valueOf(size),size); + act.actionPerformed(new ActionEvent(act,ActionEvent.ACTION_PERFORMED, + (String)act.getValue(Action.ACTION_COMMAND_KEY))); + } + }); + + cbTxtColor.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String color = (String) cbTxtColor.getSelectedItem(); + Action act = null; + + switch(color) { + case "Black": + act = new StyledEditorKit.ForegroundAction("Black", Color.black); + break; + case "Blue": + act = new StyledEditorKit.ForegroundAction("Blue", Color.blue); + break; + case "Yellow": + act = new StyledEditorKit.ForegroundAction("Yellow", Color.yellow); + break; + case "Red": + act = new StyledEditorKit.ForegroundAction("Red", Color.red); + break; + case "Green": + act = new StyledEditorKit.ForegroundAction("Green", Color.green); + break; + } + + act.actionPerformed(new ActionEvent(act,ActionEvent.ACTION_PERFORMED, + (String)act.getValue(Action.ACTION_COMMAND_KEY))); + } + }); + + + btnWysiwyg.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + String tmp = txtDescription.getText(); + if (txtDescription.getContentType().equals("text/html")) { + txtDescription.setContentType("text/plain"); + txtDescription.setText(tmp); + btnWysiwyg.setText("Wysiwyg"); + + btnBold.setEnabled(false); + btnUnderline.setEnabled(false); + btnItalic.setEnabled(false); + cbTxtColor.setEnabled(false); + cbTxtSize.setEnabled(false); + } else { + txtDescription.setContentType("text/html"); + txtDescription.setText(tmp); + btnWysiwyg.setText("Html"); + + btnBold.setEnabled(true); + btnUnderline.setEnabled(true); + btnItalic.setEnabled(true); + cbTxtColor.setEnabled(true); + cbTxtSize.setEnabled(true); + } + } + }); + + txtDescription.addKeyListener(new KeyListener() { + @Override + public void keyPressed(KeyEvent e) { + } + + @Override + public void keyTyped(KeyEvent e) { + } + + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER && txtDescription.getContentType().equals("text/html")) { + try { + kit.insertHTML((HTMLDocument) txtDescription.getDocument(), txtDescription.getCaretPosition(), + "<br>", 0, 0, HTML.Tag.BR); + txtDescription.setCaretPosition(txtDescription.getCaretPosition()); // This moves caret to next + // line + } catch (BadLocationException | IOException ex) { + ex.printStackTrace(); + } + } + } + }); } + + @Override protected boolean wantNextOrFinish() { return reactToUserInput(); |