use of org.fife.ui.rtextarea.RTextScrollPane in project bytecode-viewer by Konloch.
the class FileViewer method setContents.
public void setContents() {
String name = this.name.toLowerCase();
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
field.requestFocus();
}
BytecodeViewer.checkHotKey(e);
}
@Override
public void keyReleased(KeyEvent arg0) {
}
@Override
public void keyTyped(KeyEvent arg0) {
}
});
String contentsS = new String(contents);
if (!isPureAscii(contentsS)) {
if (name.endsWith(".png") || name.endsWith(".jpg") || name.endsWith(".jpeg") || name.endsWith(".gif") || name.endsWith(".tif") || name.endsWith(".bmp")) {
canRefresh = true;
try {
//gifs fail cause of this
image = ImageIO.read(new ByteArrayInputStream(contents));
JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
panel2.add(label, BorderLayout.CENTER);
panel2.addMouseWheelListener(new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
int notches = e.getWheelRotation();
if (notches < 0) {
image = Scalr.resize(image, Scalr.Method.SPEED, image.getWidth() + 10, image.getHeight() + 10);
} else {
image = Scalr.resize(image, Scalr.Method.SPEED, image.getWidth() - 10, image.getHeight() - 10);
}
panel2.removeAll();
JLabel label = new JLabel("", new ImageIcon(image), JLabel.CENTER);
panel2.add(label, BorderLayout.CENTER);
panel2.updateUI();
}
});
return;
} catch (Exception e) {
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
}
} else {
JHexEditor hex = new JHexEditor(contents);
panel2.add(hex);
return;
}
}
if (name.endsWith(".xml") || contentsS.startsWith("<?xml") || contentsS.startsWith(("<xml"))) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
panelArea.setText(contentsS);
} else if (name.endsWith(".py") || name.endsWith(".python")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PYTHON);
panelArea.setText(contentsS);
} else if (name.endsWith(".rb") || name.endsWith(".ruby")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_RUBY);
panelArea.setText(contentsS);
} else if (name.endsWith(".java")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setText(contentsS);
} else if (name.endsWith(".html")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
panelArea.setText(contentsS);
} else if (name.endsWith(".css")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CSS);
panelArea.setText(contentsS);
} else if (name.endsWith(".properties") || name.endsWith(".mf") || name.endsWith(".sf")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE);
panelArea.setText(contentsS);
} else if (name.endsWith(".php") || contentsS.startsWith("<?php")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PHP);
panelArea.setText(contentsS);
} else if (name.endsWith(".js")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
panelArea.setText(contentsS);
} else if (name.endsWith(".bat")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_WINDOWS_BATCH);
panelArea.setText(contentsS);
} else if (name.endsWith(".sh")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL);
panelArea.setText(contentsS);
} else if (name.endsWith(".c")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_C);
panelArea.setText(contentsS);
} else if (name.endsWith(".cpp")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
panelArea.setText(contentsS);
} else if (name.endsWith(".scala")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SCALA);
panelArea.setText(contentsS);
} else if (name.endsWith(".clojure")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CLOJURE);
panelArea.setText(contentsS);
} else if (name.endsWith(".groovy")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_GROOVY);
panelArea.setText(contentsS);
} else if (name.endsWith(".lua")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_LUA);
panelArea.setText(contentsS);
} else if (name.endsWith(".sql")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
panelArea.setText(contentsS);
} else if (name.endsWith(".json")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSON);
panelArea.setText(contentsS);
} else if (name.endsWith(".jsp")) {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JSP);
panelArea.setText(contentsS);
} else {
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
panelArea.setText(contentsS);
}
panelArea.setCaretPosition(0);
scrollPane.setColumnHeaderView(panel);
panel2.add(scrollPane);
}
use of org.fife.ui.rtextarea.RTextScrollPane in project bytecode-viewer by Konloch.
the class PaneUpdaterThread method run.
public void run() {
try {
final byte[] b = BytecodeViewer.getClassBytes(viewer.container, viewer.cn.name + ".class");
if (decompiler != Decompiler.HEXCODE) {
RSyntaxTextArea panelArea = new RSyntaxTextArea();
panelArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
panelArea.setCodeFoldingEnabled(true);
panelArea.setAntiAliasingEnabled(true);
final RTextScrollPane scrollPane = new RTextScrollPane(panelArea);
panelArea.setText(decompiler.decompileClassNode(viewer.cn, b));
panelArea.setCaretPosition(0);
panelArea.setEditable(viewer.isPaneEditable(paneId));
panelArea.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if ((e.getKeyCode() == KeyEvent.VK_F) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
viewer.requestFocus(paneId);
}
BytecodeViewer.checkHotKey(e);
}
@Override
public void keyReleased(KeyEvent arg0) {
}
@Override
public void keyTyped(KeyEvent arg0) {
}
});
scrollPane.setColumnHeaderView(new JLabel(decompiler.getName() + " Decompiler - Editable: " + panelArea.isEditable()));
panelArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
target.add(scrollPane);
}
});
viewer.updatePane(paneId, panelArea, decompiler);
} else {
final JHexEditor hex = new JHexEditor(b);
hex.setFont(new Font(Font.MONOSPACED, Font.PLAIN, (int) BytecodeViewer.viewer.fontSpinner.getValue()));
SwingUtilities.invokeLater(new Runnable() {
public void run() {
target.add(hex);
}
});
}
} catch (Exception e) {
new ExceptionUI(e);
} finally {
viewer.resetDivider();
BytecodeViewer.viewer.setIcon(false);
if (button != null)
button.setEnabled(true);
}
}
use of org.fife.ui.rtextarea.RTextScrollPane in project logisim-evolution by reds-heig.
the class HdlContentEditor method configure.
private void configure(Project proj, HdlModel model) {
this.project = proj;
this.model = model;
this.model.addHdlModelListener(modelListener);
this.addWindowListener(frameListener);
JPanel buttonsPanel = new JPanel();
buttonsPanel.add(open);
buttonsPanel.add(save);
buttonsPanel.add(validate);
buttonsPanel.add(close);
open.addActionListener(frameListener);
save.addActionListener(frameListener);
close.addActionListener(frameListener);
validate.addActionListener(frameListener);
editor = new RSyntaxTextArea(ROWS, COLUMNS);
editor.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_DELPHI);
editor.setCodeFoldingEnabled(true);
editor.setAntiAliasingEnabled(true);
editor.getDocument().addDocumentListener(editorListener);
RTextScrollPane sp = new RTextScrollPane(editor);
sp.setFoldIndicatorEnabled(true);
add(sp, BorderLayout.CENTER);
add(buttonsPanel, BorderLayout.SOUTH);
LocaleManager.addLocaleListener(frameListener);
frameListener.localeChanged();
pack();
Dimension size = getSize();
Dimension screen = getToolkit().getScreenSize();
if (size.width > screen.width || size.height > screen.height) {
size.width = Math.min(size.width, screen.width);
size.height = Math.min(size.height, screen.height);
setSize(size);
}
}
use of org.fife.ui.rtextarea.RTextScrollPane in project zaproxy by zaproxy.
the class HttpPanelSyntaxHighlightTextArea method loadConfiguration.
public void loadConfiguration(String key, FileConfiguration fileConfiguration) {
setAntiAliasingEnabled(fileConfiguration.getBoolean(key + ANTI_ALIASING, this.getAntiAliasingEnabled()));
Component c = getParent();
if (c instanceof JViewport) {
c = c.getParent();
if (c instanceof RTextScrollPane) {
final RTextScrollPane scrollPane = (RTextScrollPane) c;
scrollPane.setLineNumbersEnabled(fileConfiguration.getBoolean(key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled()));
if (isCodeFoldingAllowed()) {
setCodeFoldingEnabled(fileConfiguration.getBoolean(key + CODE_FOLDING, this.isCodeFoldingEnabled()));
scrollPane.setFoldIndicatorEnabled(this.isCodeFoldingEnabled());
}
}
}
setLineWrap(fileConfiguration.getBoolean(key + WORD_WRAP, this.getLineWrap()));
setHighlightCurrentLine(fileConfiguration.getBoolean(key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine()));
setFadeCurrentLineHighlight(fileConfiguration.getBoolean(key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight()));
setWhitespaceVisible(fileConfiguration.getBoolean(key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible()));
setEOLMarkersVisible(fileConfiguration.getBoolean(key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible()));
setMarkOccurrences(fileConfiguration.getBoolean(key + MARK_OCCURRENCES, this.getMarkOccurrences()));
setRoundedSelectionEdges(fileConfiguration.getBoolean(key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges()));
setBracketMatchingEnabled(fileConfiguration.getBoolean(key + BRACKET_MATCHING, this.isBracketMatchingEnabled()));
setAnimateBracketMatching(fileConfiguration.getBoolean(key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching()));
}
use of org.fife.ui.rtextarea.RTextScrollPane in project zaproxy by zaproxy.
the class HttpPanelSyntaxHighlightTextArea method saveConfiguration.
public void saveConfiguration(String key, FileConfiguration fileConfiguration) {
fileConfiguration.setProperty(key + ANTI_ALIASING, this.getAntiAliasingEnabled());
Component c = getParent();
if (c instanceof JViewport) {
c = c.getParent();
if (c instanceof RTextScrollPane) {
final RTextScrollPane scrollPane = (RTextScrollPane) c;
fileConfiguration.setProperty(key + SHOW_LINE_NUMBERS, scrollPane.getLineNumbersEnabled());
if (isCodeFoldingAllowed()) {
fileConfiguration.setProperty(key + CODE_FOLDING, this.isCodeFoldingEnabled());
}
}
}
fileConfiguration.setProperty(key + WORD_WRAP, this.getLineWrap());
fileConfiguration.setProperty(key + HIGHLIGHT_CURRENT_LINE, this.getHighlightCurrentLine());
fileConfiguration.setProperty(key + FADE_CURRENT_HIGHLIGHT_LINE, this.getFadeCurrentLineHighlight());
fileConfiguration.setProperty(key + SHOW_WHITESPACE_CHARACTERS, this.isWhitespaceVisible());
fileConfiguration.setProperty(key + SHOW_NEWLINE_CHARACTERS, this.getEOLMarkersVisible());
fileConfiguration.setProperty(key + MARK_OCCURRENCES, this.getMarkOccurrences());
fileConfiguration.setProperty(key + ROUNDED_SELECTION_EDGES, this.getRoundedSelectionEdges());
fileConfiguration.setProperty(key + BRACKET_MATCHING, this.isBracketMatchingEnabled());
fileConfiguration.setProperty(key + ANIMATED_BRACKET_MATCHING, this.getAnimateBracketMatching());
}
Aggregations