Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ros2: add action for hiding internal objects in ROS 2 views
This allows hiding internal publishers or subscriptions that are mostly internal to ROS 2. It thus allows simplifying the views a bit. Signed-off-by: Christophe Bedard <bedard.christophe@gmail.com> Change-Id: Id32125292c5e16cc6cf22c0ef5924dc3b1caef51 Reviewed-on: https://git.eclipse.org/r/c/tracecompass.incubator/org.eclipse.tracecompass.incubator/+/192548 Tested-by: Trace Compass Bot <tracecompass-bot@eclipse.org>
- Loading branch information
1 parent
7649029
commit a57a4aa
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
Binary file added
BIN
+137 Bytes
...types/org.eclipse.tracecompass.incubator.ros2.ui/icons/elcl16/hide_internal.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 84 additions & 0 deletions
84
.../eclipse/tracecompass/incubator/internal/ros2/ui/views/Ros2HideInternalObjectsAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/********************************************************************** | ||
* Copyright (c) 2022 École Polytechnique de Montréal | ||
* | ||
* All rights reserved. This program and the accompanying materials are | ||
* made available under the terms of the Eclipse Public License 2.0 which | ||
* accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
**********************************************************************/ | ||
|
||
package org.eclipse.tracecompass.incubator.internal.ros2.ui.views; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.eclipse.jdt.annotation.NonNull; | ||
import org.eclipse.jface.action.Action; | ||
import org.eclipse.jface.action.IAction; | ||
import org.eclipse.jface.viewers.Viewer; | ||
import org.eclipse.jface.viewers.ViewerFilter; | ||
import org.eclipse.tracecompass.incubator.internal.ros2.ui.Activator; | ||
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer; | ||
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry; | ||
|
||
/** | ||
* Action to hide internal ROS 2 objects in the time graph viewer. | ||
* | ||
* @author Christophe Bedard | ||
*/ | ||
public class Ros2HideInternalObjectsAction extends Action { | ||
|
||
private static final @NonNull String IMG_UI = "icons/elcl16/hide_internal.gif"; //$NON-NLS-1$ | ||
private static final @NonNull String ACTION_TEXT = "Hide ROS 2 internal"; //$NON-NLS-1$ | ||
private static final @NonNull String ACTION_TOOLTIP_TEXT = "Hide internal ROS 2 objects"; //$NON-NLS-1$ | ||
|
||
private static final List<String> HIDDEN_TOPICS = Arrays.asList("/parameter_events", "/rosout"); //$NON-NLS-1$ //$NON-NLS-2$ | ||
|
||
private final TimeGraphViewer fTimeGraphViewer; | ||
private final @NonNull Ros2HideInternalViewerFilter fFilter; | ||
|
||
private class Ros2HideInternalViewerFilter extends ViewerFilter { | ||
|
||
@Override | ||
public boolean select(Viewer viewer, Object parentElement, Object element) { | ||
if (!(element instanceof ITimeGraphEntry)) { | ||
return true; | ||
} | ||
ITimeGraphEntry entry = (ITimeGraphEntry) element; | ||
return !HIDDEN_TOPICS.contains(entry.getName()); | ||
} | ||
} | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param timeGraphViewer | ||
* the time graph viewer | ||
*/ | ||
public Ros2HideInternalObjectsAction(TimeGraphViewer timeGraphViewer) { | ||
super(ACTION_TEXT, IAction.AS_CHECK_BOX); | ||
fTimeGraphViewer = timeGraphViewer; | ||
fFilter = new Ros2HideInternalViewerFilter(); | ||
setToolTipText(ACTION_TOOLTIP_TEXT); | ||
setImageDescriptor(Objects.requireNonNull(Activator.getDefault()).getImageDescripterFromPath(IMG_UI)); | ||
|
||
update(); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
update(); | ||
} | ||
|
||
private void update() { | ||
if (isChecked()) { | ||
fTimeGraphViewer.addFilter(fFilter); | ||
} else { | ||
fTimeGraphViewer.removeFilter(fFilter); | ||
} | ||
fTimeGraphViewer.refresh(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters