@Override protected void onFirstShowPage() { super.onFirstShowPage(); final PTextBox name = new PTextBox(); name.setPlaceholder("Cookie name"); final PTextBox value = new PTextBox(); name.setPlaceholder("Cookie value"); final PButton add = new PButton("Add"); add.addClickHandler( new PClickHandler() { @Override public void onClick(final PClickEvent event) { UIContext.get().getCookies().setCookie(name.getValue(), value.getValue()); } }); final PTextBox name2 = new PTextBox(); name2.setPlaceholder("Cookie name"); final PButton remove = new PButton("Remove"); remove.addClickHandler( new PClickHandler() { @Override public void onClick(final PClickEvent event) { UIContext.get().getCookies().removeCookie(name2.getValue()); } }); final PHorizontalPanel addPanel = new PHorizontalPanel(); addPanel.add(name); addPanel.add(value); addPanel.add(add); final PHorizontalPanel removePanel = new PHorizontalPanel(); removePanel.add(name2); removePanel.add(remove); final PVerticalPanel panel = new PVerticalPanel(); panel.setSpacing(10); panel.add(new PLabel("Add a cookie:")); panel.add(addPanel); panel.add(new PLabel("Remove a cookie:")); panel.add(removePanel); examplePanel.setWidget(panel); }
@Override public IsPWidget render(final FormField formField) { dateBox = new PDateBox(); if (debugID != null) dateBox.ensureDebugId(debugID); final FormFieldComponent<PDateBox> dateFieldComponent = new FormFieldComponent<PDateBox>(dateBox); dateFieldComponent.setCaption(caption); dateFieldComponent.getInput().setDateFormat(dateFormat); dateFieldComponent.getInput().addValueChangeHandler(this); fields.add(dateFieldComponent); addListener(dateFieldComponent.getInput()); final PHorizontalPanel horizontalPanel = new PHorizontalPanel(); horizontalPanel.add(dateFieldComponent.asWidget()); hours = new PListBox(false, false); for (int i = 0; i < 24; i++) { hours.addItem(i + "", i); } minutes = new PListBox(false, false); for (int i = 0; i < 60; i++) { minutes.addItem(i + "", i); } seconds = new PListBox(false, false); for (int i = 0; i < 60; i++) { seconds.addItem(i + "", i); } hours.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.HOUR_OF_DAY, (Integer) hours.getSelectedValue()); } } }); minutes.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.MINUTE, (Integer) minutes.getSelectedValue()); } } }); seconds.addChangeHandler( new PChangeHandler() { @Override public void onChange(final PChangeEvent event) { if (calendar != null) { calendar.set(Calendar.SECOND, (Integer) seconds.getSelectedValue()); } } }); horizontalPanel.add(new PLabel("hh")); horizontalPanel.add(hours); horizontalPanel.add(new PLabel("mm")); horizontalPanel.add(minutes); horizontalPanel.add(new PLabel("ss")); horizontalPanel.add(seconds); return horizontalPanel; }
@Override protected void onFirstShowPage() { super.onFirstShowPage(); final PDockLayoutPanel dockLayoutPanel = new PDockLayoutPanel(PUnit.PX); dockLayoutPanel.setSizeFull(); final PTabPanel tabPanel = new PTabPanel(); tabPanel.setSizeFull(); tabPanel.addBeforeSelectionHandler( new PBeforeSelectionHandler<Integer>() { @Override public void onBeforeSelection(final PBeforeSelectionEvent<Integer> event) { PNotificationManager.showTrayNotification( "onBeforeSelection, tab index : " + event.getSelectedItem()); } }); tabPanel.addSelectionHandler( new PSelectionHandler<Integer>() { @Override public void onSelection(final PSelectionEvent<Integer> event) { PNotificationManager.showTrayNotification( "onSelection, tab index : " + event.getSelectedItem()); } }); final PButton button = new PButton("Add Tab"); button.setStyleProperty("margin", "10px"); button.addClickHandler( new PClickHandler() { @Override public void onClick(final PClickEvent clickEvent) { addTabContent(tabPanel); } }); final PButton addCustomTabButton = new PButton("Add Tab (custom tab)"); addCustomTabButton.setStyleProperty("margin", "10px"); addCustomTabButton.addClickHandler( new PClickHandler() { @Override public void onClick(final PClickEvent clickEvent) { addCustomTabContent(tabPanel); } }); final PTextBox indexTextBox = new PTextBox(); final PButton selectButton = new PButton("Select Tab"); selectButton.setStyleProperty("margin", "10px"); selectButton.addClickHandler( new PClickHandler() { @Override public void onClick(final PClickEvent clickEvent) { final String text = indexTextBox.getText(); tabPanel.selectTab(Integer.valueOf(text)); } }); final PHorizontalPanel horizontalPanel = new PHorizontalPanel(); horizontalPanel.setVerticalAlignment(PVerticalAlignment.ALIGN_MIDDLE); horizontalPanel.add(button); horizontalPanel.add(addCustomTabButton); horizontalPanel.add(indexTextBox); horizontalPanel.add(selectButton); final PHorizontalPanel tabPanelContainer = new PHorizontalPanel(); tabPanelContainer.add(tabPanel); dockLayoutPanel.addNorth(horizontalPanel, 50); dockLayoutPanel.add(tabPanelContainer); addTabContent(tabPanel); examplePanel.setWidget(dockLayoutPanel); }