Fixed some bugs, removed Debug-Code, Check some additional Corner Cases, some QOL
This commit is contained in:
parent
884fc16298
commit
6f96290026
|
@ -88,8 +88,9 @@ public class KorrekturHelper
|
||||||
for (var li = 0; li < lines.length; li++)
|
for (var li = 0; li < lines.length; li++)
|
||||||
{
|
{
|
||||||
var line = lines[li];
|
var line = lines[li];
|
||||||
|
if (getIndent(line) != path.size())
|
||||||
|
{ throw new IllegalStateException("Indentation error on Line" + lineMap[li] + "!"); }
|
||||||
var cmd = line.substring(path.size()).split("\t", 2)[0];
|
var cmd = line.substring(path.size()).split("\t", 2)[0];
|
||||||
System.out.println(indent(path.size()) + lineMap[li] + " - " + cmd + " - " + line);
|
|
||||||
var n = switch (cmd)
|
var n = switch (cmd)
|
||||||
{
|
{
|
||||||
case "!header": // !header # Test-Schema
|
case "!header": // !header # Test-Schema
|
||||||
|
@ -108,8 +109,6 @@ public class KorrekturHelper
|
||||||
var i = li + 1;
|
var i = li + 1;
|
||||||
for (; i < lines.length; i++)
|
for (; i < lines.length; i++)
|
||||||
{
|
{
|
||||||
System.out.println(indent(path.size() + 1) + lineMap[i] + " - " + cmd + " - " + lines[i]);
|
|
||||||
System.out.println(getIndent(lines[i]) + " - " + path.size());
|
|
||||||
if (getIndent(lines[i]) != path.size() + 1)
|
if (getIndent(lines[i]) != path.size() + 1)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -131,7 +130,7 @@ public class KorrekturHelper
|
||||||
throw new IOException("Indentation Error on Line " + lineMap[li] + "!");
|
throw new IOException("Indentation Error on Line " + lineMap[li] + "!");
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new IOException("Unknown Command: " + cmd);
|
throw new IOException("Unknown Command on Line " + lineMap[li] + ": " + cmd);
|
||||||
};
|
};
|
||||||
if (!path.isEmpty())
|
if (!path.isEmpty())
|
||||||
{
|
{
|
||||||
|
@ -297,12 +296,14 @@ public class KorrekturHelper
|
||||||
}
|
}
|
||||||
|
|
||||||
private final JButton btn_toClipboard;
|
private final JButton btn_toClipboard;
|
||||||
|
|
||||||
private String currentHtml = "";
|
private String currentHtml = "";
|
||||||
/** The JFrame for this {@link KorrekturHelper} */
|
/** The JFrame for this {@link KorrekturHelper} */
|
||||||
public final JFrame frm;
|
public final JFrame frm;
|
||||||
|
|
||||||
private final HtmlContext hc;
|
private final HtmlContext hc;
|
||||||
|
|
||||||
|
private boolean inReset = false;
|
||||||
|
|
||||||
private final LinkedHashSet<Node> nodes;
|
private final LinkedHashSet<Node> nodes;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,7 +336,7 @@ public class KorrekturHelper
|
||||||
btn_toClipboard.addActionListener(e -> copyToClipboard());
|
btn_toClipboard.addActionListener(e -> copyToClipboard());
|
||||||
menuPanel.add(btn_toClipboard);
|
menuPanel.add(btn_toClipboard);
|
||||||
var btn_reset = new JButton("Reset");
|
var btn_reset = new JButton("Reset");
|
||||||
btn_reset.addActionListener(e -> this.nodes.forEach(Node::reset));
|
btn_reset.addActionListener(e -> reset());
|
||||||
menuPanel.add(btn_reset);
|
menuPanel.add(btn_reset);
|
||||||
contentPanel.add(menuPanel, BorderLayout.NORTH);
|
contentPanel.add(menuPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
@ -345,6 +346,7 @@ public class KorrekturHelper
|
||||||
var panel = new JPanel(true);
|
var panel = new JPanel(true);
|
||||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||||
var jsp = new JScrollPane(panel);
|
var jsp = new JScrollPane(panel);
|
||||||
|
jsp.getVerticalScrollBar().setUnitIncrement(16);
|
||||||
Consumer<Node> c = n -> verifyClipboard();
|
Consumer<Node> c = n -> verifyClipboard();
|
||||||
for (var n : nodes)
|
for (var n : nodes)
|
||||||
{
|
{
|
||||||
|
@ -378,11 +380,24 @@ public class KorrekturHelper
|
||||||
btn_toClipboard.setBackground(Color.GREEN);
|
btn_toClipboard.setBackground(Color.GREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the Input Mask
|
||||||
|
*/
|
||||||
|
public synchronized void reset()
|
||||||
|
{
|
||||||
|
inReset = true;
|
||||||
|
this.nodes.forEach(Node::reset);
|
||||||
|
inReset = false;
|
||||||
|
verifyClipboard();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on change of data or when the System signifies, the Clipboard changed
|
* Called on change of data or when the System signifies, the Clipboard changed
|
||||||
*/
|
*/
|
||||||
public synchronized void verifyClipboard()
|
public synchronized void verifyClipboard()
|
||||||
{
|
{
|
||||||
|
if (inReset)
|
||||||
|
{ return; }
|
||||||
var sb = new StringBuilder();
|
var sb = new StringBuilder();
|
||||||
recursiveToHtml(nodes, sb, hc, 0);
|
recursiveToHtml(nodes, sb, hc, 0);
|
||||||
currentHtml = sb.toString();
|
currentHtml = sb.toString();
|
||||||
|
|
|
@ -3,13 +3,13 @@
|
||||||
:base 0.0
|
:base 0.0
|
||||||
// Design für Punkte. Pts ist dabei für die Punkte, PtsText für den Text. die Punkte zählen als Teil des Textes (<li style=PtsText><span style=Pts>'Punkte'</span>Text</li>)
|
// Design für Punkte. Pts ist dabei für die Punkte, PtsText für den Text. die Punkte zählen als Teil des Textes (<li style=PtsText><span style=Pts>'Punkte'</span>Text</li>)
|
||||||
// full -> best-Case
|
// full -> best-Case
|
||||||
:fullPts color: #0f0;
|
:fullPts color: #0f0; font-weight: bold;
|
||||||
:fullPtsText
|
:fullPtsText
|
||||||
// no -> worst-case
|
// no -> worst-case
|
||||||
:noPts color: #f00;
|
:noPts color: #f00; font-weight: bold;
|
||||||
:noPtsText
|
:noPtsText
|
||||||
// partial -> alle verbleibenden Fälle. Sonderfall: Elemente die 0 Punkte bringen (egal was ausgewählt ist) haben auch diesen Fall!
|
// partial -> alle verbleibenden Fälle. Sonderfall: Elemente die 0 Punkte bringen (egal was ausgewählt ist) haben auch diesen Fall!
|
||||||
:partialPts color: #fb0;
|
:partialPts color: #fb0; font-weight: bold;
|
||||||
:partialPtsText
|
:partialPtsText
|
||||||
:cbmsOk color: #080;
|
:cbmsOk color: #080;
|
||||||
:cbmsFail color: #800;
|
:cbmsFail color: #800;
|
||||||
|
|
|
@ -61,12 +61,14 @@ public class EitherNode extends AbstractNode
|
||||||
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
|
content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
|
||||||
content.add(btn_ok);
|
content.add(btn_ok);
|
||||||
content.add(btn_fail);
|
content.add(btn_fail);
|
||||||
|
btn_ok.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void _reset()
|
protected void _reset()
|
||||||
{
|
{
|
||||||
bg.clearSelection();
|
bg.clearSelection();
|
||||||
|
btn_ok.doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -128,7 +130,9 @@ public class EitherNode extends AbstractNode
|
||||||
Utils.formatPoints(achievedPoints(hc.mc)) + //
|
Utils.formatPoints(achievedPoints(hc.mc)) + //
|
||||||
(points.signum() < 0 ? "" : " / " + Utils.formatPoints(maximumPoints())) + "P" + //
|
(points.signum() < 0 ? "" : " / " + Utils.formatPoints(maximumPoints())) + "P" + //
|
||||||
"</span> " + //
|
"</span> " + //
|
||||||
(btn_fail.isSelected() ? btn_fail.getText() : btn_ok.getText()) + //
|
(points.signum() < 0 ? btn_fail.isSelected() ? messageOK : messageFail
|
||||||
|
: btn_fail.isSelected() ? messageFail : messageOK)
|
||||||
|
+ //
|
||||||
"</li>";
|
"</li>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package de.tuDortmund.cs.rvs.pingger.korrekturHelper.nodes;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.MathContext;
|
import java.math.MathContext;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import javax.swing.BoxLayout;
|
import javax.swing.BoxLayout;
|
||||||
import javax.swing.ButtonGroup;
|
import javax.swing.ButtonGroup;
|
||||||
|
@ -57,7 +58,6 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
var s = lines[i].substring(1).split("\t");
|
var s = lines[i].substring(1).split("\t");
|
||||||
if (s.length != 2)
|
if (s.length != 2)
|
||||||
{ throw new IllegalArgumentException("Expected exactly 1 \\t"); }
|
{ throw new IllegalArgumentException("Expected exactly 1 \\t"); }
|
||||||
System.out.println(s[0] + "\t" + s[1]);
|
|
||||||
points[i - 1] = new BigDecimal(s[0]);
|
points[i - 1] = new BigDecimal(s[0]);
|
||||||
text[i - 1] = s[1];
|
text[i - 1] = s[1];
|
||||||
rbs[i - 1] = new JRadioButton(Utils.formatPoints(points[i - 1]) + "P - " + text[i - 1]);
|
rbs[i - 1] = new JRadioButton(Utils.formatPoints(points[i - 1]) + "P - " + text[i - 1]);
|
||||||
|
@ -65,17 +65,21 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
content.add(rbs[i - 1]);
|
content.add(rbs[i - 1]);
|
||||||
bg.add(rbs[i - 1]);
|
bg.add(rbs[i - 1]);
|
||||||
}
|
}
|
||||||
|
rbs[0].doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void _reset()
|
protected void _reset()
|
||||||
{
|
{
|
||||||
bg.clearSelection();
|
bg.clearSelection();
|
||||||
|
rbs[0].doClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal achievedPoints(MathContext mc)
|
public BigDecimal achievedPoints(MathContext mc)
|
||||||
{
|
{
|
||||||
|
if (!isVisibleInResultHtml())
|
||||||
|
{ return BigDecimal.ZERO; }
|
||||||
return points[getSelected()];
|
return points[getSelected()];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,17 +90,17 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
if (rbs[i].isSelected())
|
if (rbs[i].isSelected())
|
||||||
{ return i; }
|
{ return i; }
|
||||||
}
|
}
|
||||||
return rbs.length - 1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVisibleInResultHtml()
|
public boolean isVisibleInResultHtml()
|
||||||
{ return true; }
|
{ return Arrays.stream(rbs).anyMatch(JRadioButton::isSelected); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BigDecimal maximumPoints()
|
public BigDecimal maximumPoints()
|
||||||
{
|
{
|
||||||
return maxPoints;
|
return isVisibleInResultHtml() ? maxPoints : BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -123,6 +127,13 @@ public class RadioMultiSelectNode extends AbstractNode
|
||||||
@Override
|
@Override
|
||||||
public String toResultHtml(HtmlContext hc)
|
public String toResultHtml(HtmlContext hc)
|
||||||
{
|
{
|
||||||
|
if (!isVisibleInResultHtml())
|
||||||
|
{
|
||||||
|
return "<li" + hc.styleText(BigDecimal.ZERO, maxPoints) + ">" + //
|
||||||
|
"<span" + hc.stylePts(achievedPoints(hc.mc), maxPoints) + ">" + //
|
||||||
|
Utils.formatPoints(BigDecimal.ZERO) + " / " + Utils.formatPoints(maxPoints) + "P</span> " + //
|
||||||
|
(baseMsg == null ? "" : baseMsg) + "</li>";
|
||||||
|
}
|
||||||
return "<li" + hc.styleText(achievedPoints(hc.mc), maxPoints) + ">" + //
|
return "<li" + hc.styleText(achievedPoints(hc.mc), maxPoints) + ">" + //
|
||||||
"<span" + hc.stylePts(achievedPoints(hc.mc), maxPoints) + "> " + //
|
"<span" + hc.stylePts(achievedPoints(hc.mc), maxPoints) + "> " + //
|
||||||
Utils.formatPoints(achievedPoints(hc.mc)) + " / " + Utils.formatPoints(maxPoints) + "P</span> " + //
|
Utils.formatPoints(achievedPoints(hc.mc)) + " / " + Utils.formatPoints(maxPoints) + "P</span> " + //
|
||||||
|
|
Loading…
Reference in New Issue