ca.odell.glazedlists.swing.TableComparatorChooser Java Examples
The following examples show how to use
ca.odell.glazedlists.swing.TableComparatorChooser.
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 |
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: ContractsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
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 #3
Source File: JournalTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
public JournalTab(final Program program) { super(program, TabsJournal.get().title(), Images.TOOL_JOURNAL.getIcon(), true); //Table Format tableFormat = new EnumTableFormatAdaptor<JournalTableFormat, MyJournal>(JournalTableFormat.class); //Backend EventList<MyJournal> eventList = program.getProfileData().getJournalEventList(); //Sorting (per column) eventList.getReadWriteLock().readLock().lock(); SortedList<MyJournal> sortedList = new SortedList<MyJournal>(eventList); eventList.getReadWriteLock().readLock().unlock(); //Filter eventList.getReadWriteLock().readLock().lock(); FilterList<MyJournal> filterList = new FilterList<MyJournal>(sortedList); eventList.getReadWriteLock().readLock().unlock(); //Table Model tableModel = EventModels.createTableModel(filterList, tableFormat); //Table jTable = new JJournalTable(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 Panels JScrollPane jTableScroll = new JScrollPane(jTable); //Table Filter filterControl = new JournalFilterControl( tableFormat, program.getMainWindow().getFrame(), eventList, sortedList, filterList, Settings.get().getTableFilters(NAME) ); //Menu installMenu(program, new JournalTableMenu(), jTable, MyJournal.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 #4
Source File: ReprocessedTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
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 #5
Source File: ValueTableTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
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 #6
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 #7
Source File: IndustryJobsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
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 #8
Source File: ItemsTab.java From jeveassets with GNU General Public License v2.0 | 4 votes |
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(); } }