GP-4085 Added ability to add VTSession to a shared repository

This commit is contained in:
ghidra1 2023-12-07 13:31:56 -05:00
parent b8f004c792
commit c3386b72a2
33 changed files with 1063 additions and 565 deletions

View file

@ -60,7 +60,7 @@ public class DomainFileProxy implements DomainFile {
}
DomainFileProxy(String name, String parentPath, DomainObjectAdapter doa, int version,
String fileID, ProjectLocator projectLocation) {
String fileID, ProjectLocator projectLocation) throws IOException {
this(name, doa);
this.parentPath = parentPath;

View file

@ -94,7 +94,6 @@ public abstract class DomainObjectAdapter implements DomainObject {
consumers = new ArrayList<Object>();
consumers.add(consumer);
if (!UserData.class.isAssignableFrom(getClass())) {
// UserData instances do not utilize DomainFile storage
domainFile = new DomainFileProxy(name, this);
}
}
@ -185,7 +184,12 @@ public abstract class DomainObjectAdapter implements DomainObject {
return temporary;
}
protected void setDomainFile(DomainFile df) {
/**
* Set the {@link DomainFile} associated with this instance.
* @param df domain file
* @throws DomainObjectException if a severe failure occurs during the operation.
*/
protected void setDomainFile(DomainFile df) throws DomainObjectException {
if (df == null) {
throw new IllegalArgumentException("DomainFile must not be null");
}
@ -197,7 +201,6 @@ public abstract class DomainObjectAdapter implements DomainObject {
domainFile = df;
fireEvent(new DomainObjectChangeRecord(DomainObjectEvent.FILE_CHANGED, oldDf, df));
fileChangeListeners.invoke().domainFileChanged(this);
}
protected void close() {

View file

@ -528,6 +528,9 @@ public class GhidraFileData {
projectData.clearDomainObject(getPathname());
// generate IOException
Throwable cause = e.getCause();
if (cause == null) {
cause = e;
}
if (cause instanceof IOException) {
throw (IOException) cause;
}
@ -831,9 +834,12 @@ public class GhidraFileData {
}
/**
* Returns whether the object is read-only. From a framework point of view a read-only object
* can never be changed.
* @return true if read-only
* Returns whether this file is explicitly marked as read-only. This method is only supported
* by the local file system and does not apply to a versioned file that is not checked-out.
* A versioned file that is not checked-out will always return false, while a
* {@link DomainFileProxy} will always return true.
* From a framework point of view a read-only file can never be changed.
* @return true if this file is marked read-only
*/
boolean isReadOnly() {
synchronized (fileSystem) {

View file

@ -158,7 +158,6 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
toolFrame.addWindowListener(windowListener);
AppInfo.setFrontEndTool(this);
AppInfo.setActiveProject(getProject());
initFrontEndOptions();
}
@ -408,7 +407,6 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
configureToolAction.setEnabled(true);
setProject(project);
AppInfo.setActiveProject(project);
plugin.setActiveProject(project);
firePluginEvent(new ProjectPluginEvent(getClass().getSimpleName(), project));
}
@ -616,7 +614,6 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
// Treat setVisible(false) as a dispose, as this is the only time we should be hidden
AppInfo.setFrontEndTool(null);
AppInfo.setActiveProject(null);
dispose();
}
}
@ -645,9 +642,8 @@ public class FrontEndTool extends PluginTool implements OptionsChangeListener {
return isConfigurable();
}
};
MenuData menuData =
new MenuData(new String[] { ToolConstants.MENU_FILE, "Install Extensions" }, null,
CONFIGURE_GROUP);
MenuData menuData = new MenuData(
new String[] { ToolConstants.MENU_FILE, "Install Extensions" }, null, CONFIGURE_GROUP);
menuData.setMenuSubGroup(CONFIGURE_GROUP + 2);
installExtensionsAction.setMenuBarData(menuData);

View file

@ -331,9 +331,12 @@ public interface DomainFile extends Comparable<DomainFile> {
public void setReadOnly(boolean state) throws IOException;
/**
* Returns whether the object is read-only. From a framework point of view a read-only object
* can never be changed.
* @return true if read-only
* Returns whether this file is explicitly marked as read-only. This method is only supported
* by the local file system and does not apply to a versioned file that is not checked-out.
* A versioned file that is not checked-out will always return false, while a
* {@link DomainFileProxy} will always return true.
* From a framework point of view a read-only file can never be changed.
* @return true if this file is marked read-only
*/
public boolean isReadOnly();

View file

@ -27,6 +27,7 @@ import org.jdom.output.XMLOutputter;
import ghidra.framework.client.RepositoryAdapter;
import ghidra.framework.data.DefaultProjectData;
import ghidra.framework.data.TransientDataManager;
import ghidra.framework.main.AppInfo;
import ghidra.framework.model.*;
import ghidra.framework.options.SaveState;
import ghidra.framework.project.tool.GhidraToolTemplate;
@ -291,16 +292,16 @@ public class DefaultProject implements Project {
throw new IOException("Invalid Ghidra URL specified: " + url);
}
ProjectData projectData = otherViewsMap.get(url);
if (projectData == null) {
projectData = openProjectView(url);
ProjectData viewedProjectData = otherViewsMap.get(url);
if (viewedProjectData == null) {
viewedProjectData = openProjectView(url);
}
if (projectData != null && visible && visibleViews.add(url)) {
if (viewedProjectData != null && visible && visibleViews.add(url)) {
notifyVisibleViewAdded(url);
}
return projectData;
return viewedProjectData;
}
}
@ -378,6 +379,11 @@ public class DefaultProject implements Project {
synchronized (otherViewsMap) {
isClosed = true;
// Clear active project if this is the current active project.
if (AppInfo.getActiveProject() == this) {
AppInfo.setActiveProject(null);
}
for (DefaultProjectData dataMgr : otherViewsMap.values()) {
if (dataMgr != null) {
dataMgr.close();

View file

@ -28,6 +28,7 @@ import ghidra.framework.GenericRunInfo;
import ghidra.framework.ToolUtils;
import ghidra.framework.client.*;
import ghidra.framework.data.TransientDataManager;
import ghidra.framework.main.AppInfo;
import ghidra.framework.model.*;
import ghidra.framework.preferences.Preferences;
import ghidra.framework.protocol.ghidra.GhidraURL;
@ -111,6 +112,8 @@ public class DefaultProjectManager implements ProjectManager {
lastOpenedProject = projectLocator;
updatePreferences();
}
AppInfo.setActiveProject(currentProject);
return currentProject;
}
@ -138,6 +141,7 @@ public class DefaultProjectManager implements ProjectManager {
try {
currentProject = new DefaultProject(this, projectLocator, resetOwner);
AppInfo.setActiveProject(currentProject);
if (doRestore) {
currentProject.restore();
}
@ -166,6 +170,7 @@ public class DefaultProjectManager implements ProjectManager {
}
}
}
AppInfo.setActiveProject(null);
return null;
}