diff options
| author | Simon Rettberg | 2015-07-13 12:26:22 +0200 |
|---|---|---|
| committer | Simon Rettberg | 2015-07-13 12:26:22 +0200 |
| commit | a6baf40d4e262c336ab9f5176c9b97a756b68781 (patch) | |
| tree | d5e133082800f21bbe1d4e52fbb5f6bd093f54a6 | |
| parent | [client] ImageUploadPage*: Move logic from layout class to implementation (diff) | |
| download | tutor-module-a6baf40d4e262c336ab9f5176c9b97a756b68781.tar.gz tutor-module-a6baf40d4e262c336ab9f5176c9b97a756b68781.tar.xz tutor-module-a6baf40d4e262c336ab9f5176c9b97a756b68781.zip | |
[client] ImageUpload: Implement file selection dialog
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java | 32 | ||||
| -rw-r--r-- | dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java | 34 |
2 files changed, 51 insertions, 15 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java index a1612fc6..6bd95176 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/ImageUploadPageLayout.java @@ -1,6 +1,5 @@ package org.openslx.dozmod.gui.wizard.layout; - import org.eclipse.jface.wizard.WizardPage; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -10,17 +9,18 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - - public abstract class ImageUploadPageLayout extends WizardPage { - protected Text imageName; + protected Text imageNameTextField; protected Composite container; protected Button imageFileBrowseButton; + protected Text imageFileTextField; /** * Page for uploading an imagefile - * @param editExistingImage wether to edit existing image file or create new one + * + * @param editExistingImage wether to edit existing image file or create new + * one */ public ImageUploadPageLayout() { super("Eingabe Ihrer Daten"); @@ -32,18 +32,26 @@ public abstract class ImageUploadPageLayout extends WizardPage { public void createControl(Composite parent) { container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); + layout.verticalSpacing = 16; 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.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + layout.numColumns = 3; + // -- Browse for VM -- Label imageFileCaption = new Label(container, SWT.NONE); - imageFileCaption.setText("Imagefile:"); + imageFileCaption.setText("Virtuelle Maschine"); imageFileBrowseButton = new Button(container, SWT.PUSH); imageFileBrowseButton.setText("Browse"); + imageFileTextField = new Text(container, SWT.BORDER | SWT.SINGLE); + imageFileTextField.setEditable(false); + imageFileTextField.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); + + Label imageNameCaption = new Label(container, SWT.NONE); + imageNameCaption.setText("Name des Images"); + + imageNameTextField = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gdNameField = new GridData(GridData.FILL_HORIZONTAL); + gdNameField.horizontalSpan = 2; + imageNameTextField.setLayoutData(gdNameField); setControl(container); } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java index 7b5836f9..b5880541 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/page/ImageUploadPage.java @@ -1,8 +1,15 @@ package org.openslx.dozmod.gui.wizard.page; +import java.io.File; + +import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.openslx.dozmod.Config; import org.openslx.dozmod.gui.wizard.layout.ImageUploadPageLayout; public class ImageUploadPage extends ImageUploadPageLayout { @@ -18,15 +25,36 @@ public class ImageUploadPage extends ImageUploadPageLayout { @Override public void createControl(Composite parent) { super.createControl(parent); - imageName.setEnabled(!editExistingImage); - imageName.addKeyListener(new KeyListener() { + imageNameTextField.setEnabled(!editExistingImage); + imageNameTextField.addKeyListener(new KeyListener() { @Override public void keyPressed(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { - setPageComplete(!imageName.getText().isEmpty()); + setPageComplete(!imageNameTextField.getText().isEmpty()); + } + }); + + imageFileBrowseButton.addSelectionListener(new SelectionListener() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(getWizard().getContainer().getShell(), SWT.OPEN); + dialog.setFilterNames(new String[] { "VMware Virtuelle Maschine (Beschreibungsdatei)" }); + dialog.setFilterExtensions(new String[] { "*.vmx" }); + dialog.setFilterPath(Config.getUploadPath()); + String ret = dialog.open(); + if (ret != null) { + File file = new File(ret); + Config.setUploadPath(file.getParentFile().getAbsolutePath()); + imageFileTextField.setText(ret); + } + } + + @Override + public void widgetDefaultSelected(SelectionEvent e) { } }); } |
