Source:
<code>private void addListenersToOutputButtons() { MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar(); outputToolBarButtons = toolBar.getButtons(); beforeCommandListenerForOutputButtons = new IExtendedButtonListener() { public void handleEvent(ExtendedButtonEvent event) { TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView() .getTableViewerCreatorForColumns(); if (tableViewerCreator != null) { tableViewerCreator.applyActivatedCellEditor(); } } }; <START> final List<OutputTable> outputTables = mapperManager.getOutputTables(); <END> IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() { public void handleEvent(ExtendedButtonEvent event) { for (OutputTable outputTable : outputTables) { DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(outputTable); view.getTableViewerCreatorForColumns().getTableViewer().refresh(); } } }; for (ExtendedPushButton extendedPushButton : outputToolBarButtons) { extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true); extendedPushButton.addListener(afterCommandListener, false); if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) { removeButton = (RemovePushButtonForExtendedTable) extendedPushButton; } } if (removeButton != null) { final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator(); tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() { public void handle(LineSelectionEvent e) { for (TableItem item : tableViewerCreator.getTable().getSelection()) { if (item.getData() instanceof MetadataColumn) { MetadataColumn column = (MetadataColumn) item.getData(); removeButton.getButton().setEnabled(!column.isCustom()); break; } } } }); } this.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { for (ExtendedPushButton extendedPushButton : outputToolBarButtons) { extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true); } } }); }</code><technical_language>put outputTables handleEvent function? add NPE check</technical_language>

Target:
private void addListenersToOutputButtons() { MetadataToolbarEditorView toolBar = outputMetaEditor.getToolBar(); outputToolBarButtons = toolBar.getButtons(); beforeCommandListenerForOutputButtons = new IExtendedButtonListener() { public void handleEvent(ExtendedButtonEvent event) { TableViewerCreator tableViewerCreator = mapperManager.getUiManager().getCurrentSelectedOutputTableView() .getTableViewerCreatorForColumns(); if (tableViewerCreator != null) { tableViewerCreator.applyActivatedCellEditor(); } } }; IExtendedButtonListener afterCommandListener = new IExtendedButtonListener() { public void handleEvent(ExtendedButtonEvent event) { List<OutputTable> outputTablesList = mapperManager.getOutputTables(); for (OutputTable outputTable : outputTablesList) { DataMapTableView view = mapperManager.retrieveAbstractDataMapTableView(outputTable); view.getTableViewerCreatorForColumns().getTableViewer().refresh(); } } }; for (ExtendedPushButton extendedPushButton : outputToolBarButtons) { extendedPushButton.addListener(beforeCommandListenerForOutputButtons, true); extendedPushButton.addListener(afterCommandListener, false); if (extendedPushButton instanceof RemovePushButton && !mapperManager.componentIsReadOnly()) { removeButton = (RemovePushButtonForExtendedTable) extendedPushButton; } } if (removeButton != null) { final TableViewerCreator tableViewerCreator = removeButton.getExtendedTableViewer().getTableViewerCreator(); tableViewerCreator.getSelectionHelper().addAfterSelectionListener(new ILineSelectionListener() { public void handle(LineSelectionEvent e) { for (TableItem item : tableViewerCreator.getTable().getSelection()) { if (item.getData() instanceof MetadataColumn) { MetadataColumn column = (MetadataColumn) item.getData(); removeButton.getButton().setEnabled(!column.isCustom()); break; } } } }); } this.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { for (ExtendedPushButton extendedPushButton : outputToolBarButtons) { extendedPushButton.removeListener(beforeCommandListenerForOutputButtons, true); } } }); }