Exemple #1
0
 @Override
 public String getText() {
   if (titleElement != null) {
     return titleElement.getInnerText();
   }
   return "";
 }
 public void addElement(Element element) {
   sb.append("<").append(element.getTagName());
   // TODO : append attributes
   sb.append(">")
       .append(element.getInnerText())
       .append("</")
       .append(element.getTagName())
       .append(">");
 }
 @Test
 public void checkHTML() {
   RadioButton rb = new RadioButton("myRadioGroup", "<h1>foo</h1>", true);
   Assert.assertEquals("<h1>foo</h1>", rb.getHTML());
   rb.setHTML("<h1>test</h1>");
   Assert.assertEquals("<h1>test</h1>", rb.getHTML());
   // Assert the labelElem value
   Assert.assertEquals(1, rb.getElement().getChild(1).getChildCount());
   Element h1 = (Element) rb.getElement().getChild(1).getChild(0);
   Assert.assertEquals("H1", h1.getTagName());
   Assert.assertEquals("test", h1.getInnerText());
 }
Exemple #4
0
  public String getTabText(int index) {
    Element tab = getTab(index);
    if (tab == null) return null;

    return tab.getInnerText();
  }
 public Button create(Element e) {
   Button button = new Button();
   button.getElement().setInnerText(e.getInnerText());
   WidgetsUtils.replaceOrAppend(e, button);
   return button;
 }
Exemple #6
0
  public CurrencyViewImpl() {

    Element eBasePrefix = DOM.getElementById("baseCurrencyPrefix");
    if (eBasePrefix == null) {
      throw new IllegalStateException("Base Currency Prefix div not found in hosted page");
    }
    baseCurrencyPrefix = eBasePrefix.getInnerText();

    Element eDocPrefix = DOM.getElementById("docCurrencyPrefix");
    if (eDocPrefix == null) {
      throw new IllegalStateException("Doc Currency Prefix div not found in hosted page");
    }
    docCurrencyPrefix = eDocPrefix.getInnerText();

    currencyGrid = new ListGrid();
    currencyGrid.setShowAllColumns(true);
    currencyGrid.setCanEdit(true);
    currencyGrid.setAutoFetchData(true);
    currencyGrid.setWidth100();
    currencyGrid.setHeight100();
    currencyGrid.setShowAllColumns(true);
    currencyGrid.setSelectionType(SelectionStyle.SINGLE);
    currencyGrid.setDataSource(CurrencyDataSource.getInstance());
    currencyGrid.setSortDirection(SortDirection.DESCENDING);
    currencyGrid.setSortField("dt");
    currencyGrid.setShowHeaderContextMenu(false);
    currencyGrid.setCanAutoFitFields(false);

    addRowButton = new IButton(constants.add());
    addRowButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {

            // Boolean isWindowInput = (Boolean)isWindowInputItem.getValue();
            // currencyGrid.startEditingNew();
            // currencyGrid.endEditing();
            Record firstRecord = currencyGrid.getRecordList().first();
            Record lastRecord = currencyGrid.getRecordList().last();

            Date firstDate = firstRecord.getAttributeAsDate("dt");
            Date lastDate = lastRecord.getAttributeAsDate("dt");
            Date nowDate = new Date();
            DateTimeFormat dateFormatter = DateTimeFormat.getFormat("dd.MM.yyyy");
            String firstDateStr = dateFormatter.format(firstDate);
            String lastDateStr = dateFormatter.format(lastDate);
            String nowDateStr = dateFormatter.format(nowDate);

            if (nowDateStr.equals(firstDateStr) || nowDateStr.equals(lastDateStr)) {
              SC.say(constants.warningCurrencyAlreadySet());
            } else {
              CurrencyRecord currencyRecord = new CurrencyRecord();
              currencyRecord.setDt(new Date());
              currencyRecord.setAttribute(
                  CurrencyRecord.IDENTITY_CURRENCY + baseCurrencyPrefix, 1.0);
              currencyRecord.setAttribute(
                  CurrencyRecord.IDENTITY_CURRENCY + docCurrencyPrefix, 1.0);
              currencyGrid.startEditingNew(currencyRecord);
            }
          }
        });

    editRowButton = new IButton(constants.editCurrency());
    editRowButton.setAutoFit(true);
    editRowButton.addClickHandler(
        new ClickHandler() {

          @Override
          public void onClick(ClickEvent event) {
            presenter.goTo(new CurrencyTypePlace(""));
          }
        });

    currencyGrid.addCellDoubleClickHandler(
        new CellDoubleClickHandler() {

          @Override
          public void onCellDoubleClick(CellDoubleClickEvent event) {
            if (currencyGrid.getFieldNum("remove") == event.getColNum()) {
              final ListGridRecord record = currencyGrid.getRecord(event.getRowNum());
              if (record != null) {
                SC.ask(
                    constants.askRemoveRecord(),
                    new BooleanCallback() {

                      @Override
                      public void execute(Boolean value) {
                        if (value) {
                          currencyGrid.removeData(record);
                        }
                      }
                    });
              }
            } else {
              Boolean isWindowInput = (Boolean) isWindowInputItem.getValue();
              if (isWindowInput) {
                String fieldName = currencyGrid.getFieldName(event.getColNum());
                Double exchange = null;
                try {
                  exchange = Double.parseDouble(event.getRecord().getAttribute(fieldName));
                } catch (Exception ex) {
                }
                if (fieldName != null
                    && exchange != null
                    && fieldName.startsWith(CurrencyRecord.IDENTITY_CURRENCY)) {
                  String name = fieldName.substring(1);
                  Currency currency = new Currency(name, exchange);
                  showCurrencyForm(event.getRowNum(), event.getColNum(), currency);
                }
              }
            }
          }
        });
    currencyGrid.addCellClickHandler(
        new CellClickHandler() {

          @Override
          public void onCellClick(CellClickEvent event) {

            if (currencyGrid.getFieldNum("remove") == event.getColNum()) {
              final ListGridRecord record = currencyGrid.getRecord(event.getRowNum());
              if (record != null) {
                SC.ask(
                    constants.askRemoveRecord(),
                    new BooleanCallback() {

                      @Override
                      public void execute(Boolean value) {
                        if (value) {
                          currencyGrid.removeData(record);
                        }
                      }
                    });
              }
            } else {
              Boolean isWindowInput = (Boolean) isWindowInputItem.getValue();
              if (isWindowInput) event.cancel();
            }
          }
        });

    DynamicForm form = new DynamicForm();
    isWindowInputItem = new CheckboxItem("output", constants.windowsInput());
    isWindowInputItem.setDefaultValue(false);
    isWindowInputItem.setAlign(Alignment.RIGHT);
    form.setItems(isWindowInputItem);
    form.setWidth("*");

    HLayout controlLayout = new HLayout();
    controlLayout.setMembers(addRowButton, editRowButton, form);

    addMember(currencyGrid);
    addMember(controlLayout);
  }
Exemple #7
0
 public String getTag() {
   NodeList<Element> elements = rootElement.getElementsByTagName("tagname");
   assert elements.getLength() > 0;
   Element tagname = elements.getItem(0);
   return tagname.getInnerText();
 }
Exemple #8
0
 public String getText() {
   NodeList<Element> elements = rootElement.getElementsByTagName("entity");
   assert elements.getLength() > 0;
   Element entity = elements.getItem(0);
   return entity.getInnerText();
 }
Exemple #9
0
 public String getLemma() {
   NodeList<Element> elements = rootElement.getElementsByTagName("lemma");
   assert elements.getLength() > 0;
   Element lemma = elements.getItem(0);
   return lemma.getInnerText();
 }