From f3e022fce27c26ecc57a4631e3be657019456537 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Thu, 12 Nov 2020 14:58:02 +0100 Subject: [PATCH] Various cosmetics for toolwindow empty text GitOrigin-RevId: 167ceb6e6b1d64ff9748f236966cb25534854f07 --- .../messages/InspectionsBundle.properties | 2 +- .../actions/ActivateRunToolWindowAction.kt | 25 +++++++++++++++---- .../resources/messages/LangBundle.properties | 20 ++++++++------- ...tivateInspectionResultsToolWindowAction.kt | 4 +-- .../actions/ActivateFindToolWindowAction.kt | 12 ++++++--- .../ActivateHierarchyToolWindowAction.kt | 5 ++-- .../src/com/intellij/util/ui/StatusText.java | 19 +++++++++++--- .../messages/XDebuggerBundle.properties | 3 ++- .../actions/ActivateDebugToolWindowAction.kt | 11 +++----- .../resources/messages/AntBundle.properties | 2 +- .../lang/ant/config/explorer/AntExplorer.java | 4 +-- 11 files changed, 69 insertions(+), 38 deletions(-) diff --git a/platform/analysis-api/resources/messages/InspectionsBundle.properties b/platform/analysis-api/resources/messages/InspectionsBundle.properties index a58c295d41b1..3377a36c7e75 100644 --- a/platform/analysis-api/resources/messages/InspectionsBundle.properties +++ b/platform/analysis-api/resources/messages/InspectionsBundle.properties @@ -281,5 +281,5 @@ configurable.name.code.cleanup.inspections=Code Cleanup Inspections code.analysis.is.disabled.in.power.save.mode=Code analysis is disabled in power save mode action.description.code.cleanup.options=Code Cleanup Options #Please keep $action_inspect_code$ and $action_inspection_by_name$ non-translated -inspections.empty.state.pattern=To see inspection results, use $action_inspect_code$ or $action_inspection_by_name$ +inspections.empty.state.pattern=$action_inspect_code$ or $action_inspection_by_name$ inspections.empty.state.help=Running inspections diff --git a/platform/execution-impl/src/com/intellij/execution/actions/ActivateRunToolWindowAction.kt b/platform/execution-impl/src/com/intellij/execution/actions/ActivateRunToolWindowAction.kt index 1494d7264723..0b9b28114f72 100644 --- a/platform/execution-impl/src/com/intellij/execution/actions/ActivateRunToolWindowAction.kt +++ b/platform/execution-impl/src/com/intellij/execution/actions/ActivateRunToolWindowAction.kt @@ -8,7 +8,9 @@ import com.intellij.execution.ui.RunContentManagerImpl import com.intellij.icons.AllIcons import com.intellij.ide.actions.ToolWindowEmptyStateAction import com.intellij.lang.LangBundle +import com.intellij.openapi.actionSystem.ActionManager import com.intellij.openapi.help.HelpManager +import com.intellij.openapi.keymap.KeymapUtil import com.intellij.openapi.project.Project import com.intellij.openapi.wm.ToolWindowId import com.intellij.ui.SimpleTextAttributes @@ -21,15 +23,28 @@ class ActivateRunToolWindowAction : ToolWindowEmptyStateAction(ToolWindowId.RUN, } override fun setupEmptyText(project: Project, text: StatusText) { + text.isCenterAlignText = false + text.appendLine(LangBundle.message("run.toolwindow.empty.text.0")) text.appendLine(LangBundle.message("run.toolwindow.empty.text.1")) text.appendLine(LangBundle.message("run.toolwindow.empty.text.2")) - text.appendLine(LangBundle.message("run.toolwindow.empty.text.3") + " ") - text.appendText(LangBundle.message("run.toolwindow.empty.text.4"), SimpleTextAttributes.LINK_ATTRIBUTES) { - EditConfigurationsDialog(project).show() - } + + appendLaunchConfigurationText(text, project, "ChooseRunConfiguration") text.appendLine("") - text.appendLine(AllIcons.General.ContextHelp, LangBundle.message("run.toolwindow.empty.text.help"), SimpleTextAttributes.LINK_ATTRIBUTES) { + text.appendLine(AllIcons.General.ContextHelp, LangBundle.message("run.toolwindow.empty.text.help"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { HelpManager.getInstance().invokeHelp("procedures.running.run") } } + + companion object { + fun appendLaunchConfigurationText(text: StatusText, project: Project, actionId: String) { + val shortcut = ActionManager.getInstance().getKeyboardShortcut(actionId) + val shortcutText = shortcut?.let { " (${KeymapUtil.getShortcutText(shortcut)})" } ?: "" + val line = LangBundle.message("run.toolwindow.empty.text.3", shortcutText) + text.appendLine(line.substringBefore('<')) + text.appendText(line.substringAfter('<').substringBefore('>'), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { + EditConfigurationsDialog(project).show() + } + text.appendText(line.substringAfter('>')) + } + } } diff --git a/platform/lang-api/resources/messages/LangBundle.properties b/platform/lang-api/resources/messages/LangBundle.properties index f43f81dc6d04..dd9c85581b7c 100644 --- a/platform/lang-api/resources/messages/LangBundle.properties +++ b/platform/lang-api/resources/messages/LangBundle.properties @@ -457,11 +457,14 @@ intention.name.convert.number.to.with.text=Convert number to {0} ({1}) search.everywhere.calculator.group.name=Calculator search.everywhere.calculator.result.0=Result: {0} search.everywhere.calculator.shortcut.0={0} to copy to the clipboard -status.text.find.toolwindow.empty.state=Select element and invoke Edit | Find Usages | Find Usages{0} to see its usages -run.toolwindow.empty.text.1=To run your code, do one of the following: +status.text.find.toolwindow.empty.state.1=Use Find Usages{0} on a symbol in the editor, Project or Structure tool windows. +status.text.find.toolwindow.empty.state.2=Use Find in Files{0} to search for any text in the project. +run.toolwindow.empty.text.0=To run your code, do one of the following: +run.toolwindow.empty.text.1=\u2013 Click the Run icon in the editor gutter run.toolwindow.empty.text.2=\u2013 Select "Run..." in the editor context menu -run.toolwindow.empty.text.3=\u2013 Create a -run.toolwindow.empty.text.4=run configuration + +# The < and > characters delimit the part of text that becomes a link. {0} is the keyboard shortcut for the action. +run.toolwindow.empty.text.3=\u2013 Launch a {0} run.toolwindow.empty.text.help=Running applications group.preferences=Preferences group.settings=Settings @@ -475,11 +478,10 @@ action.fix.n.problems.text={0} ({1} {1,choice,0#problems|1#problem|2#problems}) label.n.problems={0} {0,choice,0#problems|1#problem|2#problems}: suppressed=Suppressed no.longer.valid=No longer valid -hierarchy.empty.text.1=Place the caret on a symbol -hierarchy.empty.text.2=and use one of the actions: -hierarchy.empty.text.type=Type Hierarchy {0} -hierarchy.empty.text.call=Call Hierarchy {0} -hierarchy.empty.text.method=Method Hierarchy {0} +hierarchy.empty.text=Use one of the actions on a symbol: +hierarchy.empty.text.type=Type Hierarchy ({0}) +hierarchy.empty.text.call=Call Hierarchy ({0}) +hierarchy.empty.text.method=Method Hierarchy ({0}) hierarchy.empty.text.help=Source code hierarchy title.reader.mode.got.it.popup=Read library code easily text.reader.mode.got.it.popup=The Reader mode shows documentation as formatted text, enables font ligatures, code vision hints, and more. Applies only to library and read-only files. diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ActivateInspectionResultsToolWindowAction.kt b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ActivateInspectionResultsToolWindowAction.kt index 329121a4116b..455b03909e85 100644 --- a/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ActivateInspectionResultsToolWindowAction.kt +++ b/platform/lang-impl/src/com/intellij/codeInspection/ui/actions/ActivateInspectionResultsToolWindowAction.kt @@ -37,13 +37,13 @@ class ActivateInspectionResultsToolWindowAction : ToolWindowEmptyStateAction(Too } } text.appendLine("") - text.appendLine(AllIcons.General.ContextHelp, InspectionsBundle.message("inspections.empty.state.help"), SimpleTextAttributes.LINK_ATTRIBUTES) { + text.appendLine(AllIcons.General.ContextHelp, InspectionsBundle.message("inspections.empty.state.help"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { HelpManager.getInstance().invokeHelp("procedures.inspecting.running") } } private fun appendActionLink(text: StatusText, project: Project, actionId: String, @Nls actionText: String) { - text.appendText(actionText, SimpleTextAttributes.LINK_ATTRIBUTES) { + text.appendText(actionText, SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { val dataContext = FileEditorManager.getInstance(project).selectedEditor?.let { DataManager.getInstance().getDataContext(it.component) } ?: SimpleDataContext.getProjectContext(project) val event = AnActionEvent.createFromDataContext(ActionPlaces.UNKNOWN, null, dataContext) diff --git a/platform/lang-impl/src/com/intellij/find/actions/ActivateFindToolWindowAction.kt b/platform/lang-impl/src/com/intellij/find/actions/ActivateFindToolWindowAction.kt index 823ce6da791d..55d8773332ec 100644 --- a/platform/lang-impl/src/com/intellij/find/actions/ActivateFindToolWindowAction.kt +++ b/platform/lang-impl/src/com/intellij/find/actions/ActivateFindToolWindowAction.kt @@ -18,8 +18,14 @@ class ActivateFindToolWindowAction : ToolWindowEmptyStateAction(ToolWindowId.FIN } override fun setupEmptyText(project: Project, statusText: StatusText) { - val shortcut = ActionManager.getInstance().getKeyboardShortcut(IdeActions.ACTION_FIND_USAGES) - val shortcutText = shortcut?.let { " (${KeymapUtil.getShortcutText(shortcut)})"} ?: "" - statusText.appendText(LangBundle.message("status.text.find.toolwindow.empty.state", shortcutText)); + appendWithActionShortcut(statusText, "status.text.find.toolwindow.empty.state.1", IdeActions.ACTION_FIND_USAGES) + statusText.appendLine("") + appendWithActionShortcut(statusText, "status.text.find.toolwindow.empty.state.2", IdeActions.ACTION_FIND_IN_PATH) + } + + private fun appendWithActionShortcut(statusText: StatusText, key: String, actionId: String) { + val shortcut = ActionManager.getInstance().getKeyboardShortcut(actionId) + val shortcutText = shortcut?.let { " (${KeymapUtil.getShortcutText(shortcut)})" } ?: "" + statusText.appendLine(LangBundle.message(key, shortcutText)); } } diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/ActivateHierarchyToolWindowAction.kt b/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/ActivateHierarchyToolWindowAction.kt index 594e257f7e22..baf7acc4e7ba 100644 --- a/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/ActivateHierarchyToolWindowAction.kt +++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/ActivateHierarchyToolWindowAction.kt @@ -19,8 +19,7 @@ import com.intellij.util.ui.StatusText class ActivateHierarchyToolWindowAction : ToolWindowEmptyStateAction(ToolWindowId.HIERARCHY, AllIcons.Toolwindows.ToolWindowHierarchy) { override fun setupEmptyText(project: Project, text: StatusText) { text.clear() - text.appendLine(LangBundle.message("hierarchy.empty.text.1")) - text.appendLine(LangBundle.message("hierarchy.empty.text.2")) + text.appendLine(LangBundle.message("hierarchy.empty.text")) if (LanguageTypeHierarchy.INSTANCE.hasAnyExtensions()) { text.appendLine(LangBundle.message("hierarchy.empty.text.type", KeymapUtil.getShortcutText(IdeActions.ACTION_TYPE_HIERARCHY))) } @@ -31,7 +30,7 @@ class ActivateHierarchyToolWindowAction : ToolWindowEmptyStateAction(ToolWindowI text.appendLine(LangBundle.message("hierarchy.empty.text.method", KeymapUtil.getShortcutText(IdeActions.ACTION_METHOD_HIERARCHY))) } text.appendLine("") - text.appendLine(AllIcons.General.ContextHelp, LangBundle.message("hierarchy.empty.text.help"), SimpleTextAttributes.LINK_ATTRIBUTES) { + text.appendLine(AllIcons.General.ContextHelp, LangBundle.message("hierarchy.empty.text.help"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { HelpManager.getInstance().invokeHelp("procedures.viewinghierarchy") } } diff --git a/platform/platform-api/src/com/intellij/util/ui/StatusText.java b/platform/platform-api/src/com/intellij/util/ui/StatusText.java index 822d1829ee69..68a0dc6f00be 100644 --- a/platform/platform-api/src/com/intellij/util/ui/StatusText.java +++ b/platform/platform-api/src/com/intellij/util/ui/StatusText.java @@ -61,6 +61,7 @@ public abstract class StatusText { private boolean myHasActiveClickListeners; // calculated field for performance optimization private boolean myShowAboveCenter = true; private Font myFont = null; + private boolean myCenterAlignText = true; protected StatusText(JComponent owner) { this(); @@ -116,6 +117,14 @@ public abstract class StatusText { myFont = font; } + public boolean isCenterAlignText() { + return myCenterAlignText; + } + + public void setCenterAlignText(boolean centerAlignText) { + myCenterAlignText = centerAlignText; + } + public void attachTo(@Nullable Component owner) { attachTo(owner, owner); } @@ -260,7 +269,7 @@ public abstract class StatusText { updateBounds(mySecondaryColumn); } - private static void updateBounds(Column column) { + private void updateBounds(Column column) { Dimension size = new Dimension(); for (int i = 0; i < column.fragments.size(); i++) { Fragment fragment = column.fragments.get(i); @@ -270,9 +279,11 @@ public abstract class StatusText { if (i > 0) size.height += JBUIScale.scale(Y_GAP); size.width = Math.max(size.width, d.width); } - for (int i = 0; i < column.fragments.size(); i++) { - Fragment fragment = column.fragments.get(i); - fragment.boundsInColumn.x += (size.width - fragment.boundsInColumn.width)/2; + if (myCenterAlignText) { + for (int i = 0; i < column.fragments.size(); i++) { + Fragment fragment = column.fragments.get(i); + fragment.boundsInColumn.x += (size.width - fragment.boundsInColumn.width)/2; + } } column.preferredSize.setSize(size); } diff --git a/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties b/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties index 1ec87f78b1e1..05f5fbf190db 100644 --- a/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties +++ b/platform/xdebugger-api/resources/messages/XDebuggerBundle.properties @@ -243,6 +243,7 @@ debugger.inline.watches.group.name=Inline Watches debugger.inline.watches.edit.watch.expression.text=Edit Watch Expression debugger.inline.watches.popup.action.add.as.inline.watch=Add as Inline Watch -debug.toolwindow.empty.text.1=To debug your code, do one of the following: +debug.toolwindow.empty.text.0=To debug your code, do one of the following: +debug.toolwindow.empty.text.1=\u2013 Click the Run icon in the editor gutter debug.toolwindow.empty.text.2=\u2013 Select "Debug..." in the editor context menu debug.toolwindow.empty.text.help=Debugging code diff --git a/platform/xdebugger-impl/src/com/intellij/execution/actions/ActivateDebugToolWindowAction.kt b/platform/xdebugger-impl/src/com/intellij/execution/actions/ActivateDebugToolWindowAction.kt index 0d97187cd8eb..7f9fe9e13b50 100644 --- a/platform/xdebugger-impl/src/com/intellij/execution/actions/ActivateDebugToolWindowAction.kt +++ b/platform/xdebugger-impl/src/com/intellij/execution/actions/ActivateDebugToolWindowAction.kt @@ -2,12 +2,10 @@ package com.intellij.execution.actions import com.intellij.execution.executors.DefaultDebugExecutor -import com.intellij.execution.impl.EditConfigurationsDialog import com.intellij.execution.ui.RunContentManager import com.intellij.execution.ui.RunContentManagerImpl import com.intellij.icons.AllIcons import com.intellij.ide.actions.ToolWindowEmptyStateAction -import com.intellij.lang.LangBundle import com.intellij.openapi.help.HelpManager import com.intellij.openapi.project.Project import com.intellij.openapi.wm.ToolWindowId @@ -22,14 +20,13 @@ class ActivateDebugToolWindowAction : ToolWindowEmptyStateAction(ToolWindowId.DE } override fun setupEmptyText(project: Project, text: StatusText) { + text.isCenterAlignText = false + text.appendLine(XDebuggerBundle.message("debug.toolwindow.empty.text.0")) text.appendLine(XDebuggerBundle.message("debug.toolwindow.empty.text.1")) text.appendLine(XDebuggerBundle.message("debug.toolwindow.empty.text.2")) - text.appendLine(LangBundle.message("run.toolwindow.empty.text.3") + " ") - text.appendText(LangBundle.message("run.toolwindow.empty.text.4"), SimpleTextAttributes.LINK_ATTRIBUTES) { - EditConfigurationsDialog(project).show() - } + ActivateRunToolWindowAction.appendLaunchConfigurationText(text, project, "ChooseDebugConfiguration") text.appendLine("") - text.appendLine(AllIcons.General.ContextHelp, XDebuggerBundle.message("debug.toolwindow.empty.text.help"), SimpleTextAttributes.LINK_ATTRIBUTES) { + text.appendLine(AllIcons.General.ContextHelp, XDebuggerBundle.message("debug.toolwindow.empty.text.help"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES) { HelpManager.getInstance().invokeHelp("procedures.debugging") } } diff --git a/plugins/ant/resources/messages/AntBundle.properties b/plugins/ant/resources/messages/AntBundle.properties index ed19d3f4fcab..7d6525174492 100644 --- a/plugins/ant/resources/messages/AntBundle.properties +++ b/plugins/ant/resources/messages/AntBundle.properties @@ -201,6 +201,6 @@ ant.error.unsupported.class.version=Unsupported class version {0} ant.cannot.add.build.file.reason.file.is.not.xml=the file is not an xml file ant.cannot.add.build.file.reason.file.not.ant.file=the file is not recognized as an Ant file ant.empty.text.1=No build files added. -ant.empty.text.2=Add Ant build file +ant.empty.text.2=Add Ant build file... ant.empty.text.help=Adding build file to project add.ant.build.file=Add Ant build file diff --git a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java index cbb03c3a8f8d..10dd79a05d7a 100644 --- a/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java +++ b/plugins/ant/src/com/intellij/lang/ant/config/explorer/AntExplorer.java @@ -198,13 +198,13 @@ public class AntExplorer extends SimpleToolWindowPanel implements DataProvider, private void setupEmptyText() { StatusText emptyText = myTree.getEmptyText(); emptyText.appendLine(AntBundle.message("ant.empty.text.1")); - emptyText.appendLine(AntBundle.message("ant.empty.text.2"), SimpleTextAttributes.LINK_ATTRIBUTES, + emptyText.appendLine(AntBundle.message("ant.empty.text.2"), SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES, e -> addBuildFile()); emptyText.appendLine(""); emptyText.appendLine( AllIcons.General.ContextHelp, AntBundle.message("ant.empty.text.help"), - SimpleTextAttributes.LINK_ATTRIBUTES, + SimpleTextAttributes.LINK_PLAIN_ATTRIBUTES, e -> HelpManager.getInstance().invokeHelp("procedures.building.ant.add")); }