-
Notifications
You must be signed in to change notification settings - Fork 174
Added toggle for filtering failed tasks #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,97 @@ | ||||||
/******************************************************************************* | ||||||
* Copyright (c) 2023 Gradle Inc. and others | ||||||
* | ||||||
* This program and the accompanying materials are made | ||||||
* available under the terms of the Eclipse Public License 2.0 | ||||||
* which is available at https://www.eclipse.org/legal/epl-2.0/ | ||||||
* | ||||||
* SPDX-License-Identifier: EPL-2.0 | ||||||
******************************************************************************/ | ||||||
package org.eclipse.buildship.ui.internal.view; | ||||||
|
||||||
import org.gradle.tooling.events.FailureResult; | ||||||
import org.gradle.tooling.events.FinishEvent; | ||||||
import org.gradle.tooling.events.OperationResult; | ||||||
|
||||||
import com.google.common.base.Preconditions; | ||||||
|
||||||
import org.eclipse.jface.action.Action; | ||||||
import org.eclipse.jface.viewers.AbstractTreeViewer; | ||||||
|
||||||
import org.eclipse.buildship.ui.internal.PluginImages; | ||||||
import org.eclipse.buildship.ui.internal.PluginImage.ImageState; | ||||||
import org.eclipse.buildship.ui.internal.i18n.UiMessages; | ||||||
import org.eclipse.buildship.ui.internal.util.nodeselection.NodeSelection; | ||||||
import org.eclipse.buildship.ui.internal.util.nodeselection.SelectionSpecificAction; | ||||||
import org.eclipse.buildship.ui.internal.view.execution.ExecutionPageContentProvider; | ||||||
import org.eclipse.buildship.ui.internal.view.execution.OperationItem; | ||||||
|
||||||
/** | ||||||
* | ||||||
*/ | ||||||
public final class ExpandAllFailedTasksAction extends Action implements SelectionSpecificAction { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
❌ the name doesn't correspond to the functionality. We collapse the tree and expand the nodes representing failed progress events. |
||||||
|
||||||
private final AbstractTreeViewer treeViewer; | ||||||
private ExecutionPageContentProvider contentProvider = null; | ||||||
|
||||||
public ExpandAllFailedTasksAction(AbstractTreeViewer treeViewer) { | ||||||
super(null, AS_CHECK_BOX); | ||||||
this.treeViewer = Preconditions.checkNotNull(treeViewer); | ||||||
|
||||||
|
||||||
setToolTipText(UiMessages.Action_FilterFailedTasks_Tooltip); | ||||||
setImageDescriptor(PluginImages.OPERATION_FAILURE.withState(ImageState.ENABLED).getImageDescriptor()); | ||||||
} | ||||||
|
||||||
public void setContentProvider(ExecutionPageContentProvider contentProvider) { | ||||||
this.contentProvider = contentProvider; | ||||||
setChecked(contentProvider.isFilterFailedItemsEnabled()); | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void run() { | ||||||
|
||||||
this.contentProvider.toggleFilterFailedItems(); | ||||||
setChecked(this.contentProvider.isFilterFailedItemsEnabled()); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
this.treeViewer.collapseAll(); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Object rootObject = this.treeViewer.getInput(); | ||||||
|
||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (rootObject instanceof OperationItem) { | ||||||
OperationItem root = (OperationItem) rootObject; | ||||||
recursivelyExpand(root); | ||||||
} | ||||||
|
||||||
} | ||||||
|
||||||
private void recursivelyExpand(OperationItem parent) { | ||||||
FinishEvent event = parent.getFinishEvent(); | ||||||
if (event != null) { | ||||||
OperationResult result = event.getResult(); | ||||||
if (result instanceof FailureResult) { | ||||||
// Result failed (expand ancestors up to this element) | ||||||
this.treeViewer.expandToLevel(parent, 0); | ||||||
} | ||||||
} | ||||||
for (OperationItem item: parent.getChildren()) { | ||||||
recursivelyExpand(item); | ||||||
} | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean isVisibleFor(NodeSelection selection) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public boolean isEnabledFor(NodeSelection selection) { | ||||||
return true; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void setEnabledFor(NodeSelection selection) { | ||||||
setEnabled(this.contentProvider != null); | ||||||
} | ||||||
|
||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ | |
import org.eclipse.buildship.ui.internal.util.widget.PatternFilter; | ||
import org.eclipse.buildship.ui.internal.view.BasePage; | ||
import org.eclipse.buildship.ui.internal.view.CollapseAllTreeNodesAction; | ||
import org.eclipse.buildship.ui.internal.view.ExpandAllFailedTasksAction; | ||
import org.eclipse.buildship.ui.internal.view.ExpandAllTreeNodesAction; | ||
import org.eclipse.buildship.ui.internal.view.MultiPageView; | ||
import org.eclipse.buildship.ui.internal.view.PageSite; | ||
|
@@ -290,6 +291,9 @@ private void populateToolBar() { | |
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new ExpandAllTreeNodesAction(getPageControl().getViewer())); | ||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new CollapseAllTreeNodesAction(getPageControl().getViewer())); | ||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new ShowFilterAction(getPageControl())); | ||
ExpandAllFailedTasksAction action = new ExpandAllFailedTasksAction(getPageControl().getViewer()); | ||
action.setContentProvider((ExecutionPageContentProvider)getPageControl().getViewer().getContentProvider()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ this can happen in the action's constructor. Then, you can use the same pattern as around, ie
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By the looks of it, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay |
||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, action); | ||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new Separator()); | ||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new SwitchToConsoleViewAction(this)); | ||
toolbarManager.appendToGroup(MultiPageView.PAGE_GROUP, new Separator()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,10 @@ | |
******************************************************************************/ | ||
package org.eclipse.buildship.ui.internal.view.execution; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
import org.gradle.tooling.events.FailureResult; | ||
|
||
import org.eclipse.jface.viewers.ITreeContentProvider; | ||
import org.eclipse.jface.viewers.Viewer; | ||
|
||
|
@@ -17,14 +21,24 @@ | |
*/ | ||
public class ExecutionPageContentProvider implements ITreeContentProvider { | ||
|
||
private boolean filterFailedItems = false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ This is wrong as the state will get lost when the IDE restarts. Instead, store the state in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scratch that, the proper place to store the state is |
||
|
||
@Override | ||
public Object[] getElements(Object inputElement) { | ||
return getChildren(inputElement); | ||
} | ||
|
||
@Override | ||
public Object[] getChildren(Object parent) { | ||
return parent instanceof OperationItem ? ((OperationItem)parent).getChildren().toArray() : new Object[0]; | ||
if (this.isFilterFailedItemsEnabled()) { | ||
if (parent instanceof OperationItem) { | ||
return ((OperationItem)parent).getChildren().stream().filter(operationItem -> operationItem.getFinishEvent().getResult() instanceof FailureResult).collect(Collectors.toList()).toArray(); | ||
} else { | ||
return new Object[0]; | ||
} | ||
} else { | ||
return parent instanceof OperationItem ? ((OperationItem)parent).getChildren().toArray() : new Object[0]; | ||
} | ||
} | ||
|
||
@Override | ||
|
@@ -44,4 +58,12 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { | |
@Override | ||
public void dispose() { | ||
} | ||
|
||
public boolean isFilterFailedItemsEnabled() { | ||
return this.filterFailedItems; | ||
} | ||
|
||
public void toggleFilterFailedItems() { | ||
this.filterFailedItems = !this.filterFailedItems; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌ Please don't do this. Use explicit getters and setters. |
||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,7 @@ Title_Gradle_Build_Script_Compare=Gradle Build Script Compare | |||||
|
||||||
Button_Label_Browse=Browse... | ||||||
|
||||||
Action_FilterFailedTasks_Tooltip=Filter Failed Tasks | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ❌
Suggested change
|
||||||
Action_ExpandNodes_Tooltip=Expand All | ||||||
Action_CollapseNodes_Tooltip=Collapse All | ||||||
Action_ShowFilter_Tooltip=Show Filter | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name should be adjusted.