コード例 #1
0
ファイル: SplitButton.java プロジェクト: sajeeshnl/sigmah
  /**
   * Replaces the button icon <b>but</b> does not save icon reference into parent {@code icon}
   * attribute.
   *
   * @param icon The button icon to display.
   */
  private void replaceIcon(final AbstractImagePrototype icon) {

    if (rendered) {
      El oldIcon = buttonEl.selectNode("." + baseStyle + "-image");
      if (oldIcon != null) {
        oldIcon.remove();
        el().removeStyleName(baseStyle + "-text-icon", baseStyle + "-icon", baseStyle + "-noicon");
      }
      el().addStyleName(
              (icon != null
                  ? (!Util.isEmptyString(html)
                      ? " " + baseStyle + "-text-icon"
                      : " " + baseStyle + "-icon")
                  : " " + baseStyle + "-noicon"));
      Element e = null;

      if (icon != null) {
        e = (Element) icon.createElement().cast();

        Accessibility.setRole(e, "presentation");
        fly(e).addStyleName(baseStyle + "-image");

        buttonEl.insertFirst(e);
        El.fly(e).makePositionable(true);
      }
      autoWidth();
      alignIcon(e);
    }
  }
コード例 #2
0
ファイル: TabItem.java プロジェクト: sbentin/GXT_RTL
 /**
  * Sets the header's text.
  *
  * @param text the text
  */
 public void setText(String text) {
   this.text = text;
   if (rendered) {
     el().child(".x-tab-strip-text")
         .dom
         .setInnerHTML(Util.isEmptyString(text) ? "&#160;" : text);
     tabPanel.onItemTextChange(TabItem.this, this.text, text);
   }
 }
コード例 #3
0
  private void showStudentAccountWindow(StudentDetailsModel studentDetailsModel) {
    this.studentDetailsModel = studentDetailsModel;
    setHeading("Данные студента: " + studentDetailsModel.getFullName());
    XTemplate template = XTemplate.create(getHeaderTemplate());

    prepareStudentDetail(studentDetailsModel);
    headerHtml.setHtml(template.applyTemplate(Util.getJsObject(studentDetailsModel, 1)));

    studentDataForm.addStyleName("studentDataForm");
    studentDataForm.setStudentDetails(studentDetailsModel);

    show();
  }
コード例 #4
0
ファイル: ListStore.java プロジェクト: Jullil/gxt
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected void onLoad(LoadEvent le) {
    this.config = (ListLoadConfig) le.getConfig();

    Object data = le.getData();

    removeAll();

    if (data == null) {
      all = new ArrayList();
    } else if (data instanceof List) {
      List<M> list = (List) data;
      all = new ArrayList(list);
    } else if (data instanceof ListLoadResult) {
      all = new ArrayList(((ListLoadResult) data).getData());
    }

    for (M m : all) {
      registerModel(m);
    }

    if (config != null
        && config.getSortInfo() != null
        && !Util.isEmptyString(config.getSortInfo().getSortField())) {
      sortInfo = config.getSortInfo();
    } else {
      sortInfo = new SortInfo();
    }

    if (filtersEnabled) {
      filtersEnabled = false;
      applyFilters(filterProperty);
    }

    if (storeSorter != null) {
      applySort(true);
    }
    fireEvent(DataChanged, createStoreEvent());
  }
コード例 #5
0
ファイル: ListStore.java プロジェクト: Jullil/gxt
  @SuppressWarnings({"unchecked", "rawtypes"})
  protected void insert(List<? extends M> items, int index, boolean supressEvent) {
    if (items != null && items.size() > 0) {
      List<M> added = new ArrayList<M>();
      if ((loader == null && storeSorter != null)
          || (loader != null && storeSorter != null && !loader.isRemoteSort())) {
        boolean defer = index == 0 && getCount() == 0;
        for (int i = 0; i < items.size(); i++) {
          M m = items.get(i);
          StoreEvent evt = createStoreEvent();
          evt.setModels(Util.createList(m));
          if (m == null || (!supressEvent && !fireEvent(BeforeAdd, evt))) {
            continue;
          }
          if (isFiltered()) {
            snapshot.add(m);
            if (!isFiltered(m, filterProperty)) {
              all.add(m);
              added.add(m);
            }
          } else {
            all.add(m);
            added.add(m);
          }

          registerModel(m);
          if (!defer && !supressEvent && added.contains(m)) {
            applySort(true);
            evt = createStoreEvent();
            evt.setModels(Util.createList(m));
            evt.setIndex(indexOf(m));
            fireEvent(Add, evt);
          }
        }
        if (defer && !supressEvent && added.size() > 0) {
          applySort(true);
          StoreEvent evt = createStoreEvent();
          evt.setModels(getModels());
          evt.setIndex(index);
          fireEvent(Add, evt);
        }
      } else {
        for (int listIndex = 0, addedIndex = 0; listIndex < items.size(); listIndex++) {
          M m = items.get(listIndex);
          StoreEvent evt = createStoreEvent();
          evt.setModels(Util.createList(m));
          evt.setIndex(index + addedIndex);
          if (m == null || (!supressEvent && !fireEvent(BeforeAdd, evt))) {
            continue;
          }
          if (isFiltered()) {
            snapshot.add(index + listIndex, m);
            if (!isFiltered(m, filterProperty)) {
              all.add(index + (addedIndex++), m);
              added.add(m);
            }
          } else {
            all.add(index + (addedIndex++), m);
            added.add(m);
          }
          registerModel(m);
        }
        if (!supressEvent && added.size() > 0) {
          StoreEvent evt = createStoreEvent();
          evt.setModels(added);
          evt.setIndex(index);
          fireEvent(Add, evt);
        }
      }
    }
  }
コード例 #6
0
ファイル: BasicBindingExample.java プロジェクト: neolee/fsrg
  @Override
  protected void onRender(Element parent, int index) {
    super.onRender(parent, index);

    final Stock stock = TestData.getStocks().get(0);

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(10);

    StringBuffer sb = new StringBuffer();
    sb.append("<div class=text style='line-height: 1.5em'>");
    sb.append("<b>Name:</b> {name}<br>");
    sb.append("<b>Symbol:</b> {symbol}<br>");
    sb.append("<b>Last:</b> {last}<br>");
    sb.append("<b>Change:</b> {[new Number(values.change).toFixed(2)]}<br>");
    sb.append("<b>Updated:</b> {date:date(\"MM/dd/y\")}<br>");
    sb.append("</div>");

    final XTemplate template = XTemplate.create(sb.toString());
    final HTML html = new HTML();
    html.setWidth("160px");
    template.overwrite(html.getElement(), Util.getJsObject(stock));
    hp.add(html);
    // update template when model changes
    stock.addChangeListener(
        new ChangeListener() {
          public void modelChanged(ChangeEvent event) {
            template.overwrite(html.getElement(), Util.getJsObject(stock));
          }
        });

    FormPanel panel = new FormPanel();
    panel.setHeaderVisible(false);
    panel.setWidth(350);

    TextField<String> name = new TextField<String>();
    name.setName("nameField");
    name.setFieldLabel("Name");
    panel.add(name);

    TextField<String> symbol = new TextField<String>();
    symbol.setName("symbol");
    symbol.setFieldLabel("Symbol");
    panel.add(symbol);

    NumberField open = new NumberField();
    open.setName("last");
    open.setFieldLabel("Last");
    panel.add(open);

    NumberField change = new NumberField();
    change.setName("change");
    change.setFieldLabel("Change");
    change.setFormat(NumberFormat.getDecimalFormat());
    panel.add(change);

    DateField last = new DateField();
    last.setName("date");
    last.setFieldLabel("Updated");
    panel.add(last);

    SimpleComboBox<String> scb = new SimpleComboBox<String>();
    for (Stock s : TestData.getStocks()) {
      scb.add(s.getName());
    }
    scb.setFieldLabel("Name");
    scb.setForceSelection(true);
    scb.setTypeAhead(true);
    scb.setName("company");
    scb.setTriggerAction(TriggerAction.ALL);
    panel.add(scb);

    hp.add(panel);

    FormBinding binding = new FormBinding(panel);
    // manually add bindings
    binding.addFieldBinding(new FieldBinding(name, "name"));
    binding.addFieldBinding(new FieldBinding(symbol, "symbol"));
    binding.addFieldBinding(new SimpleComboBoxFieldBinding(scb, "name"));

    // auto bind remaining fields, field name must match model property name
    binding.autoBind();
    binding.bind(stock);

    add(hp);
  }