Skip to content

Commit

Permalink
#122 fixed SuperTextArea, #123 moved interfaces around
Browse files Browse the repository at this point in the history
  • Loading branch information
vaadin-miki committed Jun 4, 2020
1 parent 5173e80 commit 6377661
Show file tree
Hide file tree
Showing 17 changed files with 77 additions and 27 deletions.
8 changes: 4 additions & 4 deletions demo-v14/src/main/java/org/vaadin/miki/MainView.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.vaadin.miki.markers.HasLocale;
import org.vaadin.miki.superfields.dates.DatePattern;
import org.vaadin.miki.superfields.dates.DatePatterns;
import org.vaadin.miki.superfields.dates.HasDatePattern;
import org.vaadin.miki.markers.HasDatePattern;
import org.vaadin.miki.superfields.dates.SuperDatePicker;
import org.vaadin.miki.superfields.dates.SuperDateTimePicker;
import org.vaadin.miki.superfields.itemgrid.ItemGrid;
Expand All @@ -40,11 +40,11 @@
import org.vaadin.miki.superfields.tabs.SuperTabs;
import org.vaadin.miki.superfields.tabs.TabHandler;
import org.vaadin.miki.superfields.tabs.TabHandlers;
import org.vaadin.miki.superfields.text.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.superfields.text.CanSelectText;
import org.vaadin.miki.markers.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.superfields.text.SuperTextArea;
import org.vaadin.miki.superfields.text.SuperTextField;
import org.vaadin.miki.superfields.text.TextSelectionNotifier;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.superfields.unload.UnloadObserver;

import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.events.text;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEvent;
import org.vaadin.miki.markers.CanSelectText;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.events.text;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEventListener;
import org.vaadin.miki.markers.CanSelectText;

/**
* Marker interface for objects
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.events.text;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.shared.Registration;
import org.vaadin.miki.markers.CanSelectText;

/**
* Marker interface for objects that broadcast {@link TextSelectionEvent}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.markers;

import org.vaadin.miki.events.text.TextSelectionEvent;

/**
* Marker interface for objects capable of receiving text selection events from client-side code.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.markers;

import com.vaadin.flow.component.HasElement;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.vaadin.miki.superfields.dates;
package org.vaadin.miki.markers;

import org.vaadin.miki.superfields.dates.DatePattern;

/**
* Marker interface for objects that have a {@link DatePattern}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
package org.vaadin.miki.superfields.dates;
package org.vaadin.miki.markers;

import org.vaadin.miki.superfields.dates.DatePattern;

/**
* Mixin interface to allow chaining {@link #setDatePattern(DatePattern)}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.markers;

/**
* Marker interface for chaining {@link #setReceivingSelectionEventsFromClient(boolean)}.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.vaadin.miki.superfields.text;
package org.vaadin.miki.shared.text;

import com.vaadin.flow.component.Component;
import com.vaadin.flow.component.ComponentEventBus;
import org.vaadin.miki.markers.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.events.text.TextSelectionEvent;

import java.io.Serializable;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.Component;
import org.vaadin.miki.markers.HasDatePattern;

import java.io.Serializable;
import java.time.LocalDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,23 @@
import com.vaadin.flow.component.datepicker.DatePicker;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.shared.Registration;
import org.vaadin.miki.markers.HasDatePattern;
import org.vaadin.miki.markers.HasLabel;
import org.vaadin.miki.markers.HasLocale;
import org.vaadin.miki.markers.HasPlaceholder;
import org.vaadin.miki.markers.WithDatePatternMixin;
import org.vaadin.miki.markers.WithIdMixin;
import org.vaadin.miki.markers.WithLabelMixin;
import org.vaadin.miki.markers.WithLocaleMixin;
import org.vaadin.miki.markers.WithPlaceholderMixin;
import org.vaadin.miki.markers.WithValueMixin;
import org.vaadin.miki.superfields.text.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.superfields.text.CanSelectText;
import org.vaadin.miki.superfields.text.TextSelectionDelegate;
import org.vaadin.miki.superfields.text.TextSelectionEvent;
import org.vaadin.miki.superfields.text.TextSelectionListener;
import org.vaadin.miki.superfields.text.TextSelectionNotifier;
import org.vaadin.miki.superfields.text.WithReceivingSelectionEventsFromClientMixin;
import org.vaadin.miki.markers.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.shared.text.TextSelectionDelegate;
import org.vaadin.miki.events.text.TextSelectionEvent;
import org.vaadin.miki.events.text.TextSelectionListener;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.markers.WithReceivingSelectionEventsFromClientMixin;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import com.vaadin.flow.component.datetimepicker.DateTimePicker;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.timepicker.TimePicker;
import org.vaadin.miki.markers.HasDatePattern;
import org.vaadin.miki.markers.HasLabel;
import org.vaadin.miki.markers.HasLocale;
import org.vaadin.miki.markers.WithDatePatternMixin;
import org.vaadin.miki.markers.WithIdMixin;
import org.vaadin.miki.markers.WithLabelMixin;
import org.vaadin.miki.markers.WithLocaleMixin;
Expand All @@ -29,7 +31,7 @@
public class SuperDateTimePicker extends DateTimePicker
implements HasLocale, HasLabel, HasDatePattern,
WithLocaleMixin<SuperDateTimePicker>, WithLabelMixin<SuperDateTimePicker>,
WithDatePatternMixin<SuperDateTimePicker>, WithIdMixin<SuperDateTimePicker>,
WithDatePatternMixin<SuperDateTimePicker>, WithIdMixin<SuperDateTimePicker>,
WithValueMixin<AbstractField.ComponentValueChangeEvent<DateTimePicker, LocalDateTime>, LocalDateTime, SuperDateTimePicker> {

// so, this component is a composition of DatePicker and TimePicker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import org.vaadin.miki.markers.WithPlaceholderMixin;
import org.vaadin.miki.markers.WithTitleMixin;
import org.vaadin.miki.markers.WithValueMixin;
import org.vaadin.miki.superfields.text.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.superfields.text.CanSelectText;
import org.vaadin.miki.markers.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.superfields.text.SuperTextField;
import org.vaadin.miki.superfields.text.TextSelectionEvent;
import org.vaadin.miki.superfields.text.TextSelectionListener;
import org.vaadin.miki.superfields.text.TextSelectionNotifier;
import org.vaadin.miki.superfields.text.WithReceivingSelectionEventsFromClientMixin;
import org.vaadin.miki.events.text.TextSelectionEvent;
import org.vaadin.miki.events.text.TextSelectionListener;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.markers.WithReceivingSelectionEventsFromClientMixin;

import java.text.DecimalFormat;
import java.text.NumberFormat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
package org.vaadin.miki.superfields.text;

import com.vaadin.flow.component.AbstractField;
import com.vaadin.flow.component.AttachEvent;
import com.vaadin.flow.component.ClientCallable;
import com.vaadin.flow.component.DetachEvent;
import com.vaadin.flow.component.Tag;
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.shared.Registration;
import org.vaadin.miki.events.text.TextSelectionEvent;
import org.vaadin.miki.events.text.TextSelectionListener;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.markers.HasLabel;
import org.vaadin.miki.markers.HasPlaceholder;
import org.vaadin.miki.markers.WithIdMixin;
import org.vaadin.miki.markers.WithLabelMixin;
import org.vaadin.miki.markers.WithPlaceholderMixin;
import org.vaadin.miki.markers.WithReceivingSelectionEventsFromClientMixin;
import org.vaadin.miki.markers.WithValueMixin;
import org.vaadin.miki.shared.text.TextSelectionDelegate;

/**
* An extension of {@link TextArea} with some useful features.
Expand Down Expand Up @@ -57,6 +65,21 @@ public SuperTextArea(String label, String initialValue, ValueChangeListener<? su
super(label, initialValue, listener);
}

@Override
protected void onAttach(AttachEvent attachEvent) {
// sadly there are no mixin classes in java for protected methods
this.delegate.informClientAboutSendingEvents(this.isReceivingSelectionEventsFromClient());
super.onAttach(attachEvent);
}

@Override
protected void onDetach(DetachEvent detachEvent) {
// detaching means server should not be informed
if(this.isReceivingSelectionEventsFromClient())
this.delegate.informClientAboutSendingEvents(false);
super.onDetach(detachEvent);
}

@Override
public boolean isReceivingSelectionEventsFromClient() {
return this.receivingSelectionEventsFromClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
import com.vaadin.flow.component.dependency.JsModule;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.shared.Registration;
import org.vaadin.miki.events.text.TextSelectionEvent;
import org.vaadin.miki.events.text.TextSelectionListener;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.markers.HasLabel;
import org.vaadin.miki.markers.HasPlaceholder;
import org.vaadin.miki.markers.WithIdMixin;
import org.vaadin.miki.markers.WithLabelMixin;
import org.vaadin.miki.markers.WithPlaceholderMixin;
import org.vaadin.miki.markers.WithReceivingSelectionEventsFromClientMixin;
import org.vaadin.miki.markers.WithValueMixin;
import org.vaadin.miki.shared.text.TextSelectionDelegate;

/**
* An extension of {@link TextField} with some useful (hopefully) features.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.vaadin.miki.events.text.TextSelectionNotifier;
import org.vaadin.miki.markers.CanReceiveSelectionEventsFromClient;
import org.vaadin.miki.markers.CanSelectText;
import org.vaadin.miki.shared.text.TextSelectionDelegate;

abstract class AbstractTestForTextSelection<C extends Component & CanSelectText & HasValue<?, String> & CanReceiveSelectionEventsFromClient & TextSelectionNotifier<C>> {

Expand Down

0 comments on commit 6377661

Please sign in to comment.