Skip to content

Commit

Permalink
Instructional Offering Configuration, Multiple Class Setup: new (GWT-…
Browse files Browse the repository at this point in the history
…based) versions

- room ratio: allow for comma as decimal separator when localization has that
- avoid splitting the class/subpart label or the buttons over multiple lines (when the page gets too wide, e.g., because of a long instructor name)
  • Loading branch information
tomas-muller committed May 15, 2024
1 parent 8fac567 commit bb770a3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,9 +538,13 @@ public void onValueChange(ValueChangeEvent<String> event) {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
try {
line.setRoomRatio(Float.parseFloat(event.getValue()));
line.setRoomRatio((float)NumberFormat.getDecimalFormat().parse(event.getValue()));
} catch (NumberFormatException e) {
line.setRoomRatio(1.0f);
try {
line.setRoomRatio(Float.parseFloat(event.getValue()));
} catch (NumberFormatException f) {
line.setRoomRatio(1.0f);
}
}
roomRatio.setValue(sRoomRatioFormat.format(line.getRoomRatio()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,13 @@ public void onValueChange(ValueChangeEvent<String> event) {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
try {
line.setRoomRatio(Float.parseFloat(event.getValue()));
line.setRoomRatio((float)NumberFormat.getDecimalFormat().parse(event.getValue()));
} catch (NumberFormatException e) {
line.setRoomRatio(1.0f);
try {
line.setRoomRatio(Float.parseFloat(event.getValue()));
} catch (NumberFormatException f) {
line.setRoomRatio(1.0f);
}
}
roomRatio.setValue(sRoomRatioFormat.format(line.getRoomRatio()));
}
Expand Down
10 changes: 10 additions & 0 deletions JavaSource/org/unitime/timetable/gwt/client/widgets/NumberBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
import com.google.gwt.event.dom.client.KeyCodes;
import com.google.gwt.event.dom.client.KeyPressEvent;
import com.google.gwt.event.dom.client.KeyPressHandler;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.i18n.client.NumberFormat;

/**
* @author Tomas Muller
Expand All @@ -36,6 +38,7 @@ public NumberBox() {
setStyleName("gwt-SuggestBox");
setWidth("100px");
getElement().getStyle().setTextAlign(TextAlign.RIGHT);
final String decimalSeparator = LocaleInfo.getCurrentLocale().getNumberConstants().decimalSeparator();
addKeyPressHandler(new KeyPressHandler() {
@Override
public void onKeyPress(KeyPressEvent event) {
Expand All @@ -54,6 +57,7 @@ public void onKeyPress(KeyPressEvent event) {
}

if (isDecimal() && event.getCharCode() == '.' && !getValue().contains(".")) return;
if (isDecimal() && decimalSeparator != null && event.getCharCode() == decimalSeparator.charAt(0) && !getValue().contains(decimalSeparator)) return;
if (isNegative() && event.getCharCode() == '-' && !getValue().contains("-") && (getCursorPos() == 0 || getSelectionLength() == getValue().length()))
return;

Expand All @@ -72,6 +76,9 @@ public void onKeyPress(KeyPressEvent event) {
public void setNegative(boolean negative) { iNegative = negative; }

public Double toDouble() {
try {
return NumberFormat.getDecimalFormat().parse(getValue());
} catch (NumberFormatException e) {}
try {
return Double.parseDouble(getValue());
} catch (NumberFormatException e) {
Expand All @@ -80,6 +87,9 @@ public Double toDouble() {
}

public Float toFloat() {
try {
return (float) NumberFormat.getDecimalFormat().parse(getValue());
} catch (NumberFormatException e) {}
try {
return Float.parseFloat(getValue());
} catch (NumberFormatException e) {
Expand Down
18 changes: 18 additions & 0 deletions WebContent/styles/unitime.css
Original file line number Diff line number Diff line change
Expand Up @@ -7722,8 +7722,17 @@ unitime-RoomSharingWidget .legend .blank {
list-style-position: inside;
}

.unitime-MultipleClassSetup .class-name {
white-space: nowrap;
}

.unitime-MultipleClassSetup .class-buttons {
padding: 0px 1px 0px 1px;
white-space: nowrap;
}

.unitime-MultipleClassSetup .class-limit {
white-space: nowrap;
}

.unitime-MultipleClassSetup .class-buttons div {
Expand Down Expand Up @@ -7761,8 +7770,17 @@ unitime-RoomSharingWidget .legend .blank {
margin-left: 4px;
}

.unitime-InstrOfferingConfig .subpart-limit {
white-space: nowrap;
}

.unitime-InstrOfferingConfig .subpart-buttons {
padding: 0px 1px 0px 1px;
white-space: nowrap;
}

.unitime-InstrOfferingConfig .class-limit {
white-space: nowrap;
}

.unitime-InstrOfferingConfig .subpart-buttons div {
Expand Down

0 comments on commit bb770a3

Please sign in to comment.