mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/patch'
Conflicts: Ghidra/application.properties
This commit is contained in:
commit
f2e702d1b2
3 changed files with 89 additions and 72 deletions
|
@ -33,7 +33,6 @@ import ghidra.framework.model.ToolServices;
|
|||
import ghidra.util.Msg;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import ghidra.util.classfinder.ClassSearcher;
|
||||
import ghidra.util.exception.AssertException;
|
||||
import ghidra.util.exception.CancelledException;
|
||||
import ghidra.util.xml.GenericXMLOutputter;
|
||||
import ghidra.util.xml.XmlUtilities;
|
||||
|
@ -52,7 +51,6 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
|
|||
/**
|
||||
* Creates a new application using the given properties filename. The
|
||||
* filename is expected reside in the current working directory.
|
||||
*
|
||||
* <p>
|
||||
* <b>The given properties file is expected to have the
|
||||
* {@link ApplicationProperties#APPLICATION_NAME_PROPERTY} and
|
||||
|
@ -60,43 +58,59 @@ public abstract class StandAloneApplication implements GenericStandAloneApplicat
|
|||
* set.</b>
|
||||
*
|
||||
* @param propertiesFilename the name of the properties file.
|
||||
* @throws IOException error causing application initialization failure
|
||||
*/
|
||||
public StandAloneApplication(String propertiesFilename) {
|
||||
|
||||
try {
|
||||
ApplicationProperties properties = ApplicationProperties.fromFile(propertiesFilename);
|
||||
String name = properties.getProperty(ApplicationProperties.APPLICATION_NAME_PROPERTY);
|
||||
if (name == null) {
|
||||
Msg.error(this,
|
||||
"The application.name property is not set in " + propertiesFilename);
|
||||
}
|
||||
|
||||
String version =
|
||||
properties.getProperty(ApplicationProperties.APPLICATION_VERSION_PROPERTY);
|
||||
if (version == null) {
|
||||
Msg.error(this,
|
||||
"The application.name property is not set in " + propertiesFilename);
|
||||
}
|
||||
|
||||
ApplicationLayout applicationLayout = new DockingApplicationLayout(properties);
|
||||
init(applicationLayout);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new AssertException(e);
|
||||
}
|
||||
public StandAloneApplication(String propertiesFilename) throws IOException {
|
||||
this(new DockingApplicationLayout(readApplicationProperties(propertiesFilename)));
|
||||
}
|
||||
|
||||
public StandAloneApplication(String name, String version) {
|
||||
/**
|
||||
* Creates a new application using the specified application name
|
||||
* and version.
|
||||
* @param name application name
|
||||
* @param version application version
|
||||
* @throws IOException error causing application initialization failure
|
||||
*/
|
||||
public StandAloneApplication(String name, String version) throws IOException {
|
||||
this(new DockingApplicationLayout(name, version));
|
||||
}
|
||||
|
||||
// Setup application layout
|
||||
try {
|
||||
ApplicationLayout applicationLayout = new DockingApplicationLayout(name, version);
|
||||
init(applicationLayout);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new AssertException(e);
|
||||
/**
|
||||
* reates a new application using the given application layout
|
||||
* and associated application properties.
|
||||
* @param applicationLayout application layout
|
||||
*/
|
||||
public StandAloneApplication(ApplicationLayout applicationLayout) {
|
||||
init(applicationLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read {@link ApplicationProperties} from the specified file path relative
|
||||
* to the current working directory.
|
||||
* <p>
|
||||
* <b>The given properties file is expected to have the
|
||||
* {@link ApplicationProperties#APPLICATION_NAME_PROPERTY} and
|
||||
* {@link ApplicationProperties#APPLICATION_VERSION_PROPERTY} properties
|
||||
* set.</b>
|
||||
* @param propertiesFilename the name of the properties file.
|
||||
* @return application properties
|
||||
* @throws IOException if file read error occurs
|
||||
*/
|
||||
public static ApplicationProperties readApplicationProperties(String propertiesFilename)
|
||||
throws IOException {
|
||||
ApplicationProperties properties = ApplicationProperties.fromFile(propertiesFilename);
|
||||
String name = properties.getProperty(ApplicationProperties.APPLICATION_NAME_PROPERTY);
|
||||
if (name == null) {
|
||||
Msg.error(StandAloneApplication.class,
|
||||
"The application.name property is not set in " + propertiesFilename);
|
||||
}
|
||||
|
||||
String version = properties.getProperty(ApplicationProperties.APPLICATION_VERSION_PROPERTY);
|
||||
if (version == null) {
|
||||
Msg.error(StandAloneApplication.class,
|
||||
"The application.name property is not set in " + propertiesFilename);
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void init(ApplicationLayout applicationLayout) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue