Skip to content

Commit

Permalink
Made it possible to run programs in Java by adding (1) option to skip…
Browse files Browse the repository at this point in the history
… checking existence of executable file and (2) instructions on Java configuration.
  • Loading branch information
dj3500 committed Jul 29, 2014
1 parent abee22f commit 6d12157
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 65 deletions.
9 changes: 9 additions & 0 deletions Hightail/src/org/hightail/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ static protected void fillInUnsetValuesWithDefaults() {
setIfUnset("pathFromWorkingDirToExec", "%P.exe");
// TODO: if under Unix, this better be "%L"
setIfUnset("prependingCommand", "");
setIfUnset("checkExistence", "1");
}

static public boolean load() {
Expand All @@ -57,4 +58,12 @@ static public void save() throws IOException {
static public boolean isPrependingCommandNonempty() {
return !Config.get("prependingCommand").trim().isEmpty();
}

public static boolean getBoolean(String key) {
return !get(key).equals("0");
}

public static void setBoolean(String key, boolean value) {
set(key, value ? "1" : "0");
}
}
46 changes: 26 additions & 20 deletions Hightail/src/org/hightail/ui/ConfigJDialog.form
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Form version="1.8" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="0"/>
<Property name="title" type="java.lang.String" value="Settings"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<Events>
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
Expand Down Expand Up @@ -45,8 +44,8 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="pathsAndDirectoriesPanel" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="pathsAndDirectoriesPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="saveButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -85,20 +84,20 @@
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
<Component id="pathFromWorkingDirToExecTextField" max="32767" attributes="0"/>
</Group>
<Component id="jSeparator2" alignment="0" max="32767" attributes="0"/>
<Component id="jSeparator1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="prependingCommandTextField" max="32767" attributes="0"/>
</Group>
<Component id="checkExistenceCheckBox" alignment="0" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="prependingCommandTextField" min="-2" pref="329" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="jLabel4" alignment="0" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
Expand All @@ -115,24 +114,24 @@
<Component id="workingDirectoryBrowseButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="workingDirectoryLabel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="pathFromWorkingDirToExecLabel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="pathFromWorkingDirToExecTextField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="pathFromWorkingDirToExecLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jSeparator2" min="-2" pref="10" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="prependingCommandTextField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="checkExistenceCheckBox" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" pref="92" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
Expand Down Expand Up @@ -181,14 +180,21 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Leave it empty for C++ (i.e. if the executable is standalone). Nonempty examples: &quot;java&quot;, &quot;python&quot;"/>
<Property name="text" type="java.lang.String" value="Leave it empty for C++ (i.e. if the executable is standalone). Nonempty example: &quot;python&quot;"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="prependingCommandTextField">
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator2">
<Component class="javax.swing.JCheckBox" name="checkExistenceCheckBox">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Check whether executable file exists before execution"/>
</Properties>
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator1">
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="&lt;html&gt;Setup tips for Java: let&apos;s say you keep the main class of your compiled solution to problem B at &quot;d:\u005calgo\u005ctaskB\u005cMain.class&quot;. In this case you want to execute &quot;java -classpath d:\u005calgo\u005ctaskB Main&quot;, so you should set the working directory to &quot;d:\u005calgo&quot;, path from working directory to executable to &quot;task%P Main&quot; and the prepending command to &quot;java -classpath&quot;. If you had just &quot;d:\u005calgo\u005cMain.class&quot;, you would need to set the path from working directory to executable to &quot; Main&quot; (note the space at the beginning).&lt;br&gt;You must also uncheck &quot;check whether executable file exists&quot;." containsInvalidXMLChars="true"/>
</Properties>
</Component>
</SubComponents>
</Container>
Expand Down
53 changes: 32 additions & 21 deletions Hightail/src/org/hightail/ui/ConfigJDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public ConfigJDialog(JFrame parent) {
pathFromWorkingDirToExecTextField.setText(Config.get("pathFromWorkingDirToExec"));

prependingCommandTextField.setText(Config.get("prependingCommand"));

checkExistenceCheckBox.setSelected(Config.getBoolean("checkExistence"));
}

/** This method is called from within the constructor to
Expand All @@ -61,8 +63,8 @@ private void initComponents() {
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
prependingCommandTextField = new javax.swing.JTextField();
jSeparator2 = new javax.swing.JSeparator();
jSeparator1 = new javax.swing.JSeparator();
checkExistenceCheckBox = new javax.swing.JCheckBox();
jLabel4 = new javax.swing.JLabel();
saveButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();

Expand Down Expand Up @@ -94,7 +96,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

jLabel2.setText("Command to prepend the executable with:");

jLabel3.setText("Leave it empty for C++ (i.e. if the executable is standalone). Nonempty examples: \"java\", \"python\"");
jLabel3.setText("Leave it empty for C++ (i.e. if the executable is standalone). Nonempty example: \"python\"");

checkExistenceCheckBox.setSelected(true);
checkExistenceCheckBox.setText("Check whether executable file exists before execution");

jLabel4.setText("<html>Setup tips for Java: let's say you keep the main class of your compiled solution to problem B at \"d:\\algo\\taskB\\Main.class\". In this case you want to execute \"java -classpath d:\\algo\\taskB Main\", so you should set the working directory to \"d:\\algo\", path from working directory to executable to \"task%P Main\" and the prepending command to \"java -classpath\". If you had just \"d:\\algo\\Main.class\", you would need to set the path from working directory to executable to \" Main\" (note the space at the beginning).<br>You must also uncheck \"check whether executable file exists\".");

javax.swing.GroupLayout pathsAndDirectoriesPanelLayout = new javax.swing.GroupLayout(pathsAndDirectoriesPanel);
pathsAndDirectoriesPanel.setLayout(pathsAndDirectoriesPanelLayout);
Expand All @@ -114,17 +121,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(pathFromWorkingDirToExecLabel)
.addGap(10, 10, 10)
.addComponent(pathFromWorkingDirToExecTextField))
.addComponent(jSeparator2)
.addComponent(jSeparator1)
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(prependingCommandTextField))
.addComponent(checkExistenceCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel3))
.addGap(0, 0, Short.MAX_VALUE)))
.addComponent(jLabel3)
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(prependingCommandTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addContainerGap())
);
pathsAndDirectoriesPanelLayout.setVerticalGroup(
Expand All @@ -137,22 +144,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addComponent(workingDirectoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(workingDirectoryBrowseButton)
.addComponent(workingDirectoryLabel))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(1, 1, 1)
.addGap(18, 18, 18)
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(pathFromWorkingDirToExecLabel)
.addComponent(pathFromWorkingDirToExecTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pathFromWorkingDirToExecLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGap(18, 18, 18)
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(prependingCommandTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addGap(18, 18, 18)
.addComponent(checkExistenceCheckBox)
.addGap(18, 18, 18)
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);

Expand Down Expand Up @@ -188,8 +195,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(pathsAndDirectoriesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pathsAndDirectoriesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(saveButton)
.addComponent(cancelButton))
Expand Down Expand Up @@ -228,6 +235,9 @@ private boolean unsavedChanges() {
if (!Config.get("prependingCommand").equals(prependingCommandTextField.getText())) {
return true;
}
if (Config.getBoolean("checkExistence") != checkExistenceCheckBox.isSelected()) {
return true;
}
return false;
}

Expand Down Expand Up @@ -262,6 +272,7 @@ private void save() {
Config.set("workingDirectory", workingDirectoryTextField.getText());
Config.set("pathFromWorkingDirToExec", pathFromWorkingDirToExecTextField.getText());
Config.set("prependingCommand", prependingCommandTextField.getText());
Config.setBoolean("checkExistence", checkExistenceCheckBox.isSelected());
try {
Config.save();
JOptionPane.showMessageDialog(this, "The configuration file has been saved.");
Expand All @@ -288,11 +299,11 @@ private void workingDirectoryBrowseButtonActionPerformed(java.awt.event.ActionEv

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JCheckBox checkExistenceCheckBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel pathFromWorkingDirToExecLabel;
private javax.swing.JLabel pathFromWorkingDirToExecLabel2;
private javax.swing.JTextField pathFromWorkingDirToExecTextField;
Expand Down
Loading

0 comments on commit 6d12157

Please sign in to comment.