use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class PathEditor method createComponent.
public JComponent createComponent() {
myList = new JBList(getListModel());
myList.setCellRenderer(createListCellRenderer(myList));
TreeUIHelper.getInstance().installListSpeedSearch(myList, new Convertor<Object, String>() {
@Override
public String convert(Object file) {
return ((VirtualFile) file).getPresentableUrl();
}
});
ToolbarDecorator toolbarDecorator = ToolbarDecorator.createDecorator(myList).disableUpDownActions().setAddActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return myEnabled;
}
}).setRemoveActionUpdater(new AnActionButtonUpdater() {
@Override
public boolean isEnabled(AnActionEvent e) {
return isRemoveActionEnabled(PathEditor.this.getSelectedRoots());
}
}).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
final VirtualFile[] added = doAddItems();
if (added.length > 0) {
setModified(true);
}
requestDefaultFocus();
setSelectedRoots(added);
}
}).setRemoveAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton button) {
int[] indices = myList.getSelectedIndices();
doRemoveItems(indices, myList);
}
});
addToolbarButtons(toolbarDecorator);
myPanel = toolbarDecorator.createPanel();
myPanel.setBorder(null);
return myPanel;
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class UnifiedDiffChange method createIconRenderer.
@Nullable
private GutterIconRenderer createIconRenderer(@NotNull final Side sourceSide, @NotNull final String tooltipText, @NotNull final Icon icon) {
return new DiffGutterRenderer(icon, tooltipText) {
@Override
protected void performAction(AnActionEvent e) {
if (myViewer.isStateIsOutOfDate())
return;
if (!myViewer.isEditable(sourceSide.other(), true))
return;
final Project project = e.getProject();
final Document document = myViewer.getDocument(sourceSide.other());
DiffUtil.executeWriteCommand(document, project, "Replace change", () -> {
myViewer.replaceChange(UnifiedDiffChange.this, sourceSide);
myViewer.scheduleRediff();
});
// applyChange() will schedule rediff, but we want to try to do it in sync
// and we can't do it inside write action
myViewer.rediff();
}
};
}
use of com.intellij.openapi.actionSystem.AnActionEvent 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.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class ShowInstancesByClassAction method perform.
@Override
protected void perform(XValueNodeImpl node, @NotNull String nodeName, AnActionEvent e) {
final Project project = e.getProject();
if (project != null) {
final XDebugSession debugSession = XDebuggerManager.getInstance(project).getCurrentSession();
final ObjectReference ref = getObjectReference(node);
if (debugSession != null && ref != null) {
final ReferenceType referenceType = ref.referenceType();
new InstancesWindow(debugSession, l -> {
final List<ObjectReference> instances = referenceType.instances(l);
return instances == null ? Collections.emptyList() : instances;
}, referenceType.name()).show();
}
}
}
use of com.intellij.openapi.actionSystem.AnActionEvent in project intellij-community by JetBrains.
the class VcsPushDialog method createForcePushInfoLabel.
@NotNull
private JComponent createForcePushInfoLabel() {
JPanel text = new JPanel();
text.setLayout(new BoxLayout(text, BoxLayout.X_AXIS));
JLabel label = new JLabel("You can enable and configure Force Push in " + ShowSettingsUtil.getSettingsMenuName() + ".");
label.setEnabled(false);
label.setFont(JBUI.Fonts.smallFont());
text.add(label);
ActionLink here = new ActionLink("Configure", new AnAction() {
@Override
public void actionPerformed(AnActionEvent e) {
Project project = myController.getProject();
VcsPushDialog.this.doCancelAction(e.getInputEvent());
ShowSettingsUtilImpl.showSettingsDialog(project, "vcs.Git", "force push");
}
});
here.setFont(JBUI.Fonts.smallFont());
text.add(here);
return JBUI.Panels.simplePanel().addToRight(text).withBorder(JBUI.Borders.emptyBottom(4));
}
Aggregations