diff --git a/src/main/java/info/istlab/IoTP/Editor.java b/src/main/java/info/istlab/IoTP/Editor.java index 9702068..9f7d50d 100644 --- a/src/main/java/info/istlab/IoTP/Editor.java +++ b/src/main/java/info/istlab/IoTP/Editor.java @@ -61,23 +61,26 @@ textArea.setTabSize(2); textArea.setTabsEmulated(true); - try { - setTitle(file.getCanonicalPath().replaceAll(App.workingDir+"/", "")); + String d = new String(App.workingDir); + if (d.contains("\\")) { + d = d.replace("\\", "\\\\"); + } + setTitle(file.getCanonicalPath().replaceAll(d + File.separator, "")); } catch (IOException e) { e.printStackTrace(); } setSize(new Dimension(800, 400));// pack(); - if (Launcher.theapp != null){ + if (Launcher.theapp != null) { Point launchP = Launcher.theapp.getLocationOnScreen(); - setLocation(launchP.x + Launcher.theapp.getWidth(), launchP.y ); + setLocation(launchP.x + Launcher.theapp.getWidth(), launchP.y); } // setLocationRelativeTo(Launcher.theapp); setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE); load(); topP = new JPanel(); - topP.setLayout(new FlowLayout(FlowLayout.CENTER, 1,2)); + topP.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 2)); topP.add(new JLabel("size:")); fontSizeJS = new JSlider(10, 50, 16); topP.add(fontSizeJS); @@ -125,21 +128,21 @@ // comlineOption = new JTextField("arg1 arg2 ...", 15); // comlineOption.setForeground(Color.GRAY); // comlineOption.addFocusListener(new FocusListener() { - // @Override - // public void focusGained(FocusEvent e) { - // if (comlineOption.getText().equals("arg1 arg2 ...")) { - // comlineOption.setText(""); - // comlineOption.setForeground(Color.BLACK); - // } - // } + // @Override + // public void focusGained(FocusEvent e) { + // if (comlineOption.getText().equals("arg1 arg2 ...")) { + // comlineOption.setText(""); + // comlineOption.setForeground(Color.BLACK); + // } + // } - // @Override - // public void focusLost(FocusEvent e) { - // if (comlineOption.getText().isEmpty()) { - // comlineOption.setForeground(Color.GRAY); - // comlineOption.setText("arg1 arg2 ..."); - // } - // } + // @Override + // public void focusLost(FocusEvent e) { + // if (comlineOption.getText().isEmpty()) { + // comlineOption.setForeground(Color.GRAY); + // comlineOption.setText("arg1 arg2 ..."); + // } + // } // }); // topP.add(comlineOption); @@ -156,7 +159,7 @@ lastOpened = this; } - private void fixIndent(){ + private void fixIndent() { String src = textArea.getText(); System.out.println(src); String out = ""; @@ -168,7 +171,8 @@ // textArea.setText(out); // System.out.println(out); } - public static String loadFile(File f){ + + public static String loadFile(File f) { InputStream is = null; try { is = new FileInputStream(f); @@ -193,6 +197,7 @@ return sb.toString(); } + public void load() { textArea.setText(loadFile(file)); } @@ -219,8 +224,8 @@ load(); } else if (e.getActionCommand().equals("Run")) { runner.startstop(); - // } else if (e.getActionCommand().equals("Compile")) { - // new ScriptRunner("Upload.sh", execB, file.getName()).startstop(); + // } else if (e.getActionCommand().equals("Compile")) { + // new ScriptRunner("Upload.sh", execB, file.getName()).startstop(); } else if (e.getActionCommand().equals("Upload")) { save(); new ScriptRunner("Upload.sh", execB, file.getName()).startstop();