/** * Create a custom field ordering from a list of strings representing field labels. There may * also be one or more optionally-quoted strings, each indicating a value to be inserted into a * constant-valued column. * * @param labels a list of field labels and optionally constant string values * @throws CustomColumnOrderingException if there is an unrecognised field name or no id fields */ public CustomColumnOrdering(List<String> labels) throws CustomColumnOrderingException { this.ordering = ReportColumn.fromStrings(labels); // Note we regenerate the labels from the ReportColumns so constant-valued // columns are consistently unquoted. this.orderedLabels = ReportColumn.getLabels(ordering); // Create the Field ordering this.fieldOrdering = new ArrayList<Field>() { { for (ReportColumn c : ordering) { if (c.isField()) add(c.field); } } }; // Sanity checks // Are there any fields included? if (this.fieldOrdering.isEmpty()) throw new CustomColumnOrderingException("", "No valid fields specified."); // Are there id fields included? if (!Field.idFields.clone().removeAll(this.fieldOrdering)) { String idFieldStr = String.format("(%s)", StringUtils.join(Field.getLabels(Field.idFields), ", ")); throw new CustomColumnOrderingException( "", String.format( "No identifying fields specified. You must include one of %s.", idFieldStr)); } // Set the field set if all is okay this.fields = EnumSet.copyOf(this.fieldOrdering); }
/** * Create an ordering from predefined lists of Fields and columns. This is enough information * from which to interpolate the other final members. Because there is no String interpretation, * there is no need to generate or catch exceptions. This version includes the ordered list of * labels, to save processing for those cases where the caller has already generated the list. * * @param fieldOrdering * @param ordering * @param orderedLabels */ private CustomColumnOrdering( final List<ReportColumn> ordering, final List<Field> fieldOrdering, final List<String> orderedLabels) { this.ordering = ordering; this.fieldOrdering = fieldOrdering; this.orderedLabels = orderedLabels; this.fields = EnumSet.copyOf(fieldOrdering); }
public Set<Color> toEnumSet() { if (isColorless()) { return EnumSet.of(Color.COLORLESS); } List<Color> list = new ArrayList<Color>(); for (Color c : Color.values()) { if (hasAnyColor(c.getColormask())) { list.add(c); } } return EnumSet.copyOf(list); }
/** * Adds a layout item to the grid. * * <p>Adds the <i>item</i> at (<i>row</i>, <code>column</code>). If an item was already added to * that location, it is replaced (but not deleted). * * <p>An item may span several more rows or columns, which is controlled by <i>rowSpan</i> and * <code>columnSpan</code>. * * <p>The <code>alignment</code> specifies the vertical and horizontal alignment of the item. The * default value 0 indicates that the item is stretched to fill the entire grid cell. The * alignment can be specified as a logical combination of a horizontal alignment ( {@link * AlignmentFlag#AlignLeft}, {@link AlignmentFlag#AlignCenter}, or {@link * AlignmentFlag#AlignRight}) and a vertical alignment ( {@link AlignmentFlag#AlignTop}, {@link * AlignmentFlag#AlignMiddle}, or {@link AlignmentFlag#AlignBottom}). * * <p> * * @see WGridLayout#addLayout(WLayout layout, int row, int column, EnumSet alignment) * @see WGridLayout#addWidget(WWidget widget, int row, int column, EnumSet alignment) */ public void addItem( WLayoutItem item, int row, int column, int rowSpan, int columnSpan, EnumSet<AlignmentFlag> alignment) { columnSpan = Math.max(1, columnSpan); rowSpan = Math.max(1, rowSpan); this.expand(row, column, rowSpan, columnSpan); final Grid.Item gridItem = this.grid_.items_.get(row).get(column); if (gridItem.item_ != null) { WLayoutItem oldItem = gridItem.item_; gridItem.item_ = null; this.updateRemoveItem(oldItem); } gridItem.item_ = item; gridItem.rowSpan_ = rowSpan; gridItem.colSpan_ = columnSpan; gridItem.alignment_ = EnumSet.copyOf(alignment); this.updateAddItem(item); }
/** Return the set of supported JVM features that improve the estimation. */ public static EnumSet<JvmFeature> getSupportedFeatures() { return EnumSet.copyOf(supportedFeatures); }
public void setRequired(EnumSet<InferenceType> required) { this.required = EnumSet.copyOf(required); }
/** * Set the media element options. * * <p> * * @see WAbstractMedia.Options */ public void setOptions(EnumSet<WAbstractMedia.Options> flags) { this.flags_ = EnumSet.copyOf(flags); this.flagsChanged_ = true; this.repaint(EnumSet.of(RepaintFlag.RepaintPropertyAttribute)); }
/** * Get the set of fields from the filter's field ordering which were omitted due to being empty. * * @return the set of empty fields which were omitted from the ordering */ public Set<Field> getOmittedEmptyFields() { Set<Field> empties = EnumSet.copyOf(columnOrdering.getFields()); empties.retainAll(emptyFields); return empties; }