com.intellij.openapi.project.DumbAwareAction Java Examples
The following examples show how to use
com.intellij.openapi.project.DumbAwareAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlutterSdkAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void actionPerformed(@NotNull AnActionEvent event) { final Project project = DumbAwareAction.getEventProject(event); if (enableActionInBazelContext()) { // See if the Bazel workspace exists for this project. final Workspace workspace = FlutterModuleUtils.getFlutterBazelWorkspace(project); if (workspace != null) { FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); startCommandInBazelContext(project, workspace); return; } } final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null; if (sdk == null) { showMissingSdkDialog(project); return; } FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); startCommand(project, sdk, PubRoot.forEventWithRefresh(event), event.getDataContext()); }
Example #2
Source File: FlutterSdkAction.java From flutter-intellij with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override public void actionPerformed(@NotNull AnActionEvent event) { final Project project = DumbAwareAction.getEventProject(event); if (enableActionInBazelContext()) { // See if the Bazel workspace exists for this project. final Workspace workspace = FlutterModuleUtils.getFlutterBazelWorkspace(project); if (workspace != null) { FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); startCommandInBazelContext(project, workspace); return; } } final FlutterSdk sdk = project != null ? FlutterSdk.getFlutterSdk(project) : null; if (sdk == null) { showMissingSdkDialog(project); return; } FlutterInitializer.sendAnalyticsAction(this); FileDocumentManager.getInstance().saveAllDocuments(); startCommand(project, sdk, PubRoot.forEventWithRefresh(event), event.getDataContext()); }
Example #3
Source File: RunIdeConsoleAction.java From consulo with Apache License 2.0 | 6 votes |
@Override public void actionPerformed(AnActionEvent e) { List<String> languages = IdeScriptEngineManager.getInstance().getLanguages(); if (languages.size() == 1) { runConsole(e, languages.iterator().next()); return; } DefaultActionGroup actions = new DefaultActionGroup(ContainerUtil.map(languages, (NotNullFunction<String, AnAction>)language -> new DumbAwareAction(language) { @Override public void actionPerformed(@Nonnull AnActionEvent e1) { runConsole(e1, language); } })); JBPopupFactory.getInstance().createActionGroupPopup("Script Engine", actions, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false). showInBestPositionFor(e.getDataContext()); }
Example #4
Source File: ScopesChooser.java From consulo with Apache License 2.0 | 6 votes |
private void fillActionGroup(final DefaultActionGroup group, final List<NamedScope> scopes, final List<Descriptor> defaultDescriptors, final InspectionProfileImpl inspectionProfile, final Set<String> excludedScopeNames) { for (final NamedScope scope : scopes) { final String scopeName = scope.getName(); if (excludedScopeNames.contains(scopeName)) { continue; } group.add(new DumbAwareAction(scopeName) { @Override public void actionPerformed(final AnActionEvent e) { for (final Descriptor defaultDescriptor : defaultDescriptors) { inspectionProfile.addScope(defaultDescriptor.getToolWrapper().createCopy(), scope, defaultDescriptor.getLevel(), true, getEventProject(e)); } onScopeAdded(); } }); } }
Example #5
Source File: DefaultSdksModel.java From consulo with Apache License 2.0 | 6 votes |
@Override public void createAddActions(DefaultActionGroup group, final JComponent parent, final Consumer<Sdk> updateTree, @Nullable Condition<SdkTypeId> filter) { final List<SdkType> types = SdkType.EP_NAME.getExtensionList(); List<SdkType> list = new ArrayList<>(types.size()); for (SdkType sdkType : types) { if (filter != null && !filter.value(sdkType)) { continue; } list.add(sdkType); } Collections.sort(list, (o1, o2) -> StringUtil.compare(o1.getPresentableName(), o2.getPresentableName(), true)); for (final SdkType type : list) { final AnAction addAction = new DumbAwareAction(type.getPresentableName(), null, type.getIcon()) { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { doAdd(parent, type, updateTree); } }; group.add(addAction); } }
Example #6
Source File: MultilinePopupBuilder.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull JBPopup createPopup() { JPanel panel = new JPanel(new BorderLayout()); panel.add(myTextField, BorderLayout.CENTER); ComponentPopupBuilder builder = JBPopupFactory.getInstance().createComponentPopupBuilder(panel, myTextField) .setCancelOnClickOutside(true) .setAdText(KeymapUtil.getShortcutsText(CommonShortcuts.CTRL_ENTER.getShortcuts()) + " to finish") .setRequestFocus(true) .setResizable(true) .setMayBeParent(true); final JBPopup popup = builder.createPopup(); popup.setMinimumSize(new JBDimension(200, 90)); AnAction okAction = new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { unregisterCustomShortcutSet(popup.getContent()); popup.closeOk(e.getInputEvent()); } }; okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent()); return popup; }
Example #7
Source File: AnalyzeDependenciesComponent.java From consulo with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Nonnull @Override public DefaultActionGroup createPopupActionGroup(JComponent component) { if (myItems == null) { myItems = new DefaultActionGroup(null, true); for (final ClasspathType classpathType : ClasspathType.values()) { myItems.addAction(new DumbAwareAction(classpathType.getDescription()) { @Override public void actionPerformed(AnActionEvent e) { mySettings.setRuntime(classpathType.isRuntime()); mySettings.setTest(classpathType.isTest()); updateTree(); } }); } } return myItems; }
Example #8
Source File: DesktopEditorAnalyzeStatusPanel.java From consulo with Apache License 2.0 | 6 votes |
private AnAction createAction(@Nonnull String id, @Nonnull Image icon) { AnAction delegate = ActionManager.getInstance().getAction(id); AnAction result = new DumbAwareAction(delegate.getTemplatePresentation().getText(), null, icon) { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { IdeFocusManager focusManager = IdeFocusManager.getInstance(myEditor.getProject()); AnActionEvent delegateEvent = AnActionEvent.createFromAnAction(delegate, e.getInputEvent(), ActionPlaces.EDITOR_INSPECTIONS_TOOLBAR, myEditor.getDataContext()); if (focusManager.getFocusOwner() != myEditor.getContentComponent()) { focusManager.requestFocus(myEditor.getContentComponent(), true).doWhenDone(() -> { delegate.actionPerformed(delegateEvent); }); } else { delegate.actionPerformed(delegateEvent); } } }; result.copyShortcutFrom(delegate); return result; }
Example #9
Source File: XValueHint.java From consulo with Apache License 2.0 | 6 votes |
@Override protected boolean showHint(final JComponent component) { boolean result = super.showHint(component); if (result && getType() == ValueHintType.MOUSE_OVER_HINT) { myDisposable = Disposable.newDisposable(); ShortcutSet shortcut = ActionManager.getInstance().getAction("ShowErrorDescription").getShortcutSet(); new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { hideHint(); final Point point = new Point(myPoint.x, myPoint.y + getEditor().getLineHeight()); new XValueHint(getProject(), getEditor(), point, ValueHintType.MOUSE_CLICK_HINT, myExpressionInfo, myEvaluator, myDebugSession).invokeHint(); } }.registerCustomShortcutSet(shortcut, getEditor().getContentComponent(), myDisposable); } if (result) { XValueHint prev = getEditor().getUserData(HINT_KEY); if (prev != null) { prev.hideHint(); } getEditor().putUserData(HINT_KEY, this); } return result; }
Example #10
Source File: RecentLocationsAction.java From consulo with Apache License 2.0 | 6 votes |
private static void initSearchActions(@Nonnull Project project, @Nonnull RecentLocationsDataModel data, @Nonnull ListWithFilter<RecentLocationItem> listWithFilter, @Nonnull JBList<RecentLocationItem> list, @Nonnull JBCheckBox checkBox, @Nonnull JBPopup popup, @Nonnull Ref<? super Boolean> navigationRef) { listWithFilter.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { int clickCount = event.getClickCount(); if (clickCount > 1 && clickCount % 2 == 0) { event.consume(); navigateToSelected(project, list, popup, navigationRef); } } }); DumbAwareAction.create(e -> navigateToSelected(project, list, popup, navigationRef)).registerCustomShortcutSet(CustomShortcutSet.fromString("ENTER"), listWithFilter, popup); DumbAwareAction.create(e -> removePlaces(project, listWithFilter, list, data, checkBox.isSelected())) .registerCustomShortcutSet(CustomShortcutSet.fromString("DELETE", "BACK_SPACE"), listWithFilter, popup); }
Example #11
Source File: QuickChangeLookAndFeel.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void fillActions(Project project, @Nonnull DefaultActionGroup group, @Nonnull DataContext dataContext) { final LafManager manager = LafManager.getInstance(); final UIManager.LookAndFeelInfo[] lfs = manager.getInstalledLookAndFeels(); final UIManager.LookAndFeelInfo current = manager.getCurrentLookAndFeel(); for (final UIManager.LookAndFeelInfo lf : lfs) { group.add(new DumbAwareAction(lf.getName(), "", lf == current ? ourCurrentAction : ourNotCurrentAction) { @Override public void actionPerformed(AnActionEvent e) { final UIManager.LookAndFeelInfo cur = manager.getCurrentLookAndFeel(); if (cur == lf) return; manager.setCurrentLookAndFeel(lf); manager.updateUI(); } }); } }
Example #12
Source File: ExtendableTextField.java From consulo with Apache License 2.0 | 5 votes |
/** * Temporary solution to support icons in the text component for different L&F. * This method replaces non-supported UI with Darcula UI. * * @param ui an object to paint this text component */ //@Override //@Deprecated //public void setUI(TextUI ui) { // TextUI suggested = ui; // try { // if (ui == null || !Class.forName("com.intellij.ide.ui.laf.darcula.ui.TextFieldWithPopupHandlerUI_New").isAssignableFrom(ui.getClass())) { // ui = (TextUI)Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI_New").getDeclaredMethod("createUI", JComponent.class).invoke(null, this); // } // } // catch (Exception ignore) { // } // // super.setUI(ui); // if (ui != suggested) { // try { // setBorder((Border)Class.forName("com.intellij.ide.ui.laf.darcula.ui.DarculaTextBorder_New").newInstance()); // } // catch (Exception ignore) { // } // } //} public ExtendableTextField addBrowseExtension(@Nonnull Runnable action, @Nullable Disposable parentDisposable) { KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK); String tooltip = UIBundle.message("component.with.browse.button.browse.button.tooltip.text") + " (" + KeymapUtil.getKeystrokeText(keyStroke) + ")"; ExtendableTextComponent.Extension browseExtension = ExtendableTextComponent.Extension.create(AllIcons.Nodes.TreeOpen, AllIcons.Nodes.TreeOpen, tooltip, action); new DumbAwareAction() { @Override public void actionPerformed(@Nonnull AnActionEvent e) { action.run(); } }.registerCustomShortcutSet(new CustomShortcutSet(keyStroke), this, parentDisposable); addExtension(browseExtension); return this; }
Example #13
Source File: DesktopToolWindowContentUi.java From consulo with Apache License 2.0 | 5 votes |
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) { return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final Content selectedContent = manager.getSelectedContent(); final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>(); int selectedTab = -1; for (Content content : manager.getContents()) { if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) { final String label = content.getTabName().substring(tabPrefix.length() + 2); final JComponent component = content.getComponent(); if (content == selectedContent) { selectedTab = tabs.size(); } tabs.add(Pair.create(label, component)); manager.removeContent(content, false); content.setComponent(null); Disposer.dispose(content); } } PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix); for (int i = 0; i < tabs.size(); i++) { final Pair<String, JComponent> tab = tabs.get(i); ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab); } } }; }
Example #14
Source File: DesktopToolWindowContentUi.java From consulo with Apache License 2.0 | 5 votes |
private static AnAction createSplitTabsAction(final TabbedContent content) { return new DumbAwareAction("Split '" + content.getTitlePrefix() + "' group") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { content.split(); } }; }
Example #15
Source File: ScopesChooser.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public DefaultActionGroup createPopupActionGroup(JComponent component) { final DefaultActionGroup group = new DefaultActionGroup(); final List<NamedScope> predefinedScopes = new ArrayList<NamedScope>(); final List<NamedScope> customScopes = new ArrayList<NamedScope>(); for (final NamedScopesHolder holder : NamedScopesHolder.getAllNamedScopeHolders(myProject)) { Collections.addAll(customScopes, holder.getEditableScopes()); predefinedScopes.addAll(holder.getPredefinedScopes()); } predefinedScopes.remove(CustomScopesProviderEx.getAllScope()); for (NamedScope predefinedScope : predefinedScopes) { if (predefinedScope instanceof NonProjectFilesScope) { predefinedScopes.remove(predefinedScope); break; } } fillActionGroup(group, predefinedScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); fillActionGroup(group, customScopes, myDefaultDescriptors, myInspectionProfile, myExcludedScopeNames); group.addSeparator(); group.add(new DumbAwareAction("Edit Scopes Order...") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final ScopesOrderDialog dlg = new ScopesOrderDialog(myInspectionProfile, myProject); if (dlg.showAndGet()) { onScopesOrderChanged(); } } }); return group; }
Example #16
Source File: DockablePopupManager.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected AnAction createRestorePopupAction() { return new DumbAwareAction("Open as Popup", getRestorePopupDescription(), null) { @Override public void actionPerformed(@Nonnull AnActionEvent e) { restorePopupBehavior(); } }; }
Example #17
Source File: ChooseFileEncodingAction.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull protected DefaultActionGroup createCharsetsActionGroup(@Nullable String clearItemText, @Nullable Charset alreadySelected, @Nonnull Function<? super Charset, String> charsetFilter) { DefaultActionGroup group = new DefaultActionGroup(); List<Charset> favorites = new ArrayList<>(EncodingManager.getInstance().getFavorites()); Collections.sort(favorites); Charset current = myVirtualFile == null ? null : myVirtualFile.getCharset(); favorites.remove(current); favorites.remove(alreadySelected); if (clearItemText != null) { String description = "Clear " + (myVirtualFile == null ? "default" : "file '" + myVirtualFile.getName() + "'") + " encoding."; group.add(new DumbAwareAction(clearItemText, description, null) { @Override public void actionPerformed(@Nonnull AnActionEvent e) { chosen(myVirtualFile, NO_ENCODING); } }); } if (favorites.isEmpty() && clearItemText == null) { fillCharsetActions(group, myVirtualFile, Arrays.asList(CharsetToolkit.getAvailableCharsets()), charsetFilter); } else { fillCharsetActions(group, myVirtualFile, favorites, charsetFilter); DefaultActionGroup more = new DefaultActionGroup("more", true); group.add(more); fillCharsetActions(more, myVirtualFile, Arrays.asList(CharsetToolkit.getAvailableCharsets()), charsetFilter); } return group; }
Example #18
Source File: QuickChangeCodeFormatterAction.java From EclipseCodeFormatter with Apache License 2.0 | 5 votes |
@Override protected void fillActions(final Project project, DefaultActionGroup group, DataContext dataContext) { Settings.Formatter formatter = ProjectComponent.getInstance(project).getSelectedProfile().getFormatter(); for (final Settings.Formatter lf : Settings.Formatter.values()) { group.add(new DumbAwareAction(lf.name(), "", lf == formatter ? ourCurrentAction : ourNotCurrentAction) { @Override public void actionPerformed(AnActionEvent e) { changeFormatter(project, lf); } }); } }
Example #19
Source File: QuickRunMavenGoalAction.java From MavenHelper with Apache License 2.0 | 5 votes |
private AnAction editAndRun(Goal goal, MavenProjectInfo mavenProject) { return new DumbAwareAction("Edit and Run", null, AllIcons.Actions.Edit) { @Override public void actionPerformed(@NotNull AnActionEvent anActionEvent) { Goal edit_and_run = GoalEditor.editGoal("Edit and Run", ApplicationSettings.get(), goal); if (edit_and_run != null) { RunGoalAction.create(goal, MyIcons.RUN_MAVEN_ICON, true, mavenProject).actionPerformed(anActionEvent); } } }; }
Example #20
Source File: QuickRunMavenGoalAction.java From MavenHelper with Apache License 2.0 | 5 votes |
private AnAction delete(Goal goal) { return new DumbAwareAction("Delete", null, AllIcons.General.Remove) { @Override public void actionPerformed(@NotNull AnActionEvent anActionEvent) { ApplicationService.getInstance().getState().removeGoal(goal); } }; }
Example #21
Source File: DiffGutterRenderer.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @Override public AnAction getClickAction() { return new DumbAwareAction() { @Override public void actionPerformed(AnActionEvent e) { performAction(e); } }; }
Example #22
Source File: DiffWindowBase.java From consulo with Apache License 2.0 | 5 votes |
protected void init() { if (myWrapper != null) return; myProcessor = createProcessor(); String dialogGroupKey = myProcessor.getContextUserData(DiffUserDataKeys.DIALOG_GROUP_KEY); if (dialogGroupKey == null) dialogGroupKey = "DiffContextDialog"; myWrapper = new WindowWrapperBuilder(DiffUtil.getWindowMode(myHints), new MyPanel(myProcessor.getComponent())) .setProject(myProject) .setParent(myHints.getParent()) .setDimensionServiceKey(dialogGroupKey) .setOnShowCallback(new Runnable() { @Override public void run() { myProcessor.updateRequest(); myProcessor.requestFocus(); // TODO: not needed for modal dialogs. Make a flag in WindowWrapperBuilder ? } }) .build(); myWrapper.setImage(ImageLoader.loadFromResource("/diff/Diff.png")); Disposer.register(myWrapper, myProcessor); new DumbAwareAction() { public void actionPerformed(final AnActionEvent e) { myWrapper.close(); } }.registerCustomShortcutSet(CommonShortcuts.getCloseActiveWindow(), myProcessor.getComponent()); }
Example #23
Source File: UnifiedToolWindowContentUI.java From consulo with Apache License 2.0 | 5 votes |
private static AnAction createSplitTabsAction(final TabbedContent content) { return new DumbAwareAction("Split '" + content.getTitlePrefix() + "' group") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { content.split(); } }; }
Example #24
Source File: UnifiedToolWindowContentUI.java From consulo with Apache License 2.0 | 5 votes |
private static AnAction createMergeTabsAction(final ContentManager manager, final String tabPrefix) { return new DumbAwareAction("Merge tabs to '" + tabPrefix + "' group") { @RequiredUIAccess @Override public void actionPerformed(@Nonnull AnActionEvent e) { final Content selectedContent = manager.getSelectedContent(); final List<Pair<String, JComponent>> tabs = new ArrayList<Pair<String, JComponent>>(); int selectedTab = -1; for (Content content : manager.getContents()) { if (tabPrefix.equals(content.getUserData(Content.TAB_GROUP_NAME_KEY))) { final String label = content.getTabName().substring(tabPrefix.length() + 2); final JComponent component = content.getComponent(); if (content == selectedContent) { selectedTab = tabs.size(); } tabs.add(Pair.create(label, component)); manager.removeContent(content, false); content.setComponent(null); Disposer.dispose(content); } } PropertiesComponent.getInstance().unsetValue(TabbedContent.SPLIT_PROPERTY_PREFIX + tabPrefix); for (int i = 0; i < tabs.size(); i++) { final Pair<String, JComponent> tab = tabs.get(i); ContentUtilEx.addTabbedContent(manager, tab.second, tabPrefix, tab.first, i == selectedTab); } } }; }
Example #25
Source File: LookupImpl.java From consulo with Apache License 2.0 | 4 votes |
private void delegateActionToEditor(@Nonnull String actionID, @Nullable Supplier<? extends AnAction> delegateActionSupplier, @Nonnull AnActionEvent actionEvent) { AnAction action = ActionManager.getInstance().getAction(actionID); DumbAwareAction.create(e -> ActionUtil.performActionDumbAware(delegateActionSupplier == null ? action : delegateActionSupplier.get(), actionEvent)) .registerCustomShortcutSet(action.getShortcutSet(), myList); }
Example #26
Source File: SystemShortcuts.java From consulo with Apache License 2.0 | 4 votes |
private void doNotify(@Nonnull Keymap keymap, @Nonnull String actionId, @Nonnull KeyStroke sysKS, @Nullable String macOsShortcutAction, @Nonnull KeyboardShortcut conflicted) { if (!ourIsNotificationRegistered) { ourIsNotificationRegistered = true; NotificationsConfiguration.getNotificationsConfiguration().register(ourNotificationGroupId, NotificationDisplayType.STICKY_BALLOON, true); } final AnAction act = ActionManager.getInstance().getAction(actionId); final String actText = act == null ? actionId : act.getTemplateText(); final String message = "The " + actText + " shortcut conflicts with macOS shortcut" + (macOsShortcutAction == null ? "" : " '" + macOsShortcutAction + "'") + ". Modify this shortcut or change macOS system settings."; final Notification notification = new Notification(ourNotificationGroupId, "Shortcuts conflicts", message, NotificationType.WARNING, null); final AnAction configureShortcut = DumbAwareAction.create("Modify shortcut", e -> { Component component = e.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT); if (component == null) { Window[] frames = Window.getWindows(); component = frames == null || frames.length == 0 ? null : frames[0]; if (component == null) { LOG.error("can't show KeyboardShortcutDialog (parent component wasn't found)"); return; } } KeymapPanel.addKeyboardShortcut(actionId, ActionShortcutRestrictions.getInstance().getForActionId(actionId), keymap, component, conflicted, SystemShortcuts.this); notification.expire(); }); notification.addAction(configureShortcut); final AnAction muteAction = DumbAwareAction.create("Don't show again", e -> { myMutedConflicts.addMutedAction(actionId); notification.expire(); }); notification.addAction(muteAction); if (SystemInfo.isMac) { final AnAction changeSystemSettings = DumbAwareAction.create("Change system settings", e -> { ApplicationManager.getApplication().executeOnPooledThread(() -> { final GeneralCommandLine cmdLine = new GeneralCommandLine("osascript", "-e", "tell application \"System Preferences\"", "-e", "set the current pane to pane id \"com.apple.preference.keyboard\"", "-e", "reveal anchor \"shortcutsTab\" of pane id \"com.apple.preference.keyboard\"", "-e", "activate", "-e", "end tell"); try { ExecUtil.execAndGetOutput(cmdLine); // NOTE: we can't detect OS-settings changes // but we can try to schedule check conflicts (and expire notification if necessary) } catch (ExecutionException ex) { LOG.error(ex); } }); }); notification.addAction(changeSystemSettings); } myNotifiedActions.add(actionId); notification.notify(null); }
Example #27
Source File: SearchEverywhereUI.java From consulo with Apache License 2.0 | 4 votes |
private void registerAction(String actionID, Consumer<? super AnActionEvent> action) { registerAction(actionID, () -> DumbAwareAction.create(action)); }
Example #28
Source File: SearchEverywhereManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
private SearchEverywhereUI createView(Project project, List<? extends SearchEverywhereContributor<?>> contributors) { SearchEverywhereUI view = new SearchEverywhereUI(project, contributors); view.setSearchFinishedHandler(() -> { if (isShown()) { myBalloon.cancel(); } }); view.addViewTypeListener(viewType -> { if (!isShown()) { return; } ApplicationManager.getApplication().invokeLater(() -> { if (myBalloon == null || myBalloon.isDisposed()) return; Dimension minSize = view.getMinimumSize(); JBInsets.addTo(minSize, myBalloon.getContent().getInsets()); myBalloon.setMinimumSize(minSize); if (viewType == SearchEverywhereUI.ViewType.SHORT) { myBalloonFullSize = myBalloon.getSize(); JBInsets.removeFrom(myBalloonFullSize, myBalloon.getContent().getInsets()); myBalloon.pack(false, true); } else { if (myBalloonFullSize == null) { myBalloonFullSize = view.getPreferredSize(); JBInsets.addTo(myBalloonFullSize, myBalloon.getContent().getInsets()); } myBalloonFullSize.height = Integer.max(myBalloonFullSize.height, minSize.height); myBalloonFullSize.width = Integer.max(myBalloonFullSize.width, minSize.width); myBalloon.setSize(myBalloonFullSize); } }); }); DumbAwareAction.create(__ -> showHistoryItem(true)).registerCustomShortcutSet(SearchTextField.SHOW_HISTORY_SHORTCUT, view); DumbAwareAction.create(__ -> showHistoryItem(false)).registerCustomShortcutSet(SearchTextField.ALT_SHOW_HISTORY_SHORTCUT, view); return view; }
Example #29
Source File: RunAnythingPopupUI.java From consulo with Apache License 2.0 | 4 votes |
private void initSearchActions() { myResultsList.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { onMouseClicked(e); } }); DumbAwareAction.create(e -> RunAnythingUtil.jumpNextGroup(true, myResultsList)).registerCustomShortcutSet(CustomShortcutSet.fromString("TAB"), (JComponent)TargetAWT.to(mySearchField), this); DumbAwareAction.create(e -> RunAnythingUtil.jumpNextGroup(false, myResultsList)) .registerCustomShortcutSet(CustomShortcutSet.fromString("shift TAB"), (JComponent)TargetAWT.to(mySearchField), this); AnAction escape = ActionManager.getInstance().getAction("EditorEscape"); DumbAwareAction.create(__ -> { triggerUsed(); searchFinishedHandler.run(); }).registerCustomShortcutSet(escape == null ? CommonShortcuts.ESCAPE : escape.getShortcutSet(), this); DumbAwareAction.create(e -> executeCommand()) .registerCustomShortcutSet(CustomShortcutSet.fromString("ENTER", "shift ENTER", "alt ENTER", "alt shift ENTER", "meta ENTER"), (JComponent)TargetAWT.to(mySearchField), this); DumbAwareAction.create(e -> { RunAnythingSearchListModel model = getSearchingModel(myResultsList); if (model == null) return; Object selectedValue = myResultsList.getSelectedValue(); int index = myResultsList.getSelectedIndex(); if (!(selectedValue instanceof RunAnythingItem) || isMoreItem(index)) return; RunAnythingCache.getInstance(getProject()).getState().getCommands().remove(((RunAnythingItem)selectedValue).getCommand()); model.remove(index); model.shiftIndexes(index, -1); if (model.size() > 0) ScrollingUtil.selectItem(myResultsList, index < model.size() ? index : index - 1); Application.get().invokeLater(() -> { if (myCalcThread != null) { myCalcThread.updatePopup(); } }); }).registerCustomShortcutSet(CustomShortcutSet.fromString("shift BACK_SPACE"), (JComponent)TargetAWT.to(mySearchField), this); myProject.getMessageBus().connect(this).subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { @Override public void exitDumbMode() { Application.get().invokeLater(() -> rebuildList()); } }); }
Example #30
Source File: FileStructurePopup.java From consulo with Apache License 2.0 | 4 votes |
private void addCheckbox(JPanel panel, TreeAction action) { String text = action instanceof FileStructureFilter ? ((FileStructureFilter)action).getCheckBoxText() : action instanceof FileStructureNodeProvider ? ((FileStructureNodeProvider)action).getCheckBoxText() : null; if (text == null) return; Shortcut[] shortcuts = extractShortcutFor(action); JBCheckBox checkBox = new JBCheckBox(); checkBox.setOpaque(false); UIUtil.applyStyle(UIUtil.ComponentStyle.SMALL, checkBox); boolean selected = getDefaultValue(action); checkBox.setSelected(selected); boolean isRevertedStructureFilter = action instanceof FileStructureFilter && ((FileStructureFilter)action).isReverted(); myTreeActionsOwner.setActionIncluded(action, isRevertedStructureFilter != selected); checkBox.addActionListener(__ -> { boolean state = checkBox.isSelected(); if (!myAutoClicked.contains(checkBox)) { saveState(action, state); } myTreeActionsOwner.setActionIncluded(action, isRevertedStructureFilter != state); rebuild(false).onProcessed(ignore -> { if (mySpeedSearch.isPopupActive()) { mySpeedSearch.refreshSelection(); } }); }); checkBox.setFocusable(false); if (shortcuts.length > 0) { text += " (" + KeymapUtil.getShortcutText(shortcuts[0]) + ")"; DumbAwareAction.create(e -> checkBox.doClick()).registerCustomShortcutSet(new CustomShortcutSet(shortcuts), myTree); } checkBox.setText(StringUtil.capitalize(StringUtil.trimStart(text.trim(), "Show "))); panel.add(checkBox); myCheckBoxes.put(action.getClass(), checkBox); }