use of com.intellij.openapi.actionSystem.CustomShortcutSet in project intellij-community by JetBrains.
the class UsageGroupingRuleProviderImpl method createGroupByFileStructureAction.
public static GroupByFileStructureAction createGroupByFileStructureAction(UsageViewImpl impl) {
final JComponent component = impl.getComponent();
final GroupByFileStructureAction groupByFileStructureAction = new GroupByFileStructureAction(impl);
groupByFileStructureAction.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK)), component, impl);
return groupByFileStructureAction;
}
use of com.intellij.openapi.actionSystem.CustomShortcutSet in project intellij-community by JetBrains.
the class CvsConfigurationsListEditor method createListPanel.
private JComponent createListPanel() {
final AnActionButton duplicateButton = new DumbAwareActionButton(CvsBundle.message("action.name.copy"), PlatformIcons.COPY_ICON) {
@Override
public void updateButton(AnActionEvent e) {
e.getPresentation().setEnabled(getSelectedConfiguration() != null);
}
@Override
public void actionPerformed(AnActionEvent e) {
copySelectedConfiguration();
}
};
duplicateButton.setShortcut(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_D, SystemInfo.isMac ? KeyEvent.META_MASK : KeyEvent.CTRL_MASK)));
final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myList).setAddAction(new AnActionButtonRunnable() {
@Override
public void run(AnActionButton anActionButton) {
createNewConfiguration();
}
}).addExtraAction(duplicateButton);
return decorator.createPanel();
}
use of com.intellij.openapi.actionSystem.CustomShortcutSet in project intellij-community by JetBrains.
the class GitSkippedCommits method addActionsTo.
@Override
protected void addActionsTo(DefaultActionGroup group) {
super.addActionsTo(group);
ShowAllAffectedGenericAction showCommit = ShowAllAffectedGenericAction.getInstance();
showCommit.registerCustomShortcutSet(new CustomShortcutSet(CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myTree);
group.addAction(showCommit);
}
use of com.intellij.openapi.actionSystem.CustomShortcutSet 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.CustomShortcutSet in project intellij-community by JetBrains.
the class CreateTestDialog method createCenterPanel.
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new GridBagLayout());
GridBagConstraints constr = new GridBagConstraints();
constr.fill = GridBagConstraints.HORIZONTAL;
constr.anchor = GridBagConstraints.WEST;
int gridy = 1;
constr.insets = insets(4);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
final JLabel libLabel = new JLabel(CodeInsightBundle.message("intention.create.test.dialog.testing.library"));
libLabel.setLabelFor(myLibrariesCombo);
panel.add(libLabel, constr);
constr.gridx = 1;
constr.weightx = 1;
constr.gridwidth = GridBagConstraints.REMAINDER;
panel.add(myLibrariesCombo, constr);
myFixLibraryPanel = new JPanel(new BorderLayout());
myFixLibraryLabel = new JLabel();
myFixLibraryLabel.setIcon(AllIcons.Actions.IntentionBulb);
myFixLibraryPanel.add(myFixLibraryLabel, BorderLayout.CENTER);
myFixLibraryPanel.add(myFixLibraryButton, BorderLayout.EAST);
constr.insets = insets(1);
constr.gridy = gridy++;
constr.gridx = 0;
panel.add(myFixLibraryPanel, constr);
constr.gridheight = 1;
constr.insets = insets(6);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
constr.gridwidth = 1;
panel.add(new JLabel(CodeInsightBundle.message("intention.create.test.dialog.class.name")), constr);
myTargetClassNameField = new EditorTextField(suggestTestClassName(myTargetClass));
myTargetClassNameField.getDocument().addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent e) {
getOKAction().setEnabled(PsiNameHelper.getInstance(myProject).isIdentifier(getClassName()));
}
});
constr.gridx = 1;
constr.weightx = 1;
panel.add(myTargetClassNameField, constr);
constr.insets = insets(1);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
panel.add(new JLabel(CodeInsightBundle.message("intention.create.test.dialog.super.class")), constr);
mySuperClassField = new ReferenceEditorComboWithBrowseButton(new MyChooseSuperClassAction(), null, myProject, true, JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE, RECENT_SUPERS_KEY);
mySuperClassField.setMinimumSize(mySuperClassField.getPreferredSize());
constr.gridx = 1;
constr.weightx = 1;
panel.add(mySuperClassField, constr);
constr.insets = insets(1);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
panel.add(new JLabel(CodeInsightBundle.message("dialog.create.class.destination.package.label")), constr);
constr.gridx = 1;
constr.weightx = 1;
String targetPackageName = myTargetPackage != null ? myTargetPackage.getQualifiedName() : "";
myTargetPackageField = new PackageNameReferenceEditorCombo(targetPackageName, myProject, RECENTS_KEY, CodeInsightBundle.message("dialog.create.class.package.chooser.title"));
new AnAction() {
public void actionPerformed(AnActionEvent e) {
myTargetPackageField.getButton().doClick();
}
}.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.SHIFT_DOWN_MASK)), myTargetPackageField.getChildComponent());
JPanel targetPackagePanel = new JPanel(new BorderLayout());
targetPackagePanel.add(myTargetPackageField, BorderLayout.CENTER);
panel.add(targetPackagePanel, constr);
constr.insets = insets(6);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
panel.add(new JLabel(CodeInsightBundle.message("intention.create.test.dialog.generate")), constr);
constr.gridx = 1;
constr.weightx = 1;
panel.add(myGenerateBeforeBox, constr);
constr.insets = insets(1);
constr.gridy = gridy++;
panel.add(myGenerateAfterBox, constr);
constr.insets = insets(6);
constr.gridy = gridy++;
constr.gridx = 0;
constr.weightx = 0;
final JLabel membersLabel = new JLabel(CodeInsightBundle.message("intention.create.test.dialog.select.methods"));
membersLabel.setLabelFor(myMethodsTable);
panel.add(membersLabel, constr);
constr.gridx = 1;
constr.weightx = 1;
panel.add(myShowInheritedMethodsBox, constr);
constr.insets = insets(1, 8);
constr.gridy = gridy++;
constr.gridx = 0;
constr.gridwidth = GridBagConstraints.REMAINDER;
constr.fill = GridBagConstraints.BOTH;
constr.weighty = 1;
panel.add(ScrollPaneFactory.createScrollPane(myMethodsTable), constr);
myLibrariesCombo.setRenderer(new ListCellRendererWrapper<TestFramework>() {
@Override
public void customize(JList list, TestFramework value, int index, boolean selected, boolean hasFocus) {
if (value != null) {
setText(value.getName());
setIcon(value.getIcon());
}
}
});
final boolean hasTestRoots = !ModuleRootManager.getInstance(myTargetModule).getSourceRoots(JavaModuleSourceRootTypes.TESTS).isEmpty();
final List<TestFramework> attachedLibraries = new ArrayList<>();
final String defaultLibrary = getDefaultLibraryName();
TestFramework defaultDescriptor = null;
final DefaultComboBoxModel model = (DefaultComboBoxModel) myLibrariesCombo.getModel();
final List<TestFramework> descriptors = new ArrayList<>();
descriptors.addAll(Arrays.asList(Extensions.getExtensions(TestFramework.EXTENSION_NAME)));
descriptors.sort((d1, d2) -> Comparing.compare(d1.getName(), d2.getName()));
for (final TestFramework descriptor : descriptors) {
model.addElement(descriptor);
if (hasTestRoots && descriptor.isLibraryAttached(myTargetModule)) {
attachedLibraries.add(descriptor);
if (defaultLibrary == null) {
defaultDescriptor = descriptor;
}
}
if (Comparing.equal(defaultLibrary, descriptor.getName())) {
defaultDescriptor = descriptor;
}
}
myLibrariesCombo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final Object selectedItem = myLibrariesCombo.getSelectedItem();
if (selectedItem != null) {
final DumbService dumbService = DumbService.getInstance(myProject);
dumbService.setAlternativeResolveEnabled(true);
try {
onLibrarySelected((TestFramework) selectedItem);
} finally {
dumbService.setAlternativeResolveEnabled(false);
}
}
}
});
if (defaultDescriptor != null && (attachedLibraries.contains(defaultDescriptor) || attachedLibraries.isEmpty())) {
myLibrariesCombo.setSelectedItem(defaultDescriptor);
} else {
myLibrariesCombo.setSelectedIndex(0);
}
myFixLibraryButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (mySelectedFramework instanceof JavaTestFramework) {
((JavaTestFramework) mySelectedFramework).setupLibrary(myTargetModule);
} else {
OrderEntryFix.addJarToRoots(mySelectedFramework.getLibraryPath(), myTargetModule, null);
}
myFixLibraryPanel.setVisible(false);
}
});
myShowInheritedMethodsBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
updateMethodsTable();
}
});
restoreShowInheritedMembersStatus();
updateMethodsTable();
return panel;
}
Aggregations