mirror of https://github.com/xfarrow/guify.git
update
This commit is contained in:
parent
1cfba5fbb3
commit
2050c061db
|
@ -11,6 +11,7 @@ public class NotepadController {
|
|||
private INotepadFrame notepadFrame = null;
|
||||
private FindAndReplaceController myFindAndReplaceController;
|
||||
private boolean unsaved = false;
|
||||
private String initialText = null;
|
||||
|
||||
public boolean isUnsaved() {
|
||||
return unsaved;
|
||||
|
@ -24,12 +25,15 @@ public class NotepadController {
|
|||
return this.filePath;
|
||||
}
|
||||
|
||||
public String getInitialText() {
|
||||
return this.initialText;
|
||||
}
|
||||
|
||||
public NotepadController(String filePath) {
|
||||
this.filePath = filePath;
|
||||
String contentToDisplay = SshEngine.readFile(filePath);
|
||||
initialText = SshEngine.readFile(filePath);
|
||||
try {
|
||||
notepadFrame = (INotepadFrame) JFrameFactory.createJFrame(IFrameFactory.NOTEPAD, this);
|
||||
notepadFrame.displayContent(contentToDisplay);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return;
|
||||
|
|
|
@ -31,9 +31,6 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||
private boolean jtextAreaShouldListenForChanges = true;
|
||||
private JTextArea textArea;
|
||||
|
||||
/**
|
||||
* Create the application.
|
||||
*/
|
||||
public Notepad(Object controller) {
|
||||
this.controller = (NotepadController) controller;
|
||||
setTitle(this.controller.getFilePath());
|
||||
|
@ -50,6 +47,7 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||
textArea.setTabSize(4);
|
||||
textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
|
||||
textArea.setCaretPosition(0);
|
||||
textArea.setText(((NotepadController)controller).getInitialText());
|
||||
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
|
@ -165,15 +163,4 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets text in the JTextArea without triggering
|
||||
* a text changed action
|
||||
*/
|
||||
public void displayContent(String content) {
|
||||
jtextAreaShouldListenForChanges = false;
|
||||
textArea.setText(content);
|
||||
jtextAreaShouldListenForChanges = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package views.interfaces;
|
|||
|
||||
public interface INotepadFrame {
|
||||
void setVisible(boolean visible);
|
||||
void displayContent(String content);
|
||||
int getX();
|
||||
int getY();
|
||||
int getWidth();
|
||||
|
|
Loading…
Reference in New Issue