From 0c7ea7452587b9dae3f113b8a06c9453609a6668 Mon Sep 17 00:00:00 2001 From: Lukasz Byczynski Date: Thu, 7 May 2015 03:27:32 +0200 Subject: [PATCH] Closes: #6 #9 Adding/removing listeners in scala API by listenerSets and Cleanup hierarchy of components --- .../vaadin/addons/rinne/VAbsoluteLayout.scala | 3 +- .../org/vaadin/addons/rinne/VAccordion.scala | 4 +- .../org/vaadin/addons/rinne/VAudio.scala | 6 +- .../vaadin/addons/rinne/VBrowserFrame.scala | 2 +- .../org/vaadin/addons/rinne/VButton.scala | 52 +-------- .../org/vaadin/addons/rinne/VCalendar.scala | 1 - .../org/vaadin/addons/rinne/VCheckBox.scala | 9 +- .../vaadin/addons/rinne/VColorPicker.scala | 19 ++- .../org/vaadin/addons/rinne/VComboBox.scala | 4 +- .../org/vaadin/addons/rinne/VCssLayout.scala | 7 +- .../addons/rinne/VCustomComponent.scala | 4 +- .../vaadin/addons/rinne/VCustomLayout.scala | 4 +- .../org/vaadin/addons/rinne/VDateField.scala | 3 +- .../org/vaadin/addons/rinne/VEmbedded.scala | 41 +++---- .../org/vaadin/addons/rinne/VFlash.scala | 57 ++++++++- .../org/vaadin/addons/rinne/VFormLayout.scala | 2 +- .../org/vaadin/addons/rinne/VGridLayout.scala | 22 ++-- .../org/vaadin/addons/rinne/VImage.scala | 4 +- .../org/vaadin/addons/rinne/VLabel.scala | 5 +- .../scala/org/vaadin/addons/rinne/VLink.scala | 3 +- .../org/vaadin/addons/rinne/VListSelect.scala | 4 +- .../org/vaadin/addons/rinne/VMenuBar.scala | 4 +- .../vaadin/addons/rinne/VNativeButton.scala | 41 +------ .../vaadin/addons/rinne/VNativeSelect.scala | 4 +- .../vaadin/addons/rinne/VOptionGroup.scala | 6 +- .../org/vaadin/addons/rinne/VPanel.scala | 3 +- .../org/vaadin/addons/rinne/VPopupView.scala | 28 +++-- .../vaadin/addons/rinne/VProgressBar.scala | 5 +- .../org/vaadin/addons/rinne/VTabSheet.scala | 3 +- .../org/vaadin/addons/rinne/VTable.scala | 3 +- .../scala/org/vaadin/addons/rinne/VTree.scala | 10 +- .../vaadin/addons/rinne/VTwinColSelect.scala | 6 - .../org/vaadin/addons/rinne/VUpload.scala | 23 ++-- .../org/vaadin/addons/rinne/VWindow.scala | 42 ++++--- .../addons/rinne/events/ListenersSet.scala | 20 +++- .../helpers/AutoAddAndHideComboBoxMixin.scala | 18 +++ .../HideWhenEmptyMixin.scala | 20 ++-- .../rinne/helpers/HideWhenReadOnlyMixin.scala | 17 +++ .../OptionableAnyRefValueMixin.scala | 6 +- .../OptionableStringValueMixin.scala | 6 +- .../AbstractComponentContainerMixin.scala | 4 +- .../rinne/mixins/AbstractComponentMixin.scala | 21 ++-- .../rinne/mixins/AbstractEmbeddedMixin.scala | 11 +- .../rinne/mixins/AbstractFieldMixin.scala | 11 +- .../rinne/mixins/AbstractLayoutMixin.scala | 4 +- .../rinne/mixins/AbstractMediaMixin.scala | 31 ++--- .../mixins/AbstractOrderedLayoutMixin.scala | 6 +- .../rinne/mixins/AbstractPropertyMixin.scala | 6 +- .../rinne/mixins/AbstractSelectMixin.scala | 38 +++--- ...bstractSingleComponentContainerMixin.scala | 4 +- .../mixins/AbstractSplitPanelMixin.scala | 59 ++++++---- .../rinne/mixins/AbstractTextFieldMixin.scala | 31 ++--- .../mixins/AutoAddAndHideComboBoxMixin.scala | 14 --- .../rinne/mixins/BlurNotifierMixin.scala | 3 +- .../addons/rinne/mixins/ButtonMixin.scala | 54 +++++++++ .../mixins/ComponentContainerMixin.scala | 28 +++-- .../addons/rinne/mixins/ComponentMixin.scala | 31 +++-- ...ContainerItemSetChangeNotifierMixin2.scala | 26 +++++ .../addons/rinne/mixins/ContainerMixin.scala | 3 +- ...tainerPropertySetChangeNotifierMixin.scala | 25 ++++ .../rinne/mixins/ContainerViewerMixin.scala | 14 +++ .../addons/rinne/mixins/DateFieldMixin.scala | 4 +- .../rinne/mixins/FocusNotifierMixin.scala | 24 ++++ .../addons/rinne/mixins/FocusableMixin.scala | 3 +- .../mixins/HideWhenEmptyStringMixin.scala | 3 - .../rinne/mixins/ItemClickNotifierMixin.scala | 25 ++++ .../mixins/LayoutAlignmentHandlerMixin.scala | 18 +++ .../mixins/LayoutClickNotifierMixin.scala | 3 +- ...n.scala => LayoutMarginHandlerMixin.scala} | 17 +-- ....scala => LayoutSpacingHandlerMixin.scala} | 3 +- .../mixins/MouseClickNotifierMixin.scala | 28 +++++ .../MouseDoubleClickNotifierMixin.scala | 28 +++++ .../rinne/mixins/MultiSelectableMixin.scala | 9 -- .../addons/rinne/mixins/PanelMixin.scala | 3 +- .../addons/rinne/mixins/PropertyMixin.scala | 3 +- ...rtyReadOnlyStatusChangeNotifierMixin.scala | 24 ++++ .../PropertyValueChangeNotifierMixin.scala | 25 ++++ .../rinne/mixins/PropertyViewerMixin.scala | 14 +++ .../mixins/ShowOnlyInEditModeMixin.scala | 21 ---- .../addons/rinne/mixins/SizeableMixin.scala | 24 ++-- .../addons/rinne/mixins/TabSheetMixin.scala | 43 +++---- .../addons/rinne/mixins/TableMixin.scala | 108 ++++++++---------- .../rinne/mixins/UploadFieldMixin.scala | 3 - 83 files changed, 830 insertions(+), 548 deletions(-) create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/helpers/AutoAddAndHideComboBoxMixin.scala rename addon/src/main/scala/org/vaadin/addons/rinne/{mixins => helpers}/HideWhenEmptyMixin.scala (57%) create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenReadOnlyMixin.scala rename addon/src/main/scala/org/vaadin/addons/rinne/{mixins => helpers}/OptionableAnyRefValueMixin.scala (50%) rename addon/src/main/scala/org/vaadin/addons/rinne/{mixins => helpers}/OptionableStringValueMixin.scala (50%) delete mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/AutoAddAndHideComboBoxMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ButtonMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerItemSetChangeNotifierMixin2.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerPropertySetChangeNotifierMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerViewerMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusNotifierMixin.scala delete mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyStringMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ItemClickNotifierMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutAlignmentHandlerMixin.scala rename addon/src/main/scala/org/vaadin/addons/rinne/mixins/{MarginHandlerMixin.scala => LayoutMarginHandlerMixin.scala} (84%) rename addon/src/main/scala/org/vaadin/addons/rinne/mixins/{SpacingHandlerMixin.scala => LayoutSpacingHandlerMixin.scala} (75%) create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseClickNotifierMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseDoubleClickNotifierMixin.scala delete mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/MultiSelectableMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyReadOnlyStatusChangeNotifierMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyValueChangeNotifierMixin.scala create mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyViewerMixin.scala delete mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/ShowOnlyInEditModeMixin.scala delete mode 100644 addon/src/main/scala/org/vaadin/addons/rinne/mixins/UploadFieldMixin.scala diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VAbsoluteLayout.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VAbsoluteLayout.scala index 5e4129b..46902fc 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VAbsoluteLayout.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VAbsoluteLayout.scala @@ -3,8 +3,7 @@ package org.vaadin.addons.rinne import com.vaadin.ui.{AbsoluteLayout, Component} import org.vaadin.addons.rinne.mixins.{AbstractLayoutMixin, ComponentContainerMixin, ComponentMixin, LayoutClickNotifierMixin} -class VAbsoluteLayout extends AbsoluteLayout -with AbstractLayoutMixin with ComponentContainerMixin with ComponentMixin with LayoutClickNotifierMixin { +class VAbsoluteLayout extends AbsoluteLayout with AbstractLayoutMixin { def add[C <: Component](component: C, location: String): C = { addComponent(component, location) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VAccordion.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VAccordion.scala index 4785832..eacd929 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VAccordion.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VAccordion.scala @@ -1,6 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Accordion -import org.vaadin.addons.rinne.mixins.TabSheetMixin +import org.vaadin.addons.rinne.mixins._ -class VAccordion extends Accordion with TabSheetMixin +class VAccordion extends Accordion with TabSheetMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VAudio.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VAudio.scala index 9bf8d77..61a0d2d 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VAudio.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VAudio.scala @@ -1,8 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Audio -import org.vaadin.addons.rinne.mixins.AbstractMediaMixin +import org.vaadin.addons.rinne.mixins.{ComponentMixin, AbstractComponentMixin, AbstractMediaMixin} -class VAudio extends Audio with AbstractMediaMixin { - -} +class VAudio extends Audio with AbstractMediaMixin diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VBrowserFrame.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VBrowserFrame.scala index 59ef6ea..160a542 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VBrowserFrame.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VBrowserFrame.scala @@ -1,6 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.BrowserFrame -import org.vaadin.addons.rinne.mixins.AbstractEmbeddedMixin +import org.vaadin.addons.rinne.mixins.{ComponentMixin, AbstractComponentMixin, AbstractEmbeddedMixin} class VBrowserFrame extends BrowserFrame with AbstractEmbeddedMixin diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VButton.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VButton.scala index d6b6699..bd2be75 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VButton.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VButton.scala @@ -1,54 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Button -import org.vaadin.addons.rinne.events._ -import org.vaadin.addons.rinne.mixins.{AbstractComponentMixin, FocusableMixin} +import org.vaadin.addons.rinne.mixins._ -import scala.collection.JavaConverters._ - -class VButton extends Button with AbstractComponentMixin with BlurNotifier with FocusNotifier with FocusableMixin { - - lazy val clickListeners: ListenersSet[Button.ClickEvent => Unit] = - new ListenersTrait[Button.ClickEvent, ButtonClickListener] { - override def listeners = getListeners(classOf[Button.ClickEvent]) - - override def addListener(elem: Button.ClickEvent => Unit) = addClickListener(new ButtonClickListener(elem)) - - override def removeListener(elem: ButtonClickListener) = removeClickListener(elem) - - override def clear(): Unit = { - super.clear() - listeners.asScala.foreach(_ => removeListener(_)) - } - } - private var _clickKeyShortcut: Option[KeyShortcut] = None - - def clickKeyShortcut_=(clickShortcut: Option[KeyShortcut]) { - _clickKeyShortcut = clickShortcut - clickShortcut match { - case None => removeClickShortcut() - case Some(shortcut) => setClickShortcut(shortcut.keyCode.value, shortcut.modifiers.map(_.value): _*) - } - } - - def disableOnClick: Boolean = isDisableOnClick - - def disableOnClick_=(disableOnClick: Boolean) { - setDisableOnClick(disableOnClick) - } - - def clickKeyShortcut: Option[KeyShortcut] = _clickKeyShortcut - - def htmlContentAllowed: Boolean = isHtmlContentAllowed - - def htmlContentAllowed_=(htmlContentAllowed: Boolean) { - setHtmlContentAllowed(htmlContentAllowed) - } - - - def clickKeyShortcut_=(clickShortcut: KeyShortcut) { - this.clickKeyShortcut = Option(clickShortcut) - } - - -} +class VButton extends Button with ButtonMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VCalendar.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VCalendar.scala index c0946f7..acfe60a 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VCalendar.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VCalendar.scala @@ -56,7 +56,6 @@ class VCalendar extends Calendar with AbstractComponentMixin { def weeklyCaptionFormat: String = getWeeklyCaptionFormat def weeklyCaptionFormat_=(value: String): Unit = setWeeklyCaptionFormat(value) - } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VCheckBox.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VCheckBox.scala index 74e0ea4..8131866 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VCheckBox.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VCheckBox.scala @@ -1,13 +1,16 @@ package org.vaadin.addons.rinne +import com.vaadin.event.FieldEvents.{BlurNotifier, FocusNotifier} import com.vaadin.ui.CheckBox -import org.vaadin.addons.rinne.mixins.AbstractFieldMixin +import org.vaadin.addons.rinne.mixins.{AbstractFieldMixin, BlurNotifierMixin, FocusNotifierMixin} -class VCheckBox extends CheckBox with AbstractFieldMixin[java.lang.Boolean] { +class VCheckBox extends CheckBox +with AbstractFieldMixin[java.lang.Boolean] with BlurNotifierMixin with BlurNotifier with FocusNotifierMixin with FocusNotifier { - def value_=(value: Boolean) { + def value_=(value: Boolean): Unit = { setValue(value) } def boolValue: Boolean = getValue + } \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VColorPicker.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VColorPicker.scala index ec85db7..6dab357 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VColorPicker.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VColorPicker.scala @@ -1,6 +1,23 @@ package org.vaadin.addons.rinne +import java.util + import com.vaadin.ui.ColorPicker +import com.vaadin.ui.components.colorpicker.{ColorChangeEvent, ColorChangeListener} +import org.vaadin.addons.rinne.events.ListenersSet import org.vaadin.addons.rinne.mixins.AbstractComponentMixin -class VColorPicker extends ColorPicker with AbstractComponentMixin \ No newline at end of file +class VColorPicker extends ColorPicker with AbstractComponentMixin { + + lazy val colorChangeListeners = new ListenersSet[ColorChangeEvent, ColorChangeListener] { + override protected def addListener(listener: ListenerLambda): Unit = addColorChangeListener( + new Listener(listener) with ColorChangeListener { + override def colorChanged(event: ColorChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: ColorChangeListener): Unit = removeColorChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[ColorChangeEvent]) + } +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VComboBox.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VComboBox.scala index b1137d0..e73b62e 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VComboBox.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VComboBox.scala @@ -2,9 +2,9 @@ package org.vaadin.addons.rinne import com.vaadin.shared.ui.combobox.FilteringMode import com.vaadin.ui.ComboBox -import org.vaadin.addons.rinne.mixins.{AbstractSelectMixin, ContainerMixin} +import org.vaadin.addons.rinne.mixins.AbstractSelectMixin -class VComboBox extends ComboBox with AbstractSelectMixin with ContainerMixin { +class VComboBox extends ComboBox with AbstractSelectMixin { def inputPrompt: Option[String] = Option(getInputPrompt) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VCssLayout.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VCssLayout.scala index 49703f0..c342536 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VCssLayout.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VCssLayout.scala @@ -1,12 +1,11 @@ package org.vaadin.addons.rinne import com.vaadin.ui.{Component, CssLayout} -import org.vaadin.addons.rinne.events.LayoutClickNotifierMixin -import org.vaadin.addons.rinne.mixins.AbstractLayoutMixin +import org.vaadin.addons.rinne.mixins.{LayoutClickNotifierMixin, AbstractLayoutMixin} class VCssLayout extends CssLayout with AbstractLayoutMixin with LayoutClickNotifierMixin { - private var _cssMap = Map.empty[Component, String] + private var _cssMap = Map[Component, String]() def add[C <: Component](component: C, css: => String = null): C = { add(component) @@ -16,7 +15,7 @@ class VCssLayout extends CssLayout with AbstractLayoutMixin with LayoutClickNoti component } - override def getCss(component: Component): String = _cssMap.getOrElse(component, "") + def getCssForComponent(component: Component): Option[String] = _cssMap.get(component) override def removeComponent(component: Component) = { super.removeComponent(component) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VCustomComponent.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VCustomComponent.scala index 91458e6..ed3e4ad 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VCustomComponent.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VCustomComponent.scala @@ -7,11 +7,11 @@ class VCustomComponent extends CustomComponent with ComponentMixin { def compositionRoot: Option[Component] = Option(getCompositionRoot) - def compositionRoot_=(component: Component) { + def compositionRoot_=(component: Component): Unit = { setCompositionRoot(component) } - def compositionRoot_=(component: Option[Component]) { + def compositionRoot_=(component: Option[Component]): Unit = { setCompositionRoot(component.orNull) } } \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VCustomLayout.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VCustomLayout.scala index f72505e..c882149 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VCustomLayout.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VCustomLayout.scala @@ -7,11 +7,11 @@ class VCustomLayout extends CustomLayout with AbstractLayoutMixin { def templateName = Option(getTemplateName) - def templateName_=(templateName: String) = setTemplateName(templateName) + def templateName_=(templateName: String): Unit = setTemplateName(templateName) def templateContents = Option(getTemplateContents) - def templateContents_=(templateContents: String) = setTemplateContents(templateContents) + def templateContents_=(templateContents: String): Unit = setTemplateContents(templateContents) def add[C <: Component](component: C, location: String): C = { addComponent(component, location) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VDateField.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VDateField.scala index 05fb902..a9940de 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VDateField.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VDateField.scala @@ -1,5 +1,6 @@ package org.vaadin.addons.rinne +import com.vaadin.ui.DateField import org.vaadin.addons.rinne.mixins.DateFieldMixin -class VDateField extends DateFieldMixin \ No newline at end of file +class VDateField extends DateField with DateFieldMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VEmbedded.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VEmbedded.scala index 9ff78b3..a63d2a8 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VEmbedded.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VEmbedded.scala @@ -1,12 +1,11 @@ package org.vaadin.addons.rinne -import com.vaadin.server.Resource import com.vaadin.ui.Embedded -import org.vaadin.addons.rinne.mixins.AbstractComponentMixin +import org.vaadin.addons.rinne.mixins.{AbstractComponentMixin, ComponentMixin, MouseClickNotifierMixin} import scala.collection.mutable -class VEmbedded extends Embedded with AbstractComponentMixin { +class VEmbedded extends Embedded with AbstractComponentMixin with ComponentMixin with MouseClickNotifierMixin { lazy val parameters: mutable.Map[String, String] = new mutable.Map[String, String] with Serializable { def -=(name: String): this.type = { @@ -36,51 +35,39 @@ class VEmbedded extends Embedded with AbstractComponentMixin { } } - def alternateText: Option[String] = Option(getAlternateText) - - def alternateText_=(alternateText: Option[String]) = setAlternateText(alternateText.orNull) - - def alternateText_=(alternateText: String) = setAlternateText(alternateText) - - def source: Option[Resource] = Option(getSource) - - def source_=(source: Resource) = setSource(source) - - def source_=(source: Option[Resource]) = setSource(source.orNull) - def codebase: Option[String] = Option(getCodebase) - def codebase_=(codebase: String) = setCodebase(codebase) + def codebase_=(codebase: String): Unit = setCodebase(codebase) - def codebase_=(codebase: Option[String]) = setCodebase(codebase.orNull) + def codebase_=(codebase: Option[String]): Unit = setCodebase(codebase.orNull) def codetype: Option[String] = Option(getCodetype) - def codetype_=(codetype: String) = setCodetype(codetype) + def codetype_=(codetype: String): Unit = setCodetype(codetype) - def codetype_=(codetype: Option[String]) = setCodetype(codetype.orNull) + def codetype_=(codetype: Option[String]): Unit = setCodetype(codetype.orNull) def standby: Option[String] = Option(getStandby) - def standby_=(standby: String) = setStandby(standby) + def standby_=(standby: String): Unit = setStandby(standby) - def standby_=(standby: Option[String]) = setStandby(standby.orNull) + def standby_=(standby: Option[String]): Unit = setStandby(standby.orNull) def mimeType: Option[String] = Option(getMimeType) - def mimeType_=(mimeType: String) = setMimeType(mimeType) + def mimeType_=(mimeType: String): Unit = setMimeType(mimeType) - def mimeType_=(mimeType: Option[String]) = setMimeType(mimeType.orNull) + def mimeType_=(mimeType: Option[String]): Unit = setMimeType(mimeType.orNull) def classId: Option[String] = Option(getClassId) - def classId_=(classId: String) = setClassId(classId) + def classId_=(classId: String): Unit = setClassId(classId) - def classId_=(classId: Option[String]) = setClassId(classId.orNull) + def classId_=(classId: Option[String]): Unit = setClassId(classId.orNull) def archive: Option[String] = Option(getArchive) - def archive_=(archive: String) = setArchive(archive) + def archive_=(archive: String): Unit = setArchive(archive) - def archive_=(archive: Option[String]) = setArchive(archive.orNull) + def archive_=(archive: Option[String]): Unit = setArchive(archive.orNull) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VFlash.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VFlash.scala index cb7eca8..5aeab52 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VFlash.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VFlash.scala @@ -3,4 +3,59 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Flash import org.vaadin.addons.rinne.mixins.AbstractEmbeddedMixin -class VFlash extends Flash with AbstractEmbeddedMixin \ No newline at end of file +import scala.collection.mutable + +class VFlash extends Flash with AbstractEmbeddedMixin { + + lazy val parameters: mutable.Map[String, String] = new mutable.Map[String, String] with Serializable { + def -=(name: String): this.type = { + removeParameter(name) + this + } + + def +=(parameter: (String, String)): this.type = { + update(parameter._1, parameter._2) + this + } + + override def update(name: String, value: String) { + setParameter(name, value) + } + + def get(name: String): Option[String] = Option(getParameter(name)) + + override def size = { + import scala.collection.JavaConverters._ + getParameterNames.asScala.size + } + + def iterator: Iterator[(String, String)] = { + import scala.collection.JavaConverters._ + getParameterNames.asScala.map { name => (name, getParameter(name)) }.toIterator + } + } + + def codebase: Option[String] = Option(getCodebase) + + def codebase_=(codebase: String): Unit = setCodebase(codebase) + + def codebase_=(codebase: Option[String]): Unit = setCodebase(codebase.orNull) + + def codetype: Option[String] = Option(getCodetype) + + def codetype_=(codetype: String): Unit = setCodetype(codetype) + + def codetype_=(codetype: Option[String]): Unit = setCodetype(codetype.orNull) + + def standby: Option[String] = Option(getStandby) + + def standby_=(standby: String): Unit = setStandby(standby) + + def standby_=(standby: Option[String]): Unit = setStandby(standby.orNull) + + def archive: Option[String] = Option(getArchive) + + def archive_=(archive: String): Unit = setArchive(archive) + + def archive_=(archive: Option[String]): Unit = setArchive(archive.orNull) +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VFormLayout.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VFormLayout.scala index 232356a..c688049 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VFormLayout.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VFormLayout.scala @@ -3,4 +3,4 @@ package org.vaadin.addons.rinne import com.vaadin.ui.FormLayout import org.vaadin.addons.rinne.mixins.AbstractOrderedLayoutMixin -class VFormLayout extends FormLayout with AbstractOrderedLayoutMixin +class VFormLayout extends FormLayout with AbstractOrderedLayoutMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VGridLayout.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VGridLayout.scala index ff94473..4f1f07b 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VGridLayout.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VGridLayout.scala @@ -1,9 +1,10 @@ package org.vaadin.addons.rinne import com.vaadin.ui.{Alignment, Component, GridLayout} -import org.vaadin.addons.rinne.mixins.{AbstractLayoutMixin, MarginHandlerMixin, SpacingHandlerMixin} +import org.vaadin.addons.rinne.mixins._ -class VGridLayout extends GridLayout with AbstractLayoutMixin with SpacingHandlerMixin with MarginHandlerMixin { +class VGridLayout extends GridLayout with AbstractLayoutMixin +with LayoutSpacingHandlerMixin with LayoutMarginHandlerMixin with LayoutAlignmentHandlerMixin with LayoutClickNotifierMixin { def add[C <: Component]( component: C = null, @@ -30,26 +31,17 @@ class VGridLayout extends GridLayout with AbstractLayoutMixin with SpacingHandle def columns: Int = getColumns - def columns_=(columns: Int) { - setColumns(columns) - } + def columns_=(columns: Int): Unit = setColumns(columns) def rows: Int = getRows - def rows_=(rows: Int) { - setRows(rows) - } + def rows_=(rows: Int): Unit = setRows(rows) def cursorX: Int = getCursorX - def cursorX_=(cursorX: Int) { - setCursorX(cursorX) - } + def cursorX_=(cursorX: Int): Unit = setCursorX(cursorX) def cursorY: Int = getCursorY - def cursorY_=(cursorY: Int) { - setCursorY(cursorY) - } - + def cursorY_=(cursorY: Int): Unit = setCursorY(cursorY) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VImage.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VImage.scala index bd41d51..7d6cd38 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VImage.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VImage.scala @@ -1,6 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Image -import org.vaadin.addons.rinne.mixins.AbstractEmbeddedMixin +import org.vaadin.addons.rinne.mixins.{MouseClickNotifierMixin, AbstractEmbeddedMixin} -class VImage extends Image with AbstractEmbeddedMixin +class VImage extends Image with AbstractEmbeddedMixin with MouseClickNotifierMixin diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VLabel.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VLabel.scala index 730f2d8..e6a636e 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VLabel.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VLabel.scala @@ -3,9 +3,10 @@ package org.vaadin.addons.rinne import com.vaadin.data.util.converter.Converter import com.vaadin.shared.ui.label.ContentMode import com.vaadin.ui.Label -import org.vaadin.addons.rinne.mixins.{AbstractComponentMixin, PropertyMixin} +import org.vaadin.addons.rinne.mixins.{PropertyViewerMixin, AbstractComponentMixin, PropertyMixin, PropertyValueChangeNotifierMixin} -class VLabel extends Label with AbstractComponentMixin with PropertyMixin[String] { +class VLabel extends Label with AbstractComponentMixin +with PropertyMixin[String] with PropertyValueChangeNotifierMixin with PropertyViewerMixin { def contentMode: ContentMode = getContentMode diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VLink.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VLink.scala index a383a3e..5e87936 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VLink.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VLink.scala @@ -6,9 +6,10 @@ import com.vaadin.ui.Link import org.vaadin.addons.rinne.mixins.AbstractComponentMixin class VLink extends Link with AbstractComponentMixin { + def targetName: Option[String] = Option(getTargetName) - def targetName_=(targetName: String) { + def targetName_=(targetName: String): Unit = { setTargetName(targetName) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VListSelect.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VListSelect.scala index c1a4af7..bc0be97 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VListSelect.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VListSelect.scala @@ -1,9 +1,9 @@ package org.vaadin.addons.rinne import com.vaadin.ui.ListSelect -import org.vaadin.addons.rinne.mixins.{AbstractSelectMixin, MultiSelectableMixin} +import org.vaadin.addons.rinne.mixins.AbstractSelectMixin -class VListSelect extends ListSelect with AbstractSelectMixin with MultiSelectableMixin { +class VListSelect extends ListSelect with AbstractSelectMixin { def rows: Int = getRows diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VMenuBar.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VMenuBar.scala index e59ded9..89ef0f6 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VMenuBar.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VMenuBar.scala @@ -1,6 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.MenuBar -import org.vaadin.addons.rinne.mixins.AbstractComponentMixin +import org.vaadin.addons.rinne.mixins.{AbstractComponentMixin, FocusableMixin} -class VMenuBar extends MenuBar with AbstractComponentMixin +class VMenuBar extends MenuBar with AbstractComponentMixin with FocusableMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VNativeButton.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VNativeButton.scala index a07ea73..99aa953 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VNativeButton.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VNativeButton.scala @@ -2,43 +2,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.{Button, NativeButton} import org.vaadin.addons.rinne.events._ -import org.vaadin.addons.rinne.mixins.{AbstractComponentMixin, FocusableMixin} +import org.vaadin.addons.rinne.mixins.{ButtonMixin, AbstractComponentMixin, FocusableMixin} -class VNativeButton extends NativeButton with AbstractComponentMixin with BlurNotifier with FocusNotifier with FocusableMixin { - - lazy val clickListeners: ListenersSet[Button.ClickEvent => Unit] = - new ListenersTrait[Button.ClickEvent, ButtonClickListener] { - override def listeners = getListeners(classOf[Button.ClickEvent]) - - override def addListener(elem: Button.ClickEvent => Unit) = addClickListener(new ButtonClickListener(elem)) - - override def removeListener(elem: ButtonClickListener) = removeClickListener(elem) - } - private var _clickKeyShortcut: Option[KeyShortcut] = None - - def clickShortcut_=(clickShortcut: KeyShortcut) { - this.clickKeyShortcut = Option(clickShortcut) - } - - def clickKeyShortcut: Option[KeyShortcut] = _clickKeyShortcut - - def clickKeyShortcut_=(clickShortcut: Option[KeyShortcut]) { - _clickKeyShortcut = clickShortcut - clickShortcut match { - case None => removeClickShortcut() - case Some(shortcut) => setClickShortcut(shortcut.keyCode.value, shortcut.modifiers.map(_.value): _*) - } - } - - def disableOnClick: Boolean = isDisableOnClick - - def disableOnClick_=(disableOnClick: Boolean) { - setDisableOnClick(disableOnClick) - } - - def htmlContentAllowed: Boolean = isHtmlContentAllowed - - def htmlContentAllowed_=(htmlContentAllowed: Boolean) { - setHtmlContentAllowed(htmlContentAllowed) - } -} +class VNativeButton extends NativeButton with ButtonMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VNativeSelect.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VNativeSelect.scala index 8f36225..16a151e 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VNativeSelect.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VNativeSelect.scala @@ -1,6 +1,6 @@ package org.vaadin.addons.rinne import com.vaadin.ui.NativeSelect -import org.vaadin.addons.rinne.mixins.AbstractSelectMixin +import org.vaadin.addons.rinne.mixins.{FocusNotifierMixin, BlurNotifierMixin, AbstractSelectMixin} -class VNativeSelect extends NativeSelect with AbstractSelectMixin \ No newline at end of file +class VNativeSelect extends NativeSelect with AbstractSelectMixin with BlurNotifierMixin with FocusNotifierMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VOptionGroup.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VOptionGroup.scala index 0c9e589..3bf5257 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VOptionGroup.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VOptionGroup.scala @@ -1,11 +1,9 @@ package org.vaadin.addons.rinne import com.vaadin.ui.OptionGroup -import org.vaadin.addons.rinne.events.{BlurNotifier, FocusNotifier} -import org.vaadin.addons.rinne.mixins.{AbstractSelectMixin, MultiSelectableMixin} +import org.vaadin.addons.rinne.mixins.{FocusNotifierMixin, BlurNotifierMixin, AbstractSelectMixin} -class VOptionGroup extends OptionGroup -with AbstractSelectMixin with MultiSelectableMixin with BlurNotifier with FocusNotifier { +class VOptionGroup extends OptionGroup with AbstractSelectMixin with BlurNotifierMixin with FocusNotifierMixin { def htmlContentAllowed: Boolean = isHtmlContentAllowed diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VPanel.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VPanel.scala index 1a880ee..abf0ee8 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VPanel.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VPanel.scala @@ -1,5 +1,6 @@ package org.vaadin.addons.rinne +import com.vaadin.ui.Panel import org.vaadin.addons.rinne.mixins.PanelMixin -class VPanel extends PanelMixin \ No newline at end of file +class VPanel extends Panel with PanelMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VPopupView.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VPopupView.scala index d72f5b0..c5a84e4 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VPopupView.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VPopupView.scala @@ -1,10 +1,26 @@ package org.vaadin.addons.rinne +import java.util + +import com.vaadin.ui.PopupView.{PopupVisibilityEvent, PopupVisibilityListener} import com.vaadin.ui.{Component, HasComponents, PopupView} +import org.vaadin.addons.rinne.events.ListenersSet import org.vaadin.addons.rinne.mixins.AbstractComponentMixin class VPopupView extends PopupView("", null) with AbstractComponentMixin with HasComponents { + lazy val popupVisibilityListeners = new ListenersSet[PopupVisibilityEvent, PopupVisibilityListener] { + override protected def addListener(listener: ListenerLambda): Unit = addPopupVisibilityListener( + new PopupVisibilityListener { + override def popupVisibilityChange(event: PopupVisibilityEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: PopupVisibilityListener): Unit = removePopupVisibilityListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[PopupVisibilityEvent]) + } + def minimizedHtmlValue: String = getContent.getMinimizedValueAsHTML def minimizedHtmlValue_=(minimizedHtmlValue: String): Unit = { @@ -42,14 +58,4 @@ class VPopupView extends PopupView("", null) with AbstractComponentMixin with Ha def hideOnMouseOut: Boolean = isHideOnMouseOut def hideOnMouseOut_=(hideOnMouseOut: Boolean): Unit = setHideOnMouseOut(hideOnMouseOut) - - // lazy val popupVisibilityListeners: ListenersSet[PopupView.PopupVisibilityEvent => Unit] = - // new ListenersTrait[PopupView.PopupVisibilityEvent, PopupVisibilityListener] { - // override def listeners = getListeners(classOf[PopupView.PopupVisibilityEvent]) - // - // override def addListener(elem: PopupView.PopupVisibilityEvent => Unit) = - // addPopupVisibilityListener(new PopupVisibilityListener(elem)) - // - // override def removeListener(elem: PopupVisibilityListener) = removePopupVisibilityListener(elem) - // } -} +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VProgressBar.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VProgressBar.scala index 3fde5cb..f40dff0 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VProgressBar.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VProgressBar.scala @@ -1,9 +1,10 @@ package org.vaadin.addons.rinne import com.vaadin.ui.ProgressBar -import org.vaadin.addons.rinne.mixins.AbstractFieldMixin +import org.vaadin.addons.rinne.mixins.{PropertyValueChangeNotifierMixin, PropertyViewerMixin, AbstractFieldMixin} -class VProgressBar extends ProgressBar with AbstractFieldMixin[java.lang.Float] { +class VProgressBar extends ProgressBar with AbstractFieldMixin[java.lang.Float] +with PropertyViewerMixin with PropertyValueChangeNotifierMixin { def indeterminate: Boolean = isIndeterminate diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VTabSheet.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VTabSheet.scala index af406a9..42f7834 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VTabSheet.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VTabSheet.scala @@ -1,5 +1,6 @@ package org.vaadin.addons.rinne +import com.vaadin.ui.TabSheet import org.vaadin.addons.rinne.mixins.TabSheetMixin -class VTabSheet extends TabSheetMixin \ No newline at end of file +class VTabSheet extends TabSheet with TabSheetMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VTable.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VTable.scala index 051daa5..c730a59 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VTable.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VTable.scala @@ -1,5 +1,6 @@ package org.vaadin.addons.rinne +import com.vaadin.ui.Table import org.vaadin.addons.rinne.mixins.TableMixin -class VTable extends TableMixin \ No newline at end of file +class VTable extends Table with TableMixin \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VTree.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VTree.scala index 69cdf0b..7592329 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VTree.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VTree.scala @@ -2,15 +2,9 @@ package org.vaadin.addons.rinne import com.vaadin.shared.ui.MultiSelectMode import com.vaadin.ui.Tree -import org.vaadin.addons.rinne.mixins.AbstractSelectMixin +import org.vaadin.addons.rinne.mixins.{AbstractSelectMixin, ItemClickNotifierMixin} -class VTree extends Tree with AbstractSelectMixin { - - def multiSelect: Boolean = isMultiSelect - - def multiSelect_=(multiSelect: Boolean) { - setMultiSelect(multiSelect) - } +class VTree extends Tree with AbstractSelectMixin with ItemClickNotifierMixin { def expanded(itemId: Any): Boolean = isExpanded(itemId) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VTwinColSelect.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VTwinColSelect.scala index d2c506c..0221d0f 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VTwinColSelect.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VTwinColSelect.scala @@ -5,12 +5,6 @@ import org.vaadin.addons.rinne.mixins.AbstractSelectMixin class VTwinColSelect extends TwinColSelect with AbstractSelectMixin { - def multiSelect: Boolean = isMultiSelect - - def multiSelect_=(multiSelect: Boolean) { - setMultiSelect(multiSelect) - } - def rows: Int = getRows def rows_=(rows: Int) { diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VUpload.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VUpload.scala index e2f830e..c3bea58 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VUpload.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VUpload.scala @@ -1,24 +1,17 @@ package org.vaadin.addons.rinne import com.vaadin.ui.Upload +import com.vaadin.ui.Upload.Receiver import org.vaadin.addons.rinne.mixins.AbstractComponentMixin class VUpload extends Upload with AbstractComponentMixin { - // def receiver: Option[Upload.ReceiveEvent => java.io.OutputStream] = getReceiver match { - // case null => None - // case receiver: UploadReceiver => Some(receiver.receiver) - // } - // - // def receiver_=(receiver: Upload.ReceiveEvent => java.io.OutputStream) { - // setReceiver(new UploadReceiver(receiver)) - // } - // - // def receiver_=(receiverOption: Option[Upload.ReceiveEvent => java.io.OutputStream]) { - // receiverOption match { - // case None => setReceiver(null) - // case Some(r) => receiver = r - // } - // } + + + def receiver: Option[Receiver] = Option(getReceiver) + + def receiver_=(receiver: Receiver): Unit = receiver_=(Option(receiver)) + + def receiver_=(receiverOption: Option[Receiver]): Unit = setReceiver(receiverOption.orNull) def uploading: Boolean = isUploading diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/VWindow.scala b/addon/src/main/scala/org/vaadin/addons/rinne/VWindow.scala index 6a6d438..3793116 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/VWindow.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/VWindow.scala @@ -1,27 +1,36 @@ package org.vaadin.addons.rinne +import java.util + import com.vaadin.ui.Window -import org.vaadin.addons.rinne.events._ -import org.vaadin.addons.rinne.mixins.PanelMixin +import com.vaadin.ui.Window.{CloseListener, ResizeListener, ResizeEvent, CloseEvent} +import org.vaadin.addons.rinne.events.ListenersSet +import org.vaadin.addons.rinne.mixins.{BlurNotifierMixin, FocusNotifierMixin, PanelMixin} -class VWindow extends Window with PanelMixin with BlurNotifier with FocusNotifier { +class VWindow extends Window with PanelMixin with BlurNotifierMixin with FocusNotifierMixin { - lazy val closeListeners: ListenersSet[Window.CloseEvent => Unit] = - new ListenersTrait[Window.CloseEvent, WindowCloseListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Window.CloseListener]) + lazy val closeListeners = new ListenersSet[CloseEvent, CloseListener] { + override protected def addListener(listener: ListenerLambda): Unit = addCloseListener( + new CloseListener { + override def windowClose(e: CloseEvent): Unit = listener(e) + } + ) - override def addListener(elem: Window.CloseEvent => Unit) = addCloseListener(new WindowCloseListener(elem)) + override protected def removeListener(listener: CloseListener): Unit = removeCloseListener(listener) - override def removeListener(elem: WindowCloseListener) = removeCloseListener(elem) - } - lazy val resizeListeners: ListenersSet[Window.ResizeEvent => Unit] = - new ListenersTrait[Window.ResizeEvent, WindowResizeListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Window.CloseListener]) + override protected def listeners: util.Collection[_] = getListeners(classOf[CloseEvent]) + } + lazy val resizeListeners = new ListenersSet[ResizeEvent, ResizeListener] { + override protected def addListener(listener: ListenerLambda): Unit = addResizeListener( + new ResizeListener { + override def windowResized(e: ResizeEvent): Unit = listener(e) + } + ) - override def addListener(elem: Window.ResizeEvent => Unit) = addResizeListener(new WindowResizeListener(elem)) + override protected def removeListener(listener: ResizeListener): Unit = removeResizeListener(listener) - override def removeListener(elem: WindowResizeListener) = removeResizeListener(elem) - } + override protected def listeners: util.Collection[_] = getListeners(classOf[ResizeEvent]) + } private var _closeKeyShortcut: Option[KeyShortcut] = None def closeKeyShortcut_=(cs: Option[KeyShortcut]): Unit = { @@ -61,7 +70,4 @@ class VWindow extends Window with PanelMixin with BlurNotifier with FocusNotifie def draggable_=(draggable: Boolean) = setDraggable(draggable) - - - } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/events/ListenersSet.scala b/addon/src/main/scala/org/vaadin/addons/rinne/events/ListenersSet.scala index 1886200..2d34f00 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/events/ListenersSet.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/events/ListenersSet.scala @@ -9,7 +9,7 @@ trait ListenersSet[E, L] extends mutable.Set[E => Unit] with Serializable { import scala.collection.JavaConverters._ - abstract class Listener(val action: ListenerLambda) extends L + abstract class Listener(val action: ListenerLambda) protected def addListener(listener: ListenerLambda): Unit @@ -23,21 +23,31 @@ trait ListenersSet[E, L] extends mutable.Set[E => Unit] with Serializable { override def iterator: Iterator[ListenerLambda] = { listeners.asScala.map { - case l: L with Listener => Some(l.action) + case l: Listener => Some(l.action) case _ => None }.flatten.toIterator } - override def +=(elem: ListenerLambda): ListenersSet[E, L] = { + override def +=(elem: ListenerLambda) = { addListener(elem) this } - override def -=(elem: E => Unit): ListenersSet[E, L] = { + def +=(elem: => Unit) = { + addListener(_ => elem) + this + } + + override def -=(elem: E => Unit) = { listeners.asScala.foreach { - case e: L with Listener if e == elem => removeListener(e) + case e: Listener if e == elem => removeListener(e.asInstanceOf[L]) case _ => } this } + + override def clear(): Unit = { + super.clear() + listeners.asScala.foreach(_ => removeListener(_)) + } } \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/helpers/AutoAddAndHideComboBoxMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/AutoAddAndHideComboBoxMixin.scala new file mode 100644 index 0000000..27a9fcb --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/AutoAddAndHideComboBoxMixin.scala @@ -0,0 +1,18 @@ +package org.vaadin.addons.rinne.helpers + +import org.vaadin.addons.rinne.VComboBox + +trait AutoAddAndHideComboBoxMixin extends HideWhenEmptyMixin[AnyRef] { + this: VComboBox => + + nullSelectionAllowed = false + newItemsAllowed = true + immediate = true + + valueChangeListeners += (_ => { + value.foreach(v => + if (!containsId(v) && !v.toString.isEmpty) + addItem(v) + ) + }) +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenEmptyMixin.scala similarity index 57% rename from addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyMixin.scala rename to addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenEmptyMixin.scala index 0236d4e..beb8746 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenEmptyMixin.scala @@ -1,20 +1,16 @@ -package org.vaadin.addons.rinne.mixins +package org.vaadin.addons.rinne.helpers import com.vaadin.data.Property.{ReadOnlyStatusChangeEvent, ReadOnlyStatusChangeListener} +import com.vaadin.ui.AbstractField +import org.vaadin.addons.rinne.mixins.AbstractFieldMixin trait HideWhenEmptyMixin[T] extends AbstractFieldMixin[T] { + this: AbstractField[T] => - valueChangeListeners += _visibilityTest() + readOnlyStatusChangeListeners += (_ => _visibilityTest()) + valueChangeListeners += (_ => _visibilityTest()) _visibilityTest() - addReadOnlyStatusChangeListener( - new ReadOnlyStatusChangeListener { - override def readOnlyStatusChange(event: ReadOnlyStatusChangeEvent) { - _visibilityTest() - } - } - ) - private def _visibilityTest() { if (!readOnly) { // edit mode -> visible always @@ -25,9 +21,9 @@ trait HideWhenEmptyMixin[T] extends AbstractFieldMixin[T] { case v: String => v.size > 0 case v: Option[_] => - v.isDefined && v.get.toString.size > 0 + v.isDefined && v.get.toString.length > 0 case _ => - value.toString.size > 0 + value.toString.length > 0 } } else visible = false diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenReadOnlyMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenReadOnlyMixin.scala new file mode 100644 index 0000000..0e95871 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/HideWhenReadOnlyMixin.scala @@ -0,0 +1,17 @@ +package org.vaadin.addons.rinne.helpers + +import com.vaadin.data.Property.{ReadOnlyStatusChangeEvent, ReadOnlyStatusChangeListener} +import com.vaadin.ui.AbstractField +import org.vaadin.addons.rinne.mixins.AbstractFieldMixin + +trait HideWhenReadOnlyMixin[T] extends AbstractFieldMixin[T] { + this: AbstractField[T] => + + readOnlyStatusChangeListeners += (_ => _visibilityTest()) + valueChangeListeners += (_ => _visibilityTest()) + _visibilityTest() + + private def _visibilityTest() { + visible = !readOnly + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableAnyRefValueMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableAnyRefValueMixin.scala similarity index 50% rename from addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableAnyRefValueMixin.scala rename to addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableAnyRefValueMixin.scala index 675e56c..847fca6 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableAnyRefValueMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableAnyRefValueMixin.scala @@ -1,7 +1,11 @@ -package org.vaadin.addons.rinne.mixins +package org.vaadin.addons.rinne.helpers +import com.vaadin.ui.AbstractField import org.vaadin.addons.rinne.converters.Converters +import org.vaadin.addons.rinne.mixins.AbstractFieldMixin trait OptionableAnyRefValueMixin extends AbstractFieldMixin[AnyRef] { + this: AbstractField[AnyRef] => + setConverter(Converters.optionToAny) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableStringValueMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableStringValueMixin.scala similarity index 50% rename from addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableStringValueMixin.scala rename to addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableStringValueMixin.scala index 46037d3..9efef28 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/OptionableStringValueMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/helpers/OptionableStringValueMixin.scala @@ -1,7 +1,11 @@ -package org.vaadin.addons.rinne.mixins +package org.vaadin.addons.rinne.helpers +import com.vaadin.ui.AbstractField import org.vaadin.addons.rinne.converters.Converters +import org.vaadin.addons.rinne.mixins.AbstractFieldMixin trait OptionableStringValueMixin extends AbstractFieldMixin[String] { + this: AbstractField[String] => + setConverter(Converters.optionToString) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentContainerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentContainerMixin.scala index 7534d8c..56e331c 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentContainerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentContainerMixin.scala @@ -2,4 +2,6 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.AbstractComponentContainer -trait AbstractComponentContainerMixin extends AbstractComponentContainer with ContainerMixin +trait AbstractComponentContainerMixin { + this: AbstractComponentContainer with ContainerMixin => +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentMixin.scala index cbeada6..54e39f0 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractComponentMixin.scala @@ -2,28 +2,21 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.AbstractComponent -trait AbstractComponentMixin extends AbstractComponent with ComponentMixin { +trait AbstractComponentMixin extends ComponentMixin { + this: AbstractComponent => def description: Option[String] = Option(getDescription) - def description_=(description: Option[String]) { - setDescription(description.orNull) - } + def description_=(description: Option[String]): Unit = setDescription(description.orNull) - def description_=(description: String) { - setDescription(description) - } + def description_=(description: String): Unit = setDescription(description) def immediate: Boolean = isImmediate - def immediate_=(immediate: Boolean) { - setImmediate(immediate) - } + def immediate_=(immediate: Boolean): Unit = setImmediate(immediate) def data: Any = getData - def data_=(data: Any) { - setData(data) - } - + def data_=(data: Any): Unit = setData(data) } + diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractEmbeddedMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractEmbeddedMixin.scala index c21b53f..188f2de 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractEmbeddedMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractEmbeddedMixin.scala @@ -3,17 +3,18 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.server.Resource import com.vaadin.ui.AbstractEmbedded -trait AbstractEmbeddedMixin extends AbstractEmbedded with AbstractComponentMixin { +trait AbstractEmbeddedMixin extends AbstractComponentMixin { + this: AbstractEmbedded => def source: Option[Resource] = Option(getSource) - def source_=(source: Option[Resource]) { setSource(source.orNull) } + def source_=(source: Option[Resource]): Unit = setSource(source.orNull) - def source_=(source: Resource) { setSource(source) } + def source_=(source: Resource): Unit = setSource(source) def alternateText: Option[String] = Option(getAlternateText) - def alternateText_=(alternateText: String) { setAlternateText(alternateText) } + def alternateText_=(alternateText: String): Unit = setAlternateText(alternateText) - def alternateText_=(alternateText: Option[String]) { setAlternateText(alternateText.orNull) } + def alternateText_=(alternateText: Option[String]): Unit = setAlternateText(alternateText.orNull) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractFieldMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractFieldMixin.scala index 989e164..fdc85d9 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractFieldMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractFieldMixin.scala @@ -1,10 +1,10 @@ package org.vaadin.addons.rinne.mixins -import org.vaadin.addons.rinne.events.ValueChangeNotifier import com.vaadin.ui.AbstractField -trait AbstractFieldMixin[T] extends AbstractField[T] -with FieldMixin[T] with AbstractComponentMixin with ValueChangeNotifier { +trait AbstractFieldMixin[T] extends AbstractComponentMixin +with PropertyValueChangeNotifierMixin with PropertyReadOnlyStatusChangeNotifierMixin { + this: AbstractField[T] => def validationVisible: Boolean = isValidationVisible @@ -14,6 +14,9 @@ with FieldMixin[T] with AbstractComponentMixin with ValueChangeNotifier { def conversionError_=(conversionError: String): Unit = setConversionError(conversionError) - // override def value: Option[T] = Option(getValue) + def value: Option[T] = Option(getValue) + def value_=(v: Option[T]): Unit = setValue(v.getOrElse(null).asInstanceOf[T]) + + def value_=(v: T): Unit = setValue(v) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractLayoutMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractLayoutMixin.scala index 9cd0f31..8b71188 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractLayoutMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractLayoutMixin.scala @@ -2,4 +2,6 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.AbstractLayout -trait AbstractLayoutMixin extends AbstractLayout with ComponentContainerMixin +trait AbstractLayoutMixin extends ComponentContainerMixin { + this: AbstractLayout => +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractMediaMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractMediaMixin.scala index 9843902..679bc06 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractMediaMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractMediaMixin.scala @@ -3,50 +3,37 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.server.Resource import com.vaadin.ui.AbstractMedia -trait AbstractMediaMixin extends AbstractMedia with AbstractComponentMixin { +trait AbstractMediaMixin extends AbstractComponentMixin { + this: AbstractMedia => import scala.collection.JavaConverters._ def source: Option[Resource] = getSources.asScala.headOption - def source_=(source: Resource) { - setSource(source) - } + def source_=(source: Resource): Unit = setSource(source) def sources: Seq[Resource] = getSources.asScala def showControls: Boolean = isShowControls - def showControls_=(showControls: Boolean) { - setShowControls(showControls) - } + def showControls_=(showControls: Boolean): Unit = setShowControls(showControls) def altText: Option[String] = Option(getAltText) - def altText_=(altText: Option[String]) { - setAltText(altText.orNull) - } + def altText_=(altText: Option[String]): Unit = setAltText(altText.orNull) - def altText_=(altText: String) { - setAltText(altText) - } + def altText_=(altText: String): Unit = setAltText(altText) def htmlContentAllowed: Boolean = isHtmlContentAllowed - def htmlContentAllowed_=(htmlContentAllowed: Boolean) { - setHtmlContentAllowed(htmlContentAllowed) - } + def htmlContentAllowed_=(htmlContentAllowed: Boolean): Unit = setHtmlContentAllowed(htmlContentAllowed) def autoplay: Boolean = isAutoplay - def autoplay_=(autoplay: Boolean) { - setAutoplay(autoplay) - } + def autoplay_=(autoplay: Boolean): Unit = setAutoplay(autoplay) def muted: Boolean = isMuted - def muted_=(muted: Boolean) { - setMuted(muted) - } + def muted_=(muted: Boolean): Unit = setMuted(muted) } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractOrderedLayoutMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractOrderedLayoutMixin.scala index 0795ba6..3f472f5 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractOrderedLayoutMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractOrderedLayoutMixin.scala @@ -1,10 +1,10 @@ package org.vaadin.addons.rinne.mixins -import org.vaadin.addons.rinne.events.LayoutClickNotifierMixin import com.vaadin.ui.{Alignment, Component, AbstractOrderedLayout} -trait AbstractOrderedLayoutMixin extends AbstractOrderedLayout -with AbstractLayoutMixin with SpacingHandlerMixin with MarginHandlerMixin with LayoutClickNotifierMixin { +trait AbstractOrderedLayoutMixin extends AbstractLayoutMixin +with LayoutSpacingHandlerMixin with LayoutMarginHandlerMixin with LayoutAlignmentHandlerMixin with LayoutClickNotifierMixin { + this: AbstractOrderedLayout => def add[C <: Component](component: C, ratio: Float = -1, alignment: Alignment = null, index: Int = -1): C = { diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractPropertyMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractPropertyMixin.scala index 174b9cc..84dc744 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractPropertyMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractPropertyMixin.scala @@ -1,6 +1,8 @@ package org.vaadin.addons.rinne.mixins -import org.vaadin.addons.rinne.events.ReadOnlyStatusChangeNotifier +import com.vaadin.data.Property.ReadOnlyStatusChangeNotifier import com.vaadin.data.util.AbstractProperty -trait AbstractPropertyMixin[T] extends AbstractProperty[T] with PropertyMixin[T] with ReadOnlyStatusChangeNotifier[T] \ No newline at end of file +trait AbstractPropertyMixin[T] extends PropertyMixin[T] with ReadOnlyStatusChangeNotifier { + this: AbstractProperty[T] => +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSelectMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSelectMixin.scala index 278b309..63a1953 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSelectMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSelectMixin.scala @@ -3,7 +3,10 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.AbstractSelect import com.vaadin.ui.AbstractSelect.ItemCaptionMode -trait AbstractSelectMixin extends AbstractSelect with AbstractFieldMixin[Object] with ComponentMixin { +trait AbstractSelectMixin extends AbstractFieldMixin[AnyRef] with ComponentMixin +with ContainerMixin with ContainerViewerMixin with ContainerItemSetChangeNotifierMixin +with ContainerPropertySetChangeNotifierMixin { + this: AbstractSelect => def newItemsAllowed: Boolean = isNewItemsAllowed @@ -11,44 +14,33 @@ trait AbstractSelectMixin extends AbstractSelect with AbstractFieldMixin[Object] def itemCaptionMode: ItemCaptionMode = getItemCaptionMode - def itemCaptionMode_=(itemCaptionMode: ItemCaptionMode) { - setItemCaptionMode(itemCaptionMode) - } + def itemCaptionMode_=(itemCaptionMode: ItemCaptionMode): Unit = setItemCaptionMode(itemCaptionMode) def itemCaptionPropertyId: Option[Any] = Option(getItemCaptionPropertyId) - def itemCaptionPropertyId_=(itemCaptionPropertyId: Option[Any]) { + def itemCaptionPropertyId_=(itemCaptionPropertyId: Option[Any]): Unit = { setItemCaptionPropertyId(itemCaptionPropertyId.orNull) } - def itemCaptionPropertyId_=(itemCaptionPropertyId: Any) { - setItemCaptionPropertyId(itemCaptionPropertyId) - } + def itemCaptionPropertyId_=(itemCaptionPropertyId: Any): Unit = setItemCaptionPropertyId(itemCaptionPropertyId) def itemIconPropertyId: Option[Any] = Option(getItemIconPropertyId) - def itemIconPropertyId_=(itemIconPropertyId: Option[Any]) { - setItemIconPropertyId(itemIconPropertyId.orNull) - } + def itemIconPropertyId_=(itemIconPropertyId: Option[Any]): Unit = setItemIconPropertyId(itemIconPropertyId.orNull) - def itemIconPropertyId_=(itemIconPropertyId: Any) { - setItemIconPropertyId(itemIconPropertyId) - } + def itemIconPropertyId_=(itemIconPropertyId: Any): Unit = setItemIconPropertyId(itemIconPropertyId) def nullSelectionAllowed: Boolean = isNullSelectionAllowed - def nullSelectionAllowed_=(nullSelectionAllowed: Boolean) { - setNullSelectionAllowed(nullSelectionAllowed) - } + def nullSelectionAllowed_=(nullSelectionAllowed: Boolean): Unit = setNullSelectionAllowed(nullSelectionAllowed) def nullSelectionItemId: Option[Any] = Option(getNullSelectionItemId) - def nullSelectionItemId_=(nullSelectionItemId: Option[Any]) { - setNullSelectionItemId(nullSelectionItemId.orNull) - } + def nullSelectionItemId_=(nullSelectionItemId: Option[Any]): Unit = setNullSelectionItemId(nullSelectionItemId.orNull) - def nullSelectionItemId_=(nullSelectionItemId: Any) { - setNullSelectionItemId(nullSelectionItemId) - } + def nullSelectionItemId_=(nullSelectionItemId: Any): Unit = setNullSelectionItemId(nullSelectionItemId) + + def multiSelect: Boolean = isMultiSelect + def multiSelect_=(multiSelect: Boolean): Unit = setMultiSelect(multiSelect) } \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSingleComponentContainerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSingleComponentContainerMixin.scala index 29e6274..a9e0fe0 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSingleComponentContainerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSingleComponentContainerMixin.scala @@ -2,7 +2,9 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.{Component, AbstractSingleComponentContainer} -trait AbstractSingleComponentContainerMixin extends AbstractSingleComponentContainer { +trait AbstractSingleComponentContainerMixin { + this: AbstractSingleComponentContainer => + def componentCount: Int = getComponentCount def content: Option[Component] = Option(getContent) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSplitPanelMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSplitPanelMixin.scala index af06056..67ff456 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSplitPanelMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractSplitPanelMixin.scala @@ -1,51 +1,70 @@ package org.vaadin.addons.rinne.mixins +import java.util + +import com.vaadin.ui.AbstractSplitPanel.{SplitterClickListener, SplitterClickEvent} +import org.vaadin.addons.rinne.events.ListenersSet import org.vaadin.addons.rinne.{Units, Measure} import com.vaadin.server.Sizeable.{Unit => VaadinUnit} import com.vaadin.ui.{Component, AbstractSplitPanel} -trait AbstractSplitPanelMixin extends AbstractSplitPanel with ComponentContainerMixin with SizeableMixin { +trait AbstractSplitPanelMixin extends ComponentContainerMixin with SizeableMixin { + this: AbstractSplitPanel => - def firstComponent: Option[Component] = Option(getFirstComponent) + lazy val splitterClickListeners = new ListenersSet[SplitterClickEvent, SplitterClickListener] { + override protected def addListener(listener: ListenerLambda): Unit = addSplitterClickListener( + new SplitterClickListener { + override def splitterClick(event: SplitterClickEvent): Unit = listener(event) + } + ) - def firstComponent_=(component: Component) { setFirstComponent(component) } + override protected def removeListener(listener: SplitterClickListener): Unit = removeSplitterClickListener(listener) - def firstComponent_=(component: Option[Component]) { setFirstComponent(component.orNull) } + override protected def listeners: util.Collection[_] = getListeners(classOf[SplitterClickEvent]) + } + var reserved = false - def secondComponent: Option[Component] = Option(getSecondComponent) + def firstComponent: Option[Component] = Option(getFirstComponent) - def secondComponent_=(component: Component) { setSecondComponent(component) } + def firstComponent_=(component: Component): Unit = setFirstComponent(component) - def secondComponent_=(component: Option[Component]) { setSecondComponent(component.orNull) } + def firstComponent_=(component: Option[Component]): Unit = setFirstComponent(component.orNull) - var reserved = false + def secondComponent: Option[Component] = Option(getSecondComponent) - def splitPosition: Measure = new Measure(getSplitPosition, Units(getSplitPositionUnit.ordinal)) + def secondComponent_=(component: Component): Unit = setSecondComponent(component) + + def secondComponent_=(component: Option[Component]): Unit = setSecondComponent(component.orNull) - def splitPosition_=(position: Option[Measure]) { + def splitPosition_=(position: Option[Measure]): Unit = { position match { - case None => setSplitPosition(50, VaadinUnit.PERCENTAGE, reserved) case Some(pos) => setSplitPosition(pos.value.intValue, VaadinUnit.values().apply(pos.unit.id), reserved) + case None => setSplitPosition(50, VaadinUnit.PERCENTAGE, reserved) } } - def splitPosition_=(position: Measure) { splitPosition = Some(position) } + def splitPosition: Measure = new Measure(getSplitPosition, Units(getSplitPositionUnit.ordinal)) def minSplitPosition: Measure = Measure(getMinSplitPosition, Units(getMinSplitPositionUnit.ordinal)) - def minSplitPosition_=(minSplitPosition: Option[Measure]) { + def minSplitPosition_=(minSplitPosition: Option[Measure]): Unit = { minSplitPosition match { - case None => setMinSplitPosition(0, com.vaadin.server.Sizeable.Unit.PERCENTAGE) case Some(pos) => setMinSplitPosition(pos.value.intValue, VaadinUnit.values.apply(pos.unit.id)) + case None => setMinSplitPosition(0, com.vaadin.server.Sizeable.Unit.PERCENTAGE) } } def maxSplitPosition: Measure = Measure(getMaxSplitPosition, Units(getMaxSplitPositionUnit.ordinal)) - def maxSplitPosition_=(maxSplitPosition: Option[Measure]) { + def splitPosition_=(position: Measure): Unit = + { + splitPosition = Some(position) + } + + def maxSplitPosition_=(maxSplitPosition: Option[Measure]): Unit = { maxSplitPosition match { - case None => setMaxSplitPosition(100, VaadinUnit.PERCENTAGE) case Some(pos) => setMaxSplitPosition(pos.value.floatValue, VaadinUnit.values.apply(pos.unit.id)) + case None => setMaxSplitPosition(100, VaadinUnit.PERCENTAGE) } } @@ -53,11 +72,5 @@ trait AbstractSplitPanelMixin extends AbstractSplitPanel with ComponentContainer def locked_=(locked: Boolean) { setLocked(locked) } - // lazy val splitterClickListeners: ListenersSet[AbstractSplitPanel.SplitterClickEvent => Unit] = - // new ListenersTrait[AbstractSplitPanel.SplitterClickEvent, SplitterClickListener] { - // override def listeners = getListeners(classOf[com.vaadin.ui.AbstractSplitPanel.SplitterClickEvent]) - // override def addListener(elem: AbstractSplitPanel.SplitterClickEvent => Unit) = - // addSplitterClickListener(new SplitterClickListener(elem)) - // override def removeListener(elem: SplitterClickListener) = removeSplitterClickListener(elem) - // } + } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractTextFieldMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractTextFieldMixin.scala index 3dd4d5b..0aa9751 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractTextFieldMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AbstractTextFieldMixin.scala @@ -1,13 +1,28 @@ package org.vaadin.addons.rinne.mixins -import org.vaadin.addons.rinne.events.{BlurNotifier, FocusNotifier} +import java.util + +import com.vaadin.event.FieldEvents.{TextChangeListener, TextChangeEvent} import com.vaadin.ui.AbstractTextField +import org.vaadin.addons.rinne.events.ListenersSet -trait AbstractTextFieldMixin extends AbstractTextField -with AbstractFieldMixin[String] with BlurNotifier with FocusNotifier { +trait AbstractTextFieldMixin extends AbstractFieldMixin[String] with BlurNotifierMixin with FocusNotifierMixin { + this: AbstractTextField => nullRepresentation = "" + lazy val textChangeListeners = new ListenersSet[TextChangeEvent, TextChangeListener] { + override protected def addListener(listener: ListenerLambda): Unit = addTextChangeListener( + new TextChangeListener { + override def textChange(event: TextChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: TextChangeListener): Unit = removeTextChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[TextChangeEvent]) + } + def prompt: Option[String] = Option(getInputPrompt) def prompt_=(prompt: Option[String]) { @@ -57,14 +72,4 @@ with AbstractFieldMixin[String] with BlurNotifier with FocusNotifier { def textChangeTimeout = getTextChangeTimeout def textChangeTimeout_=(textChangeTimeout: Int) = setTextChangeTimeout(textChangeTimeout) - - // lazy val textChangeListeners: ListenersSet[AbstractTextField.TextChangeEvent => Unit] = - // new ListenersTrait[AbstractTextField.TextChangeEvent, TextChangeListener] { - // override def listeners = p.getListeners(classOf[com.vaadin.event.FieldEvents.TextChangeEvent]) - // - // override def addListener(elem: AbstractTextField.TextChangeEvent => Unit) = - // p.addTextChangeListener(new TextChangeListener(elem)) - // - // override def removeListener(elem: TextChangeListener) = p.removeTextChangeListener(elem) - // } } \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AutoAddAndHideComboBoxMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AutoAddAndHideComboBoxMixin.scala deleted file mode 100644 index cf35a7d..0000000 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/AutoAddAndHideComboBoxMixin.scala +++ /dev/null @@ -1,14 +0,0 @@ -package org.vaadin.addons.rinne.mixins - -import org.vaadin.addons.rinne.VComboBox - -trait AutoAddAndHideComboBoxMixin extends VComboBox with HideWhenEmptyMixin[AnyRef] { - nullSelectionAllowed = false - newItemsAllowed = true - immediate = true - - valueChangeListeners += (_ => { - if (value.isDefined && !containsId(value.get) && !value.get.toString.isEmpty) - addItem(value.get) - }) -} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/BlurNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/BlurNotifierMixin.scala index 97c4a4c..ce281b8 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/BlurNotifierMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/BlurNotifierMixin.scala @@ -3,8 +3,9 @@ package org.vaadin.addons.rinne.mixins import java.util import com.vaadin.event.FieldEvents.{BlurEvent, BlurListener, BlurNotifier} +import com.vaadin.server.AbstractClientConnector import com.vaadin.ui.AbstractComponent -import org.vaadin.addons.rinne.events._ +import org.vaadin.addons.rinne.events.ListenersSet trait BlurNotifierMixin { this: AbstractComponent with BlurNotifier => diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ButtonMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ButtonMixin.scala new file mode 100644 index 0000000..a68484d --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ButtonMixin.scala @@ -0,0 +1,54 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.ui.Button +import com.vaadin.ui.Button.ClickEvent +import org.vaadin.addons.rinne.KeyShortcut +import org.vaadin.addons.rinne.events.ListenersSet + +trait ButtonMixin extends AbstractComponentMixin with BlurNotifierMixin with FocusNotifierMixin with FocusableMixin { + this: Button => + + lazy val clickListeners = new ListenersSet[Button.ClickEvent, Button.ClickListener] { + override protected def addListener(listener: ListenerLambda): Unit = addClickListener( + new Listener(listener) with Button.ClickListener { + override def buttonClick(event: ClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: Button.ClickListener): Unit = removeClickListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[Button.ClickEvent]) + } + private var _clickKeyShortcut: Option[KeyShortcut] = None + + def clickKeyShortcut_=(clickShortcut: Option[KeyShortcut]): Unit = { + _clickKeyShortcut = clickShortcut + clickShortcut match { + case Some(shortcut) => setClickShortcut(shortcut.keyCode.value, shortcut.modifiers.map(_.value): _*) + case None => removeClickShortcut() + } + } + + def clickKeyShortcut: Option[KeyShortcut] = _clickKeyShortcut + + def disableOnClick: Boolean = isDisableOnClick + + def disableOnClick_=(disableOnClick: Boolean): Unit = { + setDisableOnClick(disableOnClick) + } + + def htmlContentAllowed: Boolean = isHtmlContentAllowed + + def clickKeyShortcut_=(clickShortcut: KeyShortcut): Unit = + { + this.clickKeyShortcut = Option(clickShortcut) + } + + def htmlContentAllowed_=(htmlContentAllowed: Boolean): Unit = { + setHtmlContentAllowed(htmlContentAllowed) + } + + +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentContainerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentContainerMixin.scala index 3c1d491..47f3ffd 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentContainerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentContainerMixin.scala @@ -1,20 +1,17 @@ package org.vaadin.addons.rinne.mixins -import com.vaadin.ui.{Component, ComponentContainer} -import scala.collection.mutable +import com.vaadin.ui.{AbstractComponentContainer, Component, ComponentContainer} -trait ComponentContainerMixin extends ComponentContainer with ComponentMixin { +import scala.collection.mutable - def add[C <: Component](component: C) = { - addComponent(component) - component - } +trait ComponentContainerMixin extends ComponentMixin { + this: ComponentContainer => lazy val componentSet = new mutable.Set[Component] with Serializable { import scala.collection.JavaConverters._ - def contains(key: Component) = { + def contains(key: Component): Boolean = { iterator.contains(key) } @@ -22,9 +19,20 @@ trait ComponentContainerMixin extends ComponentContainer with ComponentMixin { ComponentContainerMixin.this.iterator().asScala } - def +=(elem: Component) = { addComponent(elem); this } + def +=(elem: Component) = { + addComponent(elem) + this + } - def -=(elem: Component) = { removeComponent(elem); this } + def -=(elem: Component) = { + removeComponent(elem) + this + } + } + + def add[C <: Component](component: C): C = { + addComponent(component) + component } } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentMixin.scala index 13e3a72..ec9beb3 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ComponentMixin.scala @@ -5,13 +5,8 @@ import com.vaadin.ui.{Component, UI} import java.util.Locale import scala.collection.mutable -trait ComponentMixin extends Component with SizeableMixin { - - def styleName: Option[String] = Option(getStyleName) - - def styleName_=(styleName: Option[String]) { setStyleName(styleName.orNull) } - - def styleName_=(styleName: String) { setStyleName(styleName) } +trait ComponentMixin extends SizeableMixin { + this: Component => lazy val styleNames = new mutable.Set[String] with Serializable { def contains(key: String) = getStyleName.split(" ").iterator.contains(key) @@ -23,6 +18,16 @@ trait ComponentMixin extends Component with SizeableMixin { def -=(elem: String) = { removeStyleName(elem); this } } + def styleName: Option[String] = Option(getStyleName) + + def styleName_=(styleName: Option[String]) { + setStyleName(styleName.orNull) + } + + def styleName_=(styleName: String) { + setStyleName(styleName) + } + def enabled: Boolean = isEnabled def enabled_=(enabled: Boolean) { setEnabled(enabled) } @@ -37,13 +42,17 @@ trait ComponentMixin extends Component with SizeableMixin { def caption: Option[String] = Option(getCaption) - def caption_=(caption: Option[String]) { setCaption(caption.orNull) } + def caption_=(caption: Option[String]) { + setCaption(caption.orNull) + } def caption_=(caption: String) { setCaption(caption) } def icon: Option[Resource] = Option(getIcon) - def icon_=(icon: Option[Resource]) { setIcon(icon.orNull) } + def icon_=(icon: Option[Resource]) { + setIcon(icon.orNull) + } def icon_=(icon: Resource) { setIcon(icon) } @@ -53,7 +62,9 @@ trait ComponentMixin extends Component with SizeableMixin { def id: Option[String] = Option(getId) - def id_=(id: Option[String]) { setId(id.orNull) } + def id_=(id: Option[String]) { + setId(id.orNull) + } def id_=(id: String) { setId(id) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerItemSetChangeNotifierMixin2.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerItemSetChangeNotifierMixin2.scala new file mode 100644 index 0000000..78d4b49 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerItemSetChangeNotifierMixin2.scala @@ -0,0 +1,26 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.data.Container.ItemSetChangeEvent +import com.vaadin.data.{Container, Property} +import com.vaadin.data.Property.{ValueChangeEvent, ValueChangeListener} +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait ContainerItemSetChangeNotifierMixin2 { + this: AbstractComponent with Container.ItemSetChangeNotifier => + + lazy val itemSetChangeListeners = new ListenersSet[Container.ItemSetChangeEvent, Container.ItemSetChangeListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addItemSetChangeListener( + new Listener(listener) with Container.ItemSetChangeListener { + override def containerItemSetChange(event: ItemSetChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: Container.ItemSetChangeListener): Unit = removeItemSetChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[Container.ItemSetChangeEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerMixin.scala index 6d3e568..70de655 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerMixin.scala @@ -2,7 +2,8 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.data.Container -trait ContainerMixin extends Container with ComponentMixin { +trait ContainerMixin { + this: Container => import scala.collection.JavaConverters._ diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerPropertySetChangeNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerPropertySetChangeNotifierMixin.scala new file mode 100644 index 0000000..c882027 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerPropertySetChangeNotifierMixin.scala @@ -0,0 +1,25 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.data.Container +import com.vaadin.data.Container.{PropertySetChangeEvent, ItemSetChangeEvent} +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait ContainerPropertySetChangeNotifierMixin { + this: AbstractComponent with Container.PropertySetChangeNotifier => + + lazy val propertySetChangeListeners = new ListenersSet[Container.PropertySetChangeEvent, Container.PropertySetChangeListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addPropertySetChangeListener( + new Listener(listener) with Container.PropertySetChangeListener { + override def containerPropertySetChange(event: PropertySetChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: Container.PropertySetChangeListener): Unit = removePropertySetChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[Container.PropertySetChangeEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerViewerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerViewerMixin.scala new file mode 100644 index 0000000..613412a --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ContainerViewerMixin.scala @@ -0,0 +1,14 @@ +package org.vaadin.addons.rinne.mixins + +import com.vaadin.data.Container + +trait ContainerViewerMixin { + this: Container.Viewer => + + def dataSource_=(newDataSource: Container): Unit = dataSource = Some(newDataSource) + + def dataSource: Option[Container] = Option(getContainerDataSource) + + def dataSource_=(newDataSource: Option[Container]): Unit = setContainerDataSource(newDataSource.orNull) + +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/DateFieldMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/DateFieldMixin.scala index 66d948f..d5a9635 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/DateFieldMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/DateFieldMixin.scala @@ -4,9 +4,9 @@ import java.util.{TimeZone, Date} import com.vaadin.shared.ui.datefield.Resolution import com.vaadin.ui.DateField -import org.vaadin.addons.rinne.events.{FocusNotifier, BlurNotifier} -trait DateFieldMixin extends DateField with AbstractFieldMixin[Date] with BlurNotifier with FocusNotifier { +trait DateFieldMixin extends AbstractFieldMixin[Date] with BlurNotifierMixin with FocusNotifierMixin { + this: DateField => resolution = Resolution.SECOND diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusNotifierMixin.scala new file mode 100644 index 0000000..d399e11 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusNotifierMixin.scala @@ -0,0 +1,24 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.event.FieldEvents.{FocusListener, FocusEvent, FocusNotifier} +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait FocusNotifierMixin { + this: AbstractComponent with FocusNotifier => + + lazy val focusListeners = new ListenersSet[FocusEvent, FocusListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addFocusListener( + new Listener(listener) with FocusListener { + override def focus(focusEvent: FocusEvent): Unit = listener(focusEvent) + } + ) + + override protected def removeListener(listener: FocusListener): Unit = removeFocusListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[FocusEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusableMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusableMixin.scala index e8b9696..4423608 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusableMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/FocusableMixin.scala @@ -2,7 +2,8 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.Component -trait FocusableMixin extends Component.Focusable with ComponentMixin { +trait FocusableMixin extends ComponentMixin { + this: Component.Focusable => def tabIndex: Int = getTabIndex diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyStringMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyStringMixin.scala deleted file mode 100644 index c826e43..0000000 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/HideWhenEmptyStringMixin.scala +++ /dev/null @@ -1,3 +0,0 @@ -package org.vaadin.addons.rinne.mixins - -trait HideWhenEmptyStringMixin extends HideWhenEmptyMixin[String] \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ItemClickNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ItemClickNotifierMixin.scala new file mode 100644 index 0000000..4e2718c --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ItemClickNotifierMixin.scala @@ -0,0 +1,25 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.event.ItemClickEvent +import com.vaadin.event.ItemClickEvent.{ItemClickListener, ItemClickNotifier} +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait ItemClickNotifierMixin { + this: AbstractComponent with ItemClickNotifier => + + lazy val itemClickListeners = new ListenersSet[ItemClickEvent, ItemClickListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addItemClickListener( + new Listener(listener) with ItemClickListener { + override def itemClick(event: ItemClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: ItemClickListener): Unit = removeItemClickListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[ItemClickEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutAlignmentHandlerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutAlignmentHandlerMixin.scala new file mode 100644 index 0000000..c1d99c9 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutAlignmentHandlerMixin.scala @@ -0,0 +1,18 @@ +package org.vaadin.addons.rinne.mixins + +import com.vaadin.ui.{Alignment, Component, Layout} + +trait LayoutAlignmentHandlerMixin { + this: Layout.AlignmentHandler => + + def componentAlignment(component: Component): Alignment = getComponentAlignment(component) + + def componentAlignment_=(component: Component, alignment: Alignment): Unit = + setComponentAlignment(component, alignment) + + def defaultComponentAlignment: Alignment = getDefaultComponentAlignment + + def defaultComponentAlignment_=(defaultComponentAlignment: Alignment): Unit = + setDefaultComponentAlignment(defaultComponentAlignment) + +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutClickNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutClickNotifierMixin.scala index fd78079..8a52357 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutClickNotifierMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutClickNotifierMixin.scala @@ -2,10 +2,9 @@ package org.vaadin.addons.rinne.mixins import java.util -import com.vaadin.event.FieldEvents.{BlurEvent, BlurListener, BlurNotifier} import com.vaadin.event.LayoutEvents.{LayoutClickEvent, LayoutClickListener, LayoutClickNotifier} import com.vaadin.ui.AbstractComponent -import org.vaadin.addons.rinne.events._ +import org.vaadin.addons.rinne.events.ListenersSet trait LayoutClickNotifierMixin { this: AbstractComponent with LayoutClickNotifier => diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MarginHandlerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutMarginHandlerMixin.scala similarity index 84% rename from addon/src/main/scala/org/vaadin/addons/rinne/mixins/MarginHandlerMixin.scala rename to addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutMarginHandlerMixin.scala index 593a7ef..2a15617 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MarginHandlerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutMarginHandlerMixin.scala @@ -4,21 +4,24 @@ import com.vaadin.ui.Layout.MarginHandler case class Margin(top: Boolean = false, right: Boolean = false, bottom: Boolean = false, left: Boolean = false) -trait MarginHandlerMixin extends MarginHandler { +trait LayoutMarginHandlerMixin { + this: MarginHandler => + + def margin_=(margin: Boolean) { + setMargin(margin) + } + + def margin(top: Boolean = false, right: Boolean = false, bottom: Boolean = false, left: Boolean = false) { + margin = Margin(top, right, bottom, left) + } def margin: Margin = { val margin = getMargin Margin(margin.hasTop, margin.hasRight, margin.hasBottom, margin.hasLeft) } - def margin_=(margin: Boolean) { setMargin(margin) } - def margin_=(margin: Margin) { setMargin(new com.vaadin.shared.ui.MarginInfo(margin.top, margin.right, margin.bottom, margin.left)) } - def margin(top: Boolean = false, right: Boolean = false, bottom: Boolean = false, left: Boolean = false) { - margin = Margin(top, right, bottom, left) - } - } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SpacingHandlerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutSpacingHandlerMixin.scala similarity index 75% rename from addon/src/main/scala/org/vaadin/addons/rinne/mixins/SpacingHandlerMixin.scala rename to addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutSpacingHandlerMixin.scala index 290ab06..037f38b 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SpacingHandlerMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/LayoutSpacingHandlerMixin.scala @@ -2,7 +2,8 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.Layout.SpacingHandler -trait SpacingHandlerMixin extends SpacingHandler { +trait LayoutSpacingHandlerMixin { + this: SpacingHandler => def spacing: Boolean = isSpacing diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseClickNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseClickNotifierMixin.scala new file mode 100644 index 0000000..9ecb856 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseClickNotifierMixin.scala @@ -0,0 +1,28 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.event.MouseEvents +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait MouseClickNotifierMixin { + this: AbstractComponent => + + lazy val clickListeners = new ListenersSet[MouseEvents.ClickEvent, MouseEvents.ClickListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addClickListener( + new Listener(listener) with MouseEvents.ClickListener { + override def click(event: MouseEvents.ClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: MouseEvents.ClickListener): Unit = removeClickListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[MouseEvents.ClickEvent]) + } + + def addClickListener(listener: MouseEvents.ClickListener): Unit + + def removeClickListener(listener: MouseEvents.ClickListener): Unit +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseDoubleClickNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseDoubleClickNotifierMixin.scala new file mode 100644 index 0000000..557d8d3 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MouseDoubleClickNotifierMixin.scala @@ -0,0 +1,28 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.event.MouseEvents +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait MouseDoubleClickNotifierMixin { + this: AbstractComponent => + + lazy val clickListeners = new ListenersSet[MouseEvents.DoubleClickEvent, MouseEvents.DoubleClickListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addClickListener( + new Listener(listener) with MouseEvents.DoubleClickListener { + override def doubleClick(event: MouseEvents.DoubleClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: MouseEvents.DoubleClickListener): Unit = removeClickListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[MouseEvents.DoubleClickEvent]) + } + + def addClickListener(listener: MouseEvents.DoubleClickListener): Unit + + def removeClickListener(listener: MouseEvents.DoubleClickListener): Unit +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MultiSelectableMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MultiSelectableMixin.scala deleted file mode 100644 index f06b4cc..0000000 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/MultiSelectableMixin.scala +++ /dev/null @@ -1,9 +0,0 @@ -package org.vaadin.addons.rinne.mixins - -import com.vaadin.ui.AbstractSelect - -trait MultiSelectableMixin extends AbstractSelect { - def multiSelect: Boolean = isMultiSelect - - def multiSelect_=(multiSelect: Boolean) { setMultiSelect(multiSelect) } -} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PanelMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PanelMixin.scala index f21477e..9e8d9b2 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PanelMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PanelMixin.scala @@ -2,7 +2,8 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.ui.Panel -trait PanelMixin extends Panel with AbstractSingleComponentContainerMixin with FocusableMixin { +trait PanelMixin extends AbstractSingleComponentContainerMixin with FocusableMixin { + this: Panel => def scrollLeft: Int = getScrollLeft diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyMixin.scala index c8af546..517b1b1 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyMixin.scala @@ -2,7 +2,8 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.data.Property -trait PropertyMixin[T] extends Property[T] { +trait PropertyMixin[T] { + this: Property[T] => def value: Option[T] = Option(getValue) diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyReadOnlyStatusChangeNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyReadOnlyStatusChangeNotifierMixin.scala new file mode 100644 index 0000000..654a7a1 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyReadOnlyStatusChangeNotifierMixin.scala @@ -0,0 +1,24 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.data.Property +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait PropertyReadOnlyStatusChangeNotifierMixin { + this: AbstractComponent with Property.ReadOnlyStatusChangeNotifier => + + lazy val readOnlyStatusChangeListeners = new ListenersSet[Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addReadOnlyStatusChangeListener( + new Listener(listener) with Property.ReadOnlyStatusChangeListener { + override def readOnlyStatusChange(event: Property.ReadOnlyStatusChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: Property.ReadOnlyStatusChangeListener): Unit = removeReadOnlyStatusChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[Property.ReadOnlyStatusChangeEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyValueChangeNotifierMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyValueChangeNotifierMixin.scala new file mode 100644 index 0000000..5dd6bc0 --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyValueChangeNotifierMixin.scala @@ -0,0 +1,25 @@ +package org.vaadin.addons.rinne.mixins + +import java.util + +import com.vaadin.data.Property +import com.vaadin.data.Property.{ValueChangeListener, ValueChangeEvent} +import com.vaadin.ui.AbstractComponent +import org.vaadin.addons.rinne.events.ListenersSet + +trait PropertyValueChangeNotifierMixin { + this: AbstractComponent with Property.ValueChangeNotifier => + + lazy val valueChangeListeners = new ListenersSet[ValueChangeEvent, ValueChangeListener] { + + override protected def addListener(listener: ListenerLambda): Unit = addValueChangeListener( + new Listener(listener) with ValueChangeListener { + override def valueChange(event: ValueChangeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: ValueChangeListener): Unit = removeValueChangeListener(listener) + + override protected def listeners: util.Collection[_] = getListeners(classOf[ValueChangeEvent]) + } +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyViewerMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyViewerMixin.scala new file mode 100644 index 0000000..2abcb3a --- /dev/null +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/PropertyViewerMixin.scala @@ -0,0 +1,14 @@ +package org.vaadin.addons.rinne.mixins + +import com.vaadin.data.Property + +trait PropertyViewerMixin { + this: Property.Viewer => + + def dataSource: Option[Property[_]] = Option(getPropertyDataSource) + + def dataSource_=(newDataSource: Property[_]): Unit = dataSource_=(Some(newDataSource)) + + def dataSource_=(newDataSource: Option[Property[_]]): Unit = setPropertyDataSource(newDataSource.orNull) + +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ShowOnlyInEditModeMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ShowOnlyInEditModeMixin.scala deleted file mode 100644 index efc5c03..0000000 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/ShowOnlyInEditModeMixin.scala +++ /dev/null @@ -1,21 +0,0 @@ -package org.vaadin.addons.rinne.mixins - -import com.vaadin.data.Property.{ReadOnlyStatusChangeEvent, ReadOnlyStatusChangeListener} - -trait ShowOnlyInEditModeMixin[T] extends AbstractFieldMixin[T] { - - valueChangeListeners += _visibilityTest() - _visibilityTest() - - addReadOnlyStatusChangeListener( - new ReadOnlyStatusChangeListener { - override def readOnlyStatusChange(event: ReadOnlyStatusChangeEvent) { - _visibilityTest() - } - } - ) - - private def _visibilityTest() { - visible = !readOnly - } -} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SizeableMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SizeableMixin.scala index c49fb73..242be44 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SizeableMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/SizeableMixin.scala @@ -1,23 +1,15 @@ package org.vaadin.addons.rinne.mixins -import org.vaadin.addons.rinne.{Measure, Units} import com.vaadin.server.Sizeable +import org.vaadin.addons.rinne.{Measure, Units} -trait SizeableMixin extends Sizeable { - - - def width: Option[Measure] = if (getWidth < 0) None else Option(Measure(getWidth, Units(getWidthUnits.ordinal))) +trait SizeableMixin { + this: Sizeable => def width_=(width: Option[Measure]) = setWidth(if (width.isDefined) width.get.toString else null) - def width_=(width: Measure) = setWidth(if (width != null) width.toString else null) - - def height: Option[Measure] = if (getHeight < 0) None else Option(Measure(getHeight, Units(getHeightUnits.ordinal))) - def height_=(height: Option[Measure]) = setHeight(if (height.isDefined) height.get.toString else null) - def height_=(height: Measure) = setHeight(if (height != null) height.toString else null) - def sizeFull() = setSizeFull() def sizeUndefined() = setSizeUndefined() @@ -31,4 +23,12 @@ trait SizeableMixin extends Sizeable { this.width = width this.height = height } -} \ No newline at end of file + + def width: Option[Measure] = if (getWidth < 0) None else Option(Measure(getWidth, Units(getWidthUnits.ordinal))) + + def width_=(width: Measure) = setWidth(if (width != null) width.toString else null) + + def height: Option[Measure] = if (getHeight < 0) None else Option(Measure(getHeight, Units(getHeightUnits.ordinal))) + + def height_=(height: Measure) = setHeight(if (height != null) height.toString else null) +} diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TabSheetMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TabSheetMixin.scala index f555f92..461f5bd 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TabSheetMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TabSheetMixin.scala @@ -1,45 +1,40 @@ package org.vaadin.addons.rinne.mixins -import com.vaadin.ui.Component.Focusable +import java.util + +import com.vaadin.ui.TabSheet.{SelectedTabChangeEvent, SelectedTabChangeListener} import com.vaadin.ui.{Component, TabSheet} import org.vaadin.addons.rinne.events._ -trait TabSheetMixin extends TabSheet with AbstractComponentMixin with Focusable with FocusNotifier with BlurNotifier { +trait TabSheetMixin extends AbstractComponentMixin with FocusNotifierMixin with BlurNotifierMixin { + this: TabSheet => + lazy val selectedTabChangeListeners = new ListenersSet[TabSheet.SelectedTabChangeEvent, SelectedTabChangeListener] { + override protected def addListener(listener: ListenerLambda): Unit = addSelectedTabChangeListener( + new Listener(listener) with SelectedTabChangeListener { + override def selectedTabChange(selectedTabChangeEvent: SelectedTabChangeEvent): Unit = listener(selectedTabChangeEvent) + } + ) - override def addTab(component: Component, caption: String): TabSheet.Tab = super.addTab(component, caption) + override protected def removeListener(listener: SelectedTabChangeListener): Unit = removeSelectedTabChangeListener(listener) - // def addTab(component: Component, caption: String, icon: Resource): TabSheet.Tab = - // register(p.addTab(component.p, caption, icon.p)) - // def addTab(component: Component, caption: String, icon: Resource, position: Int): TabSheet.Tab = - // register(p.addTab(component.p, caption, icon.p, position)) - // def addTab(component: Component, position: Int): TabSheet.Tab = register(p.addTab(component.p, position)) + override protected def listeners: util.Collection[_] = getListeners(classOf[TabSheet.SelectedTabChangeListener]) + } def add[C <: Component](component: C): C = { addTab(component) component } - def tabsVisible: Boolean = !areTabsHidden - def tabsVisible_=(tabsVisible: Boolean) { hideTabs(!tabsVisible) } - - def selectedComponent: Component = getSelectedTab - - def selectedComponent_=(component: Component) { setSelectedTab(component) } + def tabsVisible_=(tabsVisible: Boolean): Unit = hideTabs(!tabsVisible) def selectedTab: TabSheet.Tab = getTab(selectedComponent) - def selectedTab_=(tab: TabSheet.Tab) { selectedComponent = tab.getComponent } + def selectedTab_=(tab: TabSheet.Tab): Unit = selectedComponent = tab.getComponent - lazy val selectedTabChangeListeners: ListenersSet[TabSheet.SelectedTabChangeEvent => Unit] = - new ListenersTrait[TabSheet.SelectedTabChangeEvent, SelectedTabChangeListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.TabSheet.SelectedTabChangeEvent]) - - override def addListener(elem: TabSheet.SelectedTabChangeEvent => Unit) = - addSelectedTabChangeListener(new SelectedTabChangeListener(elem)) + def selectedComponent: Component = getSelectedTab - override def removeListener(elem: SelectedTabChangeListener) = removeSelectedTabChangeListener(elem) - } -} + def selectedComponent_=(component: Component): Unit = setSelectedTab(component) +} \ No newline at end of file diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TableMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TableMixin.scala index a5464d2..2d900d7 100644 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TableMixin.scala +++ b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/TableMixin.scala @@ -3,14 +3,57 @@ package org.vaadin.addons.rinne.mixins import com.vaadin.server.Resource import com.vaadin.shared.ui.MultiSelectMode import com.vaadin.ui.Table +import com.vaadin.ui.Table._ import org.vaadin.addons.rinne.SelectionMode import org.vaadin.addons.rinne.events._ -import scala.collection.mutable +trait TableMixin extends AbstractSelectMixin with ItemClickNotifierMixin { + this: Table => -trait TableMixin extends Table with AbstractSelectMixin with ItemClickNotifier { + lazy val headerClickListeners = new ListenersSet[HeaderClickEvent, HeaderClickListener] { + override def listeners = getListeners(classOf[HeaderClickEvent]) - private val _columnGeneratorIds: mutable.Set[Any] = mutable.Set.empty[Any] + override protected def addListener(listener: ListenerLambda): Unit = addHeaderClickListener( + new HeaderClickListener { + override def headerClick(event: HeaderClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: HeaderClickListener): Unit = removeHeaderClickListener(listener) + } + lazy val footerClickListeners = new ListenersSet[FooterClickEvent, FooterClickListener] { + override def listeners = getListeners(classOf[FooterClickEvent]) + + override protected def addListener(listener: ListenerLambda): Unit = addFooterClickListener( + new FooterClickListener { + override def footerClick(event: FooterClickEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: FooterClickListener): Unit = removeFooterClickListener(listener) + } + lazy val columnResizeListeners = new ListenersSet[ColumnResizeEvent, ColumnResizeListener] { + override def listeners = getListeners(classOf[ColumnResizeEvent]) + + override protected def addListener(listener: ListenerLambda): Unit = addColumnResizeListener( + new ColumnResizeListener { + override def columnResize(event: ColumnResizeEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: ColumnResizeListener): Unit = removeColumnResizeListener(listener) + } + lazy val columnReorderListeners = new ListenersSet[ColumnReorderEvent, ColumnReorderListener] { + override def listeners = getListeners(classOf[ColumnResizeEvent]) + + override protected def addListener(listener: ListenerLambda): Unit = addColumnReorderListener( + new ColumnReorderListener { + override def columnReorder(event: ColumnReorderEvent): Unit = listener(event) + } + ) + + override protected def removeListener(listener: ColumnReorderListener): Unit = removeColumnReorderListener(listener) + } def visibleColumns: Seq[Any] = getVisibleColumns @@ -24,9 +67,10 @@ trait TableMixin extends Table with AbstractSelectMixin with ItemClickNotifier { def columnHeaders_=(columnHeaders: => Seq[String]): Unit = setColumnHeaders(columnHeaders: _*) - def columnHeaders_=(columnHeaders: Seq[Option[String]]): Unit = setColumnHeaders(columnHeaders map { - _.orNull - }: _*) + def columnHeaders_=(columnHeaders: Seq[Option[String]]): Unit = + setColumnHeaders(columnHeaders map { + _.orNull + }: _*) def columnIcons: Seq[Option[Resource]] = getColumnIcons.map(Option(_)).toSeq @@ -152,56 +196,4 @@ trait TableMixin extends Table with AbstractSelectMixin with ItemClickNotifier { def footerVisible_=(footerVisible: Boolean) { setFooterVisible(footerVisible) } - - lazy val headerClickListeners: ListenersSet[Table.HeaderClickEvent => Unit] = - new ListenersTrait[Table.HeaderClickEvent, HeaderClickListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Table.HeaderClickListener]) - - override def addListener(elem: Table.HeaderClickEvent => Unit) { - addHeaderClickListener(new HeaderClickListener(elem)) - } - - override def removeListener(elem: HeaderClickListener) { - removeHeaderClickListener(elem) - } - } - - lazy val footerClickListeners: ListenersSet[Table.FooterClickEvent => Unit] = - new ListenersTrait[Table.FooterClickEvent, FooterClickListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Table.FooterClickListener]) - - override def addListener(elem: Table.FooterClickEvent => Unit) { - addFooterClickListener(new FooterClickListener(elem)) - } - - override def removeListener(elem: FooterClickListener) { - removeFooterClickListener(elem) - } - } - - lazy val columnResizeListeners: ListenersSet[Table.ColumnResizeEvent => Unit] = - new ListenersTrait[Table.ColumnResizeEvent, ColumnResizeListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Table.ColumnReorderListener]) - - override def addListener(elem: Table.ColumnResizeEvent => Unit) { - addColumnResizeListener(new ColumnResizeListener(elem)) - } - - override def removeListener(elem: ColumnResizeListener) { - removeColumnResizeListener(elem) - } - } - - lazy val columnReorderListeners: ListenersSet[Table.ColumnReorderEvent => Unit] = - new ListenersTrait[Table.ColumnReorderEvent, ColumnReorderListener] { - override def listeners = getListeners(classOf[com.vaadin.ui.Table.ColumnReorderListener]) - - override def addListener(elem: Table.ColumnReorderEvent => Unit) { - addColumnReorderListener(new ColumnReorderListener(elem)) - } - - override def removeListener(elem: ColumnReorderListener) { - removeColumnReorderListener(elem) - } - } } diff --git a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/UploadFieldMixin.scala b/addon/src/main/scala/org/vaadin/addons/rinne/mixins/UploadFieldMixin.scala deleted file mode 100644 index 5b0a865..0000000 --- a/addon/src/main/scala/org/vaadin/addons/rinne/mixins/UploadFieldMixin.scala +++ /dev/null @@ -1,3 +0,0 @@ -package org.vaadin.addons.rinne.mixins - -trait UploadFieldMixin extends AbstractComponentMixin \ No newline at end of file