mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-138163 Select Run/Debug Configuration shortcut does not work in 14.1
This commit is contained in:
+14
-25
@@ -42,34 +42,23 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
public static final Icon CHECKED_SELECTED_ICON = new SizedIcon(AllIcons.Actions.Checked_selected, 16, 16);
|
||||
public static final Icon EMPTY_ICON = EmptyIcon.ICON_16;
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
ComboBoxButton button = (ComboBoxButton)e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
if (button == null || !button.isShowing()) return;
|
||||
button.showPopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
ComboBoxButton button = (ComboBoxButton)presentation.getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
Project project = e.getData(CommonDataKeys.PROJECT);
|
||||
if (ActionPlaces.isMainMenuOrActionSearch(e.getPlace())) {
|
||||
presentation.setDescription(ExecutionBundle.message("choose.run.configuration.action.description"));
|
||||
presentation.setEnabled(button != null);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (project == null || project.isDisposed() || !project.isInitialized()) {
|
||||
updateButton(null, null, null, presentation);
|
||||
updatePresentation(null, null, null, presentation);
|
||||
presentation.setEnabled(false);
|
||||
}
|
||||
else {
|
||||
updateButton(ExecutionTargetManager.getActiveTarget(project),
|
||||
RunManagerEx.getInstanceEx(project).getSelectedConfiguration(),
|
||||
project,
|
||||
presentation);
|
||||
updatePresentation(ExecutionTargetManager.getActiveTarget(project),
|
||||
RunManagerEx.getInstanceEx(project).getSelectedConfiguration(),
|
||||
project,
|
||||
presentation);
|
||||
presentation.setEnabled(true);
|
||||
}
|
||||
}
|
||||
@@ -78,10 +67,10 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
}
|
||||
}
|
||||
|
||||
private static void updateButton(@Nullable ExecutionTarget target,
|
||||
final @Nullable RunnerAndConfigurationSettings settings,
|
||||
final @Nullable Project project,
|
||||
final @NotNull Presentation presentation) {
|
||||
private static void updatePresentation(@Nullable ExecutionTarget target,
|
||||
@Nullable RunnerAndConfigurationSettings settings,
|
||||
@Nullable Project project,
|
||||
@NotNull Presentation presentation) {
|
||||
if (project != null && target != null && settings != null) {
|
||||
String name = settings.getName();
|
||||
if (target != DefaultExecutionTarget.INSTANCE) {
|
||||
@@ -236,10 +225,10 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
ExecutionTargetManager.setActiveTarget(myProject, myTarget);
|
||||
updateButton(ExecutionTargetManager.getActiveTarget(myProject),
|
||||
RunManagerEx.getInstanceEx(myProject).getSelectedConfiguration(),
|
||||
myProject,
|
||||
e.getPresentation());
|
||||
updatePresentation(ExecutionTargetManager.getActiveTarget(myProject),
|
||||
RunManagerEx.getInstanceEx(myProject).getSelectedConfiguration(),
|
||||
myProject,
|
||||
e.getPresentation());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -270,7 +259,7 @@ public class RunConfigurationsComboBoxAction extends ComboBoxAction implements D
|
||||
@Override
|
||||
public void actionPerformed(final AnActionEvent e) {
|
||||
RunManager.getInstance(myProject).setSelectedConfiguration(myConfiguration);
|
||||
updateButton(ExecutionTargetManager.getActiveTarget(myProject), myConfiguration, myProject, e.getPresentation());
|
||||
updatePresentation(ExecutionTargetManager.getActiveTarget(myProject), myConfiguration, myProject, e.getPresentation());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+36
-14
@@ -29,9 +29,12 @@ import com.intellij.openapi.util.IconLoader;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.IdeFocusManager;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.ColorUtil;
|
||||
import com.intellij.ui.Gray;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.UserActivityProviderComponent;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.JBSwingUtilities;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -49,13 +52,29 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
|
||||
private boolean mySmallVariant = true;
|
||||
private String myPopupTitle;
|
||||
private DataContext myDataContext;
|
||||
|
||||
protected ComboBoxAction() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
ComboBoxButton button = (ComboBoxButton)e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
if (button == null) {
|
||||
Component contextComponent = e.getData(PlatformDataKeys.CONTEXT_COMPONENT);
|
||||
JRootPane rootPane = UIUtil.getParentOfType(JRootPane.class, contextComponent);
|
||||
if (rootPane != null) {
|
||||
button = (ComboBoxButton)
|
||||
JBSwingUtilities.uiTraverser().breadthFirstTraversal(rootPane).filter(new Condition<Component>() {
|
||||
@Override
|
||||
public boolean value(Component component) {
|
||||
return component instanceof ComboBoxButton && ((ComboBoxButton)component).getMyAction() == ComboBoxAction.this;
|
||||
}
|
||||
}).first();
|
||||
}
|
||||
if (button == null) return;
|
||||
}
|
||||
if (!button.isShowing()) return;
|
||||
button.showPopup();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -85,8 +104,6 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
|
||||
@Override
|
||||
public void update(AnActionEvent e) {
|
||||
super.update(e);
|
||||
myDataContext = e.getDataContext();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -212,14 +229,15 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
myForceTransparent = transparent;
|
||||
}
|
||||
|
||||
public void showPopup() {
|
||||
@NotNull
|
||||
private Runnable setForcePressed() {
|
||||
myForcePressed = true;
|
||||
repaint();
|
||||
|
||||
Runnable onDispose = new Runnable() {
|
||||
return new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// give button chance to handle action listener
|
||||
// give the button a chance to handle action listener
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -231,9 +249,6 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
fireStateChanged();
|
||||
}
|
||||
};
|
||||
|
||||
myPopup = createPopup(onDispose);
|
||||
myPopup.show(new RelativePoint(this, new Point(-1, getHeight())));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -242,19 +257,26 @@ public abstract class ComboBoxAction extends AnAction implements CustomComponent
|
||||
return myForcePressed ? null : super.getToolTipText();
|
||||
}
|
||||
|
||||
public void showPopup() {
|
||||
createPopup(setForcePressed()).showUnderneathOf(this);
|
||||
}
|
||||
|
||||
protected JBPopup createPopup(Runnable onDispose) {
|
||||
DefaultActionGroup group = createPopupActionGroup(this);
|
||||
|
||||
DataContext context = getDataContext();
|
||||
myDataContext = null;
|
||||
final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
|
||||
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(
|
||||
myPopupTitle, group, context, false, false, false, onDispose, getMaxRows(), getPreselectCondition());
|
||||
popup.setMinimumSize(new Dimension(getMinWidth(), getMinHeight()));
|
||||
return popup;
|
||||
}
|
||||
|
||||
private ComboBoxAction getMyAction() {
|
||||
return ComboBoxAction.this;
|
||||
}
|
||||
|
||||
protected DataContext getDataContext() {
|
||||
return myDataContext == null ? DataManager.getInstance().getDataContext(this) : myDataContext;
|
||||
return DataManager.getInstance().getDataContext(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-2
@@ -40,6 +40,7 @@ import com.intellij.ui.JBColor;
|
||||
import com.intellij.ui.awt.RelativePoint;
|
||||
import com.intellij.ui.awt.RelativeRectangle;
|
||||
import com.intellij.ui.switcher.SwitchTarget;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -329,9 +330,12 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar {
|
||||
|
||||
private JComponent getCustomComponent(AnAction action) {
|
||||
Presentation presentation = myPresentationFactory.getPresentation(action);
|
||||
JComponent customComponent = ((CustomComponentAction)action).createCustomComponent(presentation);
|
||||
JComponent customComponent = ObjectUtils.tryCast(presentation.getClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY), JComponent.class);
|
||||
if (customComponent == null) {
|
||||
customComponent = ((CustomComponentAction)action).createCustomComponent(presentation);
|
||||
presentation.putClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY, customComponent);
|
||||
}
|
||||
tweakActionComponentUI(customComponent);
|
||||
presentation.putClientProperty(CustomComponentAction.CUSTOM_COMPONENT_PROPERTY, customComponent);
|
||||
return customComponent;
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -28,6 +28,7 @@ public class PresentationFactory {
|
||||
myAction2Presentation = new WeakHashMap<AnAction, Presentation>();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final Presentation getPresentation(@NotNull AnAction action){
|
||||
Presentation presentation = myAction2Presentation.get(action);
|
||||
if (presentation == null || !action.isDefaultIcon()){
|
||||
|
||||
@@ -39,13 +39,6 @@ import javax.swing.*;
|
||||
*/
|
||||
public class SwitchTaskCombo extends ComboBoxAction implements DumbAware {
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
ComboBoxButton button = (ComboBoxButton)e.getPresentation().getClientProperty(CUSTOM_COMPONENT_PROPERTY);
|
||||
if (button == null || !button.isShowing()) return;
|
||||
button.showPopup();
|
||||
}
|
||||
|
||||
public JComponent createCustomComponent(final Presentation presentation) {
|
||||
ComboBoxButton button = new ComboBoxButton(presentation) {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user