/** * Lookup all nested children in widget and tries to search children which implement Focusable * interface. * * @param widget widget to lookup * @return list of {@link com.google.gwt.user.client.ui.Focusable} widgets or empty list if none * was found * @see com.google.gwt.user.client.ui.Focusable */ public static List<FocusWidget> getFocusableChildren(Widget widget) { List<FocusWidget> focusable = new ArrayList<>(); if (widget instanceof FocusWidget) { focusable.add((FocusWidget) widget); } if (widget instanceof HasWidgets) { for (Widget w : ((HasWidgets) widget)) { focusable.addAll(getFocusableChildren(w)); } } return focusable; }
public MenuButton(SafeHtml content, ItemsProvider itemsProvider) { super(); this.itemsProvider = itemsProvider; addStyleName(RESOURCES.css().menuButton()); showMenuTimer = new Timer() { @Override public void run() { showMenu(); } }; final FocusWidget mainButton = new MainButton(content); final FocusWidget dropButton = new DropButton(); add(mainButton); add(dropButton); attachMouseEventHandlers(mainButton); attachMouseEventHandlers(dropButton); }
public FocusWidget getFocusWidget() { return _rbs.get(0); }
public Widget addToolButton(final GeneralCommand cmd, boolean alignRight) { final FocusWidget btn = new Button(cmd.getLabel()); updateHighlighted(btn, cmd); btn.addClickHandler(new ClickHandler() { public void onClick(ClickEvent ev) { cmd.execute(); } }); cmd.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent pce) { if (pce.getPropertyName().equals(GeneralCommand.PROP_TITLE)) { if (btn instanceof HasText) { ((HasText) btn).setText(String.valueOf(pce.getNewValue())); } } else if (pce.getPropertyName().equals(GeneralCommand.PROP_HIGHLIGHT)) { updateHighlighted(btn, cmd); } } }); if (!StringUtils.isEmpty(cmd.getShortDesc())) { btn.setTitle(cmd.getShortDesc()); } addToolButton(btn, alignRight); return btn; }
private void setValueOfInputBox(FocusWidget inputBox, String value) { if(inputBox instanceof TextBox) { ((TextBox) inputBox).setText(value); } else if(inputBox instanceof ListBox) { ListBox listBox = ((ListBox) inputBox); boolean done = false; for(int i=0 ; i < listBox.getItemCount() || done ; i++) { if(listBox.getValue(i).equals(value)) { listBox.setSelectedIndex(i); done = true; } } if(!done) { listBox.addItem(value); listBox.setSelectedIndex(listBox.getItemCount()-1); } } }
public static MessageBox prompt(String caption, String message, boolean asHTML, Widget widget, int buttons, MessageBoxListener listener) { final MessageBox mb = new MessageBox(); mb.setText(caption); mb.setButtons(buttons, listener); mb._dockPanel.add(asHTML ? new HTML(message) : new Label(message), DockPanel.NORTH); mb._dockPanel.add(widget, DockPanel.CENTER); mb.center(); if(widget instanceof FocusWidget) ((FocusWidget)widget).setFocus(true); return mb; }
/** * Sets content widget. * * @param widget content widget */ public final void setContentWidget(Widget widget) { container.add(widget); for (FocusWidget focusWidget : UIUtil.getFocusableChildren(widget)) { focusWidget.addBlurHandler(blurHandler); } focusView(); }
private void attachMouseEventHandlers(FocusWidget widget) { widget.addMouseOutHandler(event -> showMenuTimer.cancel()); widget.addMouseUpHandler(event -> showMenuTimer.cancel()); widget.addMouseDownHandler( event -> { if (event.getNativeButton() == BUTTON_LEFT) { showMenuTimer.schedule(1000); } else { showMenuTimer.cancel(); } }); }
/** * Updates the View to reflect the showing state of the popup. * * @param showing true if showing, false if not. */ protected void setShowing(boolean showing) { // set for each focusable widget blur handler to have ability to store last focused element for (FocusWidget focusWidget : UIUtil.getFocusableChildren(content)) { focusWidget.addBlurHandler(blurHandler); } if (showing) { contentContainer.addStyleName(css.contentVisible()); } else { contentContainer.removeStyleName(css.contentVisible()); } }
/** * Sets focus on the first focusable child if such exists. * * @return <code>true</code> if the focus was set */ private boolean setFocusOnChildOf(Widget widget) { List<FocusWidget> focusableChildren = UIUtil.getFocusableChildren(widget); for (FocusWidget focusableWidget : focusableChildren) { if (focusableWidget.isVisible()) { focusableWidget.setFocus(true); return true; } } return false; }
public void setFocus(final String id) { DeferredCommand.addCommand(new Command(){ public void execute() { InputField f = getField(id); if (f != null) { FocusWidget fw = f.getFocusWidget(); if (fw != null) { fw.setFocus(true); } } } }); }
protected void handleEvent(WebEvent ev) { List<String> sources = getQuerySources(); if (sources == null || sources.size() == 0) return; if (addedMap == null) { addedMap = new HashMap<String, Boolean>(sources.size()); for(String s : sources) { addedMap.put(s, false); } } TablePanel table; if (ev.getData() instanceof TablePanel) { table = (TablePanel) ev.getData(); } else { table = getEventHub().getActiveTable(); } String tblName = table.getName(); if (sources.contains(tblName)) { boolean isAdded = addedMap.get(tblName); if (!isAdded) { FocusWidget b = makeButton(table); table.addToolButton(b, false); addedMap.put(tblName, true); } } }
public static void updateHighlighted(FocusWidget b, GeneralCommand cmd) { if (cmd.isHighlighted()) { b.removeStyleName("button"); b.removeStyleName("normal-text"); b.addStyleName("button-highlight"); b.addStyleName("highlight-text"); } else { b.removeStyleName("button-highlight"); b.removeStyleName("highlight-text"); b.addStyleName("button"); b.addStyleName("normal-text"); } }
public StringListPanel(String title, List<String> fieldNames, FocusWidget w, boolean autoSort) { widget = w; if (title != null) { titlePanel = new HorizontalPanel(); SmallHeading titleLabel = new SmallHeading(title); titlePanel.add(titleLabel); add(titlePanel); } t = new StringListTable(fieldNames, autoSort); add(t); buttonPanel = new HorizontalPanel(); buttonPanel.setStyleName(Gerrit.RESOURCES.css().stringListPanelButtons()); deleteButton = new Button(Gerrit.C.stringListPanelDelete()); deleteButton.setEnabled(false); deleteButton.addClickHandler( new ClickHandler() { @Override public void onClick(ClickEvent event) { widget.setEnabled(true); t.deleteChecked(); } }); buttonPanel.add(deleteButton); add(buttonPanel); }
private void on(GwtEvent<?> e) { if (widget.isEnabled() || !(e.getSource() instanceof FocusWidget) || !((FocusWidget) e.getSource()).isEnabled()) { if (e.getSource() instanceof ValueBoxBase) { final TextBoxBase box = ((TextBoxBase) e.getSource()); Scheduler.get() .scheduleDeferred( new ScheduledCommand() { @Override public void execute() { if (box.getValue().trim().equals(originalValue)) { widget.setEnabled(false); } } }); } return; } if (e.getSource() instanceof TextBoxBase) { onTextBoxBase((TextBoxBase) e.getSource()); } else { // For many widgets, we can assume that a change is an edit. If // a widget does not work that way, it should be special cased // above. widget.setEnabled(true); } }
private String getValueOfInputBox(FocusWidget inputBox) { if(inputBox instanceof TextBox) { return ((TextBox) inputBox).getText(); } else if(inputBox instanceof ListBox) { ListBox listBox = ((ListBox) inputBox); return listBox.getItemText(listBox.getSelectedIndex()); } throw new AtomException("inputBox must be either TextBox or ListBox, but was " + inputBox.toString()); }
private void setEnabled(boolean enabled) { FocusWidget[] widgets = { listBoxLevelNumber, listBoxLevelName, listBoxPrefecture, textBoxPlayerName, textBoxGreeting, listBoxDifficultSelect, listBoxNewProblem, buttonGameVsCom, buttonGameAllClass, buttonGameEvent, buttonGameTheme, textBoxEventName, buttonShowEventRooms, checkBoxPublicEvent, listBoxTheme, buttonShowUserCode, }; for (FocusWidget widget : widgets) { widget.setEnabled(enabled); } multiItemSelectorGenre.setEnabled(enabled); multiItemSelectorType.setEnabled(enabled); }
private void setEnable(boolean enabled) { FocusWidget[] widgets = { buttonNewProblem, buttonMoveToVerification, buttonSendProblem, textBoxGetProblem, buttonGetProblem, buttonCopyProblem, buttonNextProblem }; for (FocusWidget widget : widgets) { widget.setEnabled(enabled); } widgetProblemForm.setEnable(enabled); }
public void setEnable(boolean enabled) { List<FocusWidget> focusWidgets = Lists.newArrayList(listBoxGenre, listBoxType, listBoxRandomFlag, textAreaSentence, textBoxAnswer[0], textBoxAnswer[1], textBoxAnswer[2], textBoxAnswer[3], textBoxChoice[0], textBoxChoice[1], textBoxChoice[2], textBoxChoice[3], radioButtonNone, radioButtonImage, radioButtonYouTube, textBoxExternalUrl, textBoxCreator, textAreaNote, checkBoxResetAnswerCount, checkBoxImageChoice, checkBoxImageAnswer, checkBoxRemovePlayerAnswers, buttonClearProblemFeedback, checkBoxResetVote); focusWidgets.addAll(buttonPolygonCreation); for (FocusWidget focusWidget : focusWidgets) { focusWidget.setEnabled(enabled); } }
public EventWidget(FocusWidget widget) { super(widget); this.widget = widget; // this makes sure the auto-resizing works, see Overflow.VISIBLE javadoc setWidth(INITIAL_SIZE); setHeight(INITIAL_SIZE); }
public void lock(){ for( FocusWidget wgt : paramBoxs ){ wgt.setEnabled( false ); } }
public void unlock(){ for( FocusWidget wgt : paramBoxs ){ wgt.setEnabled( true ); } }
public List<FocusWidget> getParamBoxs() { return paramBoxs; }
public void setParamBoxs(List<FocusWidget> paramBoxs) { this.paramBoxs = paramBoxs; }
public static void showPopup(VOverlay overlay, int left, int top) { overlay.setAutoHideEnabled(true); overlay.setVisible(false); overlay.show(); Widget widget = overlay.getWidget(); if (widget instanceof VVerticalLayout) { resetItemSelection(widget); VVerticalLayout verticalLayout = (VVerticalLayout) widget; if (verticalLayout.getStyleName().contains(CUBA_CONTEXT_MENU_CONTAINER)) { int widgetCount = verticalLayout.getWidgetCount(); if (widgetCount > 1) { Widget verticalSlot = verticalLayout.getWidget(0); Widget buttonWidget = ((Slot) verticalSlot).getWidget(); buttonWidget.addStyleName(SELECTED_ITEM_STYLE); if (buttonWidget instanceof FocusWidget) { ((FocusWidget) buttonWidget).setFocus(true); } } } } // mac FF gets bad width due GWT popups overflow hacks, // re-determine width int offsetWidth = overlay.getOffsetWidth(); int offsetHeight = overlay.getOffsetHeight(); if (offsetWidth + left > Window.getClientWidth()) { left = left - offsetWidth; if (left < 0) { left = 0; } } if (offsetHeight + top > Window.getClientHeight()) { top = top - offsetHeight; if (top < 0) { top = 0; } } overlay.setPopupPosition(left, top); overlay.setVisible(true); }
@Override public void onBlur(BlurEvent event) { if (event.getSource() instanceof FocusWidget) { lastFocused = (FocusWidget) event.getSource(); } }
/** Returns {@code true} if widget is in the focus and {@code false} - otherwise. */ public boolean isWidgetFocused(FocusWidget widget) { return view.isElementFocused(widget.getElement()); }
public void addToolButton(FocusWidget btn, boolean alignRight) { btn.addStyleName("button"); addToolWidget(btn, alignRight); }
@Override public FocusWidget getFocusWidget() { return _inputField.getTextBox(); }
@Override public FocusWidget getFocusWidget() { return _inputField.getFocusWidget(); }
public FocusWidget getFocusWidget() { return null; }
public FocusWidget getFocusWidget() { return _cbs.get(0); }
public OnEditEnabler(FocusWidget w, TextBoxBase tb) { this(w); originalValue = tb.getValue().trim(); listenTo(tb); }
public OnEditEnabler(FocusWidget w, ListBox lb) { this(w); listenTo(lb); }
public OnEditEnabler(FocusWidget w, CheckBox cb) { this(w); listenTo(cb); }
public OnEditEnabler(FocusWidget w) { widget = w; }
public void setFocusOn(FocusWidget focusWidget) { focusOn = focusWidget; }