server/ServerWindow.java
/**
		 * Refresh all data in the table based on the data sources
		 */
Refresh all data in the table based on the data sources
Refresh all data in the table based on the data sources
public void refresh() {
			list = dataSource.get();
			Object[][] data = new Object[list.size()][columns.length];
			int index = 0;
			for(Model model : list) {
				data[index] = new Object[columns.length];
				int col = 0;
				for(String columnName : columns) {
					if(extras.containsKey(columnName)) {
						java.util.function.Supplier<Map<? extends Model, Object>> extraSource = extras.get(columnName);
						Map<? extends Model, Object> extraColumns = extraSource.get();
						data[index][col] = extraColumns.get(model);
					} else if(extras2.containsKey(columnName)) {
						Function<Model, Object> extraSource = extras2.get(columnName);
						data[index][col] = extraSource.apply(model);
					} else {
						try {
							Method method = model.getClass().getDeclaredMethod("get" + columnName);
							Object result = method.invoke(model, new Object[] {});
							if(result instanceof Model) {
								data[index][col] = ((Model) result).getName();
							} else {
								data[index][col] = result;
							}
						} catch (Exception e) {
							System.err.println("Unable to call get" + columnName + "() on " + model.getClass().getName());
							e.printStackTrace();
						}
					}
					col++;
				}
				index++;
			}
			this.data = data;
			this.fireTableDataChanged();
		}
public void refresh ( ) { list = dataSource . get ( ) ; Object [ ] [ ] data = new Object [ list . size ( ) ] [ columns . length ] ; int index = 0 ; for ( Model model : list ) { data [ index ] = new Object [ columns . length ] ; int col = 0 ; for ( String columnName : columns ) { if ( extras . containsKey ( columnName ) ) { java . util . function . Supplier < Map < ? extends Model , Object > > extraSource = extras . get ( columnName ) ; Map < ? extends Model , Object > extraColumns = extraSource . get ( ) ; data [ index ] [ col ] = extraColumns . get ( model ) ; } else if ( extras2 . containsKey ( columnName ) ) { Function < Model , Object > extraSource = extras2 . get ( columnName ) ; data [ index ] [ col ] = extraSource . apply ( model ) ; } else { try { Method method = model . getClass ( ) . getDeclaredMethod ( "get" + columnName ) ; Object result = method . invoke ( model , new Object [ ] { } ) ; if ( result instanceof Model ) { data [ index ] [ col ] = ( ( Model ) result ) . getName ( ) ; } else { data [ index ] [ col ] = result ; } } catch ( Exception e ) { System . err . println ( "Unable to call get" + columnName + "() on " + model . getClass ( ) . getName ( ) ) ; e . printStackTrace ( ) ; } } col ++ ; } index ++ ; } this . data = data ; this . fireTableDataChanged ( ) ; }
Refresh all data in the table based on the data sources
Refresh all data in the table based on the data sources
//Check for Model->Value mapping in extras //Check for Model->Value function in extras2 to call on each model //Otherwise, call get<ColumName> on the model //Move on to the next column //Move on to the next row