Skip to content

Commit

Permalink
gwt - improvement: use setDisplay()
Browse files Browse the repository at this point in the history
  • Loading branch information
Duilio Protti committed Mar 19, 2014
1 parent 620ace7 commit 4cc496f
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions architecture-examples/gwt/src/com/todo/client/ToDoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.InputElement;
import com.google.gwt.dom.client.SpanElement;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.KeyCodes;
Expand Down Expand Up @@ -142,9 +143,9 @@ public void clearTaskText() {
public void setTaskStatistics(int totalTasks, int completedTasks) {
int remainingTasks = totalTasks - completedTasks;

hideElement(mainSection, totalTasks == 0);
hideElement(todoStatsContainer, totalTasks == 0);
hideElement(clearCompleted.getElement(), completedTasks == 0);
displayOrHide(mainSection, totalTasks == 0);
displayOrHide(todoStatsContainer, totalTasks == 0);
displayOrHide(clearCompleted.getElement(), completedTasks == 0);

remainingTasksCount.setInnerText(Integer.toString(remainingTasks));
remainingTasksLabel.setInnerText(remainingTasks > 1 || remainingTasks == 0 ? "items" : "item");
Expand All @@ -169,11 +170,11 @@ private void selectRoutingHyperlink(Hyperlink hyperlink, ToDoRouting currentRout
}
}

private void hideElement(Element element, boolean hide) {
private void displayOrHide(Element element, boolean hide) {
if (hide) {
element.setAttribute("style", "display:none;");
element.getStyle().setDisplay(Display.NONE);
} else {
element.setAttribute("style", "display:block;");
element.getStyle().setDisplay(Display.BLOCK);
}
}
}

0 comments on commit 4cc496f

Please sign in to comment.