/** * Creates a new table model that renders the specified list with an automatically * generated {@link TableFormat}. It uses JavaBeans and reflection to create * a {@link TableFormat} as specified. While holding a read lock, * this method wraps the source list using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}. * * <p>Note that classes that will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread.<p> * * @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. * */ public static <E> AdvancedTableModel<E> eventTableModelWithThreadProxyList(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { return eventTableModelWithThreadProxyList(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }
/** wraps the given source list with a swing thread proxy list, if necessary */ private static <E> TransformedList<E,E> createSwingThreadProxyList(EventList<E> source) { return GlazedListsSwing.isSwingThreadProxyList(source) ? null : GlazedListsSwing.swingThreadProxyList(source); }
/** * Creates a new list model that contains all objects located in the given * <code>source</code> and reacts to any changes in the given <code>source</code>. * * <p>The returned selection model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * </p> * * @param source the EventList that provides the elements */ public static <E> DefaultEventListModel<E> eventListModelWithThreadProxyList(EventList<E> source) { final EventList<E> proxySource = createSwingThreadProxyList(source); return new DefaultEventListModel<E>(proxySource, true); }
/** * Creates a new {@link JEventListPanel} hosting the * {@link JComponent}s from the specified source {@link EventList}. */ public JEventListPanel(EventList<E> source, Format<E> format) { this.swingSource = GlazedListsSwing.swingThreadProxyList(source); this.listLayout = new ListLayout(this, format); this.format = format; this.setLayout(listLayout); // populate the initial elements for(int i = 0; i < swingSource.size(); i++) { sourceChangeHandler.insert(i); } // listen for changes to the source swingSource.addListEventListener(sourceChangeHandler); }
FilterList<Issue> textFilteredIssues = new FilterList<Issue>(issues, textMatcherEditor); SortedList<Issue> sortedIssues = new SortedList<Issue>(textFilteredIssues, null); EventList<Issue> issueProxyList = GlazedListsSwing.swingThreadProxyList(sortedIssues); TableModel tableModel = GlazedListsSwing.eventTableModel(issueProxyList, new IssueTableFormat()); ListSelectionModel selectionModel = GlazedListsSwing.eventSelectionModel(issueProxyList);
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel if (table.getFillsViewportHeight()) { // workaround the problem of repainting issues when this property is // set, because of the known mismatch between ListEvents and TableModelEvents // use another event conversion strategy in this case final Factory<E> eventAdapterFactory = GlazedListsSwing.manyToOneEventAdapterFactory(); tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat, eventAdapterFactory); } else { // use default event conversion strategy tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); } table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
episodeEventList = new ObservableElementList<>(GlazedLists.threadSafeList(new BasicEventList<TvShowEpisodeChooserModel>()), GlazedLists.beanConnector(TvShowEpisodeChooserModel.class)); sortedEpisodes = new SortedList<>(GlazedListsSwing.swingThreadProxyList(episodeEventList), new EpisodeComparator()); new TvShowEpisodeChooserModelFilterator()); FilterList<TvShowEpisodeChooserModel> textFilteredEpisodes = new FilterList<>(sortedEpisodes, textMatcherEditor); AdvancedTableModel<TvShowEpisodeChooserModel> episodeTableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(textFilteredEpisodes, new EpisodeTableFormat()); DefaultEventSelectionModel<TvShowEpisodeChooserModel> selectionModel = new DefaultEventSelectionModel<>(textFilteredEpisodes);
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
/** * Creates a new table model 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 classes that will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * To do this programmatically, use {@link SwingUtilities#invokeAndWait(Runnable)} and * wrap the source list (or some part of the source list's pipeline) using * GlazedListsSwing#swingThreadProxyList(EventList).</p> * * @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. * */ public static <E> AdvancedTableModel<E> eventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { return eventTableModel(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }
/** * Creates a new {@link JEventListPanel} hosting the * {@link JComponent}s from the specified source {@link EventList}. */ public JEventListPanel(EventList<E> source, Format<E> format) { this.swingSource = GlazedListsSwing.swingThreadProxyList(source); this.listLayout = new ListLayout(this, format); this.format = format; this.setLayout(listLayout); // populate the initial elements for(int i = 0; i < swingSource.size(); i++) { sourceChangeHandler.insert(i); } // listen for changes to the source swingSource.addListEventListener(sourceChangeHandler); }
FilterList<Issue> textFilteredIssues = new FilterList<Issue>(issues, textMatcherEditor); SortedList<Issue> sortedIssues = new SortedList<Issue>(textFilteredIssues, null); EventList<Issue> issueProxyList = GlazedListsSwing.swingThreadProxyList(sortedIssues); TableModel tableModel = GlazedListsSwing.eventTableModel(issueProxyList, new IssueTableFormat()); ListSelectionModel selectionModel = GlazedListsSwing.eventSelectionModel(issueProxyList);
/** Installs the GlazedLists integration on the given JXTable. */ private JXTableSupport(JXTable table, EventList<E> eventList, TableFormat<? super E> tableFormat, SortedList<E> sortedList, Object sortingStrategy) { this.table = table; this.tableFormat = tableFormat; // remember table state for restore on uninstall tableMemento = JXTableMemento.create(table); tableMemento.storeStateFrom(table); // set state needed to integrate with Glazed Lists tableMemento.configureStateForGlazedLists(table); // prepare and set TableModel und SelectionModel tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList(eventList, tableFormat); table.setModel(tableModel); selectionModel = GlazedListsSwing.eventSelectionModelWithThreadProxyList(eventList); table.setSelectionModel(selectionModel); // finally install TableComparatorChooser tableComparatorChooser = TableComparatorChooser.<E>install(table, sortedList, sortingStrategy, tableFormat); }
/** * Creates a new table model 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 classes that will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * To do this programmatically, use {@link SwingUtilities#invokeAndWait(Runnable)} and * wrap the source list (or some part of the source list's pipeline) using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}.</p> * * @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. * */ public static <E> AdvancedTableModel<E> eventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { return eventTableModel(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }
/** wraps the given source list with a swing thread proxy list, if necessary */ private static <E> TransformedList<E,E> createSwingThreadProxyList(EventList<E> source) { return GlazedListsSwing.isSwingThreadProxyList(source) ? null : GlazedListsSwing.swingThreadProxyList(source); }
/** * Creates a new {@link JEventListPanel} hosting the * {@link JComponent}s from the specified source {@link EventList}. */ public JEventListPanel(EventList<E> source, Format<E> format) { this.swingSource = GlazedListsSwing.swingThreadProxyList(source); this.listLayout = new ListLayout(this, format); this.format = format; this.setLayout(listLayout); // populate the initial elements for(int i = 0; i < swingSource.size(); i++) { sourceChangeHandler.insert(i); } // listen for changes to the source swingSource.addListEventListener(sourceChangeHandler); }
FilterList<Issue> textFilteredIssues = new FilterList<Issue>(issues, textMatcherEditor); SortedList<Issue> sortedIssues = new SortedList<Issue>(textFilteredIssues, null); EventList<Issue> issueProxyList = GlazedListsSwing.swingThreadProxyList(sortedIssues); TableModel tableModel = GlazedListsSwing.eventTableModel(issueProxyList, new IssueTableFormat()); ListSelectionModel selectionModel = GlazedListsSwing.eventSelectionModel(issueProxyList);
/** * Creates a new table model that renders the specified list with an automatically * generated {@link TableFormat}. It uses JavaBeans and reflection to create * a {@link TableFormat} as specified. While holding a read lock, * this method wraps the source list using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}. * * <p>Note that classes that will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread.<p> * * @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. * */ public static <E> AdvancedTableModel<E> eventTableModelWithThreadProxyList(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { return eventTableModelWithThreadProxyList(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }
/** * Creates a new combobox model that contains all objects located in the given * <code>source</code> and reacts to any changes in the given <code>source</code>. * * <p>The returned combobox model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * </p> * * @param source the EventList that provides the elements */ public static <E> DefaultEventComboBoxModel<E> eventComboBoxModelWithThreadProxyList(EventList<E> source) { final EventList<E> proxySource = createSwingThreadProxyList(source); return new DefaultEventComboBoxModel<E>(proxySource, true); }
/** * Creates a new table model 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 classes that will be obfuscated may not work with * reflection. In this case, implement a {@link TableFormat} manually.</p> * * <p>The returned table model is <strong>not thread-safe</strong>. Unless otherwise * noted, all methods are only safe to be called from the event dispatch thread. * To do this programmatically, use {@link SwingUtilities#invokeAndWait(Runnable)} and * wrap the source list (or some part of the source list's pipeline) using * {@link GlazedListsSwing#swingThreadProxyList(EventList)}.</p> * * @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. * */ public static <E> AdvancedTableModel<E> eventTableModel(EventList<E> source, String[] propertyNames, String[] columnLabels, boolean[] writable) { return eventTableModel(source, GlazedLists.tableFormat(propertyNames, columnLabels, writable)); }
/** wraps the given source list with a swing thread proxy list, if necessary */ private static <E> TransformedList<E,E> createSwingThreadProxyList(EventList<E> source) { return GlazedListsSwing.isSwingThreadProxyList(source) ? null : GlazedListsSwing.swingThreadProxyList(source); }