Skip to content
Permalink
Browse files
remove deprecation/style warnings
  • Loading branch information
paulk-asert committed Apr 14, 2022
1 parent f8c4516 commit 7dafa709692f3e27461952c3b98df70ed01714f4
Showing 2 changed files with 25 additions and 25 deletions.
@@ -165,10 +165,10 @@ public ConsoleTextEditor() {
});
textEditor.setFont(new Font(defaultFamily, Font.PLAIN, fontSize));

setViewportView(new JPanel(new BorderLayout()) {{
add(numbersPanel, BorderLayout.WEST);
add(textEditor, BorderLayout.CENTER);
}});
JPanel view = new JPanel(new BorderLayout());
view.add(numbersPanel, BorderLayout.WEST);
view.add(textEditor, BorderLayout.CENTER);
setViewportView(view);

textEditor.setDragEnabled(editable);

@@ -211,26 +211,26 @@ public void changedUpdate(DocumentEvent documentEvent) {
doc.addDocumentListener(redoAction);

InputMap im = textEditor.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_MASK, false);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_Z, InputEvent.CTRL_DOWN_MASK, false);
im.put(ks, StructuredSyntaxResources.UNDO);
ActionMap am = textEditor.getActionMap();
am.put(StructuredSyntaxResources.UNDO, undoAction);

ks = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_MASK, false);
ks = KeyStroke.getKeyStroke(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK, false);
im.put(ks, StructuredSyntaxResources.REDO);
am.put(StructuredSyntaxResources.REDO, redoAction);

ks = KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_MASK, false);
ks = KeyStroke.getKeyStroke(KeyEvent.VK_P, InputEvent.CTRL_DOWN_MASK, false);
im.put(ks, StructuredSyntaxResources.PRINT);
am.put(StructuredSyntaxResources.PRINT, printAction);
}

public void setShowLineNumbers(boolean showLineNumbers) {
if (showLineNumbers) {
setViewportView(new JPanel(new BorderLayout()) {{
add(numbersPanel, BorderLayout.WEST);
add(textEditor, BorderLayout.CENTER);
}});
JPanel view = new JPanel(new BorderLayout());
view.add(numbersPanel, BorderLayout.WEST);
view.add(textEditor, BorderLayout.CENTER);
setViewportView(view);
} else {
setViewportView(textEditor);
}
@@ -251,9 +251,7 @@ public TextEditor getTextEditor() {

protected void initActions() {
ActionMap map = getActionMap();

PrintAction printAction = new PrintAction();
map.put(StructuredSyntaxResources.PRINT, printAction);
map.put(StructuredSyntaxResources.PRINT, new PrintAction());
}

private class PrintAction extends AbstractAction {
@@ -353,11 +351,11 @@ public Action getPrintAction() {
return printAction;
}

public void enableHighLighter(Class clazz) {
public void enableHighLighter(Class<? extends DocumentFilter> clazz) {
DefaultStyledDocument doc = (DefaultStyledDocument) textEditor.getDocument();

try {
DocumentFilter documentFilter = (DocumentFilter) clazz.getConstructor(doc.getClass()).newInstance(doc);
DocumentFilter documentFilter = clazz.getConstructor(doc.getClass()).newInstance(doc);
doc.setDocumentFilter(documentFilter);

disableMatchingHighlighter();
@@ -48,6 +48,7 @@
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@@ -70,6 +71,7 @@ public class TextEditor extends JTextPane implements Pageable, Printable {
public static final String FIND_PREVIOUS = "Find Previous";
public static final String REPLACE = "Replace...";
public static final String AUTO_INDENT = "AutoIndent";
public static final String DELETE = "delete";

private static final String TABBED_SPACES = " ";
private static final Pattern TAB_BACK_PATTERN =
@@ -136,7 +138,7 @@ public TextEditor(boolean tabsAsSpaces) {
* Creates a new instance of TextEditor
*/
public TextEditor(boolean tabsAsSpaces, boolean multiLineTab) {
this(multiLineTab, tabsAsSpaces, false);
this(tabsAsSpaces, multiLineTab, false);
}

/**
@@ -159,23 +161,23 @@ public TextEditor(boolean tabsAsSpaces, boolean multiLineTab, boolean unwrapped)
aMap = getActionMap();
InputMap iMap = getInputMap();
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0, false);
iMap.put(keyStroke, "delete");
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, KeyEvent.SHIFT_MASK, false);
iMap.put(keyStroke, "delete");
aMap.put("delete", action);
iMap.put(keyStroke, DELETE);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, InputEvent.SHIFT_DOWN_MASK, false);
iMap.put(keyStroke, DELETE);
aMap.put(DELETE, action);

// set all the actions
action = new FindAction();
aMap.put(FIND, action);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, KeyEvent.CTRL_MASK, false);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK, false);
iMap.put(keyStroke, FIND);

aMap.put(FIND_NEXT, FindReplaceUtility.FIND_ACTION);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0, false);
iMap.put(keyStroke, FIND_NEXT);

aMap.put(FIND_PREVIOUS, FindReplaceUtility.FIND_ACTION);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, KeyEvent.SHIFT_MASK, false);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_F3, InputEvent.SHIFT_DOWN_MASK, false);
iMap.put(keyStroke, FIND_PREVIOUS);

action = new TabAction();
@@ -185,12 +187,12 @@ public TextEditor(boolean tabsAsSpaces, boolean multiLineTab, boolean unwrapped)

action = new ShiftTabAction();
aMap.put("TextEditor-shiftTabAction", action);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK, false);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_DOWN_MASK, false);
iMap.put(keyStroke, "TextEditor-shiftTabAction");

action = new ReplaceAction();
getActionMap().put(REPLACE, action);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_H, KeyEvent.CTRL_MASK, false);
keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_H, InputEvent.CTRL_DOWN_MASK, false);
do {
iMap.remove(keyStroke);
iMap = iMap.getParent();

0 comments on commit 7dafa70

Please sign in to comment.