/** * Creates a new {@link EventList} which contains the given elements. * * @param contents the list elements, if <code>null</code> the result will be an empty list * @return the new {@link EventList} */ public static <E> EventList<E> eventListOf(E... contents) { return eventList(contents == null ? Collections.<E>emptyList() : Arrays.asList(contents)); }
Comparator<T> firstComparator = beanPropertyComparator(clazz, property, comparableComparator()); comparators.add(beanPropertyComparator(clazz, properties[i], comparableComparator())); return chainComparators(comparators);
/** * Creates a reverse {@link Comparator} that works for {@link Comparable} objects. */ @SuppressWarnings("unchecked") public static <T extends Comparable> Comparator<T> reverseComparator() { if(reversedComparable == null) reversedComparable = reverseComparator(comparableComparator()); return (Comparator<T>)reversedComparable; }
return syncEventListToMultiMap(source, keyMaker, comparableComparator());
movieList = new ObservableElementList<>(GlazedLists.threadSafeList(new BasicEventList<Movie>()), GlazedLists.beanConnector(Movie.class)); movieSetList = ObservableCollections.observableList(Collections.synchronizedList(new ArrayList<MovieSet>())); tagsObservable = ObservableCollections.observableList(new CopyOnWriteArrayList<String>());
/** * Creates a new TableColumnComparator that sorts objects by the specified * column using the specified table format. */ public TableColumnComparator(TableFormat<? super E> tableFormat, int column) { this(tableFormat, column, GlazedLists.comparableComparator()); }
/** * Creates a chain of {@link Comparator}s that applies the provided * {@link Comparator}s in the sequence specified until differences or * absolute equality is determined. */ public static <T> Comparator<T> chainComparators(Comparator<T>... comparators) { return chainComparators(Arrays.asList(comparators)); }
/** * Create a new Connector for the {@link ObservableElementList} that works with JavaBeans' * {@link java.beans.PropertyChangeListener}. The methods to add and remove listeners are * detected automatically by examining the bean class and searching for a method prefixed with * "add" or "remove" taking a single {@link java.beans.PropertyChangeListener} argument. * <p>Use this variant, if you want to control which {@link java.beans.PropertyChangeEvent}s * are delivered to the ObservableElementList. You can match or filter events by name. * <p>If <code>matchPropertyNames</code> is <code>true</code>, the <code>propertyNames</code> * parameter specifies the set of properties by name whose {@link java.beans.PropertyChangeEvent}s * should be delivered to the ObservableElementList, e.g. property change events for properties * not contained in the specified <code>propertyNames</code> are ignored in this case. * If <code>matchPropertyNames</code> is <code>false</code>, then the specified * <code>propertyNames</code> are filtered, e.g. all but the specified property change events are * delivered to the ObservableElementList. * * @param beanClass a class with both * <code>addPropertyChangeListener(PropertyChangeListener)</code> and * <code>removePropertyChangeListener(PropertyChangeListener)</code>, or similar * methods. * @param matchPropertyNames if <code>true</code>, match property change events against the * specified property names, if <code>false</code> filter them * @param propertyNames specifies the properties by name whose {@link java.beans.PropertyChangeEvent}s * should be matched or filtered * @return an ObservableElementList.Connector for the specified class */ public static <E> ObservableElementList.Connector<E> beanConnector(Class<E> beanClass, boolean matchPropertyNames, String... propertyNames) { final Matcher<PropertyChangeEvent> byNameMatcher = Matchers.propertyEventNameMatcher(matchPropertyNames, propertyNames); return beanConnector(beanClass, byNameMatcher); }
/** * Creates a {@link TextFilterList} that filters the specified {@link EventList} * of elements using the JavaBeans property names specified to get the * {@link String}s to search. * * <p>Note that the classes which will be obfuscated may not work with * reflection. In this case, implement a {@link TextFilterator} manually. * * @param propertyNames an array of property names in the JavaBeans format. * For example, if your list contains Objects with the methods getFirstName(), * setFirstName(String), getAge(), setAge(Integer), then this array should * contain the two strings "firstName" and "age". This format is specified * by the JavaBeans {@link java.beans.PropertyDescriptor}. */ public TextFilterList(EventList source, String[] propertyNames) { this(source, null, GlazedLists.textFilterator(propertyNames)); }
/** * Creates a new viewer for the given {@link Table} that updates the table * contents in response to changes on the specified {@link EventList}. The * {@link Table} is formatted with an automatically generated * {@link TableFormat}. It uses JavaBeans and Reflection to create a * {@link TableFormat} as specified. * * @param source the EventList that provides the row objects * @param table the Table viewing the source objects * @param propertyNames an array of property names in the JavaBeans format. * For example, if your list contains Objects with the methods * getFirstName(), setFirstName(String), getAge(), setAge(Integer), * then this array should contain the two strings "firstName" and * "age". This format is specified by the JavaBeans * {@link java.beans.PropertyDescriptor}. * @param columnLabels the corresponding column names for the listed * property names. For example, if your columns are "firstName" and * "age", then your labels might be "First Name" and "Age". * @deprecated use a combination of * {@link GlazedLists#tableFormat(String[], String[])} and * {@link #EventTableViewer(EventList, Table, TableFormat)} * instead */ public EventTableViewer(EventList<E> source, Table table, String[] propertyNames, String[] columnLabels) { this(source, table, GlazedLists.tableFormat(propertyNames, columnLabels)); }
if(sortKey.getSortOrder() == SortOrder.DESCENDING) comparator = GlazedLists.reverseComparator(comparator); comparator = comparators.get(0); } else { comparator = GlazedLists.chainComparators((List)comparators);
public CompositeList() { super(new BasicEventList<EventList<E>>(), (Model)GlazedLists.listCollectionListModel()); }
/** * Gets the current best comparator to sort this column. */ public Comparator getComparator() { if(comparatorIndex == -1) return null; Comparator comparator = comparators.get(getComparatorIndex()); if(isReverse()) comparator = GlazedLists.reverseComparator(comparator); return comparator; }
this.mediaScraper = mediaScraper; this.metadata = new MediaEpisode(mediaScraper.getId()); episodeEventList = new ObservableElementList<>(GlazedLists.threadSafeList(new BasicEventList<TvShowEpisodeChooserModel>()), GlazedLists.beanConnector(TvShowEpisodeChooserModel.class)); sortedEpisodes = new SortedList<>(GlazedListsSwing.swingThreadProxyList(episodeEventList), new EpisodeComparator());
/** * Creates a new TableColumnComparator that sorts objects by the specified * column using the specified table format. */ public TableColumnComparator(TableFormat<? super E> tableFormat, int column) { this(tableFormat, column, GlazedLists.comparableComparator()); }
return syncEventListToMultiMap(source, keyMaker, comparableComparator());
/** * Creates a chain of {@link Comparator}s that applies the provided * {@link Comparator}s in the sequence specified until differences or * absolute equality is determined. */ public static <T> Comparator<T> chainComparators(Comparator<T>... comparators) { return chainComparators(Arrays.asList(comparators)); }
/** * Create a new Connector for the {@link ObservableElementList} that works with JavaBeans' * {@link java.beans.PropertyChangeListener}. The methods to add and remove listeners are * detected automatically by examining the bean class and searching for a method prefixed with * "add" or "remove" taking a single {@link java.beans.PropertyChangeListener} argument. * <p>Use this variant, if you want to control which {@link java.beans.PropertyChangeEvent}s * are delivered to the ObservableElementList. You can match or filter events by name. * <p>If <code>matchPropertyNames</code> is <code>true</code>, the <code>propertyNames</code> * parameter specifies the set of properties by name whose {@link java.beans.PropertyChangeEvent}s * should be delivered to the ObservableElementList, e.g. property change events for properties * not contained in the specified <code>propertyNames</code> are ignored in this case. * If <code>matchPropertyNames</code> is <code>false</code>, then the specified * <code>propertyNames</code> are filtered, e.g. all but the specified property change events are * delivered to the ObservableElementList. * * @param beanClass a class with both * <code>addPropertyChangeListener(PropertyChangeListener)</code> and * <code>removePropertyChangeListener(PropertyChangeListener)</code>, or similar * methods. * @param matchPropertyNames if <code>true</code>, match property change events against the * specified property names, if <code>false</code> filter them * @param propertyNames specifies the properties by name whose {@link java.beans.PropertyChangeEvent}s * should be matched or filtered * @return an ObservableElementList.Connector for the specified class */ public static <E> ObservableElementList.Connector<E> beanConnector(Class<E> beanClass, boolean matchPropertyNames, String... propertyNames) { final Matcher<PropertyChangeEvent> byNameMatcher = Matchers.propertyEventNameMatcher(matchPropertyNames, propertyNames); return beanConnector(beanClass, byNameMatcher); }
/** * Creates a {@link TextFilterList} that filters the specified {@link EventList} * of elements using the JavaBeans property names specified to get the * {@link String}s to search. * * <p>Note that the classes which will be obfuscated may not work with * reflection. In this case, implement a {@link TextFilterator} manually. * * @param propertyNames an array of property names in the JavaBeans format. * For example, if your list contains Objects with the methods getFirstName(), * setFirstName(String), getAge(), setAge(Integer), then this array should * contain the two strings "firstName" and "age". This format is specified * by the JavaBeans {@link java.beans.PropertyDescriptor}. * @param filterEdit a text field for typing in the filter text. */ public TextFilterList(EventList source, String[] propertyNames, JTextField filterEdit) { this(source, GlazedLists.textFilterator(propertyNames), filterEdit); }
/** * Creates a new table that renders the specified list with an automatically * generated {@link TableFormat}. It uses JavaBeans and reflection to create * a {@link TableFormat} as specified. * * <p>Note that the classes which will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually. * * @param source the EventList that provides the row objects * @param propertyNames an array of property names in the JavaBeans format. * For example, if your list contains Objects with the methods getFirstName(), * setFirstName(String), getAge(), setAge(Integer), then this array should * contain the two strings "firstName" and "age". This format is specified * by the JavaBeans {@link java.beans.PropertyDescriptor}. * @param columnLabels the corresponding column names for the listed property * names. For example, if your columns are "firstName" and "age", then * your labels might be "First Name" and "Age". * @param writable an array of booleans specifying which of the columns in * your table are writable. * * @deprecated Use {@link GlazedListsSwing#createEventTableModel(EventList, String[], String[], boolean[])} * and {@link GlazedListsSwing#swingThreadProxyList(EventList)} instead */ public EventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { this(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }