mirror of
https://github.com/xfarrow/guify.git
synced 2025-06-05 22:09:25 +02:00
update
This commit is contained in:
@ -11,6 +11,7 @@ public class NotepadController {
|
|||||||
private INotepadFrame notepadFrame = null;
|
private INotepadFrame notepadFrame = null;
|
||||||
private FindAndReplaceController myFindAndReplaceController;
|
private FindAndReplaceController myFindAndReplaceController;
|
||||||
private boolean unsaved = false;
|
private boolean unsaved = false;
|
||||||
|
private String initialText = null;
|
||||||
|
|
||||||
public boolean isUnsaved() {
|
public boolean isUnsaved() {
|
||||||
return unsaved;
|
return unsaved;
|
||||||
@ -24,12 +25,15 @@ public class NotepadController {
|
|||||||
return this.filePath;
|
return this.filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInitialText() {
|
||||||
|
return this.initialText;
|
||||||
|
}
|
||||||
|
|
||||||
public NotepadController(String filePath) {
|
public NotepadController(String filePath) {
|
||||||
this.filePath = filePath;
|
this.filePath = filePath;
|
||||||
String contentToDisplay = SshEngine.readFile(filePath);
|
initialText = SshEngine.readFile(filePath);
|
||||||
try {
|
try {
|
||||||
notepadFrame = (INotepadFrame) JFrameFactory.createJFrame(IFrameFactory.NOTEPAD, this);
|
notepadFrame = (INotepadFrame) JFrameFactory.createJFrame(IFrameFactory.NOTEPAD, this);
|
||||||
notepadFrame.displayContent(contentToDisplay);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return;
|
return;
|
||||||
|
@ -31,9 +31,6 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||||||
private boolean jtextAreaShouldListenForChanges = true;
|
private boolean jtextAreaShouldListenForChanges = true;
|
||||||
private JTextArea textArea;
|
private JTextArea textArea;
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the application.
|
|
||||||
*/
|
|
||||||
public Notepad(Object controller) {
|
public Notepad(Object controller) {
|
||||||
this.controller = (NotepadController) controller;
|
this.controller = (NotepadController) controller;
|
||||||
setTitle(this.controller.getFilePath());
|
setTitle(this.controller.getFilePath());
|
||||||
@ -50,6 +47,7 @@ public class Notepad extends JFrame implements INotepadFrame {
|
|||||||
textArea.setTabSize(4);
|
textArea.setTabSize(4);
|
||||||
textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
|
textArea.setFont(new Font("Monospaced", Font.PLAIN, 14));
|
||||||
textArea.setCaretPosition(0);
|
textArea.setCaretPosition(0);
|
||||||
|
textArea.setText(((NotepadController)controller).getInitialText());
|
||||||
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
textArea.getDocument().addDocumentListener(new DocumentListener() {
|
||||||
@Override
|
@Override
|
||||||
public void insertUpdate(DocumentEvent e) {
|
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 {
|
public interface INotepadFrame {
|
||||||
void setVisible(boolean visible);
|
void setVisible(boolean visible);
|
||||||
void displayContent(String content);
|
|
||||||
int getX();
|
int getX();
|
||||||
int getY();
|
int getY();
|
||||||
int getWidth();
|
int getWidth();
|
||||||
|
Reference in New Issue
Block a user