ca.odell.glazedlists.SortedList Java Examples

The following examples show how to use ca.odell.glazedlists.SortedList. 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: FlatGlazedListsTest.java    From FlatLaf with 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 #2
Source File: TODOLists.java    From cropplanning with GNU General Public License v3.0 5 votes vote down vote up
public TODOLists() {
    setModuleName("TODOLists");
    setModuleType("Core");
    setModuleVersion( CPSGlobalSettings.getVersion() );

    tempCal = new GregorianCalendar();

    data = new BasicEventList<CPSPlanting>();
    dataFiltered = new FilterList<CPSPlanting>( data );
    dataSorted = new SortedList<CPSPlanting>( dataFiltered, null );
    
}
 
Example #3
Source File: JAutoCompleteDialog.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public JAutoCompleteDialog(Program program, String title, Image image, String msg, boolean strict, boolean allowOverwrite) {
	super(program, title, image);

	this.strict = strict;
	this.allowOverwrite = allowOverwrite;

	ListenerClass listener = new ListenerClass();

	JLabel jText = new JLabel(msg);

	jItems = new JComboBox<>();
	eventList = EventListManager.create();

	eventList.getReadWriteLock().readLock().lock();
	SortedList<T> sortedList = new SortedList<>(eventList, getComparator());
	eventList.getReadWriteLock().readLock().unlock();
	
	autoComplete = AutoCompleteSupport.install(jItems, EventModels.createSwingThreadProxyList(sortedList), getFilterator());
	autoComplete.setStrict(strict);

	jOK = new JButton(GuiShared.get().ok());
	jOK.setActionCommand(AutoCompleteAction.OK.name());
	jOK.addActionListener(listener);

	JButton jCancel = new JButton(GuiShared.get().cancel());
	jCancel.setActionCommand(AutoCompleteAction.CANCEL.name());
	jCancel.addActionListener(listener);

	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.LEADING)
			.addComponent(jText)
			.addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
				.addComponent(jItems, 220, 220, 220)
				.addGroup(layout.createSequentialGroup()
					.addComponent(jOK, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
					.addComponent(jCancel, Program.getButtonsWidth(), Program.getButtonsWidth(), Program.getButtonsWidth())
				)
			)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(jText, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addComponent(jItems, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			.addGroup(layout.createParallelGroup()
				.addComponent(jOK, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
				.addComponent(jCancel, Program.getButtonsHeight(), Program.getButtonsHeight(), Program.getButtonsHeight())
			)
	);
}
 
Example #4
Source File: ContractsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ContractsTab(Program program) {
	super(program, TabsContracts.get().title(), Images.TOOL_CONTRACTS.getIcon(), true);

	JFixedToolBar jToolBarLeft = new JFixedToolBar();

	JFixedToolBar jToolBarRight = new JFixedToolBar();

	JButton jCollapse = new JButton(TabsContracts.get().collapse(), Images.MISC_COLLAPSED.getIcon());
	jCollapse.setActionCommand(ContractsAction.COLLAPSE.name());
	jCollapse.addActionListener(listener);
	jToolBarRight.addButton(jCollapse);

	JButton jExpand = new JButton(TabsContracts.get().expand(), Images.MISC_EXPANDED.getIcon());
	jExpand.setActionCommand(ContractsAction.EXPAND.name());
	jExpand.addActionListener(listener);
	jToolBarRight.addButton(jExpand);

	//Table Format
	tableFormat = new EnumTableFormatAdaptor<ContractsTableFormat, MyContractItem>(ContractsTableFormat.class);
	//Backend
	eventList = program.getProfileData().getContractItemEventList();
	//Sorting (per column)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<MyContractItem> sortedListColumn = new SortedList<MyContractItem>(eventList);
	eventList.getReadWriteLock().readLock().unlock();

	//Sorting Separator (ensure export always has the right order)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<MyContractItem> sortedListSeparator = new SortedList<MyContractItem>(sortedListColumn, new SeparatorComparator());
	eventList.getReadWriteLock().readLock().unlock();

	//Filter
	eventList.getReadWriteLock().readLock().lock();
	filterList = new FilterList<MyContractItem>(sortedListSeparator);
	eventList.getReadWriteLock().readLock().unlock();
	//Separator
	separatorList = new SeparatorList<MyContractItem>(filterList, new SeparatorComparator(), 1, Integer.MAX_VALUE);
	//Table Model
	tableModel = EventModels.createTableModel(separatorList, tableFormat);
	//Table
	jTable = new JContractsTable(program, tableModel, separatorList);
	jTable.setSeparatorRenderer(new ContractsSeparatorTableCell(jTable, separatorList, listener));
	jTable.setSeparatorEditor(new ContractsSeparatorTableCell(jTable, separatorList, listener));
	jTable.setCellSelectionEnabled(true);
	PaddingTableCellRenderer.install(jTable, 3);
	//Sorting
	TableComparatorChooser.install(jTable, sortedListColumn, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
	//Selection Model
	selectionModel = EventModels.createSelectionModel(separatorList);
	selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE);
	jTable.setSelectionModel(selectionModel);
	//Listeners
	installTable(jTable, NAME);
	//Scroll
	JScrollPane jTableScroll = new JScrollPane(jTable);
	//Table Filter
	filterControl = new ContractsFilterControl(
			tableFormat,
			program.getMainWindow().getFrame(),
			eventList,
			sortedListSeparator,
			filterList,
			Settings.get().getTableFilters(NAME)
	);

	//Menu
	installMenu(program, new ContractsTableMenu(), jTable, MyContractItem.class);

	layout.setHorizontalGroup(
			layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
					.addComponent(filterControl.getPanel())
					.addGroup(layout.createSequentialGroup()
							.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
							.addGap(0)
							.addComponent(jToolBarRight)
					)
					.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
	layout.setVerticalGroup(
			layout.createSequentialGroup()
					.addComponent(filterControl.getPanel())
					.addGroup(layout.createParallelGroup()
							.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
							.addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					)
					.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
}
 
Example #5
Source File: TreeTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public AssetTreeSortedComparator(SortedList<TreeAsset> sortedList) {
	this.sortedList = sortedList;
}
 
Example #6
Source File: TreeTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public AssetTreeFormat(SortedList<TreeAsset> sortedList) {
	this.comparator = new AssetTreeSortedComparator(sortedList);
}
 
Example #7
Source File: ReprocessedTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ReprocessedTab(final Program program) {
	super(program, TabsReprocessed.get().title(), Images.TOOL_REPROCESSED.getIcon(), true);

	JFixedToolBar jToolBarLeft = new JFixedToolBar();

	JButton jClear = new JButton(TabsReprocessed.get().removeAll(), Images.EDIT_DELETE.getIcon());
	jClear.setActionCommand(ReprocessedAction.CLEAR.name());
	jClear.addActionListener(listener);
	jToolBarLeft.addButton(jClear);

	jToolBarLeft.addSpace(30);

	JLabel jInfo = new JLabel(TabsReprocessed.get().info());
	jInfo.setMinimumSize(new Dimension(100, Program.getButtonsHeight()));
	jInfo.setMaximumSize(new Dimension(Short.MAX_VALUE, Program.getButtonsHeight()));
	jInfo.setHorizontalAlignment(SwingConstants.LEFT);
	jToolBarLeft.add(jInfo);

	JFixedToolBar jToolBarRight = new JFixedToolBar();

	JButton jCollapse = new JButton(TabsReprocessed.get().collapse(), Images.MISC_COLLAPSED.getIcon());
	jCollapse.setActionCommand(ReprocessedAction.COLLAPSE.name());
	jCollapse.addActionListener(listener);
	jToolBarRight.addButton(jCollapse);

	JButton jExpand = new JButton(TabsReprocessed.get().expand(), Images.MISC_EXPANDED.getIcon());
	jExpand.setActionCommand(ReprocessedAction.EXPAND.name());
	jExpand.addActionListener(listener);
	jToolBarRight.addButton(jExpand);

	//Table Format
	tableFormat = new EnumTableFormatAdaptor<>(ReprocessedTableFormat.class);
	//Backend
	eventList = EventListManager.create();
	//Sorting (per column)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<ReprocessedInterface> sortedListColumn = new SortedList<>(eventList);
	eventList.getReadWriteLock().readLock().unlock();

	//Sorting Total (Ensure that total is always last)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<ReprocessedInterface> sortedListTotal = new SortedList<>(sortedListColumn, new TotalComparator());
	eventList.getReadWriteLock().readLock().unlock();
	//Filter
	eventList.getReadWriteLock().readLock().lock();
	filterList = new FilterList<>(sortedListTotal);
	eventList.getReadWriteLock().readLock().unlock();
	//Separator
	separatorList = new SeparatorList<>(filterList, new ReprocessedSeparatorComparator(), 1, Integer.MAX_VALUE);
	//Table Model
	tableModel = EventModels.createTableModel(separatorList, tableFormat);
	//Table
	jTable = new JReprocessedTable(program, tableModel, separatorList);
	jTable.setSeparatorRenderer(new ReprocessedSeparatorTableCell(jTable, separatorList, listener));
	jTable.setSeparatorEditor(new ReprocessedSeparatorTableCell(jTable, separatorList, listener));
	jTable.setCellSelectionEnabled(true);
	PaddingTableCellRenderer.install(jTable, 3);
	//Sorting
	TableComparatorChooser.install(jTable, sortedListColumn, TableComparatorChooser.MULTIPLE_COLUMN_MOUSE, tableFormat);
	//Selection Model
	selectionModel = EventModels.createSelectionModel(separatorList);
	selectionModel.setSelectionMode(ListSelection.MULTIPLE_INTERVAL_SELECTION_DEFENSIVE);
	jTable.setSelectionModel(selectionModel);
	//Listeners
	installTable(jTable, NAME);
	//Scroll
	JScrollPane jTableScroll = new JScrollPane(jTable);
	//Table Filter
	filterControl = new ReprocessedFilterControl(
			tableFormat,
			program.getMainWindow().getFrame(),
			eventList,
			sortedListTotal,
			filterList,
			Settings.get().getTableFilters(NAME)
			);

	//Menu
	installMenu(program, new ReprocessedTableMenu(), jTable, ReprocessedInterface.class);

	layout.setHorizontalGroup(
		layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
			.addComponent(filterControl.getPanel())
			.addGroup(layout.createSequentialGroup()
				.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, Integer.MAX_VALUE)
				.addGap(0)
				.addComponent(jToolBarRight)
			)
			.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(filterControl.getPanel())
			.addGroup(layout.createParallelGroup()
				.addComponent(jToolBarLeft, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
				.addComponent(jToolBarRight, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
			)
			.addComponent(jTableScroll, 0, 0, Short.MAX_VALUE)
	);
}
 
Example #8
Source File: ValueTableTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ValueTableTab(final Program program) {
	super(program, TabsValues.get().title(), Images.TOOL_VALUE_TABLE.getIcon(), true);
	//Table Format
	tableFormat = new EnumTableFormatAdaptor<>(ValueTableFormat.class);
	//Backend
	eventList = EventListManager.create();
	//Sorting (per column)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<Value> columnSortedList = new SortedList<>(eventList);
	eventList.getReadWriteLock().readLock().unlock();
	//Sorting Total
	eventList.getReadWriteLock().readLock().lock();
	SortedList<Value> totalSortedList = new SortedList<>(columnSortedList, new TotalComparator());
	eventList.getReadWriteLock().readLock().unlock();
	//Filter
	eventList.getReadWriteLock().readLock().lock();
	filterList = new FilterList<>(totalSortedList);
	eventList.getReadWriteLock().readLock().unlock();
	//Table Model
	tableModel = EventModels.createTableModel(filterList, tableFormat);
	//Table
	jTable = new JValueTable(program, tableModel);
	jTable.setCellSelectionEnabled(true);
	jTable.setRowSelectionAllowed(true);
	jTable.setColumnSelectionAllowed(true);
	PaddingTableCellRenderer.install(jTable, 3);
	//Sorting
	TableComparatorChooser.install(jTable, columnSortedList, 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 ValueFilterControl(
			tableFormat,
			program.getMainWindow().getFrame(),
			eventList,
			totalSortedList,
			filterList,
			Settings.get().getTableFilters(NAME)
			);

	//Menu
	installMenu(program, new ValueTableMenu(), jTable, Value.class);

	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 #9
Source File: AssetsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
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 #10
Source File: IndustryJobsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public IndustryJobsTab(final Program program) {
	super(program, TabsJobs.get().industry(), Images.TOOL_INDUSTRY_JOBS.getIcon(), true);

	ListenerClass listener = new ListenerClass();
	//Table Format
	tableFormat = new EnumTableFormatAdaptor<IndustryJobTableFormat, MyIndustryJob>(IndustryJobTableFormat.class);
	//Backend
	eventList = program.getProfileData().getIndustryJobsEventList();
	//Sorting (per column)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<MyIndustryJob> sortedList = new SortedList<MyIndustryJob>(eventList);
	eventList.getReadWriteLock().readLock().unlock();

	//Filter
	eventList.getReadWriteLock().readLock().lock();
	filterList = new FilterList<MyIndustryJob>(sortedList);
	eventList.getReadWriteLock().readLock().unlock();
	filterList.addListEventListener(listener);
	//Table Model
	tableModel = EventModels.createTableModel(filterList, tableFormat);
	//Table
	jTable = new JIndustryJobsTable(program, tableModel);
	jTable.setCellSelectionEnabled(true);
	PaddingTableCellRenderer.install(jTable, 1);
	//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
	Map<String, List<Filter>> defaultFilters = new HashMap<String, List<Filter>>();
	List<Filter> filter;
	filter = new ArrayList<Filter>();
	filter.add(new Filter(LogicType.AND, IndustryJobTableFormat.STATE, CompareType.EQUALS_NOT, IndustryJobState.STATE_DELIVERED.toString()));
	defaultFilters.put(TabsJobs.get().active(), filter);
	filter = new ArrayList<Filter>();
	filter.add(new Filter(LogicType.AND, IndustryJobTableFormat.STATE, CompareType.EQUALS, IndustryJobState.STATE_DELIVERED.toString()));
	defaultFilters.put(TabsJobs.get().completed(), filter);
	filterControl = new IndustryJobsFilterControl(
			tableFormat,
			program.getMainWindow().getFrame(),
			eventList,
			sortedList,
			filterList,
			Settings.get().getTableFilters(NAME),
			defaultFilters
			);

	//Menu
	installMenu(program, new JobsTableMenu(), jTable, MyIndustryJob.class);

	jInventionSuccess = StatusPanel.createLabel(TabsJobs.get().inventionSuccess(), Images.JOBS_INVENTION_SUCCESS.getIcon());
	this.addStatusbarLabel(jInventionSuccess);

	jManufactureOutputValue = StatusPanel.createLabel(TabsJobs.get().manufactureJobsValue(), Images.TOOL_VALUES.getIcon());
	this.addStatusbarLabel(jManufactureOutputValue);

	jCount = StatusPanel.createLabel(TabsJobs.get().count(), Images.EDIT_ADD.getIcon());
	this.addStatusbarLabel(jCount);

	layout.setHorizontalGroup(
		layout.createParallelGroup()
			.addComponent(filterControl.getPanel())
			.addComponent(jTableScroll, 700, 700, Short.MAX_VALUE)
	);
	layout.setVerticalGroup(
		layout.createSequentialGroup()
			.addComponent(filterControl.getPanel())
			.addComponent(jTableScroll, 100, 400, Short.MAX_VALUE)
	);
}
 
Example #11
Source File: ItemsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ItemsTab(final Program program) {
	super(program, TabsItems.get().items(), Images.TOOL_ITEMS.getIcon(), true);

	//Table Format
	tableFormat = new EnumTableFormatAdaptor<>(ItemTableFormat.class);
	//Backend
	eventList = EventListManager.create();
	//Sorting (per column)
	eventList.getReadWriteLock().readLock().lock();
	SortedList<Item> sortedList = new SortedList<>(eventList);
	eventList.getReadWriteLock().readLock().unlock();
	//Filter
	eventList.getReadWriteLock().readLock().lock();
	filterList = new FilterList<>(sortedList);
	eventList.getReadWriteLock().readLock().unlock();
	
	//Table Model
	tableModel = EventModels.createTableModel(filterList, tableFormat);
	//Table
	jTable = new JAutoColumnTable(program, tableModel);
	jTable.setCellSelectionEnabled(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 ItemsFilterControl(
			tableFormat,
			program.getMainWindow().getFrame(),
			eventList,
			sortedList,
			filterList,
			Settings.get().getTableFilters(NAME)
			);

	//Menu
	installMenu(program, new ItemTableMenu(), jTable, Item.class);

	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)
	);

	try {
		eventList.getReadWriteLock().writeLock().lock();
		eventList.clear();
		eventList.addAll(StaticData.get().getItems().values());
	} finally {
		eventList.getReadWriteLock().writeLock().unlock();
	}
}
 
Example #12
Source File: ItemsTab.java    From jeveassets with GNU General Public License v2.0 4 votes vote down vote up
public ItemsFilterControl(EnumTableFormatAdaptor<ItemTableFormat, Item> tableFormat, JFrame jFrame, EventList<Item> eventList, SortedList<Item> sortedList, FilterList<Item> filterList, Map<String, List<Filter>> filters) {
	super(jFrame, NAME, eventList, sortedList, filterList, filters);
	this.tableFormat = tableFormat;
}