mirror of
https://github.com/nasa/trick.git
synced 2024-12-21 06:03:10 +00:00
#521 preparation for java 10 support for xmls annotation and improved safety of file separator call
This commit is contained in:
parent
4030757304
commit
a1aaf52ce7
@ -13,6 +13,10 @@ ifeq ($(JAVAC_VERSION),9)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
ifeq ($(JAVAC_VERSION),10)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
SRC_DIR = src
|
||||
SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java)
|
||||
BUILD_DIR = build
|
||||
|
@ -110,9 +110,9 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
// if we want to put the properties into a different location, change here.
|
||||
static {
|
||||
try {
|
||||
propDirectory = System.getProperty("user.home") + System.getProperty("file.separator") + ".trick";
|
||||
propDirectory = System.getProperty("user.home") + java.io.File.separator + ".trick";
|
||||
} catch (Exception e) {
|
||||
propDirectory = System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick";
|
||||
propDirectory = System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick";
|
||||
}
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
applicationName = getContext().getApplicationClass().getSimpleName();
|
||||
|
||||
// set directory for session storage
|
||||
getContext().getLocalStorage().setDirectory(new File(propDirectory + System.getProperty("file.separator") + "." + applicationName));
|
||||
getContext().getLocalStorage().setDirectory(new File(propDirectory + java.io.File.separator + "." + applicationName));
|
||||
|
||||
// register property for JToggleButton class so that its state can be saved
|
||||
getContext().getSessionStorage().putProperty(JToggleButton.class, this);
|
||||
@ -330,7 +330,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
// Load any saved user settable properties from properties file
|
||||
trickProperties = new Properties();
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(propDirectory + System.getProperty("file.separator") + applicationName + ".properties");
|
||||
FileInputStream in = new FileInputStream(propDirectory + java.io.File.separator + applicationName + ".properties");
|
||||
trickProperties.load(in);
|
||||
in.close();
|
||||
}
|
||||
@ -384,7 +384,7 @@ public abstract class TrickApplication extends SingleFrameApplication implements
|
||||
|
||||
// Save any user settable properties to properties file in user's home directory in .trick dir
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(propDirectory + System.getProperty("file.separator") + applicationName +".properties");
|
||||
FileOutputStream out = new FileOutputStream(propDirectory + java.io.File.separator + applicationName +".properties");
|
||||
trickProperties.store(out, "--- Trick User Properties ---");
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
|
@ -748,11 +748,11 @@ public class UIUtils {
|
||||
ImageIcon imgIcon = null;
|
||||
|
||||
// if the fileName is a full path
|
||||
if (fileName.indexOf(System.getProperty("file.separator")) != -1) {
|
||||
if (fileName.indexOf(java.io.File.separator) != -1) {
|
||||
imgIcon = new ImageIcon(fileName);
|
||||
} else {
|
||||
// if only a file name specified, try to find it at common resources folder
|
||||
URL imgURL = TrickApplication.class.getResource("resources" + System.getProperty("file.separator") + fileName);
|
||||
URL imgURL = TrickApplication.class.getResource("resources" + java.io.File.separator + fileName);
|
||||
if (imgURL != null) {
|
||||
imgIcon = new ImageIcon(imgURL);
|
||||
}
|
||||
@ -778,11 +778,11 @@ public class UIUtils {
|
||||
try {
|
||||
InputStream ins = null;
|
||||
// if the fileName is a full path
|
||||
if (fileName.indexOf(System.getProperty("file.separator")) != -1) {
|
||||
if (fileName.indexOf(java.io.File.separator) != -1) {
|
||||
ins = new FileInputStream(fileName);
|
||||
} else {
|
||||
// if only a file name, then find it at common resources area
|
||||
ins = TrickApplication.class.getResourceAsStream("resources" + System.getProperty("file.separator") + fileName);
|
||||
ins = TrickApplication.class.getResourceAsStream("resources" + java.io.File.separator + fileName);
|
||||
}
|
||||
return ins;
|
||||
} catch (NullPointerException npe) {
|
||||
|
@ -356,7 +356,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
while (!simFilePath.getName().startsWith("SIM_")) {
|
||||
simFilePath = simFilePath.getParentFile();
|
||||
}
|
||||
String simExeArg = eachItem+System.getProperty("file.separator")+"input.py";
|
||||
String simExeArg = eachItem+java.io.File.separator+"input.py";
|
||||
ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg);
|
||||
pb.directory(simFilePath);
|
||||
printStatusMessage("cd " + simFilePath.getPath() + "\n");
|
||||
@ -869,7 +869,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
// TODO: use TrickFileFilter
|
||||
FilenameFilter simFilter = new FilenameFilter() {
|
||||
public boolean accept(File path, String filename) {
|
||||
File myFullPath = new File(path + System.getProperty("file.separator") + filename);
|
||||
File myFullPath = new File(path + java.io.File.separator + filename);
|
||||
if ( myFullPath.isDirectory() && filename.contains("SIM") ) {
|
||||
return true;
|
||||
} else {
|
||||
@ -894,7 +894,7 @@ public class TrickDPApplication extends DataProductsApplication {
|
||||
*/
|
||||
private String appendDirsFromPropertyFile(String simDirs) {
|
||||
// prevent the duplicate ones
|
||||
File myDpPropFile = new File(propDirectory + System.getProperty("file.separator") + applicationName + ".properties");
|
||||
File myDpPropFile = new File(propDirectory + java.io.File.separator + applicationName + ".properties");
|
||||
if ( myDpPropFile.exists() ) {
|
||||
String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
|
||||
// if the property doesn't exist, return the original string
|
||||
|
@ -300,7 +300,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
|
||||
// For PS view
|
||||
private void psView() {
|
||||
File selectedFirstFile = new File(fileDir + System.getProperty("file.separator") + selectedPSFileList.getSelectedFirstData().toString());
|
||||
File selectedFirstFile = new File(fileDir + java.io.File.separator + selectedPSFileList.getSelectedFirstData().toString());
|
||||
try {
|
||||
if (selectedFirstFile.exists() && Desktop.isDesktopSupported()) {
|
||||
Desktop.getDesktop().open(selectedFirstFile);
|
||||
@ -324,7 +324,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
for (Object obj : selectedData) {
|
||||
commandBuf.append(" ");
|
||||
commandBuf.append(fileDir);
|
||||
commandBuf.append(System.getProperty("file.separator"));
|
||||
commandBuf.append(java.io.File.separator);
|
||||
commandBuf.append(obj.toString());
|
||||
}
|
||||
|
||||
@ -357,7 +357,7 @@ public class PDFBooklet extends JDialog implements ActionListener, ListSelection
|
||||
for (Object obj : selectedData) {
|
||||
commandBuf.append(" ");
|
||||
commandBuf.append(fileDir);
|
||||
commandBuf.append(System.getProperty("file.separator"));
|
||||
commandBuf.append(java.io.File.separator);
|
||||
commandBuf.append(obj.toString());
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ public class TrickDPActionController {
|
||||
public void launchQP(String[] initialArgs) {
|
||||
// the command variable program command name and arguments
|
||||
List<String> command = new ArrayList<String>();
|
||||
String fileSeparator = System.getProperty("file.separator");
|
||||
String fileSeparator = java.io.File.separator;
|
||||
String pathSeparator = System.getProperty("path.separator");
|
||||
|
||||
String javaPath = UIUtils.getTrickHome() + fileSeparator + "libexec/trick" + fileSeparator + "java";
|
||||
|
@ -487,7 +487,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
|
||||
for (int i = 0; i < simRunDirField.length; i++) {
|
||||
if (i==0) {
|
||||
simRunDirField[i] = new JTextField(results[4] + System.getProperty("file.separator") + results[5] + " " + results[6]);
|
||||
simRunDirField[i] = new JTextField(results[4] + java.io.File.separator + results[5] + " " + results[6]);
|
||||
} else {
|
||||
simRunDirField[i] = new JTextField();
|
||||
}
|
||||
@ -495,7 +495,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
overrunField[i].setPreferredSize( new Dimension(60, overrunField[i].getHeight()) );
|
||||
}
|
||||
simRunDir = results[7];
|
||||
simRunDir = results[4] + System.getProperty("file.separator") + simRunDir;
|
||||
simRunDir = results[4] + java.io.File.separator + simRunDir;
|
||||
|
||||
simState.setRunPath(simRunDir);
|
||||
|
||||
@ -510,7 +510,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
"trick.sim_serives.var_send( ) \n" +
|
||||
"trick.sim_services.var_clear( ) \n");
|
||||
results = commandSimcom.get().split("\t");
|
||||
simRunDirField[i].setText(results[1] + System.getProperty("file.separator") + results[2] + " " + results[2]);*/
|
||||
simRunDirField[i].setText(results[1] + java.io.File.separator + results[2] + " " + results[2]);*/
|
||||
simRunDirField[i].setText("Slave " + i);
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ public class SimControlApplication extends TrickApplication implements PropertyC
|
||||
*/
|
||||
private void printSendHS() {
|
||||
if (simState != null) {
|
||||
File sendHS = new File(simState.getRunPath() + System.getProperty("file.separator") + "send_hs");
|
||||
File sendHS = new File(simState.getRunPath() + java.io.File.separator + "send_hs");
|
||||
if (!sendHS.exists()) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,6 +14,9 @@ JAVAC_VERSION := $(shell ${JAVAC} -version 2>&1 | perl -ne 'print /(\d+)/')
|
||||
ifeq ($(JAVAC_VERSION),9)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
ifeq ($(JAVAC_VERSION),10)
|
||||
JAVAC_FLAGS += --add-modules java.se.ee
|
||||
endif
|
||||
|
||||
SRC_DIR = src
|
||||
SRC_FILES = $(shell find ${SRC_DIR} -type f -name \*.java)
|
||||
|
@ -43,8 +43,8 @@ public class TrickApplicationTest {
|
||||
public void testPropertyLocation() {
|
||||
application();
|
||||
application();
|
||||
boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + System.getProperty("file.separator") + ".trick"))
|
||||
|| (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + System.getProperty("file.separator") + ".trick"));
|
||||
boolean rightLocation = (TrickApplication.propDirectory.equals(System.getenv("HOME") + java.io.File.separator + ".trick"))
|
||||
|| (TrickApplication.propDirectory.equals(System.getenv("TRICK_USER_HOME") + java.io.File.separator + ".trick"));
|
||||
assertTrue("The default property location is not at ../.trick!", rightLocation);
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class LogHeaderReaderTest {
|
||||
|
||||
@Test(expected = FileNotFoundException.class)
|
||||
public void testGetContentsWithNotFoundFile() throws FileNotFoundException, IOException {
|
||||
DataReader reader = new LogHeaderReader("resources" + System.getProperty("file.separator") + "unknowFile.header");
|
||||
DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "unknowFile.header");
|
||||
reader.processHeader();
|
||||
}
|
||||
|
||||
@ -61,15 +61,15 @@ public class LogHeaderReaderTest {
|
||||
expectedVarList[8].setUnits("N");
|
||||
|
||||
// ASCII
|
||||
DataReader reader = new LogHeaderReader("resources" + System.getProperty("file.separator") + "log_Ball.header");
|
||||
DataReader reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball.header");
|
||||
assertArrayEquals("Error in getContents for ASCII in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
|
||||
// HDF5
|
||||
reader = new LogHeaderReader("resources" + System.getProperty("file.separator") + "log_Ball2.header");
|
||||
reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball2.header");
|
||||
assertArrayEquals("Error in getContents for HDF5 in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
|
||||
// little_endian
|
||||
reader = new LogHeaderReader("resources" + System.getProperty("file.separator") + "log_Ball3.header");
|
||||
reader = new LogHeaderReader("resources" + java.io.File.separator + "log_Ball3.header");
|
||||
assertArrayEquals("Error in getContents for little_endian in DataReader.java", expectedVarList, reader.getRecordedVarList().toArray());
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class WaitForDreApplication extends DreApplication {
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForDreApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
sieResourcePath ="resources" + System.getProperty("file.separator") + "S_sie.resource";
|
||||
sieResourcePath ="resources" + java.io.File.separator + "S_sie.resource";
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
|
@ -29,7 +29,7 @@ public class WaitForSieApplication extends SieApplication {
|
||||
*/
|
||||
public static void launchAndWait(Class<? extends WaitForSieApplication> applicationClass) {
|
||||
synchronized(lock) {
|
||||
sieResourcePath = "resources" + System.getProperty("file.separator") + "S_sie.resource";
|
||||
sieResourcePath = "resources" + java.io.File.separator + "S_sie.resource";
|
||||
Application.launch(applicationClass, new String[]{});
|
||||
while(true) {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user