mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-13 15:52:01 +07:00
IJPL-160192 UI Inspector: Added action button to show accessibility issues
Merge-request: IJ-MR-143036 Merged-by: Dmitrii Drobotov <dmitry.drobotov@jetbrains.com> GitOrigin-RevId: 838706eb4cf4a954f6dcddada1f9321feb8be32b
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e5e0d3b80
commit
67b9deb0a3
@@ -9,6 +9,7 @@ action.Anonymous.text.parents=Parents
|
||||
action.Anonymous.text.refresh=Refresh
|
||||
action.Anonymous.text.Accessible=Accessible
|
||||
action.Anonymous.text.Visible=Visible
|
||||
action.Anonymous.text.ShowAccessibilityIssues=Show Accessibility Issues
|
||||
action.Anonymous.description.open.definition=Open the definition of the selected component
|
||||
action.Anonymous.text.DataContext=Data Context
|
||||
action.Anonymous.text.reset.statistics=Reset Statistics
|
||||
|
||||
@@ -150,6 +150,7 @@ public abstract class HierarchyTree extends JTree implements TreeSelectionListen
|
||||
private final Accessible myAccessible;
|
||||
private final String myName;
|
||||
private final boolean isAccessibleNode;
|
||||
private String accessibilityTestResult;
|
||||
|
||||
String myText;
|
||||
|
||||
@@ -185,6 +186,10 @@ public abstract class HierarchyTree extends JTree implements TreeSelectionListen
|
||||
return node;
|
||||
}
|
||||
|
||||
public void runAccessibilityTests() { this.accessibilityTestResult = "pass"; }
|
||||
|
||||
public void clearAccessibilityTestsResult() { this.accessibilityTestResult = null; }
|
||||
|
||||
private ComponentNode(@Nullable Component component,
|
||||
@Nullable Accessible accessible,
|
||||
@NotNull String name,
|
||||
@@ -341,12 +346,18 @@ public abstract class HierarchyTree extends JTree implements TreeSelectionListen
|
||||
append(", ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
append("data-provider", SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);
|
||||
}
|
||||
|
||||
componentNode.setText(toString());
|
||||
setIcon(Icons.findIconFor(component));
|
||||
}
|
||||
else {
|
||||
append(componentNode.myName);
|
||||
}
|
||||
|
||||
if (componentNode.accessibilityTestResult != null) {
|
||||
append(", ", SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
append(componentNode.accessibilityTestResult, SimpleTextAttributes.GRAYED_ATTRIBUTES);
|
||||
}
|
||||
}
|
||||
if (isRenderer) {
|
||||
setIcon(AllIcons.Ide.Rating);
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.Splitter;
|
||||
import com.intellij.openapi.util.DimensionService;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.JBSplitter;
|
||||
@@ -120,6 +121,8 @@ public final class InspectorWindow extends JDialog implements Disposable {
|
||||
actions.add(new ShowDataContextAction());
|
||||
actions.addSeparator();
|
||||
actions.add(new MyNavigateAction());
|
||||
actions.addSeparator();
|
||||
actions.add(new ShowAccessibilityIssuesAction());
|
||||
|
||||
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.CONTEXT_TOOLBAR, actions, true);
|
||||
toolbar.setTargetComponent(getRootPane());
|
||||
@@ -433,6 +436,45 @@ public final class InspectorWindow extends JDialog implements Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
private final class ShowAccessibilityIssuesAction extends MyTextAction {
|
||||
private final boolean isAccessibilityAuditEnabled = Registry.is("ui.inspector.accessibility.audit", false);
|
||||
private boolean showAccessibilityIssues = false;
|
||||
|
||||
private ShowAccessibilityIssuesAction() {
|
||||
super(InternalActionsBundle.messagePointer("action.Anonymous.text.ShowAccessibilityIssues"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(@NotNull AnActionEvent e) {
|
||||
showAccessibilityIssues = !showAccessibilityIssues;
|
||||
|
||||
updateTreeWithAccessibilityStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) { e.getPresentation().setEnabledAndVisible(isAccessibilityAuditEnabled); }
|
||||
|
||||
@Override
|
||||
public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.BGT; }
|
||||
|
||||
private void updateTreeWithAccessibilityStatus() {
|
||||
TreeUtil.visitVisibleRows(myHierarchyTree, path -> {
|
||||
Object node = path.getLastPathComponent();
|
||||
if (node instanceof HierarchyTree.ComponentNode componentNode) {
|
||||
if (showAccessibilityIssues){
|
||||
componentNode.runAccessibilityTests();
|
||||
} else {
|
||||
componentNode.clearAccessibilityTestsResult();
|
||||
}
|
||||
}
|
||||
|
||||
return TreeVisitor.Action.CONTINUE;
|
||||
});
|
||||
|
||||
myHierarchyTree.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
private final class RefreshAction extends MyTextAction {
|
||||
private RefreshAction() {
|
||||
super(InternalActionsBundle.messagePointer("action.Anonymous.text.refresh"));
|
||||
|
||||
Reference in New Issue
Block a user