< prev index next >

application/org.openjdk.jmc.flightrecorder.ui/src/main/java/org/openjdk/jmc/flightrecorder/ui/pages/SocketIOPage.java

Print this page




  52 import org.eclipse.swt.custom.CTabFolder;
  53 import org.eclipse.swt.custom.CTabItem;
  54 import org.eclipse.swt.custom.SashForm;
  55 import org.eclipse.swt.layout.FillLayout;
  56 import org.eclipse.swt.widgets.Composite;
  57 import org.eclipse.swt.widgets.Control;
  58 import org.eclipse.ui.forms.widgets.Form;
  59 import org.eclipse.ui.forms.widgets.FormToolkit;
  60 
  61 import org.openjdk.jmc.common.IDisplayable;
  62 import org.openjdk.jmc.common.IState;
  63 import org.openjdk.jmc.common.IWritableState;
  64 import org.openjdk.jmc.common.item.IAccessorFactory;
  65 import org.openjdk.jmc.common.item.IAttribute;
  66 import org.openjdk.jmc.common.item.IItem;
  67 import org.openjdk.jmc.common.item.IItemCollection;
  68 import org.openjdk.jmc.common.item.IItemFilter;
  69 import org.openjdk.jmc.common.item.ItemFilters;
  70 import org.openjdk.jmc.common.unit.IQuantity;
  71 import org.openjdk.jmc.common.unit.IRange;

  72 import org.openjdk.jmc.common.unit.UnitLookup;
  73 import org.openjdk.jmc.common.util.ColorToolkit;
  74 import org.openjdk.jmc.common.util.StateToolkit;
  75 import org.openjdk.jmc.flightrecorder.JfrAttributes;
  76 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
  77 import org.openjdk.jmc.flightrecorder.jdk.JdkAttributes;
  78 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
  79 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
  80 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
  81 import org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI;
  82 import org.openjdk.jmc.flightrecorder.ui.IDataPageFactory;
  83 import org.openjdk.jmc.flightrecorder.ui.IDisplayablePage;
  84 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
  85 import org.openjdk.jmc.flightrecorder.ui.IPageDefinition;
  86 import org.openjdk.jmc.flightrecorder.ui.IPageUI;
  87 import org.openjdk.jmc.flightrecorder.ui.ItemCollectionToolkit;
  88 import org.openjdk.jmc.flightrecorder.ui.StreamModel;
  89 import org.openjdk.jmc.flightrecorder.ui.common.AbstractDataPage;
  90 import org.openjdk.jmc.flightrecorder.ui.common.CompositeKeyAccessorFactory;
  91 import org.openjdk.jmc.flightrecorder.ui.common.DataPageToolkit;


 184                 LIST.addColumn(JdkAttributes.IO_SOCKET_READ_EOS);
 185                 LIST.addColumn(JdkAttributes.IO_TIMEOUT);
 186         }
 187 
 188         private enum HistogramType {
 189                 HOST, PORT, HOST_AND_PORT
 190         }
 191 
 192         private class IOPageUi implements IPageUI {
 193                 private static final String PRIMARY_FILTER = "primaryFilter"; //$NON-NLS-1$
 194                 private static final String SECONDARY_FILTER = "secondaryFilter"; //$NON-NLS-1$
 195                 private static final String EVENT_FILTER = "eventFilter"; //$NON-NLS-1$
 196                 private static final String SASH_ELEMENT = "sash"; //$NON-NLS-1$
 197                 private static final String LIST_ELEMENT = "eventList"; //$NON-NLS-1$
 198                 private static final String SOCKETIO_TABLE_ELEMENT = "socketTable"; //$NON-NLS-1$
 199                 private static final String SECONDARY_SOCKETIO_TABLE_ELEMENT = "secondarySocketTable"; //$NON-NLS-1$
 200                 private static final String HISTGRAM_TYPE = "histogramType"; //$NON-NLS-1$
 201 
 202                 private final ChartCanvas timelineCanvas;
 203                 private final ChartCanvas durationCanvas;

 204                 private final ItemList itemList;
 205 
 206                 private final SashForm sash;
 207                 private final IPageContainer pageContainer;
 208                 private final Composite histogramParent;
 209                 private ItemHistogram primaryHistogram;
 210                 private Supplier<TableSettings> secondaryHistogramSettings;
 211                 private Consumer<IItemCollection> itemConsumerRoot;
 212                 private HistogramType histogramType;
 213                 private ItemHistogram secondaryHistogram;
 214                 private FilterComponent primaryFilter;
 215                 private FilterComponent secondaryFilter;
 216                 private FilterComponent eventFilter;
 217                 private IRange<IQuantity> timeRange;
 218                 private IItemCollection selectionItems;
 219                 private XYChart timelineChart;
 220                 private XYChart durationChart;

 221                 private CTabFolder tabFolder;
 222                 private FlavorSelector flavorSelector;
 223 
 224                 IOPageUi(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
 225                         this.pageContainer = pageContainer;
 226                         Form form = DataPageToolkit.createForm(parent, toolkit, getName(), getIcon());
 227                         sash = new SashForm(form.getBody(), SWT.VERTICAL);
 228                         toolkit.adapt(sash);
 229                         histogramParent = toolkit.createComposite(sash);
 230                         histogramParent.setLayout(new FillLayout(SWT.VERTICAL));
 231                         histogramType = StateToolkit.readEnum(state, HISTGRAM_TYPE, HistogramType.HOST, HistogramType.class);
 232                         buildHistograms(TableSettings.forState(state.getChild(SOCKETIO_TABLE_ELEMENT)),
 233                                         TableSettings.forState(state.getChild(SECONDARY_SOCKETIO_TABLE_ELEMENT)));
 234 
 235                         tabFolder = new CTabFolder(sash, SWT.NONE);
 236                         toolkit.adapt(tabFolder);
 237                         CTabItem t1 = new CTabItem(tabFolder, SWT.NONE);
 238                         t1.setToolTipText(Messages.IO_PAGE_TIMELINE_DESCRIPTION);
 239                         timelineCanvas = new ChartCanvas(tabFolder);
 240                         t1.setText(Messages.PAGES_TIMELINE);


 247                         // FIXME: X-auto-range should be done properly
 248                         IQuantity max = socketItems.getAggregate(JdkAggregators.LONGEST_EVENT);
 249                         // FIXME: Workaround to make max value included
 250                         max = max == null ? UnitLookup.MILLISECOND.quantity(20) : max.add(UnitLookup.MILLISECOND.quantity(20));
 251                         durationChart = new XYChart(UnitLookup.MILLISECOND.quantity(0), max, RendererToolkit.empty(), 180);
 252                         durationChart.setVisibleRange(durationRange.getStart(), durationRange.getEnd());
 253                         durationChart.addVisibleRangeListener(r -> durationRange = r);
 254                         buildChart();
 255 
 256                         CTabItem t2 = new CTabItem(tabFolder, SWT.NONE);
 257                         t2.setToolTipText(Messages.IO_PAGE_DURATIONS_DESCRIPTION);
 258                         durationCanvas = new ChartCanvas(tabFolder);
 259                         t2.setText(Messages.PAGES_DURATIONS);
 260                         t2.setControl(durationCanvas);
 261                         DataPageToolkit.createChartTooltip(durationCanvas);
 262                         DataPageToolkit.setChart(durationCanvas, durationChart, JfrAttributes.DURATION,
 263                                         pageContainer::showSelection);
 264                         SelectionStoreActionToolkit.addSelectionStoreActions(pageContainer.getSelectionStore(), durationChart,
 265                                         JfrAttributes.DURATION, Messages.SocketIOPage_DURATION_SELECTION, durationCanvas.getContextMenu());
 266 








 267                         CTabItem t3 = new CTabItem(tabFolder, SWT.NONE);
 268                         t3.setToolTipText(Messages.IO_PAGE_EVENT_LOG_DESCRIPTION);











 269                         itemList = LIST.buildWithoutBorder(tabFolder, getTableSettings(state.getChild(LIST_ELEMENT)));
 270                         MCContextMenuManager itemListMm = MCContextMenuManager
 271                                         .create(itemList.getManager().getViewer().getControl());
 272                         ColumnMenusFactory.addDefaultMenus(itemList.getManager(), itemListMm);
 273                         SelectionStoreActionToolkit.addSelectionStoreActions(pageContainer.getSelectionStore(), itemList,
 274                                         Messages.SocketIOPage_LOG_SELECTION, itemListMm);
 275                         itemList.getManager().getViewer().addSelectionChangedListener(
 276                                         e -> pageContainer.showSelection(ItemCollectionToolkit.build(itemList.getSelection().get())));
 277                         t3.setText(Messages.PAGES_EVENT_LOG);
 278                         eventFilter = FilterComponent.createFilterComponent(itemList, itemListFilter,
 279                                         getDataSource().getItems().apply(TABLE_ITEMS), pageContainer.getSelectionStore()::getSelections,
 280                                         this::onEventFilterChange);
 281                         itemListMm.add(eventFilter.getShowFilterAction());
 282                         itemListMm.add(eventFilter.getShowSearchAction());
 283                         t3.setControl(eventFilter.getComponent());
 284                         eventFilter.loadState(state.getChild(EVENT_FILTER));
 285                         onEventFilterChange(itemListFilter);
 286                         itemList.getManager().setSelectionState(itemListSelection);
 287 


 288                         tabFolder.setSelection(tabFolderIndex);
 289 
 290                         PersistableSashForm.loadState(sash, state.getChild(SASH_ELEMENT));
 291 
 292                         flavorSelector = FlavorSelector.itemsWithTimerange(form, TABLE_ITEMS, getDataSource().getItems(),
 293                                         pageContainer, this::onInputSelected, this::onUseRange, flavorSelectorState);
 294 
 295                         form.getToolBarManager()
 296                                         .appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(HistogramType.HOST,
 297                                                         Messages.SocketIOPage_BY_HOST_ACTION,
 298                                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_HOST)));
 299                         form.getToolBarManager()
 300                                         .appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(HistogramType.PORT,
 301                                                         Messages.SocketIOPage_BY_PORT_ACTION,
 302                                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_PORT)));
 303                         form.getToolBarManager().appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(
 304                                         HistogramType.HOST_AND_PORT, Messages.SocketIOPage_BY_HOST_AND_PORT_ACTION,
 305                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_HOST_AND_PORT)));
 306 
 307                         addResultActions(form);


 442                         SelectionStoreActionToolkit.addSelectionStoreRangeActions(pageContainer.getSelectionStore(), timelineChart,
 443                                         JfrAttributes.LIFETIME, Messages.SocketIOPage_TIMELINE_SELECTION, timelineCanvas.getContextMenu());
 444                 }
 445 
 446                 private void onInputSelected(IItemCollection items, IRange<IQuantity> timeRange) {
 447                         this.selectionItems = items;
 448                         this.timeRange = timeRange;
 449                         refreshPageItems();
 450                 }
 451 
 452                 private void refreshPageItems() {
 453                         IItemCollection items = selectionItems != null ? selectionItems : getDataSource().getItems();
 454                         itemConsumerRoot.accept(items.apply(JdkFilters.SOCKET_READ_OR_WRITE));
 455                 }
 456 
 457                 private void updateChartAndListDetails(IItemCollection selectedItems) {
 458                         String hostCount = hostPortCount();
 459 
 460                         List<IXDataRenderer> timelineRows = new ArrayList<>();
 461                         List<IXDataRenderer> durationRows = new ArrayList<>();


 462                         IItemCollection readItems = selectedItems.apply(JdkFilters.SOCKET_READ);
 463                         if (readItems.hasItems()) {
 464                                 timelineRows.add(DataPageToolkit.buildSizeRow(Messages.SocketIOPage_ROW_SOCKET_READ + hostCount,
 465                                                 JdkAggregators.SOCKET_READ_SIZE.getDescription(), readItems, JdkAggregators.SOCKET_READ_SIZE,
 466                                                 READ_COLOR, SocketIOPage::getColor));
 467                                 durationRows
 468                                                 .add(DataPageToolkit.buildDurationHistogram(Messages.SocketIOPage_ROW_SOCKET_READ + hostCount,
 469                                                                 JdkAggregators.SOCKET_READ_COUNT.getDescription(), readItems,
 470                                                                 JdkAggregators.SOCKET_READ_COUNT, READ_COLOR));



 471                         }
 472                         IItemCollection writeItems = selectedItems.apply(JdkFilters.SOCKET_WRITE);
 473                         if (writeItems.hasItems()) {
 474                                 timelineRows.add(DataPageToolkit.buildSizeRow(Messages.SocketIOPage_ROW_SOCKET_WRITE + hostCount,
 475                                                 JdkAggregators.SOCKET_WRITE_SIZE.getDescription(), writeItems, JdkAggregators.SOCKET_WRITE_SIZE,
 476                                                 WRITE_COLOR, SocketIOPage::getColor));
 477                                 durationRows
 478                                                 .add(DataPageToolkit.buildDurationHistogram(Messages.SocketIOPage_ROW_SOCKET_WRITE + hostCount,
 479                                                                 JdkAggregators.SOCKET_WRITE_COUNT.getDescription(), writeItems,
 480                                                                 JdkAggregators.SOCKET_WRITE_COUNT, WRITE_COLOR));



 481                         }
 482                         if (timelineCanvas != null) {
 483                                 timelineCanvas.replaceRenderer(RendererToolkit.uniformRows(timelineRows));
 484                                 durationCanvas.replaceRenderer(RendererToolkit.uniformRows(durationRows));


 485 
 486                                 itemList.show(selectedItems);
 487                                 pageContainer.showSelection(selectedItems);
 488                         }
 489                 }
 490 
 491                 public String hostPortCount() {
 492                         HistogramSelection hostSelection = histogramType == HistogramType.HOST ? primaryHistogram.getSelection()
 493                                         : histogramType == HistogramType.PORT ? secondaryHistogram.getSelection() : null;
 494                         HistogramSelection portSelection = histogramType == HistogramType.PORT ? primaryHistogram.getSelection()
 495                                         : histogramType == HistogramType.HOST ? secondaryHistogram.getSelection() : null;
 496                         HistogramSelection hostPortSelection = histogramType == HistogramType.HOST_AND_PORT
 497                                         ? primaryHistogram.getSelection() : null;
 498 
 499                         return hostPortCount(hostSelection != null ? hostSelection.getRowCount() : 0,
 500                                         portSelection != null ? portSelection.getRowCount() : 0,
 501                                         hostPortSelection != null ? hostPortSelection.getRowCount() : 0);
 502                 }
 503 
 504                 public String hostPortCount(int hostCount, int portCount, int hostPortCount) {


 551                                         new ColumnSettings(READ_SIZE, false, 120, false), new ColumnSettings(WRITE_SIZE, false, 120, false),
 552                                         new ColumnSettings(READ_EOS, false, 80, false), new ColumnSettings(IO_TIMEOUT, false, 50, false)));
 553                 } else {
 554                         return new TableSettings(state);
 555                 }
 556         }
 557 
 558         @Override
 559         public IPageUI display(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
 560                 return new IOPageUi(parent, toolkit, pageContainer, state);
 561         }
 562 
 563         private Map<HistogramType, SelectionState> primaryTableSelection;
 564         private Map<HistogramType, SelectionState> secondaryTableSelection;
 565         private SelectionState itemListSelection;
 566         private Map<HistogramType, IItemFilter> primaryTableFilter;
 567         private Map<HistogramType, IItemFilter> secondaryTableFilter;
 568         private IItemFilter itemListFilter;
 569         private IRange<IQuantity> timelineRange;
 570         private IRange<IQuantity> durationRange;

 571         private int tabFolderIndex = 0;
 572         public FlavorSelectorState flavorSelectorState;
 573 
 574         public SocketIOPage(IPageDefinition dpd, StreamModel items, IPageContainer editor) {
 575                 super(dpd, items, editor);
 576                 primaryTableSelection = new HashMap<>();
 577                 secondaryTableSelection = new HashMap<>();
 578                 primaryTableFilter = new HashMap<>();
 579                 secondaryTableFilter = new HashMap<>();
 580                 timelineRange = editor.getRecordingRange();
 581                 durationRange = editor.getRecordingRange();


 582         }
 583 
 584         @Override
 585         public IItemFilter getDefaultSelectionFilter() {
 586                 return TABLE_ITEMS;
 587         }
 588 
 589         private static Color getColor(IItem item) {
 590                 return JdkTypeIDs.SOCKET_READ.equals(item.getType().getIdentifier()) ? READ_ALPHA_COLOR : WRITE_ALPHA_COLOR;
 591         }
 592 
 593 }


  52 import org.eclipse.swt.custom.CTabFolder;
  53 import org.eclipse.swt.custom.CTabItem;
  54 import org.eclipse.swt.custom.SashForm;
  55 import org.eclipse.swt.layout.FillLayout;
  56 import org.eclipse.swt.widgets.Composite;
  57 import org.eclipse.swt.widgets.Control;
  58 import org.eclipse.ui.forms.widgets.Form;
  59 import org.eclipse.ui.forms.widgets.FormToolkit;
  60 
  61 import org.openjdk.jmc.common.IDisplayable;
  62 import org.openjdk.jmc.common.IState;
  63 import org.openjdk.jmc.common.IWritableState;
  64 import org.openjdk.jmc.common.item.IAccessorFactory;
  65 import org.openjdk.jmc.common.item.IAttribute;
  66 import org.openjdk.jmc.common.item.IItem;
  67 import org.openjdk.jmc.common.item.IItemCollection;
  68 import org.openjdk.jmc.common.item.IItemFilter;
  69 import org.openjdk.jmc.common.item.ItemFilters;
  70 import org.openjdk.jmc.common.unit.IQuantity;
  71 import org.openjdk.jmc.common.unit.IRange;
  72 import org.openjdk.jmc.common.unit.QuantitiesToolkit;
  73 import org.openjdk.jmc.common.unit.UnitLookup;
  74 import org.openjdk.jmc.common.util.ColorToolkit;
  75 import org.openjdk.jmc.common.util.StateToolkit;
  76 import org.openjdk.jmc.flightrecorder.JfrAttributes;
  77 import org.openjdk.jmc.flightrecorder.jdk.JdkAggregators;
  78 import org.openjdk.jmc.flightrecorder.jdk.JdkAttributes;
  79 import org.openjdk.jmc.flightrecorder.jdk.JdkFilters;
  80 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
  81 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
  82 import org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI;
  83 import org.openjdk.jmc.flightrecorder.ui.IDataPageFactory;
  84 import org.openjdk.jmc.flightrecorder.ui.IDisplayablePage;
  85 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
  86 import org.openjdk.jmc.flightrecorder.ui.IPageDefinition;
  87 import org.openjdk.jmc.flightrecorder.ui.IPageUI;
  88 import org.openjdk.jmc.flightrecorder.ui.ItemCollectionToolkit;
  89 import org.openjdk.jmc.flightrecorder.ui.StreamModel;
  90 import org.openjdk.jmc.flightrecorder.ui.common.AbstractDataPage;
  91 import org.openjdk.jmc.flightrecorder.ui.common.CompositeKeyAccessorFactory;
  92 import org.openjdk.jmc.flightrecorder.ui.common.DataPageToolkit;


 185                 LIST.addColumn(JdkAttributes.IO_SOCKET_READ_EOS);
 186                 LIST.addColumn(JdkAttributes.IO_TIMEOUT);
 187         }
 188 
 189         private enum HistogramType {
 190                 HOST, PORT, HOST_AND_PORT
 191         }
 192 
 193         private class IOPageUi implements IPageUI {
 194                 private static final String PRIMARY_FILTER = "primaryFilter"; //$NON-NLS-1$
 195                 private static final String SECONDARY_FILTER = "secondaryFilter"; //$NON-NLS-1$
 196                 private static final String EVENT_FILTER = "eventFilter"; //$NON-NLS-1$
 197                 private static final String SASH_ELEMENT = "sash"; //$NON-NLS-1$
 198                 private static final String LIST_ELEMENT = "eventList"; //$NON-NLS-1$
 199                 private static final String SOCKETIO_TABLE_ELEMENT = "socketTable"; //$NON-NLS-1$
 200                 private static final String SECONDARY_SOCKETIO_TABLE_ELEMENT = "secondarySocketTable"; //$NON-NLS-1$
 201                 private static final String HISTGRAM_TYPE = "histogramType"; //$NON-NLS-1$
 202 
 203                 private final ChartCanvas timelineCanvas;
 204                 private final ChartCanvas durationCanvas;
 205                 private final ChartCanvas sizeCanvas;
 206                 private final ItemList itemList;
 207 
 208                 private final SashForm sash;
 209                 private final IPageContainer pageContainer;
 210                 private final Composite histogramParent;
 211                 private ItemHistogram primaryHistogram;
 212                 private Supplier<TableSettings> secondaryHistogramSettings;
 213                 private Consumer<IItemCollection> itemConsumerRoot;
 214                 private HistogramType histogramType;
 215                 private ItemHistogram secondaryHistogram;
 216                 private FilterComponent primaryFilter;
 217                 private FilterComponent secondaryFilter;
 218                 private FilterComponent eventFilter;
 219                 private IRange<IQuantity> timeRange;
 220                 private IItemCollection selectionItems;
 221                 private XYChart timelineChart;
 222                 private XYChart durationChart;
 223                 private XYChart sizeChart;
 224                 private CTabFolder tabFolder;
 225                 private FlavorSelector flavorSelector;
 226 
 227                 IOPageUi(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
 228                         this.pageContainer = pageContainer;
 229                         Form form = DataPageToolkit.createForm(parent, toolkit, getName(), getIcon());
 230                         sash = new SashForm(form.getBody(), SWT.VERTICAL);
 231                         toolkit.adapt(sash);
 232                         histogramParent = toolkit.createComposite(sash);
 233                         histogramParent.setLayout(new FillLayout(SWT.VERTICAL));
 234                         histogramType = StateToolkit.readEnum(state, HISTGRAM_TYPE, HistogramType.HOST, HistogramType.class);
 235                         buildHistograms(TableSettings.forState(state.getChild(SOCKETIO_TABLE_ELEMENT)),
 236                                         TableSettings.forState(state.getChild(SECONDARY_SOCKETIO_TABLE_ELEMENT)));
 237 
 238                         tabFolder = new CTabFolder(sash, SWT.NONE);
 239                         toolkit.adapt(tabFolder);
 240                         CTabItem t1 = new CTabItem(tabFolder, SWT.NONE);
 241                         t1.setToolTipText(Messages.IO_PAGE_TIMELINE_DESCRIPTION);
 242                         timelineCanvas = new ChartCanvas(tabFolder);
 243                         t1.setText(Messages.PAGES_TIMELINE);


 250                         // FIXME: X-auto-range should be done properly
 251                         IQuantity max = socketItems.getAggregate(JdkAggregators.LONGEST_EVENT);
 252                         // FIXME: Workaround to make max value included
 253                         max = max == null ? UnitLookup.MILLISECOND.quantity(20) : max.add(UnitLookup.MILLISECOND.quantity(20));
 254                         durationChart = new XYChart(UnitLookup.MILLISECOND.quantity(0), max, RendererToolkit.empty(), 180);
 255                         durationChart.setVisibleRange(durationRange.getStart(), durationRange.getEnd());
 256                         durationChart.addVisibleRangeListener(r -> durationRange = r);
 257                         buildChart();
 258 
 259                         CTabItem t2 = new CTabItem(tabFolder, SWT.NONE);
 260                         t2.setToolTipText(Messages.IO_PAGE_DURATIONS_DESCRIPTION);
 261                         durationCanvas = new ChartCanvas(tabFolder);
 262                         t2.setText(Messages.PAGES_DURATIONS);
 263                         t2.setControl(durationCanvas);
 264                         DataPageToolkit.createChartTooltip(durationCanvas);
 265                         DataPageToolkit.setChart(durationCanvas, durationChart, JfrAttributes.DURATION,
 266                                         pageContainer::showSelection);
 267                         SelectionStoreActionToolkit.addSelectionStoreActions(pageContainer.getSelectionStore(), durationChart,
 268                                         JfrAttributes.DURATION, Messages.SocketIOPage_DURATION_SELECTION, durationCanvas.getContextMenu());
 269                         
 270                         IQuantity sizeMax = QuantitiesToolkit.maxPresent(socketItems.getAggregate(JdkAggregators.SOCKET_READ_LARGEST),
 271                                         socketItems.getAggregate(JdkAggregators.SOCKET_WRITE_LARGEST)); 
 272                         // FIXME: Workaround to make max value included
 273                         sizeMax = sizeMax == null ? UnitLookup.BYTE.quantity(64): sizeMax.add(UnitLookup.BYTE.quantity(64));
 274                         sizeChart = new XYChart(UnitLookup.BYTE.quantity(0), sizeMax, RendererToolkit.empty(), 180);
 275                         sizeChart.setVisibleRange(sizeRange.getStart(), sizeMax);
 276                         sizeChart.addVisibleRangeListener(range -> sizeRange = range);
 277                         
 278                         CTabItem t3 = new CTabItem(tabFolder, SWT.NONE);
 279                         t3.setToolTipText(Messages.IO_PAGE_SIZE_DESCRIPTION);
 280                         sizeCanvas = new ChartCanvas(tabFolder);
 281                         t3.setText(Messages.PAGES_SIZE);
 282                         t3.setControl(sizeCanvas);
 283                         DataPageToolkit.createChartTooltip(sizeCanvas);
 284                         DataPageToolkit.setChart(sizeCanvas, sizeChart, JdkAttributes.IO_SIZE,
 285                                         pageContainer::showSelection);
 286                         SelectionStoreActionToolkit.addSelectionStoreActions(pageContainer.getSelectionStore(), sizeChart,
 287                                         JdkAttributes.IO_SIZE, Messages.SocketIOPage_SIZE_SELECTION, sizeCanvas.getContextMenu());
 288 
 289                         CTabItem t4 = new CTabItem(tabFolder, SWT.NONE);
 290                         t4.setToolTipText(Messages.IO_PAGE_EVENT_LOG_DESCRIPTION);
 291                         itemList = LIST.buildWithoutBorder(tabFolder, getTableSettings(state.getChild(LIST_ELEMENT)));
 292                         MCContextMenuManager itemListMm = MCContextMenuManager
 293                                         .create(itemList.getManager().getViewer().getControl());
 294                         ColumnMenusFactory.addDefaultMenus(itemList.getManager(), itemListMm);
 295                         SelectionStoreActionToolkit.addSelectionStoreActions(pageContainer.getSelectionStore(), itemList,
 296                                         Messages.SocketIOPage_LOG_SELECTION, itemListMm);
 297                         itemList.getManager().getViewer().addSelectionChangedListener(
 298                                         e -> pageContainer.showSelection(ItemCollectionToolkit.build(itemList.getSelection().get())));
 299                         t4.setText(Messages.PAGES_EVENT_LOG);
 300                         eventFilter = FilterComponent.createFilterComponent(itemList, itemListFilter,
 301                                         getDataSource().getItems().apply(TABLE_ITEMS), pageContainer.getSelectionStore()::getSelections,
 302                                         this::onEventFilterChange);
 303                         itemListMm.add(eventFilter.getShowFilterAction());
 304                         itemListMm.add(eventFilter.getShowSearchAction());
 305                         t4.setControl(eventFilter.getComponent());
 306                         eventFilter.loadState(state.getChild(EVENT_FILTER));
 307                         onEventFilterChange(itemListFilter);
 308                         itemList.getManager().setSelectionState(itemListSelection);
 309                         
 310                         
 311 
 312                         tabFolder.setSelection(tabFolderIndex);
 313 
 314                         PersistableSashForm.loadState(sash, state.getChild(SASH_ELEMENT));
 315 
 316                         flavorSelector = FlavorSelector.itemsWithTimerange(form, TABLE_ITEMS, getDataSource().getItems(),
 317                                         pageContainer, this::onInputSelected, this::onUseRange, flavorSelectorState);
 318 
 319                         form.getToolBarManager()
 320                                         .appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(HistogramType.HOST,
 321                                                         Messages.SocketIOPage_BY_HOST_ACTION,
 322                                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_HOST)));
 323                         form.getToolBarManager()
 324                                         .appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(HistogramType.PORT,
 325                                                         Messages.SocketIOPage_BY_PORT_ACTION,
 326                                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_PORT)));
 327                         form.getToolBarManager().appendToGroup(DataPageToolkit.FORM_TOOLBAR_PAGE_SETUP, buildHistogramTypeAction(
 328                                         HistogramType.HOST_AND_PORT, Messages.SocketIOPage_BY_HOST_AND_PORT_ACTION,
 329                                         FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.ICON_IO_BY_HOST_AND_PORT)));
 330 
 331                         addResultActions(form);


 466                         SelectionStoreActionToolkit.addSelectionStoreRangeActions(pageContainer.getSelectionStore(), timelineChart,
 467                                         JfrAttributes.LIFETIME, Messages.SocketIOPage_TIMELINE_SELECTION, timelineCanvas.getContextMenu());
 468                 }
 469 
 470                 private void onInputSelected(IItemCollection items, IRange<IQuantity> timeRange) {
 471                         this.selectionItems = items;
 472                         this.timeRange = timeRange;
 473                         refreshPageItems();
 474                 }
 475 
 476                 private void refreshPageItems() {
 477                         IItemCollection items = selectionItems != null ? selectionItems : getDataSource().getItems();
 478                         itemConsumerRoot.accept(items.apply(JdkFilters.SOCKET_READ_OR_WRITE));
 479                 }
 480 
 481                 private void updateChartAndListDetails(IItemCollection selectedItems) {
 482                         String hostCount = hostPortCount();
 483 
 484                         List<IXDataRenderer> timelineRows = new ArrayList<>();
 485                         List<IXDataRenderer> durationRows = new ArrayList<>();
 486                         List<IXDataRenderer> sizeRows = new ArrayList<>();
 487 
 488                         IItemCollection readItems = selectedItems.apply(JdkFilters.SOCKET_READ);
 489                         if (readItems.hasItems()) {
 490                                 timelineRows.add(DataPageToolkit.buildSizeRow(Messages.SocketIOPage_ROW_SOCKET_READ + hostCount,
 491                                                 JdkAggregators.SOCKET_READ_SIZE.getDescription(), readItems, JdkAggregators.SOCKET_READ_SIZE,
 492                                                 READ_COLOR, SocketIOPage::getColor));
 493                                 durationRows
 494                                                 .add(DataPageToolkit.buildDurationHistogram(Messages.SocketIOPage_ROW_SOCKET_READ + hostCount,
 495                                                                 JdkAggregators.SOCKET_READ_COUNT.getDescription(), readItems,
 496                                                                 JdkAggregators.SOCKET_READ_COUNT, READ_COLOR));
 497                                 sizeRows.add(DataPageToolkit.buildSizeHistogram(Messages.SocketIOPage_ROW_SOCKET_READ + hostCount,
 498                                                 JdkAggregators.SOCKET_READ_COUNT.getDescription(), readItems, 
 499                                                 JdkAggregators.SOCKET_READ_COUNT, READ_COLOR, JdkAttributes.IO_SOCKET_BYTES_READ));
 500                         }
 501                         IItemCollection writeItems = selectedItems.apply(JdkFilters.SOCKET_WRITE);
 502                         if (writeItems.hasItems()) {
 503                                 timelineRows.add(DataPageToolkit.buildSizeRow(Messages.SocketIOPage_ROW_SOCKET_WRITE + hostCount,
 504                                                 JdkAggregators.SOCKET_WRITE_SIZE.getDescription(), writeItems, JdkAggregators.SOCKET_WRITE_SIZE,
 505                                                 WRITE_COLOR, SocketIOPage::getColor));
 506                                 durationRows
 507                                                 .add(DataPageToolkit.buildDurationHistogram(Messages.SocketIOPage_ROW_SOCKET_WRITE + hostCount,
 508                                                                 JdkAggregators.SOCKET_WRITE_COUNT.getDescription(), writeItems,
 509                                                                 JdkAggregators.SOCKET_WRITE_COUNT, WRITE_COLOR));
 510                                 sizeRows.add(DataPageToolkit.buildSizeHistogram(Messages.SocketIOPage_ROW_SOCKET_WRITE + hostCount, 
 511                                                 JdkAggregators.SOCKET_WRITE_COUNT.getDescription(), writeItems, 
 512                                                 JdkAggregators.SOCKET_WRITE_COUNT, WRITE_COLOR, JdkAttributes.IO_SOCKET_BYTES_WRITTEN));
 513                         }
 514                         if (timelineCanvas != null) {
 515                                 timelineCanvas.replaceRenderer(RendererToolkit.uniformRows(timelineRows));
 516                                 durationCanvas.replaceRenderer(RendererToolkit.uniformRows(durationRows));
 517                                 sizeCanvas.replaceRenderer(RendererToolkit.uniformRows(sizeRows));
 518 
 519 
 520                                 itemList.show(selectedItems);
 521                                 pageContainer.showSelection(selectedItems);
 522                         }
 523                 }
 524 
 525                 public String hostPortCount() {
 526                         HistogramSelection hostSelection = histogramType == HistogramType.HOST ? primaryHistogram.getSelection()
 527                                         : histogramType == HistogramType.PORT ? secondaryHistogram.getSelection() : null;
 528                         HistogramSelection portSelection = histogramType == HistogramType.PORT ? primaryHistogram.getSelection()
 529                                         : histogramType == HistogramType.HOST ? secondaryHistogram.getSelection() : null;
 530                         HistogramSelection hostPortSelection = histogramType == HistogramType.HOST_AND_PORT
 531                                         ? primaryHistogram.getSelection() : null;
 532 
 533                         return hostPortCount(hostSelection != null ? hostSelection.getRowCount() : 0,
 534                                         portSelection != null ? portSelection.getRowCount() : 0,
 535                                         hostPortSelection != null ? hostPortSelection.getRowCount() : 0);
 536                 }
 537 
 538                 public String hostPortCount(int hostCount, int portCount, int hostPortCount) {


 585                                         new ColumnSettings(READ_SIZE, false, 120, false), new ColumnSettings(WRITE_SIZE, false, 120, false),
 586                                         new ColumnSettings(READ_EOS, false, 80, false), new ColumnSettings(IO_TIMEOUT, false, 50, false)));
 587                 } else {
 588                         return new TableSettings(state);
 589                 }
 590         }
 591 
 592         @Override
 593         public IPageUI display(Composite parent, FormToolkit toolkit, IPageContainer pageContainer, IState state) {
 594                 return new IOPageUi(parent, toolkit, pageContainer, state);
 595         }
 596 
 597         private Map<HistogramType, SelectionState> primaryTableSelection;
 598         private Map<HistogramType, SelectionState> secondaryTableSelection;
 599         private SelectionState itemListSelection;
 600         private Map<HistogramType, IItemFilter> primaryTableFilter;
 601         private Map<HistogramType, IItemFilter> secondaryTableFilter;
 602         private IItemFilter itemListFilter;
 603         private IRange<IQuantity> timelineRange;
 604         private IRange<IQuantity> durationRange;
 605         private IRange<IQuantity> sizeRange;
 606         private int tabFolderIndex = 0;
 607         public FlavorSelectorState flavorSelectorState;
 608 
 609         public SocketIOPage(IPageDefinition dpd, StreamModel items, IPageContainer editor) {
 610                 super(dpd, items, editor);
 611                 primaryTableSelection = new HashMap<>();
 612                 secondaryTableSelection = new HashMap<>();
 613                 primaryTableFilter = new HashMap<>();
 614                 secondaryTableFilter = new HashMap<>();
 615                 timelineRange = editor.getRecordingRange();
 616                 durationRange = editor.getRecordingRange();
 617                 sizeRange = DataPageToolkit.buildSizeRange(items.getItems(), true);
 618 
 619         }
 620 
 621         @Override
 622         public IItemFilter getDefaultSelectionFilter() {
 623                 return TABLE_ITEMS;
 624         }
 625 
 626         private static Color getColor(IItem item) {
 627                 return JdkTypeIDs.SOCKET_READ.equals(item.getType().getIdentifier()) ? READ_ALPHA_COLOR : WRITE_ALPHA_COLOR;
 628         }
 629 
 630 }
< prev index next >