ca.odell.glazedlists.EventList Java Examples
The following examples show how to use
ca.odell.glazedlists.EventList.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListComponent.java From ice with Eclipse Public License 1.0 | 6 votes |
/** * A protected constructor inherited from TransformedList. * * @param source * The source list used by the TransformedList. */ protected ListComponent(EventList<T> source) { super(source); // Create the logger logger = LoggerFactory.getLogger(getClass()); // Store the source list locally too so that JAXB gets it jaxbSourceList = (BasicEventList<T>) source; // Set up the ids - id, name, description and context idList = new BasicEventList<String>(); idList.add("1"); idList.add("ICE Object"); idList.add("ICE Object"); idList.add(""); // Setup the listener map listenerMap = new HashMap<IUpdateableListener, ListEventListener<Object>>(); }
Example #2
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 6 votes |
public static <T extends ItemType & EditablePriceType> void updatePrices(EventList<T> eventList, Set<Integer> typeIDs) { if (typeIDs == null || typeIDs.isEmpty()) { return; } List<T> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (T t : eventList) { if (typeIDs.contains(getTypeID(t.isBPC(), t.getItem().getTypeID()))) { found.add(t); //Save for update updatePrice(t); } } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #3
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 6 votes |
private void updateIndustryJobPrices(EventList<MyIndustryJob> eventList, Set<Integer> typeIDs) { if (typeIDs == null || typeIDs.isEmpty()) { return; } List<MyIndustryJob> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (MyIndustryJob industryJob : eventList) { if (typeIDs.contains(getTypeID(industryJob.isBPC(), industryJob.getItem().getTypeID())) || typeIDs.contains(getTypeID(industryJob.isCopying(), industryJob.getProductTypeID()))) { found.add(industryJob); //Save for update updatePrice(industryJob); //Update data } } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #4
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 6 votes |
public static <T extends EditableLocationType> void updateLocation(EventList<T> eventList, Set<Long> locationIDs) { if (locationIDs == null || locationIDs.isEmpty()) { return; } List<T> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (T t : eventList) { if (locationIDs.contains(t.getLocationID())) { found.add(t); //Save for update t.setLocation(ApiIdConverter.getLocation(t.getLocationID())); //Update data } } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #5
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 6 votes |
private <T extends LocationsType> void updateLocations(EventList<T> eventList, Set<Long> locationIDs) { if (locationIDs == null || locationIDs.isEmpty()) { return; } List<T> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (T t : eventList) { for (MyLocation location : t.getLocations()) { if (locationIDs.contains(location.getLocationID())) { found.add(t); //Save for update break; //Item already added } } } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #6
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 5 votes |
private void updateAssetPrices(EventList<MyAsset> eventList, Set<Integer> typeIDs) { if (typeIDs == null || typeIDs.isEmpty()) { return; } List<MyAsset> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (MyAsset asset : eventList) { //Reprocessed price boolean reprocessed = false; for (ReprocessedMaterial material : asset.getItem().getReprocessedMaterial()) { if (typeIDs.contains(material.getTypeID())) { reprocessed = true; break; } } if (reprocessed) { asset.setPriceReprocessed(ApiIdConverter.getPriceReprocessed(asset.getItem())); //Update data } //Dynamic Price boolean dynamic = typeIDs.contains(getTypeID(asset.isBPC(), asset.getItem().getTypeID())); if (dynamic) { updatePrice(asset); //Update data } //Update if (reprocessed || dynamic) { //If changed found.add(asset); //Save for update } } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #7
Source File: FlatGlazedListsTest.java From FlatLaf with Apache License 2.0 | 5 votes |
FlatGlazedListsTest() { initComponents(); EventList<Item> itemEventList = new BasicEventList<>(); itemEventList.add( new Item( "item 1", "item 1b", "January", 123, null ) ); itemEventList.add( new Item( "item 2", "item 2b", "February", 456, true ) ); itemEventList.add( new Item( "item 3", null, "March", null, false ) ); itemEventList.add( new Item( "item 4", null, "April", 234, true ) ); itemEventList.add( new Item( "item 5", null, "May", null, false ) ); itemEventList.add( new Item( "item 6", null, "June", null, null ) ); itemEventList.add( new Item( "item 7", null, "July", null, null ) ); itemEventList.add( new Item( "item 8", null, "August", null, null ) ); itemEventList.add( new Item( "item 9", null, "September", null, null ) ); itemEventList.add( new Item( "item 10", null, "October", null, null ) ); itemEventList.add( new Item( "item 11", null, "November", null, null ) ); itemEventList.add( new Item( "item 12", null, "December", null, null ) ); Comparator<Item> itemComparator = Comparator.comparing( Item::getName ); SortedList<Item> sortedItems = new SortedList<>( itemEventList, itemComparator ); AdvancedTableModel<Item> tableModel = GlazedListsSwing.eventTableModelWithThreadProxyList( sortedItems, new ItemTableFormat() ); itemsTable.setModel( tableModel ); TableComparatorChooser<Item> tableComparatorChooser = TableComparatorChooser.install( itemsTable, sortedItems, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE ); tableComparatorChooser.appendComparator( 0, 0, false ); TableComparatorChooser.setIconPath( "resources/windowsxp" ); }
Example #8
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> int indexOf(EventList<E> eventList, Object object) { try { eventList.getReadWriteLock().readLock().lock(); return eventList.indexOf(object); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #9
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> E get(EventList<E> eventList, int index) { try { eventList.getReadWriteLock().readLock().lock(); return eventList.get(index); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #10
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> int size(EventList<E> eventList) { try { eventList.getReadWriteLock().readLock().lock(); return eventList.size(); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #11
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> boolean contains(EventList<E> eventList, E e) { try { eventList.getReadWriteLock().readLock().lock(); return eventList.contains(e); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #12
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> boolean isEmpty(EventList<E> eventList) { try { eventList.getReadWriteLock().readLock().lock(); return eventList.isEmpty(); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #13
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> List<E> safeList(EventList<E> eventList) { try { eventList.getReadWriteLock().readLock().lock(); return new ArrayList<>(eventList); } finally { eventList.getReadWriteLock().readLock().unlock(); } }
Example #14
Source File: EventListManager.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> EventList<E> create() { if (Program.isDebug()) { DebugList<E> debugList = new DebugList<>(); debugList.setLockCheckingEnabled(true); return debugList; } else { return new BasicEventList<>(); } }
Example #15
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 5 votes |
private static <T> void updateList(EventList<T> eventList, List<T> found) { if (found.isEmpty()) { return; } if (found.size() > 2) { Program.ensureEDT(new Runnable() { @Override public void run() { try { eventList.getReadWriteLock().writeLock().lock(); List<T> cache = new ArrayList<>(eventList); eventList.clear(); eventList.addAll(cache); } finally { eventList.getReadWriteLock().writeLock().unlock(); } } }); } else { Program.ensureEDT(new Runnable() { @Override public void run() { try { eventList.getReadWriteLock().writeLock().lock(); eventList.removeAll(found); eventList.addAll(found); } finally { eventList.getReadWriteLock().writeLock().unlock(); } } }); } }
Example #16
Source File: ProfileData.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static void updateNames(EventList<MyAsset> eventList, Set<Long> itemIDs) { if (itemIDs == null || itemIDs.isEmpty()) { return; } List<MyAsset> found = new ArrayList<>(); try { eventList.getReadWriteLock().readLock().lock(); for (MyAsset asset : eventList) { if (itemIDs.contains(asset.getItemID())) { found.add(asset); //Save for update updateName(asset); //Update Name updateContainerChildren(found, asset.getAssets()); //Update Container } for (MyAsset parent : asset.getParents()) { //Offices if (parent.getTypeID() != 27) { continue; } if (itemIDs.contains(parent.getItemID())) { updateName(parent); //Update Name updateContainerChildren(found, parent.getAssets()); //Update Container } } } if (found.isEmpty()) { } } finally { eventList.getReadWriteLock().readLock().unlock(); } updateList(eventList, found); }
Example #17
Source File: EventModels.java From jeveassets with GNU General Public License v2.0 | 5 votes |
public static <E> EventList<E> createSwingThreadProxyList(EventList<E> source) { final EventList<E> result; source.getReadWriteLock().readLock().lock(); try { result = GlazedListsSwing.swingThreadProxyList(source); } finally { source.getReadWriteLock().readLock().unlock(); } return result; }
Example #18
Source File: XMLMaterialsDatabase.java From ice with Eclipse Public License 1.0 | 5 votes |
@Override public EventList<Material> getElements() { // Create a new event list and return it using the standard factory // method for GlazedLists. EventList<Material> list = GlazedLists.eventList(materialsMap.values()); return list; }
Example #19
Source File: FilterControl.java From jeveassets with GNU General Public License v2.0 | 5 votes |
protected FilterControl(final JFrame jFrame, final String name, final EventList<E> eventList, final EventList<E> exportEventList, final FilterList<E> filterList, final Map<String, List<Filter>> filters, final Map<String, List<Filter>> defaultFilters) { this.name = name; this.eventList = eventList; this.exportEventList = exportEventList; this.filterList = filterList; eventList.addListEventListener(new ListEventListener<E>() { @Override @SuppressWarnings("deprecation") public void listChanged(ListEvent<E> listChanges) { try { eventList.getReadWriteLock().readLock().lock(); List<E> delete = new ArrayList<E>(); List<E> update = new ArrayList<E>(); while(listChanges.next()) { switch (listChanges.getType()) { case ListEvent.DELETE: addSafe(delete, listChanges.getOldValue()); break; case ListEvent.UPDATE: addSafe(eventList, update, listChanges.getIndex()); break; } } cacheDelete(delete); cacheUpdate(update); } finally { eventList.getReadWriteLock().readLock().unlock(); } } }); this.filters = filters; this.defaultFilters = defaultFilters; ListenerClass listener = new ListenerClass(); filterList.addListEventListener(listener); gui = new FilterGui<E>(jFrame, this); cache = new HashMap<E, String>(); }
Example #20
Source File: AdjacentGroupingList.java From cropplanning with GNU General Public License v3.0 | 5 votes |
/** * A private constructor which provides a convenient handle to the * {@link SortedList} which will serve as the source of this list. * * @param source the elements to be grouped arranged in sorted order * @param comparator the {@link Comparator} used to determine groupings * @param dummyParameter dummy parameter to differentiate between the different * {@link AdjacentGroupingList} constructors. */ private AdjacentGroupingList(EventList<E> source, Comparator<? super E> comparator, Void dummyParameter) { super(source); // the grouper handles changes to the SortedList this.grouper = new AdjacentGrouper<E>( source, comparator, new AdjacentGroupingList.AdjacentGrouperClient()); // initialize the tree of GroupLists rebuildGroupListTreeFromBarcode(); source.addListEventListener(this); }
Example #21
Source File: AdjacentGrouper.java From cropplanning with GNU General Public License v3.0 | 4 votes |
/** * Create a new {@link AdjacentGrouper} that manages groups for the * specified {@link SortedList}. */ public AdjacentGrouper(EventList<E> sortedList, Comparator<? super E> comparator1, AdjacentGrouper.Client client) { this.sourceList = sortedList; this.client = client; setComparator( comparator1 ); }
Example #22
Source File: AssetsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public AssetFilterControl(JFrame jFrame, EventList<MyAsset> eventList, EventList<MyAsset> exportEventList, FilterList<MyAsset> filterList, Map<String, List<Filter>> filters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters); }
Example #23
Source File: IndustryJobsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public IndustryJobsFilterControl(EnumTableFormatAdaptor<IndustryJobTableFormat, MyIndustryJob> tableFormat, JFrame jFrame, EventList<MyIndustryJob> eventList, EventList<MyIndustryJob> exportEventList, FilterList<MyIndustryJob> filterList, Map<String, List<Filter>> filters, Map<String, List<Filter>> defaultFilters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters, defaultFilters); this.tableFormat = tableFormat; }
Example #24
Source File: ReprocessedTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public ReprocessedFilterControl(EnumTableFormatAdaptor<ReprocessedTableFormat, ReprocessedInterface> tableFormat, JFrame jFrame, EventList<ReprocessedInterface> eventList, EventList<ReprocessedInterface> exportEventList, FilterList<ReprocessedInterface> filterList, Map<String, List<Filter>> filters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters); this.tableFormat = tableFormat; }
Example #25
Source File: AssetsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public AssetsTab(final Program program) { super(program, TabsAssets.get().assets(), Images.TOOL_ASSETS.getIcon(), false); layout.setAutoCreateGaps(true); ListenerClass listener = new ListenerClass(); //Table Format tableFormat = new EnumTableFormatAdaptor<AssetTableFormat, MyAsset>(AssetTableFormat.class); //Backend EventList<MyAsset> eventList = program.getProfileData().getAssetsEventList(); //Sorting (per column) eventList.getReadWriteLock().readLock().lock(); SortedList<MyAsset> sortedList = new SortedList<MyAsset>(eventList); eventList.getReadWriteLock().readLock().unlock(); //Filter eventList.getReadWriteLock().readLock().lock(); filterList = new FilterList<MyAsset>(sortedList); eventList.getReadWriteLock().readLock().unlock(); filterList.addListEventListener(listener); //Table Model tableModel = EventModels.createTableModel(filterList, tableFormat); //Table jTable = new JAssetTable(program, tableModel); jTable.setCellSelectionEnabled(true); jTable.setRowSelectionAllowed(true); jTable.setColumnSelectionAllowed(true); //Sorting TableComparatorChooser.install(jTable, sortedList, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat); //Selection Model selectionModel = EventModels.createSelectionModel(filterList); selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE); jTable.setSelectionModel(selectionModel); //Listeners installTable(jTable, NAME); //Scroll JScrollPane jTableScroll = new JScrollPane(jTable); //Table Filter filterControl = new AssetFilterControl( program.getMainWindow().getFrame(), eventList, sortedList, filterList, Settings.get().getTableFilters(NAME) ); //Menu installMenu(program, new AssetTableMenu(), jTable, MyAsset.class); jVolume = StatusPanel.createLabel(TabsAssets.get().totalVolume(), Images.ASSETS_VOLUME.getIcon()); this.addStatusbarLabel(jVolume); jCount = StatusPanel.createLabel(TabsAssets.get().totalCount(), Images.EDIT_ADD.getIcon()); //Add this.addStatusbarLabel(jCount); jAverage = StatusPanel.createLabel(TabsAssets.get().average(), Images.ASSETS_AVERAGE.getIcon()); this.addStatusbarLabel(jAverage); jReprocessed = StatusPanel.createLabel(TabsAssets.get().totalReprocessed(), Images.SETTINGS_REPROCESSING.getIcon()); this.addStatusbarLabel(jReprocessed); jValue = StatusPanel.createLabel(TabsAssets.get().totalValue(), Images.TOOL_VALUES.getIcon()); this.addStatusbarLabel(jValue); layout.setHorizontalGroup( layout.createParallelGroup() .addComponent(filterControl.getPanel()) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createSequentialGroup() .addComponent(filterControl.getPanel()) .addComponent(jTableScroll, 0, 0, Short.MAX_VALUE) ); }
Example #26
Source File: ValueTableTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public ValueFilterControl(EnumTableFormatAdaptor<ValueTableFormat, Value> tableFormat, JFrame jFrame, EventList<Value> eventList, EventList<Value> exportEventList, FilterList<Value> filterList, Map<String, List<Filter>> filters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters); this.tableFormat = tableFormat; }
Example #27
Source File: StockpileTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public StockpileFilterControl(EnumTableFormatAdaptor<StockpileTableFormat, StockpileItem> tableFormat, JFrame jFrame, EventList<StockpileItem> eventList, EventList<StockpileItem> exportEventList, FilterList<StockpileItem> filterList, Map<String, List<Filter>> filters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters); this.tableFormat = tableFormat; }
Example #28
Source File: StockpileDialog.java From jeveassets with GNU General Public License v2.0 | 4 votes |
private void setLocationType(LocationType locationType) { this.locationType = locationType; boolean empty = false; if (locationType == LocationType.PLANET) { jLocationType.setIcon(Images.LOC_PLANET.getIcon()); jLocationType.setToolTipText(TabsStockpile.get().planet()); jPanel.setBorder(BorderFactory.createTitledBorder(TabsStockpile.get().planet())); try { planets.getReadWriteLock().readLock().lock(); empty = planets.isEmpty(); filterList = new FilterList<>(planets); } finally { planets.getReadWriteLock().readLock().unlock(); } jPlanet.setSelected(true); } else if (locationType == LocationType.STATION) { jLocationType.setIcon(Images.LOC_STATION.getIcon()); jLocationType.setToolTipText(TabsStockpile.get().station()); jPanel.setBorder(BorderFactory.createTitledBorder(TabsStockpile.get().station())); try { stations.getReadWriteLock().readLock().lock(); empty = stations.isEmpty(); filterList = new FilterList<>(stations); } finally { stations.getReadWriteLock().readLock().unlock(); } jStation.setSelected(true); } else if (locationType == LocationType.SYSTEM) { jLocationType.setIcon(Images.LOC_SYSTEM.getIcon()); jLocationType.setToolTipText(TabsStockpile.get().system()); jPanel.setBorder(BorderFactory.createTitledBorder(TabsStockpile.get().system())); try { systems.getReadWriteLock().readLock().lock(); empty = systems.isEmpty(); filterList = new FilterList<>(systems); } finally { systems.getReadWriteLock().readLock().unlock(); } jSystem.setSelected(true); } else if (locationType == LocationType.REGION) { jLocationType.setIcon(Images.LOC_REGION.getIcon()); jLocationType.setToolTipText(TabsStockpile.get().region()); jPanel.setBorder(BorderFactory.createTitledBorder(TabsStockpile.get().region())); try { regions.getReadWriteLock().readLock().lock(); empty = regions.isEmpty(); filterList = new FilterList<>(regions); } finally { regions.getReadWriteLock().readLock().unlock(); } jRegion.setSelected(true); } else { jLocationType.setIcon(Images.LOC_LOCATIONS.getIcon()); jLocationType.setToolTipText(TabsStockpile.get().universe()); jPanel.setBorder(BorderFactory.createTitledBorder(TabsStockpile.get().universe())); EventList<MyLocation> eventList = EventListManager.create(); try { eventList.getReadWriteLock().readLock().lock(); filterList = new FilterList<>(eventList); } finally { eventList.getReadWriteLock().readLock().unlock(); } jUniverse.setSelected(true); } if (autoComplete != null) { //Remove old jLocation.removeItemListener(listener); autoComplete.uninstall(); autoComplete = null; } if (locationType != LocationType.UNIVERSE) { if (empty) { jLocation.setEnabled(false); jLocation.getModel().setSelectedItem(TabsStockpile.get().noLocationsFound()); } else { jLocation.setEnabled(true); autoComplete = AutoCompleteSupport.install(jLocation, EventModels.createSwingThreadProxyList(filterList), new LocationsFilterator()); autoComplete.setStrict(true); autoComplete.setCorrectsCase(true); jLocation.addItemListener(listener); //Must be added after AutoCompleteSupport } } else { jLocation.setEnabled(false); jLocation.getModel().setSelectedItem(TabsStockpile.get().universe()); } }
Example #29
Source File: MarketOrdersTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public MarketOrdersFilterControl(EnumTableFormatAdaptor<MarketTableFormat, MyMarketOrder> tableFormat, JFrame jFrame, EventList<MyMarketOrder> eventList, EventList<MyMarketOrder> exportEventList, FilterList<MyMarketOrder> filterList, Map<String, List<Filter>> filters, Map<String, List<Filter>> defaultFilters) { super(jFrame, NAME, eventList, exportEventList, filterList, filters, defaultFilters); this.tableFormat = tableFormat; }
Example #30
Source File: FilterControl.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public EventList<E> getExportEventList() { return exportEventList; }