MCPcopy
hub / github.com/Col-E/Recaf / ofFile

Method ofFile

src/main/java/me/coley/recaf/ui/ContextBuilder.java:606–642  ·  view source on GitHub ↗

@param name File name. @return Context menu for files.

(String name)

Source from the content-addressed store, hash-verified

604 * @return Context menu for files.
605 */
606 public ContextMenu ofFile(String name) {
607 // Create the menu
608 MenuItem header = new MenuItem(shorten(name));
609 header.getStyleClass().add("context-menu-header");
610 header.setGraphic(UiUtil.createFileGraphic(name));
611 header.setDisable(true);
612 ContextMenu menu = new ContextMenu();
613 menu.getItems().add(header);
614 // Add workspace-navigator specific items, but only for primary files
615 if (isWorkspaceTree() && isPrimaryFile(name)) {
616 MenuItem rename = new ActionMenuItem(LangUtil.translate("misc.rename"), () -> {
617 Window main = controller.windows().getMainWindow().getStage();
618 RenamingTextField popup = RenamingTextField.forFile(controller, name);
619 popup.show(main);
620 });
621 MenuItem remove = new ActionMenuItem(LangUtil.translate("misc.remove"), () -> {
622 YesNoWindow.prompt(LangUtil.translate("misc.confirm.message"), () -> {
623 controller.getWorkspace().getPrimary().getFiles().remove(name);
624 controller.windows().getMainWindow().getTabs().closeTab(name);
625 }, null).show(treeView);
626 });
627 menu.getItems().addAll(
628 rename,
629 remove,
630 new SeparatorMenuItem(),
631 new ActionMenuItem(translate("ui.edit.copypath"), () -> {
632 ClipboardContent content = new ClipboardContent();
633 content.putString(name);
634 Clipboard.getSystemClipboard().setContent(content);
635 })
636 );
637
638 }
639 // Inject plugin menus
640 plugins.ofType(ContextMenuInjectorPlugin.class).forEach(injector -> injector.forFile(this, menu, name));
641 return menu;
642 }
643
644 /**
645 * @param resource

Callers 1

JavaResourceCellClass · 0.80

Calls 15

shortenMethod · 0.95
createFileGraphicMethod · 0.95
isWorkspaceTreeMethod · 0.95
isPrimaryFileMethod · 0.95
translateMethod · 0.95
forFileMethod · 0.95
promptMethod · 0.95
getStageMethod · 0.80
getMainWindowMethod · 0.80
windowsMethod · 0.80
removeMethod · 0.80
getPrimaryMethod · 0.80

Tested by

no test coverage detected