use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class BaseRunConfigurationAction method actionPerformed.
@Override
public void actionPerformed(final AnActionEvent e) {
final DataContext dataContext = e.getDataContext();
final ConfigurationContext context = ConfigurationContext.getFromContext(dataContext);
final RunnerAndConfigurationSettings existing = context.findExisting();
if (existing == null) {
final List<ConfigurationFromContext> producers = getConfigurationsFromContext(context);
if (producers.isEmpty())
return;
if (producers.size() > 1) {
final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
Collections.sort(producers, ConfigurationFromContext.NAME_COMPARATOR);
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationFromContext>(ExecutionBundle.message("configuration.action.chooser.title"), producers) {
@Override
@NotNull
public String getTextFor(final ConfigurationFromContext producer) {
return childActionName(producer.getConfigurationType(), producer.getConfiguration());
}
@Override
public Icon getIconFor(final ConfigurationFromContext producer) {
return producer.getConfigurationType().getIcon();
}
@Override
public PopupStep onChosen(final ConfigurationFromContext producer, final boolean finalChoice) {
perform(producer, context);
return FINAL_CHOICE;
}
});
final InputEvent event = e.getInputEvent();
if (event instanceof MouseEvent) {
popup.show(new RelativePoint((MouseEvent) event));
} else if (editor != null) {
popup.showInBestPositionFor(editor);
} else {
popup.showInBestPositionFor(dataContext);
}
} else {
perform(producers.get(0), context);
}
return;
}
perform(context);
}
use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class NavBarPanel method installActions.
public void installActions(final int index, final NavBarItem component) {
//suppress it for a while
//installDnD(index, component);
ListenerUtil.addMouseListener(component, new MouseAdapter() {
@Override
public void mouseReleased(final MouseEvent e) {
if (SystemInfo.isWindows) {
click(e);
}
}
@Override
public void mousePressed(final MouseEvent e) {
if (!SystemInfo.isWindows) {
click(e);
}
}
private void click(final MouseEvent e) {
if (e.isConsumed())
return;
if (e.isPopupTrigger()) {
myModel.setSelectedIndex(index);
IdeFocusManager.getInstance(myProject).requestFocus(NavBarPanel.this, true);
rightClick(index);
e.consume();
} else if (!e.isPopupTrigger()) {
if (e.getClickCount() == 1) {
ctrlClick(index);
myModel.setSelectedIndex(index);
e.consume();
} else if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) {
myModel.setSelectedIndex(index);
IdeFocusManager.getInstance(myProject).requestFocus(NavBarPanel.this, true);
doubleClick(index);
e.consume();
}
}
}
});
}
use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class MacrosDialog method addListeners.
private void addListeners() {
myMacrosList.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(ListSelectionEvent e) {
Macro macro = getSelectedMacro();
if (macro == null) {
myPreviewTextarea.setText("");
setOKActionEnabled(false);
} else {
myPreviewTextarea.setText(macro.preview());
setOKActionEnabled(true);
}
}
});
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(MouseEvent e) {
if (getSelectedMacro() != null) {
close(OK_EXIT_CODE);
return true;
}
return false;
}
}.installOn(myMacrosList);
}
use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class OptionTreeWithPreviewPanel method createOptionsTree.
protected JTree createOptionsTree() {
DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode();
String groupName = "";
DefaultMutableTreeNode groupNode = null;
List<BooleanOptionKey> result = sortOptions(orderByGroup(myKeys));
for (BooleanOptionKey key : result) {
String newGroupName = key.groupName;
if (!newGroupName.equals(groupName) || groupNode == null) {
groupName = newGroupName;
groupNode = new DefaultMutableTreeNode(newGroupName);
rootNode.add(groupNode);
}
if (isOptionVisible(key)) {
groupNode.add(new MyToggleTreeNode(key, key.title));
}
}
DefaultTreeModel model = new DefaultTreeModel(rootNode);
final Tree optionsTree = new Tree(model);
new TreeSpeedSearch(optionsTree).setComparator(new SpeedSearchComparator(false));
TreeUtil.installActions(optionsTree);
optionsTree.setRootVisible(false);
UIUtil.setLineStyleAngled(optionsTree);
optionsTree.setShowsRootHandles(true);
optionsTree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (!optionsTree.isEnabled())
return;
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
TreePath treePath = optionsTree.getLeadSelectionPath();
selectCheckbox(treePath);
e.consume();
}
}
});
new ClickListener() {
@Override
public boolean onClick(@NotNull MouseEvent e, int clickCount) {
if (!optionsTree.isEnabled())
return false;
TreePath treePath = optionsTree.getPathForLocation(e.getX(), e.getY());
selectCheckbox(treePath);
return true;
}
}.installOn(optionsTree);
int row = 0;
while (row < optionsTree.getRowCount()) {
optionsTree.expandRow(row);
row++;
}
return optionsTree;
}
use of java.awt.event.MouseEvent in project intellij-community by JetBrains.
the class BaseExecuteBeforeRunDialog method createCenterPanel.
@Override
protected JComponent createCenterPanel() {
JPanel panel = new JPanel(new BorderLayout());
myRoot = buildNodes();
final Tree tree = new Tree(myRoot);
final MyTreeCellRenderer cellRenderer = new MyTreeCellRenderer();
tree.setCellRenderer(cellRenderer);
tree.setRootVisible(false);
tree.setShowsRootHandles(true);
tree.setLineStyleAngled();
TreeUtil.installActions(tree);
new TreeSpeedSearch(tree);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
int row = tree.getRowForLocation(e.getX(), e.getY());
if (row >= 0) {
Rectangle rowBounds = tree.getRowBounds(row);
cellRenderer.setBounds(rowBounds);
Rectangle checkBounds = cellRenderer.myCheckbox.getBounds();
checkBounds.setLocation(rowBounds.getLocation());
if (checkBounds.contains(e.getPoint())) {
toggleNode(tree, (DefaultMutableTreeNode) tree.getPathForRow(row).getLastPathComponent());
e.consume();
tree.setSelectionRow(row);
}
}
}
});
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) {
TreePath treePath = tree.getLeadSelectionPath();
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treePath.getLastPathComponent();
toggleNode(tree, node);
e.consume();
}
}
});
expacndChecked(tree);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(tree);
scrollPane.setPreferredSize(JBUI.size(400, 400));
panel.add(scrollPane, BorderLayout.CENTER);
return panel;
}
Aggregations