void (MouseEvent e) { Point point = e.getPoint(); int index = list.locationToIndex(point); if (index != -1) { Rectangle cellBounds = list.getCellBounds(index, index); if (!cellBounds.contains(point) && (KeyEvent.CTRL_DOWN_MASK & e.getModifiersEx()) != KeyEvent.CTRL_DOWN_MASK) { index = -1; list.clearSelection(); } } if (index != -1) { if (MouseEvent.BUTTON1 == e.getButton() && e.getClickCount() == 2) { // Double click list.setSelectedIndex(index); VirtualFile selected = (VirtualFile) list.getSelectedValue(); if (selected != null) { if (selected.isDirectory()) { thumbnailView.setRoot(selected); } else { FileEditorManager fileEditorManager = FileEditorManager.getInstance(thumbnailView.getProject()); fileEditorManager.openFile(selected, true); } e.consume(); } } if (MouseEvent.BUTTON3 == e.getButton() && e.getClickCount() == 1) { // Ensure that we have selection if ((KeyEvent.CTRL_DOWN_MASK & e.getModifiersEx()) != KeyEvent.CTRL_DOWN_MASK) { // Ctrl is not pressed list.setSelectedIndex(index); } else { // Ctrl is pressed list.getSelectionModel().addSelectionInterval(index, index); } // Single right click ActionManager actionManager = ActionManager.getInstance(); ActionGroup actionGroup = (ActionGroup) actionManager.getAction(ThumbnailViewActions.GROUP_POPUP); ActionPopupMenu menu = actionManager.createActionPopupMenu(ThumbnailViewActions.ACTION_PLACE, actionGroup); JPopupMenu popupMenu = menu.getComponent(); popupMenu.pack(); JBPopupMenu.showByEvent(e, popupMenu); e.consume(); } } }