Merge branch 'GP-2644_ghidra_LinkedFolders'

This commit is contained in:
ghidra1 2022-11-22 12:53:18 -05:00
commit f0a8af3e8b
153 changed files with 7083 additions and 1732 deletions

View file

@ -18,11 +18,13 @@ package ghidra.trace.database;
import java.io.IOException;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import db.DBHandle;
import db.buffers.BufferFile;
import db.buffers.ManagedBufferFile;
import ghidra.framework.data.*;
import ghidra.framework.data.DBWithUserDataContentHandler;
import ghidra.framework.data.DomainObjectMergeManager;
import ghidra.framework.model.ChangeSet;
import ghidra.framework.model.DomainObject;
import ghidra.framework.store.*;
@ -34,9 +36,16 @@ import ghidra.util.exception.CancelledException;
import ghidra.util.exception.VersionException;
import ghidra.util.task.TaskMonitor;
public class DBTraceContentHandler extends DBContentHandler {
public class DBTraceContentHandler extends DBWithUserDataContentHandler<DBTrace> {
public static final String TRACE_CONTENT_TYPE = "Trace";
public static ImageIcon TRACE_ICON = Trace.TRACE_ICON;
static final Class<DBTrace> TRACE_DOMAIN_OBJECT_CLASS = DBTrace.class;
static final String TRACE_CONTENT_DEFAULT_TOOL = "Debugger";
private static final DBTraceLinkContentHandler linkHandler = new DBTraceLinkContentHandler();
@Override
public long createFile(FileSystem fs, FileSystem userfs, String path, String name,
DomainObject obj, TaskMonitor monitor)
@ -48,7 +57,7 @@ public class DBTraceContentHandler extends DBContentHandler {
}
@Override
public DomainObjectAdapter getImmutableObject(FolderItem item, Object consumer, int version,
public DBTrace getImmutableObject(FolderItem item, Object consumer, int version,
int minChangeVersion, TaskMonitor monitor)
throws IOException, CancelledException, VersionException {
String contentType = item.getContentType();
@ -96,7 +105,7 @@ public class DBTraceContentHandler extends DBContentHandler {
}
@Override
public DomainObjectAdapter getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade,
public DBTrace getReadOnlyObject(FolderItem item, int version, boolean okToUpgrade,
Object consumer, TaskMonitor monitor)
throws IOException, VersionException, CancelledException {
String contentType = item.getContentType();
@ -146,7 +155,7 @@ public class DBTraceContentHandler extends DBContentHandler {
}
@Override
public DomainObjectAdapter getDomainObject(FolderItem item, FileSystem userfs, long checkoutId,
public DBTrace getDomainObject(FolderItem item, FileSystem userfs, long checkoutId,
boolean okToUpgrade, boolean recover, Object consumer, TaskMonitor monitor)
throws IOException, CancelledException, VersionException {
String contentType = item.getContentType();
@ -296,8 +305,8 @@ public class DBTraceContentHandler extends DBContentHandler {
}
@Override
public Class<? extends DomainObject> getDomainObjectClass() {
return DBTrace.class;
public Class<DBTrace> getDomainObjectClass() {
return TRACE_DOMAIN_OBJECT_CLASS;
}
@Override
@ -312,12 +321,12 @@ public class DBTraceContentHandler extends DBContentHandler {
@Override
public String getDefaultToolName() {
return "Debugger";
return TRACE_CONTENT_DEFAULT_TOOL;
}
@Override
public Icon getIcon() {
return Trace.TRACE_ICON;
return TRACE_ICON;
}
@Override
@ -331,4 +340,9 @@ public class DBTraceContentHandler extends DBContentHandler {
// TODO:
return null;
}
@Override
public DBTraceLinkContentHandler getLinkHandler() {
return linkHandler;
}
}

View file

@ -0,0 +1,71 @@
/* ###
* IP: GHIDRA
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ghidra.trace.database;
import java.io.IOException;
import javax.swing.Icon;
import ghidra.framework.data.LinkHandler;
import ghidra.framework.data.URLLinkObject;
import ghidra.framework.model.DomainObject;
import ghidra.framework.store.FileSystem;
import ghidra.util.InvalidNameException;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
public class DBTraceLinkContentHandler extends LinkHandler<DBTrace> {
public static final String TRACE_LINK_CONTENT_TYPE = "TraceLink";
@Override
public long createFile(FileSystem fs, FileSystem userfs, String path, String name,
DomainObject obj, TaskMonitor monitor)
throws IOException, InvalidNameException, CancelledException {
if (!(obj instanceof URLLinkObject)) {
throw new IOException("Unsupported domain object: " + obj.getClass().getName());
}
return createFile((URLLinkObject) obj, TRACE_LINK_CONTENT_TYPE, fs, path, name,
monitor);
}
@Override
public String getContentType() {
return TRACE_LINK_CONTENT_TYPE;
}
@Override
public String getContentTypeDisplayString() {
return TRACE_LINK_CONTENT_TYPE;
}
@Override
public Class<DBTrace> getDomainObjectClass() {
// return linked content class
return DBTraceContentHandler.TRACE_DOMAIN_OBJECT_CLASS;
}
@Override
public Icon getIcon() {
return DBTraceContentHandler.TRACE_ICON;
}
@Override
public String getDefaultToolName() {
return DBTraceContentHandler.TRACE_CONTENT_DEFAULT_TOOL;
}
}