1 /*
2 * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
3 *
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * The contents of this file are subject to the terms of either the Universal Permissive License
7 * v 1.0 as shown at http://oss.oracle.com/licenses/upl
8 *
9 * or the following license:
10 *
11 * Redistribution and use in source and binary forms, with or without modification, are permitted
12 * provided that the following conditions are met:
13 *
14 * 1. Redistributions of source code must retain the above copyright notice, this list of conditions
15 * and the following disclaimer.
16 *
17 * 2. Redistributions in binary form must reproduce the above copyright notice, this list of
18 * conditions and the following disclaimer in the documentation and/or other materials provided with
19 * the distribution.
20 *
21 * 3. Neither the name of the copyright holder nor the names of its contributors may be used to
22 * endorse or promote products derived from this software without specific prior written permission.
48 import org.eclipse.jface.viewers.ComboViewer;
49 import org.eclipse.jface.viewers.ISelection;
50 import org.eclipse.jface.viewers.ISelectionChangedListener;
51 import org.eclipse.jface.viewers.IStructuredContentProvider;
52 import org.eclipse.jface.viewers.IStructuredSelection;
53 import org.eclipse.jface.viewers.LabelProvider;
54 import org.eclipse.jface.viewers.SelectionChangedEvent;
55 import org.eclipse.jface.viewers.StructuredSelection;
56 import org.eclipse.jface.viewers.Viewer;
57 import org.eclipse.swt.SWT;
58 import org.eclipse.swt.events.PaintEvent;
59 import org.eclipse.swt.events.PaintListener;
60 import org.eclipse.swt.events.SelectionAdapter;
61 import org.eclipse.swt.events.SelectionEvent;
62 import org.eclipse.swt.graphics.Point;
63 import org.eclipse.swt.graphics.RGB;
64 import org.eclipse.swt.widgets.Button;
65 import org.eclipse.swt.widgets.Canvas;
66 import org.eclipse.swt.widgets.Composite;
67 import org.eclipse.swt.widgets.Control;
68 import org.eclipse.swt.widgets.Label;
69 import org.eclipse.ui.forms.widgets.Form;
70
71 import org.openjdk.jmc.common.IDisplayable;
72 import org.openjdk.jmc.common.IMCThread;
73 import org.openjdk.jmc.common.item.IAttribute;
74 import org.openjdk.jmc.common.item.IItemCollection;
75 import org.openjdk.jmc.common.item.IItemFilter;
76 import org.openjdk.jmc.common.unit.IQuantity;
77 import org.openjdk.jmc.common.unit.IRange;
78 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
79 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
80 import org.openjdk.jmc.flightrecorder.ui.selection.FlavorToolkit;
81 import org.openjdk.jmc.flightrecorder.ui.selection.IFlavoredSelection;
82 import org.openjdk.jmc.flightrecorder.ui.selection.IItemStreamFlavor;
83 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore;
84 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreEntry;
85 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreListener;
86 import org.openjdk.jmc.ui.charts.SubdividedQuantityRange;
87 import org.openjdk.jmc.ui.misc.SWTColorToolkit;
88
284
285 // FIXME: Instead use radio buttons with images?
286 rangeStyleButton = new Button(selectorRow, SWT.CHECK);
287 rangeStyleButton.setLayoutData(GridDataFactory.swtDefaults().create());
288 rangeStyleButton.setText(Messages.FlavorSelector_BUTTON_CONTAINED);
289 rangeStyleButton.setToolTipText(Messages.FlavorSelector_BUTTON_CONTAINED_TOOLTIP);
290 rangeStyleButton.setEnabled(showConcurrentButton.getSelection());
291 rangeStyleButton.setSelection(flavorSelectorState.concurrentContained);
292 rangeStyleButton.addSelectionListener(new RangeStyleSelectionListener());
293
294 // FIXME: Instead use radio buttons with images?
295 sameThreadsButton = new Button(selectorRow, SWT.CHECK);
296 sameThreadsButton.setLayoutData(GridDataFactory.swtDefaults().create());
297 sameThreadsButton.setText(Messages.FlavorSelector_BUTTON_SAME_THREADS);
298 sameThreadsButton.setToolTipText(Messages.FlavorSelector_BUTTON_SAME_THREADS_TOOLTIP);
299 sameThreadsButton.setEnabled(showConcurrentButton.getSelection());
300 sameThreadsButton.setSelection(flavorSelectorState.sameThreads);
301 sameThreadsButton.addSelectionListener(new SameThreadsSelectionListener());
302
303 // FIXME: Persist state for above checkboxes?
304
305 onShow.ifPresent(on -> {
306 Label rangeLabel = new Label(selectorRow, SWT.NONE);
307 rangeLabel.setLayoutData(GridDataFactory.swtDefaults().create());
308 rangeLabel.setText(Messages.FlavorSelector_LABEL_TIMERANGE);
309 showButton = new Button(selectorRow, SWT.PUSH);
310 showButton.setText(Messages.FlavorSelector_BUTTON_TIMERANGE_SET);
311 showButton.setToolTipText(Messages.FlavorSelector_BUTTON_TIMERANGE_SET_TOOLTIP);
312 showButton.setLayoutData(GridDataFactory.swtDefaults().create());
313 resetButton = new Button(selectorRow, SWT.PUSH);
314 resetButton.setText(Messages.FlavorSelector_BUTTON_TIMERANGE_CLEAR);
315 resetButton.setToolTipText(Messages.FlavorSelector_BUTTON_TIMERANGE_CLEAR_TOOLTIP);
316 resetButton.addListener(SWT.Selection, e -> on.accept(false));
317 resetButton.setLayoutData(GridDataFactory.swtDefaults().create());
318 showButton.addListener(SWT.Selection, e -> on.accept(true));
319 });
320
321 canvas = new Canvas(container, SWT.NO_BACKGROUND);
322 canvas.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(SWT.DEFAULT, 7)
323 .grab(true, false).create());
324 painter = new RangePainter(canvas, pageContainer.getRecordingRange());
325
326 selectionCombo.setInput(pageContainer.getSelectionStore());
327 selectionCombo.setSelection(getCurrentSelection());
328 callbackActive = true;
329
330 enableSelection();
331
332 IItemStreamFlavor currentFlavor = null;
333 if (pageContainer.getSelectionStore().isCurrentActive()) {
334 currentFlavor = getSelectedFlavor();
335 }
336 useFlavor(currentFlavor);
|
1 /*
2 * Copyright (c) 2018, 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.
49 import org.eclipse.jface.viewers.ComboViewer;
50 import org.eclipse.jface.viewers.ISelection;
51 import org.eclipse.jface.viewers.ISelectionChangedListener;
52 import org.eclipse.jface.viewers.IStructuredContentProvider;
53 import org.eclipse.jface.viewers.IStructuredSelection;
54 import org.eclipse.jface.viewers.LabelProvider;
55 import org.eclipse.jface.viewers.SelectionChangedEvent;
56 import org.eclipse.jface.viewers.StructuredSelection;
57 import org.eclipse.jface.viewers.Viewer;
58 import org.eclipse.swt.SWT;
59 import org.eclipse.swt.events.PaintEvent;
60 import org.eclipse.swt.events.PaintListener;
61 import org.eclipse.swt.events.SelectionAdapter;
62 import org.eclipse.swt.events.SelectionEvent;
63 import org.eclipse.swt.graphics.Point;
64 import org.eclipse.swt.graphics.RGB;
65 import org.eclipse.swt.widgets.Button;
66 import org.eclipse.swt.widgets.Canvas;
67 import org.eclipse.swt.widgets.Composite;
68 import org.eclipse.swt.widgets.Control;
69 import org.eclipse.swt.widgets.Event;
70 import org.eclipse.swt.widgets.Label;
71 import org.eclipse.swt.widgets.Listener;
72 import org.eclipse.ui.forms.widgets.Form;
73
74 import org.openjdk.jmc.common.IDisplayable;
75 import org.openjdk.jmc.common.IMCThread;
76 import org.openjdk.jmc.common.item.IAttribute;
77 import org.openjdk.jmc.common.item.IItemCollection;
78 import org.openjdk.jmc.common.item.IItemFilter;
79 import org.openjdk.jmc.common.unit.IQuantity;
80 import org.openjdk.jmc.common.unit.IRange;
81 import org.openjdk.jmc.flightrecorder.ui.IPageContainer;
82 import org.openjdk.jmc.flightrecorder.ui.messages.internal.Messages;
83 import org.openjdk.jmc.flightrecorder.ui.selection.FlavorToolkit;
84 import org.openjdk.jmc.flightrecorder.ui.selection.IFlavoredSelection;
85 import org.openjdk.jmc.flightrecorder.ui.selection.IItemStreamFlavor;
86 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore;
87 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreEntry;
88 import org.openjdk.jmc.flightrecorder.ui.selection.SelectionStore.SelectionStoreListener;
89 import org.openjdk.jmc.ui.charts.SubdividedQuantityRange;
90 import org.openjdk.jmc.ui.misc.SWTColorToolkit;
91
287
288 // FIXME: Instead use radio buttons with images?
289 rangeStyleButton = new Button(selectorRow, SWT.CHECK);
290 rangeStyleButton.setLayoutData(GridDataFactory.swtDefaults().create());
291 rangeStyleButton.setText(Messages.FlavorSelector_BUTTON_CONTAINED);
292 rangeStyleButton.setToolTipText(Messages.FlavorSelector_BUTTON_CONTAINED_TOOLTIP);
293 rangeStyleButton.setEnabled(showConcurrentButton.getSelection());
294 rangeStyleButton.setSelection(flavorSelectorState.concurrentContained);
295 rangeStyleButton.addSelectionListener(new RangeStyleSelectionListener());
296
297 // FIXME: Instead use radio buttons with images?
298 sameThreadsButton = new Button(selectorRow, SWT.CHECK);
299 sameThreadsButton.setLayoutData(GridDataFactory.swtDefaults().create());
300 sameThreadsButton.setText(Messages.FlavorSelector_BUTTON_SAME_THREADS);
301 sameThreadsButton.setToolTipText(Messages.FlavorSelector_BUTTON_SAME_THREADS_TOOLTIP);
302 sameThreadsButton.setEnabled(showConcurrentButton.getSelection());
303 sameThreadsButton.setSelection(flavorSelectorState.sameThreads);
304 sameThreadsButton.addSelectionListener(new SameThreadsSelectionListener());
305
306 // FIXME: Persist state for above checkboxes?
307 onShow.ifPresent(on -> {
308 Label rangeLabel = new Label(selectorRow, SWT.NONE);
309 rangeLabel.setLayoutData(GridDataFactory.swtDefaults().create());
310 rangeLabel.setText(Messages.FlavorSelector_LABEL_TIMERANGE);
311 showButton = new Button(selectorRow, SWT.PUSH);
312 showButton.setText(Messages.FlavorSelector_BUTTON_TIMERANGE_SET);
313 showButton.setToolTipText(Messages.FlavorSelector_BUTTON_TIMERANGE_SET_TOOLTIP);
314 showButton.setLayoutData(GridDataFactory.swtDefaults().create());
315 resetButton = new Button(selectorRow, SWT.PUSH);
316 resetButton.setText(Messages.FlavorSelector_BUTTON_TIMERANGE_CLEAR);
317 resetButton.setToolTipText(Messages.FlavorSelector_BUTTON_TIMERANGE_CLEAR_TOOLTIP);
318 resetButton.addListener(SWT.Selection, e -> on.accept(false));
319 resetButton.addListener(SWT.Selection, new Listener() {
320 @Override
321 public void handleEvent(Event event) {
322 on.accept(false);
323 }
324 });
325 resetButton.setLayoutData(GridDataFactory.swtDefaults().create());
326 showButton.addListener(SWT.Selection, e -> on.accept(true));
327 });
328
329 canvas = new Canvas(container, SWT.NO_BACKGROUND);
330 canvas.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(SWT.DEFAULT, 7)
331 .grab(true, false).create());
332 painter = new RangePainter(canvas, pageContainer.getRecordingRange());
333
334 selectionCombo.setInput(pageContainer.getSelectionStore());
335 selectionCombo.setSelection(getCurrentSelection());
336 callbackActive = true;
337
338 enableSelection();
339
340 IItemStreamFlavor currentFlavor = null;
341 if (pageContainer.getSelectionStore().isCurrentActive()) {
342 currentFlavor = getSelectedFlavor();
343 }
344 useFlavor(currentFlavor);
|