List of usage examples for com.google.gwt.event.dom.client FocusHandler FocusHandler
FocusHandler
From source file:org.sigmah.client.page.orgunit.reports.OrgUnitReportsView.java
License:Open Source License
private void displaySection(final ProjectReportSectionDTO section, final FoldPanel parent, final StringBuilder prefix, int level, final boolean draftMode) { final FoldPanel sectionPanel = new FoldPanel(); sectionPanel.setHeading(prefix.toString() + ' ' + section.getName()); sectionPanel.addStyleName("project-report-level-" + level); int index = 1; int prefixLength = prefix.length(); for (final ProjectReportContent object : section.getChildren()) { if (object.getClass() == ProjectReportSectionDTO.class) { prefix.append(index).append('.'); displaySection((ProjectReportSectionDTO) object, sectionPanel, prefix, level + 1, draftMode); index++;/*from w ww .j a v a 2 s . c o m*/ prefix.setLength(prefixLength); } else if (object.getClass() == RichTextElementDTO.class) { if (draftMode) { final RichTextArea textArea = new RichTextArea(); textArea.setHTML(((RichTextElementDTO) object).getText()); textArea.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { globalFormatterArray[0] = textArea.getFormatter(); } }); sectionPanel.add(textArea); textAreas.put(((RichTextElementDTO) object).getId(), textArea); oldContents.put(((RichTextElementDTO) object).getId(), textArea.getText()); } else { final HTML html = new HTML(); final String value = ((RichTextElementDTO) object).getText(); if (value == null || "".equals(value)) { html.setText(I18N.CONSTANTS.reportEmptySection()); html.addStyleName("project-report-field-empty"); } else { html.setHTML(value); html.addStyleName("project-report-field"); } sectionPanel.add(html); } } else if (object.getClass() == KeyQuestionDTO.class) { final KeyQuestionDTO keyQuestion = (KeyQuestionDTO) object; keyQuestionState.increaseCount(); keyQuestion.setNumber(keyQuestionState.getCount()); // Rich text field final RichTextArea textArea = new RichTextArea(); final RichTextElementDTO richTextElementDTO = keyQuestion.getRichTextElementDTO(); if (richTextElementDTO != null) { textArea.setHTML(richTextElementDTO.getText()); textAreas.put(richTextElementDTO.getId(), textArea); oldContents.put(richTextElementDTO.getId(), textArea.getText()); } else { Log.error("No text area is attached to the key question #" + keyQuestion.getId()); } // Compas icon final ToolbarImages images = GWT.create(ToolbarImages.class); final ImageResource icon; if ("".equals(textArea.getText())) icon = images.compasRed(); else { icon = images.compasGreen(); keyQuestionState.increaseValids(); } final int toolButtonIndex = sectionPanel.getToolButtonCount(); sectionPanel.addToolButton(icon, new ClickHandler() { @Override public void onClick(ClickEvent event) { KeyQuestionDialog.getDialog(keyQuestion, textArea, sectionPanel, toolButtonIndex, keyQuestionState, draftMode).show(); } }); } else { Log.warn("Report : object type unknown (" + object.getClass() + ")"); } } parent.add(sectionPanel); }
From source file:org.sigmah.client.ui.view.reports.ReportsView.java
License:Open Source License
/** * {@inheritDoc}// www . j a v a 2 s. co m */ @Override public HasHTML addTextArea(final RichTextElementDTO richTextElement, final FoldPanel sectionPanel, final boolean draftMode) { if (draftMode) { final RichTextArea textArea = new RichTextArea(); textArea.setHTML(richTextElement.getText()); textArea.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { globalFormatterArray[0] = textArea.getFormatter(); } }); sectionPanel.add(textArea); return textArea; } else { final HTML html = new HTML(); final String value = richTextElement.getText(); if (ClientUtils.isBlank(value)) { html.setText(I18N.CONSTANTS.reportEmptySection()); html.addStyleName(STYLE_PROJECT_REPORT_FIELD_EMPTY); } else { html.setHTML(value); html.addStyleName(STYLE_PROJECT_REPORT_FIELD); } sectionPanel.add(html); return null; } }
From source file:org.ssgwt.client.ui.AdvancedPasswordBox.java
License:Apache License
/** * Class constructor//from ww w. j a va 2 s . c o m */ public AdvancedPasswordBox() { mainPanel.add(placeholder); placeholder.setWidth("100%"); mainPanel.add(passwordBox); passwordBox.setWidth("100%"); passwordBox.setVisible(false); placeholder.addFocusHandler(new FocusHandler() { /** * Function called when the place holder gains focus * * @param event - The event that should be handled */ @Override public void onFocus(FocusEvent event) { placeholder.setVisible(false); Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() { public void execute() { passwordBox.setFocus(true); } }); passwordBox.setVisible(true); } }); passwordBox.addBlurHandler(new BlurHandler() { /** * Function called when the password box loses focus * * @param event - The event that should be handled */ @Override public void onBlur(BlurEvent event) { if (passwordBox.getText() == null || passwordBox.getText().equals("")) { placeholder.setVisible(true); passwordBox.setVisible(false); } } }); initWidget(mainPanel); }
From source file:org.ssgwt.client.ui.AdvancedTextbox.java
License:Apache License
/** * Attach all handlers to the input textbox. Current handlers include @see * FocusHandler and @see BlurHandler. These handlers are responsible for * displaying and hiding the placeholder text at the right time. * //from www . j av a2s .com * @author Jaco Nel <jaco.nel@a24group.com> * @since 05 June 2012 */ public void attacheHanlders() { // hide the placeholder text on focus addFocusHandler(new FocusHandler() { public void onFocus(FocusEvent event) { hidePlaceholder(); } }); // display the placeholder text when focus is lost. addBlurHandler(new BlurHandler() { public void onBlur(BlurEvent event) { displayPlaceholder(); } }); }
From source file:org.talend.mdm.webapp.general.client.layout.BrandingBar.java
License:Open Source License
private void initEvent() { languageBox.addChangeHandler(new ChangeHandler() { @Override//from w ww. j av a 2s . c o m public void onChange(ChangeEvent event) { if (languageBoxEnable) { changeLanguage(); } } }); languageBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (languageBox != null) { languageSeleted = languageBox.getSelectedIndex(); } String languageSelected = languageBox.getValue(languageBox.getSelectedIndex()); if (languageSelected == null || "".equals(languageSelected.trim())) { //$NON-NLS-1$ languageSelected = UrlUtil.getLanguage(); } service.isExpired(languageSelected, new SessionAwareAsyncCallback<Boolean>() { @Override public void onSuccess(Boolean result) { languageBoxEnable = true; } @Override protected void doOnFailure(final Throwable caught) { languageBoxEnable = false; languageBox.setSelectedIndex(languageSeleted); super.doOnFailure(caught); } }); } }); logout.addSelectionListener(new SelectionListener<ButtonEvent>() { @Override public void componentSelected(ButtonEvent ce) { GeneralServiceAsync service = (GeneralServiceAsync) Registry.get(General.OVERALL_SERVICE); service.logout(new SessionAwareAsyncCallback<Void>() { @Override public void onSuccess(Void result) { Cookies.removeCookie("JSESSIONID"); //$NON-NLS-1$ Cookies.removeCookie("JSESSIONIDSSO"); //$NON-NLS-1$ Window.Location.replace(GWT.getHostPageBaseURL()); } }); } }); }
From source file:org.uberfire.client.workbench.panels.impl.StaticWorkbenchPanelView.java
License:Apache License
@PostConstruct void postConstruct() { panel.addFocusHandler(new FocusHandler() { @Override/*from w w w . j a v a2 s .co m*/ public void onFocus(final FocusEvent event) { panelManager.onPanelFocus(presenter.getDefinition()); } }); //When a tab is selected ensure content is resized and set focus panel.addSelectionHandler(new SelectionHandler<PartDefinition>() { @Override public void onSelection(final SelectionEvent<PartDefinition> event) { panelManager.onPartLostFocus(); panelManager.onPartFocus(event.getSelectedItem()); } }); Layouts.setToFillParent(panel); initWidget(panel); }
From source file:org.uberfire.client.workbench.panels.impl.UnanchoredStaticWorkbenchPanelView.java
License:Apache License
@PostConstruct void postConstruct() { panel.addFocusHandler(new FocusHandler() { @Override/*from ww w . ja va 2 s . c o m*/ public void onFocus(final FocusEvent event) { panelManager.onPanelFocus(presenter.getDefinition()); } }); //When a tab is selected ensure content is resized and set focus panel.addSelectionHandler(new SelectionHandler<PartDefinition>() { @Override public void onSelection(final SelectionEvent<PartDefinition> event) { panelManager.onPartLostFocus(); panelManager.onPartFocus(event.getSelectedItem()); } }); Layouts.setToFillParent(panel); initWidget(panel); }
From source file:org.uberfire.ext.properties.editor.client.widgets.PropertyEditorPasswordTextBox.java
License:Apache License
public PropertyEditorPasswordTextBox() { initWidget(uiBinder.createAndBindUi(this)); passwordTextBox.addFocusHandler(new FocusHandler() { @Override// ww w . ja v a2s . c o m public void onFocus(FocusEvent event) { passwordTextBox.selectAll(); } }); }
From source file:org.uberfire.ext.properties.editor.client.widgets.PropertyEditorTextBox.java
License:Apache License
public PropertyEditorTextBox() { initWidget(uiBinder.createAndBindUi(this)); textBox.addFocusHandler(new FocusHandler() { @Override/*from w w w . ja v a2 s . co m*/ public void onFocus(FocusEvent event) { textBox.selectAll(); } }); }
From source file:org.unitime.timetable.gwt.client.aria.AriaButton.java
License:Apache License
public AriaButton(String html) { super(html);// w w w . j av a 2 s . com setAriaLabel(UniTimeHeaderPanel.stripAccessKey(html).replace(" ", " ").replace("‑", "-")); Character accessKey = UniTimeHeaderPanel.guessAccessKey(html); if (accessKey != null) setAccessKey(accessKey); ToolBox.setMinWidth(getElement().getStyle(), "75px"); addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { iFocused = true; } }); addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { iFocused = false; } }); }