Skip to content

Commit

Permalink
GUI changes
Browse files Browse the repository at this point in the history
- Replaced the hard Borders of the composites in the attack tabs with
groups that have a smoother border.
- Added a separator between the buttons "Decrypt ciphertexts" and "Back
to Key Generation and Encryption" in the attack tabs
References Issue jcryptool#40
Code cleanup

Added @OverRide tags
Added ColorService to manifest.mf

Replaced Color selction with jct default colorService
Changed foreground color and background color
Gave the description more space
  • Loading branch information
Thorben committed Sep 19, 2018
1 parent fa42087 commit 637b335
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 88 deletions.
1 change: 1 addition & 0 deletions org.jcryptool.visual.kleptography/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-Vendor: %Bundle-Vendor
Import-Package: org.jcryptool.core.logging.utils,
org.jcryptool.core.util.colors,
org.jcryptool.core.util.fonts
Export-Package: org.jcryptool.visual.kleptography,
org.jcryptool.visual.kleptography.algorithm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
* @version 0.9.5
*/
public class RestartHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (HandlerUtil.getActivePart(event) instanceof KleptoView) {
KleptoView view = ((KleptoView) HandlerUtil.getActivePart(event));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
import org.jcryptool.core.util.colors.ColorService;
import org.jcryptool.visual.kleptography.KleptographyPlugin;
import org.jcryptool.visual.kleptography.algorithm.Kleptography;

Expand Down Expand Up @@ -69,19 +69,11 @@ public enum PrimeGenSetting {
private Composite parent;

// Define all the colors at once.
public static final Color WHITE;
public static final Color BACKGROUND_GRAY;
public static final Color FOREGROUND_GRAY;
public static final Color BLACK;
public static final Color YELLOW;
static {
final Display d = Display.getDefault();
WHITE = d.getSystemColor(SWT.COLOR_WHITE);
BACKGROUND_GRAY = d.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
FOREGROUND_GRAY = d.getSystemColor(SWT.COLOR_GRAY);
BLACK = d.getSystemColor(SWT.COLOR_BLACK);
YELLOW = d.getSystemColor(SWT.COLOR_YELLOW);
}
public static final Color WHITE = ColorService.WHITE;
public static final Color BACKGROUND_GRAY = ColorService.LIGHTGRAY;
public static final Color FOREGROUND_GRAY = ColorService.GRAY;
public static final Color BLACK = ColorService.BLACK;
public static final Color YELLOW = ColorService.YELLOW;

@Override
public void createPartControl(final Composite parent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ private void createContents(final Shell shell) {
bFirst.setLayoutData(data);

bFirst.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setSelection(1);
shell.close();
Expand All @@ -102,6 +103,7 @@ public void widgetSelected(SelectionEvent event) {
bSecond.setLayoutData(data);

bSecond.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setSelection(2);
shell.close();
Expand All @@ -114,6 +116,7 @@ public void widgetSelected(SelectionEvent event) {
bCancel.setLayoutData(data);

bCancel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
setSelection(-1);
shell.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class RSAAttackView extends Composite {

private Composite cAttackFixed;
private Composite cFieldsFixed;
private Composite cButtonsFixed;
private Group cButtonsFixed;
private Group gPublicKeysFixed;
private Group gCalculationsFixed;
private Group gCipherTextFixed;
Expand Down Expand Up @@ -91,7 +91,7 @@ public class RSAAttackView extends Composite {
private Text tTextSETUP1;
private Text tTextSETUP2;
private Composite cAttackSETUP;
private Composite cButtonsSETUP;
private Group cButtonsSETUP;
private Button bCalcPrivateKeysSETUP;
private Button bDecryptTextsSETUP;
private Label lQSETUP1;
Expand Down Expand Up @@ -128,6 +128,10 @@ public class RSAAttackView extends Composite {
private Label lEncryptedP;
private StyledText tEncryptedP;

private Label lhorizontalSeparatorFixed;

private Label lhorizontalSeparatorSETUP;

/**
* Constructor for the attack view. Sets up the layout of the tab.
* @param parent The parent composite (the Attack tab).
Expand Down Expand Up @@ -209,17 +213,21 @@ private void setUpAttackStack(Composite localParent) {
* @param localParent The Fixed P composite contained in the StackLayout.
*/
private void setUpAttackFixed(Composite localParent) {
cButtonsFixed = new Composite(localParent, SWT.BORDER);
cButtonsFixed.setLayout(new GridLayout(1, false));
cButtonsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

setUpButtonsFixed(cButtonsFixed);

cFieldsFixed = new Composite(localParent, SWT.BORDER);
cFieldsFixed.setLayout(new GridLayout(1, false));
cFieldsFixed = new Composite(localParent, SWT.NONE);
GridLayout gl_cFieldsFixed = new GridLayout(1, false);
gl_cFieldsFixed.marginWidth = 0;
gl_cFieldsFixed.marginHeight = 0;
cFieldsFixed.setLayout(gl_cFieldsFixed);
cFieldsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));

setUpFieldsFixed(cFieldsFixed);

cButtonsFixed = new Group(localParent, SWT.NONE);
cButtonsFixed.setLayout(new GridLayout(1, false));
cButtonsFixed.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

setUpButtonsFixed(cButtonsFixed);
}

/**
Expand All @@ -238,6 +246,11 @@ private void setUpButtonsFixed(Composite localParent) {
bDecryptTextsFixed = new Button(localParent, SWT.PUSH);
bDecryptTextsFixed.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
bDecryptTextsFixed.setText(Messages.RSAAttackView_Fixed_Decrypt_Cipher);

lhorizontalSeparatorFixed = new Label(localParent, SWT.HORIZONTAL | SWT.SEPARATOR);
GridData gd_lhorizontalSeparatorFixed = new GridData(SWT.FILL, SWT.CENTER, false, false);
gd_lhorizontalSeparatorFixed.verticalIndent = 15;
lhorizontalSeparatorFixed.setLayoutData(gd_lhorizontalSeparatorFixed);

bBackFixed = new Button(localParent, SWT.PUSH);
bBackFixed.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
Expand Down Expand Up @@ -524,17 +537,21 @@ private void setUpDecryptionsFixed(Composite localParent) {
* @param localParent The parent control of the SETUP fields.
*/
private void setUpAttackSETUP(Composite localParent) {
cButtonsSETUP = new Composite(localParent, SWT.BORDER);
cButtonsSETUP.setLayout(new GridLayout(1, false));
cButtonsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

setUpButtonsSETUP(cButtonsSETUP);

cFieldsSETUP = new Composite(localParent, SWT.BORDER);
cFieldsSETUP.setLayout(new GridLayout(1, false));
cFieldsSETUP = new Composite(localParent, SWT.NONE);
GridLayout gl_cFieldsSETUP = new GridLayout(1, false);
gl_cFieldsSETUP.marginWidth = 0;
gl_cFieldsSETUP.marginHeight = 0;
cFieldsSETUP.setLayout(gl_cFieldsSETUP);
cFieldsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1));

setUpFieldsSETUP(cFieldsSETUP);

cButtonsSETUP = new Group(localParent, SWT.NONE);
cButtonsSETUP.setLayout(new GridLayout(1, false));
cButtonsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 1, 1));

setUpButtonsSETUP(cButtonsSETUP);
}

/**
Expand All @@ -553,6 +570,11 @@ private void setUpButtonsSETUP(Composite localParent) {
bDecryptTextsSETUP = new Button(localParent, SWT.PUSH);
bDecryptTextsSETUP.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
bDecryptTextsSETUP.setText(Messages.RSAAttackView_SETUP_Decrypt_Cipher);

lhorizontalSeparatorSETUP = new Label(localParent, SWT.HORIZONTAL | SWT.SEPARATOR);
GridData gd_lhorizontalSeparatorSETUP = new GridData(SWT.FILL, SWT.CENTER, false, false);
gd_lhorizontalSeparatorSETUP.verticalIndent = 15;
lhorizontalSeparatorSETUP.setLayoutData(gd_lhorizontalSeparatorSETUP);

bBackSETUP = new Button(localParent, SWT.PUSH);
bBackSETUP.setLayoutData(new GridData(SWT.FILL, SWT.TOP, false, false, 1, 1));
Expand Down Expand Up @@ -948,9 +970,11 @@ public void saveCipherTextSETUP() {
*/
private void setUpAttackListeners() {
bCalcGCD.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
// If the user used the same N to generate both saved ciphertexts,
// the attack won't work. Let the user know and don't bother trying.
Expand All @@ -972,9 +996,11 @@ public void widgetSelected(SelectionEvent e) {
});

bCalcPrivateKeysFixed.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.currentStep = 18;
kleptoView.klepto.attack.calculatePrivateKeysFixed();
Expand All @@ -992,9 +1018,11 @@ public void widgetSelected(SelectionEvent e) {
});

bDecryptTextsFixed.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.currentStep = 19;
kleptoView.klepto.attack.decryptFixed();
Expand All @@ -1005,9 +1033,11 @@ public void widgetSelected(SelectionEvent e) {
});

bDecryptP.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.currentStep = 10;
kleptoView.klepto.attack.getPFromN(
Expand All @@ -1022,9 +1052,11 @@ public void widgetSelected(SelectionEvent e) {
});

bCalcPrivateKeysSETUP.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.currentStep = 11;
kleptoView.klepto.attack.calculatePrivateKeysSETUP();
Expand All @@ -1042,9 +1074,11 @@ public void widgetSelected(SelectionEvent e) {
});

bDecryptTextsSETUP.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.currentStep = 12;
kleptoView.klepto.attack.decryptSETUP();
Expand All @@ -1055,18 +1089,22 @@ public void widgetSelected(SelectionEvent e) {
});

bBackFixed.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.setTabSelection(0);
}
});

bBackSETUP.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent e) {
widgetSelected(e);
}
@Override
public void widgetSelected(SelectionEvent e) {
kleptoView.setTabSelection(0);
}
Expand Down
Loading

0 comments on commit 637b335

Please sign in to comment.