1 /* 2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2019, Red Hat Inc. 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.ui.charts; 35 36 import org.eclipse.jface.resource.JFaceResources; 37 import org.eclipse.swt.SWT; 38 import org.eclipse.swt.layout.GridData; 39 import org.eclipse.swt.layout.GridLayout; 40 import org.eclipse.swt.widgets.Composite; 41 import org.eclipse.swt.widgets.Label; 42 import org.eclipse.swt.widgets.Listener; 43 44 import org.openjdk.jmc.common.unit.IQuantity; 45 import org.openjdk.jmc.common.unit.IRange; 46 import org.openjdk.jmc.ui.misc.ChartCanvas; 47 import org.openjdk.jmc.ui.misc.PatternFly.Palette; 48 import org.openjdk.jmc.ui.misc.TimeFilter; 49 50 public class ChartFilterControlBar extends Composite { 51 52 private static final String THREADS_LABEL = "Threads"; 53 54 private TimeFilter timeFilter; 55 56 public ChartFilterControlBar(Composite parent, Listener resetListener, IRange<IQuantity> recordingRange) { 57 super(parent, SWT.NO_BACKGROUND); 58 this.setLayout(new GridLayout(3, false)); 59 this.setBackground(Palette.PF_BLACK_300.getSWTColor()); 60 Label nameLabel = new Label(this, SWT.CENTER | SWT.HORIZONTAL); 61 nameLabel.setText(THREADS_LABEL); 62 GridData gd = new GridData(SWT.FILL, SWT.CENTER, false, true); 63 gd.widthHint = 180; 64 nameLabel.setLayoutData(gd); 65 nameLabel.setFont(JFaceResources.getFontRegistry().get(JFaceResources.BANNER_FONT)); 66 67 timeFilter = new TimeFilter(this, recordingRange, resetListener); 68 timeFilter.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); 69 } 70 71 public void setChart(XYChart chart) { 72 timeFilter.setChart(chart); 73 } 74 75 public void setChartCanvas(ChartCanvas canvas) { 76 timeFilter.setChartCanvas(canvas); 77 } 78 79 public void setStartTime(IQuantity startTime) { 80 timeFilter.setStartTime(startTime); 81 } 82 83 public void setEndTime(IQuantity endTime) { 84 timeFilter.setEndTime(endTime); 85 } 86 }