IDEA-123773 The "Show Whitespaces" broken

This commit is contained in:
Vassiliy Kudryashov
2014-04-11 21:59:39 +04:00
parent 0f869ebb31
commit 45cb352694
6 changed files with 26 additions and 12 deletions
@@ -16,9 +16,9 @@
package com.intellij.ide.actions;
import com.intellij.idea.ActionsBundle;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.Presentation;
import com.intellij.openapi.actionSystem.ToggleAction;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.openapi.wm.WindowManager;
@@ -31,15 +31,21 @@ import java.awt.*;
/**
* @author pegov
*/
public class ToggleFullScreenAction extends AnAction implements DumbAware {
public class ToggleFullScreenAction extends ToggleAction implements DumbAware {
private static final String TEXT_ENTER_FULL_SCREEN = ActionsBundle.message("action.ToggleFullScreen.text.enter");
private static final String TEXT_EXIT_FULL_SCREEN = ActionsBundle.message("action.ToggleFullScreen.text.exit");
@Override
public void actionPerformed(final AnActionEvent e) {
public boolean isSelected(AnActionEvent e) {
IdeFrameEx frame = getFrame();
return frame != null && frame.isInFullScreen();
}
@Override
public void setSelected(AnActionEvent e, boolean state) {
IdeFrameEx frame = getFrame();
if (frame != null) {
frame.toggleFullScreen(!frame.isInFullScreen());
frame.toggleFullScreen(state);
}
}
@@ -339,6 +339,7 @@ public class CustomActionsSchema implements ExportableComponent, NamedJDOMExtern
}
if (anAction.getTemplatePresentation() != null) {
anAction.getTemplatePresentation().setIcon(icon);
anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(icon));
anAction.setDefaultIcon(false);
}
}
@@ -333,6 +333,7 @@ public class CustomizableActionsPanel {
if (exitCode == Messages.OK) {
mySelectedSchema.addIconCustomization(actionId, null);
anAction.getTemplatePresentation().setIcon(AllIcons.Toolbar.Unknown);
anAction.getTemplatePresentation().setDisabledIcon(IconLoader.getDisabledIcon(AllIcons.Toolbar.Unknown));
anAction.setDefaultIcon(false);
node.setUserObject(Pair.create(actionId, AllIcons.Toolbar.Unknown));
myActionsTree.repaint();
@@ -145,12 +145,11 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
final ActionManagerImpl am = (ActionManagerImpl)ActionManager.getInstance();
ActionPopupMenuImpl popupMenu = (ActionPopupMenuImpl)am.createActionPopupMenu(event.getPlace(), (ActionGroup)myAction, new MenuItemPresentationFactory() {
@Override
protected Presentation processPresentation(Presentation presentation) {
protected void processPresentation(Presentation presentation) {
if (myNoIconsInPopup) {
presentation.setIcon(null);
presentation.setHoveredIcon(null);
}
return presentation;
}
});
popupMenu.setDataContextProvider(new Getter<DataContext>() {
@@ -353,6 +352,7 @@ public class ActionButton extends JComponent implements ActionButtonComponent, A
updateToolTipText();
}
else if (Presentation.PROP_ENABLED.equals(propertyName)) {
updateIcon();
repaint();
}
else if (Presentation.PROP_ICON.equals(propertyName)) {
@@ -33,13 +33,12 @@ public class MenuItemPresentationFactory extends PresentationFactory {
myForceHide = forceHide;
}
protected Presentation processPresentation(Presentation presentation) {
protected void processPresentation(Presentation presentation) {
if (!UISettings.getInstance().SHOW_ICONS_IN_MENUS || myForceHide) {
presentation.setIcon(null);
presentation.setDisabledIcon(null);
presentation.setHoveredIcon(null);
presentation.putClientProperty(HIDE_ICON, Boolean.TRUE);
}
return presentation;
}
}
@@ -31,14 +31,21 @@ public class PresentationFactory {
public final Presentation getPresentation(@NotNull AnAction action){
Presentation presentation = myAction2Presentation.get(action);
if (presentation == null || !action.isDefaultIcon()){
presentation = action.getTemplatePresentation().clone();
myAction2Presentation.put(action, processPresentation(presentation));
Presentation templatePresentation = action.getTemplatePresentation();
if (presentation == null) {
presentation = templatePresentation.clone();
myAction2Presentation.put(action, presentation);
}
if (!action.isDefaultIcon()) {
presentation.setIcon(templatePresentation.getIcon());
presentation.setDisabledIcon(templatePresentation.getDisabledIcon());
}
processPresentation(presentation);
}
return presentation;
}
protected Presentation processPresentation(Presentation presentation) {
return presentation;
protected void processPresentation(Presentation presentation) {
}
public void reset() {