コード例 #1
0
 /**
  * @param textBox
  * @param formatter
  */
 protected MaskedTextBox(TextBox textBox) {
   String id = textBox.getElement().getId();
   if (id == null || id.length() == 0) {
     textBox.getElement().setId(generateNewId());
   }
   this.textBox = textBox;
   this.textBox.setStyleName(DEFAULT_STYLE_NAME);
   initWidget(this.textBox);
   PasteEventSourceRegisterFactory.getRegister()
       .registerPasteEventSource(this, this.textBox.getElement());
 }
コード例 #2
0
  public InlineMultiSelect() {
    popup.setAutoHideEnabled(true);
    popup.addAutoHidePartner(textbox.getElement());

    multiSelect.addValueChangeHandler(
        new ValueChangeHandler<List<String>>() {

          @Override
          public void onValueChange(ValueChangeEvent<List<String>> event) {
            int size = event.getValue().size();
            textbox.setText(size + " selected");
          }
        });
    popup.add(multiSelect);

    textbox.setText("Make a selection");
    textbox.setReadOnly(true);
    panel.add(textbox);
    panel.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            popup.showRelativeTo(panel);
          }
        });

    initWidget(panel);
  }
コード例 #3
0
ファイル: TextBox.java プロジェクト: alkacon/geranium
  /** Constructs a new instance of this widget. */
  public TextBox() {

    setEnabled(true);
    m_textbox.setStyleName(CSS.textBox());
    m_textbox.getElement().setId("CmsTextBox_" + (idCounter++));

    TextBoxHandler handler = new TextBoxHandler("");
    m_textbox.addMouseOverHandler(handler);
    m_textbox.addMouseOutHandler(handler);
    m_textbox.addFocusHandler(handler);
    m_textbox.addBlurHandler(handler);
    m_textbox.addValueChangeHandler(handler);
    m_textbox.addKeyPressHandler(handler);

    m_handler = handler;

    m_textboxContainer.setStyleName(CSS.textBoxPanel());
    m_textboxContainer.addStyleName(I_LayoutBundle.INSTANCE.generalCss().cornerAll());
    m_textboxContainer.addStyleName(I_LayoutBundle.INSTANCE.generalCss().textMedium());
    m_panel.add(m_textboxContainer);
    m_panel.add(m_error);
    m_textboxContainer.add(m_textbox);
    m_textboxContainer.setPaddingX(4);
    sinkEvents(Event.ONPASTE);
    initWidget(m_panel);
  }
コード例 #4
0
ファイル: createChat.java プロジェクト: nievesbq/webAppClient
  public void run(final RootPanel rp, final String nick) {

    if (Cookies.getCookie(nick) == null) Cookies.setCookie(nick, "" + 0);

    cl.setPageSize(500);

    final Button sendMessage =
        new Button(
            "sendMessage",
            new ClickHandler() {

              public void onClick(ClickEvent event) {

                if (!message.getText().equals("")) {
                  new Post().postJson(SERVERURL, nick.toString(), message.getText());
                  message.setText("");
                }
              }
            });

    rp.get("mainDiv2").setVisible(true);
    message.getElement().setAttribute("placeholder", "Introduce your message");
    message.getElement().setAttribute("id", "message");

    cl.getElement().setAttribute("id", "chatBox");

    sendMessage.getElement().setAttribute("id", "sendMessage");
    sendMessage.setText("Send");

    vp.getElement().setAttribute("id", "verticalPanel");
    hp.getElement().setAttribute("id", "horizontalPanel");

    panel.getElement().setAttribute("id", "scroller");

    hp.add(message);
    hp.add(sendMessage);
    panel.add(cl);
    vp.add(panel);

    vp.add(hp);
    rp.get("mainDiv2").add(vp);

    Timer t =
        new Timer() {
          @Override
          public void run() {
            getMessages();

            if (chatList != null && Integer.parseInt(Cookies.getCookie(nick)) < chatList.size()) {
              cl.setRowCount(chatList.size() + 1, true);
              cl.setRowData(
                  Integer.parseInt(Cookies.getCookie(nick)),
                  chatList.subList(Integer.parseInt(Cookies.getCookie(nick)), chatList.size()));
              panel.setVerticalScrollPosition(panel.getMaximumVerticalScrollPosition() - 1);
              Cookies.setCookie(nick, "" + chatList.size());
            }
          }
        };
    t.scheduleRepeating(1000);
  }
コード例 #5
0
  /**
   * Internal method which is called when the user clicks on an editable title field.
   *
   * <p>
   */
  protected void editTitle() {

    m_title.setVisible(false);
    final TextBox box = new TextBox();
    box.setText(m_title.getText());
    box.getElement().setAttribute("size", "45");
    box.addStyleName(I_CmsInputLayoutBundle.INSTANCE.inputCss().labelInput());
    box.addStyleName(I_CmsLayoutBundle.INSTANCE.listItemWidgetCss().titleInput());
    final String originalTitle = m_title.getText();
    // wrap the boolean flag in an array so we can change it from the event handlers
    final boolean[] checked = new boolean[] {false};

    box.addBlurHandler(
        new BlurHandler() {

          /**
           * @see
           *     com.google.gwt.event.dom.client.BlurHandler#onBlur(com.google.gwt.event.dom.client.BlurEvent)
           */
          public void onBlur(BlurEvent event) {

            if (checked[0]) {
              return;
            }

            onEditTitleTextBox(box);
            checked[0] = true;
          }
        });

    box.addKeyPressHandler(
        new KeyPressHandler() {

          /**
           * @see
           *     com.google.gwt.event.dom.client.KeyPressHandler#onKeyPress(com.google.gwt.event.dom.client.KeyPressEvent)
           */
          public void onKeyPress(KeyPressEvent event) {

            if (checked[0]) {
              return;
            }

            int keycode = event.getNativeEvent().getKeyCode();

            if ((keycode == 10) || (keycode == 13)) {
              onEditTitleTextBox(box);
              checked[0] = true;
            }
            if (keycode == 27) {
              box.setText(originalTitle);
              onEditTitleTextBox(box);
              checked[0] = true;
            }
          }
        });
    m_titleRow.insert(box, 1);
    box.setFocus(true);
  }
コード例 #6
0
  public DeleteContentPopup() {
    super(false);
    add(binder.createAndBindUi(this));
    this.setGlassEnabled(true);

    h3Panel.setVisible(false);
    lblRemoving.setVisible(false);
    lblRemoving.getElement().getStyle().setMargin(26, Unit.PX);
    txtConfirmAction.setVisible(false);
    setButtonVisibility(true);
    setElementId();

    txtConfirmAction.addKeyUpHandler(new ValidateConfirmText());
    txtConfirmAction.getElement().getStyle().setColor("#515151");
    txtConfirmAction.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            if (!txtConfirmAction.getText().isEmpty()) {
              if (txtConfirmAction
                  .getText()
                  .toLowerCase()
                  .equalsIgnoreCase(i18n.GL1175().toLowerCase())) {
                txtConfirmAction.setText("");
                txtConfirmAction.getElement().getStyle().setColor("#000000");
              }
            }
          }
        });

    txtConfirmAction.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            if (txtConfirmAction.getText().isEmpty()) {
              txtConfirmAction.getElement().getStyle().setColor("#515151");
            }
          }
        });
    StringUtil.setAttributes(txtConfirmAction, true);
    btnNegitive.setText(StringUtil.generateMessage(i18n.GL0142()));
    btnNegitive.getElement().setAttribute("alt", StringUtil.generateMessage(i18n.GL0142()));
    btnNegitive.getElement().setAttribute("title", StringUtil.generateMessage(i18n.GL0142()));

    btnPositive.setText(StringUtil.generateMessage(i18n.GL0190()));
    btnPositive.getElement().setAttribute("alt", StringUtil.generateMessage(i18n.GL0190()));
    btnPositive.getElement().setAttribute("title", StringUtil.generateMessage(i18n.GL0190()));

    /*lblDeleteText.setText(i18n.GL2189());
    StringUtil.setAttributes(lblDeleteText.getElement(), "lblDeleteText", null, "lblDeleteText");*/

    Window.enableScrolling(false);
    AppClientFactory.fireEvent(new SetHeaderZIndexEvent(98, false));
    this.center();
  }
コード例 #7
0
 @Inject
 public ZipImporterPageViewImpl(
     ProjectImporterResource resource, ZipImporterPageViewImplUiBinder uiBinder) {
   style = resource.zipImporterPageStyle();
   style.ensureInjected();
   initWidget(uiBinder.createAndBindUi(this));
   projectName.getElement().setAttribute("maxlength", "32");
   projectDescription.getElement().setAttribute("maxlength", "256");
 }
コード例 #8
0
  @Inject
  public AddCollectionView() {
    setWidget(uiBinder.createAndBindUi(this));
    hideText.setText(i18n.GL0592());
    hideText.getElement().setId("lblHideText");
    hideText.getElement().setAttribute("alt", i18n.GL0592());
    hideText.getElement().setAttribute("title", i18n.GL0592());

    addcollectionText.getElement().setInnerHTML(i18n.GL0690());
    addcollectionText.getElement().setId("pnlAddcollectionText");
    addcollectionText.getElement().setAttribute("alt", i18n.GL0690());
    addcollectionText.getElement().setAttribute("title", i18n.GL0690());

    renameText.setText(i18n.GL0593());
    renameText.getElement().setId("lblRenameText");
    renameText.getElement().setAttribute("alt", i18n.GL0593());
    renameText.getElement().setAttribute("title", i18n.GL0593());

    addToShelfCollectionButton.setText(i18n.GL0590());
    addToShelfCollectionButton.getElement().setId("btnAddToShelfCollectionButton");
    addToShelfCollectionButton.getElement().setAttribute("alt", i18n.GL0590());
    addToShelfCollectionButton.getElement().setAttribute("title", i18n.GL0590());

    collectionAddedSuccessMessageContainer.setVisible(false);
    getAddToShelfCollectionButton().addClickHandler(new OnAddCollectionClick());
    collectionTitleInCoverPage.addKeyUpHandler(new onKeyErrorMsg());
    workSpaceLink.setText(i18n.GL0589());
    workSpaceLink.getElement().setId("lnkWorkSpaceLink");
    workSpaceLink.getElement().setAttribute("alt", i18n.GL0589());
    workSpaceLink.getElement().setAttribute("title", i18n.GL0589());

    addToCollectionWidgetContainer.getElement().setId("pnlAddToCollectionWidgetContainer");
    collectionAddImageContainer.getElement().setId("pnlCollectionAddImageContainer");
    addResourceInsteadLabelContainerInCollectionImage
        .getElement()
        .setId("pnlAddResourceInsteadLabelContainerInCollectionImage");
    collectionAddedSuccessMessageContainer
        .getElement()
        .setId("pnlCollectionAddedSuccessMessageContainer");
    successMessageLabelText.getElement().setId("lblSuccessMessageLabelText");
    addCollectionInsteadLabelContainer.getElement().setId("pnlAddCollectionInsteadLabelContainer");
    collectionTitleInCoverPage.getElement().setId("txtCollectionTitleInCoverPage");
    StringUtil.setAttributes(collectionTitleInCoverPage, true);
    addingLabel.getElement().setId("lblAddingLabel");
    addErrorLabel.getElement().setId("errlblAddErrorLabel");
    hideButton.getElement().setId("epnlHideButton");
  }
コード例 #9
0
  public EditClassContentView() {
    setWidget(uiBinder.createAndBindUi(this));
    setId();
    saveBtn.setEnabled(false);
    saveBtn.addStyleName(CssTokens.DISABLED);
    coursePanel.setVisible(false);
    errorLabel.setVisible(false);

    scoreTextBox.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            String score = scoreTextBox.getText();
            if (!scoreTextBox.isReadOnly()) {
              if (score.isEmpty()) {
                errorLabel.setText("Please enter the minimum score");
                errorLabel.getElement().getStyle().setColor("orange");
                errorLabel.setVisible(true);
                saveEnabled(false);
                saveBtn.addStyleName(CssTokens.DISABLED);
              } else if (score != null || score != "") {
                if (Integer.parseInt(score) > 100 || Integer.parseInt(score) < 0) {
                  errorLabel.setText(i18n.GL3425());
                  errorLabel.getElement().getStyle().setColor("orange");
                  errorLabel.setVisible(true);
                  saveEnabled(false);
                  saveBtn.addStyleName(CssTokens.DISABLED);
                } else {
                  miniScore = Integer.valueOf(score);
                  saveEnabled(true);
                  saveBtn.removeStyleName(CssTokens.DISABLED);
                  errorLabel.setVisible(false);
                }
              }
            }
          }
        });
    scoreTextBox.setMaxLength(3);
    scoreTextBox.getElement().setAttribute("maxlength", "3");
    scoreTextBox.addKeyPressHandler(new NumbersOnly());
    createCourseBtn.addClickHandler(new AddCourseHandler());
  }
コード例 #10
0
  private void setElementId() {
    btnPositive.getElement().setId("btnPositive");
    btnNegitive.getElement().setId("btnNegitive");
    lblTitle.getElement().setId("lblTitle");
    txtConfirmAction.getElement().setId("txtConfirmAction");
    lblRemoving.getElement().setId("lblRemoving");
    closeBtn.getElement().getStyle().setCursor(Cursor.POINTER);

    h5Panel.setText("Warning: this cannot be undone");
    paragraphPnl.setText("Please type in delete");
    chkBoxList.add(chkBox1);
    chkBoxList.add(chkBox2);
    chkBoxList.add(chkBox3);

    chkBox1.getElement().setId("checkboxG12");
    chkBox2.getElement().setId("checkboxG13");
    chkBox3.getElement().setId("checkboxG14");

    checkboxG12.getElement().setAttribute("for", "checkboxG12");
    checkboxG13.getElement().setAttribute("for", "checkboxG13");
    checkboxG14.getElement().setAttribute("for", "checkboxG14");

    chkBox1.setValue(false);
    chkBox2.setValue(false);
    chkBox3.setValue(false);
    if (AppClientFactory.getPlaceManager()
        .getCurrentPlaceRequest()
        .getNameToken()
        .equals(PlaceTokens.EDIT_CLASS)) {
      checkboxG12.setText(i18n.GL3575());
      checkboxG13.setText(i18n.GL3576());
      checkboxG14.setText(i18n.GL3577());
      checkboxG13.getElement().getStyle().setLineHeight(18, Unit.PX);
    } else {
      checkboxG12.setText(i18n.GL3579());
      checkboxG13.setText(i18n.GL3573());
      checkboxG14.setText(i18n.GL3574());
    }
  }
コード例 #11
0
ファイル: DateBox.java プロジェクト: Ondenge/imogene
  /**
   * Create a new date box.
   *
   * @param date the default date.
   * @param picker the picker to drop down from the date box
   * @param format to use to parse and format dates
   */
  public DateBox(DatePicker picker, Date date, Format format) {
    this.picker = picker;
    this.popup = new PopupPanel(true);
    assert format != null : "You may not construct a date box with a null format";
    this.format = format;

    popup.addAutoHidePartner(box.getElement());
    popup.setWidget(picker);
    popup.setStyleName("dateBoxPopup");

    initWidget(box);
    setStyleName(DEFAULT_STYLENAME);

    handler = new DateBoxHandler();
    picker.addValueChangeHandler(handler);
    box.addFocusHandler(handler);
    box.addBlurHandler(handler);
    box.addClickHandler(handler);
    box.addKeyDownHandler(handler);
    box.setDirectionEstimator(false);
    popup.addCloseHandler(handler);
    setValue(date);
  }
コード例 #12
0
  private ToolStrip toolstripButtons() {

    final TextBox filter = new TextBox();
    filter.setMaxLength(30);
    filter.setVisibleLength(20);
    filter.getElement().setAttribute("style", "float:right; width:120px;");
    filter.addKeyUpHandler(
        keyUpEvent -> {
          String word = filter.getText();
          if (word != null && word.trim().length() > 0) {
            filter(word);
          } else {
            clearFilter();
          }
        });

    ToolStrip topLevelTools = new ToolStrip();

    final HTML label = new HTML(Console.CONSTANTS.commom_label_filter() + ":&nbsp;");
    label.getElement().setAttribute("style", "padding-top:8px;");
    topLevelTools.addToolWidget(label);
    topLevelTools.addToolWidget(filter);

    enableBtn =
        new ToolButton(Console.CONSTANTS.common_label_enable(), event -> presenter.enable());
    disableBtn =
        new ToolButton(Console.CONSTANTS.common_label_disable(), event -> presenter.disable());
    refreshBtn =
        new ToolButton(Console.CONSTANTS.common_label_refresh(), event -> presenter.loadChanges());

    topLevelTools.addToolButtonRight(enableBtn);
    topLevelTools.addToolButtonRight(disableBtn);
    topLevelTools.addToolButtonRight(refreshBtn);

    return topLevelTools;
  }
コード例 #13
0
 @Override
 public void setPlaceholder(String placeholder) {
   itemBox.getElement().setAttribute("placeholder", placeholder);
 }
コード例 #14
0
 @Override
 public String getPlaceholder() {
   return itemBox.getElement().getAttribute("placeholder");
 }
コード例 #15
0
  /** Generate and build the List Items to be set on Auto Complete box. */
  private void generateAutoComplete(SuggestOracle suggestions) {
    list.setStyleName("multiValueSuggestBox-list");
    this.suggestions = suggestions;
    final ListItem item = new ListItem();

    item.setStyleName("multiValueSuggestBox-input-token");
    final SuggestBox box = new SuggestBox(suggestions, itemBox);
    String autocompleteId = DOM.createUniqueId();
    itemBox.getElement().setId(autocompleteId);

    item.add(box);
    list.add(item);

    itemBox.addKeyDownHandler(
        new KeyDownHandler() {
          public void onKeyDown(KeyDownEvent event) {
            boolean itemsChanged = false;

            switch (event.getNativeKeyCode()) {
              case KeyCodes.KEY_ENTER:
                if (directInputAllowed) {
                  String value = itemBox.getValue();
                  if (value != null && !(value = value.trim()).isEmpty()) {
                    gwt.material.design.client.base.Suggestion directInput =
                        new gwt.material.design.client.base.Suggestion();
                    directInput.setDisplay(value);
                    directInput.setSuggestion(value);
                    itemsChanged = addItem(directInput);
                    itemBox.setValue("");
                    itemBox.setFocus(true);
                  }
                }
                break;

              case KeyCodes.KEY_BACKSPACE:
                if (itemBox.getValue().trim().isEmpty()) {
                  if (itemsHighlighted.isEmpty()) {
                    if (suggestionMap.size() > 0) {

                      ListItem li = (ListItem) list.getWidget(list.getWidgetCount() - 2);
                      MaterialChip p = (MaterialChip) li.getWidget(0);

                      Set<Entry<Suggestion, MaterialChip>> entrySet = suggestionMap.entrySet();
                      for (Entry<Suggestion, MaterialChip> entry : entrySet) {
                        if (p.equals(entry.getValue())) {
                          suggestionMap.remove(entry.getKey());
                          itemsChanged = true;
                          break;
                        }
                      }

                      list.remove(li);
                    }
                  }
                }

              case KeyCodes.KEY_DELETE:
                if (itemBox.getValue().trim().isEmpty()) {
                  for (ListItem li : itemsHighlighted) {
                    li.removeFromParent();
                    MaterialChip p = (MaterialChip) li.getWidget(0);

                    Set<Entry<Suggestion, MaterialChip>> entrySet = suggestionMap.entrySet();
                    for (Entry<Suggestion, MaterialChip> entry : entrySet) {
                      if (p.equals(entry.getValue())) {
                        suggestionMap.remove(entry.getKey());
                        itemsChanged = true;
                        break;
                      }
                    }
                  }
                  itemsHighlighted.clear();
                }
                itemBox.setFocus(true);
                break;
            }

            if (itemsChanged) {
              ValueChangeEvent.fire(MaterialAutoComplete.this, getValue());
            }
          }
        });

    itemBox.addClickHandler(
        new ClickHandler() {
          @Override
          public void onClick(ClickEvent event) {
            box.showSuggestionList();
          }
        });

    box.addSelectionHandler(
        new SelectionHandler<SuggestOracle.Suggestion>() {
          public void onSelection(SelectionEvent<SuggestOracle.Suggestion> selectionEvent) {
            Suggestion selectedItem = selectionEvent.getSelectedItem();
            itemBox.setValue("");
            if (addItem(selectedItem)) {
              ValueChangeEvent.fire(MaterialAutoComplete.this, getValue());
            }
            itemBox.setFocus(true);
          }
        });

    panel.add(list);
    panel
        .getElement()
        .setAttribute("onclick", "document.getElementById('" + autocompleteId + "').focus()");
    panel.add(lblError);
    box.setFocus(true);
  }
コード例 #16
0
ファイル: AsyncClient.java プロジェクト: pslegr/errai
  public void onModuleLoad() {
    final HorizontalPanel hPanel = new HorizontalPanel();
    final Label messagesReceived = new Label("Messaged Received: ");
    final Label messagesReceivedVal = new Label();

    class Counter {
      int count = 0;

      public void increment() {
        messagesReceivedVal.setText(String.valueOf(++count));
      }
    }

    final Counter counter = new Counter();

    for (int i = 0; i < 7; i++) {
      final VerticalPanel panel = new VerticalPanel();

      final Button startStopButton = new Button("Start" + i);
      final TextBox resultBox = new TextBox();
      resultBox.setEnabled(false);

      final String receiverName = "RandomNumberReceiver" + i;

      final Style resultStyle = resultBox.getElement().getStyle();

      /** Create a callback receiver to receive the data from the server. */
      final MessageCallback receiver =
          new MessageCallback() {
            public void callback(Message message) {
              counter.increment();
              Double value = message.get(Double.class, "Data");
              resultBox.setText(String.valueOf(value));

              if (value > 0.5d) {
                resultStyle.setProperty("backgroundColor", "green");
              } else {
                resultStyle.setProperty("backgroundColor", "red");
              }
            }
          };

      /** Subscribe to the receiver using the recevierName. */
      ErraiBus.get().subscribe(receiverName, receiver);

      final int num = i;

      startStopButton.addClickHandler(
          new ClickHandler() {
            public void onClick(ClickEvent clickEvent) {
              /** Send a message to Start/Stop the task on the server. */
              MessageBuilder.createMessage()
                  .toSubject("AsyncService")
                  .command(startStopButton.getText())
                  .with(MessageParts.ReplyTo, receiverName)
                  .noErrorHandling()
                  .sendNowWith(ErraiBus.get());

              /**
               * Flip-flop the value of the button every time it's pushed between 'Start' and 'Stop'
               */
              startStopButton.setText(
                  ("Start" + num).equals(startStopButton.getText()) ? "Stop" + num : "Start" + num);
            }
          });

      panel.add(startStopButton);
      panel.add(resultBox);

      hPanel.add(panel);
    }

    final VerticalPanel outerPanel = new VerticalPanel();
    outerPanel.add(hPanel);

    final HorizontalPanel messageCounter = new HorizontalPanel();
    messageCounter.add(messagesReceived);
    messageCounter.add(messagesReceivedVal);

    outerPanel.add(messageCounter);

    RootPanel.get().add(outerPanel);
  }
コード例 #17
0
ファイル: NumberBoxItem.java プロジェクト: pgier/ballroom
 @Override
 public Element getInputElement() {
   return textBox.getElement();
 }
コード例 #18
0
ファイル: TextBox.java プロジェクト: alkacon/geranium
  /**
   * Returns the HTML id of the internal textbox used by this widget.
   *
   * <p>
   *
   * @return the HTML id of the internal textbox used by this widget
   */
  public String getId() {

    return m_textbox.getElement().getId();
  }
コード例 #19
0
 public void setPlaceHolderText(String string) {
   textBox.getElement().setAttribute("placeholder", string);
 }
コード例 #20
0
ファイル: TabGeographic.java プロジェクト: eENVplus/EUOSME
  /**
   * constructor TabGeographic
   *
   * @return the widget composed by the Geographic Tab
   */
  public TabGeographic() {
    queryButton.setText(constants.runQuery());
    // set style
    titleLabel.removeStyleName("gwt-Label");
    // set form names
    setFormName();

    // initialize widget
    initWidget(uiBinder.createAndBindUi(this));

    // add scroll bars
    dock.getWidgetContainerElement(dock.getWidget(0)).addClassName("auto");
    dock.getWidgetContainerElement(dock.getWidget(0)).getStyle().clearOverflow();
    Element myTable = dock.getElement().getElementsByTagName("table").getItem(0);
    @SuppressWarnings("unused")
    String txt = myTable.getInnerHTML();
    myTable.getStyle().clearPosition();

    if (summaryHTML.getHTML().isEmpty()) summaryHTML.removeFromParent();

    // HTML matchFound = new HTML("<div style=\"height:300px;overflow:auto;\"><div
    // id=\"responseCount\" style=\"display:none;\"><span style=\"font-weight: bold;\">Matches
    // found:</span><span id=\"matchCount\" style=\"display:none;\"></span><div
    // id=\"matches\"></div></div>");

    // Workaround to the problem of the map position
    // Issue 366: Google Map widget does not initialize correctly inside a LayoutPanel
    if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("google")) {
      map = new com.google.gwt.maps.client.MapWidget();
      nativeMakeMap(
          map.getElement(),
          geoBoundsObj.newTextBoxNorth.getElement(),
          geoBoundsObj.newTextBoxEast.getElement(),
          geoBoundsObj.newTextBoxSouth.getElement(),
          geoBoundsObj.newTextBoxWest.getElement(),
          queryTextBox.getElement());
      mapPanel.add(map);
      // google.maps.event.trigger(map, 'resize');
      // mapPanel.add(matchFound);
      // Event.trigger(mapWidget.getMap(), "resize");
    } else if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) {
      queryPanel.removeFromParent();
      if (mapWidget == null) {
        initMapGwtOl();
        mapPanel.add(mapWidget);
        mapWidget
            .getElement()
            .getFirstChildElement()
            .getStyle()
            .setZIndex(0); // force the map to fall behind popups MG 06.05.2015
      }
    } else {
      queryPanel.removeFromParent();
      sinkEvents(Event.ONMOUSEUP);
      Element map_el = DOM.getElementById("mapstraction");
      mxnMakeMap(map_el, EUOSMEGWT.apiMapstraction);
      mapPanel.getElement().insertFirst(map_el);
    }

    preferredObj.add(country);
    country.myListBox.addChangeHandler(
        new ChangeHandler() {
          @Override
          public void onChange(ChangeEvent event) {
            String selValue = country.myListBox.getValue(country.myListBox.getSelectedIndex());
            if (!selValue.isEmpty()) {
              // selValue contains a value like S:-21.39;W:55.84;N:51.09;E:-63.15
              String[] coordinates = selValue.split(";");
              String south = "";
              String west = "";
              String north = "";
              String east = "";
              for (int i = 0; i < coordinates.length; i++) {
                if (coordinates[i].startsWith("S:")) south = coordinates[i].substring(2);
                if (coordinates[i].startsWith("W:")) west = coordinates[i].substring(2);
                if (coordinates[i].startsWith("N:")) north = coordinates[i].substring(2);
                if (coordinates[i].startsWith("E:")) east = coordinates[i].substring(2);
              }
              if (!north.isEmpty() && !east.isEmpty() && !south.isEmpty() && !west.isEmpty()) {
                geoBoundsObj.newTextBoxSouth.setValue(south);
                geoBoundsObj.newTextBoxWest.setValue(west);
                geoBoundsObj.newTextBoxNorth.setValue(north);
                geoBoundsObj.newTextBoxEast.setValue(east);
                geoBoundsObj.newButton.click();

                // zoom to the country bound
                if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) {
                  Map map = mapWidget.getMap();
                  map.zoomToExtent(
                      new Bounds(
                          Double.parseDouble(west),
                          Double.parseDouble(south),
                          Double.parseDouble(east),
                          Double.parseDouble(north)));
                } else
                  setBoundsMapstraction(
                      Double.parseDouble(south),
                      Double.parseDouble(west),
                      Double.parseDouble(north),
                      Double.parseDouble(east));
              } else Window.alert(constants.geoCodeListError());
            }
          }
        });

    geoBoundsObj.myListBox.addBlurHandler(
        new BlurHandler() {
          @Override
          public void onBlur(BlurEvent event) {
            // refresh the map to avoid shifting cursor
            if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) {
              mapWidget.getMap().setCenter(mapWidget.getMap().getCenter());
            }
          }
        });

    geoBoundsObj.newButton.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // refresh the map to avoid shifting cursor
            if (EUOSMEGWT.apiMapstraction.equalsIgnoreCase("gwt-ol")) {
              mapWidget.getMap().setCenter(mapWidget.getMap().getCenter());
            }
          }
        });
  }
コード例 #21
0
ファイル: TagListWidget.java プロジェクト: gvpinto/gwtia
 @UiHandler("newTag")
 public void onBlur(BlurEvent event) {
   newTag.getElement().getStyle().setColor("gray");
   newTag.setText("..new tag..");
 }
コード例 #22
0
  public NewClasspagePopupView() {

    this.res = NewClasspagePopupCBundle.INSTANCE;
    res.css().ensureInjected();
    setWidget(uiBinder.createAndBindUi(this));
    // this.getElement().getStyle().setWidth(450,Unit.PX);
    btnCancel.addClickHandler(new CloseExistsClickHandler());
    btnAdd.addClickHandler(new AddExistsClickHandler());
    classpageTitleTxt.getElement().setAttribute("placeholder", i18n.GL1124());
    classpageTitleTxt.getElement().setAttribute("maxlength", "50");
    classpageTitleTxt.getElement().setId("txtClassPageTitle");
    StringUtil.setAttributes(classpageTitleTxt, true);
    bodyConatiner.getElement().getStyle().setPadding(15, Unit.PX);
    titlePanel.getElement().getStyle().setMarginBottom(10, Unit.PX);

    btnAdd.getElement().setId("btnAdd");
    btnAdd.setText(i18n.GL0745());
    btnAdd.getElement().setAttribute("alt", i18n.GL0745());
    btnAdd.getElement().setAttribute("title", i18n.GL0745());

    btnCancel.setText(i18n.GL0142());
    btnCancel.getElement().setId("btnCancel");
    btnCancel.getElement().setAttribute("alt", i18n.GL0142());
    btnCancel.getElement().setAttribute("title", i18n.GL0142());

    titlePanel.getElement().setInnerText(i18n.GL0318());
    titlePanel.getElement().setId("pnlTitle");
    titlePanel.getElement().setAttribute("alt", i18n.GL0318());
    titlePanel.getElement().setAttribute("title", i18n.GL0318());

    headerPanel.getElement().setInnerText(i18n.GL0747());
    headerPanel.getElement().setId("pnlHeader");
    headerPanel.getElement().setAttribute("alt", i18n.GL0747());
    headerPanel.getElement().setAttribute("title", i18n.GL0747());
    mandatoryClasspageTitleLbl.setText(i18n.GL0746());
    mandatoryClasspageTitleLbl.getElement().setId("lblMandatoryClasspageTitle");
    mandatoryClasspageTitleLbl.getElement().setAttribute("alt", i18n.GL0746());
    mandatoryClasspageTitleLbl.getElement().setAttribute("title", i18n.GL0746());

    classpageTitleTxt.addBlurHandler(
        new BlurHandler() {

          @Override
          public void onBlur(BlurEvent event) {
            Map<String, String> parms = new HashMap<String, String>();
            parms.put("text", classpageTitleTxt.getText());
            AppClientFactory.getInjector()
                .getResourceService()
                .checkProfanity(
                    parms,
                    new SimpleAsyncCallback<Boolean>() {

                      @Override
                      public void onSuccess(Boolean value) {
                        boolean isHavingBadWords = value;
                        if (value) {
                          classpageTitleTxt.getElement().getStyle().setBorderColor("orange");
                          mandatoryClasspageTitleLbl.setText(i18n.GL0554());
                          mandatoryClasspageTitleLbl.setVisible(true);
                        } else {
                          classpageTitleTxt.getElement().getStyle().clearBackgroundColor();
                          classpageTitleTxt.getElement().getStyle().setBorderColor("#ccc");
                          mandatoryClasspageTitleLbl.setVisible(false);
                        }
                      }
                    });
          }
        });

    classpageTitleTxt.addKeyUpHandler(new TitleKeyUpHandler());
    setModal(true);
    Window.enableScrolling(false);
    AppClientFactory.fireEvent(new SetHeaderZIndexEvent(98, false));
    mandatoryClasspageTitleLbl.setVisible(false);
    //		panelLoading.setVisible(false);
    panelPleaseWait.setVisible(false);
    panelLoading.setText(i18n.GL0122());
    panelControls.setVisible(true);
    show();
    center();
    classpageTitleTxt.setFocus(true);
    panelLoading.getElement().setId("pnlLoading");
    panelControls.getElement().setId("pnlControls");
  }
コード例 #23
0
ファイル: TextBox.java プロジェクト: alkacon/geranium
  /** @see com.alkacon.geranium.client.ui.input.I_HasBlur#blur() */
  public void blur() {

    m_textbox.getElement().blur();
  }
コード例 #24
0
  public void ajouterElement(JSONArray parametres, final int x, final int y, final String type) {

    final FormulaireController gc = FormulaireController.getInstance();
    FormulaireBoard cb = gc.getCheckerBoard();
    Widget element = null;
    TextBox label = new TextBox();
    label.addStyleName("inputLabel");
    JSONValue paramAsJSONValue;
    if (type.equals("text") || type.equals("date") || type.equals("time") || type.equals("chiffre"))
      paramAsJSONValue = parametres.get(0);
    else {
      JSONValue parametresValue = parametres.get(0);
      JSONObject parametresObject = parametresValue.isObject();
      if (parametresObject.get("nom").isString().stringValue().equals("titre"))
        paramAsJSONValue = parametres.get(0);
      else paramAsJSONValue = parametres.get(1);
    }
    JSONObject paramAsJSONObject = paramAsJSONValue.isObject();
    label.setText(paramAsJSONObject.get("valeur").isString().stringValue());
    TextBox choix = null;
    final DroppableElement cellule = (DroppableElement) cb.getCell(x, y);
    cellule.type = type;
    Element elem = new Element(new Position(y, x), "deplace");
    elem.getElement().setClassName(elem.getType() + "Style");
    Image suppression = new Image();
    suppression.setUrl("images/formulaire/delete.png");
    suppression.addStyleName("deleteForm");

    String id = Utils.generateId();
    ;

    // Création de l'element selon le type
    if (type.equals("text")) {
      element = new TextBox();
    }
    if (type.equals("image")) {
      element = new Image("../images/formulaire/Photo.png");
    } else if (type.equals("checkbox")) {
      CheckBox c = new CheckBox();
      // Ajout de l'attribut name pour les champs checkbox et radio
      cellule.name = "" + CHOICE;
      element = c;
      // Ajout du label de choix pour les champs de type checkbox et radio
      choix = new TextBox();
      choix.addStyleName("inputLabel");
      choix.getElement().setAttribute("placeholder", "Choix");

    } else if (type.equals("radio")) {
      RadioButton r = new RadioButton("Choix");
      cellule.name = "" + CHOICE;
      element = r;
      choix = new TextBox();
      choix.addStyleName("inputLabel");
      choix.getElement().setAttribute("placeholder", "Choix");
    } else if (type.equals("combobox")) {
      OPTION++;
      // Ajout de l'option pour les champs de type combobox
      cellule.option = "" + OPTION;
      element = new ListBox();
    } else if (type.equals("chiffre")) {
      element =
          new HTML(
              "<input type='text' class='gwt-TextBox' onkeypress=\"if((event.keyCode < 48 || event.keyCode > 57) && event.keyCode != 46){ event.returnValue=false;}else if(event.keyCode == 46 && (this.value == '' || this.value.indexOf('.') != -1)){ event.returnValue =false;} \" />");
    } else if (type.equals("date")) {
      element = new HTML("<input type='text' id='date" + id + "' class='gwt-TextBox' />");
    } else {
      element = new HTML("<input type='text' id='time" + id + "'  class='gwt-TextBox' />");
    }

    HorizontalPanel hp = cellule.getWidgetElement();

    hp.add(label);
    hp.add(element);
    cellule.choix = false;
    if (type.equals("checkbox") || type.equals("radio") || type.equals("combobox")) {

      JSONValue parametresValue = parametres.get(0);
      JSONObject parametresObject = parametresValue.isObject();
      if (parametresObject.get("nom").isString().stringValue().equals("titre"))
        paramAsJSONValue = parametres.get(1);
      else paramAsJSONValue = parametres.get(0);

      paramAsJSONObject = paramAsJSONValue.isObject();

      String ch[] = paramAsJSONObject.get("valeur").isString().stringValue().split("\\*_\\*");
      if (type.equals("checkbox") || type.equals("radio")) {
        choix.setText(ch[0]);
        for (int i = 1; i < ch.length; i++) {
          DroppableElement.ajouterChoix(x + i, y, type, ch[i]);
        }
        CHOICE++;
      } else {
        for (int i = 0; i < ch.length; i++) {
          ((ListBox) element).addItem(ch[i], ch[i]);
        }
      }
    }

    if (choix != null) hp.add(choix);
    hp.add(elem);
    hp.add(suppression);
    cellule.lock();
    if (type.equals("date") || type.equals("time"))
      FormulaireController.nativeMethod(type + id, type);

    // Action de la suppression
    suppression.addClickHandler(
        new ClickHandler() {
          public void onClick(ClickEvent event) {
            // Vider la cellule
            cellule.clear();
            // Si le champs est de type checkbox ou radio, il faix vider les
            // champs de choix également
            if (type.equals("checkbox") || type.equals("radio")) {
              final FormulaireController gc = FormulaireController.getInstance();
              FormulaireBoard c = gc.getCheckerBoard();
              boolean end = false;
              int ligne = x + 1;
              while (!end) {
                DroppableElement cellule_choix = (DroppableElement) c.getCell(ligne, y);
                if (cellule_choix.choix) {
                  cellule_choix.clear();
                  cellule_choix.type = null;
                  cellule_choix.choix = false;
                  cellule_choix.name = null;
                  cellule_choix.enable();
                  ligne++;
                } else end = true;
              }
            }
            // Rendre le champs capable de recevoir des elements puisqu'on
            // l'a vidé
            cellule.enable();
            cellule.type = null;
          }
        });
  }
コード例 #25
0
ファイル: TagListWidget.java プロジェクト: gvpinto/gwtia
 @UiHandler("newTag")
 public void onFocus(FocusEvent event) {
   newTag.getElement().getStyle().setColor("black");
   newTag.setText("");
 }
コード例 #26
0
  private void showSurveyStatus() {
    content.clear();

    switch (parameters.state) {
      case SUSPENDED:
        content.add(new HTMLPanel("<h1>Survey is suspended</h1>"));
        content.add(
            new HTMLPanel(
                "<h2>Reason</h2><p>"
                    + SafeHtmlUtils.htmlEscape(parameters.suspensionReason)
                    + "</p>"));

        Button resumeButton =
            WidgetFactory.createButton(
                "Resume",
                new ClickHandler() {
                  @Override
                  public void onClick(ClickEvent event) {
                    surveyControl.setParameters(
                        parameters.withState(SurveyState.ACTIVE).withSuspensionReason(""),
                        new AsyncCallback<Void>() {
                          @Override
                          public void onFailure(Throwable caught) {
                            content.clear();
                            content.add(
                                new HTMLPanel("<p>Server error: </p>" + caught.getMessage()));
                          }

                          @Override
                          public void onSuccess(Void result) {
                            Location.reload();
                          }
                        });
                  }
                });

        resumeButton.getElement().addClassName("scran24-admin-button");

        content.add(resumeButton);
        break;
      case NOT_INITIALISED:
        content.add(new HTMLPanel("<h1>Survey has not yet been activated</h1>"));
        content.add(new HTMLPanel("<p>Follow the instructions below to activate the survey."));

        FlowPanel initDiv = new FlowPanel();
        content.add(initDiv);

        initStage1(initDiv);
        break;
      case ACTIVE:
        Date now = new Date();

        boolean showSuspend = true;

        if (now.getTime() < parameters.startDate)
          content.add(new HTMLPanel("<h1>Survey is active, but not yet started</h1>"));
        else if (now.getTime() > parameters.endDate) {
          content.add(new HTMLPanel("<h1>Survey is finished</h1>"));
          showSuspend = false;
        } else content.add(new HTMLPanel("<h1>Survey is running</h1>"));

        content.add(new HTMLPanel("<h2>Start date (inclusive)</h2>"));
        content.add(
            new HTMLPanel(
                "<p>"
                    + DateTimeFormat.getFormat("EEE, MMMM d, yyyy")
                        .format(new Date(parameters.startDate))
                    + "</p>"));

        content.add(new HTMLPanel("<h2>End date (exclusive)</h2>"));
        content.add(
            new HTMLPanel(
                "<p>"
                    + DateTimeFormat.getFormat("EEE, MMMM d, yyyy")
                        .format(new Date(parameters.endDate))
                    + "</p>"));

        if (showSuspend) {

          content.add(new HTMLPanel(SafeHtmlUtils.fromSafeConstant("<h3>Suspend survey</h3>")));
          content.add(
              new HTMLPanel(SafeHtmlUtils.fromSafeConstant("<p>Reason for suspension:</p>")));
          final TextBox reason = new TextBox();
          reason.getElement().getStyle().setWidth(600, Unit.PX);

          Button suspend =
              WidgetFactory.createButton(
                  "Suspend",
                  new ClickHandler() {
                    @Override
                    public void onClick(ClickEvent event) {
                      if (reason.getText().isEmpty()) {
                        Window.alert("Please give a reason for suspension.");
                      } else {
                        surveyControl.setParameters(
                            parameters
                                .withSuspensionReason(reason.getText())
                                .withState(SurveyState.SUSPENDED),
                            new AsyncCallback<Void>() {
                              @Override
                              public void onSuccess(Void result) {
                                Location.reload();
                              }

                              @Override
                              public void onFailure(Throwable caught) {
                                Window.alert("Server error: " + caught.getMessage());
                              }
                            });
                      }
                    }
                  });

          suspend.getElement().addClassName("scran24-admin-button");

          content.add(reason);
          content.add(new HTMLPanel("<p></p>"));
          content.add(suspend);
        }
        break;
    }
  }