mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-09-28 17:11:11 -09:00
GP-3627 Copy GhidraURL action revisions
This commit is contained in:
@@ -212,6 +212,27 @@
|
|||||||
<P><IMG src="help/shared/note.png" border="0">External links will never show a broken
|
<P><IMG src="help/shared/note.png" border="0">External links will never show a broken
|
||||||
link state since they are not evaluated for such conditions.</P>
|
link state since they are not evaluated for such conditions.</P>
|
||||||
|
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
|
<H4><A name="Copy_GhidraURL"></A>Copy Ghidra URL for File</H4>
|
||||||
|
|
||||||
|
<BLOCKQUOTE>
|
||||||
|
<P>The Ghidra URL of a selected project file, or file-link, may be copied in text form
|
||||||
|
into the Copy/Paste Clipboard for use in other places where a URL may be pasted
|
||||||
|
(e.g., Listing comment annotations, external applications, etc.).
|
||||||
|
This may be done for a file in the active project or a viewed project/repository.
|
||||||
|
A shared Ghidra project URL will be produced when possible, otherwise a local
|
||||||
|
project URL will be produced.</P>
|
||||||
|
|
||||||
|
<OL>
|
||||||
|
<LI>
|
||||||
|
Select a single file or file-link from the active project tree or viewed
|
||||||
|
project/repository tree.
|
||||||
|
</LI>
|
||||||
|
|
||||||
|
<LI>Right mouse click and choose the <I>Copy GhidraURL</I> option.
|
||||||
|
The URL text is now available in the clipboard for a subsequent text Paste operation.</LI>
|
||||||
|
</OL>
|
||||||
</BLOCKQUOTE>
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
<H4><A name="Cut"></A>Move Folders and Files</H4>
|
<H4><A name="Cut"></A>Move Folders and Files</H4>
|
||||||
@@ -239,7 +260,7 @@
|
|||||||
file that is in use or a folder that contains a file that is in use.</P>
|
file that is in use or a folder that contains a file that is in use.</P>
|
||||||
</BLOCKQUOTE>
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
<H4>Drag/Drop for Copy</H4>
|
<H4>Drag/Drop for File or Folder Copy</H4>
|
||||||
|
|
||||||
<BLOCKQUOTE>
|
<BLOCKQUOTE>
|
||||||
<P>You can get the same effect of Copy/Paste using Drag and Drop.</P>
|
<P>You can get the same effect of Copy/Paste using Drag and Drop.</P>
|
||||||
@@ -247,7 +268,7 @@
|
|||||||
<OL>
|
<OL>
|
||||||
<LI>Select a folder or file (or multiple folders and files).</LI>
|
<LI>Select a folder or file (or multiple folders and files).</LI>
|
||||||
|
|
||||||
<LI>Hold the Ctrl key down and drag the object to another folder.</LI>
|
<LI><B>Hold the Ctrl key down and drag</B> the object to another folder.</LI>
|
||||||
|
|
||||||
<LI>Drop the object on a folder.</LI>
|
<LI>Drop the object on a folder.</LI>
|
||||||
</OL>
|
</OL>
|
||||||
@@ -261,7 +282,7 @@
|
|||||||
regardless of whether you hold down the Ctrl key.</P>
|
regardless of whether you hold down the Ctrl key.</P>
|
||||||
</BLOCKQUOTE>
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
<H4>Drag/Drop for Move</H4>
|
<H4>Drag/Drop for File or Folder Move</H4>
|
||||||
|
|
||||||
<BLOCKQUOTE>
|
<BLOCKQUOTE>
|
||||||
<P>You can get the same effect of Cut/Paste using Drag and Drop.</P>
|
<P>You can get the same effect of Cut/Paste using Drag and Drop.</P>
|
||||||
|
|||||||
@@ -238,10 +238,12 @@ public class FrontEndPlugin extends Plugin
|
|||||||
newFolderAction = new FrontEndProjectDataNewFolderAction(owner, groupName);
|
newFolderAction = new FrontEndProjectDataNewFolderAction(owner, groupName);
|
||||||
|
|
||||||
groupName = "Cut/copy/paste/new2";
|
groupName = "Cut/copy/paste/new2";
|
||||||
|
copyGhidraURLAction = new ProjectDataCopyGhidraURLAction(owner, groupName);
|
||||||
|
|
||||||
|
groupName = "Cut/copy/paste/new3";
|
||||||
cutAction = new ProjectDataCutAction(owner, groupName);
|
cutAction = new ProjectDataCutAction(owner, groupName);
|
||||||
clearCutAction = new ClearCutAction(owner);
|
clearCutAction = new ClearCutAction(owner);
|
||||||
copyAction = new ProjectDataCopyAction(owner, groupName);
|
copyAction = new ProjectDataCopyAction(owner, groupName);
|
||||||
copyGhidraURLAction = new ProjectDataCopyGhidraURLAction(owner, groupName);
|
|
||||||
pasteAction = new ProjectDataPasteAction(owner, groupName);
|
pasteAction = new ProjectDataPasteAction(owner, groupName);
|
||||||
pasteLinkAction = new ProjectDataPasteLinkAction(owner, groupName, false);
|
pasteLinkAction = new ProjectDataPasteLinkAction(owner, groupName, false);
|
||||||
pasteRelativeLinkAction = new ProjectDataPasteLinkAction(owner, groupName, true);
|
pasteRelativeLinkAction = new ProjectDataPasteLinkAction(owner, groupName, true);
|
||||||
|
|||||||
@@ -19,16 +19,13 @@ import java.awt.datatransfer.Clipboard;
|
|||||||
import java.awt.datatransfer.StringSelection;
|
import java.awt.datatransfer.StringSelection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import javax.swing.Icon;
|
|
||||||
|
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
|
||||||
import docking.action.MenuData;
|
import docking.action.MenuData;
|
||||||
import docking.dnd.GClipboard;
|
import docking.dnd.GClipboard;
|
||||||
import generic.theme.GIcon;
|
|
||||||
import ghidra.framework.main.AppInfo;
|
|
||||||
import ghidra.framework.main.datatree.FrontEndProjectTreeContext;
|
import ghidra.framework.main.datatree.FrontEndProjectTreeContext;
|
||||||
import ghidra.framework.model.Project;
|
import ghidra.framework.model.DomainFile;
|
||||||
|
import ghidra.framework.model.LinkFileInfo;
|
||||||
import ghidra.util.HelpLocation;
|
import ghidra.util.HelpLocation;
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
|
|
||||||
@@ -45,21 +42,25 @@ public class ProjectDataCopyGhidraURLAction extends ProjectDataCopyCutBaseAction
|
|||||||
Clipboard clipboard = GClipboard.getSystemClipboard();
|
Clipboard clipboard = GClipboard.getSystemClipboard();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
URL url = null;
|
|
||||||
if(CollectionUtils.isNotEmpty(context.getSelectedFiles())) {
|
if(CollectionUtils.isNotEmpty(context.getSelectedFiles())) {
|
||||||
url = context.getSelectedFiles().getFirst().getSharedProjectURL(null);
|
DomainFile df = context.getSelectedFiles().getFirst();
|
||||||
|
LinkFileInfo linkInfo = df.getLinkInfo();
|
||||||
|
if (linkInfo != null && linkInfo.isFolderLink()) {
|
||||||
|
return; // folder-link not supported
|
||||||
|
}
|
||||||
|
URL url = df.getSharedProjectURL(null);
|
||||||
if(url == null) {
|
if(url == null) {
|
||||||
url = context.getSelectedFiles().getFirst().getLocalProjectURL(null);
|
url = df.getLocalProjectURL(null);
|
||||||
|
}
|
||||||
|
if (url != null) {
|
||||||
|
clipboard.setContents(new StringSelection(url.toString()), null);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Msg.showError(ProjectDataCopyGhidraURLAction.class, null,
|
||||||
|
"Copy GhidraURL Failed",
|
||||||
|
"Failed to create file URL for: " + df.getPathname());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
url = context.getSelectedFolders().getFirst().getSharedProjectURL();
|
|
||||||
if(url == null) {
|
|
||||||
url = context.getSelectedFolders().getFirst().getLocalProjectURL();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
clipboard.setContents(new StringSelection(url.toString()), null);
|
|
||||||
}
|
}
|
||||||
catch (IllegalStateException ise) {
|
catch (IllegalStateException ise) {
|
||||||
// this can happen when other applications are accessing the system clipboard
|
// this can happen when other applications are accessing the system clipboard
|
||||||
@@ -71,12 +72,12 @@ public class ProjectDataCopyGhidraURLAction extends ProjectDataCopyCutBaseAction
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isEnabledForContext(FrontEndProjectTreeContext context) {
|
protected boolean isEnabledForContext(FrontEndProjectTreeContext context) {
|
||||||
if (!context.hasExactlyOneFileOrFolder()) {
|
if (context.hasExactlyOneFileOrFolder() && context.getFileCount() != 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
DomainFile df = context.getSelectedFiles().getFirst();
|
||||||
Project activeProject = AppInfo.getActiveProject();
|
LinkFileInfo linkInfo = df.getLinkInfo();
|
||||||
if (activeProject == null) {
|
if (linkInfo != null && linkInfo.isFolderLink()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user