diff options
author | Stephan Schwär | 2021-01-31 09:11:05 +0100 |
---|---|---|
committer | Stephan Schwär | 2021-01-31 09:11:05 +0100 |
commit | cb63f818fd2cb53bbb16ae13c02349c487f150bd (patch) | |
tree | 60de0d17359fdba6ac1734dd7c7aba2f0b3923fb | |
parent | Merge branch 'feature/htmlEditorInDescrioptionText' into feature-merge (diff) | |
download | tutor-module-cb63f818fd2cb53bbb16ae13c02349c487f150bd.tar.gz tutor-module-cb63f818fd2cb53bbb16ae13c02349c487f150bd.tar.xz tutor-module-cb63f818fd2cb53bbb16ae13c02349c487f150bd.zip |
[client] Remove html in description feature
The wysiwyg html description feature has a lot of bugs and is
not yet ready for production. Removing it for now and think
about if and how to implement this feature in the future.
Issue #3732
8 files changed, 5 insertions, 645 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index 93d9d204..efc75236 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -9,19 +9,15 @@ import java.awt.event.ActionListener; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.beans.Encoder; -import java.io.IOException; import java.nio.ByteBuffer; import java.util.*; import java.util.List; import javax.swing.AbstractAction; -import javax.swing.Action; import javax.swing.JComponent; import javax.swing.JFrame; import javax.swing.JMenuItem; @@ -29,12 +25,6 @@ import javax.swing.JOptionPane; import javax.swing.KeyStroke; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLDocument; -import javax.swing.text.html.HTMLEditorKit; import org.apache.log4j.Logger; import org.apache.thrift.TException; @@ -228,101 +218,6 @@ import java.util.*; } }); - 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))); - } - }); - - // change between html and Wysiwyg - 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"); - if(ImagePerms.canEdit(image) || ImagePerms.canAdmin(image)) { - btnSaveChanges.setEnabled(true); - } - - 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); - } - } - }); - - // insertion of <br> in needed because textpane is not able to - // to insert <br> when enter is pressed. - 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(); - } - } - } - }); tblVersions.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); @@ -1026,12 +921,6 @@ import java.util.*; editable = editable && (ImagePerms.canEdit(image) || ImagePerms.canAdmin(image)); txtTitle.setEditable(editable); txtDescription.setEditable(editable); - btnBold.setEnabled(editable); - btnItalic.setEnabled(editable); - btnUnderline.setEnabled(editable); - btnWysiwyg.setEnabled(editable); - cbTxtColor.setEnabled(editable); - cbTxtSize.setEnabled(editable); txtTags.setEditable(editable); cboOperatingSystem.setEnabled(editable); // cboShareMode.setEnabled(editable); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java index dbbdec5e..b98023b0 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/LectureDetailsWindow.java @@ -8,9 +8,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.io.IOException; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -20,18 +17,11 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import javax.swing.Action; import javax.swing.DefaultComboBoxModel; -import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; -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.commons.codec.language.ColognePhonetic; import org.apache.log4j.Logger; import org.apache.thrift.TException; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; @@ -277,102 +267,6 @@ public class LectureDetailsWindow extends LectureDetailsWindowLayout implements } }); - 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))); - } - }); - - // change button for html to Wysiwyg - 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"); - if (ImagePerms.canEdit(image) || ImagePerms.canAdmin(image)) { - btnSaveChanges.setEnabled(true); - } - - 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(); - } - } - } - }); - - // Update default permissions in the permission manager immediately, so it // affects // newly added users diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java index af73d32f..4d141c18 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java @@ -7,7 +7,6 @@ import javax.swing.Box; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JCheckBox; -import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JEditorPane; import javax.swing.JFrame; @@ -17,8 +16,6 @@ import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTextField; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTMLEditorKit; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.ShareMode; @@ -87,14 +84,6 @@ import java.awt.*; protected final ImageVersionTable tblVersions; protected final QScrollPane scpVersions; - protected final JButton btnBold; - protected final JButton btnItalic; - protected final JButton btnUnderline; - protected final JButton btnWysiwyg; - - protected final JComboBox cbTxtSize; - protected final JComboBox cbTxtColor; - protected final HTMLEditorKit kit; protected JTabbedPane pnlTabs; protected ImagePermissionConfigurator ctlImagePermissionConfigurator; @@ -121,50 +110,8 @@ import java.awt.*; grid.add(txtTitle, 3).expand(true, false).fill(true, false); grid.nextRow(); - // buttons for text editing - JPanel editingPanel = new JPanel(); - - editingPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); - JPanel emptyPanel = new JPanel(); - grid.add(emptyPanel); - btnBold = new JButton(new StyledEditorKit.BoldAction()); - btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 15, this)); - btnBold.setText(""); - btnItalic = new JButton(new StyledEditorKit.ItalicAction()); - btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 15, this)); - btnItalic.setText(""); - btnUnderline = new JButton(new StyledEditorKit.UnderlineAction()); - btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 15, this)); - btnUnderline.setText(""); - editingPanel.add(btnBold); - editingPanel.add(btnItalic); - editingPanel.add(btnUnderline); - - String[] textsizes = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"}; - cbTxtSize = new JComboBox<>(textsizes); - cbTxtSize.setPreferredSize(new Dimension(65,25)); - editingPanel.add(cbTxtSize); - - Object[] colors = {"Black", "Blue", "Red", "Yellow", "Green"}; - cbTxtColor = new JComboBox<>(colors); - cbTxtColor.setPreferredSize(new Dimension(100,25)); - editingPanel.add(cbTxtColor); - - grid.add(editingPanel).expand(false, true); - - emptyPanel.setLayout(new FlowLayout()); - btnWysiwyg = new JButton("HTML"); - btnWysiwyg.setPreferredSize(new Dimension(100,25)); - emptyPanel.add(btnWysiwyg); - - grid.add(emptyPanel); - grid.nextRow(); - // description txtDescription = new JEditorPane(); - kit = new HTMLEditorKit(); - txtDescription.setEditorKit(kit); - txtDescription.setContentType("text/html"); grid.add(new QLabel(I18n.WINDOW_LAYOUT.getString("ImageDetails.Label.description.text"))).anchor = GridBagConstraints.FIRST_LINE_START; JScrollPane jsp = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java index 3a100edb..6abdfc47 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureDetailsWindowLayout.java @@ -115,15 +115,6 @@ public abstract class LectureDetailsWindowLayout extends JDialog { protected final JPanel pnlTabNetshare; protected final JPanel pnlTabLdapFilter; - protected final JButton btnBold; - protected final JButton btnItalic; - protected final JButton btnUnderline; - protected final JButton btnWysiwyg; - - protected final JComboBox cbTxtSize; - protected final JComboBox cbTxtColor; - protected final HTMLEditorKit kit; - public LectureDetailsWindowLayout(Frame modalParent) { super(modalParent, I18n.WINDOW_LAYOUT.getString("LectureDetails.Dialog.title"), ModalityType.APPLICATION_MODAL); @@ -192,55 +183,9 @@ public abstract class LectureDetailsWindowLayout extends JDialog { grdGeneral.add(new QLabel(I18n.WINDOW_LAYOUT.getString("LectureDetails.Label.title.text"))); grdGeneral.add(txtTitle, 4).expand(true, false).fill(true, false); grdGeneral.nextRow(); - - // buttons for text editing - JPanel editingPanel = new JPanel(); - - editingPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); - JPanel emptyPanel = new JPanel(); - grdGeneral.add(emptyPanel); - btnBold = new JButton(new StyledEditorKit.BoldAction()); - btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 15, this)); - btnBold.setText(""); - btnItalic = new JButton(new StyledEditorKit.ItalicAction()); - btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 15, this)); - btnItalic.setText(""); - btnUnderline = new JButton(new StyledEditorKit.UnderlineAction()); - btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 15, this)); - btnUnderline.setText(""); - editingPanel.add(btnBold); - editingPanel.add(btnItalic); - editingPanel.add(btnUnderline); - - String[] textsizes = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"}; - cbTxtSize = new JComboBox<>(textsizes); - cbTxtSize.setPreferredSize(new Dimension(65,25)); - editingPanel.add(cbTxtSize); - - Object[] colors = {"Black", "Blue", "Red", "Yellow", "Green"}; - cbTxtColor = new JComboBox<>(colors); - cbTxtColor.setPreferredSize(new Dimension(100,25)); - editingPanel.add(cbTxtColor); - - grdGeneral.add(editingPanel); - - - emptyPanel.setLayout(new FlowLayout()); - btnWysiwyg = new JButton("HTML"); - btnWysiwyg.setPreferredSize(new Dimension(100,25)); - emptyPanel.add(btnWysiwyg); - - grdGeneral.add(emptyPanel); - grdGeneral.add(new JPanel()); - grdGeneral.add(new JPanel()); - - grdGeneral.nextRow(); // description txtDescription = new JEditorPane(); - kit = new HTMLEditorKit(); - txtDescription.setEditorKit(kit); - txtDescription.setContentType("text/html"); grdGeneral.add(new QLabel(I18n.WINDOW_LAYOUT.getString("LectureDetails.Label.description.text"))).anchor(GridBagConstraints.FIRST_LINE_START); JScrollPane jsp = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java index 68b680c8..8d53cba5 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageMetaDataPageLayout.java @@ -1,17 +1,12 @@ package org.openslx.dozmod.gui.wizard.layout; -import java.awt.FlowLayout; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JEditorPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; -import javax.swing.JButton; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTMLEditorKit; -import java.awt.Dimension; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.configurator.ContainerBindMountConfigurator; @@ -37,16 +32,6 @@ import javax.swing.*; protected final JCheckBox chkLicenseRestricted; protected final JCheckBox chkIsTemplate; - protected final JButton btnBold; - protected final JButton btnItalic; - protected final JButton btnUnderline; - protected final JButton btnWysiwyg; - - protected final JComboBox cbTxtSize; - protected final JComboBox cbTxtColor; - protected final HTMLEditorKit kit; - - protected final ContainerBindMountConfigurator bindMountConfigurator; /** @@ -58,7 +43,7 @@ import javax.swing.*; super(wizard, I18n.PAGE_LAYOUT.getString("ImageMetaData.WizardPage.title")); setDescription(I18n.PAGE_LAYOUT.getString("ImageMetaData.WizardPage.description")); - GridManager grid = new GridManager(this, 3, false); + GridManager grid = new GridManager(this, 2, false); lblOperatingSystem = new QLabel(I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.OS.text")); cboOperatingSystem = new ComboBox<>(Comparators.operatingSystem, new ComboBoxRenderer<OperatingSystem>() { @@ -71,7 +56,7 @@ import javax.swing.*; }); cboOperatingSystem.setEditable(false); grid.add(lblOperatingSystem); - grid.add(cboOperatingSystem, 2); + grid.add(cboOperatingSystem); grid.nextRow(); sCommandCaption = new QLabel(I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.startCommand.text")); @@ -84,62 +69,23 @@ import javax.swing.*; startCommandPane.setMinimumSize(startCommand.getMinimumSize()); grid.add(sCommandCaption); grid.add(startCommandPane).fill(true, false).expand(true, false); - grid.add(new JPanel()); grid.nextRow(); - // buttons for text editing - JPanel editingPanel = new JPanel(); - editingPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); - JPanel emptyPanel = new JPanel(); - grid.add(emptyPanel); - btnBold = new JButton(new StyledEditorKit.BoldAction()); - btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 15, this)); - btnBold.setText(""); - btnItalic = new JButton(new StyledEditorKit.ItalicAction()); - btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 15, this)); - btnItalic.setText(""); - btnUnderline = new JButton(new StyledEditorKit.UnderlineAction()); - btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 15, this)); - btnUnderline.setText(""); - editingPanel.add(btnBold); - editingPanel.add(btnItalic); - editingPanel.add(btnUnderline); - - String[] textsizes = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"}; - cbTxtSize = new JComboBox<>(textsizes); - cbTxtSize.setPreferredSize(new Dimension(65,25)); - editingPanel.add(cbTxtSize); - - Object[] colors = {"Black", "Blue", "Red", "Yellow", "Green"}; - cbTxtColor = new JComboBox<>(colors); - cbTxtColor.setPreferredSize(new Dimension(95,25)); - editingPanel.add(cbTxtColor); - - grid.add(editingPanel); - emptyPanel.setLayout(new FlowLayout()); - btnWysiwyg = new JButton("HTML"); - btnWysiwyg.setPreferredSize(new Dimension(100,25)); - emptyPanel.add(btnWysiwyg); - grid.add(emptyPanel); - grid.nextRow(); // description QLabel descriptionCaption = new QLabel(I18n.PAGE_LAYOUT.getString("ImageMetaData.Label.description.text")); txtDescription = new JEditorPane(); txtDescription.setMinimumSize(Gui.getScaledDimension(0, 70)); - kit = new HTMLEditorKit(); - txtDescription.setEditorKit(kit); - txtDescription.setContentType("text/html"); JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); grid.add(descriptionCaption); - grid.add(descPane, 2).fill(true, true).expand(true, true); + grid.add(descPane).fill(true, true).expand(true, true); grid.nextRow(); chkLicenseRestricted = new JCheckBox( I18n.PAGE_LAYOUT.getString("ImageMetaData.CheckBox.licenseRestricted.text")); chkLicenseRestricted.setSelected(true); - grid.add(chkLicenseRestricted, 3); + grid.add(chkLicenseRestricted, 2); grid.nextRow(); bindMountConfigurator = new ContainerBindMountConfigurator(); @@ -150,7 +96,7 @@ import javax.swing.*; // -- end permissions group -- chkIsTemplate = new JCheckBox(I18n.PAGE_LAYOUT.getString("ImageMetaData.CheckBox.isTemplate.text")); - grid.add(chkIsTemplate, 3); + grid.add(chkIsTemplate, 2); grid.nextRow(); grid.finish(true); 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 771dc60e..1149a6c9 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 @@ -1,19 +1,13 @@ package org.openslx.dozmod.gui.wizard.layout; import java.util.Calendar; -import java.awt.FlowLayout; import javax.swing.JScrollPane; import javax.swing.JSpinner; import javax.swing.JTextField; -import javax.swing.JPanel; -import javax.swing.JButton; -import javax.swing.JComboBox; import javax.swing.JEditorPane; import javax.swing.SpinnerDateModel; import javax.swing.text.DateFormatter; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTMLEditorKit; import org.openslx.dozmod.gui.Gui; import org.openslx.dozmod.gui.control.QDatePickerImpl; @@ -24,7 +18,6 @@ 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 { @@ -37,16 +30,6 @@ public abstract class LectureCreationPageLayout extends WizardPage { protected final JSpinner spnEndTime; protected final QLabel lblCalcPeriod; - protected final JButton btnBold; - protected final JButton btnItalic; - protected final JButton btnUnderline; - protected final JButton btnWysiwyg; - - protected final JComboBox cbTxtSize; - protected final JComboBox cbTxtColor; - protected final HTMLEditorKit kit; - - /** * Page for creating lectures * @@ -63,48 +46,8 @@ public abstract class LectureCreationPageLayout extends WizardPage { grid.add(txtName, 2).fill(true, false).expand(true, false); grid.nextRow(); - // buttons for text editing - JPanel editingPanel = new JPanel(); - editingPanel.setLayout(new FlowLayout(FlowLayout.LEADING)); - JPanel emptyPanel = new JPanel(); - grid.add(emptyPanel); - btnBold = new JButton(new StyledEditorKit.BoldAction()); - btnBold.setIcon(Gui.getScaledIconResource("/img/bold.png", "B", 15, this)); - btnBold.setText(""); - btnItalic = new JButton(new StyledEditorKit.ItalicAction()); - btnItalic.setIcon(Gui.getScaledIconResource("/img/italic.png", "B", 15, this)); - btnItalic.setText(""); - btnUnderline = new JButton(new StyledEditorKit.UnderlineAction()); - btnUnderline.setIcon(Gui.getScaledIconResource("/img/underline.png", "B", 15, this)); - btnUnderline.setText(""); - editingPanel.add(btnBold); - editingPanel.add(btnItalic); - editingPanel.add(btnUnderline); - - String[] textsizes = {"10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29"}; - cbTxtSize = new JComboBox<>(textsizes); - cbTxtSize.setPreferredSize(new Dimension(65,25)); - editingPanel.add(cbTxtSize); - - Object[] colors = {"Black", "Blue", "Red", "Yellow", "Green"}; - cbTxtColor = new JComboBox<>(colors); - cbTxtColor.setPreferredSize(new Dimension(95,25)); - editingPanel.add(cbTxtColor); - - grid.add(editingPanel); - emptyPanel.setLayout(new FlowLayout()); - btnWysiwyg = new JButton("HTML"); - btnWysiwyg.setPreferredSize(new Dimension(100,25)); - emptyPanel.add(btnWysiwyg); - - grid.add(emptyPanel); - grid.nextRow(); - // description txtDescription = new JEditorPane(); - kit = new HTMLEditorKit(); - txtDescription.setEditorKit(kit); - txtDescription.setContentType("text/html"); txtDescription.setPreferredSize(new Dimension(600,800)); JScrollPane descPane = new JScrollPane(txtDescription, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java index 68beb655..f2010da1 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageMetaDataPage.java @@ -4,19 +4,6 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.Collections; import java.util.List; -import java.awt.Color; - -import javax.swing.Action; -import javax.swing.text.BadLocationException; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.html.HTML; -import javax.swing.text.html.HTMLDocument; - -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.io.IOException; import org.apache.log4j.Logger; import org.openslx.bwlp.thrift.iface.OperatingSystem; @@ -89,97 +76,6 @@ import java.util.List; reactToUserInput(); } }); - - 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(); - } - } - } - }); } 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 71e6fe6d..ffa37134 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,17 +4,9 @@ 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; @@ -75,98 +67,6 @@ 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(); - } - } - } - }); } |