diff options
| author | Stephan Schwaer | 2015-07-23 17:23:33 +0200 |
|---|---|---|
| committer | Stephan Schwaer | 2015-07-23 17:23:33 +0200 |
| commit | b2e23908409dd81334ed139912dbb586ac6147db (patch) | |
| tree | 6f7df757e4e89323c4f71b7807a8bbd06fafae71 | |
| parent | [client] getTable for ImageCustomPermissionPage (soon not needed anymore!!!!!... (diff) | |
| download | tutor-module-b2e23908409dd81334ed139912dbb586ac6147db.tar.gz tutor-module-b2e23908409dd81334ed139912dbb586ac6147db.tar.xz tutor-module-b2e23908409dd81334ed139912dbb586ac6147db.zip | |
[client] Changed date selection in lecture create page, set text fields editable in image details if user has edit rights, dispose fonts.
6 files changed, 100 insertions, 19 deletions
diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java index 9c9ec2e7..7f1d9ad3 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/ImageDetailsWindow.java @@ -1,13 +1,16 @@ package org.openslx.dozmod.gui.window; import java.util.List; +import java.util.Map; import org.apache.log4j.Logger; +import org.apache.thrift.TException; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.widgets.Shell; import org.openslx.bwlp.thrift.iface.ImageDetailsRead; +import org.openslx.bwlp.thrift.iface.ImagePermissions; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.bwlp.thrift.iface.Virtualizer; import org.openslx.dozmod.gui.Gui; @@ -81,8 +84,8 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout { private void fill() { if (isDisposed() || image == null) return; - lblTitle.setText(SwtUtil.replaceMnemonics(image.getImageName())); - lblDescription.setText(SwtUtil.replaceMnemonics(image.getDescription())); + txtTitle.setText(SwtUtil.replaceMnemonics(image.getImageName())); + txtDescription.setText(SwtUtil.replaceMnemonics(image.getDescription())); lblOwner.setUser(UserCache.find(image.getOwnerId())); lblUpdater.setUser(UserCache.find(image.getUpdaterId())); lblCreateTime.setText(FormatHelper.longDate(image.getCreateTime())); @@ -96,8 +99,38 @@ public class ImageDetailsWindow extends ImageDetailsWindowLayout { Virtualizer virt = MetaDataCache.getVirtualizerById(image.getVirtId()); if (virt != null) lblVirtualizer.setText(virt.getVirtName()); + String tagsString = ""; + for (String tag : image.getTags()) { + tagsString = tagsString + ", " + tag; + } + txtTags.setText(tagsString); + btnIsTemplate.setSelection(image.isTemplate); + boolean isAdmin = false; + Map<String, ImagePermissions> result = null; + try { + result = ThriftManager.getSatClient().getImagePermissions(Session.getSatelliteToken(), image.getImageBaseId()); + + } catch (TException e) { + LOGGER.error("Couldn't fetch permissions of image."); + e.printStackTrace(); + } + if (result != null) { + ImagePermissions user = result.get(Session.getUserId()); + if (user != null) + isAdmin = user.edit; + } + makeEditable(isAdmin); getShell().layout(true, true); MainWindow.centerShell(getShell()); } + + // make text fields editable if admin + private void makeEditable(boolean editable){ + txtTitle.setEditable(editable); + txtDescription.setEditable(editable); + cboOperatingSystem.getCombo().setEnabled(editable); + txtTags.setEditable(editable); + btnIsTemplate.setEnabled(editable); + } } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java index fba210ec..e89ac8fd 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageDetailsWindowLayout.java @@ -16,15 +16,16 @@ import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; import org.openslx.bwlp.thrift.iface.OperatingSystem; import org.openslx.dozmod.gui.control.PersonLabel; import org.openslx.dozmod.gui.helper.SwtUtil; public abstract class ImageDetailsWindowLayout extends Composite { - protected final Label lblTitle; + protected final Text txtTitle; - protected final Label lblDescription; + protected final Text txtDescription; protected final Label lblCreateTime; @@ -38,11 +39,15 @@ public abstract class ImageDetailsWindowLayout extends Composite { protected final Label lblVirtualizer; + protected final Text txtTags; + + protected final Button btnIsTemplate; + protected final ComboViewer cboShareMode; protected final Button btnClose; - // TODO: IsTemplate, Permissions, ... + // TODO: Permissions, ... public ImageDetailsWindowLayout(Shell parent) { super(parent, SWT.NONE); @@ -50,26 +55,26 @@ public abstract class ImageDetailsWindowLayout extends Composite { this.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Title label - lblTitle = new Label(this, SWT.NONE); + txtTitle = new Text(this, SWT.NONE); FontData[] fonts = FontDescriptor.copy(JFaceResources.getFontRegistry().getFontData( JFaceResources.DEFAULT_FONT)); for (FontData f : fonts) { f.setHeight(f.getHeight() * 2); } final Font titleFont = new Font(getDisplay(), fonts); - lblTitle.setFont(titleFont); + txtTitle.setFont(titleFont); GridData gdTitle = SwtUtil.gridData(SWT.LEFT, SWT.FILL, true, false, 2); gdTitle.minimumWidth = 600; gdTitle.minimumHeight = 20; - lblTitle.setLayoutData(gdTitle); + txtTitle.setLayoutData(gdTitle); // Create a horizontal separator Label separator = new Label(this, SWT.HORIZONTAL | SWT.SEPARATOR); separator.setLayoutData(SwtUtil.gridData(SWT.FILL, SWT.FILL, true, false, 2)); // Description - lblDescription = new Label(this, SWT.BORDER); - lblDescription.setLayoutData(SwtUtil.gridData(SWT.FILL, SWT.FILL, true, false, 2)); + txtDescription = new Text(this, SWT.BORDER); + txtDescription.setLayoutData(SwtUtil.gridData(SWT.FILL, SWT.FILL, true, false, 2)); // Owner new Label(this, SWT.NONE).setText("Besitzer"); @@ -102,10 +107,18 @@ public abstract class ImageDetailsWindowLayout extends Composite { new Label(this, SWT.NONE).setText("Virtualizer"); lblVirtualizer = new Label(this, SWT.NONE); + // Tags + new Label(this, SWT.NONE).setText("Tags"); + txtTags = new Text(this, SWT.NONE); + // Share mode new Label(this, SWT.NONE).setText("Freigabemodus"); cboShareMode = new ComboViewer(this, SWT.DROP_DOWN | SWT.READ_ONLY); + // Is template + new Label(this, SWT.NONE).setText("Vorlage"); + btnIsTemplate = new Button(this, SWT.CHECK); + // Close button btnClose = new org.eclipse.swt.widgets.Button(this, SWT.PUSH | SWT.RIGHT | SWT.DOWN); btnClose.setText("Schließen"); diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java index 6397c820..093e73ea 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/ImageListWindowLayout.java @@ -3,6 +3,8 @@ package org.openslx.dozmod.gui.window.layout; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; @@ -72,8 +74,8 @@ public abstract class ImageListWindowLayout extends CompositePage { infoTitle.setText(infoTitleString); // set the fond FontData fontData = infoTitle.getFont().getFontData()[0]; - Font font = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); - infoTitle.setFont(font); + final Font titleFont = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); + infoTitle.setFont(titleFont); // the infotext Label infoText = new Label(infoComposite, SWT.NONE); infoText.setText(infoTextString); @@ -157,6 +159,14 @@ public abstract class ImageListWindowLayout extends CompositePage { templateInfo = createCaptionAndTextfield("Vorlage:", vmInfoGroup); // -- end group of details -- + // Dispose of stuff we allocated + this.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + titleFont.dispose(); + } + }); + } diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java index 6ce50dc2..ea1ecdac 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/LectureListWindowLayout.java @@ -3,6 +3,8 @@ package org.openslx.dozmod.gui.window.layout; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; @@ -71,8 +73,8 @@ public abstract class LectureListWindowLayout extends CompositePage { infoTitle.setText(infoTitleString); // set the fond FontData fontData = infoTitle.getFont().getFontData()[0]; - Font font = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); - infoTitle.setFont(font); + final Font titleFont = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); + infoTitle.setFont(titleFont); // the infotext Label infoText = new Label(infoComposite, SWT.NONE); infoText.setText(infoTextString); @@ -152,6 +154,14 @@ public abstract class LectureListWindowLayout extends CompositePage { endTime = createCaptionAndTextfield("Endzeit:", vmInfoGroup); ownerInfo = createCaptionAndTextfield("Besitzer:", vmInfoGroup); // -- end group of details -- + + // Dispose of stuff we allocated + this.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + titleFont.dispose(); + } + }); } public Text createCaptionAndTextfield(String captionString, Group group) { diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java index 0227d701..dab012d3 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/window/layout/VirtualizerNoticeWindowLayout.java @@ -1,6 +1,8 @@ package org.openslx.dozmod.gui.window.layout; import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; import org.eclipse.swt.layout.GridData; @@ -32,14 +34,16 @@ public abstract class VirtualizerNoticeWindowLayout extends Composite { // layout for this composite this.setLayout(new GridLayout(1, false)); + GridData gd = new GridData(); + gd.widthHint = 500; + this.setLayoutData(gd); // bold title at start. Label titleLabel = new Label(this, SWT.NONE); titleLabel.setText(infoTitle); FontData fontData = titleLabel.getFont().getFontData()[0]; - Font font = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); + final Font font = new Font(Gui.display, new FontData(fontData.getName(), fontData.getHeight(), SWT.BOLD)); titleLabel.setFont(font); - // TODO dispose of font? // infotext Label infoLabel = new Label(this, SWT.NONE | SWT.WRAP); @@ -72,5 +76,15 @@ public abstract class VirtualizerNoticeWindowLayout extends Composite { continueButton.setText("Weiter"); continueButton.setLayoutData(new GridData(GridData.BEGINNING, GridData.END, false, false)); + // Dispose of stuff we allocated + this.addDisposeListener(new DisposeListener() { + @Override + public void widgetDisposed(DisposeEvent e) { + font.dispose(); + } + }); + } + + }
\ No newline at end of file diff --git a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java index 61d26fe3..28380185 100644 --- a/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java +++ b/dozentenmodul/src/main/java/org/openslx/dozmod/gui/wizard/layout/LectureCreationPageLayout.java @@ -53,20 +53,21 @@ public abstract class LectureCreationPageLayout extends WizardPage { Label startDateLabel = new Label(container, SWT.NONE); startDateLabel.setText("Startdatum:"); startDateLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); - startDate = new DateTime (container, SWT.DATE); + startDate = new DateTime(container, SWT.DATE | SWT.DROP_DOWN); startDate.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); Label endDateLabel = new Label(container, SWT.NONE); endDateLabel.setText("Enddatum:"); endDateLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); - endDate = new DateTime (container, SWT.DATE); + endDate = new DateTime(container, SWT.DATE | SWT.DROP_DOWN); endDate.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); // start- and end Label endTimelabel = new Label(container, SWT.NONE); endTimelabel.setText("Startzeit:"); endTimelabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false)); - startTime = new DateTime (container, SWT.TIME | SWT.SHORT); + startTime = new DateTime (container, SWT.TIME | SWT.SHORT | SWT.DROP_DOWN); + Label endTimeLabel = new Label(container, SWT.NONE); endTimeLabel.setText("Endzeit:"); |
