jcryptool / crypto

JCrypTool Crypto Plug-ins
https://www.cryptool.org
Eclipse Public License 1.0
68 stars 39 forks source link

McEliece plugin GUI improvements #359

Closed grthor closed 3 years ago

grthor commented 3 years ago

I reworked the GUI of the McEliece Plugin. Here are some screenshots of the new GUI:

McElice1 McElice2 McElice3
grthor commented 3 years ago

Hi @simlei , I have two questions:

  1. I want to add the sample editor text ("This is the JCrypTool sample file.") as default input to the plaintext field. Where can I find this text? In my optionion copying the text to the plugin is not the way to get the text.
  2. In the second tab (Algorithm) I added a mouse hoover listener (https://github.com/grthor/crypto/blob/5aa51b1cd7763537bff4c3e1aad610b4d81a3f55/org.jcryptool.visual.errorCorrectingCodes/src/org/jcryptool/visual/errorcorrectingcodes/ui/widget/InteractiveMatrix.java#L91-L107) to the clickable matrice fields. The listener changes the mouse arrow to a hand when you hoover about one of the fields. When the JCT has focus, this works fine. If the JCT does not have focus and you hoover about a field, an exception is thrown:
    !MESSAGE Unhandled event loop exception
    !STACK 0
    java.lang.NullPointerException
    at org.jcryptool.visual.errorcorrectingcodes.ui.widget.InteractiveMatrix$1.mouseExit(InteractiveMatrix.java:100)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:208)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)

    Do you have an idea, why this exception is thrown?

simlei commented 3 years ago
  1. I want to add the sample editor text ("This is the JCrypTool sample file.") as default input to the plaintext field. Where can I find this text? In my optionion copying the text to the plugin is not the way to get the text.

/org.jcryptool.core.operations/templates/en.txt You'll have to load the resource stream but there is also existing code: https://github.com/jcryptool/core/blob/5cb0c5701be9339e8b8d5b8def022cf7a6240537/org.jcryptool.core.operations/src/org/jcryptool/core/operations/editors/AbstractEditorService.java#L249

  1. In the second tab (Algorithm) I added a mouse hoover listener (https://github.com/grthor/crypto/blob/5aa51b1cd7763537bff4c3e1aad610b4d81a3f55/org.jcryptool.visual.errorCorrectingCodes/src/org/jcryptool/visual/errorcorrectingcodes/ui/widget/InteractiveMatrix.java#L91-L107) to the clickable matrice fields. The listener changes the mouse arrow to a hand when you hoover about one of the fields. When the JCT has focus, this works fine. If the JCT does not have focus and you hoover about a field, an exception is thrown:
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
  at org.jcryptool.visual.errorcorrectingcodes.ui.widget.InteractiveMatrix$1.mouseExit(InteractiveMatrix.java:100)
  at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:208)
  at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:89)

Do you have an idea, why this exception is thrown?

Pretty sure this goes away when you use InteractiveMatrix.this.getDisplay(), instead of Display.getCurrent().

grthor commented 3 years ago

Hi @simlei , loading the default text from your address worked. Fixing the NullPointerException by changing Display.getCurrent() to InteractiveMatrix.this.getDisplay() does not work. I added a check if the display is not equal to null if the listerner is called. Not the best solution, but it works.

I will merge the changes now. Ignore the failing build check. On my computer the build works.