1 /*
   2  * Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2019 Datadog. All rights reserved.
   4  * 
   5  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   6  *
   7  * The contents of this file are subject to the terms of either the Universal Permissive License
   8  * v 1.0 as shown at http://oss.oracle.com/licenses/upl
   9  *
  10  * or the following license:
  11  *
  12  * Redistribution and use in source and binary forms, with or without modification, are permitted
  13  * provided that the following conditions are met:
  14  * 
  15  * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
  16  * and the following disclaimer.
  17  * 
  18  * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
  19  * conditions and the following disclaimer in the documentation and/or other materials provided with
  20  * the distribution.
  21  * 
  22  * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
  23  * endorse or promote products derived from this software without specific prior written permission.
  24  * 
  25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
  26  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
  27  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
  28  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  31  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
  32  * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33  */
  34 package org.openjdk.jmc.flightrecorder.ui.pages;
  35 
  36 import org.eclipse.jface.resource.ImageDescriptor;
  37 import org.openjdk.jmc.common.IState;
  38 import org.openjdk.jmc.common.item.IItemFilter;
  39 import org.openjdk.jmc.common.item.ItemFilters;
  40 import org.openjdk.jmc.flightrecorder.jdk.JdkQueries;
  41 import org.openjdk.jmc.flightrecorder.jdk.JdkTypeIDs;
  42 import org.openjdk.jmc.flightrecorder.rules.util.JfrRuleTopics;
  43 import org.openjdk.jmc.flightrecorder.ui.FlightRecorderUI;
  44 import org.openjdk.jmc.flightrecorder.ui.IDataPageFactory;
  45 import org.openjdk.jmc.flightrecorder.ui.IDisplayablePage;
  46 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
  47 import org.openjdk.jmc.flightrecorder.ui.IPageDefinition;
  48 import org.openjdk.jmc.flightrecorder.ui.StreamModel;
  49 import org.openjdk.jmc.flightrecorder.ui.common.ImageConstants;
  50 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
  51 
  52 public class NativeLibraryPage extends DistinctItemsPage {
  53         public static class NativeLibraryPageFactory implements IDataPageFactory {
  54 
  55                 @Override
  56                 public String getName(IState state) {
  57                         return Messages.NativeLibraryPage_PAGE_NAME;
  58                 }
  59 
  60                 @Override
  61                 public ImageDescriptor getImageDescriptor(IState state) {
  62                         return FlightRecorderUI.getDefault().getMCImageDescriptor(ImageConstants.PAGE_NATIVE_LIBRARY);
  63                 }
  64 
  65                 @Override
  66                 public String[] getTopics(IState state) {
  67                         return new String[] {JfrRuleTopics.NATIVE_LIBRARY_TOPIC};
  68                 }
  69 
  70                 @Override
  71                 public IDisplayablePage createPage(IPageDefinition dpd, StreamModel items, IPageContainer editor) {
  72                         return new NativeLibraryPage(dpd, items, editor);
  73                 }
  74         }
  75 
  76         public NativeLibraryPage(IPageDefinition dpd, StreamModel items, IPageContainer editor) {
  77                 super(dpd, items, editor);
  78                 setTableDefinition(JdkQueries.NATIVE_LIBRARIES);
  79         }
  80 
  81         @Override
  82         public IItemFilter getDefaultSelectionFilter() {
  83                 return ItemFilters.type(JdkTypeIDs.NATIVE_LIBRARY);
  84         }
  85 }