List of usage examples for com.google.gwt.event.dom.client FocusHandler FocusHandler
FocusHandler
From source file:org.geosdi.geoplatform.gui.client.widget.wfs.FeatureAttributesWidget.java
License:Open Source License
private ColumnModel prepareColumnModel() { List<AttributeDTO> attributesDTO = this.layerSchemaBinder.getLayerSchemaDTO().getAttributes(); List<ColumnConfig> configs = Lists.<ColumnConfig>newArrayListWithCapacity(attributesDTO.size()); for (final AttributeDTO att : attributesDTO) { final GPSecureStringTextField valueTextField = new GPSecureStringTextField(); valueTextField.setValidator(AttributeCustomFieldsMap.getValidatorForAttributeType(att.getType())); valueTextField.setAutoValidate(true); if (att.isDateType()) { FocusHandler focusHandler = new FocusHandler() { @Override/*from www. ja v a2 s .c o m*/ public void onFocus(FocusEvent event) { dataAttributeName = att.getName(); timeInputWidget.show(); } }; valueTextField.addHandler(focusHandler, FocusEvent.getType()); } ColumnConfig valueColumn = new ColumnConfig(); String name = att.getName(); valueColumn.setId(name); valueColumn.setHeaderHtml(name); valueColumn.setEditor(buildCellEditor(valueTextField)); valueColumn.setWidth((name.length() + 1) * 10); valueColumn.setToolTip("Datatype: " + att.getType()); configs.add(valueColumn); } return new ColumnModel(configs); }
From source file:org.gss_project.gss.web.client.FilesPropertiesDialog.java
License:Open Source License
/** * The widget's constructor./*from w w w .j a v a2 s. c o m*/ * * @param _files */ public FilesPropertiesDialog(final List<FileResource> _files) { super(); files = _files; int versionedNum = 0; for (FileResource fr : files) if (fr.isVersioned()) versionedNum++; Boolean versioned = null; if (versionedNum == 0) versioned = false; if (versionedNum == files.size()) versioned = true; initialVersioned = versioned; versionedCheck = new TristateCheckBox(versioned); // Set the dialog's caption. setText("Files properties"); // Outer contains inner and buttons. final VerticalPanel outer = new VerticalPanel(); final FocusPanel focusPanel = new FocusPanel(outer); // Inner contains generalPanel and permPanel. inner = new DecoratedTabPanel(); inner.setAnimationEnabled(true); final VerticalPanel generalPanel = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); final VerticalPanel verPanel = new VerticalPanel(); final HorizontalPanel vPanel = new HorizontalPanel(); inner.add(generalPanel, "General"); inner.add(verPanel, "Versions"); inner.selectTab(0); final FlexTable generalTable = new FlexTable(); generalTable.setText(0, 0, String.valueOf(files.size()) + " files selected"); generalTable.setText(1, 0, "Folder"); generalTable.setText(2, 0, "Tags"); FileResource firstFile = files.get(0); if (firstFile.getFolderName() != null) generalTable.setText(1, 1, firstFile.getFolderName()); else generalTable.setText(1, 1, "-"); // Find if tags are identical List<String> tagsList = files.get(0).getTags(); List<String> tagss; for (int i = 1; i < files.size(); i++) { tagss = files.get(i).getTags(); if (tagsList.size() != tagss.size() || !tagsList.containsAll(tagss)) { tagsList = null; break; } } // Get the tags. StringBuffer tagsBuffer = new StringBuffer(); if (tagsList == null) tagsBuffer.append(MULTIPLE_VALUES_TEXT); else { Iterator i = tagsList.iterator(); while (i.hasNext()) { String tag = (String) i.next(); tagsBuffer.append(tag).append(", "); } if (tagsBuffer.length() > 1) tagsBuffer.delete(tagsBuffer.length() - 2, tagsBuffer.length() - 1); } initialTagText = tagsBuffer.toString(); tags.setText(initialTagText); tags.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (MULTIPLE_VALUES_TEXT.equals(tags.getText())) tags.setText(""); } }); generalTable.setWidget(2, 1, tags); generalTable.getFlexCellFormatter().setStyleName(0, 0, "props-labels"); generalTable.getFlexCellFormatter().setColSpan(0, 0, 2); generalTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(2, 0, "props-labels"); generalTable.getFlexCellFormatter().setStyleName(0, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(1, 1, "props-values"); generalTable.getFlexCellFormatter().setStyleName(2, 1, "props-values"); generalTable.setCellSpacing(4); // Create the 'OK' button, along with a listener that hides the dialog // when the button is clicked. final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { accept(); closeDialog(); } }); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { closeDialog(); } }); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); generalPanel.add(generalTable); // Asynchronously retrieve the tags defined by this user. DeferredCommand.addCommand(new Command() { @Override public void execute() { updateTags(); } }); DisclosurePanel allTags = new DisclosurePanel("All tags"); allTagsContent = new FlowPanel(); allTags.setContent(allTagsContent); generalPanel.add(allTags); generalPanel.setSpacing(4); vPanel.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); vPanel.setSpacing(8); vPanel.addStyleName("gss-TabPanelBottom"); vPanel.add(new Label("Versioned")); vPanel.add(versionedCheck); verPanel.add(vPanel); outer.add(inner); outer.add(buttons); outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); outer.addStyleName("gss-TabPanelBottom"); focusPanel.setFocus(true); setWidget(outer); }
From source file:org.gss_project.gss.web.client.PermissionsAddDialog.java
License:Open Source License
public PermissionsAddDialog(List<GroupResource> _groups, PermissionsList _permList, boolean _userAdd) { groups = _groups;//from w ww .j a va 2s. c o m userAdd = _userAdd; permList = _permList; groupBox.getElement().setId("addPermission.dropDown"); suggestBox.getElement().setId("addPermission.textBox"); read.getElement().setId("addPermission.read"); write.getElement().setId("addPermission.write"); modifyACL.getElement().setId("addpermission.modify"); for (GroupResource group : _groups) groupBox.addItem(group.getName(), group.getName()); final VerticalPanel panel = new VerticalPanel(); final HorizontalPanel buttons = new HorizontalPanel(); setWidget(panel); final FlexTable permTable = new FlexTable(); permTable.setText(0, 0, "Users/Groups"); permTable.setText(0, 1, "Read"); permTable.setText(0, 2, "Write"); permTable.setText(0, 3, "Modify Access"); permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels"); permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels"); if (userAdd) { suggestBox.getTextBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (selectedUser != null && selectedUser.endsWith("@")) updateSuggestions(); } }); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // Ignore the arrow keys. int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_LEFT || keyCode == KeyCodes.KEY_RIGHT) return; if (keyCode == KeyCodes.KEY_ESCAPE) { suggestBox.hideSuggestionList(); return; } String text = suggestBox.getText().trim(); // Avoid useless queries for keystrokes that do not modify // the text. if (text.equals(selectedUser)) return; selectedUser = text; // Go to the server only if the user typed the @ character. if (selectedUser.endsWith("@")) updateSuggestions(); } }); permTable.setWidget(1, 0, suggestBox); } else permTable.setWidget(1, 0, groupBox); permTable.setWidget(1, 1, read); permTable.setWidget(1, 2, write); permTable.setWidget(1, 3, modifyACL); permTable.getFlexCellFormatter().setStyleName(1, 0, "props-labels"); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 1, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 2, HasHorizontalAlignment.ALIGN_CENTER); permTable.getFlexCellFormatter().setHorizontalAlignment(1, 3, HasHorizontalAlignment.ALIGN_CENTER); panel.add(permTable); final Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { addPermission(); hide(); } }); ok.getElement().setId("addPermission.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog // when the button is clicked. final Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("addPermission.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); panel.add(buttons); panel.addStyleName("gss-TabPanelBottom"); }
From source file:org.gss_project.gss.web.client.UserAddDialog.java
License:Open Source License
/** * The widget's constructor.//from ww w . j av a2s . c o m */ public UserAddDialog() { setAnimationEnabled(true); setText("Add User"); VerticalPanel panel = new VerticalPanel(); setWidget(panel); panel.addStyleName("gss-TabPanelBottom"); userTable.addStyleName("gss-permList"); userTable.setWidget(0, 0, new Label("Username:")); userTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels"); suggestBox.getTextBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if (selectedUser != null && selectedUser.endsWith("@")) updateSuggestions(); } }); suggestBox.addKeyUpHandler(new KeyUpHandler() { @Override public void onKeyUp(KeyUpEvent event) { // Ignore the arrow keys. int keyCode = event.getNativeKeyCode(); if (keyCode == KeyCodes.KEY_UP || keyCode == KeyCodes.KEY_DOWN || keyCode == KeyCodes.KEY_LEFT || keyCode == KeyCodes.KEY_RIGHT) return; if (keyCode == KeyCodes.KEY_ESCAPE) { suggestBox.hideSuggestionList(); return; } String text = suggestBox.getText().trim(); // Avoid useless queries for keystrokes that do not modify the // text. if (text.equals(selectedUser)) return; selectedUser = text; // Go to the server only if the user typed the @ character. if (selectedUser.endsWith("@")) updateSuggestions(); } }); suggestBox.getElement().setId("addUser.textBox"); userTable.setWidget(0, 1, suggestBox); panel.add(userTable); HorizontalPanel buttons = new HorizontalPanel(); Button ok = new Button("OK", new ClickHandler() { @Override public void onClick(ClickEvent event) { addUser(); hide(); } }); ok.getElement().setId("addUser.button.ok"); buttons.add(ok); buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER); // Create the 'Cancel' button, along with a listener that hides the // dialog when the button is clicked. Button cancel = new Button("Cancel", new ClickHandler() { @Override public void onClick(ClickEvent event) { hide(); } }); cancel.getElement().setId("addUser.button.cancel"); buttons.add(cancel); buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER); buttons.setSpacing(8); buttons.addStyleName("gss-TabPanelBottom"); panel.add(buttons); panel.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER); panel.addStyleName("gss-DialogBox"); }
From source file:org.jboss.errai.demo.grocery.client.local.Form.java
License:Apache License
@PostConstruct protected void setupSuggestions() { MultiWordSuggestOracle iso = (MultiWordSuggestOracle) name.getSuggestOracle(); for (Item i : em.createNamedQuery("allItems", Item.class).getResultList()) { iso.add(i.getName());//from w w w. j a va 2s . co m } MultiWordSuggestOracle dso = (MultiWordSuggestOracle) department.getSuggestOracle(); for (Department d : em.createNamedQuery("allDepartments", Department.class).getResultList()) { dso.add(d.getName()); } name.getValueBox().addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { if ("0px".equals(otherFields.getStyle().getHeight())) { new Animation() { @Override protected void onUpdate(double progress) { otherFields.getStyle().setHeight(Window.getClientWidth() > 768 ? 215 : 145 * progress, PX); } }.run(1000); } } }); hideOtherFields(); handlerRegistration = addEnterKeyHandler(); }
From source file:org.jbpm.designer.client.popup.AssignmentListItemWidget.java
License:Apache License
/** * Initializes an 'EditableListBox' control, which is a combination of * a ValueListBox<String> and a TextBox used to set values via a drop-down * and also allow new custom values to be added and edited. * * @param listBox// w w w . j a va 2s. c o m * @param textBox * @param bQuoteStringValues * @param customPrompt * @param placeholder */ private void initEditableListBox(final ValueListBox<String> listBox, final TextBox textBox, final boolean bQuoteStringValues, final String customPrompt, final String placeholder) { textBox.setVisible(false); textBox.setPlaceholder(placeholder); listBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> valueChangeEvent) { String newValue = valueChangeEvent.getValue(); if (customPrompt.equals(newValue)) { // "Custom..." selected, show textBox with empty value setModelValue(listBox, ""); setModelValue(textBox, ""); listBox.setVisible(false); textBox.setVisible(true); textBox.setFocus(true); } else if (newValue.startsWith("*")) { // Not a valid value setModelValue(listBox, ""); setModelValue(textBox, ""); } else if (newValue.startsWith(EDIT_PREFIX)) { // "Edit <value> ..." selected, show textBox with appropriate value String quotedValue = getModelValue(listBox); String unquotedValue = AssignmentData.createUnquotedConstant(quotedValue); setModelValue(textBox, unquotedValue); listBox.setVisible(false); textBox.setVisible(true); textBox.setFocus(true); } else if (getListBoxValues(listBox).isCustomValue(newValue)) { // A Custom value has been selected String textValue = newValue; if (bQuoteStringValues) { String unquotedValue = AssignmentData.createUnquotedConstant(newValue); textValue = unquotedValue; } setModelValue(listBox, newValue); setModelValue(textBox, textValue); } else if (newValue != null) { // A non-custom value has been selected setModelValue(listBox, newValue); setModelValue(textBox, ""); } updateListBoxValues(listBox); } }); listBox.addDomHandler(new FocusHandler() { @Override public void onFocus(FocusEvent focusEvent) { updateListBoxValues(listBox); } }, FocusEvent.getType()); textBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent focusEvent) { setCurrentTextValue(textBox, textBox.getValue()); } }); textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent blurEvent) { // Update ListBoxValues and set model values when textBox loses focus String value = textBox.getValue(); if (value != null) { if (!bQuoteStringValues) { value = value.trim(); } if (!value.isEmpty()) { String oldValue = getCurrentTextValue(textBox); addValueToListBoxValues(listBox, value, oldValue, bQuoteStringValues); } if (bQuoteStringValues) { value = AssignmentData.createQuotedConstant(value); } // Set the value even if it's "" setModelValue(textBox, value); setModelValue(listBox, value); setCurrentTextValue(textBox, value); } textBox.setVisible(false); listBox.setVisible(true); } }); }
From source file:org.jbpm.designer.client.util.ComboBoxViewImpl.java
License:Apache License
@Override public void init(final ComboBoxView.ComboBoxPresenter presenter, final ComboBoxView.ModelPresenter modelPresenter, final ValueListBox<String> listBox, final TextBox textBox, final String placeholder) { this.presenter = presenter; this.modelPresenter = modelPresenter; this.listBox = listBox; this.textBox = textBox; this.textBox.setPlaceholder(placeholder); textBox.setVisible(false);/*from w ww . ja va 2 s .c om*/ listBox.addValueChangeHandler(new ValueChangeHandler<String>() { @Override public void onValueChange(ValueChangeEvent<String> valueChangeEvent) { presenter.listBoxValueChanged(valueChangeEvent.getValue()); } }); // call listBoxGotFocus in MouseDownHandler because IE11 doesn't handle FocusHandler correctly // this works for all browsers listBox.addDomHandler(new MouseDownHandler() { @Override public void onMouseDown(MouseDownEvent mouseDownEvent) { if (!listBoxHasFocus) { listBoxHasFocus = true; listBoxGotFocus(); } } }, MouseDownEvent.getType()); listBox.addDomHandler(new BlurHandler() { @Override public void onBlur(BlurEvent blurEvent) { listBoxHasFocus = false; } }, BlurEvent.getType()); textBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent focusEvent) { textBoxGotFocus(); } }); textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent blurEvent) { // Update ListBoxValues and set model values when textBox loses focus textBoxLostFocus(); } }); }
From source file:org.jbpm.form.builder.ng.model.client.form.editors.HeaderInplaceEditor.java
License:Apache License
public HeaderInplaceEditor(final HeaderFormItem item) { final HorizontalPanel editPanel = new HorizontalPanel(); editPanel.setBorderWidth(1);/* ww w . j a va 2s. c om*/ textBox.setValue(item.getHeader().getText()); textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { wrapper.setValue(false); item.reset(); } }); textBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { wrapper.setValue(true); } }); textBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Map<String, Object> dataSnapshot = new HashMap<String, Object>(); dataSnapshot.put("item", item); dataSnapshot.put("oldValue", item.getHeader().getText()); dataSnapshot.put("newValue", textBox.getValue()); bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() { @Override public void undoAction(UndoableEvent event) { HeaderFormItem myItem = (HeaderFormItem) event.getData("item"); String value = (String) event.getData("oldValue"); myItem.setContent("<h1>" + value + "</h1>"); } @Override public void onEvent(UndoableEvent event) { } @Override public void doAction(UndoableEvent event) { HeaderFormItem myItem = (HeaderFormItem) event.getData("item"); String value = (String) event.getData("newValue"); myItem.setContent("<h1>" + value + "</h1>"); } })); item.reset(); } }); editPanel.add(textBox); textBox.setWidth(item.getHeader().getOffsetWidth() + "px"); textBox.setFocus(true); add(editPanel); }
From source file:org.jbpm.form.builder.ng.model.client.form.editors.HTMLFormItemEditor.java
License:Apache License
public HTMLFormItemEditor(HTMLFormItem formItem) { this.formItem = formItem; HorizontalPanel buttonPanel = new HorizontalPanel(); editorArea.setValue(this.formItem.getHtmlContent()); editorArea.addBlurHandler(new BlurHandler() { @Override//from www. ja v a 2 s . c om public void onBlur(BlurEvent event) { wrapper.setValue(false); } }); editorArea.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { wrapper.setValue(true); } }); editorArea.unsinkEvents(Event.ONKEYPRESS | Event.ONMOUSEUP | Event.ONDBLCLICK | Event.ONCONTEXTMENU); this.htmlButton.setEnabled(false); buttonPanel.add(createTextButton()); buttonPanel.add(createHtmlButton()); editorArea.setCharacterWidth(50); editorArea.setVisibleLines(5); panel.add(buttonPanel); panel.add(editorArea); panel.add(createDoneButton()); add(panel); }
From source file:org.jbpm.form.builder.ng.model.client.form.editors.LabelInplaceEditor.java
License:Apache License
public LabelInplaceEditor(final LabelFormItem item) { final HorizontalPanel editPanel = new HorizontalPanel(); editPanel.setBorderWidth(1);//from w w w.j a va 2s.c o m textBox.setValue(item.getLabel().getText()); textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { wrapper.setValue(false); item.reset(); } }); textBox.addFocusHandler(new FocusHandler() { @Override public void onFocus(FocusEvent event) { wrapper.setValue(true); } }); textBox.addChangeHandler(new ChangeHandler() { @Override public void onChange(ChangeEvent event) { Map<String, Object> dataSnapshot = new HashMap<String, Object>(); dataSnapshot.put("item", item); dataSnapshot.put("oldValue", item.getLabel().getText()); dataSnapshot.put("newValue", textBox.getValue()); bus.fireEvent(new UndoableEvent(dataSnapshot, new UndoableHandler() { @Override public void undoAction(UndoableEvent event) { LabelFormItem myItem = (LabelFormItem) event.getData("item"); String value = (String) event.getData("oldValue"); myItem.getLabel().setText(value); } @Override public void onEvent(UndoableEvent event) { } @Override public void doAction(UndoableEvent event) { LabelFormItem myItem = (LabelFormItem) event.getData("item"); String value = (String) event.getData("newValue"); myItem.getLabel().setText(value); } })); item.reset(); } }); editPanel.add(textBox); textBox.setWidth(item.getLabel().getOffsetWidth() + "px"); textBox.setFocus(true); add(editPanel); }