Java 类com.google.gwt.user.client.ui.FocusWidget 实例源码

项目:che    文件:UIUtil.java   
/**
 * 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;
}
项目:che    文件:MenuButton.java   
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);
}
项目:firefly    文件:RadioGroupInputField.java   
public FocusWidget getFocusWidget() {
    return _rbs.get(0);
}
项目:firefly    文件:TablePanel.java   
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;
}
项目:atom    文件:InputDialogBox.java   
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);
        }
    }
}
项目:gwtlib    文件:MessageBox.java   
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;
}
项目:che    文件:BaseView.java   
/**
 * 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();
}
项目:che    文件:MenuButton.java   
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();
        }
      });
}
项目:che    文件:View.java   
/**
 * 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());
  }
}
项目:che    文件:View.java   
/**
 * 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;
}
项目:firefly    文件:Form.java   
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);
                }
            }
        }
    });
}
项目:firefly    文件:BaseTableButtonSetter.java   
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);
        }
    }
}
项目:firefly    文件:TablePanel.java   
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");
    }
}
项目:gerrit    文件:StringListPanel.java   
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);
}
项目:gerrit    文件:OnEditEnabler.java   
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);
  }
}
项目:atom    文件:InputDialogBox.java   
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());
}
项目:QMAClone    文件:LobbyUi.java   
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);
}
项目:QMAClone    文件:CreationUi.java   
private void setEnable(boolean enabled) {
  FocusWidget[] widgets = { buttonNewProblem, buttonMoveToVerification, buttonSendProblem,
      textBoxGetProblem, buttonGetProblem, buttonCopyProblem, buttonNextProblem };
  for (FocusWidget widget : widgets) {
    widget.setEnabled(enabled);
  }
  widgetProblemForm.setEnable(enabled);
}
项目:QMAClone    文件:WidgetProblemForm.java   
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);
  }
}
项目:geomajas-project-client-gwt    文件:GraphicsWidget.java   
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);
}
项目:EasyML    文件:ETLGrid.java   
public void lock(){
    for( FocusWidget wgt : paramBoxs ){
        wgt.setEnabled( false );
    }
}
项目:EasyML    文件:ETLGrid.java   
public void unlock(){
    for( FocusWidget wgt : paramBoxs ){
        wgt.setEnabled( true );
    }
}
项目:EasyML    文件:ParameterPanel.java   
public List<FocusWidget> getParamBoxs() {
    return paramBoxs;
}
项目:EasyML    文件:ParameterPanel.java   
public void setParamBoxs(List<FocusWidget> paramBoxs) {
    this.paramBoxs = paramBoxs;
}
项目:EasyML    文件:ParameterPanel.java   
public void lock(){
    for( FocusWidget wgt : paramBoxs ){
        wgt.setEnabled( false );
    }
}
项目:EasyML    文件:ParameterPanel.java   
public void unlock(){
    for( FocusWidget wgt : paramBoxs ){
        wgt.setEnabled( true );
    }
}
项目:cuba    文件:Tools.java   
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);
}
项目:che    文件:BaseView.java   
@Override
public void onBlur(BlurEvent event) {
  if (event.getSource() instanceof FocusWidget) {
    lastFocused = (FocusWidget) event.getSource();
  }
}
项目:che    文件:Window.java   
/** Returns {@code true} if widget is in the focus and {@code false} - otherwise. */
public boolean isWidgetFocused(FocusWidget widget) {
  return view.isElementFocused(widget.getElement());
}
项目:che    文件:View.java   
@Override
public void onBlur(BlurEvent event) {
  if (event.getSource() instanceof FocusWidget) {
    lastFocused = (FocusWidget) event.getSource();
  }
}
项目:firefly    文件:TablePanel.java   
public void addToolButton(FocusWidget btn, boolean alignRight) {
    btn.addStyleName("button");
    addToolWidget(btn, alignRight);
}
项目:firefly    文件:SuggestBoxInputField.java   
@Override
public FocusWidget getFocusWidget() {
    return _inputField.getTextBox();
}
项目:firefly    文件:BaseInputFieldDecorator.java   
@Override
public FocusWidget getFocusWidget() { return _inputField.getFocusWidget(); }
项目:firefly    文件:FileUploadField.java   
public FocusWidget getFocusWidget() {
    return null;
}
项目:firefly    文件:CheckBoxGroupInputField.java   
public FocusWidget getFocusWidget() {
    return _cbs.get(0);
}
项目:gerrit    文件:OnEditEnabler.java   
public OnEditEnabler(FocusWidget w, TextBoxBase tb) {
  this(w);
  originalValue = tb.getValue().trim();
  listenTo(tb);
}
项目:gerrit    文件:OnEditEnabler.java   
public OnEditEnabler(FocusWidget w, ListBox lb) {
  this(w);
  listenTo(lb);
}
项目:gerrit    文件:OnEditEnabler.java   
public OnEditEnabler(FocusWidget w, CheckBox cb) {
  this(w);
  listenTo(cb);
}
项目:gerrit    文件:OnEditEnabler.java   
public OnEditEnabler(FocusWidget w) {
  widget = w;
}
项目:gerrit    文件:CommentedActionDialog.java   
public void setFocusOn(FocusWidget focusWidget) {
  focusOn = focusWidget;
}