Pārlūkot izejas kodu

Merge branch 'contrib'

tags/7.0.0.alpha2
Artur Signell pirms 12 gadiem
vecāks
revīzija
b6f2df4409
29 mainītis faili ar 1069 papildinājumiem un 798 dzēšanām
  1. 0
    6
      src/com/vaadin/terminal/gwt/client/ui/VButton.java
  2. 4
    0
      src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java
  3. 7
    89
      src/com/vaadin/terminal/gwt/client/ui/VDateField.java
  4. 2
    68
      src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java
  5. 101
    0
      src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendarPaintable.java
  6. 106
    0
      src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java
  7. 45
    245
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java
  8. 244
    0
      src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java
  9. 17
    86
      src/com/vaadin/terminal/gwt/client/ui/VLink.java
  10. 100
    0
      src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java
  11. 0
    5
      src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java
  12. 3
    0
      src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java
  13. 24
    0
      src/com/vaadin/terminal/gwt/client/ui/VPasswordFieldPaintable.java
  14. 8
    104
      src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java
  15. 138
    0
      src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java
  16. 0
    16
      src/com/vaadin/terminal/gwt/client/ui/VTextArea.java
  17. 38
    0
      src/com/vaadin/terminal/gwt/client/ui/VTextAreaPaintable.java
  18. 23
    119
      src/com/vaadin/terminal/gwt/client/ui/VTextField.java
  19. 124
    0
      src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java
  20. 11
    45
      src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java
  21. 58
    0
      src/com/vaadin/terminal/gwt/client/ui/VTextualDatePaintable.java
  22. 2
    1
      src/com/vaadin/ui/ComboBox.java
  23. 2
    2
      src/com/vaadin/ui/DateField.java
  24. 2
    2
      src/com/vaadin/ui/InlineDateField.java
  25. 2
    2
      src/com/vaadin/ui/Link.java
  26. 2
    2
      src/com/vaadin/ui/PasswordField.java
  27. 2
    2
      src/com/vaadin/ui/Select.java
  28. 2
    2
      src/com/vaadin/ui/TextArea.java
  29. 2
    2
      src/com/vaadin/ui/TextField.java

+ 0
- 6
src/com/vaadin/terminal/gwt/client/ui/VButton.java Parādīt failu

@@ -19,7 +19,6 @@ import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Accessibility;
import com.google.gwt.user.client.ui.FocusWidget;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId;
@@ -450,9 +449,4 @@ public class VButton extends FocusWidget implements ClickHandler, FocusHandler,
public void onBlur(BlurEvent arg0) {
client.updateVariable(paintableId, EventId.BLUR, "", true);
}

public Widget getWidgetForPaintable() {
return this;
}

}

+ 4
- 0
src/com/vaadin/terminal/gwt/client/ui/VButtonPaintable.java Parādīt failu

@@ -1,3 +1,7 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;

+ 7
- 89
src/com/vaadin/terminal/gwt/client/ui/VDateField.java Parādīt failu

@@ -8,22 +8,17 @@ import java.util.Date;

import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.VTooltip;

public class VDateField extends FlowPanel implements VPaintableWidget, Field {
public class VDateField extends FlowPanel implements Field {

public static final String CLASSNAME = "v-datefield";

private String id;
protected String paintableId;

private ApplicationConnection client;
protected ApplicationConnection client;

protected boolean immediate;

@@ -65,7 +60,7 @@ public class VDateField extends FlowPanel implements VPaintableWidget, Field {

protected DateTimeService dts;

private boolean showISOWeekNumbers = false;
protected boolean showISOWeekNumbers = false;

public VDateField() {
setStyleName(CLASSNAME);
@@ -77,80 +72,7 @@ public class VDateField extends FlowPanel implements VPaintableWidget, Field {
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (client != null) {
client.handleTooltipEvent(event, this);
}
}

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation and let layout manage caption
if (client.updateComponent(this, uidl, true)) {
return;
}

// Save details
this.client = client;
id = uidl.getId();
immediate = uidl.getBooleanAttribute("immediate");

readonly = uidl.getBooleanAttribute("readonly");
enabled = !uidl.getBooleanAttribute("disabled");

if (uidl.hasAttribute("locale")) {
final String locale = uidl.getStringAttribute("locale");
try {
dts.setLocale(locale);
currentLocale = locale;
} catch (final LocaleNotLoadedException e) {
currentLocale = dts.getLocale();
VConsole.error("Tried to use an unloaded locale \"" + locale
+ "\". Using default locale (" + currentLocale + ").");
VConsole.error(e);
}
}

// We show week numbers only if the week starts with Monday, as ISO 8601
// specifies
showISOWeekNumbers = uidl.getBooleanAttribute(WEEK_NUMBERS)
&& dts.getFirstDayOfWeek() == 1;

int newResolution;
if (uidl.hasVariable("sec")) {
newResolution = RESOLUTION_SEC;
} else if (uidl.hasVariable("min")) {
newResolution = RESOLUTION_MIN;
} else if (uidl.hasVariable("hour")) {
newResolution = RESOLUTION_HOUR;
} else if (uidl.hasVariable("day")) {
newResolution = RESOLUTION_DAY;
} else if (uidl.hasVariable("month")) {
newResolution = RESOLUTION_MONTH;
} else {
newResolution = RESOLUTION_YEAR;
}

currentResolution = newResolution;

// Add stylename that indicates current resolution
addStyleName(CLASSNAME + "-" + resolutionToString(currentResolution));

final int year = uidl.getIntVariable("year");
final int month = (currentResolution >= RESOLUTION_MONTH) ? uidl
.getIntVariable("month") : -1;
final int day = (currentResolution >= RESOLUTION_DAY) ? uidl
.getIntVariable("day") : -1;
final int hour = (currentResolution >= RESOLUTION_HOUR) ? uidl
.getIntVariable("hour") : 0;
final int min = (currentResolution >= RESOLUTION_MIN) ? uidl
.getIntVariable("min") : 0;
final int sec = (currentResolution >= RESOLUTION_SEC) ? uidl
.getIntVariable("sec") : 0;

// Construct new date for this datefield (only if not null)
if (year > -1) {
setCurrentDate(new Date((long) getTime(year, month, day, hour, min,
sec, 0)));
} else {
setCurrentDate(null);
client.handleWidgetTooltipEvent(event, this);
}
}

@@ -158,7 +80,7 @@ public class VDateField extends FlowPanel implements VPaintableWidget, Field {
* We need this redundant native function because Java's Date object doesn't
* have a setMilliseconds method.
*/
private static native double getTime(int y, int m, int d, int h, int mi,
protected static native double getTime(int y, int m, int d, int h, int mi,
int s, int ms)
/*-{
try {
@@ -227,7 +149,7 @@ public class VDateField extends FlowPanel implements VPaintableWidget, Field {
}

public String getId() {
return id;
return paintableId;
}

public ApplicationConnection getClient() {
@@ -270,8 +192,4 @@ public class VDateField extends FlowPanel implements VPaintableWidget, Field {
protected void setDate(Date date) {
this.date = date;
}

public Widget getWidgetForPaintable() {
return this;
}
}

+ 2
- 68
src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendar.java Parādīt failu

@@ -7,20 +7,16 @@ package com.vaadin.terminal.gwt.client.ui;
import java.util.Date;
import com.google.gwt.event.dom.client.DomEvent;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
/**
* A client side implementation for InlineDateField
*/
public class VDateFieldCalendar extends VDateField {
private final VCalendarPanel calendarPanel;
protected final VCalendarPanel calendarPanel;
public VDateFieldCalendar() {
super();
@@ -44,73 +40,11 @@ public class VDateFieldCalendar extends VDateField {
});
}
@Override
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
calendarPanel.setShowISOWeekNumbers(isShowISOWeekNumbers());
calendarPanel.setDateTimeService(getDateTimeService());
calendarPanel.setResolution(getCurrentResolution());
Date currentDate = getCurrentDate();
if (currentDate != null) {
calendarPanel.setDate(new Date(currentDate.getTime()));
} else {
calendarPanel.setDate(null);
}
if (currentResolution > RESOLUTION_DAY) {
calendarPanel.setTimeChangeListener(new TimeChangeListener() {
public void changed(int hour, int min, int sec, int msec) {
Date d = getDate();
if (d == null) {
// date currently null, use the value from calendarPanel
// (~ client time at the init of the widget)
d = (Date) calendarPanel.getDate().clone();
}
d.setHours(hour);
d.setMinutes(min);
d.setSeconds(sec);
DateTimeService.setMilliseconds(d, msec);
// Always update time changes to the server
calendarPanel.setDate(d);
updateValueFromPanel();
}
});
}
if (currentResolution <= RESOLUTION_MONTH) {
calendarPanel.setFocusChangeListener(new FocusChangeListener() {
public void focusChanged(Date date) {
Date date2 = new Date();
if (calendarPanel.getDate() != null) {
date2.setTime(calendarPanel.getDate().getTime());
}
/*
* Update the value of calendarPanel
*/
date2.setYear(date.getYear());
date2.setMonth(date.getMonth());
calendarPanel.setDate(date2);
/*
* Then update the value from panel to server
*/
updateValueFromPanel();
}
});
} else {
calendarPanel.setFocusChangeListener(null);
}
// Update possible changes
calendarPanel.renderCalendar();
}
/**
* TODO refactor: almost same method as in VPopupCalendar.updateValue
*/
@SuppressWarnings("deprecation")
private void updateValueFromPanel() {
protected void updateValueFromPanel() {
Date date2 = calendarPanel.getDate();
Date currentDate = getCurrentDate();
if (currentDate == null || date2.getTime() != currentDate.getTime()) {

+ 101
- 0
src/com/vaadin/terminal/gwt/client/ui/VDateFieldCalendarPaintable.java Parādīt failu

@@ -0,0 +1,101 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal.gwt.client.ui;

import java.util.Date;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;

public class VDateFieldCalendarPaintable extends VDateFieldPaintable {

@Override
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
getWidgetForPaintable().calendarPanel
.setShowISOWeekNumbers(getWidgetForPaintable()
.isShowISOWeekNumbers());
getWidgetForPaintable().calendarPanel
.setDateTimeService(getWidgetForPaintable()
.getDateTimeService());
getWidgetForPaintable().calendarPanel
.setResolution(getWidgetForPaintable().getCurrentResolution());
Date currentDate = getWidgetForPaintable().getCurrentDate();
if (currentDate != null) {
getWidgetForPaintable().calendarPanel.setDate(new Date(currentDate
.getTime()));
} else {
getWidgetForPaintable().calendarPanel.setDate(null);
}

if (getWidgetForPaintable().currentResolution > VDateField.RESOLUTION_DAY) {
getWidgetForPaintable().calendarPanel
.setTimeChangeListener(new TimeChangeListener() {
public void changed(int hour, int min, int sec, int msec) {
Date d = getWidgetForPaintable().getDate();
if (d == null) {
// date currently null, use the value from
// calendarPanel
// (~ client time at the init of the widget)
d = (Date) getWidgetForPaintable().calendarPanel
.getDate().clone();
}
d.setHours(hour);
d.setMinutes(min);
d.setSeconds(sec);
DateTimeService.setMilliseconds(d, msec);

// Always update time changes to the server
getWidgetForPaintable().calendarPanel.setDate(d);
getWidgetForPaintable().updateValueFromPanel();
}
});
}

if (getWidgetForPaintable().currentResolution <= VDateField.RESOLUTION_MONTH) {
getWidgetForPaintable().calendarPanel
.setFocusChangeListener(new FocusChangeListener() {
public void focusChanged(Date date) {
Date date2 = new Date();
if (getWidgetForPaintable().calendarPanel.getDate() != null) {
date2.setTime(getWidgetForPaintable().calendarPanel
.getDate().getTime());
}
/*
* Update the value of calendarPanel
*/
date2.setYear(date.getYear());
date2.setMonth(date.getMonth());
getWidgetForPaintable().calendarPanel
.setDate(date2);
/*
* Then update the value from panel to server
*/
getWidgetForPaintable().updateValueFromPanel();
}
});
} else {
getWidgetForPaintable().calendarPanel.setFocusChangeListener(null);
}

// Update possible changes
getWidgetForPaintable().calendarPanel.renderCalendar();
}

@Override
protected Widget createWidget() {
return GWT.create(VDateFieldCalendar.class);
}

@Override
public VDateFieldCalendar getWidgetForPaintable() {
return (VDateFieldCalendar) super.getWidgetForPaintable();
}
}

+ 106
- 0
src/com/vaadin/terminal/gwt/client/ui/VDateFieldPaintable.java Parādīt failu

@@ -0,0 +1,106 @@
package com.vaadin.terminal.gwt.client.ui;

import java.util.Date;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;

public class VDateFieldPaintable extends VAbstractPaintableWidget {

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Ensure correct implementation and let layout manage caption
if (client.updateComponent(this, uidl, true)) {
return;
}

// Save details
getWidgetForPaintable().client = client;
getWidgetForPaintable().paintableId = uidl.getId();
getWidgetForPaintable().immediate = uidl
.getBooleanAttribute("immediate");

getWidgetForPaintable().readonly = uidl.getBooleanAttribute("readonly");
getWidgetForPaintable().enabled = !uidl.getBooleanAttribute("disabled");

if (uidl.hasAttribute("locale")) {
final String locale = uidl.getStringAttribute("locale");
try {
getWidgetForPaintable().dts.setLocale(locale);
getWidgetForPaintable().currentLocale = locale;
} catch (final LocaleNotLoadedException e) {
getWidgetForPaintable().currentLocale = getWidgetForPaintable().dts
.getLocale();
VConsole.error("Tried to use an unloaded locale \"" + locale
+ "\". Using default locale ("
+ getWidgetForPaintable().currentLocale + ").");
VConsole.error(e);
}
}

// We show week numbers only if the week starts with Monday, as ISO 8601
// specifies
getWidgetForPaintable().showISOWeekNumbers = uidl
.getBooleanAttribute(VDateField.WEEK_NUMBERS)
&& getWidgetForPaintable().dts.getFirstDayOfWeek() == 1;

int newResolution;
if (uidl.hasVariable("sec")) {
newResolution = VDateField.RESOLUTION_SEC;
} else if (uidl.hasVariable("min")) {
newResolution = VDateField.RESOLUTION_MIN;
} else if (uidl.hasVariable("hour")) {
newResolution = VDateField.RESOLUTION_HOUR;
} else if (uidl.hasVariable("day")) {
newResolution = VDateField.RESOLUTION_DAY;
} else if (uidl.hasVariable("month")) {
newResolution = VDateField.RESOLUTION_MONTH;
} else {
newResolution = VDateField.RESOLUTION_YEAR;
}

getWidgetForPaintable().currentResolution = newResolution;

// Add stylename that indicates current resolution
getWidgetForPaintable()
.addStyleName(
VDateField.CLASSNAME
+ "-"
+ VDateField
.resolutionToString(getWidgetForPaintable().currentResolution));

final int year = uidl.getIntVariable("year");
final int month = (getWidgetForPaintable().currentResolution >= VDateField.RESOLUTION_MONTH) ? uidl
.getIntVariable("month") : -1;
final int day = (getWidgetForPaintable().currentResolution >= VDateField.RESOLUTION_DAY) ? uidl
.getIntVariable("day") : -1;
final int hour = (getWidgetForPaintable().currentResolution >= VDateField.RESOLUTION_HOUR) ? uidl
.getIntVariable("hour") : 0;
final int min = (getWidgetForPaintable().currentResolution >= VDateField.RESOLUTION_MIN) ? uidl
.getIntVariable("min") : 0;
final int sec = (getWidgetForPaintable().currentResolution >= VDateField.RESOLUTION_SEC) ? uidl
.getIntVariable("sec") : 0;

// Construct new date for this datefield (only if not null)
if (year > -1) {
getWidgetForPaintable().setCurrentDate(
new Date((long) getWidgetForPaintable().getTime(year,
month, day, hour, min, sec, 0)));
} else {
getWidgetForPaintable().setCurrentDate(null);
}
}

@Override
protected Widget createWidget() {
return GWT.create(VDateField.class);
}

@Override
public VDateField getWidgetForPaintable() {
return (VDateField) super.getWidgetForPaintable();
}
}

+ 45
- 245
src/com/vaadin/terminal/gwt/client/ui/VFilterSelect.java Parādīt failu

@@ -42,12 +42,10 @@ import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
@@ -59,9 +57,8 @@ import com.vaadin.terminal.gwt.client.VTooltip;
* TODO needs major refactoring (to be extensible etc)
*/
@SuppressWarnings("deprecation")
public class VFilterSelect extends Composite implements VPaintableWidget, Field,
KeyDownHandler, KeyUpHandler, ClickHandler, FocusHandler, BlurHandler,
Focusable {
public class VFilterSelect extends Composite implements Field, KeyDownHandler,
KeyUpHandler, ClickHandler, FocusHandler, BlurHandler, Focusable {

/**
* Represents a suggestion in the suggestion popup box
@@ -153,7 +150,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,

private static final String Z_INDEX = "30000";

private final SuggestionMenu menu;
protected final SuggestionMenu menu;

private final Element up = DOM.createDiv();
private final Element down = DOM.createDiv();
@@ -776,7 +773,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
return keyboardSelectedItem;
}

private void setKeyboardSelectedItem(MenuItem firstItem) {
protected void setKeyboardSelectedItem(MenuItem firstItem) {
keyboardSelectedItem = firstItem;
}

@@ -803,7 +800,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
/**
* The text box where the filter is written
*/
private final TextBox tb = new TextBox() {
protected final TextBox tb = new TextBox() {
/*
* (non-Javadoc)
*
@@ -815,7 +812,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (client != null) {
client.handleTooltipEvent(event, VFilterSelect.this);
client.handleWidgetTooltipEvent(event, VFilterSelect.this);
}
}

@@ -830,7 +827,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
};
};

private final SuggestionPopup suggestionPopup = new SuggestionPopup();
protected final SuggestionPopup suggestionPopup = new SuggestionPopup();

/**
* Used when measuring the width of the popup
@@ -848,7 +845,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (client != null) {
client.handleTooltipEvent(event, VFilterSelect.this);
client.handleWidgetTooltipEvent(event, VFilterSelect.this);
}

/*
@@ -861,73 +858,73 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,

private final Image selectedItemIcon = new Image();

private ApplicationConnection client;
protected ApplicationConnection client;

private String paintableId;
protected String paintableId;

private int currentPage;
protected int currentPage;

/**
* A collection of available suggestions (options) as received from the
* server.
*/
private final List<FilterSelectSuggestion> currentSuggestions = new ArrayList<FilterSelectSuggestion>();
protected final List<FilterSelectSuggestion> currentSuggestions = new ArrayList<FilterSelectSuggestion>();

private boolean immediate;
protected boolean immediate;

private String selectedOptionKey;
protected String selectedOptionKey;

private boolean waitingForFilteringResponse = false;
private boolean updateSelectionWhenReponseIsReceived = false;
protected boolean waitingForFilteringResponse = false;
protected boolean updateSelectionWhenReponseIsReceived = false;
private boolean tabPressedWhenPopupOpen = false;
private boolean initDone = false;
protected boolean initDone = false;

private String lastFilter = "";
protected String lastFilter = "";

private enum Select {
protected enum Select {
NONE, FIRST, LAST
};

private Select selectPopupItemWhenResponseIsReceived = Select.NONE;
protected Select selectPopupItemWhenResponseIsReceived = Select.NONE;

/**
* The current suggestion selected from the dropdown. This is one of the
* values in currentSuggestions except when filtering, in this case
* currentSuggestion might not be in currentSuggestions.
*/
private FilterSelectSuggestion currentSuggestion;
protected FilterSelectSuggestion currentSuggestion;

private int totalMatches;
private boolean allowNewItem;
private boolean nullSelectionAllowed;
private boolean nullSelectItem;
private boolean enabled;
private boolean readonly;
protected int totalMatches;
protected boolean allowNewItem;
protected boolean nullSelectionAllowed;
protected boolean nullSelectItem;
protected boolean enabled;
protected boolean readonly;

private int filteringmode = FILTERINGMODE_OFF;
protected int filteringmode = FILTERINGMODE_OFF;

// shown in unfocused empty field, disappears on focus (e.g "Search here")
private static final String CLASSNAME_PROMPT = "prompt";
private static final String ATTR_INPUTPROMPT = "prompt";
protected static final String ATTR_INPUTPROMPT = "prompt";
public static final String ATTR_NO_TEXT_INPUT = "noInput";
private String inputPrompt = "";
private boolean prompting = false;
protected String inputPrompt = "";
protected boolean prompting = false;

// Set true when popupopened has been clicked. Cleared on each UIDL-update.
// This handles the special case where are not filtering yet and the
// selected value has changed on the server-side. See #2119
private boolean popupOpenerClicked;
protected boolean popupOpenerClicked;
private String width = null;
private int textboxPadding = -1;
private int componentPadding = -1;
private int suggestionPopupMinWidth = 0;
protected int suggestionPopupMinWidth = 0;
private int popupWidth = -1;
/*
* Stores the last new item string to avoid double submissions. Cleared on
* uidl updates
*/
private String lastNewItemString;
private boolean focused = false;
protected String lastNewItemString;
protected boolean focused = false;
private int horizPaddingAndBorder = 2;

/**
@@ -1030,204 +1027,11 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
currentPage = page;
}

/*
* (non-Javadoc)
*
* @see
* com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal
* .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
*/
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
paintableId = uidl.getId();
this.client = client;

readonly = uidl.hasAttribute("readonly");
enabled = !uidl.hasAttribute("disabled");

tb.setEnabled(enabled);
updateReadOnly();

if (client.updateComponent(this, uidl, true)) {
return;
}

// Inverse logic here to make the default case (text input enabled)
// work without additional UIDL messages
boolean noTextInput = uidl.hasAttribute(ATTR_NO_TEXT_INPUT)
&& uidl.getBooleanAttribute(ATTR_NO_TEXT_INPUT);
setTextInputEnabled(!noTextInput);

// not a FocusWidget -> needs own tabindex handling
if (uidl.hasAttribute("tabindex")) {
tb.setTabIndex(uidl.getIntAttribute("tabindex"));
}

if (uidl.hasAttribute("filteringmode")) {
filteringmode = uidl.getIntAttribute("filteringmode");
}

immediate = uidl.hasAttribute("immediate");

nullSelectionAllowed = uidl.hasAttribute("nullselect");

nullSelectItem = uidl.hasAttribute("nullselectitem")
&& uidl.getBooleanAttribute("nullselectitem");

currentPage = uidl.getIntVariable("page");

if (uidl.hasAttribute("pagelength")) {
pageLength = uidl.getIntAttribute("pagelength");
}

if (uidl.hasAttribute(ATTR_INPUTPROMPT)) {
// input prompt changed from server
inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT);
} else {
inputPrompt = "";
}

suggestionPopup.updateStyleNames(uidl);

allowNewItem = uidl.hasAttribute("allownewitem");
lastNewItemString = null;

currentSuggestions.clear();
if (!waitingForFilteringResponse) {
/*
* Clear the current suggestions as the server response always
* includes the new ones. Exception is when filtering, then we need
* to retain the value if the user does not select any of the
* options matching the filter.
*/
currentSuggestion = null;
/*
* Also ensure no old items in menu. Unless cleared the old values
* may cause odd effects on blur events. Suggestions in menu might
* not necessary exist in select at all anymore.
*/
suggestionPopup.menu.clearItems();

}

final UIDL options = uidl.getChildUIDL(0);
if (uidl.hasAttribute("totalMatches")) {
totalMatches = uidl.getIntAttribute("totalMatches");
} else {
totalMatches = 0;
}

// used only to calculate minimum popup width
String captions = Util.escapeHTML(inputPrompt);

for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) {
final UIDL optionUidl = (UIDL) i.next();
final FilterSelectSuggestion suggestion = new FilterSelectSuggestion(
optionUidl);
currentSuggestions.add(suggestion);
if (optionUidl.hasAttribute("selected")) {
if (!waitingForFilteringResponse || popupOpenerClicked) {
String newSelectedOptionKey = Integer.toString(suggestion
.getOptionKey());
if (!newSelectedOptionKey.equals(selectedOptionKey)
|| suggestion.getReplacementString().equals(
tb.getText())) {
// Update text field if we've got a new selection
// Also update if we've got the same text to retain old
// text selection behavior
setPromptingOff(suggestion.getReplacementString());
selectedOptionKey = newSelectedOptionKey;
}
}
currentSuggestion = suggestion;
setSelectedItemIcon(suggestion.getIconUri());
}

// Collect captions so we can calculate minimum width for textarea
if (captions.length() > 0) {
captions += "|";
}
captions += Util.escapeHTML(suggestion.getReplacementString());
}

if ((!waitingForFilteringResponse || popupOpenerClicked)
&& uidl.hasVariable("selected")
&& uidl.getStringArrayVariable("selected").length == 0) {
// select nulled
if (!waitingForFilteringResponse || !popupOpenerClicked) {
if (!focused) {
/*
* client.updateComponent overwrites all styles so we must
* ALWAYS set the prompting style at this point, even though
* we think it has been set already...
*/
prompting = false;
setPromptingOn();
} else {
// we have focus in field, prompting can't be set on,
// instead just clear the input
tb.setValue("");
}
}
selectedOptionKey = null;
}

if (waitingForFilteringResponse
&& lastFilter.toLowerCase().equals(
uidl.getStringVariable("filter"))) {
suggestionPopup.showSuggestions(currentSuggestions, currentPage,
totalMatches);
waitingForFilteringResponse = false;
if (!popupOpenerClicked
&& selectPopupItemWhenResponseIsReceived != Select.NONE) {
// we're paging w/ arrows
if (selectPopupItemWhenResponseIsReceived == Select.LAST) {
suggestionPopup.menu.selectLastItem();
} else {
suggestionPopup.menu.selectFirstItem();
}

// This is used for paging so we update the keyboard selection
// variable as well.
MenuItem activeMenuItem = suggestionPopup.menu
.getSelectedItem();
suggestionPopup.menu.setKeyboardSelectedItem(activeMenuItem);

// Update text field to contain the correct text
setTextboxText(activeMenuItem.getText());
tb.setSelectionRange(lastFilter.length(), activeMenuItem
.getText().length() - lastFilter.length());

selectPopupItemWhenResponseIsReceived = Select.NONE; // reset
}
if (updateSelectionWhenReponseIsReceived) {
suggestionPopup.menu.doPostFilterSelectedItemAction();
}
}

// Calculate minumum textarea width
suggestionPopupMinWidth = minWidth(captions);

popupOpenerClicked = false;

if (!initDone) {
updateRootWidth();
}

// Focus dependent style names are lost during the update, so we add
// them here back again
if (focused) {
addStyleDependentName("focus");
}

initDone = true;
}

private void updateReadOnly() {
protected void updateReadOnly() {
tb.setReadOnly(readonly || !textInputEnabled);
}

private void setTextInputEnabled(boolean textInputEnabled) {
protected void setTextInputEnabled(boolean textInputEnabled) {
// Always update styles as they might have been overwritten
if (textInputEnabled) {
removeStyleDependentName(STYLE_NO_INPUT);
@@ -1249,7 +1053,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
* @param text
* the text to set in the text box
*/
private void setTextboxText(final String text) {
protected void setTextboxText(final String text) {
tb.setText(text);
}

@@ -1273,7 +1077,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
* Turns prompting on. When prompting is turned on a command prompt is shown
* in the text box if nothing has been entered.
*/
private void setPromptingOn() {
protected void setPromptingOn() {
if (!prompting) {
prompting = true;
addStyleDependentName(CLASSNAME_PROMPT);
@@ -1288,7 +1092,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
* @param text
* The text the text box should contain.
*/
private void setPromptingOff(String text) {
protected void setPromptingOff(String text) {
setTextboxText(text);
if (prompting) {
prompting = false;
@@ -1338,7 +1142,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
* @param iconUri
* The URI of the icon
*/
private void setSelectedItemIcon(String iconUri) {
protected void setSelectedItemIcon(String iconUri) {
if (iconUri == null || iconUri == "") {
panel.remove(selectedItemIcon);
updateRootWidth();
@@ -1613,7 +1417,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
/**
* Calculate minimum width for FilterSelect textarea
*/
private native int minWidth(String captions)
protected native int minWidth(String captions)
/*-{
if(!captions || captions.length <= 0)
return 0;
@@ -1665,7 +1469,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
}
addStyleDependentName("focus");

if (client.hasEventListeners(this, EventId.FOCUS)) {
if (client.hasWidgetEventListeners(this, EventId.FOCUS)) {
client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
}
@@ -1730,7 +1534,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
}
removeStyleDependentName("focus");

if (client.hasEventListeners(this, EventId.BLUR)) {
if (client.hasWidgetEventListeners(this, EventId.BLUR)) {
client.updateVariable(paintableId, EventId.BLUR, "", true);
}
}
@@ -1784,7 +1588,7 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
* Calculates the width of the select if the select has undefined width.
* Should be called when the width changes or when the icon changes.
*/
private void updateRootWidth() {
protected void updateRootWidth() {
if (width == null) {
/*
* When the width is not specified we must specify width for root
@@ -1934,8 +1738,4 @@ public class VFilterSelect extends Composite implements VPaintableWidget, Field,
super.onDetach();
suggestionPopup.hide();
}

public Widget getWidgetForPaintable() {
return this;
}
}

+ 244
- 0
src/com/vaadin/terminal/gwt/client/ui/VFilterSelectPaintable.java Parādīt failu

@@ -0,0 +1,244 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal.gwt.client.ui;

import java.util.Iterator;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.ui.VFilterSelect.FilterSelectSuggestion;

public class VFilterSelectPaintable extends VAbstractPaintableWidget {

/*
* (non-Javadoc)
*
* @see
* com.vaadin.terminal.gwt.client.Paintable#updateFromUIDL(com.vaadin.terminal
* .gwt.client.UIDL, com.vaadin.terminal.gwt.client.ApplicationConnection)
*/
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Save details
getWidgetForPaintable().client = client;
getWidgetForPaintable().paintableId = uidl.getId();

getWidgetForPaintable().readonly = uidl.hasAttribute("readonly");
getWidgetForPaintable().enabled = !uidl.hasAttribute("disabled");

getWidgetForPaintable().tb.setEnabled(getWidgetForPaintable().enabled);
getWidgetForPaintable().updateReadOnly();

if (client.updateComponent(this, uidl, true)) {
return;
}

// Inverse logic here to make the default case (text input enabled)
// work without additional UIDL messages
boolean noTextInput = uidl
.hasAttribute(VFilterSelect.ATTR_NO_TEXT_INPUT)
&& uidl.getBooleanAttribute(VFilterSelect.ATTR_NO_TEXT_INPUT);
getWidgetForPaintable().setTextInputEnabled(!noTextInput);

// not a FocusWidget -> needs own tabindex handling
if (uidl.hasAttribute("tabindex")) {
getWidgetForPaintable().tb.setTabIndex(uidl
.getIntAttribute("tabindex"));
}

if (uidl.hasAttribute("filteringmode")) {
getWidgetForPaintable().filteringmode = uidl
.getIntAttribute("filteringmode");
}

getWidgetForPaintable().immediate = uidl.hasAttribute("immediate");

getWidgetForPaintable().nullSelectionAllowed = uidl
.hasAttribute("nullselect");

getWidgetForPaintable().nullSelectItem = uidl
.hasAttribute("nullselectitem")
&& uidl.getBooleanAttribute("nullselectitem");

getWidgetForPaintable().currentPage = uidl.getIntVariable("page");

if (uidl.hasAttribute("pagelength")) {
getWidgetForPaintable().pageLength = uidl
.getIntAttribute("pagelength");
}

if (uidl.hasAttribute(VFilterSelect.ATTR_INPUTPROMPT)) {
// input prompt changed from server
getWidgetForPaintable().inputPrompt = uidl
.getStringAttribute(VFilterSelect.ATTR_INPUTPROMPT);
} else {
getWidgetForPaintable().inputPrompt = "";
}

getWidgetForPaintable().suggestionPopup.updateStyleNames(uidl);

getWidgetForPaintable().allowNewItem = uidl
.hasAttribute("allownewitem");
getWidgetForPaintable().lastNewItemString = null;

getWidgetForPaintable().currentSuggestions.clear();
if (!getWidgetForPaintable().waitingForFilteringResponse) {
/*
* Clear the current suggestions as the server response always
* includes the new ones. Exception is when filtering, then we need
* to retain the value if the user does not select any of the
* options matching the filter.
*/
getWidgetForPaintable().currentSuggestion = null;
/*
* Also ensure no old items in menu. Unless cleared the old values
* may cause odd effects on blur events. Suggestions in menu might
* not necessary exist in select at all anymore.
*/
getWidgetForPaintable().suggestionPopup.menu.clearItems();

}

final UIDL options = uidl.getChildUIDL(0);
if (uidl.hasAttribute("totalMatches")) {
getWidgetForPaintable().totalMatches = uidl
.getIntAttribute("totalMatches");
} else {
getWidgetForPaintable().totalMatches = 0;
}

// used only to calculate minimum popup width
String captions = Util.escapeHTML(getWidgetForPaintable().inputPrompt);

for (final Iterator<?> i = options.getChildIterator(); i.hasNext();) {
final UIDL optionUidl = (UIDL) i.next();
final FilterSelectSuggestion suggestion = getWidgetForPaintable().new FilterSelectSuggestion(
optionUidl);
getWidgetForPaintable().currentSuggestions.add(suggestion);
if (optionUidl.hasAttribute("selected")) {
if (!getWidgetForPaintable().waitingForFilteringResponse
|| getWidgetForPaintable().popupOpenerClicked) {
String newSelectedOptionKey = Integer.toString(suggestion
.getOptionKey());
if (!newSelectedOptionKey
.equals(getWidgetForPaintable().selectedOptionKey)
|| suggestion.getReplacementString().equals(
getWidgetForPaintable().tb.getText())) {
// Update text field if we've got a new selection
// Also update if we've got the same text to retain old
// text selection behavior
getWidgetForPaintable().setPromptingOff(
suggestion.getReplacementString());
getWidgetForPaintable().selectedOptionKey = newSelectedOptionKey;
}
}
getWidgetForPaintable().currentSuggestion = suggestion;
getWidgetForPaintable().setSelectedItemIcon(
suggestion.getIconUri());
}

// Collect captions so we can calculate minimum width for textarea
if (captions.length() > 0) {
captions += "|";
}
captions += Util.escapeHTML(suggestion.getReplacementString());
}

if ((!getWidgetForPaintable().waitingForFilteringResponse || getWidgetForPaintable().popupOpenerClicked)
&& uidl.hasVariable("selected")
&& uidl.getStringArrayVariable("selected").length == 0) {
// select nulled
if (!getWidgetForPaintable().waitingForFilteringResponse
|| !getWidgetForPaintable().popupOpenerClicked) {
if (!getWidgetForPaintable().focused) {
/*
* client.updateComponent overwrites all styles so we must
* ALWAYS set the prompting style at this point, even though
* we think it has been set already...
*/
getWidgetForPaintable().prompting = false;
getWidgetForPaintable().setPromptingOn();
} else {
// we have focus in field, prompting can't be set on,
// instead just clear the input
getWidgetForPaintable().tb.setValue("");
}
}
getWidgetForPaintable().selectedOptionKey = null;
}

if (getWidgetForPaintable().waitingForFilteringResponse
&& getWidgetForPaintable().lastFilter.toLowerCase().equals(
uidl.getStringVariable("filter"))) {
getWidgetForPaintable().suggestionPopup.showSuggestions(
getWidgetForPaintable().currentSuggestions,
getWidgetForPaintable().currentPage,
getWidgetForPaintable().totalMatches);
getWidgetForPaintable().waitingForFilteringResponse = false;
if (!getWidgetForPaintable().popupOpenerClicked
&& getWidgetForPaintable().selectPopupItemWhenResponseIsReceived != VFilterSelect.Select.NONE) {
// we're paging w/ arrows
if (getWidgetForPaintable().selectPopupItemWhenResponseIsReceived == VFilterSelect.Select.LAST) {
getWidgetForPaintable().suggestionPopup.menu
.selectLastItem();
} else {
getWidgetForPaintable().suggestionPopup.menu
.selectFirstItem();
}

// This is used for paging so we update the keyboard selection
// variable as well.
MenuItem activeMenuItem = getWidgetForPaintable().suggestionPopup.menu
.getSelectedItem();
getWidgetForPaintable().suggestionPopup.menu
.setKeyboardSelectedItem(activeMenuItem);

// Update text field to contain the correct text
getWidgetForPaintable()
.setTextboxText(activeMenuItem.getText());
getWidgetForPaintable().tb.setSelectionRange(
getWidgetForPaintable().lastFilter.length(),
activeMenuItem.getText().length()
- getWidgetForPaintable().lastFilter.length());

getWidgetForPaintable().selectPopupItemWhenResponseIsReceived = VFilterSelect.Select.NONE; // reset
}
if (getWidgetForPaintable().updateSelectionWhenReponseIsReceived) {
getWidgetForPaintable().suggestionPopup.menu
.doPostFilterSelectedItemAction();
}
}

// Calculate minumum textarea width
getWidgetForPaintable().suggestionPopupMinWidth = getWidgetForPaintable()
.minWidth(captions);

getWidgetForPaintable().popupOpenerClicked = false;

if (!getWidgetForPaintable().initDone) {
getWidgetForPaintable().updateRootWidth();
}

// Focus dependent style names are lost during the update, so we add
// them here back again
if (getWidgetForPaintable().focused) {
getWidgetForPaintable().addStyleDependentName("focus");
}

getWidgetForPaintable().initDone = true;
}

@Override
protected Widget createWidget() {
return GWT.create(VFilterSelect.class);
}

@Override
public VFilterSelect getWidgetForPaintable() {
return (VFilterSelect) super.getWidgetForPaintable();
}
}

+ 17
- 86
src/com/vaadin/terminal/gwt/client/ui/VLink.java Parādīt failu

@@ -11,44 +11,41 @@ import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;

public class VLink extends HTML implements VPaintableWidget, ClickHandler {
public class VLink extends HTML implements ClickHandler {

public static final String CLASSNAME = "v-link";

private static final int BORDER_STYLE_DEFAULT = 0;
private static final int BORDER_STYLE_MINIMAL = 1;
private static final int BORDER_STYLE_NONE = 2;
protected static final int BORDER_STYLE_DEFAULT = 0;
protected static final int BORDER_STYLE_MINIMAL = 1;
protected static final int BORDER_STYLE_NONE = 2;

private String src;
protected String src;

private String target;
protected String target;

private int borderStyle = BORDER_STYLE_DEFAULT;
protected int borderStyle = BORDER_STYLE_DEFAULT;

private boolean enabled;
protected boolean enabled;

private boolean readonly;
protected boolean readonly;

private int targetWidth;
protected int targetWidth;

private int targetHeight;
protected int targetHeight;

private Element errorIndicatorElement;
protected Element errorIndicatorElement;

private final Element anchor = DOM.createAnchor();
protected final Element anchor = DOM.createAnchor();

private final Element captionElement = DOM.createSpan();
protected final Element captionElement = DOM.createSpan();

private Icon icon;
protected Icon icon;

private ApplicationConnection client;
protected ApplicationConnection client;

public VLink() {
super();
@@ -59,68 +56,6 @@ public class VLink extends HTML implements VPaintableWidget, ClickHandler {
setStyleName(CLASSNAME);
}

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

// Ensure correct implementation,
// but don't let container manage caption etc.
if (client.updateComponent(this, uidl, false)) {
return;
}

this.client = client;

enabled = uidl.hasAttribute("disabled") ? false : true;
readonly = uidl.hasAttribute("readonly") ? true : false;

if (uidl.hasAttribute("name")) {
target = uidl.getStringAttribute("name");
anchor.setAttribute("target", target);
}
if (uidl.hasAttribute("src")) {
src = client.translateVaadinUri(uidl.getStringAttribute("src"));
anchor.setAttribute("href", src);
}

if (uidl.hasAttribute("border")) {
if ("none".equals(uidl.getStringAttribute("border"))) {
borderStyle = BORDER_STYLE_NONE;
} else {
borderStyle = BORDER_STYLE_MINIMAL;
}
} else {
borderStyle = BORDER_STYLE_DEFAULT;
}

targetHeight = uidl.hasAttribute("targetHeight") ? uidl
.getIntAttribute("targetHeight") : -1;
targetWidth = uidl.hasAttribute("targetWidth") ? uidl
.getIntAttribute("targetWidth") : -1;

// Set link caption
captionElement.setInnerText(uidl.getStringAttribute("caption"));

// handle error
if (uidl.hasAttribute("error")) {
if (errorIndicatorElement == null) {
errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(errorIndicatorElement, "className",
"v-errorindicator");
}
DOM.insertChild(getElement(), errorIndicatorElement, 0);
} else if (errorIndicatorElement != null) {
DOM.setStyleAttribute(errorIndicatorElement, "display", "none");
}

if (uidl.hasAttribute("icon")) {
if (icon == null) {
icon = new Icon(client);
anchor.insertBefore(icon.getElement(), captionElement);
}
icon.setUri(uidl.getStringAttribute("icon"));
}

}

public void onClick(ClickEvent event) {
if (enabled && !readonly) {
if (target == null) {
@@ -168,7 +103,7 @@ public class VLink extends HTML implements VPaintableWidget, ClickHandler {
Util.notifyParentOfSizeChange(this, true);
}
if (client != null) {
client.handleTooltipEvent(event, this);
client.handleWidgetTooltipEvent(event, this);
}
if (target == captionElement || target == anchor
|| (icon != null && target == icon.getElement())) {
@@ -180,8 +115,4 @@ public class VLink extends HTML implements VPaintableWidget, ClickHandler {

}

public Widget getWidgetForPaintable() {
return this;
}

}

+ 100
- 0
src/com/vaadin/terminal/gwt/client/ui/VLinkPaintable.java Parādīt failu

@@ -0,0 +1,100 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;

public class VLinkPaintable extends VAbstractPaintableWidget {

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {

// Ensure correct implementation,
// but don't let container manage caption etc.
if (client.updateComponent(this, uidl, false)) {
return;
}

getWidgetForPaintable().client = client;

getWidgetForPaintable().enabled = uidl.hasAttribute("disabled") ? false
: true;
getWidgetForPaintable().readonly = uidl.hasAttribute("readonly") ? true
: false;

if (uidl.hasAttribute("name")) {
getWidgetForPaintable().target = uidl.getStringAttribute("name");
getWidgetForPaintable().anchor.setAttribute("target",
getWidgetForPaintable().target);
}
if (uidl.hasAttribute("src")) {
getWidgetForPaintable().src = client.translateVaadinUri(uidl
.getStringAttribute("src"));
getWidgetForPaintable().anchor.setAttribute("href",
getWidgetForPaintable().src);
}

if (uidl.hasAttribute("border")) {
if ("none".equals(uidl.getStringAttribute("border"))) {
getWidgetForPaintable().borderStyle = VLink.BORDER_STYLE_NONE;
} else {
getWidgetForPaintable().borderStyle = VLink.BORDER_STYLE_MINIMAL;
}
} else {
getWidgetForPaintable().borderStyle = VLink.BORDER_STYLE_DEFAULT;
}

getWidgetForPaintable().targetHeight = uidl
.hasAttribute("targetHeight") ? uidl
.getIntAttribute("targetHeight") : -1;
getWidgetForPaintable().targetWidth = uidl.hasAttribute("targetWidth") ? uidl
.getIntAttribute("targetWidth") : -1;

// Set link caption
getWidgetForPaintable().captionElement.setInnerText(uidl
.getStringAttribute("caption"));

// handle error
if (uidl.hasAttribute("error")) {
if (getWidgetForPaintable().errorIndicatorElement == null) {
getWidgetForPaintable().errorIndicatorElement = DOM.createDiv();
DOM.setElementProperty(
getWidgetForPaintable().errorIndicatorElement,
"className", "v-errorindicator");
}
DOM.insertChild(getWidgetForPaintable().getElement(),
getWidgetForPaintable().errorIndicatorElement, 0);
} else if (getWidgetForPaintable().errorIndicatorElement != null) {
DOM.setStyleAttribute(
getWidgetForPaintable().errorIndicatorElement, "display",
"none");
}

if (uidl.hasAttribute("icon")) {
if (getWidgetForPaintable().icon == null) {
getWidgetForPaintable().icon = new Icon(client);
getWidgetForPaintable().anchor.insertBefore(
getWidgetForPaintable().icon.getElement(),
getWidgetForPaintable().captionElement);
}
getWidgetForPaintable().icon
.setUri(uidl.getStringAttribute("icon"));
}

}

@Override
protected Widget createWidget() {
return GWT.create(VLink.class);
}

@Override
public VLink getWidgetForPaintable() {
return (VLink) super.getWidgetForPaintable();
}
}

+ 0
- 5
src/com/vaadin/terminal/gwt/client/ui/VNativeButton.java Parādīt failu

@@ -15,7 +15,6 @@ import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId;
@@ -145,8 +144,4 @@ public class VNativeButton extends Button implements ClickHandler,
setStyleName(ApplicationConnection.DISABLED_CLASSNAME, !enabled);
}
}

public Widget getWidgetForPaintable() {
return this;
}
}

+ 3
- 0
src/com/vaadin/terminal/gwt/client/ui/VNativeButtonPaintable.java Parādīt failu

@@ -1,3 +1,6 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/
package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;

+ 24
- 0
src/com/vaadin/terminal/gwt/client/ui/VPasswordFieldPaintable.java Parādīt failu

@@ -0,0 +1,24 @@
package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;

public class VPasswordFieldPaintable extends VTextFieldPaintable {

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
super.updateFromUIDL(uidl, client);
}

@Override
protected Widget createWidget() {
return GWT.create(VPasswordField.class);
}

@Override
public VPasswordField getWidgetForPaintable() {
return (VPasswordField) super.getWidgetForPaintable();
}
}

+ 8
- 104
src/com/vaadin/terminal/gwt/client/ui/VPopupCalendar.java Parādīt failu

@@ -21,16 +21,10 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusOutListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.SubmitListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
/**
* Represents a date selection component with a text field and a popup date
@@ -42,19 +36,19 @@ import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;
* <code>setCalendarPanel(VCalendarPanel panel)</code> method.
*
*/
public class VPopupCalendar extends VTextualDate implements VPaintableWidget,
Field, ClickHandler, CloseHandler<PopupPanel>, SubPartAware {
public class VPopupCalendar extends VTextualDate implements Field,
ClickHandler, CloseHandler<PopupPanel>, SubPartAware {
private static final String POPUP_PRIMARY_STYLE_NAME = VDateField.CLASSNAME
protected static final String POPUP_PRIMARY_STYLE_NAME = VDateField.CLASSNAME
+ "-popup";
private final Button calendarToggle;
protected final Button calendarToggle;
private VCalendarPanel calendar;
protected VCalendarPanel calendar;
private final VOverlay popup;
protected final VOverlay popup;
private boolean open = false;
private boolean parsable = true;
protected boolean parsable = true;
public VPopupCalendar() {
super();
@@ -105,7 +99,7 @@ public class VPopupCalendar extends VTextualDate implements VPaintableWidget,
}
@SuppressWarnings("deprecation")
private void updateValue(Date newDate) {
protected void updateValue(Date newDate) {
Date currentDate = getCurrentDate();
if (currentDate == null || newDate.getTime() != currentDate.getTime()) {
setCurrentDate((Date) newDate.clone());
@@ -137,96 +131,6 @@ public class VPopupCalendar extends VTextualDate implements VPaintableWidget,
}
}
/*
* (non-Javadoc)
*
* @see
* com.vaadin.terminal.gwt.client.ui.VTextualDate#updateFromUIDL(com.vaadin
* .terminal.gwt.client.UIDL,
* com.vaadin.terminal.gwt.client.ApplicationConnection)
*/
@Override
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
boolean lastReadOnlyState = readonly;
boolean lastEnabledState = isEnabled();
parsable = uidl.getBooleanAttribute("parsable");
super.updateFromUIDL(uidl, client);
String popupStyleNames = ApplicationConnection.getStyleName(
POPUP_PRIMARY_STYLE_NAME, uidl, false);
popupStyleNames += " " + VDateField.CLASSNAME + "-"
+ resolutionToString(currentResolution);
popup.setStyleName(popupStyleNames);
calendar.setDateTimeService(getDateTimeService());
calendar.setShowISOWeekNumbers(isShowISOWeekNumbers());
if (calendar.getResolution() != currentResolution) {
calendar.setResolution(currentResolution);
if (calendar.getDate() != null) {
calendar.setDate((Date) getCurrentDate().clone());
// force re-render when changing resolution only
calendar.renderCalendar();
}
}
calendarToggle.setEnabled(enabled);
if (currentResolution <= RESOLUTION_MONTH) {
calendar.setFocusChangeListener(new FocusChangeListener() {
public void focusChanged(Date date) {
updateValue(date);
buildDate();
Date date2 = calendar.getDate();
date2.setYear(date.getYear());
date2.setMonth(date.getMonth());
}
});
} else {
calendar.setFocusChangeListener(null);
}
if (currentResolution > RESOLUTION_DAY) {
calendar.setTimeChangeListener(new TimeChangeListener() {
public void changed(int hour, int min, int sec, int msec) {
Date d = getDate();
if (d == null) {
// date currently null, use the value from calendarPanel
// (~ client time at the init of the widget)
d = (Date) calendar.getDate().clone();
}
d.setHours(hour);
d.setMinutes(min);
d.setSeconds(sec);
DateTimeService.setMilliseconds(d, msec);
// Always update time changes to the server
updateValue(d);
// Update text field
buildDate();
}
});
}
if (readonly) {
calendarToggle.addStyleName(CLASSNAME + "-button-readonly");
} else {
calendarToggle.removeStyleName(CLASSNAME + "-button-readonly");
}
if (lastReadOnlyState != readonly || lastEnabledState != isEnabled()) {
// Enabled or readonly state changed. Differences in theming might
// affect the width (for instance if the popup button is hidden) so
// we have to recalculate the width (IF the width of the field is
// fixed)
updateWidth();
}
calendarToggle.setEnabled(true);
}
/*
* (non-Javadoc)
*

+ 138
- 0
src/com/vaadin/terminal/gwt/client/ui/VPopupCalendarPaintable.java Parādīt failu

@@ -0,0 +1,138 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import java.util.Date;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.DateTimeService;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.TimeChangeListener;

public class VPopupCalendarPaintable extends VTextualDatePaintable {

/*
* (non-Javadoc)
*
* @see
* com.vaadin.terminal.gwt.client.ui.VTextualDate#updateFromUIDL(com.vaadin
* .terminal.gwt.client.UIDL,
* com.vaadin.terminal.gwt.client.ApplicationConnection)
*/
@Override
@SuppressWarnings("deprecation")
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
boolean lastReadOnlyState = getWidgetForPaintable().readonly;
boolean lastEnabledState = getWidgetForPaintable().isEnabled();

getWidgetForPaintable().parsable = uidl.getBooleanAttribute("parsable");

super.updateFromUIDL(uidl, client);

String popupStyleNames = ApplicationConnection.getStyleName(
VPopupCalendar.POPUP_PRIMARY_STYLE_NAME, uidl, false);
popupStyleNames += " "
+ VDateField.CLASSNAME
+ "-"
+ VPopupCalendar
.resolutionToString(getWidgetForPaintable().currentResolution);
getWidgetForPaintable().popup.setStyleName(popupStyleNames);

getWidgetForPaintable().calendar
.setDateTimeService(getWidgetForPaintable()
.getDateTimeService());
getWidgetForPaintable().calendar
.setShowISOWeekNumbers(getWidgetForPaintable()
.isShowISOWeekNumbers());
if (getWidgetForPaintable().calendar.getResolution() != getWidgetForPaintable().currentResolution) {
getWidgetForPaintable().calendar
.setResolution(getWidgetForPaintable().currentResolution);
if (getWidgetForPaintable().calendar.getDate() != null) {
getWidgetForPaintable().calendar
.setDate((Date) getWidgetForPaintable()
.getCurrentDate().clone());
// force re-render when changing resolution only
getWidgetForPaintable().calendar.renderCalendar();
}
}
getWidgetForPaintable().calendarToggle
.setEnabled(getWidgetForPaintable().enabled);

if (getWidgetForPaintable().currentResolution <= VPopupCalendar.RESOLUTION_MONTH) {
getWidgetForPaintable().calendar
.setFocusChangeListener(new FocusChangeListener() {
public void focusChanged(Date date) {
getWidgetForPaintable().updateValue(date);
getWidgetForPaintable().buildDate();
Date date2 = getWidgetForPaintable().calendar
.getDate();
date2.setYear(date.getYear());
date2.setMonth(date.getMonth());
}
});
} else {
getWidgetForPaintable().calendar.setFocusChangeListener(null);
}

if (getWidgetForPaintable().currentResolution > VPopupCalendar.RESOLUTION_DAY) {
getWidgetForPaintable().calendar
.setTimeChangeListener(new TimeChangeListener() {
public void changed(int hour, int min, int sec, int msec) {
Date d = getWidgetForPaintable().getDate();
if (d == null) {
// date currently null, use the value from
// calendarPanel
// (~ client time at the init of the widget)
d = (Date) getWidgetForPaintable().calendar
.getDate().clone();
}
d.setHours(hour);
d.setMinutes(min);
d.setSeconds(sec);
DateTimeService.setMilliseconds(d, msec);

// Always update time changes to the server
getWidgetForPaintable().updateValue(d);

// Update text field
getWidgetForPaintable().buildDate();
}
});
}

if (getWidgetForPaintable().readonly) {
getWidgetForPaintable().calendarToggle
.addStyleName(VPopupCalendar.CLASSNAME + "-button-readonly");
} else {
getWidgetForPaintable().calendarToggle
.removeStyleName(VPopupCalendar.CLASSNAME
+ "-button-readonly");
}

if (lastReadOnlyState != getWidgetForPaintable().readonly
|| lastEnabledState != getWidgetForPaintable().isEnabled()) {
// Enabled or readonly state changed. Differences in theming might
// affect the width (for instance if the popup button is hidden) so
// we have to recalculate the width (IF the width of the field is
// fixed)
getWidgetForPaintable().updateWidth();
}

getWidgetForPaintable().calendarToggle.setEnabled(true);
}

@Override
protected Widget createWidget() {
return GWT.create(VPopupCalendar.class);
}

@Override
public VPopupCalendar getWidgetForPaintable() {
return (VPopupCalendar) super.getWidgetForPaintable();
}
}

+ 0
- 16
src/com/vaadin/terminal/gwt/client/ui/VTextArea.java Parādīt failu

@@ -9,8 +9,6 @@ import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;
/**
* This class represents a multiline textfield (textarea).
@@ -29,20 +27,6 @@ public class VTextArea extends VTextField {
setStyleName(CLASSNAME);
}
@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Call parent renderer explicitly
super.updateFromUIDL(uidl, client);
if (uidl.hasAttribute("rows")) {
setRows(uidl.getIntAttribute("rows"));
}
if (getMaxLength() >= 0) {
sinkEvents(Event.ONKEYUP);
}
}
public void setRows(int rows) {
setRows(getElement(), rows);
}

+ 38
- 0
src/com/vaadin/terminal/gwt/client/ui/VTextAreaPaintable.java Parādīt failu

@@ -0,0 +1,38 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;

public class VTextAreaPaintable extends VTextFieldPaintable {

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Call parent renderer explicitly
super.updateFromUIDL(uidl, client);

if (uidl.hasAttribute("rows")) {
getWidgetForPaintable().setRows(uidl.getIntAttribute("rows"));
}

if (getWidgetForPaintable().getMaxLength() >= 0) {
getWidgetForPaintable().sinkEvents(Event.ONKEYUP);
}
}

@Override
protected Widget createWidget() {
return GWT.create(VTextArea.class);
}

@Override
public VTextArea getWidgetForPaintable() {
return (VTextArea) super.getWidgetForPaintable();
}
}

+ 23
- 119
src/com/vaadin/terminal/gwt/client/ui/VTextField.java Parādīt failu

@@ -4,7 +4,6 @@

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.event.dom.client.BlurEvent;
import com.google.gwt.event.dom.client.BlurHandler;
@@ -15,21 +14,16 @@ import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyDownEvent;
import com.google.gwt.event.dom.client.KeyDownHandler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.TextBoxBase;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.BrowserInfo;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.VPaintableWidget;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VTooltip;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;

/**
* This class represents a basic text input field with one row.
@@ -37,9 +31,8 @@ import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutAct
* @author Vaadin Ltd.
*
*/
public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
ChangeHandler, FocusHandler, BlurHandler, BeforeShortcutActionListener,
KeyDownHandler {
public class VTextField extends TextBoxBase implements Field, ChangeHandler,
FocusHandler, BlurHandler, KeyDownHandler {

public static final String VAR_CUR_TEXT = "curText";

@@ -53,11 +46,11 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
*/
public static final String CLASSNAME_FOCUS = "focus";

protected String id;
protected String paintableId;

protected ApplicationConnection client;

private String valueBeforeEdit = null;
protected String valueBeforeEdit = null;

/**
* Set to false if a text change event has been sent since the last value
@@ -66,20 +59,20 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
*/
private boolean valueBeforeEditIsSynced = true;

private boolean immediate = false;
protected boolean immediate = false;
private int extraHorizontalPixels = -1;
private int extraVerticalPixels = -1;
private int maxLength = -1;

private static final String CLASSNAME_PROMPT = "prompt";
private static final String ATTR_INPUTPROMPT = "prompt";
protected static final String ATTR_INPUTPROMPT = "prompt";
public static final String ATTR_TEXTCHANGE_TIMEOUT = "iet";
public static final String VAR_CURSOR = "c";
public static final String ATTR_TEXTCHANGE_EVENTMODE = "iem";
private static final String TEXTCHANGE_MODE_EAGER = "EAGER";
protected static final String TEXTCHANGE_MODE_EAGER = "EAGER";
private static final String TEXTCHANGE_MODE_TIMEOUT = "TIMEOUT";

private String inputPrompt = null;
protected String inputPrompt = null;
private boolean prompting = false;
private int lastCursorPos = -1;
private boolean wordwrap = true;
@@ -112,14 +105,14 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
* Eager polling for a change is bit dum and heavy operation, so I guess we
* should first try to survive without.
*/
private static final int TEXTCHANGE_EVENTS = Event.ONPASTE
protected static final int TEXTCHANGE_EVENTS = Event.ONPASTE
| Event.KEYEVENTS | Event.ONMOUSEUP;

@Override
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (client != null) {
client.handleTooltipEvent(event, this);
client.handleWidgetTooltipEvent(event, this);
}

if (listenTextChangeEvents
@@ -158,7 +151,7 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
client.sendPendingVariableChanges();
} else {
// Default case - just send an immediate text change message
client.updateVariable(id, VAR_CUR_TEXT, text, true);
client.updateVariable(paintableId, VAR_CUR_TEXT, text, true);

// Shouldn't investigate valueBeforeEdit to avoid duplicate text
// change events as the states are not in sync any more
@@ -180,9 +173,9 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
}
};
private boolean scheduled = false;
private boolean listenTextChangeEvents;
private String textChangeEventMode;
private int textChangeEventTimeout;
protected boolean listenTextChangeEvents;
protected String textChangeEventMode;
protected int textChangeEventTimeout;

private void deferTextChangeEvent() {
if (textChangeEventMode.equals(TEXTCHANGE_MODE_TIMEOUT) && scheduled) {
@@ -215,88 +208,7 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
super.setReadOnly(readOnly);
}

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
this.client = client;
id = uidl.getId();

if (client.updateComponent(this, uidl, true)) {
return;
}

if (uidl.getBooleanAttribute("readonly")) {
setReadOnly(true);
} else {
setReadOnly(false);
}

inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT);

setMaxLength(uidl.hasAttribute("maxLength") ? uidl
.getIntAttribute("maxLength") : -1);

immediate = uidl.getBooleanAttribute("immediate");

listenTextChangeEvents = client.hasEventListeners(this, "ie");
if (listenTextChangeEvents) {
textChangeEventMode = uidl
.getStringAttribute(ATTR_TEXTCHANGE_EVENTMODE);
if (textChangeEventMode.equals(TEXTCHANGE_MODE_EAGER)) {
textChangeEventTimeout = 1;
} else {
textChangeEventTimeout = uidl
.getIntAttribute(ATTR_TEXTCHANGE_TIMEOUT);
if (textChangeEventTimeout < 1) {
// Sanitize and allow lazy/timeout with timeout set to 0 to
// work as eager
textChangeEventTimeout = 1;
}
}
sinkEvents(TEXTCHANGE_EVENTS);
attachCutEventListener(getElement());
}

if (uidl.hasAttribute("cols")) {
setColumns(new Integer(uidl.getStringAttribute("cols")).intValue());
}

final String text = uidl.getStringVariable("text");

/*
* We skip the text content update if field has been repainted, but text
* has not been changed. Additional sanity check verifies there is no
* change in the que (in which case we count more on the server side
* value).
*/
if (!(uidl.getBooleanAttribute(ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS)
&& valueBeforeEdit != null && text.equals(valueBeforeEdit))) {
updateFieldContent(text);
}

if (uidl.hasAttribute("selpos")) {
final int pos = uidl.getIntAttribute("selpos");
final int length = uidl.getIntAttribute("sellen");
/*
* Gecko defers setting the text so we need to defer the selection.
*/
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
setSelectionRange(pos, length);
}
});
}

// Here for backward compatibility; to be moved to TextArea.
// Optimization: server does not send attribute for the default 'true'
// state.
if (uidl.hasAttribute("wordwrap")
&& uidl.getBooleanAttribute("wordwrap") == false) {
setWordwrap(false);
} else {
setWordwrap(true);
}
}

private void updateFieldContent(final String text) {
protected void updateFieldContent(final String text) {
setPrompting(inputPrompt != null && focusedTextField != this
&& (text.equals("")));

@@ -350,7 +262,7 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
}
}

private void setMaxLength(int newMaxLength) {
protected void setMaxLength(int newMaxLength) {
if (newMaxLength >= 0) {
maxLength = newMaxLength;
if (getElement().getTagName().toLowerCase().equals("textarea")) {
@@ -386,20 +298,20 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
* true if the field was blurred
*/
public void valueChange(boolean blurred) {
if (client != null && id != null) {
if (client != null && paintableId != null) {
boolean sendBlurEvent = false;
boolean sendValueChange = false;

if (blurred && client.hasEventListeners(this, EventId.BLUR)) {
if (blurred && client.hasWidgetEventListeners(this, EventId.BLUR)) {
sendBlurEvent = true;
client.updateVariable(id, EventId.BLUR, "", false);
client.updateVariable(paintableId, EventId.BLUR, "", false);
}

String newText = getText();
if (!prompting && newText != null
&& !newText.equals(valueBeforeEdit)) {
sendValueChange = immediate;
client.updateVariable(id, "text", getText(), false);
client.updateVariable(paintableId, "text", getText(), false);
valueBeforeEdit = newText;
valueBeforeEditIsSynced = true;
}
@@ -432,7 +344,7 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
if (Util.isAttachedAndDisplayed(this)) {
int cursorPos = getCursorPos();
if (lastCursorPos != cursorPos) {
client.updateVariable(id, VAR_CURSOR, cursorPos, false);
client.updateVariable(paintableId, VAR_CURSOR, cursorPos, false);
lastCursorPos = cursorPos;
return true;
}
@@ -456,8 +368,8 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
setPrompting(false);
}
focusedTextField = this;
if (client.hasEventListeners(this, EventId.FOCUS)) {
client.updateVariable(id, EventId.FOCUS, "", true);
if (client.hasWidgetEventListeners(this, EventId.FOCUS)) {
client.updateVariable(paintableId, EventId.FOCUS, "", true);
}
}

@@ -568,10 +480,6 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
}
}

public void onBeforeShortcutAction(Event e) {
valueChange(false);
}

// Here for backward compatibility; to be moved to TextArea
public void setWordwrap(boolean enabled) {
if (enabled == wordwrap) {
@@ -601,8 +509,4 @@ public class VTextField extends TextBoxBase implements VPaintableWidget, Field,
valueChange(false);
}
}

public Widget getWidgetForPaintable() {
return this;
}
}

+ 124
- 0
src/com/vaadin/terminal/gwt/client/ui/VTextFieldPaintable.java Parādīt failu

@@ -0,0 +1,124 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.ui.ShortcutActionHandler.BeforeShortcutActionListener;

public class VTextFieldPaintable extends VAbstractPaintableWidget implements
BeforeShortcutActionListener {

public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
// Save details
getWidgetForPaintable().client = client;
getWidgetForPaintable().paintableId = uidl.getId();

if (client.updateComponent(this, uidl, true)) {
return;
}

if (uidl.getBooleanAttribute("readonly")) {
getWidgetForPaintable().setReadOnly(true);
} else {
getWidgetForPaintable().setReadOnly(false);
}

getWidgetForPaintable().inputPrompt = uidl
.getStringAttribute(VTextField.ATTR_INPUTPROMPT);

getWidgetForPaintable().setMaxLength(
uidl.hasAttribute("maxLength") ? uidl
.getIntAttribute("maxLength") : -1);

getWidgetForPaintable().immediate = uidl
.getBooleanAttribute("immediate");

getWidgetForPaintable().listenTextChangeEvents = client
.hasEventListeners(this, "ie");
if (getWidgetForPaintable().listenTextChangeEvents) {
getWidgetForPaintable().textChangeEventMode = uidl
.getStringAttribute(VTextField.ATTR_TEXTCHANGE_EVENTMODE);
if (getWidgetForPaintable().textChangeEventMode
.equals(VTextField.TEXTCHANGE_MODE_EAGER)) {
getWidgetForPaintable().textChangeEventTimeout = 1;
} else {
getWidgetForPaintable().textChangeEventTimeout = uidl
.getIntAttribute(VTextField.ATTR_TEXTCHANGE_TIMEOUT);
if (getWidgetForPaintable().textChangeEventTimeout < 1) {
// Sanitize and allow lazy/timeout with timeout set to 0 to
// work as eager
getWidgetForPaintable().textChangeEventTimeout = 1;
}
}
getWidgetForPaintable().sinkEvents(VTextField.TEXTCHANGE_EVENTS);
getWidgetForPaintable().attachCutEventListener(
getWidgetForPaintable().getElement());
}

if (uidl.hasAttribute("cols")) {
getWidgetForPaintable().setColumns(
new Integer(uidl.getStringAttribute("cols")).intValue());
}

final String text = uidl.getStringVariable("text");

/*
* We skip the text content update if field has been repainted, but text
* has not been changed. Additional sanity check verifies there is no
* change in the que (in which case we count more on the server side
* value).
*/
if (!(uidl
.getBooleanAttribute(VTextField.ATTR_NO_VALUE_CHANGE_BETWEEN_PAINTS)
&& getWidgetForPaintable().valueBeforeEdit != null && text
.equals(getWidgetForPaintable().valueBeforeEdit))) {
getWidgetForPaintable().updateFieldContent(text);
}

if (uidl.hasAttribute("selpos")) {
final int pos = uidl.getIntAttribute("selpos");
final int length = uidl.getIntAttribute("sellen");
/*
* Gecko defers setting the text so we need to defer the selection.
*/
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
getWidgetForPaintable().setSelectionRange(pos, length);
}
});
}

// Here for backward compatibility; to be moved to TextArea.
// Optimization: server does not send attribute for the default 'true'
// state.
if (uidl.hasAttribute("wordwrap")
&& uidl.getBooleanAttribute("wordwrap") == false) {
getWidgetForPaintable().setWordwrap(false);
} else {
getWidgetForPaintable().setWordwrap(true);
}
}

@Override
protected Widget createWidget() {
return GWT.create(VTextField.class);
}

@Override
public VTextField getWidgetForPaintable() {
return (VTextField) super.getWidgetForPaintable();
}

public void onBeforeShortcutAction(Event e) {
getWidgetForPaintable().valueChange(false);
}

}

+ 11
- 45
src/com/vaadin/terminal/gwt/client/ui/VTextualDate.java Parādīt failu

@@ -14,25 +14,22 @@ import com.google.gwt.event.dom.client.FocusEvent;
import com.google.gwt.event.dom.client.FocusHandler;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.ui.TextBox;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.ContainerResizedListener;
import com.vaadin.terminal.gwt.client.EventId;
import com.vaadin.terminal.gwt.client.Focusable;
import com.vaadin.terminal.gwt.client.LocaleNotLoadedException;
import com.vaadin.terminal.gwt.client.LocaleService;
import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.VPaintableWidget;

public class VTextualDate extends VDateField implements VPaintableWidget,
Field, ChangeHandler, ContainerResizedListener, Focusable, SubPartAware {
public class VTextualDate extends VDateField implements Field, ChangeHandler,
ContainerResizedListener, Focusable, SubPartAware {

private static final String PARSE_ERROR_CLASSNAME = CLASSNAME
+ "-parseerror";

private final TextBox text;
protected final TextBox text;

private String formatStr;
protected String formatStr;

private String width;

@@ -40,11 +37,11 @@ public class VTextualDate extends VDateField implements VPaintableWidget,

protected int fieldExtraWidth = -1;

private boolean lenient;
protected boolean lenient;

private static final String CLASSNAME_PROMPT = "prompt";
private static final String ATTR_INPUTPROMPT = "prompt";
private String inputPrompt = "";
protected static final String ATTR_INPUTPROMPT = "prompt";
protected String inputPrompt = "";
private boolean prompting = false;

public VTextualDate() {
@@ -65,8 +62,8 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
setPrompting(false);
}
if (getClient() != null
&& getClient().hasEventListeners(VTextualDate.this,
EventId.FOCUS)) {
&& getClient().hasWidgetEventListeners(
VTextualDate.this, EventId.FOCUS)) {
getClient()
.updateVariable(getId(), EventId.FOCUS, "", true);
}
@@ -83,8 +80,8 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
text.setText(readonly ? "" : inputPrompt);
}
if (getClient() != null
&& getClient().hasEventListeners(VTextualDate.this,
EventId.BLUR)) {
&& getClient().hasWidgetEventListeners(
VTextualDate.this, EventId.BLUR)) {
getClient().updateVariable(getId(), EventId.BLUR, "", true);
}
}
@@ -92,37 +89,6 @@ public class VTextualDate extends VDateField implements VPaintableWidget,
add(text);
}

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
int origRes = currentResolution;
String oldLocale = currentLocale;
super.updateFromUIDL(uidl, client);
if (origRes != currentResolution || oldLocale != currentLocale) {
// force recreating format string
formatStr = null;
}
if (uidl.hasAttribute("format")) {
formatStr = uidl.getStringAttribute("format");
}

inputPrompt = uidl.getStringAttribute(ATTR_INPUTPROMPT);

lenient = !uidl.getBooleanAttribute("strict");

buildDate();
// not a FocusWidget -> needs own tabindex handling
if (uidl.hasAttribute("tabindex")) {
text.setTabIndex(uidl.getIntAttribute("tabindex"));
}

if (readonly) {
text.addStyleDependentName("readonly");
} else {
text.removeStyleDependentName("readonly");
}

}

protected String getFormatString() {
if (formatStr == null) {
if (currentResolution == RESOLUTION_YEAR) {

+ 58
- 0
src/com/vaadin/terminal/gwt/client/ui/VTextualDatePaintable.java Parādīt failu

@@ -0,0 +1,58 @@
/*
@VaadinApache2LicenseForJavaFiles@
*/

package com.vaadin.terminal.gwt.client.ui;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.Widget;
import com.vaadin.terminal.gwt.client.ApplicationConnection;
import com.vaadin.terminal.gwt.client.UIDL;

public class VTextualDatePaintable extends VDateFieldPaintable {

@Override
public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
int origRes = getWidgetForPaintable().currentResolution;
String oldLocale = getWidgetForPaintable().currentLocale;
super.updateFromUIDL(uidl, client);
if (origRes != getWidgetForPaintable().currentResolution
|| oldLocale != getWidgetForPaintable().currentLocale) {
// force recreating format string
getWidgetForPaintable().formatStr = null;
}
if (uidl.hasAttribute("format")) {
getWidgetForPaintable().formatStr = uidl
.getStringAttribute("format");
}

getWidgetForPaintable().inputPrompt = uidl
.getStringAttribute(VTextualDate.ATTR_INPUTPROMPT);

getWidgetForPaintable().lenient = !uidl.getBooleanAttribute("strict");

getWidgetForPaintable().buildDate();
// not a FocusWidget -> needs own tabindex handling
if (uidl.hasAttribute("tabindex")) {
getWidgetForPaintable().text.setTabIndex(uidl
.getIntAttribute("tabindex"));
}

if (getWidgetForPaintable().readonly) {
getWidgetForPaintable().text.addStyleDependentName("readonly");
} else {
getWidgetForPaintable().text.removeStyleDependentName("readonly");
}

}

@Override
protected Widget createWidget() {
return GWT.create(VTextualDate.class);
}

@Override
public VTextualDate getWidgetForPaintable() {
return (VTextualDate) super.getWidgetForPaintable();
}
}

+ 2
- 1
src/com/vaadin/ui/ComboBox.java Parādīt failu

@@ -10,6 +10,7 @@ import com.vaadin.data.Container;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
import com.vaadin.terminal.gwt.client.ui.VFilterSelectPaintable;
/**
* A filtering dropdown single-select. Suitable for newItemsAllowed, but it's
@@ -20,7 +21,7 @@ import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
*
*/
@SuppressWarnings("serial")
@ClientWidget(VFilterSelect.class)
@ClientWidget(VFilterSelectPaintable.class)
public class ComboBox extends Select {
private String inputPrompt = null;

+ 2
- 2
src/com/vaadin/ui/DateField.java Parādīt failu

@@ -27,7 +27,7 @@ import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.ui.VDateField;
import com.vaadin.terminal.gwt.client.ui.VPopupCalendar;
import com.vaadin.terminal.gwt.client.ui.VPopupCalendarPaintable;

/**
* <p>
@@ -50,7 +50,7 @@ import com.vaadin.terminal.gwt.client.ui.VPopupCalendar;
* @since 3.0
*/
@SuppressWarnings("serial")
@ClientWidget(VPopupCalendar.class)
@ClientWidget(VPopupCalendarPaintable.class)
public class DateField extends AbstractField<Date> implements
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {


+ 2
- 2
src/com/vaadin/ui/InlineDateField.java Parādīt failu

@@ -7,7 +7,7 @@ package com.vaadin.ui;
import java.util.Date;
import com.vaadin.data.Property;
import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar;
import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendarPaintable;
/**
* <p>
@@ -22,7 +22,7 @@ import com.vaadin.terminal.gwt.client.ui.VDateFieldCalendar;
* @VERSION@
* @since 5.0
*/
@ClientWidget(VDateFieldCalendar.class)
@ClientWidget(VDateFieldCalendarPaintable.class)
public class InlineDateField extends DateField {
public InlineDateField() {

+ 2
- 2
src/com/vaadin/ui/Link.java Parādīt failu

@@ -7,7 +7,7 @@ package com.vaadin.ui;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.VLink;
import com.vaadin.terminal.gwt.client.ui.VLinkPaintable;

/**
* Link is used to create external or internal URL links.
@@ -18,7 +18,7 @@ import com.vaadin.terminal.gwt.client.ui.VLink;
* @since 3.0
*/
@SuppressWarnings("serial")
@ClientWidget(VLink.class)
@ClientWidget(VLinkPaintable.class)
public class Link extends AbstractComponent {

/* Target window border type constant: No window border */

+ 2
- 2
src/com/vaadin/ui/PasswordField.java Parādīt failu

@@ -4,13 +4,13 @@
package com.vaadin.ui;

import com.vaadin.data.Property;
import com.vaadin.terminal.gwt.client.ui.VPasswordField;
import com.vaadin.terminal.gwt.client.ui.VPasswordFieldPaintable;

/**
* A field that is used to enter secret text information like passwords. The
* entered text is not displayed on the screen.
*/
@ClientWidget(VPasswordField.class)
@ClientWidget(VPasswordFieldPaintable.class)
public class PasswordField extends AbstractTextField {

/**

+ 2
- 2
src/com/vaadin/ui/Select.java Parādīt failu

@@ -23,7 +23,7 @@ import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.Resource;
import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
import com.vaadin.terminal.gwt.client.ui.VFilterSelectPaintable;

/**
* <p>
@@ -44,7 +44,7 @@ import com.vaadin.terminal.gwt.client.ui.VFilterSelect;
* @since 3.0
*/
@SuppressWarnings("serial")
@ClientWidget(VFilterSelect.class)
@ClientWidget(VFilterSelectPaintable.class)
public class Select extends AbstractSelect implements AbstractSelect.Filtering,
FieldEvents.BlurNotifier, FieldEvents.FocusNotifier {


+ 2
- 2
src/com/vaadin/ui/TextArea.java Parādīt failu

@@ -7,12 +7,12 @@ package com.vaadin.ui;
import com.vaadin.data.Property;
import com.vaadin.terminal.PaintException;
import com.vaadin.terminal.PaintTarget;
import com.vaadin.terminal.gwt.client.ui.VTextArea;
import com.vaadin.terminal.gwt.client.ui.VTextAreaPaintable;

/**
* A text field that supports multi line editing.
*/
@ClientWidget(VTextArea.class)
@ClientWidget(VTextAreaPaintable.class)
public class TextArea extends AbstractTextField {

private static final int DEFAULT_ROWS = 5;

+ 2
- 2
src/com/vaadin/ui/TextField.java Parādīt failu

@@ -5,7 +5,7 @@
package com.vaadin.ui;

import com.vaadin.data.Property;
import com.vaadin.terminal.gwt.client.ui.VTextField;
import com.vaadin.terminal.gwt.client.ui.VTextFieldPaintable;
import com.vaadin.ui.ClientWidget.LoadStyle;

/**
@@ -29,7 +29,7 @@ import com.vaadin.ui.ClientWidget.LoadStyle;
* @since 3.0
*/
@SuppressWarnings("serial")
@ClientWidget(value = VTextField.class, loadStyle = LoadStyle.EAGER)
@ClientWidget(value = VTextFieldPaintable.class, loadStyle = LoadStyle.EAGER)
public class TextField extends AbstractTextField {

/**

Notiek ielāde…
Atcelt
Saglabāt