use of com.mucommander.ui.main.menu.TablePopupMenu in project mucommander by mucommander.
the class ShowFilePopupMenuAction method performAction.
@Override
public void performAction(FileSet files) {
FileTable table = mainFrame.getActiveTable();
int currentRow = table.getSelectedRow();
// Does the row correspond to the parent '..' folder ?
boolean parentFolderClicked = currentRow == 0 && table.getFileTableModel().hasParentFolder();
TablePopupMenu popupMenu = new TablePopupMenu(mainFrame, table.getFolderPanel().getCurrentFolder(), parentFolderClicked ? null : table.getSelectedFile(), parentFolderClicked, files);
// find coordinates of current row and show popup menu bellow it
Rectangle rect = table.getCellRect(currentRow, table.getSelectedColumn(), true);
popupMenu.show(table, 0, rect.y + rect.height);
}
use of com.mucommander.ui.main.menu.TablePopupMenu in project mucommander by mucommander.
the class ShowFilePopupMenuAction method performAction.
@Override
public void performAction() {
try {
AbstractFile selectedFile = mainFrame.getActiveTable().getSelectedFile();
FileTable fileTable = mainFrame.getActiveTable();
FileTableModel tableModel = (FileTableModel) fileTable.getModel();
int selectedRow = fileTable.getSelectedRow();
Rectangle rect = fileTable.getCellRect(selectedRow, fileTable.convertColumnIndexToView(Column.NAME.ordinal()), true);
boolean parentFolderSelected = selectedRow == 0 && tableModel.hasParentFolder();
new TablePopupMenu(mainFrame, fileTable.getFolderPanel().getCurrentFolder(), parentFolderSelected ? null : selectedFile, parentFolderSelected, tableModel.getMarkedFiles()).show(fileTable, rect.x + rect.width, rect.y);
} catch (Exception e) {
InformationDialog.showErrorDialog(mainFrame);
}
}
use of com.mucommander.ui.main.menu.TablePopupMenu in project mucommander by mucommander.
the class FileTable method mousePressed.
public void mousePressed(MouseEvent e) {
// Discard mouse events while in 'no events mode'
if (mainFrame.getNoEventsMode())
return;
if (e.getSource() != this)
return;
// Right-click brings a contextual popup menu
if (DesktopManager.isRightMouseButton(e)) {
// Find the row that was right-clicked
int x = e.getX();
int y = e.getY();
int clickedRow = rowAtPoint(new Point(x, y));
// Does the row correspond to the parent '..' folder ?
boolean parentFolderClicked = clickedRow == 0 && tableModel.hasParentFolder();
// Select clicked row if it is not selected already
if (currentRow != clickedRow)
selectRow(clickedRow);
// Request focus on this FileTable is focus is somewhere else
if (!hasFocus())
requestFocus();
// Popup menu where the user right-clicked
new TablePopupMenu(mainFrame, folderPanel.getCurrentFolder(), parentFolderClicked ? null : tableModel.getFileAtRow(clickedRow), parentFolderClicked, tableModel.getMarkedFiles()).show(this, x, y);
} else // Control left-click also works
if (DesktopManager.isMiddleMouseButton(e)) {
// Used by mouseDragged
lastDraggedRow = rowAtPoint(e.getPoint());
markOnRightClick = !tableModel.isRowMarked(lastDraggedRow);
setRowMarked(lastDraggedRow, markOnRightClick);
} else if (DesktopManager.isLeftMouseButton(e)) {
// Marks a group of rows, from last current row to clicked row (current row)
if (e.isShiftDown()) {
setRangeMarked(currentRow, lastRow, !tableModel.isRowMarked(currentRow));
} else // Marks the clicked row
if (e.isControlDown()) {
int rowNum = rowAtPoint(e.getPoint());
setRowMarked(rowNum, !tableModel.isRowMarked(rowNum));
}
}
}
Aggregations