Skip to content
Snippets Groups Projects
Commit d1baf523 authored by palaniappan1's avatar palaniappan1
Browse files

UI and ReadMe.md file Updated

parent 887aeac3
No related branches found
No related tags found
No related merge requests found
com.sse.plugin.crypto/Plugin_View.png

66.6 KiB

......@@ -25,3 +25,21 @@ Type text in the text-field and click the button, the text in the text-field wil
The algorithm used for encryption is a Signature class from javax.crypto.
There is no specific reason in selecting this cryptographic algorithm.
Click the toolbar, it will attach another view with textview and button.
### Changes done in the UI
Added the label below the button. Now my viewGroup for the plugin looks like this
![ViewGroup](ViewGroup.png)
View nested inside another view.
To draw the black border around the viewGroup, I used paintListener method and set the
foreground color to black and set the lineWidth as 5. The divider line in the viewGroup above the
views is simply a line drawn by calculations.
The final plugin view looks like this:
![Plugin View](Plugin_View.png)
com.sse.plugin.crypto/ViewGroup.png

11.1 KiB

package com.sse.plugin.crypto;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.PaintEvent;
import org.eclipse.swt.events.PaintListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.part.ViewPart;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import javax.crypto.Cipher;
import javax.swing.border.LineBorder;
public class View extends ViewPart {
......@@ -21,13 +28,44 @@ public class View extends ViewPart {
@Override
public void createPartControl(Composite parent) {
Text text = new Text(parent, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Group group = new Group(parent, SWT.BORDER);
group.setLayout(new GridLayout(1, false));
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
Composite composite = new Composite(group, SWT.NONE);
GridLayout compositeLayout = new GridLayout(1, false);
compositeLayout.marginWidth = 20;
compositeLayout.marginHeight = 40;
composite.setLayout(compositeLayout);
Text text = new Text(composite, SWT.BORDER);
GridData textLayoutData = new GridData(SWT.NONE, SWT.TOP, true, true);
textLayoutData.widthHint = 200;
text.setLayoutData(textLayoutData);
text.setText("Input");
Button button = new Button(composite, SWT.NONE);
GridData gridData = new GridData(SWT.NONE, SWT.CENTER, false, false);
gridData.horizontalIndent = 40;
gridData.verticalIndent = 20;
button.setLayoutData(gridData);
button.setText("Encrypt");
button.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
gc.setLineWidth(5);
gc.drawRectangle(0, 0, button.getBounds().width - 1, button.getBounds().height - 1);
}
});
Label label = new Label(composite, SWT.NONE);
label.setText("Cipher Text");
Button button = new Button(parent, SWT.PUSH);
button.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
button.setText("encrypt");
button.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
......@@ -35,12 +73,26 @@ public class View extends ViewPart {
String ciphertext;
try {
ciphertext = encrypt(input.getBytes());
text.setText(ciphertext);
label.setText(ciphertext);
} catch (Exception e1) {
e1.printStackTrace();
}
}
});
composite.addPaintListener(new PaintListener() {
@Override
public void paintControl(PaintEvent e) {
GC gc = e.gc;
gc.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
gc.setLineWidth(5);
// int y = composite.getBounds().height / 5;
int y = 25;
gc.drawLine(0, y,composite.getBounds().width - 1 , y);
gc.drawRectangle(0, 0, composite.getBounds().width - 1, composite.getBounds().height - 1);
}
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment