Example #1
0
 public void selectButton(Object obj) {
   for (int i = 0; i < panel.getWidgetCount(); i++) {
     Button b = (Button) panel.getWidget(i);
     if (b.getElement().getPropertyObject("object") == obj) b.addStyleName("Ribbon-selected");
     else b.removeStyleName("Ribbon-selected");
   }
 }
Example #2
0
 public String getValue() {
   String tagString = "";
   for (int loop = 0; loop < tags.getWidgetCount(); loop++) {
     tagString += ((TagDisplay) tags.getWidget(loop)).getTag() + DELIMITER;
   }
   return tagString.substring(0, tagString.length() - 1);
 }
Example #3
0
 @Override
 public void reset() {
   hLb.setText("Thai SME Accounting");
   for (int i = 0; i < actBar.getWidgetCount(); i++) {
     actBar.getWidget(i).setVisible(false);
   }
 }
  /**
   * Removes a widget from the button panel.
   *
   * <p>
   *
   * @param w the widget to remove
   */
  public void removeButton(Widget w) {

    m_buttonPanel.remove(w);
    if (CmsCoreProvider.get().isIe7()) {
      m_buttonPanel.getElement().getStyle().setWidth(m_buttonPanel.getWidgetCount() * 22, Unit.PX);
    }
  }
 @Override
 public void clearErrorMessage() {
   if (holder.getWidgetCount() == 1) {
     return;
   }
   holder.remove(1);
 }
Example #6
0
 @Override
 public void setLoading() {
   hLb.setText(constants.loading());
   for (int i = 0; i < actBar.getWidgetCount(); i++) {
     actBar.getWidget(i).setVisible(false);
   }
 }
 /**
  * Add an item to the list.
  *
  * @param pNewWidget the new display widget
  */
 @SuppressWarnings("unchecked")
 protected void addDisplayWidget(final W pNewWidget) {
   final String itemId = getIdFromWidget(pNewWidget);
   int beforeIdx = -1;
   for (Widget w : iGuiList) {
     CbGenericListItem<W> gli = (CbGenericListItem<W>) w;
     if (itemId.compareToIgnoreCase(getIdFromWidget(gli.getDisplayWidget())) < 0) {
       beforeIdx = gli.getRowIdx();
       break;
     }
   }
   CbGenericListItem<W> newRow =
       new CbGenericListItem<W>(getSelectorCallback(), getMoreArrowCallback());
   newRow.setDisplayWidget(pNewWidget);
   if (beforeIdx < 0) {
     newRow.setRowIdx(iGuiList.getWidgetCount());
     iGuiList.add(newRow);
   } else {
     newRow.setRowIdx(beforeIdx);
     iGuiList.insert(newRow, beforeIdx);
     int i = 0;
     for (Widget w : iGuiList) {
       ((CbGenericListItem<W>) w).setRowIdx(i++);
     }
   }
   checkEmptyListHint();
 }
  /**
   * Adds a widget to the front of the button panel.
   *
   * <p>
   *
   * @param w the widget to add
   */
  public void addButtonToFront(Widget w) {

    m_buttonPanel.insert(w, 0);
    if (CmsCoreProvider.get().isIe7()) {
      m_buttonPanel.getElement().getStyle().setWidth(m_buttonPanel.getWidgetCount() * 22, Unit.PX);
    }
  }
Example #9
0
  public String getButtonText(Object obj) {
    for (int i = 0; i < panel.getWidgetCount(); i++) {
      Button b = (Button) panel.getWidget(i);
      if (b.getElement().getPropertyObject("object") == obj) return b.getText();
    }

    return null;
  }
Example #10
0
  public final BuilderPanel add(Widget child) {
    if (child == null) return this;

    if (panel.getWidgetCount() > 0) addSpacer(spacing);

    addChild(child, childWidth);

    return this;
  }
 @Override
 public void showErrorMessage(SafeHtml errorMessage, Set<EntityType<?>> expectedTypes) {
   if (holder.getWidgetCount() > 1) {
     clearErrorMessage();
   }
   PrimitiveDataEditorFreshEntityView error = errorViewProvider.get();
   error.setExpectedTypes(errorMessage, expectedTypes);
   holder.add(error);
 }
Example #12
0
 @Override
 public void onTransitionEnd() {
   for (int i = 0; i < _panel.getWidgetCount(); i++) {
     Widget w = _panel.getWidget(i);
     if (Utils.isSubclassOf(w.getClass(), WidgetBase.class)) {
       ((WidgetBase) w).onTransitionEnd();
     }
   }
 }
 public void chngeNdeWdgtToEnable() {
   for (int i = 0; i < nodeContainer.getWidgetCount(); i++) {
     if (((NodeWidget) nodeContainer.getWidget(i)).isSelected) {
       // ((NodeWidget)nodeContainer.getWidget(i)).enableEndpoint();
       ((NodeWidget) nodeContainer.getWidget(i)).isSelected = false;
       // ((NodeWidget)nodeContainer.getWidget(i)).disableEndpoint();
       ((NodeWidget) nodeContainer.getWidget(i)).enableEndpoint();
     }
   }
 }
Example #14
0
  private void initializeActBtns(int targetSize) {

    int currentSize = actBar.getWidgetCount();

    for (int i = currentSize; i < targetSize; i++) {
      ActBtn actBtn = new ActBtn();
      actBtn.addStyleName(style.actBtn());
      actBtn.addClickHandler(actBtnClickHandler);
      actBar.add(actBtn);
    }
  }
Example #15
0
 /**
  * Mark the list item at the given position.
  *
  * @param pRowIdx item index
  */
 @SuppressWarnings("unchecked")
 private void setMarked(final int pRowIdx) {
   boolean clear = pRowIdx < 0 || pRowIdx >= iGuiList.getWidgetCount() || pRowIdx == iMarkedIdx;
   clearMarker();
   if (!clear) {
     ((CbGenericListItem<W>) iGuiList.getWidget(pRowIdx)).setMarkerVisible(true);
     iMarkedIdx = pRowIdx;
     iBtnDeleteItem.setEnabled(true);
     if (iBtnEditItem != null) {
       iBtnEditItem.setEnabled(true);
     }
   }
 }
Example #16
0
 @SuppressWarnings("unchecked")
 private void clearMarker() {
   if (iMarkedIdx >= 0) {
     if (iMarkedIdx < iGuiList.getWidgetCount()) {
       // (else the widget is already deleted)
       ((CbGenericListItem<W>) iGuiList.getWidget(iMarkedIdx)).setMarkerVisible(false);
     }
     iMarkedIdx = -1;
     iBtnDeleteItem.setEnabled(false);
     if (iBtnEditItem != null) {
       iBtnEditItem.setEnabled(false);
     }
   }
 }
  private boolean checkPriLvlSlctd() {
    boolean slctd = false;
    int wdgtCnt = priLvlCntnrWdgt.getWidgetCount();

    for (int i = 0; i < wdgtCnt; i++) {
      if (priLvlCntnrWdgt.getWidget(0) instanceof SwitchButton) {
        if (!((SwitchButton) priLvlCntnrWdgt.getWidget(i)).isEnable()) {
          return true;
        }
      }
    }

    return slctd;
  }
  public void hide() {

    int wdgtCnt = priLvlCntnrWdgt.getWidgetCount();
    for (int i = 0; i < wdgtCnt; i++) {
      if (priLvlCntnrWdgt.getWidget(i) instanceof SwitchButton) {
        if (!((SwitchButton) priLvlCntnrWdgt.getWidget(i)).isEnable()) {
          ((SwitchButton) priLvlCntnrWdgt.getWidget(i)).enable();
        }
      }
    }

    mainPnl.getElement().getStyle().setDisplay(Display.NONE);
    visible = false;
  }
  private int getIndxOfSlctdWdgt() {
    int indx = 0;
    int wdgtCnt = priLvlCntnrWdgt.getWidgetCount();

    for (int i = 0; i < wdgtCnt; i++) {
      if (priLvlCntnrWdgt.getWidget(i) instanceof SwitchButton) {
        if (!((SwitchButton) priLvlCntnrWdgt.getWidget(i)).isEnable()) {
          ((SwitchButton) priLvlCntnrWdgt.getWidget(i)).enable();
          return i;
        }
      }
    }

    return indx;
  }
Example #20
0
  /**
   * Getter.
   *
   * @return the ID of the marked entry
   */
  @SuppressWarnings("unchecked")
  public String getMarkedID() {
    LOG.enter("getMarkedID"); // $NON-NLS-1$
    if (LOG.isDetailEnabled()) {
      LOG.detail(
          "getMarkedID", //$NON-NLS-1$
          "iMarkedIdx = " + iMarkedIdx); // $NON-NLS-1$
    }

    String result = null;
    if (iMarkedIdx >= 0 && iMarkedIdx < iGuiList.getWidgetCount()) {
      result =
          getIdFromWidget(
              ((CbGenericListItem<W>) iGuiList.getWidget(iMarkedIdx)).getDisplayWidget());
    }

    LOG.exit("getMarkedID", result); // $NON-NLS-1$
    return result;
  }
Example #21
0
  protected void handleTextAreaClick(
      FlowPanel flowPanel,
      DoubleClickEvent event,
      TextArea critReftextArea,
      ScrollPanel scrollPanel) {

    int textAreaCount = flowPanel.getWidgetCount();

    String idString = critReftextArea.getText();
    int idStart = idString.indexOf("<id");
    int idEnd = idString.indexOf("/>", idStart);
    idString = idString.substring(idStart, idEnd + "/>".length());

    String extension = idString.substring(idString.indexOf("extension"));
    extension = extension.substring(0, extension.indexOf("root"));
    extension = extension.trim();

    String root = idString.substring(idString.indexOf("root"));
    root = root.substring(0, root.indexOf("/>"));
    root = root.trim();

    for (int i = 0; i < textAreaCount; i++) {

      TextArea textArea = (TextArea) flowPanel.getWidget(i);
      if (textArea.getStyleName().indexOf("entry_background") == -1) {
        continue;
      }

      String text = textArea.getText();
      if (text.indexOf(root) > -1 && text.indexOf(extension) > -1) {
        DOM.scrollIntoView(textArea.getElement());
        break;
      }
    }
    System.out.println("Done.");
  }
Example #22
0
 private void checkEmptyListHint() {
   boolean empty = iGuiList.getWidgetCount() < 1;
   iEmpty.setVisible(empty);
   iHeaderHint.setVisible(!empty);
   iGuiList.setVisible(!empty);
 }
  /**
   * Returns the number of buttons.
   *
   * <p>
   *
   * @return the number of buttons
   */
  public int getButtonCount() {

    return m_buttonPanel.getWidgetCount();
  }
  /**
   * Returns if additional info items are present.
   *
   * <p>
   *
   * @return <code>true</code> if additional info items are present
   */
  public boolean hasAdditionalInfo() {

    return m_additionalInfo.getWidgetCount() > 0;
  }
Example #25
0
 public void add(Widget w, int index) {
   formElements.insert(w, Math.max(0, Math.min(index, formElements.getWidgetCount())));
 }
 /**
  * Adds a new non-visible component to this panel. Note that this method will not add the
  * component to the form component! This needs to be done separately.
  *
  * @param component Simple mock component to be added
  */
 public void addComponent(MockComponent component) {
   componentsPanel.add(component);
   if (componentsPanel.getWidgetCount() > 0) {
     heading.setText(MESSAGES.nonVisibleComponentsHeader());
   }
 }
Example #27
0
 public void setEnabled(Object obj, boolean fEnabled) {
   for (int i = 0; i < panel.getWidgetCount(); i++) {
     Button b = (Button) panel.getWidget(i);
     if (b.getElement().getPropertyObject("object") == obj) b.setEnabled(fEnabled);
   }
 }
  /**
   * A narrative that is linked to an event or another narrative and has to be rendered within it
   * has to be treated especially, because unlike with other linked content item types, we do want
   * to show the content items that have been linked to the narrative. We'll only show the linked
   * content items of the type: Multimedia, Quotes and Players.
   *
   * <p>TODO: Reuse the ContainerView here somehow, instead of reimplementing a bunch of stuff.
   */
  private Widget renderLinkedNarrative(NarrativeContentItem narrative) {
    // The left panel has the narrative headline, byline, summary and body
    Widget leftPanel = LinkedViewFactory.createView(narrative, contentItem.getAuthorsString());
    // The right panel has multimedia, players and quotes
    FlowPanel rightPanel = new FlowPanel();
    rightPanel.addStyleName(Resources.INSTANCE.css().linkedContentItemsPanel());

    // Create a map from the different types linked to the narrative to the widgets of content items
    // of those types that will be rendered
    Map<ContentItemType, List<Widget>> linkedWidgetsMap =
        new HashMap<ContentItemType, List<Widget>>();
    for (ContentItemType contentItemType : LINKED_TYPES_SHOWN_FOR_NARRATIVES) {
      linkedWidgetsMap.put(contentItemType, new ArrayList<Widget>());
    }
    List<AssetContentItem> linkedImages = new ArrayList<AssetContentItem>();

    for (BaseContentItem linkedContentItem : narrative.getLinkedContentItems()) {
      if (linkedContentItem != null) {
        ContentItemType linkedContentItemType = linkedContentItem.getContentItemType();
        if (linkedContentItemType == ContentItemType.ASSET
            && ((AssetContentItem) linkedContentItem).getAssetType() == AssetType.IMAGE) {
          // Collect all of the images in a list so that they can be shown in a slideshow
          linkedImages.add((AssetContentItem) linkedContentItem);
        } else if (LINKED_TYPES_SHOWN_FOR_NARRATIVES.contains(linkedContentItemType)) {
          // Create a widget for the linked content items and put it in the map
          linkedWidgetsMap
              .get(linkedContentItemType)
              .add(LinkedViewFactory.createView(linkedContentItem, narrative.getAuthorsString()));
        }
      }
    }
    // First render the images
    // TODO: this is mostly repeated from 'createImages' below, but
    // will go away once we get narratives rendering with a ContainerView as well.
    if (!linkedImages.isEmpty()) {
      List<AssetContentItem> slideshowImages = new ArrayList<AssetContentItem>();
      List<AssetContentItem> thumbnailOnlyImages = new ArrayList<AssetContentItem>();

      for (AssetContentItem image : linkedImages) {
        if (GlobalUtil.isContentEmpty(image.getContent())) {
          thumbnailOnlyImages.add(image);
        } else {
          slideshowImages.add(image);
        }
      }

      if (!slideshowImages.isEmpty()) {
        AssetContentItem previewImage = slideshowImages.get(0);
        previewImage.setRelatedAssets(slideshowImages);
        Widget previewPanel =
            LinkedViewFactory.createView(previewImage, contentItem.getAuthorsString());
        rightPanel.add(previewPanel);
      }

      for (AssetContentItem image : thumbnailOnlyImages) {
        rightPanel.add(LinkedViewFactory.createView(image, contentItem.getAuthorsString()));
      }
    }
    // Then render the rest of the linked content items
    for (List<Widget> widgetList : linkedWidgetsMap.values()) {
      for (Widget widget : widgetList) {
        rightPanel.add(widget);
      }
    }

    FlowPanel linkedNarrativePanel = new FlowPanel();
    if (rightPanel.getWidgetCount() > 0) {
      linkedNarrativePanel.add(rightPanel);
    }
    linkedNarrativePanel.add(leftPanel);

    narrativeWidgetsById.put(narrative.getId(), linkedNarrativePanel);

    return linkedNarrativePanel;
  }
 /**
  * Removes a new non-visible component from this panel. Note that this method will not remove the
  * component from the form component! This needs to be done separately.
  *
  * @param component Simple mock component to be removed
  */
 public void removeComponent(MockComponent component) {
   componentsPanel.remove(component);
   if (componentsPanel.getWidgetCount() == 0) {
     heading.setText("");
   }
 }
Example #30
0
 public void setButtonText(Object obj, String text) {
   for (int i = 0; i < panel.getWidgetCount(); i++) {
     Button b = (Button) panel.getWidget(i);
     if (b.getElement().getPropertyObject("object") == obj) b.setText(text);
   }
 }