Commit 1a2ce74c authored by Markus's avatar Markus
Browse files

Little bugs...

parent fc0ca16d
......@@ -3,7 +3,7 @@
<!--this file was created by Eclipse Runnable JAR Export Wizard-->
<!--ANT 1.7 is required -->
<target name="create_run_jar">
<delete file="./release/pseuCoCo-runnable"/>
<delete file="./release/pseuCoCo-runnable.jar"/>
<delete file="./release/PseucoIDE.jar"/>
<jar destfile="./release/PseucoIDE.jar" filesetmanifest="mergewithoutmain">
<manifest>
......
......@@ -22,4 +22,4 @@ mainAgent{
a1 = start m.countDutch (); // Ich lass einen Agenten los !
a2 = start countFrench (); // Ich lass einen Agenten los !
println ( " Beide zaehlen ! " ); // Das sollen alle wissen .
}
}
\ No newline at end of file
......@@ -246,7 +246,7 @@ public class GUI extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
File f = new File(Start.workspace+System.getProperty("file.separator")+currentProject+".pseuco");
if (!f.exists()) {
if (!f.exists() || currentProject.isEmpty()) {
JFileChooser fc = new JFileChooser(Start.workspace);
fc.setFileFilter(new FileFilter() {
@Override
......@@ -281,6 +281,7 @@ public class GUI extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
if (!checkCurrentProject()) return;
JFileChooser fc = new JFileChooser(Start.workspace);
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fc.setAcceptAllFileFilterUsed(false);
......@@ -304,12 +305,14 @@ public class GUI extends JFrame {
menuExport.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put((KeyStroke) action.getValue(Action.ACCELERATOR_KEY), "Export project");
helpItem(menuExport, "Export to java program (Ctrl+E)", "/resources/export");
}
private void runBtn() {
Action action = new AbstractAction() {
private static final long serialVersionUID = 1L;
@Override
public void actionPerformed(ActionEvent e) {
if (!checkCurrentProject()) return;
savePseuCo(Start.workspace+System.getProperty("file.separator")+currentProject+".pseuco");
Pseuco.run(Start.workspace+System.getProperty("file.separator")+currentProject+".pseuco");
}
......@@ -327,6 +330,7 @@ public class GUI extends JFrame {
@Override
public void actionPerformed(ActionEvent e) {
if (!checkCurrentProject()) return;
savePseuCo(Start.workspace+System.getProperty("file.separator")+currentProject+".pseuco");
Pseuco.debug(Start.workspace+System.getProperty("file.separator")+currentProject+".pseuco");
}
......@@ -716,28 +720,15 @@ public class GUI extends JFrame {
* @param path
*/
private void savePseuCo(String path) {
String in = input.getText().replaceAll("\\s", ""), tmp = "", line;
try {
if (!path.endsWith(".pseuco"))
path += ".pseuco";
BufferedReader reader = new BufferedReader(new FileReader(path));
while ((line = reader.readLine()) != null)
tmp += line;
reader.close();
tmp = tmp.replaceAll("\\s", "");
BufferedWriter writer = new BufferedWriter(new FileWriter(path));
writer.write(input.getText());
writer.close();
} catch (IOException e1) {
if (Start.debug) e1.printStackTrace();
} finally {
if (!in.equals(tmp)) {
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(path));
writer.write(input.getText());
writer.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
......@@ -756,7 +747,7 @@ public class GUI extends JFrame {
list.setSelectedValue(currentProject, true);
setTitle("PseuCo IDE "+Start.version+" - "+currentProject);
} catch (IOException | BadLocationException e2) {
if (Start.debug) e2.printStackTrace();
//if (Start.debug) e2.printStackTrace();
}
}
......@@ -789,4 +780,17 @@ public class GUI extends JFrame {
return false;
}
}
/**
* Checks if the current project exists.
* If not, it shows a warning to the user.
* @return true if the current project has been saved.
*/
protected boolean checkCurrentProject() {
if (! currentProject.isEmpty()) return true;
JOptionPane.showMessageDialog(this, "You have to save your file first, before you can compile it.", "Error", JOptionPane.INFORMATION_MESSAGE);
return false;
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment