Compare commits

..

No commits in common. "master" and "v1.2.0" have entirely different histories.

1 changed files with 24 additions and 65 deletions

View File

@ -301,15 +301,14 @@ public class KorrekturHelper
private final JButton btn_toClipboard;
private final JPanel contentPanel, menuPanel;
private String currentHtml = "";
/** The JFrame for this {@link KorrekturHelper} */
public final JFrame frm;
private HtmlContext hc;
private final HtmlContext hc;
private boolean inReset = false;
private LinkedHashSet<Node> nodes;
private final LinkedHashSet<Node> nodes;
/**
* @param nodes Nodes
@ -317,13 +316,16 @@ public class KorrekturHelper
*/
public KorrekturHelper(LinkedHashSet<Node> nodes, HtmlContext hc)
{
this.nodes = nodes;
this.hc = hc;
frm = new JFrame("Pinggers Korrektur Helper");
frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPanel = new JPanel(new BorderLayout(), true);
var contentPanel = new JPanel(new BorderLayout(), true);
/*
* Menu Panel
*/
menuPanel = new JPanel(true);
var menuPanel = new JPanel(true);
menuPanel.setLayout(new BoxLayout(menuPanel, BoxLayout.X_AXIS));
var jtb_aot = new JToggleButton("Always on Top");
@ -337,20 +339,28 @@ public class KorrekturHelper
btn_toClipboard = new JButton("Copy to Clipboard");
btn_toClipboard.addActionListener(e -> copyToClipboard());
menuPanel.add(btn_toClipboard);
var btn_drop = new JButton("Open Schema");
btn_drop.addActionListener(e -> fileDialog());
menuPanel.add(btn_drop);
var btn_reset = new JButton("Reset");
btn_reset.addActionListener(e -> reset());
menuPanel.add(btn_reset);
contentPanel.add(menuPanel, BorderLayout.NORTH);
setNodes(nodes, hc);
/*
* Node-Panel with Scrollpane
*/
var panel = new JPanel(true);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
var jsp = new JScrollPane(panel);
jsp.getVerticalScrollBar().setUnitIncrement(16);
Consumer<Node> c = n -> verifyClipboard();
for (var n : nodes)
{
n.addChangeListener(c);
panel.add(n.getComponent());
}
contentPanel.add(jsp, BorderLayout.CENTER);
frm.setContentPane(contentPanel);
frm.pack();
if (frm.getHeight() > 900)
{
frm.setSize(frm.getWidth(), 900);
}
}
/**
@ -374,29 +384,6 @@ public class KorrekturHelper
btn_toClipboard.setBackground(Color.GREEN);
}
private void fileDialog()
{
var x = new JFileChooser();
if (x.showOpenDialog(frm) == JFileChooser.APPROVE_OPTION)
{
var f = x.getSelectedFile();
try (
var in = new FileInputStream(f);
var isr = new InputStreamReader(in, StandardCharsets.UTF_8);
var br = new BufferedReader(isr, 1024 * 1024)
)
{
var hc = new HtmlContext();
var n = parseSchema(br, hc);
setNodes(n, hc);
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
/**
* Resets the Input Mask
*/
@ -408,34 +395,6 @@ public class KorrekturHelper
verifyClipboard();
}
/**
* Set the Nodes and {@link HtmlContext}
*
* @param nodes nodes
* @param hc context
*/
public void setNodes(LinkedHashSet<Node> nodes, HtmlContext hc)
{
this.nodes = nodes;
this.hc = hc;
/*
* Node-Panel with Scrollpane
*/
var panel = new JPanel(true);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
var jsp = new JScrollPane(panel);
jsp.getVerticalScrollBar().setUnitIncrement(16);
Consumer<Node> c = n -> verifyClipboard();
for (var n : nodes)
{
n.addChangeListener(c);
panel.add(n.getComponent());
}
contentPanel.removeAll();
contentPanel.add(menuPanel, BorderLayout.NORTH);
contentPanel.add(jsp, BorderLayout.CENTER);
}
/**
* Called on change of data or when the System signifies, the Clipboard changed
*/