Example usage for com.intellij.openapi.actionSystem ToggleAction ToggleAction

List of usage examples for com.intellij.openapi.actionSystem ToggleAction ToggleAction

Introduction

In this page you can find the example usage for com.intellij.openapi.actionSystem ToggleAction ToggleAction.

Prototype

public ToggleAction(@Nullable @Nls(capitalization = Nls.Capitalization.Title) final String text,
            @Nullable @Nls(capitalization = Nls.Capitalization.Sentence) final String description,
            @Nullable final Icon icon) 

Source Link

Usage

From source file:com.android.tools.idea.profiling.view.AnalysisResultsManager.java

License:Apache License

@NotNull
@Override/*from   w  ww .j a v a2s  .co m*/
protected AnAction[] createActions() {
    return new AnAction[] {
            new ToggleAction(AndroidBundle.message("android.captures.analysis.results.manager.run.name"),
                    AndroidBundle.message("android.captures.analysis.results.manager.run.description"),
                    AllIcons.Toolwindows.ToolWindowRun) {
                @Override
                public boolean isSelected(AnActionEvent e) {
                    AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
                    return analysisResultsContent != null && !analysisResultsContent.canRunAnalysis();
                }

                @Override
                public void setSelected(AnActionEvent e, boolean state) {
                    if (state) {
                        AnalysisResultsContent analysisResultsContent = getContentFromDesigner();
                        if (analysisResultsContent != null && analysisResultsContent.canRunAnalysis()) {
                            analysisResultsContent.performAnalysis();
                        }
                    }
                }

                @Override
                public void update(@NotNull AnActionEvent e) {
                    super.update(e);
                    Presentation presentation = e.getPresentation();
                    if (isSelected(e)) {
                        presentation.setText(AndroidBundle
                                .message("android.captures.analysis.results.manager.run.disabled.name"));
                        presentation.setDescription(AndroidBundle
                                .message("android.captures.analysis.results.manager.run.disabled.description"));
                        presentation.setIcon(AllIcons.Process.DisabledRun);
                    } else {
                        presentation.setText(AndroidBundle
                                .message("android.captures.analysis.results.manager.run.enabled.name"));
                        presentation.setDescription(AndroidBundle
                                .message("android.captures.analysis.results.manager.run.enabled.description"));
                        presentation.setIcon(AllIcons.Toolwindows.ToolWindowRun);
                    }
                }
            } };
}

From source file:com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog.java

License:Apache License

@NotNull
private ToggleAction createGridViewAction() {
    return new ToggleAction(null, "grid", AndroidIcons.Views.GridView) {
        @Override/*from  w ww.  j  a  v a  2  s .c  o m*/
        public boolean isSelected(AnActionEvent e) {
            return myGridMode;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            setGridMode(state);
        }
    };
}

From source file:com.android.tools.idea.ui.resourcechooser.ChooseResourceDialog.java

License:Apache License

@NotNull
private ToggleAction createListViewAction() {
    return new ToggleAction(null, "list", AndroidIcons.Views.ListView) {
        @Override// w w w.  jav a 2s .  c  o  m
        public boolean isSelected(AnActionEvent e) {
            return !myGridMode;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            setGridMode(!state);
        }
    };
}

From source file:com.intellij.analysis.AnalysisUIOptions.java

License:Apache License

public AnAction createGroupBySeverityAction(final InspectionResultsView view) {
    return new ToggleAction(InspectionsBundle.message("inspection.action.group.by.severity"),
            InspectionsBundle.message("inspection.action.group.by.severity.description"),
            AllIcons.Nodes.SortBySeverity) {

        @Override//from   w ww  . j  a va2s .com
        public boolean isSelected(AnActionEvent e) {
            return GROUP_BY_SEVERITY;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            GROUP_BY_SEVERITY = state;
            view.update();
        }
    };
}

From source file:com.intellij.analysis.AnalysisUIOptions.java

License:Apache License

public AnAction createFilterResolvedItemsAction(final InspectionResultsView view) {
    return new ToggleAction(InspectionsBundle.message("inspection.filter.resolved.action.text"),
            InspectionsBundle.message("inspection.filter.resolved.action.text"), AllIcons.General.Filter) {

        @Override/*from   www. ja  v a2  s.  c o  m*/
        public boolean isSelected(AnActionEvent e) {
            return FILTER_RESOLVED_ITEMS;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            FILTER_RESOLVED_ITEMS = state;
            view.update();
        }
    };
}

From source file:com.intellij.analysis.AnalysisUIOptions.java

License:Apache License

public AnAction createShowOutdatedProblemsAction(final InspectionResultsView view) {
    return new ToggleAction(InspectionsBundle.message("inspection.filter.show.diff.action.text"),
            InspectionsBundle.message("inspection.filter.show.diff.action.text"), AllIcons.Actions.Diff) {

        @Override//  w  w  w  .  ja va  2 s .  c  o m
        public boolean isSelected(AnActionEvent e) {
            return SHOW_DIFF_WITH_PREVIOUS_RUN;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            SHOW_DIFF_WITH_PREVIOUS_RUN = state;
            if (!SHOW_DIFF_WITH_PREVIOUS_RUN) {
                SHOW_ONLY_DIFF = false;
            }
            view.update();
        }
    };
}

From source file:com.intellij.analysis.AnalysisUIOptions.java

License:Apache License

public AnAction createGroupByDirectoryAction(final InspectionResultsView view) {
    return new ToggleAction("Group by directory", "Group by directory", AllIcons.Actions.GroupByPackage) {

        @Override//from  w w  w  . ja  va  2s .  c  om
        public boolean isSelected(AnActionEvent e) {
            return SHOW_STRUCTURE;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            SHOW_STRUCTURE = state;
            view.update();
        }
    };
}

From source file:com.intellij.analysis.AnalysisUIOptions.java

License:Apache License

public AnAction createShowDiffOnlyAction(final InspectionResultsView view) {
    return new ToggleAction(InspectionsBundle.message("inspection.filter.show.diff.only.action.text"),
            InspectionsBundle.message("inspection.filter.show.diff.only.action.text"),
            AllIcons.Actions.ShowChangesOnly) {

        @Override/*from  ww w. j  a  v  a2s  . com*/
        public boolean isSelected(AnActionEvent e) {
            return SHOW_ONLY_DIFF;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            SHOW_ONLY_DIFF = state;
            view.update();
        }

        @Override
        public void update(final AnActionEvent e) {
            super.update(e);
            e.getPresentation().setEnabled(SHOW_DIFF_WITH_PREVIOUS_RUN);
        }
    };
}

From source file:com.intellij.android.designer.designSurface.AndroidDesignerActionPanel.java

License:Apache License

private ActionGroup getRhsActions() {
    DefaultActionGroup group = new DefaultActionGroup();

    group.add(new ToggleAction(null, "Zoom to Fit (0)", AndroidIcons.ZoomFit) {
        @Override//from  w w  w . j  av a  2  s .  c  o  m
        public boolean isSelected(AnActionEvent e) {
            return ((AndroidDesignerEditorPanel) myDesigner).isZoomToFit();
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            myDesigner.zoom(ZoomType.FIT);
        }
    });
    group.add(new AnAction(null, "Reset Zoom to 100% (1)", AndroidIcons.ZoomActual) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            myDesigner.zoom(ZoomType.ACTUAL);
        }
    });
    group.addSeparator();
    group.add(new AnAction(null, "Zoom In (+)", AndroidIcons.ZoomIn) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            myDesigner.zoom(ZoomType.IN);
        }
    });
    group.add(new AnAction(null, "Zoom Out (-)", AndroidIcons.ZoomOut) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            myDesigner.zoom(ZoomType.OUT);
        }
    });

    String description = "Jump to Source";
    KeyboardShortcut shortcut = ActionManager.getInstance()
            .getKeyboardShortcut(IdeActions.ACTION_GOTO_DECLARATION);
    if (shortcut != null) {
        description += " (" + KeymapUtil.getShortcutText(shortcut) + ")";
    }
    // Use FilesTypes.Text rather than FileTypes.Xml here to avoid having the icon from
    // the tab bar replicated right below it
    group.add(new AnAction(null, description, AllIcons.FileTypes.Text) {
        @Override
        public void actionPerformed(AnActionEvent e) {
            List<RadComponent> selection = myDesigner.getSurfaceArea().getSelection();
            if (!selection.isEmpty()) {
                RadViewComponent component = (RadViewComponent) selection.get(0);
                PsiNavigateUtil.navigate(component.getTag());
            }
        }

        @Override
        public void update(AnActionEvent e) {
            List<RadComponent> selection = myDesigner.getSurfaceArea().getSelection();
            e.getPresentation().setEnabled(!selection.isEmpty());
        }
    });

    return group;
}

From source file:com.intellij.codeInsight.documentation.DockablePopupManager.java

License:Apache License

protected AnAction[] createActions() {
    ToggleAction toggleAutoUpdateAction = new ToggleAction(getAutoUpdateTitle(), getAutoUpdateDescription(),
            AllIcons.General.AutoscrollFromSource) {
        @Override/*w w w  . j  a  v a 2 s .  c om*/
        public boolean isSelected(AnActionEvent e) {
            return myAutoUpdateDocumentation;
        }

        @Override
        public void setSelected(AnActionEvent e, boolean state) {
            PropertiesComponent.getInstance().setValue(getAutoUpdateEnabledProperty(), String.valueOf(state));
            myAutoUpdateDocumentation = state;
            restartAutoUpdate(state);
        }
    };
    return new AnAction[] { toggleAutoUpdateAction, createRestorePopupAction() };
}