use of java.awt.event.MouseAdapter 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.MouseAdapter 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;
}
use of java.awt.event.MouseAdapter in project jadx by skylot.
the class MainWindow method initUI.
private void initUI() {
mainPanel = new JPanel(new BorderLayout());
JSplitPane splitPane = new JSplitPane();
splitPane.setResizeWeight(SPLIT_PANE_RESIZE_WEIGHT);
mainPanel.add(splitPane);
DefaultMutableTreeNode treeRoot = new DefaultMutableTreeNode(NLS.str("msg.open_file"));
treeModel = new DefaultTreeModel(treeRoot);
tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
treeClickAction();
}
});
tree.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
treeClickAction();
}
}
});
tree.setCellRenderer(new DefaultTreeCellRenderer() {
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean isLeaf, int row, boolean focused) {
Component c = super.getTreeCellRendererComponent(tree, value, selected, expanded, isLeaf, row, focused);
if (value instanceof JNode) {
setIcon(((JNode) value).getIcon());
}
return c;
}
});
tree.addTreeWillExpandListener(new TreeWillExpandListener() {
@Override
public void treeWillExpand(TreeExpansionEvent event) throws ExpandVetoException {
TreePath path = event.getPath();
Object node = path.getLastPathComponent();
if (node instanceof JClass) {
JClass cls = (JClass) node;
cls.getRootClass().load();
}
}
@Override
public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
}
});
progressPane = new ProgressPanel(this, true);
JPanel leftPane = new JPanel(new BorderLayout());
leftPane.add(new JScrollPane(tree), BorderLayout.CENTER);
leftPane.add(progressPane, BorderLayout.PAGE_END);
splitPane.setLeftComponent(leftPane);
tabbedPane = new TabbedPane(this);
splitPane.setRightComponent(tabbedPane);
dropTarget = new DropTarget(this, DnDConstants.ACTION_COPY, new MainDropTarget(this));
setContentPane(mainPanel);
setTitle(DEFAULT_TITLE);
}
use of java.awt.event.MouseAdapter in project jadx by skylot.
the class TabbedPane method makeTabComponent.
private Component makeTabComponent(final ContentPanel contentPanel) {
JNode node = contentPanel.getNode();
String name = node.makeLongString();
final JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 3, 0));
panel.setOpaque(false);
final JLabel label = new JLabel(name);
label.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
label.setIcon(node.getIcon());
final JButton button = new JButton();
button.setIcon(ICON_CLOSE_INACTIVE);
button.setRolloverIcon(ICON_CLOSE);
button.setRolloverEnabled(true);
button.setOpaque(false);
button.setUI(new BasicButtonUI());
button.setContentAreaFilled(false);
button.setFocusable(false);
button.setBorder(null);
button.setBorderPainted(false);
button.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
closeCodePanel(contentPanel);
}
});
panel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isMiddleMouseButton(e)) {
closeCodePanel(contentPanel);
} else if (SwingUtilities.isRightMouseButton(e)) {
JPopupMenu menu = createTabPopupMenu(contentPanel);
menu.show(panel, e.getX(), e.getY());
} else {
// TODO: make correct event delegation to tabbed pane
setSelectedComponent(contentPanel);
}
}
});
panel.add(label);
panel.add(button);
panel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
return panel;
}
use of java.awt.event.MouseAdapter in project jadx by skylot.
the class JadxSettingsWindow method makeEditorGroup.
private SettingsGroup makeEditorGroup() {
JButton fontBtn = new JButton(NLS.str("preferences.select_font"));
fontBtn.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
JFontChooser fontChooser = new JFontChooser();
fontChooser.setSelectedFont(settings.getFont());
int result = fontChooser.showDialog(JadxSettingsWindow.this);
if (result == JFontChooser.OK_OPTION) {
Font font = fontChooser.getSelectedFont();
LOG.info("Selected Font : {}", font);
settings.setFont(font);
mainWindow.updateFont(font);
}
}
});
SettingsGroup other = new SettingsGroup(NLS.str("preferences.editor"));
other.addRow(NLS.str("preferences.font"), fontBtn);
return other;
}
Aggregations