use of org.fife.ui.rsyntaxtextarea.TextEditorPane in project lara-framework by specs-feup.
the class EditorConfigurer method buildTextArea.
/**
* Build a text area according to the type of the input file
*
* @param inputFile
* @param sourceTextArea
* @return
*/
public TextEditorPane buildTextArea(File inputFile, boolean isNew, SourceTextArea sourceTextArea) {
TextEditorPane textArea = new TextEditorPane();
sourceTextArea.setTextArea(textArea);
// textArea.setFont(textArea.getFont().deriveFont(12f));
if (theme != null) {
theme.apply(textArea);
}
textArea.setMarkAllHighlightColor(MARK_ALL_COLOR);
addPopupOptions(textArea);
// Add folding
textArea.setCodeFoldingEnabled(true);
textArea.setAntiAliasingEnabled(true);
loadFile(sourceTextArea, inputFile);
return textArea;
}
use of org.fife.ui.rsyntaxtextarea.TextEditorPane in project MeteoInfo by meteoinfo.
the class EditorDockable method runPythonScript.
/**
* Run Jython script
*
* @param jTextArea_Output
*/
public void runPythonScript(final JTextArea jTextArea_Output) {
SwingWorker worker = new SwingWorker<String, String>() {
PrintStream oout = System.out;
PrintStream oerr = System.err;
@Override
protected String doInBackground() throws Exception {
JTextAreaWriter writer = new JTextAreaWriter(jTextArea_Output);
JTextAreaPrintStream printStream = new JTextAreaPrintStream(System.out, jTextArea_Output);
jTextArea_Output.setText("");
// Create an instance of the PythonInterpreter
// Py.getSystemState().setdefaultencoding("utf-8");
// UPythonInterpreter interp = new UPythonInterpreter();
PythonInterpreter interp = new PythonInterpreter();
interp.setOut(writer);
interp.setErr(writer);
System.setOut(printStream);
System.setErr(printStream);
// }
try {
interp.exec("import sys");
interp.set("milapp", EditorDockable.this.parent);
// interp.exec("sys.path.append('" + path + "')");
// interp.exec("import mipylib");
// interp.exec("from mipylib.miscript import *");
// interp.exec("from meteoinfo.numeric.JNumeric import *");
// interp.exec("mis = MeteoInfoScript()");
// interp.set("miapp", _parent);
// for (String jarfn : jarfns) {
// interp.exec("sys.path.append('" + jarfn + "')");
// }
} catch (Exception e) {
e.printStackTrace();
}
TextEditorPane textArea = getActiveTextArea();
// textArea.setEncoding(fn);
String code = textArea.getText();
// if (code.contains("coding=utf-8")){
// code = code.replace("coding=utf-8", "coding = utf-8");
// }
String encoding = EncodingUtil.findEncoding(code);
if (encoding != null) {
try {
interp.execfile(new ByteArrayInputStream(code.getBytes(encoding)));
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
interp.execfile(new ByteArrayInputStream(code.getBytes()));
} catch (Exception e) {
e.printStackTrace();
}
}
return "";
}
@Override
protected void done() {
System.setOut(oout);
System.setErr(oerr);
}
};
worker.execute();
}
use of org.fife.ui.rsyntaxtextarea.TextEditorPane in project lara-framework by specs-feup.
the class OutlinePanel method selectionHandler.
private void selectionHandler(ListSelectionEvent e) {
// if (listModel.isEmpty()) {
// return;
// }
OutlineElement element = list.getSelectedValue();
if (element == null) {
return;
}
int line = element.getLine();
try {
TextEditorPane laraTextArea = editor.getTabsContainer().getCurrentTab().getTextArea();
laraTextArea.setCaretPosition(laraTextArea.getLineStartOffset(line - 1));
} catch (BadLocationException e1) {
}
}
use of org.fife.ui.rsyntaxtextarea.TextEditorPane in project lara-framework by specs-feup.
the class EditorConfigurer method setLaraTextArea.
public static void setLaraTextArea(SourceTextArea sourceTextArea) {
TextEditorPane textArea = sourceTextArea.getTextArea();
textArea.setSyntaxEditingStyle(TextEditorDemo.LARA_STYLE_KEY);
CompletionProvider provider = EditorConfigurer.createCompletionProvider();
AutoCompletion ac = new AutoCompletion(provider);
ac.install(textArea);
textArea.clearParsers();
EditorParser parser = new EditorParser();
textArea.addParser(parser);
// adds a list of aspects to the aspect list pane whenever a parsing is performed
parser.addListener(sourceTextArea::outlineAstListener);
}
use of org.fife.ui.rsyntaxtextarea.TextEditorPane in project myrobotlab by MyRobotLab.
the class ArduinoGui method addMrlCommPanel.
public void addMrlCommPanel() {
JPanel uploadPanel = new JPanel(new BorderLayout());
String pathToMrlComm = null;
String mrlIno = null;
try {
pathToMrlComm = "resource/Arduino/MrlComm/MrlComm.ino";
mrlIno = FileIO.toString(pathToMrlComm);
} catch (Exception e) {
}
try {
if (mrlIno == null) {
pathToMrlComm = "src/resource/Arduino/MrlComm/MrlComm.ino";
mrlIno = FileIO.toString(pathToMrlComm);
}
} catch (Exception e) {
}
GridBagConstraints gc = new GridBagConstraints();
gc.gridx = 0;
gc.gridy = 0;
JPanel top = new JPanel(new GridBagLayout());
top.add(new JLabel("Arduino IDE Path "), gc);
gc.gridx++;
top.add(arduinoPath, gc);
gc.gridx++;
if (chooser == null) {
chooser = new FileChooser("browse", arduinoPath);
chooser.filterDirsOnly();
}
top.add(chooser, gc);
gc.gridx++;
top.add(openMrlComm, gc);
gc.gridx++;
top.add(uploadMrlComm, gc);
gc.gridx++;
gc.gridx = 0;
gc.gridy = 1;
gc.gridwidth = 2;
top.add(new JLabel("MrlComm.ino location "), gc);
gc.gridx += 2;
top.add(new JLabel(pathToMrlComm), gc);
uploadPanel.add(top, BorderLayout.NORTH);
editor = new TextEditorPane();
// editor.setPreferredSize(new Dimension(500, 400));
editor.setText(mrlIno);
editor.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS);
editor.setCodeFoldingEnabled(true);
editor.setAntiAliasingEnabled(true);
editor.setEnabled(false);
editor.setReadOnly(true);
RTextScrollPane pane = new RTextScrollPane(editor);
pane.setPreferredSize(new Dimension(500, 400));
uploadPanel.add(pane, BorderLayout.CENTER);
JScrollPane pane2 = new JScrollPane(uploadResults);
uploadPanel.add(pane2, BorderLayout.SOUTH);
localTabs.addTab("upload", uploadPanel);
}
Aggregations