Ejemplo n.º 1
0
    /**
     * Whether the element has children.
     *
     * @param element to identify, either a SystemInfo or FileInfo
     * @return true if element has non-empty children list, otherwise false
     */
    public boolean hasChildren(Object element) {
      if (element instanceof ExampleContributions) {
        ExampleContributions si = (ExampleContributions) element;
        if (si.getCategories().isEmpty() == false) return true;
      }

      if (element instanceof ExampleCategory) {
        ExampleCategory si = (ExampleCategory) element;
        if (si.getExamples().isEmpty() == false) return true;
      }

      return false;
    }
Ejemplo n.º 2
0
    /**
     * Get the category or example name as the label text.
     *
     * @param obj object to label
     * @return category or example name
     */
    public String getText(Object obj) {

      if (obj instanceof ExampleCategory) {
        ExampleCategory c = (ExampleCategory) obj;
        return c.getName();
      }

      if (obj instanceof Example) {
        Example e = (Example) obj;
        return MessageFormat.format("{0} {1}", e.getName(), e.getVersion());
      }

      return obj.toString();
    }
Ejemplo n.º 3
0
    /** Gets the array of elements based on input. */
    public Object[] getElements(Object inputElement) {

      // individual example contributions
      if (inputElement instanceof ExampleContributions) {
        ExampleContributions input = (ExampleContributions) inputElement;
        return input.getCategoriesArray();
      }

      // example contribution categories
      if (inputElement instanceof ExampleCategory) {
        ExampleCategory input = (ExampleCategory) inputElement;
        return input.getExamplesArray();
      }

      return new Object[0];
    }