/** * Changes the specified value * * @param fetcherId * @param newValue */ public void updateResult(int index, String fetcherId, Object newValue) { int fetcherIndex = fetcherRegistry.getSelectedFetcherIndex(CommentFetcher.ID); if (fetcherIndex >= 0) { // update the value in the results scanningResults.getResult(index).setValue(fetcherIndex, newValue); // update visual representation clear(index); } }
public ResultTable( Composite parent, GUIConfig guiConfig, FetcherRegistry fetcherRegistry, ScanningResultList scanningResultList, StateMachine stateMachine, ColumnsActions.ColumnClick columnClickListener, ColumnsActions.ColumnResize columnResizeListener) { super(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL); this.guiConfig = guiConfig; this.scanningResults = scanningResultList; this.fetcherRegistry = fetcherRegistry; setHeaderVisible(true); setLinesVisible(true); this.columnClickListener = columnClickListener; this.columnResizeListener = columnResizeListener; fetcherRegistry.addListener(this); // add columns according to fetchers handleUpdateOfSelectedFetchers(fetcherRegistry); // load button images listImages[ResultType.UNKNOWN.ordinal()] = new Image(null, Labels.getInstance().getImageAsStream("list.unknown.img")); listImages[ResultType.DEAD.ordinal()] = new Image(null, Labels.getInstance().getImageAsStream("list.dead.img")); listImages[ResultType.ALIVE.ordinal()] = new Image(null, Labels.getInstance().getImageAsStream("list.alive.img")); listImages[ResultType.WITH_PORTS.ordinal()] = new Image(null, Labels.getInstance().getImageAsStream("list.addinfo.img")); addListener(SWT.KeyDown, new CommandsMenuActions.Delete(this, stateMachine)); addListener(SWT.KeyDown, new CommandsMenuActions.CopyIP(this)); addListener(SWT.KeyDown, new ToolsActions.SelectAll(this)); // this one populates table dynamically, taking data from ScanningResultList addListener(SWT.SetData, new SetDataListener()); // listen to state machine events stateMachine.addTransitionListener(this); }
/** Rebuild column list according to selected fetchers */ public void handleUpdateOfSelectedFetchers(FetcherRegistry fetcherRegistry) { // remove all items (otherwise they will be shown incorrectly) removeAll(); // remove all columns TableColumn[] columns = getColumns(); for (int i = 0; i < columns.length; i++) { columns[i].dispose(); } // add the new selected columns back for (Fetcher fetcher : fetcherRegistry.getSelectedFetchers()) { TableColumn tableColumn = new TableColumn(this, SWT.NONE); tableColumn.setWidth(guiConfig.getColumnWidth(fetcher)); tableColumn.setData(fetcher); // this is used in some listeners in ColumnsActions tableColumn.addListener(SWT.Selection, columnClickListener); tableColumn.addListener(SWT.Resize, columnResizeListener); } updateColumnNames(); }
public void updateColumnNames() { int i = 0; for (Fetcher fetcher : fetcherRegistry.getSelectedFetchers()) { getColumn(i++).setText(fetcher.getFullName()); } }