diff --git a/src/main/java/istlab/KisoJikken/Editor.java b/src/main/java/istlab/KisoJikken/Editor.java index be783cd..b6e93a3 100644 --- a/src/main/java/istlab/KisoJikken/Editor.java +++ b/src/main/java/istlab/KisoJikken/Editor.java @@ -52,6 +52,8 @@ textArea.setCodeFoldingEnabled(true); } else if (file.getName().endsWith(".sh")) { textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL); + } else if (file.getName().endsWith(".class")){ + textArea.setEditable(false); } getContentPane().add(new RTextScrollPane(textArea)); textArea.addKeyListener(this); diff --git a/src/main/java/istlab/KisoJikken/JCompiler.java b/src/main/java/istlab/KisoJikken/JCompiler.java index bab9659..7bf52af 100644 --- a/src/main/java/istlab/KisoJikken/JCompiler.java +++ b/src/main/java/istlab/KisoJikken/JCompiler.java @@ -27,16 +27,21 @@ @Override public void run() { - System.out.println("== コンパイル開始 =="); + // System.out.println("== コンパイル開始 =="); ProcessBuilder processBuilder = new ProcessBuilder("bash", "-c", "javac -encoding UTF-8 " + pkgname + "/*.java"); - System.out.println("> cd ~" + App.nwpsrc); - System.out.println("> javac -encoding UTF-8 " + pkgname + "/*.java"); + processBuilder.redirectErrorStream(true); + JTAConsole con = new JTAConsole("(Compile) javac "+pkgname+"/*.java"); + con.Systemoutprintln("== コンパイル開始 =="); + + con.Systemoutprintln("> cd ~" + App.nwpsrc); + con.Systemoutprintln("> javac -encoding UTF-8 " + pkgname + "/*.java"); // ProcessBuilder processBuilder = new ProcessBuilder("pwd"); processBuilder.directory(new File(App.userhome + App.nwpsrc)); - processBuilder.inheritIO(); + // processBuilder.inheritIO(); try { process = processBuilder.start(); + con.startBR(process); // BufferedReader reader = new BufferedReader(new // InputStreamReader(process.getInputStream())); // String line; @@ -47,7 +52,7 @@ } catch (IOException | InterruptedException e1) { e1.printStackTrace(); } - System.out.println("== コンパイル終了 =="); + con.Systemoutprintln("== コンパイル終了 =="); thread = null; } } diff --git a/src/main/java/istlab/KisoJikken/JExecutor.java b/src/main/java/istlab/KisoJikken/JExecutor.java index a7a2637..c657154 100644 --- a/src/main/java/istlab/KisoJikken/JExecutor.java +++ b/src/main/java/istlab/KisoJikken/JExecutor.java @@ -30,7 +30,7 @@ ProcessBuilder processBuilder = new ProcessBuilder("java", pkgname + "." + javafname); processBuilder.redirectErrorStream(true); - JTAConsole con = new JTAConsole(); + JTAConsole con = new JTAConsole("(Exec) java " + pkgname + "." + javafname); con.Systemoutprintln("== 実行開始 =="); con.Systemoutprintln("> cd ~" + App.nwpsrc); con.Systemoutprintln("> java " + pkgname + "." + javafname); diff --git a/src/main/java/istlab/KisoJikken/JTAConsole.java b/src/main/java/istlab/KisoJikken/JTAConsole.java index f43caac..9f96809 100644 --- a/src/main/java/istlab/KisoJikken/JTAConsole.java +++ b/src/main/java/istlab/KisoJikken/JTAConsole.java @@ -1,17 +1,22 @@ package istlab.KisoJikken; +import java.awt.Point; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.Stack; import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class JTAConsole extends JTextArea implements Runnable, WindowListener { + // static JTAConsole lastWindow; + // static Point lastActivePoint; + static Stack winStack = new Stack(); JFrame frame; Process process; Thread thread; @@ -20,15 +25,30 @@ // ProcessBuilder pb; // public JTAConsole(ProcessBuilder prob) { - public JTAConsole() { + public JTAConsole(String title) { // pb = prob; - frame = new JFrame(); + frame = new JFrame(title); frame.getContentPane().add(new JScrollPane(this)); frame.setSize(500, 200); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); frame.addWindowListener(this); + if (winStack.size()>0){ + JTAConsole last = winStack.peek(); + if (last.isVisible()){ + Point lastFrameP = last.frame.getLocationOnScreen(); + frame.setLocation(lastFrameP.x+470, lastFrameP.y); + } + } + // if (lastActivePoint != null){ + // frame.setLocation(lastActivePoint.x+500, lastActivePoint.y); + // } else if (lastWindow != null && lastWindow.isVisible()){ + // Point lastFrameP = lastWindow.frame.getLocationOnScreen(); + // frame.setLocation(lastFrameP.x+500, lastFrameP.y); + // } + // lastWindow = this; + winStack.push(this); } public void Systemoutprintln(String s) { @@ -50,7 +70,6 @@ } catch (IOException e) { e.printStackTrace(); } catch (InterruptedException e) { - // TODO Auto-generated catch block e.printStackTrace(); } @@ -82,50 +101,46 @@ } catch (IOException e) { e.printStackTrace(); } - JTAConsole con = new JTAConsole(); + JTAConsole con = new JTAConsole("Demo"); con.startBR(process); } @Override public void windowOpened(WindowEvent e) { - // TODO Auto-generated method stub } @Override public void windowClosing(WindowEvent e) { process.destroy(); - + winStack.remove(this); + setVisible(false); } @Override public void windowClosed(WindowEvent e) { - // TODO Auto-generated method stub } @Override public void windowIconified(WindowEvent e) { - // TODO Auto-generated method stub } @Override public void windowDeiconified(WindowEvent e) { - // TODO Auto-generated method stub } @Override public void windowActivated(WindowEvent e) { - // TODO Auto-generated method stub + // JTAConsole.lastActivePoint = frame.getLocationOnScreen(); } @Override public void windowDeactivated(WindowEvent e) { - // TODO Auto-generated method stub } }