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

@ -71,7 +71,7 @@ public abstract class DataProductsApplication extends TrickApplication {
public SessionRun runToConfigure; public SessionRun runToConfigure;
public String sessionFile; public String sessionFile;
public File fileDevice; public File fileDevice;
//======================================== //========================================
@ -88,7 +88,7 @@ public abstract class DataProductsApplication extends TrickApplication {
protected JRadioButtonMenuItem fermiRadioButton; protected JRadioButtonMenuItem fermiRadioButton;
protected JRadioButtonMenuItem javaRadioButton; protected JRadioButtonMenuItem javaRadioButton;
protected JRadioButtonMenuItem gnuplotRadioButton; protected JRadioButtonMenuItem gnuplotRadioButton;
protected JToggleButton gnuplotButton; protected JToggleButton gnuplotButton;
protected String plotDevice = Session.DEVICE_OPTIONS[Session.TERMINAL_DEVICE]; 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_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
//======================================== //========================================
private String plotCommand; private String plotCommand;
// Options are: "Simple", "Comparison", "Delta", "Contrast" // Options are: "Simple", "Comparison", "Delta", "Contrast"
private String preferredPresentation; private String preferredPresentation;
// Options are: "Plot", "Table". // Options are: "Plot", "Table".
private String displayMode; private String displayMode;
//======================================== //========================================
// Constructors // Constructors
//======================================== //========================================
@ -122,30 +124,30 @@ 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;
} }
/** /**
* Gets the common bottom component if this is what you want. * Gets the common bottom component if this is what you want.
* *
@ -234,12 +236,16 @@ public abstract class DataProductsApplication extends TrickApplication {
public void toggleGnuplot() { public void toggleGnuplot() {
if (gnuplotButton.isSelected()) { if (gnuplotButton.isSelected()) {
gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.on.icon")); gnuplotButton.setIcon(resourceMap.getIcon("gnuplot.on.icon"));
gnuplotRadioButton.setSelected(true); gnuplotRadioButton.setSelected(true);
getAction("selectGnuplotTerminal").setEnabled(true); getAction("selectGnuplotTerminal").setEnabled(true);
} 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);
} }
@ -258,7 +264,7 @@ public abstract class DataProductsApplication extends TrickApplication {
getAction("selectGnuplotTerminal").setEnabled(true); getAction("selectGnuplotTerminal").setEnabled(true);
toggleGnuplot(); toggleGnuplot();
} }
@Action @Action
public void selectJavaPlot() { public void selectJavaPlot() {
gnuplotButton.setSelected(false); gnuplotButton.setSelected(false);
@ -327,7 +333,7 @@ public abstract class DataProductsApplication extends TrickApplication {
*/ */
@Override @Override
protected void initialize(String[] args) { 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 = 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);
View view = getMainView(); View view = getMainView();
view.setComponent(createMainPanel()); view.setComponent(createMainPanel());
view.setMenuBar(createMenuBar()); view.setMenuBar(createMenuBar());
@ -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();
@ -463,7 +480,7 @@ public abstract class DataProductsApplication extends TrickApplication {
gnuplotTerminal = Session.GNUPLOT_TERMINAL_OPTIONS[Session.X11_GNUPLOT_TERMINAL]; gnuplotTerminal = Session.GNUPLOT_TERMINAL_OPTIONS[Session.X11_GNUPLOT_TERMINAL];
} }
} }
/** /**
* Helper method for setting plot device. * Helper method for setting plot device.
* *
@ -478,7 +495,7 @@ public abstract class DataProductsApplication extends TrickApplication {
plotDevice = Session.DEVICE_OPTIONS[Session.TERMINAL_DEVICE]; plotDevice = Session.DEVICE_OPTIONS[Session.TERMINAL_DEVICE];
} }
} }
/** /**
* Resets all commond fields if available. * Resets all commond fields if available.
*/ */
@ -557,49 +574,49 @@ 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();
} }
/** /**
* Launches a process with specified parameters. * Launches a process with specified parameters.
* *
* @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());
} }
/** /**
* Redirects runtime process messages from screen to GUI status area. * Redirects runtime process messages from screen to GUI status area.
* *
* @param runtimeProcess The runtime process from which screen messages is generated. * @param runtimeProcess The runtime process from which screen messages is generated.
*/ */
public void captureProcessMessage(Process runtimeProcess) { public void captureProcessMessage(Process runtimeProcess) {
try { try {
if (runtimeProcess == null) { if (runtimeProcess == null) {
return; return;
} }
BufferedReader stdInput = new BufferedReader(new InputStreamReader(runtimeProcess.getInputStream())); BufferedReader stdInput = new BufferedReader(new InputStreamReader(runtimeProcess.getInputStream()));
BufferedReader stdError = new BufferedReader(new InputStreamReader(runtimeProcess.getErrorStream())); BufferedReader stdError = new BufferedReader(new InputStreamReader(runtimeProcess.getErrorStream()));
@ -626,10 +643,10 @@ public abstract class DataProductsApplication extends TrickApplication {
public void printStatusMessage(String msg) { public void printStatusMessage(String msg) {
statusArea.append(msg); statusArea.append(msg);
} }
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;
} }
@ -648,5 +665,5 @@ public abstract class DataProductsApplication extends TrickApplication {
public void done() { public void done() {
} }
} }
} }

View File

@ -74,13 +74,13 @@ 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;
public String rightClickedDP = null; public String rightClickedDP = null;
//======================================== //========================================
// Protected data // Protected data
//======================================== //========================================
@ -90,22 +90,22 @@ public class TrickDPApplication extends DataProductsApplication {
// Private Data // Private Data
//======================================== //========================================
private TrickDPActionController actionController = null; 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"); private String currentDir = System.getProperty("user.dir");
// to call functions in trick_qp // to call functions in trick_qp
private QPRemoteCallInterface qpRemoteCall; private QPRemoteCallInterface qpRemoteCall;
// to let other application to call this app (trick_dp) // to let other application to call this app (trick_dp)
private DPRemoteCallInterface dpRemoteCall; private DPRemoteCallInterface dpRemoteCall;
// menu items for gnuplot terminal // menu items for gnuplot terminal
private JRadioButtonMenuItem[] gnuplotTerminalMenuItems; private JRadioButtonMenuItem[] gnuplotTerminalMenuItems;
// menu items for device choices // menu items for device choices
private JRadioButtonMenuItem[] deviceMenuItems; private JRadioButtonMenuItem[] deviceMenuItems;
//======================================== //========================================
// Constructors // Constructors
//======================================== //========================================
@ -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,58 +216,58 @@ 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) {
} catch (MalformedURLException me) { } catch (MalformedURLException me) {
} catch (NotBoundException nbe) { } 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. // 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
@ -325,68 +325,68 @@ public class TrickDPApplication extends DataProductsApplication {
if (selectedLen < 1) { if (selectedLen < 1) {
JOptionPane.showMessageDialog(getMainFrame(), JOptionPane.showMessageDialog(getMainFrame(),
"No DP_ file is selected from DP Selections!", "No DP_ file is selected from DP Selections!",
"Error", "Error",
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
} else if (selectedLen > 1) { } else if (selectedLen > 1) {
JOptionPane.showMessageDialog(getMainFrame(), JOptionPane.showMessageDialog(getMainFrame(),
"More than one DP_ file selected in DP Selections. Only one may be edited at a time!", "More than one DP_ file selected in DP Selections. Only one may be edited at a time!",
"Error", "Error",
JOptionPane.WARNING_MESSAGE); JOptionPane.WARNING_MESSAGE);
} else { } else {
actionController.handleEditDP(dpList.getSelectedFirstData().toString()); actionController.handleEditDP(dpList.getSelectedFirstData().toString());
} }
} }
// Edit DP... from the popup menu after right-clicking on a DP_ file // Edit DP... from the popup menu after right-clicking on a DP_ file
@Action @Action
public void editRightClickedDP() { public void editRightClickedDP() {
actionController.handleEditDP(rightClickedDP); actionController.handleEditDP(rightClickedDP);
} }
// 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
public void plotDestination() { public void plotDestination() {
} }
@Action @Action
public void selectFileDevice() { public void selectFileDevice() {
fileDevice = UIUtils.chooseSaveFile(UIUtils.getTrickUserHome(), "dp_out", null, getMainFrame()); 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, // if no file is selected such as the Cancel button is clicked,
// set the device to what it was before // set the device to what it was before
setDevice(plotDevice); setDevice(plotDevice);
} }
} }
//======================================== //========================================
// Set/Get methods // Set/Get methods
//======================================== //========================================
//======================================== //========================================
// Methods // Methods
//======================================== //========================================
@ -413,17 +413,17 @@ public class TrickDPApplication extends DataProductsApplication {
public static void main(String[] args) { public static void main(String[] args) {
Application.launch(TrickDPApplication.class, args); Application.launch(TrickDPApplication.class, args);
} }
/** /**
* 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");
} }
/** /**
* Starts things after everything else is ready. * Starts things after everything else is ready.
* This is called after startup. * This is called after startup.
@ -433,28 +433,28 @@ 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) {
} }
} }
/** /**
* Makes initialization as needed. This is called before startup(). * Makes initialization as needed. This is called before startup().
* *
@ -462,10 +462,10 @@ 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();
} }
// Save all SIM directories for next time before shutting down // Save all SIM directories for next time before shutting down
@Override @Override
public void shutdown() { public void shutdown() {
@ -490,19 +490,19 @@ 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");
if (simDirList != null) { if (simDirList != null) {
String[] simDirs = simDirList.split(","); String[] simDirs = simDirList.split(",");
/* FileTree will not add/display a folder icon if the directory /* FileTree will not add/display a folder icon if the directory
@ -514,22 +514,22 @@ public class TrickDPApplication extends DataProductsApplication {
* is hidden/filtered. * is hidden/filtered.
* Fixed in FileTree. * Fixed in FileTree.
*/ */
//Arrays.sort( simdirs, Collections.reverseOrder() ); //Arrays.sort( simdirs, Collections.reverseOrder() );
for (int i = 0; i < simDirs.length; i ++) { for (int i = 0; i < simDirs.length; i ++) {
File dir = new File(simDirs[i]); File dir = new File(simDirs[i]);
if (i == 0) { if (i == 0) {
simRunTree = new SimRunTree(dir, simRunFileFilter, 4); simRunTree = new SimRunTree(dir, simRunFileFilter, 4);
} else { } else {
simRunTree.importDir(dir); simRunTree.importDir(dir);
} }
} }
} 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);
} }
simRunTree.setPreferredSize(new Dimension(325, 375)); simRunTree.setPreferredSize(new Dimension(325, 375));
@ -551,27 +551,27 @@ public class TrickDPApplication extends DataProductsApplication {
return simRunTree; return simRunTree;
} }
/** /**
* 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();
} }
/** /**
* 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);
runList.addListMouseListener(new LocalMouseListener()); runList.addListMouseListener(new LocalMouseListener());
runList.setPreferredSize(new Dimension(325, 225)); runList.setPreferredSize(new Dimension(325, 225));
runList.getJList().setTransferHandler(new SessionRunTransferHandler(runList.getJList())); runList.getJList().setTransferHandler(new SessionRunTransferHandler(runList.getJList()));
runList.getJList().setDragEnabled(true); runList.getJList().setDragEnabled(true);
runList.getJList().setDropMode(DropMode.INSERT); runList.getJList().setDropMode(DropMode.INSERT);
@ -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));
@ -673,7 +673,7 @@ public class TrickDPApplication extends DataProductsApplication {
}; };
String[] dataProductMenuActionNames = { String[] dataProductMenuActionNames = {
"addDP", "addDP",
"editSelectedDP", "editSelectedDP",
"filterDP" "filterDP"
}; };
@ -697,21 +697,21 @@ public class TrickDPApplication extends DataProductsApplication {
"helpContents", "helpContents",
"---", "---",
"showAboutBox" "showAboutBox"
}; };
JMenu sessionMenu = createMenu("sessionMenu", sessionMenuActionNames); JMenu sessionMenu = createMenu("sessionMenu", sessionMenuActionNames);
sessionMenu.insert(confirmExitSelection, sessionMenuActionNames.length-1); sessionMenu.insert(confirmExitSelection, sessionMenuActionNames.length-1);
menuBar.add(sessionMenu); menuBar.add(sessionMenu);
menuBar.add(createMenu("simsRunsMenu",simsRunsMenuActionNames)); menuBar.add(createMenu("simsRunsMenu",simsRunsMenuActionNames));
menuBar.add(createMenu("dataProductMenu",dataProductMenuActionNames)); menuBar.add(createMenu("dataProductMenu",dataProductMenuActionNames));
menuBar.add(createSettingsMenu()); menuBar.add(createSettingsMenu());
menuBar.add(createMenu("actionsMenu",actionsMenuActionNames)); menuBar.add(createMenu("actionsMenu",actionsMenuActionNames));
menuBar.add(createHelpMenu("helpMenu", helpMenuActionNames, "Help.hs")); menuBar.add(createHelpMenu("helpMenu", helpMenuActionNames, "Help.hs"));
return menuBar; return menuBar;
} }
@ -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,14 +785,14 @@ 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;
} }
/** /**
* Helper method for initializing properties as necessary. * Helper method for initializing properties as necessary.
*/ */
private void initProperties() { private void initProperties() {
setTrickDPSimDirsProperty(); setTrickDPSimDirsProperty();
setTrickDPImportDirProperty(); setTrickDPImportDirProperty();
@ -800,21 +804,21 @@ public class TrickDPApplication extends DataProductsApplication {
private void setTrickDPImportDirProperty() { private void setTrickDPImportDirProperty() {
String defaultImportSimDir = trickProperties.getProperty("TRICK_DP_IMPORT_DIR"); 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 the TRICK_DP_IMPORT_DIR doesn't exist, set TRICK_USER_HOME to the property
if (defaultImportSimDir == null) { if (defaultImportSimDir == null) {
defaultImportSimDir = UIUtils.getTrickUserHome(); defaultImportSimDir = UIUtils.getTrickUserHome();
} }
// if TRICK_USER_HOME doesn't exist, set current dir to the property // if TRICK_USER_HOME doesn't exist, set current dir to the property
if (defaultImportSimDir == null || !((new File(defaultImportSimDir)).exists())) { if (defaultImportSimDir == null || !((new File(defaultImportSimDir)).exists())) {
defaultImportSimDir = currentDir; defaultImportSimDir = currentDir;
} }
trickProperties.setProperty("TRICK_DP_IMPORT_DIR", defaultImportSimDir); trickProperties.setProperty("TRICK_DP_IMPORT_DIR", defaultImportSimDir);
} }
/** /**
* Helper method to set TRICK_DP_SIM_DIRS property. * Helper method to set TRICK_DP_SIM_DIRS property.
* *
* The property string contains: * The property string contains:
* 1. current directory if it is in a SIM dir or it has SIM dirs * 1. current directory if it is in a SIM dir or it has SIM dirs
* 2. TrickDPApplication.properties * 2. TrickDPApplication.properties
@ -822,16 +826,16 @@ public class TrickDPApplication extends DataProductsApplication {
*/ */
private void setTrickDPSimDirsProperty() { private void setTrickDPSimDirsProperty() {
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);
// add TRICK_USER_HOME if it's not there // add TRICK_USER_HOME if it's not there
if (!simDirs.contains(UIUtils.getTrickUserHome())) { if (!simDirs.contains(UIUtils.getTrickUserHome())) {
if (simDirs != null && !simDirs.trim().isEmpty()) { if (simDirs != null && !simDirs.trim().isEmpty()) {
@ -840,32 +844,32 @@ public class TrickDPApplication extends DataProductsApplication {
simDirs = UIUtils.getTrickUserHome(); simDirs = UIUtils.getTrickUserHome();
} }
} }
// 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);
} }
/** /**
* Helper method to initially set current dir to the dir string. * Helper method to initially set current dir to the dir string.
* *
*/ */
private String addCurrentDir() { private String addCurrentDir() {
String simDirs = ""; 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") ) { 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);
@ -878,18 +882,18 @@ public class TrickDPApplication extends DataProductsApplication {
}; };
String[] simsList = new File(currentDir).list(simFilter); String[] simsList = new File(currentDir).list(simFilter);
if ( simsList != null && simsList.length > 0 ) { if ( simsList != null && simsList.length > 0 ) {
simDirs = currentDir; simDirs = currentDir;
} }
} }
return simDirs; return simDirs;
} }
/** /**
* Helper method to append those dirs specified as TRICK_DP_SIM_DIRS property * Helper method to append those dirs specified as TRICK_DP_SIM_DIRS property
* in related .properties file without duplication to the specified dir string * in related .properties file without duplication to the specified dir string
* separated by comma. * separated by comma.
* *
*/ */
private String appendDirsFromPropertyFile(String simDirs) { private String appendDirsFromPropertyFile(String simDirs) {
// prevent the duplicate ones // prevent the duplicate ones
@ -897,19 +901,19 @@ public class TrickDPApplication extends DataProductsApplication {
if ( myDpPropFile.exists() ) { if ( myDpPropFile.exists() ) {
String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS"); String dpSimDirsProperty = trickProperties.getProperty("TRICK_DP_SIM_DIRS");
// if the property doesn't exist, return the original string // if the property doesn't exist, return the original string
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()) {
continue; 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 // 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;
} }
} }
} }
} }
@ -950,44 +954,44 @@ public class TrickDPApplication extends DataProductsApplication {
} }
return runPaths; return runPaths;
} }
/** /**
* 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.
*
* @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
}
} }
/**
* 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 // Inner classes
//======================================== //========================================
@ -995,7 +999,7 @@ public class TrickDPApplication extends DataProductsApplication {
* Localized mouse call handling. * Localized mouse call handling.
*/ */
private class LocalMouseListener extends MouseAdapter { private class LocalMouseListener extends MouseAdapter {
//======================================== //========================================
// MouseListener method(s) // MouseListener method(s)
//======================================== //========================================
@ -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 {
rightClickedDP = null;
}
} else if (e.getSource() == simDPTree.getTree()) {
if (simDPTree.getRightClickedTreeUserObj() != null) {
rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath();
} else { } else {
rightClickedDP = null; rightClickedDP = null;
} }
} } else if (e.getSource() == simDPTree.getTree()) {
// common behaviors are handled in ListPanel if (simDPTree.getRightClickedTreeUserObj() != null) {
rightClickedDP = simDPTree.getRightClickedTreeUserObj().getFile().getAbsolutePath();
} else {
rightClickedDP = null;
}
}
// 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();