Added code to trick_dp that will check if fxplot exists. If it does then it will

add a radio button for it.  If it doesn't exist, it will not show up in the plot
menu.
This commit is contained in:
Alex Lin 2015-03-04 13:37:20 -06:00
parent 2fab93da66
commit a1fea8a36f
3 changed files with 342 additions and 315 deletions

View File

@ -2,8 +2,11 @@
# trick_dp that determines trick_home based on execution location of this script. # 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 File::Basename ;
use Cwd 'abs_path'; use Cwd 'abs_path';
use gte ;
if ( ! exists $ENV{TRICK_HOME} ) { if ( ! exists $ENV{TRICK_HOME} ) {
$trick_bin = dirname(abs_path($0)) ; $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 # set TRICK_HOME based on the value of trick_home
$ENV{TRICK_HOME} = $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" ) { 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/ \\ $command = "java -classpath $ENV{TRICK_HOME}/bin/java/dist/*:$ENV{TRICK_HOME}/bin/java/lib/*:$ENV{TRICK_HOME}/bin/java/lib/ \\

View File

@ -98,6 +98,7 @@ public abstract class DataProductsApplication extends TrickApplication {
protected static String TEMP_DP_FILE = "/tmp/DP_" + System.getenv("USER") + ".xml"; 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 static String TEMP_SESSION_FILE = "/tmp/Session_" + System.getenv("USER") + ".xml";
protected boolean fermiExists ;
//======================================== //========================================
// Private Data // Private Data
@ -110,6 +111,7 @@ public abstract class DataProductsApplication extends TrickApplication {
// Options are: "Plot", "Table". // Options are: "Plot", "Table".
private String displayMode; private String displayMode;
//======================================== //========================================
// Constructors // Constructors
//======================================== //========================================
@ -122,28 +124,28 @@ public abstract class DataProductsApplication extends TrickApplication {
* Sets the preferred presentation. * Sets the preferred presentation.
*/ */
public void setPreferredPresentation(String pt) { public void setPreferredPresentation(String pt) {
preferredPresentation = pt; preferredPresentation = pt;
} }
/** /**
* Gets the preferred presentation. * Gets the preferred presentation.
*/ */
public String getPreferredPresentation() { public String getPreferredPresentation() {
return preferredPresentation; return preferredPresentation;
} }
/** /**
* Sets preferred display mode. * Sets preferred display mode.
*/ */
public void setDisplayMode(String md) { public void setDisplayMode(String md) {
displayMode = md; displayMode = md;
} }
/** /**
* Gets preferred display mode. * Gets preferred display mode.
*/ */
public String getDisplayMode() { public String getDisplayMode() {
return displayMode; return displayMode;
} }
/** /**
@ -239,7 +241,11 @@ public abstract class DataProductsApplication extends TrickApplication {
} else { } else {
gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.off.icon")); gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.off.icon"));
if (gnuplotRadioButton.isSelected()) { if (gnuplotRadioButton.isSelected()) {
fermiRadioButton.setSelected(true); if ( fermiExists ) {
fermiRadioButton.setSelected(true);
} else {
javaRadioButton.setSelected(true);
}
} }
getAction("selectGnuplotTerminal").setEnabled(false); getAction("selectGnuplotTerminal").setEnabled(false);
} }
@ -360,15 +366,26 @@ public abstract class DataProductsApplication extends TrickApplication {
fermiRadioButton = new JRadioButtonMenuItem(); fermiRadioButton = new JRadioButtonMenuItem();
fermiRadioButton.setAction(getAction("selectFermi")); fermiRadioButton.setAction(getAction("selectFermi"));
fermiRadioButton.setSelected(true);
javaRadioButton = new JRadioButtonMenuItem(getAction("selectJavaPlot")); 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 = new JRadioButtonMenuItem();
gnuplotRadioButton.setAction(getAction("selectGnuplot")); gnuplotRadioButton.setAction(getAction("selectGnuplot"));
radioButtonGroup = new ButtonGroup(); radioButtonGroup = new ButtonGroup();
radioButtonGroup.add(fermiRadioButton); if ( fermiExists ) {
radioButtonGroup.add(fermiRadioButton);
}
radioButtonGroup.add(javaRadioButton); radioButtonGroup.add(javaRadioButton);
radioButtonGroup.add(gnuplotRadioButton); radioButtonGroup.add(gnuplotRadioButton);
@ -388,7 +405,7 @@ public abstract class DataProductsApplication extends TrickApplication {
* @return a {@link JComponent} as the main panel. * @return a {@link JComponent} as the main panel.
*/ */
@Override @Override
protected JComponent createMainPanel() { protected JComponent createMainPanel() {
JXMultiSplitPane msp = new JXMultiSplitPane(); JXMultiSplitPane msp = new JXMultiSplitPane();
@ -557,13 +574,13 @@ public abstract class DataProductsApplication extends TrickApplication {
* @param sessionFile The session used for plotting. * @param sessionFile The session used for plotting.
*/ */
public void launchPlotProgram(String sessionFile) { public void launchPlotProgram(String sessionFile) {
if (fermiRadioButton.isSelected()) { if (fermiRadioButton.isSelected()) {
plotCommand = resourceMap.getString("fxplot.command"); plotCommand = resourceMap.getString("fxplot.command");
} else if (javaRadioButton.isSelected()) { } else if (javaRadioButton.isSelected()) {
plotCommand = resourceMap.getString("jxplot.command"); plotCommand = resourceMap.getString("jxplot.command");
} else if (gnuplotRadioButton.isSelected()) { } else if (gnuplotRadioButton.isSelected()) {
plotCommand = resourceMap.getString("gxplot.command"); plotCommand = resourceMap.getString("gxplot.command");
} }
plotCommand = UIUtils.getTrickBin() + File.separator + plotCommand; plotCommand = UIUtils.getTrickBin() + File.separator + plotCommand;
(new LaunchPlotProcessTask(plotCommand, sessionFile)).execute(); (new LaunchPlotProcessTask(plotCommand, sessionFile)).execute();
@ -575,15 +592,15 @@ public abstract class DataProductsApplication extends TrickApplication {
* @param command The operating system program and arguments. * @param command The operating system program and arguments.
*/ */
public void launchPlotProcess(String... command) throws Exception{ public void launchPlotProcess(String... command) throws Exception{
if (command == null || command.length < 0) { if (command == null || command.length < 0) {
printStatusMessage("No plotting command specified!\n"); printStatusMessage("No plotting command specified!\n");
return; return;
} }
if (plotDevice.equals(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) { if (plotDevice.equals(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
printStatusMessage("Generating postscript file(s) ...\n"); printStatusMessage("Generating postscript file(s) ...\n");
} else { } else {
printStatusMessage("===>>>Launching " + command[0] + "<<<===\n"); printStatusMessage("===>>>Launching " + command[0] + "<<<===\n");
} }
ProcessBuilder pb = new ProcessBuilder(command); ProcessBuilder pb = new ProcessBuilder(command);
captureProcessMessage(pb.start()); captureProcessMessage(pb.start());
@ -629,7 +646,7 @@ public abstract class DataProductsApplication extends TrickApplication {
private class LaunchPlotProcessTask extends SwingWorker<Void, Void> { private class LaunchPlotProcessTask extends SwingWorker<Void, Void> {
private String[] processCommand; private String[] processCommand;
public LaunchPlotProcessTask(String... command) { public LaunchPlotProcessTask(String... command) {
this.processCommand = command; this.processCommand = command;
} }
@ -637,10 +654,10 @@ public abstract class DataProductsApplication extends TrickApplication {
@Override @Override
public Void doInBackground() { public Void doInBackground() {
try { try {
launchPlotProcess(processCommand); launchPlotProcess(processCommand);
} catch (Exception e) { } catch (Exception e) {
printStatusMessage("Error launching plotting process!\n"); printStatusMessage("Error launching plotting process!\n");
} }
return null; return null;
} }

View File

@ -74,7 +74,7 @@ public class TrickDPApplication extends DataProductsApplication {
//======================================== //========================================
// Public data // Public data
//======================================== //========================================
public FileTreePanel simRunTree; public FileTreePanel simRunTree;
public FileTreePanel simDPTree; public FileTreePanel simDPTree;
public ListPanel runList; public ListPanel runList;
public ListPanel dpList; public ListPanel dpList;
@ -116,7 +116,7 @@ public class TrickDPApplication extends DataProductsApplication {
//======================================== //========================================
@Action @Action
public void newSession() { public void newSession() {
actionController.handleNewSession(); actionController.handleNewSession();
} }
@Action @Action
@ -136,44 +136,44 @@ public class TrickDPApplication extends DataProductsApplication {
@Action @Action
public void singlePlot() { public void singlePlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleSinglePlot(); actionController.handleSinglePlot();
} }
@Action @Action
public void comparisonPlot() { public void comparisonPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.COMPARISON_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.COMPARISON_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleComparisonPlot(); actionController.handleComparisonPlot();
} }
@Action @Action
public void errorPlot() { public void errorPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleErrorPlot(); actionController.handleErrorPlot();
} }
@Action @Action
public void contrastPlot() { public void contrastPlot() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.CONTRAST_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.CONTRAST_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.PLOT_MODE]);
actionController.handleContrastPlot(); actionController.handleContrastPlot();
} }
@Action @Action
public void tabularData() { public void tabularData() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.SIMPLE_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularData(); actionController.handleTabularData();
} }
@Action @Action
public void tabularErrorData() { public void tabularErrorData() {
setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]); setPreferredPresentation(Session.PRESENTATION_OPTIONS[Session.DELTA_PRESENTATION]);
setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]); setDisplayMode(Session.MODE_OPTIONS[Session.TABLE_MODE]);
actionController.handleTabularErrorData(); actionController.handleTabularErrorData();
} }
// user selected Import Sim Dir from Sims/Runs menu // user selected Import Sim Dir from Sims/Runs menu
@ -216,20 +216,20 @@ public class TrickDPApplication extends DataProductsApplication {
@Action @Action
public void createPDF() { public void createPDF() {
if (fileDevice == null) { if (fileDevice == null) {
fileDevice = new File(UIUtils.getTrickUserHome()); fileDevice = new File(UIUtils.getTrickUserHome());
} }
PDFBooklet.showDialog(getMainFrame(), "Create PDF", fileDevice); PDFBooklet.showDialog(getMainFrame(), "Create PDF", fileDevice);
} }
@Action @Action
public void addRuns() { public void addRuns() {
actionController.handleAddRuns(); actionController.handleAddRuns();
// Need to modify trick_qp as well when runs are added, so // Need to modify trick_qp as well when runs are added, so
// registering the remote call. Every time need to // registering the remote call. Every time need to
// register a new one as the other application could // register a new one as the other application could
// be no longer exist. // be no longer exist.
try { try {
registerQPRemoteCall(); registerQPRemoteCall();
} catch (RemoteException re) { } catch (RemoteException re) {
@ -243,31 +243,31 @@ public class TrickDPApplication extends DataProductsApplication {
// 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. // and then there is no need to update trick_qp.
if (qpRemoteCall != null) { if (qpRemoteCall != null) {
if (runList.getAllData() != null) { if (runList.getAllData() != null) {
Object[] allRuns = runList.getAllData(); Object[] allRuns = runList.getAllData();
int len = allRuns.length; int len = allRuns.length;
if (len > 0) { if (len > 0) {
final String[] dirList = new String[len]; final String[] dirList = new String[len];
for (int i = 0; i < len; i ++) { for (int i = 0; i < len; i ++) {
if (allRuns[i] instanceof SessionRun) { if (allRuns[i] instanceof SessionRun) {
dirList[i] = ((SessionRun)allRuns[i]).getDir(); dirList[i] = ((SessionRun)allRuns[i]).getDir();
} }
} }
try { try {
// parsing the String array instead of an array of SessionRun // parsing the String array instead of an array of SessionRun
// so that we don't have to worry about the SessionRun objects serialization. // so that we don't have to worry about the SessionRun objects serialization.
qpRemoteCall.updateRunList(dirList); qpRemoteCall.updateRunList(dirList);
} catch (RemoteException re) { } catch (RemoteException re) {
} }
} }
} }
} }
} }
@Action @Action
public void readDPList() { public void readDPList() {
actionController.handleReadDPList(); actionController.handleReadDPList();
} }
@Action @Action
@ -347,39 +347,39 @@ public class TrickDPApplication extends DataProductsApplication {
// Filter from Data Product menu // Filter from Data Product menu
@Action @Action
public void filterDP() { public void filterDP() {
actionController.handleFilterDP(); actionController.handleFilterDP();
} }
@Action @Action
public void runSim() { public void runSim() {
String simExe = "./S_main_" + UIUtils.getTrickHostCPU() + ".exe"; String simExe = "./S_main_" + UIUtils.getTrickHostCPU() + ".exe";
for (String eachItem : simRunTree.getSelectedItems()) { for (String eachItem : simRunTree.getSelectedItems()) {
File eachItemFile = new File(eachItem); File eachItemFile = new File(eachItem);
File simFilePath = eachItemFile.getParentFile(); File simFilePath = eachItemFile.getParentFile();
// find out the SIM_ directory for the RUN // find out the SIM_ directory for the RUN
while (!simFilePath.getName().startsWith("SIM_")) { while (!simFilePath.getName().startsWith("SIM_")) {
simFilePath = simFilePath.getParentFile(); simFilePath = simFilePath.getParentFile();
} }
String simExeArg = eachItem+System.getProperty("file.separator")+"input.py"; String simExeArg = eachItem+System.getProperty("file.separator")+"input.py";
ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg); ProcessBuilder pb = new ProcessBuilder(simExe, simExeArg);
pb.directory(simFilePath); pb.directory(simFilePath);
printStatusMessage("cd " + simFilePath.getPath() + "\n"); printStatusMessage("cd " + simFilePath.getPath() + "\n");
printStatusMessage(simExe + " " + simExeArg + "\n"); printStatusMessage(simExe + " " + simExeArg + "\n");
Process process = null; Process process = null;
try { try {
process = pb.start(); process = pb.start();
} catch (IOException e) { } catch (IOException e) {
printStatusMessage(e.getMessage() + "\n"); printStatusMessage(e.getMessage() + "\n");
} }
if (process != null) { if (process != null) {
captureProcessMessage(process); captureProcessMessage(process);
} }
} }
} }
@Action @Action
public void refreshSelected() { public void refreshSelected() {
actionController.handleRefreshSelected(); actionController.handleRefreshSelected();
} }
@Action @Action
@ -418,9 +418,9 @@ public class TrickDPApplication extends DataProductsApplication {
* Helper method for registering the remote call to call functions in trick_qp. * Helper method for registering the remote call to call functions in trick_qp.
*/ */
private void registerQPRemoteCall() throws RemoteException, MalformedURLException, NotBoundException { private void registerQPRemoteCall() throws RemoteException, MalformedURLException, NotBoundException {
// TODO: may need to change to register by hostname and port number. // TODO: may need to change to register by hostname and port number.
// Here "localhost" is hard-coded and the default port 1099 is implied. // Here "localhost" is hard-coded and the default port 1099 is implied.
Registry registry = LocateRegistry.getRegistry(); Registry registry = LocateRegistry.getRegistry();
qpRemoteCall = (QPRemoteCallInterface) registry.lookup("server.QPRemoteCallInterface"); qpRemoteCall = (QPRemoteCallInterface) registry.lookup("server.QPRemoteCallInterface");
} }
@ -433,25 +433,25 @@ public class TrickDPApplication extends DataProductsApplication {
*/ */
@Override @Override
protected void ready() { protected void ready() {
super.ready(); super.ready();
// TODO: may need to support different port instead of the default one // TODO: may need to support different port instead of the default one
// Create the registry in case any other application needs to // Create the registry in case any other application needs to
// make the remote call to this application. Be sure to create // make the remote call to this application. Be sure to create
// a different registry from trick_qp. // a different registry from trick_qp.
try { try {
LocateRegistry.createRegistry(1099); LocateRegistry.createRegistry(1099);
} catch (RemoteException re) { } catch (RemoteException re) {
// registry already exists, do nothing // registry already exists, do nothing
} }
try { try {
dpRemoteCall = new DPRemoteCallInterfaceImpl(); dpRemoteCall = new DPRemoteCallInterfaceImpl();
Naming.rebind("server.DPRemoteCallInterface", dpRemoteCall); Naming.rebind("server.DPRemoteCallInterface", dpRemoteCall);
} catch (RemoteException re) { } catch (RemoteException re) {
} catch (MalformedURLException me) { } catch (MalformedURLException me) {
} }
} }
@ -462,7 +462,7 @@ public class TrickDPApplication extends DataProductsApplication {
*/ */
@Override @Override
protected void initialize(String[] args) { protected void initialize(String[] args) {
super.initialize(args); super.initialize(args);
initProperties(); initProperties();
} }
@ -490,15 +490,15 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected void createActionController() { protected void createActionController() {
actionController = new TrickDPActionController(); actionController = new TrickDPActionController();
} }
/** /**
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected JComponent createLeftTop() { protected JComponent createLeftTop() {
TrickFileFilter simRunFileFilter = new TrickFileFilter(TrickFileFilter.SIM_RUN); TrickFileFilter simRunFileFilter = new TrickFileFilter(TrickFileFilter.SIM_RUN);
String simDirList = trickProperties.getProperty("TRICK_DP_SIM_DIRS"); String simDirList = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
@ -526,8 +526,8 @@ public class TrickDPApplication extends DataProductsApplication {
} }
} else { } else {
// after app properties initialization, simDirList should never be null // after app properties initialization, simDirList should never be null
// leave else here just in case! // leave else here just in case!
File dir = new File(UIUtils.getTrickUserHome()); File dir = new File(UIUtils.getTrickUserHome());
simRunTree = new SimRunTree(dir, simRunFileFilter, 4); simRunTree = new SimRunTree(dir, simRunFileFilter, 4);
} }
@ -556,8 +556,8 @@ public class TrickDPApplication extends DataProductsApplication {
* Helper method for expanding the node at frist row of a tree. * Helper method for expanding the node at frist row of a tree.
*/ */
private void expandFirstNodeOfTree(FileTreePanel treePanel) { private void expandFirstNodeOfTree(FileTreePanel treePanel) {
treePanel.getTree().expandRow(0); treePanel.getTree().expandRow(0);
treePanel.scrollToTreeTop(); treePanel.scrollToTreeTop();
} }
@ -565,7 +565,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected JComponent createLeftMiddle() { protected JComponent createLeftMiddle() {
runList = new ListPanel(); runList = new ListPanel();
runList.setType(DataPanel.RUN_LIST); runList.setType(DataPanel.RUN_LIST);
simRunTree.addObserver(runList); simRunTree.addObserver(runList);
@ -590,7 +590,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected JComponent createRightTop() { protected JComponent createRightTop() {
File dir = new File(UIUtils.getTrickUserHome()); File dir = new File(UIUtils.getTrickUserHome());
TrickFileFilter simDPFileFilter = new TrickFileFilter(TrickFileFilter.SIM_DP); TrickFileFilter simDPFileFilter = new TrickFileFilter(TrickFileFilter.SIM_DP);
simDPTree = new SimDPTree(dir, simDPFileFilter, 4); simDPTree = new SimDPTree(dir, simDPFileFilter, 4);
@ -619,7 +619,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected JComponent createRightMiddle() { protected JComponent createRightMiddle() {
dpList = new ListPanel(); dpList = new ListPanel();
dpList.setType(DataPanel.DP_LIST); dpList.setType(DataPanel.DP_LIST);
simDPTree.addObserver(dpList); simDPTree.addObserver(dpList);
@ -640,7 +640,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Required by {@link DataProductsApplication}. * Required by {@link DataProductsApplication}.
*/ */
@Override @Override
protected JComponent createBottom() { protected JComponent createBottom() {
JComponent Bottom = getCommonBottom(); JComponent Bottom = getCommonBottom();
Bottom.setPreferredSize(new Dimension(800, 150)); Bottom.setPreferredSize(new Dimension(800, 150));
@ -747,9 +747,9 @@ public class TrickDPApplication extends DataProductsApplication {
toolBar.setFloatable(false); toolBar.setFloatable(false);
for (String actionName : toolbarActionNames) { for (String actionName : toolbarActionNames) {
if (actionName.equals("---")) { if (actionName.equals("---")) {
toolBar.addSeparator(); toolBar.addSeparator();
} else if (actionName.equals("toggleGnuplot")) { } else if (actionName.equals("toggleGnuplot")) {
toolBar.add(gnuplotButton); toolBar.add(gnuplotButton);
} else { } else {
toolBar.add(createButton(actionName, false)); toolBar.add(createButton(actionName, false));
} }
@ -763,8 +763,8 @@ public class TrickDPApplication extends DataProductsApplication {
* Helper method for creating Settings menu. * Helper method for creating Settings menu.
*/ */
private JMenu createSettingsMenu() { private JMenu createSettingsMenu() {
JMenu settingsMenu = new JMenu(); JMenu settingsMenu = new JMenu();
settingsMenu.setName("settingsMenu"); settingsMenu.setName("settingsMenu");
settingsMenu.add(new JLabel("Device")); settingsMenu.add(new JLabel("Device"));
@ -772,7 +772,11 @@ public class TrickDPApplication extends DataProductsApplication {
settingsMenu.addSeparator(); settingsMenu.addSeparator();
settingsMenu.add(new JLabel("Plot Utility")); 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(); settingsMenu.addSeparator();
@ -781,7 +785,7 @@ public class TrickDPApplication extends DataProductsApplication {
settingsMenu.add(gnuplotTerminalMenu); settingsMenu.add(gnuplotTerminalMenu);
gnuplotTerminalMenuItems = addRadioButtonMenuItems(gnuplotTerminalMenu, new String[]{"selectX11", "selectPSColor", "selectPSBW", "selectPNG", "selectEPS", "selectAQUA"}); gnuplotTerminalMenuItems = addRadioButtonMenuItems(gnuplotTerminalMenu, new String[]{"selectX11", "selectPSColor", "selectPSBW", "selectPNG", "selectEPS", "selectAQUA"});
return settingsMenu; return settingsMenu;
} }
/** /**
@ -824,10 +828,10 @@ public class TrickDPApplication extends DataProductsApplication {
String simDirs = addCurrentDir(); String simDirs = addCurrentDir();
/*if (simDirs == null) { /*if (simDirs == null) {
simDirs = UIUtils.getTrickUserHome(); simDirs = UIUtils.getTrickUserHome();
if (simDirs == null) { if (simDirs == null) {
simDirs = ""; simDirs = "";
} }
}*/ }*/
simDirs = appendDirsFromPropertyFile(simDirs); simDirs = appendDirsFromPropertyFile(simDirs);
@ -842,8 +846,8 @@ public class TrickDPApplication extends DataProductsApplication {
} }
// the dir that is shown on the top and is always expanded when the gui is initially up. // 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 // this dir is either the current dir if it is in a SIM or has a SIM dir
// or the TRICK_USER_HOME. // or the TRICK_USER_HOME.
trickProperties.setProperty("TRICK_DP_SIM_DIRS", simDirs); trickProperties.setProperty("TRICK_DP_SIM_DIRS", simDirs);
} }
@ -857,15 +861,15 @@ public class TrickDPApplication extends DataProductsApplication {
// 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") ) { if ( currentDir.contains("/SIM") ) {
try { try {
simDirs = (new File("..")).getCanonicalPath(); simDirs = (new File("..")).getCanonicalPath();
} catch (java.io.IOException ioe) { } catch (java.io.IOException ioe) {
// shouldn't get here // shouldn't get here
simDirs = currentDir.replaceAll("/SIM+\\S*", ""); simDirs = currentDir.replaceAll("/SIM+\\S*", "");
} }
} else { } else {
// Filter a list of returned files that are SIM directories // Filter a list of returned files that are SIM directories
// TODO: use TrickFileFilter // TODO: use TrickFileFilter
FilenameFilter simFilter = new FilenameFilter() { FilenameFilter simFilter = new FilenameFilter() {
public boolean accept(File path, String filename) { public boolean accept(File path, String filename) {
File myFullPath = new File(path + System.getProperty("file.separator") + filename); File myFullPath = new File(path + System.getProperty("file.separator") + filename);
@ -900,15 +904,15 @@ public class TrickDPApplication extends DataProductsApplication {
if (dpSimDirsProperty == null) { if (dpSimDirsProperty == null) {
return simDirs; return simDirs;
} }
String[] dpSimDirs = dpSimDirsProperty.split(","); String[] dpSimDirs = dpSimDirsProperty.split(",");
// if the property doesn't have any value for some reason, // if the property doesn't have any value for some reason,
// return the original string // return the original string
if (dpSimDirs == null || dpSimDirs.length < 1) { if (dpSimDirs == null || dpSimDirs.length < 1) {
return simDirs; return simDirs;
} }
Arrays.sort(dpSimDirs); Arrays.sort(dpSimDirs);
for (String eachDir : dpSimDirs) { for (String eachDir : dpSimDirs) {
if (eachDir == null || eachDir.isEmpty()) { if (eachDir == null || eachDir.isEmpty()) {
@ -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 // Keep the first one as the first one as it will be expanded automatically at beginning
if ( t1 == true && t2 == false ){ if ( t1 == true && t2 == false ){
if (!simDirs.isEmpty()) { if (!simDirs.isEmpty()) {
simDirs = simDirs.concat("," + eachDir); simDirs = simDirs.concat("," + eachDir);
} else { } else {
simDirs = eachDir; simDirs = eachDir;
} }
} }
} }
} }
@ -954,37 +958,37 @@ public class TrickDPApplication extends DataProductsApplication {
/** /**
* Sets the device for plotting. * Sets the device for plotting.
* *
* @param dc The name of the device. * @param dc The name of the device.
*/ */
public void setDevice(String dc) { public void setDevice(String dc) {
if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.PRINTER_DEVICE])) { if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.PRINTER_DEVICE])) {
deviceMenuItems[Session.PRINTER_DEVICE].doClick(); deviceMenuItems[Session.PRINTER_DEVICE].doClick();
} else if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) { } else if (dc.equalsIgnoreCase(Session.DEVICE_OPTIONS[Session.FILE_DEVICE])) {
deviceMenuItems[Session.FILE_DEVICE].doClick(); deviceMenuItems[Session.FILE_DEVICE].doClick();
} else { } else {
deviceMenuItems[Session.TERMINAL_DEVICE].doClick(); // default deviceMenuItems[Session.TERMINAL_DEVICE].doClick(); // default
} }
} }
/** /**
* Sets the Gnuplot terminal. * Sets the Gnuplot terminal.
* *
* @param gt The name of the Gnuplot terminal. * @param gt The name of the Gnuplot terminal.
*/ */
public void setGnuplotTerminal(String gt) { public void setGnuplotTerminal(String gt) {
if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_COLOR_GNUPLOT_TERMINAL])) { if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_COLOR_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_COLOR_GNUPLOT_TERMINAL].doClick(); gnuplotTerminalMenuItems[Session.PS_COLOR_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_BW_GNUPLOT_TERMINAL])) { } else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PS_BW_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PS_BW_GNUPLOT_TERMINAL].doClick(); gnuplotTerminalMenuItems[Session.PS_BW_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PNG_GNUPLOT_TERMINAL])) { } else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.PNG_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.PNG_GNUPLOT_TERMINAL].doClick(); gnuplotTerminalMenuItems[Session.PNG_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.EPS_GNUPLOT_TERMINAL])) { } else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.EPS_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.EPS_GNUPLOT_TERMINAL].doClick(); gnuplotTerminalMenuItems[Session.EPS_GNUPLOT_TERMINAL].doClick();
} else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.AQUA_GNUPLOT_TERMINAL])) { } else if (gt.equalsIgnoreCase(Session.GNUPLOT_TERMINAL_OPTIONS[Session.AQUA_GNUPLOT_TERMINAL])) {
gnuplotTerminalMenuItems[Session.AQUA_GNUPLOT_TERMINAL].doClick(); gnuplotTerminalMenuItems[Session.AQUA_GNUPLOT_TERMINAL].doClick();
} else { } else {
gnuplotTerminalMenuItems[Session.X11_GNUPLOT_TERMINAL].doClick(); // default gnuplotTerminalMenuItems[Session.X11_GNUPLOT_TERMINAL].doClick(); // default
} }
} }
@ -1006,29 +1010,29 @@ public class TrickDPApplication extends DataProductsApplication {
* @param e MouseEvent sent from system. * @param e MouseEvent sent from system.
*/ */
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if (UIUtils.isRightMouseClick(e)) { if (UIUtils.isRightMouseClick(e)) {
if (e.getSource() == runList.getJList()) { if (e.getSource() == runList.getJList()) {
if (runList.getSelectedFirstData() != null && if (runList.getSelectedFirstData() != null &&
runList.getSelectedFirstData() instanceof SessionRun) { runList.getSelectedFirstData() instanceof SessionRun) {
runToConfigure = (SessionRun)runList.getSelectedFirstData(); runToConfigure = (SessionRun)runList.getSelectedFirstData();
} }
} else if (e.getSource() == dpList.getJList()) { } else if (e.getSource() == dpList.getJList()) {
int index = dpList.getJList().locationToIndex(e.getPoint()); int index = dpList.getJList().locationToIndex(e.getPoint());
if (index > -1) { if (index > -1) {
Object clickedObj = dpList.getJList().getModel().getElementAt(index); Object clickedObj = dpList.getJList().getModel().getElementAt(index);
rightClickedDP = clickedObj.toString(); rightClickedDP = clickedObj.toString();
} else { } else {
rightClickedDP = null; rightClickedDP = null;
} }
} else if (e.getSource() == simDPTree.getTree()) { } else if (e.getSource() == simDPTree.getTree()) {
if (simDPTree.getRightClickedTreeUserObj() != null) { if (simDPTree.getRightClickedTreeUserObj() != null) {
rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath(); rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath();
} else { } else {
rightClickedDP = null; rightClickedDP = null;
} }
} }
// common behaviors are handled in ListPanel // common behaviors are handled in ListPanel
} else if (UIUtils.isDoubleClick(e)) { } else if (UIUtils.isDoubleClick(e)) {
if (e.getSource() == dpList.getJList()) { if (e.getSource() == dpList.getJList()) {
dpList.removeSelectedData(); dpList.removeSelectedData();