From 9beb3d41963ad42b1b4531b543abeb938615cf93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anian=20B=C3=BChler?= <anian.buehler@reutlingen-university.de> Date: Tue, 9 Feb 2021 15:43:22 +0100 Subject: [PATCH] added support for "Umlaute" and exception-handle for block-insert --- src/main/java/edu/mit/blocks/codeblocks/BlockLink.java | 3 ++- src/main/java/edu/mit/blocks/codeblocks/CommandRule.java | 8 +++++++- .../java/edu/mit/blocks/codeblockutil/LabelWidget.java | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/edu/mit/blocks/codeblocks/BlockLink.java b/src/main/java/edu/mit/blocks/codeblocks/BlockLink.java index 9f401a4..5f4db9f 100644 --- a/src/main/java/edu/mit/blocks/codeblocks/BlockLink.java +++ b/src/main/java/edu/mit/blocks/codeblocks/BlockLink.java @@ -149,7 +149,8 @@ public class BlockLink { // the plug shouldn't be connected by the time we reach here. This // exception will only be thrown if the plug is connected even // after any insertion-esq links were broken above - throw new RuntimeException("trying to link a plug that's already connected somewhere."); + + throw new RuntimeException("trying to link a plug that's already connected somewhere."); } // actually form the connection diff --git a/src/main/java/edu/mit/blocks/codeblocks/CommandRule.java b/src/main/java/edu/mit/blocks/codeblocks/CommandRule.java index c0f0312..6b2ee74 100644 --- a/src/main/java/edu/mit/blocks/codeblocks/CommandRule.java +++ b/src/main/java/edu/mit/blocks/codeblocks/CommandRule.java @@ -48,7 +48,13 @@ public class CommandRule implements LinkRule, WorkspaceListener { } link = BlockLink.getBlockLink(workspace, top, bottom, top.getAfterConnector(), bottom.getBeforeConnector()); - link.connect(); + try{ + link.connect(); + }catch (RuntimeException re) { + //added by letsgoING + //No Output needed -> it works + //System.out.println("catched Exeption: "+ re); + } } } } diff --git a/src/main/java/edu/mit/blocks/codeblockutil/LabelWidget.java b/src/main/java/edu/mit/blocks/codeblockutil/LabelWidget.java index e234f56..ba2d67c 100644 --- a/src/main/java/edu/mit/blocks/codeblockutil/LabelWidget.java +++ b/src/main/java/edu/mit/blocks/codeblockutil/LabelWidget.java @@ -381,7 +381,7 @@ public abstract class LabelWidget extends JComponent { * BlockLabelTextField is a java JtextField that internally handles various events * and provides the semantic to interface with the user. Unlike typical JTextFields, * the blockLabelTextField allows clients to only enter certain keys board input. - * It also reacts to enters and escapse by delegating the KeyEvent to the parent + * It also reacts to enters and escape by delegating the KeyEvent to the parent * RenderableBlock. */ private class BlockLabelTextField extends JTextField implements MouseListener, DocumentListener, FocusListener, ActionListener { @@ -397,7 +397,9 @@ public abstract class LabelWidget extends JComponent { 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '\'', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+', '-', '=', '{', '}', '|', '[', ']', '\\', ' ', - ':', '"', ';', '\'', '<', '>', '?', ',', '.', '/', '`', '~'}; + ':', '"', ';', '\'', '<', '>', '?', ',', '.', '/', '`', '~', + 'ä', 'ö', 'ü', 'Ä', 'Ö', 'Ü', 'ß'}; + /** These Key inputs are processed by all this text field */ @SuppressWarnings("deprecation") private final int[] validMasks = {KeyEvent.VK_BACK_SPACE, -- GitLab