use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class ChooseFileEncodingAction method createCharsetsActionGroup.
@NotNull
protected DefaultActionGroup createCharsetsActionGroup(@Nullable String clearItemText, @Nullable Charset alreadySelected, @NotNull Function<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(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;
}
use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class ProjectStartupConfigurable method createComponent.
@Nullable
@Override
public JComponent createComponent() {
myModel = new ProjectStartupTasksTableModel(RunManagerEx.getInstanceEx(myProject));
myTable = new JBTable(myModel);
myTable.getEmptyText().setText("Add run configurations with the + button");
new TableSpeedSearch(myTable);
DefaultCellEditor defaultEditor = (DefaultCellEditor) myTable.getDefaultEditor(Object.class);
defaultEditor.setClickCountToStart(1);
myTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
final int row = myTable.getSelectedRow();
if (row >= 0 && myModel.isCellEditable(row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN)) {
myModel.setValueAt(!Boolean.TRUE.equals(myTable.getValueAt(row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN)), row, ProjectStartupTasksTableModel.IS_SHARED_COLUMN);
}
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyEvent.VK_SPACE), myTable);
myTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() >= 2) {
editRunConfiguration();
}
}
});
installRenderers();
myDecorator = ToolbarDecorator.createDecorator(myTable).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
selectAndAddConfiguration(button);
}
}).setEditAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
editRunConfiguration();
}
}).setEditActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return myTable.getSelectedRow() >= 0;
}
}).disableUpAction().disableDownAction();
final JPanel tasksPanel = myDecorator.createPanel();
final JLabel label = new JLabel("Run tasks and tools via run configurations");
label.setForeground(UIUtil.getInactiveTextColor());
label.setHorizontalAlignment(SwingConstants.RIGHT);
final JPanel wrapper = new JPanel(new BorderLayout());
wrapper.add(new JLabel("To be started on project opening:"), BorderLayout.WEST);
wrapper.add(label, BorderLayout.EAST);
wrapper.setBorder(BorderFactory.createEmptyBorder(0, 0, UIUtil.DEFAULT_VGAP, 0));
final JPanel main = new JPanel(new BorderLayout());
main.add(wrapper, BorderLayout.NORTH);
main.add(tasksPanel, BorderLayout.CENTER);
return main;
}
use of com.intellij.openapi.project.DumbAwareAction in project intellij-community by JetBrains.
the class QuickEditHandler method showBalloon.
public static void showBalloon(Editor editor, PsiFile newFile, JComponent component) {
final Balloon balloon = JBPopupFactory.getInstance().createBalloonBuilder(component).setShadow(true).setAnimationCycle(0).setHideOnClickOutside(true).setHideOnKeyOutside(true).setHideOnAction(false).setFillColor(UIUtil.getControlColor()).createBalloon();
new DumbAwareAction() {
@Override
public void actionPerformed(AnActionEvent e) {
balloon.hide();
}
}.registerCustomShortcutSet(CommonShortcuts.ESCAPE, component);
Disposer.register(newFile.getProject(), balloon);
final Balloon.Position position = QuickEditAction.getBalloonPosition(editor);
RelativePoint point = JBPopupFactory.getInstance().guessBestPopupLocation(editor);
if (position == Balloon.Position.above) {
final Point p = point.getPoint();
point = new RelativePoint(point.getComponent(), new Point(p.x, p.y - editor.getLineHeight()));
}
balloon.show(point, position);
}
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 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);
}
Aggregations