summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/wizards/ImageUploadPage.java
blob: b4f36589858becce291014cba54978ff65fce599 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package wizards;


import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
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.Label;
import org.eclipse.swt.widgets.Text;



public class ImageUploadPage extends WizardPage {

	protected Text imageName;
	protected Composite container;
	protected boolean editExistingImage;
	protected Button imageFileBrowseButton;



	/**
	 * Page for uploading an imagefile
	 * @param editExistingImage wether to edit existing image file or create new one
	 */
	public ImageUploadPage(boolean editExistingImage) {
		super("Eingabe Ihrer Daten");
		setTitle("Eingabe Ihrer Daten");
		setDescription("Geben Sie bitte einen aussagekräftigen Namen für das neue Image ein.");
		this.editExistingImage = editExistingImage;
	}



	@Override
	public void createControl(Composite parent) {
		container = new Composite(parent, SWT.NONE);
		GridLayout layout = new GridLayout();
		container.setLayout(layout);
		layout.numColumns = 2;
		Label imageNameCaption= new Label(container, SWT.NONE);
		imageNameCaption.setText("Name des Images");


		imageName = new Text(container, SWT.BORDER | SWT.SINGLE);
		imageName.setText("");
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		imageName.setLayoutData(gd);
		imageName.setEnabled(!editExistingImage);
		System.out.println(editExistingImage);

		imageName.addKeyListener(new KeyListener() {
			@Override
			public void keyPressed(KeyEvent e) {
			}

			@Override
			public void keyReleased(KeyEvent e) {
				if (!imageName.getText().isEmpty()) {
					setPageComplete(true);
				} else {
					setPageComplete(false);
				}
			}
		});

		Label imageFileCaption = new Label(container, SWT.NONE);
		imageFileCaption.setText("Imagefile:");
		imageFileBrowseButton = new Button(container, SWT.PUSH);
		imageFileBrowseButton.setText("Browse");


		// required to avoid an error in the system
		setControl(container);
		setPageComplete(editExistingImage);
	}


	public String getText1() {
		return imageName.getText();
	}

}