Java Code Examples for ca.odell.glazedlists.EventList

The following examples show how to use ca.odell.glazedlists.EventList. These examples are extracted from open source projects. 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 Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 2
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 3
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 4
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 6 votes vote down vote up
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 5
Source Project: ice   Source File: ListComponent.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * 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 6
Source Project: FlatLaf   Source File: FlatGlazedListsTest.java    License: Apache License 2.0 5 votes vote down vote up
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 7
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 8
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 9
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 10
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static <E> EventList<E> create() {
	if (Program.isDebug()) {
		DebugList<E> debugList = new DebugList<>();
		debugList.setLockCheckingEnabled(true);
		return debugList;
	} else {
		return new BasicEventList<>();
	}
}
 
Example 11
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static <E> List<E> safeList(EventList<E> eventList) {
	try {
		eventList.getReadWriteLock().readLock().lock();
		return new ArrayList<>(eventList);
	} finally {
		eventList.getReadWriteLock().readLock().unlock();
	}
}
 
Example 12
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static <E> boolean isEmpty(EventList<E> eventList) {
	try {
		eventList.getReadWriteLock().readLock().lock();
		return eventList.isEmpty();
	} finally {
		eventList.getReadWriteLock().readLock().unlock();
	}
}
 
Example 13
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 14
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static <E> int size(EventList<E> eventList) {
	try {
		eventList.getReadWriteLock().readLock().lock();
		return eventList.size();
	} finally {
		eventList.getReadWriteLock().readLock().unlock();
	}
}
 
Example 15
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 16
Source Project: jeveassets   Source File: EventListManager.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 17
Source Project: jeveassets   Source File: EventModels.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 Project: jeveassets   Source File: FilterControl.java    License: GNU General Public License v2.0 5 votes vote down vote up
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 19
Source Project: ice   Source File: XMLMaterialsDatabase.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@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 20
/**
 * 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 Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyAccountBalance> getAccountBalanceEventList() {
	return accountBalanceEventList;
}
 
Example 22
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyAsset> getAssetsEventList() {
	return assetsEventList;
}
 
Example 23
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyIndustryJob> getIndustryJobsEventList() {
	return industryJobsEventList;
}
 
Example 24
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyMarketOrder> getMarketOrdersEventList() {
	return marketOrdersEventList;
}
 
Example 25
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyJournal> getJournalEventList() {
	return journalEventList;
}
 
Example 26
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyTransaction> getTransactionsEventList() {
	return transactionsEventList;
}
 
Example 27
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyContract> getContractEventList() {
	return contractEventList;
}
 
Example 28
Source Project: jeveassets   Source File: ProfileData.java    License: GNU General Public License v2.0 4 votes vote down vote up
public EventList<MyContractItem> getContractItemEventList() {
	return contractItemEventList;
}
 
Example 29
Source Project: jeveassets   Source File: EventModels.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static <E> DefaultEventTableModel<E> createTableModel(EventList<E> source, TableFormat<E> tableFormat) {
	// XXX - Workaround for java bug: https://bugs.openjdk.java.net/browse/JDK-8068824
	//return new DefaultEventTableModel<E>(createSwingThreadProxyList(source), tableFormat);
	return new FixedEventTableModel<E>(createSwingThreadProxyList(source), tableFormat);
}
 
Example 30
Source Project: jeveassets   Source File: EventModels.java    License: GNU General Public License v2.0 4 votes vote down vote up
public static <E> DefaultEventSelectionModel<E> createSelectionModel(EventList<E> source) {
	return new DefaultEventSelectionModel<E>(createSwingThreadProxyList(source));
}