Merge remote-tracking branch 'origin/master'

This commit is contained in:
Derek Bankieris 2015-03-10 16:05:34 -05:00
commit c7e5ab1139
5 changed files with 349 additions and 316 deletions

View File

@ -19,4 +19,10 @@ wiki page includes instructions to install Trick.
The full [User's Guide](https://github.com/nasa/Trick/wiki/Users-Guide) is in
the wiki pages.
### Tutorial
The Trick tutorial explaining how to start using Trick can be found in the docs directory.
### License
Trick is released under the NASA Open Source Agreement Version 1.3 [license](LICENSE).

View File

@ -2,8 +2,11 @@
# trick_dp that determines trick_home based on execution location of this script.
use FindBin qw($Bin);
use lib "$Bin/pm" ;
use File::Basename ;
use Cwd 'abs_path';
use gte ;
if ( ! exists $ENV{TRICK_HOME} ) {
$trick_bin = dirname(abs_path($0)) ;
@ -12,6 +15,9 @@ if ( ! exists $ENV{TRICK_HOME} ) {
# set TRICK_HOME based on the value of trick_home
$ENV{TRICK_HOME} = $trick_home ;
}
$host_cpu = gte("TRICK_HOST_CPU") ;
chomp($host_cpu) ;
$ENV{TRICK_HOST_CPU} = $host_cpu ;
if ( $^O eq "darwin" ) {
$command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\

View File

@ -1,3 +1,3 @@
current_version = "13.6.dev"
current_version = "15.0.dev"
thread_version = "1.1"
service_issues = ""

View File

@ -71,7 +71,7 @@ public abstract class DataProductsApplication extends TrickApplication {
public SessionRun runToConfigure;
public String sessionFile;
public File fileDevice;
//========================================
@ -88,7 +88,7 @@ public abstract class DataProductsApplication extends TrickApplication {
protected JRadioButtonMenuItem fermiRadioButton;
protected JRadioButtonMenuItem javaRadioButton;
protected JRadioButtonMenuItem gnuplotRadioButton;
protected JToggleButton gnuplotButton;
protected String plotDevice = Session.DEVICE_OPTIONS[Session.TERMINAL_DEVICE];
@ -97,19 +97,21 @@ public abstract class DataProductsApplication extends TrickApplication {
protected static String TEMP_DP_FILE = "/tmp/DP_" + System.getenv("USER") + ".xml";
protected static String TEMP_SESSION_FILE = "/tmp/Session_" + System.getenv("USER") + ".xml";
protected boolean fermiExists ;
//========================================
// Private Data
//========================================
private String plotCommand;
// Options are: "Simple", "Comparison", "Delta", "Contrast"
private String preferredPresentation;
// Options are: "Plot", "Table".
private String displayMode;
//========================================
// Constructors
//========================================
@ -122,30 +124,30 @@ public abstract class DataProductsApplication extends TrickApplication {
* Sets the preferred presentation.
*/
public void setPreferredPresentation(String pt) {
preferredPresentation = pt;
preferredPresentation = pt;
}
/**
* Gets the preferred presentation.
*/
public String getPreferredPresentation() {
return preferredPresentation;
return preferredPresentation;
}
/**
* Sets preferred display mode.
*/
public void setDisplayMode(String md) {
displayMode = md;
displayMode = md;
}
/**
* Gets preferred display mode.
*/
public String getDisplayMode() {
return displayMode;
return displayMode;
}
/**
* Gets the common bottom component if this is what you want.
*
@ -234,12 +236,16 @@ public abstract class DataProductsApplication extends TrickApplication {
public void toggleGnuplot() {
if (gnuplotButton.isSelected()) {
gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.on.icon"));
gnuplotRadioButton.setSelected(true);
gnuplotRadioButton.setSelected(true);
getAction("selectGnuplotTerminal").setEnabled(true);
} else {
gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.off.icon"));
if (gnuplotRadioButton.isSelected()) {
fermiRadioButton.setSelected(true);
if ( fermiExists ) {
fermiRadioButton.setSelected(true);
} else {
javaRadioButton.setSelected(true);
}
}
getAction("selectGnuplotTerminal").setEnabled(false);
}
@ -258,7 +264,7 @@ public abstract class DataProductsApplication extends TrickApplication {
getAction("selectGnuplotTerminal").setEnabled(true);
toggleGnuplot();
}
@Action
public void selectJavaPlot() {
gnuplotButton.setSelected(false);
@ -327,7 +333,7 @@ public abstract class DataProductsApplication extends TrickApplication {
*/
@Override
protected void initialize(String[] args) {
super.initialize(args);
super.initialize(args);
}
/**
@ -360,19 +366,30 @@ public abstract class DataProductsApplication extends TrickApplication {
fermiRadioButton = new JRadioButtonMenuItem();
fermiRadioButton.setAction(getAction("selectFermi"));
fermiRadioButton.setSelected(true);
javaRadioButton = new JRadioButtonMenuItem(getAction("selectJavaPlot"));
String fermi_exe = UIUtils.getTrickHome() + "/trick_source/data_products/DPX/APPS/FXPLOT/object_" + UIUtils.getTrickHostCPU() + "/fxplot" ;
File f = new File(fermi_exe) ;
fermiExists = f.exists() ;
if ( fermiExists ) {
fermiRadioButton.setSelected(true);
} else {
javaRadioButton.setSelected(true);
}
gnuplotRadioButton = new JRadioButtonMenuItem();
gnuplotRadioButton.setAction(getAction("selectGnuplot"));
radioButtonGroup = new ButtonGroup();
radioButtonGroup.add(fermiRadioButton);
if ( fermiExists ) {
radioButtonGroup.add(fermiRadioButton);
}
radioButtonGroup.add(javaRadioButton);
radioButtonGroup.add(gnuplotRadioButton);
View view = getMainView();
view.setComponent(createMainPanel());
view.setMenuBar(createMenuBar());
@ -388,7 +405,7 @@ public abstract class DataProductsApplication extends TrickApplication {
* @return a {@link JComponent} as the main panel.
*/
@Override
protected JComponent createMainPanel() {
protected JComponent createMainPanel() {
JXMultiSplitPane msp = new JXMultiSplitPane();
@ -463,7 +480,7 @@ public abstract class DataProductsApplication extends TrickApplication {
gnuplotTerminal = Session.GNUPLOT_TERMINAL_OPTIONS[Session.X11_GNUPLOT_TERMINAL];
}
}
/**
* Helper method for setting plot device.
*
@ -478,7 +495,7 @@ public abstract class DataProductsApplication extends TrickApplication {
plotDevice = Session.DEVICE_OPTIONS[Session.TERMINAL_DEVICE];
}
}
/**
* Resets all commond fields if available.
*/
@ -557,49 +574,49 @@ public abstract class DataProductsApplication extends TrickApplication {
* @param sessionFile The session used for plotting.
*/
public void launchPlotProgram(String sessionFile) {
if (fermiRadioButton.isSelected()) {
plotCommand = resourceMap.getString("fxplot.command");
} else if (javaRadioButton.isSelected()) {
plotCommand = resourceMap.getString("jxplot.command");
} else if (gnuplotRadioButton.isSelected()) {
plotCommand = resourceMap.getString("gxplot.command");
}
if (fermiRadioButton.isSelected()) {
plotCommand = resourceMap.getString("fxplot.command");
} else if (javaRadioButton.isSelected()) {
plotCommand = resourceMap.getString("jxplot.command");
} else if (gnuplotRadioButton.isSelected()) {
plotCommand = resourceMap.getString("gxplot.command");
}
plotCommand = UIUtils.getTrickBin() + File.separator + plotCommand;
(new LaunchPlotProcessTask(plotCommand, sessionFile)).execute();
}
/**
* Launches a process with specified parameters.
*
* @param command The operating system program and arguments.
*/
public void launchPlotProcess(String... command) throws Exception{
if (command == null || command.length < 0) {
printStatusMessage("No plotting command specified!\n");
return;
}
if (plotDevice.equals(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
printStatusMessage("Generating postscript file(s) ...\n");
if (command == null || command.length < 0) {
printStatusMessage("No plotting command specified!\n");
return;
}
if (plotDevice.equals(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
printStatusMessage("Generating postscript file(s) ...\n");
} else {
printStatusMessage("===>>>Launching " + command[0] + "<<<===\n");
}
}
ProcessBuilder pb = new ProcessBuilder(command);
captureProcessMessage(pb.start());
}
/**
* Redirects runtime process messages from screen to GUI status area.
*
*
* @param runtimeProcess The runtime process from which screen messages is generated.
*/
public void captureProcessMessage(Process runtimeProcess) {
try {
try {
if (runtimeProcess == null) {
return;
}
BufferedReader stdInput = new BufferedReader(new InputStreamReader(runtimeProcess.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(runtimeProcess.getErrorStream()));
@ -626,10 +643,10 @@ public abstract class DataProductsApplication extends TrickApplication {
public void printStatusMessage(String msg) {
statusArea.append(msg);
}
private class LaunchPlotProcessTask extends SwingWorker<Void, Void> {
private String[] processCommand;
private String[] processCommand;
public LaunchPlotProcessTask(String... command) {
this.processCommand = command;
}
@ -637,10 +654,10 @@ public abstract class DataProductsApplication extends TrickApplication {
@Override
public Void doInBackground() {
try {
launchPlotProcess(processCommand);
} catch (Exception e) {
printStatusMessage("Error launching plotting process!\n");
}
launchPlotProcess(processCommand);
} catch (Exception e) {
printStatusMessage("Error launching plotting process!\n");
}
return null;
}
@ -648,5 +665,5 @@ public abstract class DataProductsApplication extends TrickApplication {
public void done() {
}
}
}

View File

@ -74,13 +74,13 @@ public class TrickDPApplication extends DataProductsApplication {
//========================================
// Public data
//========================================
public FileTreePanel simRunTree;
public FileTreePanel simRunTree;
public FileTreePanel simDPTree;
public ListPanel runList;
public ListPanel dpList;
public String rightClickedDP = null;
//========================================
// Protected data
//========================================
@ -90,22 +90,22 @@ public class TrickDPApplication extends DataProductsApplication {
// Private Data
//========================================
private TrickDPActionController actionController = null;
// the current dir where the app is started from
// the current dir where the app is started from
private String currentDir = System.getProperty("user.dir");
// to call functions in trick_qp
private QPRemoteCallInterface qpRemoteCall;
// to let other application to call this app (trick_dp)
private DPRemoteCallInterface dpRemoteCall;
// menu items for gnuplot terminal
private JRadioButtonMenuItem[] gnuplotTerminalMenuItems;
// menu items for device choices
private JRadioButtonMenuItem[] deviceMenuItems;
//========================================
// Constructors
//========================================
@ -116,7 +116,7 @@ public class TrickDPApplication extends DataProductsApplication {
//========================================
@Action
public void newSession() {
actionController.handleNewSession();
actionController.handleNewSession();
}
@Action
@ -136,44 +136,44 @@ public class TrickDPApplication extends DataProductsApplication {
@Action
public void singlePlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleSinglePlot();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleSinglePlot();
}
@Action
public void comparisonPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.COMPARISON_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleComparisonPlot();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.COMPARISON_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleComparisonPlot();
}
@Action
public void errorPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleErrorPlot();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleErrorPlot();
}
@Action
public void contrastPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.CONTRAST_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleContrastPlot();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.CONTRAST_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleContrastPlot();
}
@Action
public void tabularData() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularData();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularData();
}
@Action
public void tabularErrorData() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularErrorData();
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularErrorData();
}
// user selected Import Sim Dir from Sims/Runs menu
@ -216,58 +216,58 @@ public class TrickDPApplication extends DataProductsApplication {
@Action
public void createPDF() {
if (fileDevice == null) {
fileDevice = new File(UIUtils.getTrickUserHome());
}
PDFBooklet.showDialog(getMainFrame(), "Create PDF", fileDevice);
if (fileDevice == null) {
fileDevice = new File(UIUtils.getTrickUserHome());
}
PDFBooklet.showDialog(getMainFrame(), "Create PDF", fileDevice);
}
@Action
public void addRuns() {
actionController.handleAddRuns();
// Need to modify trick_qp as well when runs are added, so
// registering the remote call. Every time need to
// register a new one as the other application could
// be no longer exist.
actionController.handleAddRuns();
// Need to modify trick_qp as well when runs are added, so
// registering the remote call. Every time need to
// register a new one as the other application could
// be no longer exist.
try {
registerQPRemoteCall();
} catch (RemoteException re) {
} catch (MalformedURLException me) {
} catch (NotBoundException nbe) {
}
// if trick_qp is not up, remote call won't be created successfully
// if trick_qp is not up, remote call won't be created successfully
// and then there is no need to update trick_qp.
if (qpRemoteCall != null) {
if (runList.getAllData() != null) {
Object[] allRuns = runList.getAllData();
int len = allRuns.length;
if (len > 0) {
final String[] dirList = new String[len];
for (int i = 0; i < len; i ++) {
if (allRuns[i] instanceof SessionRun) {
dirList[i] = ((SessionRun)allRuns[i]).getDir();
}
}
try {
// parsing the String array instead of an array of SessionRun
// so that we don't have to worry about the SessionRun objects serialization.
qpRemoteCall.updateRunList(dirList);
} catch (RemoteException re) {
}
}
}
}
if (runList.getAllData() != null) {
Object[] allRuns = runList.getAllData();
int len = allRuns.length;
if (len > 0) {
final String[] dirList = new String[len];
for (int i = 0; i < len; i ++) {
if (allRuns[i] instanceof SessionRun) {
dirList[i] = ((SessionRun)allRuns[i]).getDir();
}
}
try {
// parsing the String array instead of an array of SessionRun
// so that we don't have to worry about the SessionRun objects serialization.
qpRemoteCall.updateRunList(dirList);
} catch (RemoteException re) {
}
}
}
}
}
@Action
public void readDPList() {
actionController.handleReadDPList();
actionController.handleReadDPList();
}
@Action
@ -325,68 +325,68 @@ public class TrickDPApplication extends DataProductsApplication {
if (selectedLen < 1) {
JOptionPane.showMessageDialog(getMainFrame(),
"No DP_ file is selected from DP Selections!",
"Error",
"Error",
JOptionPane.WARNING_MESSAGE);
} else if (selectedLen > 1) {
JOptionPane.showMessageDialog(getMainFrame(),
"More than one DP_ file selected in DP Selections. Only one may be edited at a time!",
"Error",
"Error",
JOptionPane.WARNING_MESSAGE);
} else {
actionController.handleEditDP(dpList.getSelectedFirstData().toString());
}
}
// Edit DP... from the popup menu after right-clicking on a DP_ file
@Action
public void editRightClickedDP() {
actionController.handleEditDP(rightClickedDP);
}
// Filter from Data Product menu
@Action
public void filterDP() {
actionController.handleFilterDP();
actionController.handleFilterDP();
}
@Action
public void runSim() {
String simExe = "./S_main_" + UIUtils.getTrickHostCPU() + ".exe";
for (String eachItem : simRunTree.getSelectedItems()) {
File eachItemFile = new File(eachItem);
File simFilePath = eachItemFile.getParentFile();
// find out the SIM_ directory for the RUN
while (!simFilePath.getName().startsWith("SIM_")) {
simFilePath = simFilePath.getParentFile();
}
String simExeArg = eachItem+System.getProperty("file.separator")+"input.py";
ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg);
pb.directory(simFilePath);
printStatusMessage("cd " + simFilePath.getPath() + "\n");
printStatusMessage(simExe + " " + simExeArg + "\n");
Process process = null;
try {
String simExe = "./S_main_" + UIUtils.getTrickHostCPU() + ".exe";
for (String eachItem : simRunTree.getSelectedItems()) {
File eachItemFile = new File(eachItem);
File simFilePath = eachItemFile.getParentFile();
// find out the SIM_ directory for the RUN
while (!simFilePath.getName().startsWith("SIM_")) {
simFilePath = simFilePath.getParentFile();
}
String simExeArg = eachItem+System.getProperty("file.separator")+"input.py";
ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg);
pb.directory(simFilePath);
printStatusMessage("cd " + simFilePath.getPath() + "\n");
printStatusMessage(simExe + " " + simExeArg + "\n");
Process process = null;
try {
process = pb.start();
} catch (IOException e) {
printStatusMessage(e.getMessage() + "\n");
}
if (process != null) {
captureProcessMessage(process);
}
}
if (process != null) {
captureProcessMessage(process);
}
}
}
@Action
public void refreshSelected() {
actionController.handleRefreshSelected();
actionController.handleRefreshSelected();
}
@Action
public void plotDestination() {
}
@Action
public void selectFileDevice() {
fileDevice = UIUtils.chooseSaveFile(UIUtils.getTrickUserHome(), "dp_out", null, getMainFrame());
@ -396,14 +396,14 @@ public class TrickDPApplication extends DataProductsApplication {
// if no file is selected such as the Cancel button is clicked,
// set the device to what it was before
setDevice(plotDevice);
}
}
}
//========================================
// Set/Get methods
//========================================
//========================================
// Methods
//========================================
@ -413,17 +413,17 @@ public class TrickDPApplication extends DataProductsApplication {
public static void main(String[] args) {
Application.launch(TrickDPApplication.class, args);
}
/**
/**
* Helper method for registering the remote call to call functions in trick_qp.
*/
private void registerQPRemoteCall() throws RemoteException, MalformedURLException, NotBoundException {
// TODO: may need to change to register by hostname and port number.
// Here "localhost" is hard-coded and the default port 1099 is implied.
Registry registry = LocateRegistry.getRegistry();
// TODO: may need to change to register by hostname and port number.
// Here "localhost" is hard-coded and the default port 1099 is implied.
Registry registry = LocateRegistry.getRegistry();
qpRemoteCall = (QPRemoteCallInterface) registry.lookup("server.QPRemoteCallInterface");
}
/**
* Starts things after everything else is ready.
* This is called after startup.
@ -433,28 +433,28 @@ public class TrickDPApplication extends DataProductsApplication {
*/
@Override
protected void ready() {
super.ready();
// TODO: may need to support different port instead of the default one
// Create the registry in case any other application needs to
// make the remote call to this application. Be sure to create
// a different registry from trick_qp.
try {
LocateRegistry.createRegistry(1099);
} catch (RemoteException re) {
// registry already exists, do nothing
}
try {
super.ready();
// TODO: may need to support different port instead of the default one
// Create the registry in case any other application needs to
// make the remote call to this application. Be sure to create
// a different registry from trick_qp.
try {
LocateRegistry.createRegistry(1099);
} catch (RemoteException re) {
// registry already exists, do nothing
}
try {
dpRemoteCall = new DPRemoteCallInterfaceImpl();
Naming.rebind("server.DPRemoteCallInterface", dpRemoteCall);
} catch (RemoteException re) {
} catch (MalformedURLException me) {
}
} catch (RemoteException re) {
} catch (MalformedURLException me) {
}
}
/**
* Makes initialization as needed. This is called before startup().
*
@ -462,10 +462,10 @@ public class TrickDPApplication extends DataProductsApplication {
*/
@Override
protected void initialize(String[] args) {
super.initialize(args);
super.initialize(args);
initProperties();
}
// Save all SIM directories for next time before shutting down
@Override
public void shutdown() {
@ -490,19 +490,19 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}.
*/
@Override
protected void createActionController() {
actionController = new TrickDPActionController();
protected void createActionController() {
actionController = new TrickDPActionController();
}
/**
* Required by {@link DataProductsApplication}.
*/
@Override
protected JComponent createLeftTop() {
protected JComponent createLeftTop() {
TrickFileFilter simRunFileFilter = new TrickFileFilter(TrickFileFilter.SIM_RUN);
String simDirList = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
if (simDirList != null) {
String[] simDirs = simDirList.split(",");
/* FileTree will not add/display a folder icon if the directory
@ -514,22 +514,22 @@ public class TrickDPApplication extends DataProductsApplication {
* is hidden/filtered.
* Fixed in FileTree.
*/
//Arrays.sort( simdirs, Collections.reverseOrder() );
//Arrays.sort( simdirs, Collections.reverseOrder() );
for (int i = 0; i < simDirs.length; i ++) {
File dir = new File(simDirs[i]);
File dir = new File(simDirs[i]);
if (i == 0) {
simRunTree = new SimRunTree(dir, simRunFileFilter, 4);
} else {
simRunTree.importDir(dir);
}
}
} else {
// after app properties initialization, simDirList should never be null
// leave else here just in case!
// after app properties initialization, simDirList should never be null
// leave else here just in case!
File dir = new File(UIUtils.getTrickUserHome());
simRunTree = new SimRunTree(dir, simRunFileFilter, 4);
simRunTree = new SimRunTree(dir, simRunFileFilter, 4);
}
simRunTree.setPreferredSize(new Dimension(325, 375));
@ -551,27 +551,27 @@ public class TrickDPApplication extends DataProductsApplication {
return simRunTree;
}
/**
* Helper method for expanding the node at frist row of a tree.
*/
private void expandFirstNodeOfTree(FileTreePanel treePanel) {
treePanel.getTree().expandRow(0);
treePanel.scrollToTreeTop();
treePanel.getTree().expandRow(0);
treePanel.scrollToTreeTop();
}
/**
* Required by {@link DataProductsApplication}.
*/
@Override
protected JComponent createLeftMiddle() {
protected JComponent createLeftMiddle() {
runList = new ListPanel();
runList.setType(DataPanel.RUN_LIST);
simRunTree.addObserver(runList);
runList.addListMouseListener(new LocalMouseListener());
runList.setPreferredSize(new Dimension(325, 225));
runList.getJList().setTransferHandler(new SessionRunTransferHandler(runList.getJList()));
runList.getJList().setDragEnabled(true);
runList.getJList().setDropMode(DropMode.INSERT);
@ -590,7 +590,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}.
*/
@Override
protected JComponent createRightTop() {
protected JComponent createRightTop() {
File dir = new File(UIUtils.getTrickUserHome());
TrickFileFilter simDPFileFilter = new TrickFileFilter(TrickFileFilter.SIM_DP);
simDPTree = new SimDPTree(dir, simDPFileFilter, 4);
@ -619,7 +619,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}.
*/
@Override
protected JComponent createRightMiddle() {
protected JComponent createRightMiddle() {
dpList = new ListPanel();
dpList.setType(DataPanel.DP_LIST);
simDPTree.addObserver(dpList);
@ -640,7 +640,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}.
*/
@Override
protected JComponent createBottom() {
protected JComponent createBottom() {
JComponent Bottom = getCommonBottom();
Bottom.setPreferredSize(new Dimension(800, 150));
@ -673,7 +673,7 @@ public class TrickDPApplication extends DataProductsApplication {
};
String[] dataProductMenuActionNames = {
"addDP",
"editSelectedDP",
"editSelectedDP",
"filterDP"
};
@ -697,21 +697,21 @@ public class TrickDPApplication extends DataProductsApplication {
"helpContents",
"---",
"showAboutBox"
};
};
JMenu sessionMenu = createMenu("sessionMenu", sessionMenuActionNames);
sessionMenu.insert(confirmExitSelection, sessionMenuActionNames.length-1);
menuBar.add(sessionMenu);
menuBar.add(sessionMenu);
menuBar.add(createMenu("simsRunsMenu",simsRunsMenuActionNames));
menuBar.add(createMenu("dataProductMenu",dataProductMenuActionNames));
menuBar.add(createSettingsMenu());
menuBar.add(createMenu("actionsMenu",actionsMenuActionNames));
menuBar.add(createHelpMenu("helpMenu", helpMenuActionNames, "Help.hs"));
return menuBar;
}
@ -747,9 +747,9 @@ public class TrickDPApplication extends DataProductsApplication {
toolBar.setFloatable(false);
for (String actionName : toolbarActionNames) {
if (actionName.equals("---")) {
toolBar.addSeparator();
toolBar.addSeparator();
} else if (actionName.equals("toggleGnuplot")) {
toolBar.add(gnuplotButton);
toolBar.add(gnuplotButton);
} else {
toolBar.add(createButton(actionName, false));
}
@ -763,8 +763,8 @@ public class TrickDPApplication extends DataProductsApplication {
* Helper method for creating Settings menu.
*/
private JMenu createSettingsMenu() {
JMenu settingsMenu = new JMenu();
settingsMenu.setName("settingsMenu");
JMenu settingsMenu = new JMenu();
settingsMenu.setName("settingsMenu");
settingsMenu.add(new JLabel("Device"));
@ -772,7 +772,11 @@ public class TrickDPApplication extends DataProductsApplication {
settingsMenu.addSeparator();
settingsMenu.add(new JLabel("Plot Utility"));
addRadioButtonMenuItems(settingsMenu, new JRadioButtonMenuItem[]{fermiRadioButton, javaRadioButton, gnuplotRadioButton});
if ( fermiExists ) {
addRadioButtonMenuItems(settingsMenu, new JRadioButtonMenuItem[]{fermiRadioButton, javaRadioButton, gnuplotRadioButton});
} else {
addRadioButtonMenuItems(settingsMenu, new JRadioButtonMenuItem[]{javaRadioButton, gnuplotRadioButton});
}
settingsMenu.addSeparator();
@ -781,14 +785,14 @@ public class TrickDPApplication extends DataProductsApplication {
settingsMenu.add(gnuplotTerminalMenu);
gnuplotTerminalMenuItems = addRadioButtonMenuItems(gnuplotTerminalMenu, new String[]{"selectX11", "selectPSColor", "selectPSBW", "selectPNG", "selectEPS", "selectAQUA"});
return settingsMenu;
return settingsMenu;
}
/**
* Helper method for initializing properties as necessary.
*/
private void initProperties() {
setTrickDPSimDirsProperty();
setTrickDPImportDirProperty();
@ -800,21 +804,21 @@ public class TrickDPApplication extends DataProductsApplication {
private void setTrickDPImportDirProperty() {
String defaultImportSimDir = trickProperties.getProperty("TRICK_DP_IMPORT_DIR");
// if the TRICK_DP_IMPORT_DIR doesn't exist, set TRICK_USER_HOME to the property
if (defaultImportSimDir == null) {
if (defaultImportSimDir == null) {
defaultImportSimDir = UIUtils.getTrickUserHome();
}
// if TRICK_USER_HOME doesn't exist, set current dir to the property
if (defaultImportSimDir == null || !((new File(defaultImportSimDir)).exists())) {
defaultImportSimDir = currentDir;
}
trickProperties.setProperty("TRICK_DP_IMPORT_DIR", defaultImportSimDir);
}
/**
* Helper method to set TRICK_DP_SIM_DIRS property.
*
*
* The property string contains:
* 1. current directory if it is in a SIM dir or it has SIM dirs
* 2. TrickDPApplication.properties
@ -822,16 +826,16 @@ public class TrickDPApplication extends DataProductsApplication {
*/
private void setTrickDPSimDirsProperty() {
String simDirs = addCurrentDir();
/*if (simDirs == null) {
simDirs = UIUtils.getTrickUserHome();
if (simDirs == null) {
simDirs = "";
}
/*if (simDirs == null) {
simDirs = UIUtils.getTrickUserHome();
if (simDirs == null) {
simDirs = "";
}
}*/
simDirs = appendDirsFromPropertyFile(simDirs);
// add TRICK_USER_HOME if it's not there
if (!simDirs.contains(UIUtils.getTrickUserHome())) {
if (simDirs != null && !simDirs.trim().isEmpty()) {
@ -840,32 +844,32 @@ public class TrickDPApplication extends DataProductsApplication {
simDirs = UIUtils.getTrickUserHome();
}
}
// the dir that is shown on the top and is always expanded when the gui is initially up.
// this dir is either the current dir if it is in a SIM or has a SIM dir
// or the TRICK_USER_HOME.
// this dir is either the current dir if it is in a SIM or has a SIM dir
// or the TRICK_USER_HOME.
trickProperties.setProperty("TRICK_DP_SIM_DIRS", simDirs);
}
/**
* Helper method to initially set current dir to the dir string.
*
*
*/
private String addCurrentDir() {
String simDirs = "";
// if current dir is in a SIM dir, import its parent
// if current dir is in a SIM dir, import its parent
if ( currentDir.contains("/SIM") ) {
try {
simDirs = (new File("..")).getCanonicalPath();
} catch (java.io.IOException ioe) {
// shouldn't get here
simDirs = currentDir.replaceAll("/SIM+\\S*", "");
}
try {
simDirs = (new File("..")).getCanonicalPath();
} catch (java.io.IOException ioe) {
// shouldn't get here
simDirs = currentDir.replaceAll("/SIM+\\S*", "");
}
} else {
// Filter a list of returned files that are SIM directories
// TODO: use TrickFileFilter
// TODO: use TrickFileFilter
FilenameFilter simFilter = new FilenameFilter() {
public boolean accept(File path, String filename) {
File myFullPath = new File(path + System.getProperty("file.separator") + filename);
@ -878,18 +882,18 @@ public class TrickDPApplication extends DataProductsApplication {
};
String[] simsList = new File(currentDir).list(simFilter);
if ( simsList != null && simsList.length > 0 ) {
simDirs = currentDir;
simDirs = currentDir;
}
}
return simDirs;
}
/**
* Helper method to append those dirs specified as TRICK_DP_SIM_DIRS property
* in related .properties file without duplication to the specified dir string
* Helper method to append those dirs specified as TRICK_DP_SIM_DIRS property
* in related .properties file without duplication to the specified dir string
* separated by comma.
*
*
*/
private String appendDirsFromPropertyFile(String simDirs) {
// prevent the duplicate ones
@ -897,19 +901,19 @@ public class TrickDPApplication extends DataProductsApplication {
if ( myDpPropFile.exists() ) {
String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
// if the property doesn't exist, return the original string
if (dpSimDirsProperty == null) {
if (dpSimDirsProperty == null) {
return simDirs;
}
String[] dpSimDirs = dpSimDirsProperty.split(",");
// if the property doesn't have any value for some reason,
// return the original string
if (dpSimDirs == null || dpSimDirs.length < 1) {
return simDirs;
}
Arrays.sort(dpSimDirs);
String[] dpSimDirs = dpSimDirsProperty.split(",");
// if the property doesn't have any value for some reason,
// return the original string
if (dpSimDirs == null || dpSimDirs.length < 1) {
return simDirs;
}
Arrays.sort(dpSimDirs);
for (String eachDir : dpSimDirs) {
if (eachDir == null || eachDir.isEmpty()) {
continue;
@ -924,11 +928,11 @@ public class TrickDPApplication extends DataProductsApplication {
}
// Keep the first one as the first one as it will be expanded automatically at beginning
if ( t1 == true && t2 == false ){
if (!simDirs.isEmpty()) {
simDirs = simDirs.concat("," + eachDir);
} else {
simDirs = eachDir;
}
if (!simDirs.isEmpty()) {
simDirs = simDirs.concat("," + eachDir);
} else {
simDirs = eachDir;
}
}
}
}
@ -950,44 +954,44 @@ public class TrickDPApplication extends DataProductsApplication {
}
return runPaths;
}
/**
* Sets the device for plotting.
*
* @param dc The name of the device.
*
* @param dc The name of the device.
*/
public void setDevice(String dc) {
if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.PRINTER_DEVICE])) {
deviceMenuItems[Session.PRINTER_DEVICE].doClick();
} else if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
deviceMenuItems[Session.FILE_DEVICE].doClick();
} else {
deviceMenuItems[Session.TERMINAL_DEVICE].doClick(); // default
}
}
/**
* Sets the Gnuplot terminal.
*
* @param gt The name of the Gnuplot terminal.
*/
public void setGnuplotTerminal(String gt) {
if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_COLOR_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_COLOR_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_BW_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_BW_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PNG_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PNG_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.EPS_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.EPS_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.AQUA_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.AQUA_GNUPLOT_TERMINAL].doClick();
} else {
gnuplotTerminalMenuItems[Session.X11_GNUPLOT_TERMINAL].doClick(); // default
}
if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.PRINTER_DEVICE])) {
deviceMenuItems[Session.PRINTER_DEVICE].doClick();
} else if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
deviceMenuItems[Session.FILE_DEVICE].doClick();
} else {
deviceMenuItems[Session.TERMINAL_DEVICE].doClick(); // default
}
}
/**
* Sets the Gnuplot terminal.
*
* @param gt The name of the Gnuplot terminal.
*/
public void setGnuplotTerminal(String gt) {
if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_COLOR_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_COLOR_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_BW_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_BW_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PNG_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PNG_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.EPS_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.EPS_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.AQUA_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.AQUA_GNUPLOT_TERMINAL].doClick();
} else {
gnuplotTerminalMenuItems[Session.X11_GNUPLOT_TERMINAL].doClick(); // default
}
}
//========================================
// Inner classes
//========================================
@ -995,7 +999,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Localized mouse call handling.
*/
private class LocalMouseListener extends MouseAdapter {
//========================================
// MouseListener method(s)
//========================================
@ -1006,29 +1010,29 @@ public class TrickDPApplication extends DataProductsApplication {
* @param e MouseEvent sent from system.
*/
@Override
public void mouseClicked(MouseEvent e) {
public void mouseClicked(MouseEvent e) {
if (UIUtils.isRightMouseClick(e)) {
if (e.getSource() == runList.getJList()) {
if (runList.getSelectedFirstData() != null &&
runList.getSelectedFirstData() instanceof SessionRun) {
runToConfigure = (SessionRun)runList.getSelectedFirstData();
}
} else if (e.getSource() == dpList.getJList()) {
int index = dpList.getJList().locationToIndex(e.getPoint());
if (index > -1) {
Object clickedObj = dpList.getJList().getModel().getElementAt(index);
rightClickedDP = clickedObj.toString();
} else {
rightClickedDP = null;
}
} else if (e.getSource() == simDPTree.getTree()) {
if (simDPTree.getRightClickedTreeUserObj() != null) {
rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath();
if (e.getSource() == runList.getJList()) {
if (runList.getSelectedFirstData() != null &&
runList.getSelectedFirstData() instanceof SessionRun) {
runToConfigure = (SessionRun)runList.getSelectedFirstData();
}
} else if (e.getSource() == dpList.getJList()) {
int index = dpList.getJList().locationToIndex(e.getPoint());
if (index > -1) {
Object clickedObj = dpList.getJList().getModel().getElementAt(index);
rightClickedDP = clickedObj.toString();
} else {
rightClickedDP = null;
}
}
// common behaviors are handled in ListPanel
} else if (e.getSource() == simDPTree.getTree()) {
if (simDPTree.getRightClickedTreeUserObj() != null) {
rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath();
} else {
rightClickedDP = null;
}
}
// common behaviors are handled in ListPanel
} else if (UIUtils.isDoubleClick(e)) {
if (e.getSource() == dpList.getJList()) {
dpList.removeSelectedData();