use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class ChangesBrowserBase method buildToolBar.
protected void buildToolBar(final DefaultActionGroup toolBarGroup) {
myDiffAction = new DumbAwareAction() {
public void update(AnActionEvent e) {
e.getPresentation().setEnabled(canShowDiff());
}
public void actionPerformed(AnActionEvent e) {
showDiff();
}
};
ActionUtil.copyFrom(myDiffAction, "ChangesView.Diff");
myDiffAction.registerCustomShortcutSet(myViewer, null);
toolBarGroup.add(myDiffAction);
}
use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class CopyrightProfilesPanel method createActions.
@Override
@Nullable
protected ArrayList<AnAction> createActions(boolean fromPopup) {
ArrayList<AnAction> result = new ArrayList<>();
result.add(new DumbAwareAction("Add", "Add", IconUtil.getAddIcon()) {
{
registerCustomShortcutSet(CommonShortcuts.INSERT, myTree);
}
@Override
public void actionPerformed(AnActionEvent event) {
String name = askForProfileName("Create Copyright Profile", "");
if (name != null) {
addProfileNode(new CopyrightProfile(name));
}
}
});
result.add(new MyDeleteAction());
result.add(new DumbAwareAction("Copy", "Copy", PlatformIcons.COPY_ICON) {
{
registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_MASK)), myTree);
}
@Override
public void actionPerformed(AnActionEvent event) {
String profileName = askForProfileName("Copy Copyright Profile", "");
if (profileName == null) {
return;
}
CopyrightProfile clone = new CopyrightProfile();
clone.copyFrom((CopyrightProfile) getSelectedObject());
clone.setName(profileName);
addProfileNode(clone);
}
@Override
public void update(AnActionEvent event) {
super.update(event);
event.getPresentation().setEnabled(getSelectedObject() != null);
}
});
result.add(new DumbAwareAction("Import", "Import", PlatformIcons.IMPORT_ICON) {
@Override
public void actionPerformed(AnActionEvent event) {
FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor().withFileFilter(file -> {
final FileType fileType = file.getFileType();
return fileType != PlainTextFileType.INSTANCE && (fileType == StdFileTypes.IDEA_MODULE || fileType == StdFileTypes.XML);
}).withTitle("Choose File Containing Copyright Notice");
FileChooser.chooseFile(descriptor, myProject, null, file -> {
final List<CopyrightProfile> profiles = ExternalOptionHelper.loadOptions(VfsUtilCore.virtualToIoFile(file));
if (profiles == null)
return;
if (!profiles.isEmpty()) {
if (profiles.size() == 1) {
importProfile(profiles.get(0));
} else {
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<CopyrightProfile>("Choose profile to import", profiles) {
@Override
public PopupStep onChosen(final CopyrightProfile selectedValue, boolean finalChoice) {
return doFinalStep(() -> importProfile(selectedValue));
}
@NotNull
@Override
public String getTextFor(CopyrightProfile value) {
return value.getName();
}
}).showUnderneathOf(myNorthPanel);
}
} else {
Messages.showWarningDialog(myProject, "The selected file does not contain any copyright settings.", "Import Failure");
}
});
}
private void importProfile(CopyrightProfile copyrightProfile) {
final String profileName = askForProfileName("Import copyright profile", copyrightProfile.getName());
if (profileName == null)
return;
copyrightProfile.setName(profileName);
addProfileNode(copyrightProfile);
Messages.showInfoMessage(myProject, "The copyright settings have been successfully imported.", "Import Complete");
}
});
return result;
}
use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class MultilinePopupBuilder method createPopup.
@NotNull
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(@NotNull AnActionEvent e) {
unregisterCustomShortcutSet(popup.getContent());
popup.closeOk(e.getInputEvent());
}
};
okAction.registerCustomShortcutSet(CommonShortcuts.CTRL_ENTER, popup.getContent());
return popup;
}
use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class DeepCompareAction method selectBranchAndPerformAction.
private static void selectBranchAndPerformAction(@NotNull VcsLogDataPack dataPack, @NotNull AnActionEvent event, @NotNull final Consumer<String> consumer, @NotNull Collection<VirtualFile> visibleRoots) {
ActionGroup actionGroup = new BranchPopupBuilder(dataPack, visibleRoots, null) {
@NotNull
@Override
protected AnAction createAction(@NotNull final String name) {
return new DumbAwareAction(name) {
@Override
public void actionPerformed(AnActionEvent e) {
consumer.consume(name);
}
};
}
}.build();
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup("Select branch to compare", actionGroup, event.getDataContext(), false, false, false, null, -1, null);
InputEvent inputEvent = event.getInputEvent();
if (inputEvent instanceof MouseEvent) {
popup.show(new RelativePoint((MouseEvent) inputEvent));
} else {
popup.showInBestPositionFor(event.getDataContext());
}
}
use of com.intellij.openapi.project.DumbAwareAction in project android by JetBrains.
the class GradleBuildTreeViewPanel method fillRightToolbarGroup.
@Override
protected void fillRightToolbarGroup(DefaultActionGroup group) {
super.fillRightToolbarGroup(group);
group.add(new DumbAwareAction("Show Console Output", null, AndroidIcons.GradleConsole) {
@Override
public void actionPerformed(AnActionEvent e) {
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(GradleConsoleToolWindowFactory.ID);
if (window != null) {
window.activate(null, false);
}
}
@Override
public void update(AnActionEvent e) {
e.getPresentation().setEnabledAndVisible(true);
}
});
DefaultActionGroup filterGroup = new DefaultActionGroup("GradleBuildMessagesFilter", true) {
@Override
public void update(AnActionEvent e) {
Presentation presentation = e.getPresentation();
presentation.setDescription("Filter messages to display");
presentation.setIcon(AllIcons.General.Filter);
}
@Override
public boolean isDumbAware() {
return true;
}
};
// We could have iterated through ErrorTreeElementKind.values() and have less code, but we want to keep this order:
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.ERROR));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.WARNING));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.INFO));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.NOTE));
filterGroup.add(new FilterMessagesByKindAction(ErrorTreeElementKind.GENERIC));
group.add(filterGroup);
}
Aggregations