/** * Changes the auto-update property of the selected official external modules. * * @param autoUpdate auto-update property to be set */ private void changeSelectedModsAutoUpdate(final Boolean autoUpdate) { final OffExtModConfsBean confsBean = LEnv.LAUNCHER_SETTINGS.get(LSettings.OFF_EXT_MOD_CONFS).cloneBean(); for (final int row : table.getSelectedModelRows()) confsBean .getModuleConfForFolder( ((ExtModRefBean) table.getModel().getValueAt(row, extModRefColIdx)).getFolder(), true) .setAutoUpdate(autoUpdate); LEnv.LAUNCHER_SETTINGS.set(LSettings.OFF_EXT_MOD_CONFS, confsBean); rebuildTable(); }
/** Rebuilds the table. */ private void rebuildTable() { table.saveSelection(extModRefColIdx); final ModulesBean modules = ScelightLauncher.INSTANCE().getModules(); // Only build table if modules bean has been retrieved. if (waitInfoWrapper.isVisible()) { if (modules == null) { if (recheckTimer == null) { // Start timer to periodically check if modules been has been retrieved recheckTimer = new Timer( 250, new ActionAdapter() { @Override public void actionPerformed(final ActionEvent event) { rebuildTable(); } }); recheckTimer.start(); } return; } else { if (recheckTimer != null) recheckTimer.stop(); waitInfoWrapper.setVisible(false); tableWrapperBox.setVisible(true); } } final Vector<Vector<Object>> data = new Vector<>(); final OffExtModConfsBean offExtModConfsBean = LEnv.LAUNCHER_SETTINGS.get(LSettings.OFF_EXT_MOD_CONFS); if (modules.getExtModRefList() != null) // This might be null if no internet connection... for (final ExtModRefBean emr : modules.getExtModRefList()) { final OffExtModConfBean conf = offExtModConfsBean.getModuleConfForFolder(emr.getFolder()); final StringBuilder authorsBuilder = new StringBuilder(); for (final PersonBean author : emr.getAuthorList()) { if (authorsBuilder.length() > 0) authorsBuilder.append(", "); authorsBuilder.append(LEnv.LANG.formatPersonName(author.getPersonName())); } data.add( LUtils.vector( emr, emr.getIcon(), emr.getName(), conf == null ? Boolean.FALSE : conf.getAutoUpdate(), authorsBuilder.toString(), LUtils.tryMakingUrl(emr.getHomePage()), emr.getShortDesc())); } table .getXTableModel() .setDataVector( data, LUtils.vector( "ExtModRef", "I", "Name", "Auto-updated?", "Author", "Home page", "Short description")); extModRefColIdx = 0; final int autoUpdateColIdx = 3; table.getXTableRowSorter().setColumnDefaultDesc(autoUpdateColIdx, true); table.getColumnModel().removeColumn(table.getColumnModel().getColumn(extModRefColIdx)); table.packColumnsExceptLast(); table.restoreSelection(extModRefColIdx); }