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(); } }