Skip to content

Commit 6d12157

Browse files
committed
Made it possible to run programs in Java by adding (1) option to skip checking existence of executable file and (2) instructions on Java configuration.
1 parent abee22f commit 6d12157

File tree

5 files changed

+98
-65
lines changed

5 files changed

+98
-65
lines changed

Hightail/src/org/hightail/Config.java

+9
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ static protected void fillInUnsetValuesWithDefaults() {
3333
setIfUnset("pathFromWorkingDirToExec", "%P.exe");
3434
// TODO: if under Unix, this better be "%L"
3535
setIfUnset("prependingCommand", "");
36+
setIfUnset("checkExistence", "1");
3637
}
3738

3839
static public boolean load() {
@@ -57,4 +58,12 @@ static public void save() throws IOException {
5758
static public boolean isPrependingCommandNonempty() {
5859
return !Config.get("prependingCommand").trim().isEmpty();
5960
}
61+
62+
public static boolean getBoolean(String key) {
63+
return !get(key).equals("0");
64+
}
65+
66+
public static void setBoolean(String key, boolean value) {
67+
set(key, value ? "1" : "0");
68+
}
6069
}

Hightail/src/org/hightail/ui/ConfigJDialog.form

+26-20
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22

3-
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
3+
<Form version="1.8" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
44
<Properties>
55
<Property name="defaultCloseOperation" type="int" value="0"/>
66
<Property name="title" type="java.lang.String" value="Settings"/>
77
</Properties>
88
<SyntheticProperties>
99
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
10-
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
1110
</SyntheticProperties>
1211
<Events>
1312
<EventHandler event="windowClosing" listener="java.awt.event.WindowListener" parameters="java.awt.event.WindowEvent" handler="formWindowClosing"/>
@@ -45,8 +44,8 @@
4544
<Group type="103" groupAlignment="0" attributes="0">
4645
<Group type="102" alignment="0" attributes="0">
4746
<EmptySpace max="-2" attributes="0"/>
48-
<Component id="pathsAndDirectoriesPanel" max="32767" attributes="0"/>
49-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
47+
<Component id="pathsAndDirectoriesPanel" min="-2" max="-2" attributes="0"/>
48+
<EmptySpace max="32767" attributes="0"/>
5049
<Group type="103" groupAlignment="3" attributes="0">
5150
<Component id="saveButton" alignment="3" min="-2" max="-2" attributes="0"/>
5251
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
@@ -85,20 +84,20 @@
8584
<EmptySpace min="-2" pref="10" max="-2" attributes="0"/>
8685
<Component id="pathFromWorkingDirToExecTextField" max="32767" attributes="0"/>
8786
</Group>
88-
<Component id="jSeparator2" alignment="0" max="32767" attributes="0"/>
89-
<Component id="jSeparator1" max="32767" attributes="0"/>
90-
<Group type="102" alignment="0" attributes="0">
91-
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
92-
<EmptySpace max="-2" attributes="0"/>
93-
<Component id="prependingCommandTextField" max="32767" attributes="0"/>
94-
</Group>
87+
<Component id="checkExistenceCheckBox" alignment="0" max="32767" attributes="0"/>
9588
<Group type="102" attributes="0">
9689
<Group type="103" groupAlignment="0" attributes="0">
9790
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
9891
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
92+
<Group type="102" alignment="0" attributes="0">
93+
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
94+
<EmptySpace type="unrelated" max="-2" attributes="0"/>
95+
<Component id="prependingCommandTextField" min="-2" pref="329" max="-2" attributes="0"/>
96+
</Group>
9997
</Group>
10098
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
10199
</Group>
100+
<Component id="jLabel4" alignment="0" pref="0" max="32767" attributes="0"/>
102101
</Group>
103102
<EmptySpace max="-2" attributes="0"/>
104103
</Group>
@@ -115,24 +114,24 @@
115114
<Component id="workingDirectoryBrowseButton" alignment="3" min="-2" max="-2" attributes="0"/>
116115
<Component id="workingDirectoryLabel" alignment="3" min="-2" max="-2" attributes="0"/>
117116
</Group>
118-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
119-
<Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/>
120-
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
117+
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
121118
<Group type="103" groupAlignment="3" attributes="0">
122119
<Component id="pathFromWorkingDirToExecLabel" alignment="3" min="-2" max="-2" attributes="0"/>
123120
<Component id="pathFromWorkingDirToExecTextField" alignment="3" min="-2" max="-2" attributes="0"/>
124121
</Group>
125122
<EmptySpace max="-2" attributes="0"/>
126123
<Component id="pathFromWorkingDirToExecLabel2" min="-2" max="-2" attributes="0"/>
127-
<EmptySpace type="unrelated" max="-2" attributes="0"/>
128-
<Component id="jSeparator2" min="-2" pref="10" max="-2" attributes="0"/>
129-
<EmptySpace max="-2" attributes="0"/>
124+
<EmptySpace type="separate" max="-2" attributes="0"/>
130125
<Group type="103" groupAlignment="3" attributes="0">
131126
<Component id="prependingCommandTextField" alignment="3" min="-2" max="-2" attributes="0"/>
132127
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
133128
</Group>
134129
<EmptySpace max="-2" attributes="0"/>
135130
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
131+
<EmptySpace type="separate" max="-2" attributes="0"/>
132+
<Component id="checkExistenceCheckBox" min="-2" max="-2" attributes="0"/>
133+
<EmptySpace type="separate" max="-2" attributes="0"/>
134+
<Component id="jLabel4" min="-2" pref="92" max="-2" attributes="0"/>
136135
<EmptySpace max="32767" attributes="0"/>
137136
</Group>
138137
</Group>
@@ -181,14 +180,21 @@
181180
</Component>
182181
<Component class="javax.swing.JLabel" name="jLabel3">
183182
<Properties>
184-
<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;"/>
183+
<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;"/>
185184
</Properties>
186185
</Component>
187186
<Component class="javax.swing.JTextField" name="prependingCommandTextField">
188187
</Component>
189-
<Component class="javax.swing.JSeparator" name="jSeparator2">
188+
<Component class="javax.swing.JCheckBox" name="checkExistenceCheckBox">
189+
<Properties>
190+
<Property name="selected" type="boolean" value="true"/>
191+
<Property name="text" type="java.lang.String" value="Check whether executable file exists before execution"/>
192+
</Properties>
190193
</Component>
191-
<Component class="javax.swing.JSeparator" name="jSeparator1">
194+
<Component class="javax.swing.JLabel" name="jLabel4">
195+
<Properties>
196+
<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"/>
197+
</Properties>
192198
</Component>
193199
</SubComponents>
194200
</Container>

Hightail/src/org/hightail/ui/ConfigJDialog.java

+32-21
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public ConfigJDialog(JFrame parent) {
3939
pathFromWorkingDirToExecTextField.setText(Config.get("pathFromWorkingDirToExec"));
4040

4141
prependingCommandTextField.setText(Config.get("prependingCommand"));
42+
43+
checkExistenceCheckBox.setSelected(Config.getBoolean("checkExistence"));
4244
}
4345

4446
/** This method is called from within the constructor to
@@ -61,8 +63,8 @@ private void initComponents() {
6163
jLabel2 = new javax.swing.JLabel();
6264
jLabel3 = new javax.swing.JLabel();
6365
prependingCommandTextField = new javax.swing.JTextField();
64-
jSeparator2 = new javax.swing.JSeparator();
65-
jSeparator1 = new javax.swing.JSeparator();
66+
checkExistenceCheckBox = new javax.swing.JCheckBox();
67+
jLabel4 = new javax.swing.JLabel();
6668
saveButton = new javax.swing.JButton();
6769
cancelButton = new javax.swing.JButton();
6870

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

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

97-
jLabel3.setText("Leave it empty for C++ (i.e. if the executable is standalone). Nonempty examples: \"java\", \"python\"");
99+
jLabel3.setText("Leave it empty for C++ (i.e. if the executable is standalone). Nonempty example: \"python\"");
100+
101+
checkExistenceCheckBox.setSelected(true);
102+
checkExistenceCheckBox.setText("Check whether executable file exists before execution");
103+
104+
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\".");
98105

99106
javax.swing.GroupLayout pathsAndDirectoriesPanelLayout = new javax.swing.GroupLayout(pathsAndDirectoriesPanel);
100107
pathsAndDirectoriesPanel.setLayout(pathsAndDirectoriesPanelLayout);
@@ -114,17 +121,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
114121
.addComponent(pathFromWorkingDirToExecLabel)
115122
.addGap(10, 10, 10)
116123
.addComponent(pathFromWorkingDirToExecTextField))
117-
.addComponent(jSeparator2)
118-
.addComponent(jSeparator1)
119-
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
120-
.addComponent(jLabel2)
121-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
122-
.addComponent(prependingCommandTextField))
124+
.addComponent(checkExistenceCheckBox, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
123125
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
124126
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
125127
.addComponent(jLabel1)
126-
.addComponent(jLabel3))
127-
.addGap(0, 0, Short.MAX_VALUE)))
128+
.addComponent(jLabel3)
129+
.addGroup(pathsAndDirectoriesPanelLayout.createSequentialGroup()
130+
.addComponent(jLabel2)
131+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
132+
.addComponent(prependingCommandTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 329, javax.swing.GroupLayout.PREFERRED_SIZE)))
133+
.addGap(0, 0, Short.MAX_VALUE))
134+
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
128135
.addContainerGap())
129136
);
130137
pathsAndDirectoriesPanelLayout.setVerticalGroup(
@@ -137,22 +144,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
137144
.addComponent(workingDirectoryTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
138145
.addComponent(workingDirectoryBrowseButton)
139146
.addComponent(workingDirectoryLabel))
140-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
141-
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
142-
.addGap(1, 1, 1)
147+
.addGap(18, 18, 18)
143148
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
144149
.addComponent(pathFromWorkingDirToExecLabel)
145150
.addComponent(pathFromWorkingDirToExecTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
146151
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
147152
.addComponent(pathFromWorkingDirToExecLabel2)
148-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
149-
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
150-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
153+
.addGap(18, 18, 18)
151154
.addGroup(pathsAndDirectoriesPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
152155
.addComponent(prependingCommandTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
153156
.addComponent(jLabel2))
154157
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
155158
.addComponent(jLabel3)
159+
.addGap(18, 18, 18)
160+
.addComponent(checkExistenceCheckBox)
161+
.addGap(18, 18, 18)
162+
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
156163
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
157164
);
158165

@@ -188,8 +195,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
188195
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
189196
.addGroup(layout.createSequentialGroup()
190197
.addContainerGap()
191-
.addComponent(pathsAndDirectoriesPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
192-
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
198+
.addComponent(pathsAndDirectoriesPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
199+
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
193200
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
194201
.addComponent(saveButton)
195202
.addComponent(cancelButton))
@@ -228,6 +235,9 @@ private boolean unsavedChanges() {
228235
if (!Config.get("prependingCommand").equals(prependingCommandTextField.getText())) {
229236
return true;
230237
}
238+
if (Config.getBoolean("checkExistence") != checkExistenceCheckBox.isSelected()) {
239+
return true;
240+
}
231241
return false;
232242
}
233243

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

289300
// Variables declaration - do not modify//GEN-BEGIN:variables
290301
private javax.swing.JButton cancelButton;
302+
private javax.swing.JCheckBox checkExistenceCheckBox;
291303
private javax.swing.JLabel jLabel1;
292304
private javax.swing.JLabel jLabel2;
293305
private javax.swing.JLabel jLabel3;
294-
private javax.swing.JSeparator jSeparator1;
295-
private javax.swing.JSeparator jSeparator2;
306+
private javax.swing.JLabel jLabel4;
296307
private javax.swing.JLabel pathFromWorkingDirToExecLabel;
297308
private javax.swing.JLabel pathFromWorkingDirToExecLabel2;
298309
private javax.swing.JTextField pathFromWorkingDirToExecTextField;

0 commit comments

Comments
 (0)