コード例 #1
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  public TableType generateDefaultTable(String gid) {
    final TableType table = new TableType();
    table.setId(gid);
    table.setTitle(ILMLCoreConstants.TITLE_PREFIX + gid);
    final ContentType ct = ContentType.fromValue(ILguiItem.CONTENT_JOBS);
    table.setContenttype(ct);

    for (final ColumnlayoutType columnLayout :
        lguiItem.getLayoutAccess().getTableLayout(gid).getColumn()) {
      if (columnLayout.isActive()) {
        final ColumnType column = new ColumnType();
        column.setId(columnLayout.getCid());
        column.setName(columnLayout.getKey());
        generateDefaultSorting(column);
        if (columnLayout.getKey().equals(ILguiItem.JOB_STATUS)) {
          column.setType(ITableColumnLayout.COLUMN_TYPE_MANDATORY);
          if (gid.equals(ILMLCoreConstants.ID_ACTIVE_JOBS_VIEW)) {
            generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.EQ, columnLayout);
          } else {
            generateDefaultPattern(JobStatusData.RUNNING, ILMLCoreConstants.NEQ, columnLayout);
          }
        }
        table.getColumn().add(column);
      }
    }
    jaxbUtil.addTable(lgui, table);
    return table;
  }
コード例 #2
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 public void deleteOldPattern(String gid) {
   final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid);
   if (tablelayout != null) {
     for (final ColumnlayoutType column : tablelayout.getColumn()) {
       column.setPattern(null);
     }
   }
 }
コード例 #3
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 public void setTableColumnActive(String gid, String text, boolean activeTableColumn) {
   final List<ColumnlayoutType> columnLayouts =
       lguiItem.getLayoutAccess().getTableLayout(gid).getColumn();
   for (final ColumnlayoutType column : columnLayouts) {
     if (column.getKey().equals(text)) {
       column.setActive(activeTableColumn);
       break;
     }
   }
 }
コード例 #4
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /** Currently unused */
 public int getNumberOfTableColumns(String gid) {
   final TablelayoutType layout = lguiItem.getLayoutAccess().getTableLayout(gid);
   int activeColumn = 0;
   for (final ColumnlayoutType column : layout.getColumn()) {
     if (column.isActive()) {
       activeColumn++;
     }
   }
   return activeColumn;
 }
コード例 #5
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /**
  * Get column indexes of active columns for the table layout
  *
  * @param gid ID of the table layout
  * @return array of column indexes
  */
 private BigInteger[] getCids(String gid) {
   final TablelayoutType layout = lguiItem.getLayoutAccess().getTableLayout(gid);
   final BigInteger[] cids = new BigInteger[layout.getColumn().size()];
   for (int i = 0; i < layout.getColumn().size(); i++) {
     for (final ColumnlayoutType column : layout.getColumn()) {
       if (column.getPos() != null && column.getPos().equals(BigInteger.valueOf(i))) {
         cids[i] = column.getCid();
       }
     }
   }
   return cids;
 }
コード例 #6
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 public void deleteOldPattern(String gid, List<String> columnsTitle) {
   final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid);
   if (tablelayout != null) {
     for (final ColumnlayoutType column : tablelayout.getColumn()) {
       for (final String columnTitle : columnsTitle) {
         if (column.getKey().equals(columnTitle)) {
           column.setPattern(null);
         }
       }
     }
   }
 }
コード例 #7
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /**
  * Get column indexes of active columns for the table layout
  *
  * @param gid ID of the table layout
  * @return array of column indexes
  */
 private BigInteger[] getCidsActiveColumns(String gid) {
   final TablelayoutType layout = lguiItem.getLayoutAccess().getTableLayout(gid);
   final List<BigInteger> cids = new ArrayList<BigInteger>();
   for (int i = 0; i < layout.getColumn().size(); i++) {
     for (final ColumnlayoutType column : layout.getColumn()) {
       if (column.getPos() != null
           && column.getPos().equals(BigInteger.valueOf(i))
           && column.isActive()) {
         cids.add(column.getCid());
       }
     }
   }
   return cids.toArray(new BigInteger[cids.size()]);
 }
コード例 #8
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /**
  * Change the table column widths
  *
  * @param gid ID of the table layout
  * @param widths new column widths
  */
 public void changeTableColumnsWidth(String gid, Double[] widths) {
   final BigInteger[] cids = getCids(gid);
   for (int i = 0; i < widths.length; i++) {
     for (final ColumnlayoutType column :
         lguiItem.getLayoutAccess().getLayoutColumsToCids(cids, gid)) {
       if (column.getPos() != null
           && BigInteger.valueOf(i).equals(column.getPos())
           && column.isActive()) {
         column.setWidth(widths[i]);
         break;
       }
     }
   }
 }
コード例 #9
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /** Not currently used */
 @SuppressWarnings("unused")
 private void reduceColumnPos(String gid, int pos, int i) {
   if (pos == i) {
     return;
   }
   final List<ColumnlayoutType> columnLayouts =
       lguiItem.getLayoutAccess().getTableLayout(gid).getColumn();
   for (final ColumnlayoutType column : columnLayouts) {
     if (column.getPos() != null && column.getPos().intValue() == pos) {
       column.setPos(BigInteger.valueOf(pos - 1));
       reduceColumnPos(gid, pos + 1, i);
       break;
     }
   }
 }
コード例 #10
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  public String[] getTableColumnTitles(String gid) {
    if (lguiItem == null && lguiItem.getLayoutAccess() == null) {
      return null;
    }
    final ColumnlayoutType[] layoutColumns =
        lguiItem.getLayoutAccess().getLayoutColumsToCids(getCidsActiveColumns(gid), gid);
    final List<String> titles = new ArrayList<String>();
    for (final ColumnlayoutType layoutColumn : layoutColumns) {
      if (layoutColumn.getKey() != null) {
        titles.add(layoutColumn.getKey());
      }
    }

    return titles.toArray(new String[titles.size()]);
  }
コード例 #11
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 private void generateDefaultPattern(String value, String relation, ColumnlayoutType column) {
   final PatternType pattern = new PatternType();
   final SelectType select = new SelectType();
   select.setRel(relation);
   select.setValue(value);
   jaxbUtil.addPatternSelect(pattern, select);
   column.setPattern(pattern);
 }
コード例 #12
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  public Object[] getSortProperties(String gid) {
    final Object[] values = new Object[2];
    values[0] = -1;
    values[1] = ITableColumnLayout.SORT_DIRECTION_NONE;

    final TablelayoutType tableLayout = lguiItem.getLayoutAccess().getTableLayout(gid);
    for (final ColumnlayoutType columnLayout : tableLayout.getColumn()) {
      if (!columnLayout.getSorted().equals(Columnsortedtype.FALSE)) {
        values[0] = columnLayout.getPos().intValue();
        if (columnLayout.getSorted().equals(Columnsortedtype.ASC)) {
          values[1] = ITableColumnLayout.SORT_DIRECTION_UP;
        } else {
          values[1] = ITableColumnLayout.SORT_DIRECTION_DOWN;
        }
      }
    }
    return values;
  }
コード例 #13
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 /**
  * Change the table column order
  *
  * @param gid ID of the table layout
  * @param order new order of columns
  */
 public void changeTableColumnsOrder(String gid, int[] order) {
   final List<ColumnlayoutType> newColumnLayouts = new ArrayList<ColumnlayoutType>();
   final List<ColumnlayoutType> oldColumnLayouts =
       lguiItem.getLayoutAccess().getTableLayout(gid).getColumn();
   for (int i = 0; i < order.length; i++) {
     for (final ColumnlayoutType column : oldColumnLayouts) {
       if (BigInteger.valueOf(order[i]).equals(column.getPos())) {
         final ColumnlayoutType columnNew = column;
         columnNew.setPos(BigInteger.valueOf(i));
         newColumnLayouts.add(columnNew);
         lguiItem.getLayoutAccess().getTableLayout(gid).getColumn().remove(column);
         break;
       }
     }
   }
   for (final ColumnlayoutType column : newColumnLayouts) {
     lguiItem.getLayoutAccess().getTableLayout(gid).getColumn().add(column);
   }
 }
コード例 #14
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  /**
   * Get the column layout for the table
   *
   * @param gid ID of the table layout
   * @return column layout
   */
  public ITableColumnLayout[] getTableColumnLayout(String gid) {
    if (lguiItem == null && lguiItem.getLayoutAccess() == null) {
      return new ITableColumnLayout[0];
    }

    final BigInteger[] cids = getCids(gid);

    // layoutColumns are sorted by cids
    final ColumnlayoutType[] layoutColumns =
        lguiItem.getLayoutAccess().getLayoutColumsToCids(cids, gid);
    final ITableColumnLayout[] tableColumnLayouts = new ITableColumnLayout[layoutColumns.length];

    for (int i = 0; i < layoutColumns.length; i++) {
      final ColumnlayoutType column = layoutColumns[i];
      if (column != null) {
        String style = null;
        final String sort = getColumnSortProperty(getTable(gid), cids, i);
        // when there is a change
        if (column.getSorted() != null && column.getSorted().value() != null && sort != null) {
          if (sort.equals(ILMLCoreConstants.TABLECOLUMN_NUMERIC)) {
            style = ITableColumnLayout.COLUMN_STYLE_RIGHT;
          } else if (sort.equals(ILMLCoreConstants.TABLECOLUMN_ALPHA)) {
            style = ITableColumnLayout.COLUMN_STYLE_LEFT;
          } else {
            style = ITableColumnLayout.COLUMN_STYLE_CENTER;
          }
        }
        tableColumnLayouts[i] =
            new TableColumnLayout(
                column.getKey(), column.getWidth(), style, column.isActive(), sort);
      }
    }
    return tableColumnLayouts;
  }
コード例 #15
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
 public void generateNewPattern(String gid, List<IPattern> filterValues) {
   final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid);
   if (tablelayout != null) {
     for (final ColumnlayoutType column : tablelayout.getColumn()) {
       for (final IPattern filterValue : filterValues) {
         if (column.getKey().equals(filterValue.getColumnTitle())) {
           final PatternType pattern = new PatternType();
           if (filterValue.isRange()) {
             final SelectType selectMin = new SelectType();
             selectMin.setRel(ILMLCoreConstants.xGE_LC);
             selectMin.setValue(filterValue.getMinValueRange());
             final SelectType selectMax = new SelectType();
             selectMax.setRel(ILMLCoreConstants.xLE_LC);
             selectMax.setValue(filterValue.getMaxValueRange());
             jaxbUtil.addPatternSelect(pattern, selectMin);
             jaxbUtil.addPatternSelect(pattern, selectMax);
           } else {
             final SelectType select = new SelectType();
             select.setValue(filterValue.getRelationValue());
             if (filterValue.getRelationOperator().equals(ILMLCoreConstants.LT)) {
               select.setRel(ILMLCoreConstants.xLT_LC);
             } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.LE)) {
               select.setRel(ILMLCoreConstants.xLE_LC);
             } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.GT)) {
               select.setRel(ILMLCoreConstants.xGT_LC);
             } else if (filterValue.getRelationOperator().equals(ILMLCoreConstants.GE)) {
               select.setRel(ILMLCoreConstants.xGE_LC);
             } else {
               select.setRel(filterValue.getRelationOperator());
             }
             jaxbUtil.addPatternSelect(pattern, select);
           }
           column.setPattern(pattern);
         }
       }
     }
   }
 }
コード例 #16
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  public void setSortProperties(String gid, int sortIndex, String sortDirection) {
    final TablelayoutType tableLayout = lguiItem.getLayoutAccess().getTableLayout(gid);

    // Delete old sorting settings
    for (final ColumnlayoutType column : tableLayout.getColumn()) {
      if (column.getSorted() != Columnsortedtype.FALSE) {
        column.setSorted(Columnsortedtype.FALSE);
      }
    }

    // Check if there is a sorting
    if (!sortDirection.equals(ITableColumnLayout.SORT_DIRECTION_NONE) && sortIndex != -1) {
      // Find the column and check for the sorting direction
      for (final ColumnlayoutType column : tableLayout.getColumn()) {
        if (column.getPos().equals(BigInteger.valueOf(sortIndex))) {
          if (sortDirection.equals(ITableColumnLayout.SORT_DIRECTION_UP)) {
            column.setSorted(Columnsortedtype.ASC);
          } else {
            column.setSorted(Columnsortedtype.DESC);
          }
        }
      }
    }
  }
コード例 #17
0
ファイル: TableHandler.java プロジェクト: eclipse/ptp
  /**
   * Reading out the select patterns from the JAXB objects.
   *
   * <p>Also taking care of the switch between the operators on the client side and in the LML file.
   *
   * @param gid Id of the table from which we want to get the list of patterns.
   * @return List of select patterns
   */
  public List<IPattern> getPattern(String gid) {
    // Expects both elements to be available table and tablelayout
    // Requires sort datatype from table and pattern from tablelayout
    final TablelayoutType tablelayout = lguiItem.getLayoutAccess().getTableLayout(gid);
    final TableType table = getTable(gid);
    final LinkedList<IPattern> patternList = new LinkedList<IPattern>();
    // Avoid null values
    if (tablelayout == null || table == null) {
      return patternList;
    }
    final HashMap<ColumnlayoutType, ColumnType> columnLayoutToColumn =
        new HashMap<ColumnlayoutType, ColumnType>();
    // Search column for each columnlayout
    for (final ColumnlayoutType columnLayout : tablelayout.getColumn()) {
      for (final ColumnType aColumn : table.getColumn()) {
        // Search for columnlayout referencing to the column's ID
        if (aColumn.getId().intValue() == columnLayout.getCid().intValue()) {
          columnLayoutToColumn.put(columnLayout, aColumn);
          break;
        }
      }
    }

    for (final ColumnlayoutType columnLayout : tablelayout.getColumn()) {
      final ColumnType column = columnLayoutToColumn.get(columnLayout);
      if (column != null && columnLayout != null && columnLayout.getPattern() != null) {
        final List<SelectType> selects =
            jaxbUtil.getSelects(columnLayout.getPattern().getIncludeAndExcludeAndSelect());
        if (selects.size() == 1) {
          String rel = null;
          if (selects.get(0).getRel().equals(ILMLCoreConstants.xLT_LC)) {
            rel = ILMLCoreConstants.LT;
          } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xLE_LC)) {
            rel = ILMLCoreConstants.LE;
          } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xGT_LC)) {
            rel = ILMLCoreConstants.GT;
          } else if (selects.get(0).getRel().equals(ILMLCoreConstants.xGE_LC)) {
            rel = ILMLCoreConstants.GE;
          } else {
            rel = selects.get(0).getRel();
          }
          if (rel != null) {
            patternList.add(
                (new Pattern(columnLayout.getKey(), column.getSort().value()))
                    .setRelation(rel, selects.get(0).getValue()));
          }
        } else if (selects.size() == 2) {
          String minValue = null;
          String maxValue = null;
          for (final SelectType select : selects) {
            if (select.getRel().equals(ILMLCoreConstants.xLE_LC)) {
              maxValue = select.getValue();
            } else if (select.getRel().equals(ILMLCoreConstants.xGE_LC)) {
              minValue = select.getValue();
            }
          }
          if (minValue != null && maxValue != null) {
            patternList.add(
                (new Pattern(columnLayout.getKey(), column.getSort().value()))
                    .setRange(minValue, maxValue));
          }
        }
      }
    }
    return patternList;
  }