use of javax.swing.JEditorPane in project suite by stupidsing.
the class EditorController method paste.
public void paste() {
JEditorPane editor = view.getEditor();
String orig = editor.getText();
String pasteText = new ClipboardUtil().getClipboardText();
if (pasteText != null) {
int s = editor.getSelectionStart();
int e = editor.getSelectionEnd();
editor.setText(orig.substring(0, s) + pasteText + orig.substring(e, orig.length()));
editor.setCaretPosition(s + pasteText.length());
}
}
use of javax.swing.JEditorPane in project suite by stupidsing.
the class EditorController method newFile.
public void newFile() {
confirmSave(() -> {
JEditorPane editor = view.getEditor();
editor.setText("");
editor.requestFocusInWindow();
model.changeFilename("pad");
model.changeIsModified(false);
});
}
use of javax.swing.JEditorPane in project suite by stupidsing.
the class EditorController method funFilter.
public void funFilter() {
boolean isDo = false;
JFrame frame = view.getFrame();
JEditorPane editor = view.getEditor();
String fun = //
JOptionPane.showInputDialog(//
frame, "Enter " + (isDo ? "do " : "") + "function:", "Functional Filter", JOptionPane.PLAIN_MESSAGE);
editor.setText(Suite.evaluateFilterFun(fun, editor.getText(), false, false));
}
use of javax.swing.JEditorPane in project suite by stupidsing.
the class EditorView method run.
public JFrame run(EditorController controller, String title) {
JTextField searchTextField = this.searchTextField = applyDefaults(new JTextField(32));
DefaultListModel<String> listModel = this.listModel = new DefaultListModel<>();
listModel.addElement("<Empty>");
JList<String> searchList = this.searchList = applyDefaults(new JList<>(listModel));
searchList.setFont(sansFont);
JLabel rightLabel = this.rightLabel = applyDefaults(new JLabel("Right"));
rightLabel.setVisible(false);
JTextField filenameTextField = this.filenameTextField = applyDefaults(new JTextField("pad"));
filenameTextField.setVisible(false);
JTextArea messageTextArea = this.messageTextArea = applyDefaults(new JTextArea("Bottom"));
messageTextArea.setEditable(false);
messageTextArea.setRows(12);
JScrollPane messageScrollPane = this.messageScrollPane = newScrollPane(messageTextArea);
messageScrollPane.setVisible(false);
JEditorPane editor = this.editor = applyDefaults(new EditorPane(model));
JScrollPane editorScrollPane = newScrollPane(editor);
JButton okButton = applyDefaults(new JButton("OK"));
Listen.mouseClicked(okButton).wire(controller::evaluate);
JFrame frame = this.frame = new JFrame(title);
frame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
frame.setJMenuBar(newMenuBar(controller));
frame.setSize(new Dimension(windowWidth, windowHeight));
frame.setVisible(true);
int u = 64, u3 = u * 3;
lay = new LayoutCalculator(frame.getContentPane());
layout = //
lay.boxh(lay.ex(u, //
lay.boxv(//
lay.fx(24, lay.c(searchTextField)), //
lay.ex(u, lay.c(searchList)))), lay.ex(u3, //
lay.boxv(//
lay.fx(24, lay.c(filenameTextField)), //
lay.ex(u3, lay.c(editorScrollPane)), //
lay.fx(8, lay.b()), lay.fx(24, //
lay.boxh(//
lay.ex(u3, lay.b()), //
lay.fx(64, lay.c(okButton)), //
lay.ex(u3, lay.b()))), //
lay.ex(u, lay.c(messageScrollPane)))), lay.ex(u, lay.c(rightLabel)));
Listen.action(searchTextField).wire(event -> controller.searchFiles(model.searchText()));
Listen.componentResized(frame).wire(this::refresh);
Listen.documentChanged(filenameTextField).wire(event -> model.changeFilename(filenameTextField.getText()));
Listen.documentChanged(searchTextField).wire(event -> model.changeSearchText(searchTextField.getText()));
Listen.keyPressed(searchTextField, KeyEvent.VK_DOWN).wire(event -> controller.downToSearchList());
Listen.keyPressed(searchList, KeyEvent.VK_ENTER).wire(event -> controller.selectList(searchList.getSelectedValue()));
Listen.mouseDoubleClicked(searchList).wire(event -> controller.selectList(searchList.getSelectedValue()));
Listen.windowClosing(frame).wire(controller::close);
model.filenameChanged().wire(filename -> {
filenameTextField.setText(filename);
repaint();
});
model.isModifiedChanged().wire(this::repaint);
controller.newFile();
refresh();
editor.requestFocusInWindow();
return frame;
}
use of javax.swing.JEditorPane in project knime-core by knime.
the class PairedTTestNodeView method createMainPanel.
/**
* The content of the view.
*/
private JPanel createMainPanel() {
JPanel p = new JPanel(new GridBagLayout());
GridBagConstraints c = createGridBagConstraints();
c.gridwidth = 2;
m_headerPane = new JEditorPane("text/html", "");
m_headerPane.setEditable(false);
p.add(m_headerPane, c);
c.gridwidth = 1;
c.gridy++;
c.gridx = 0;
c.gridwidth = 2;
m_descrStatPane = new JEditorPane("text/html", "");
m_descrStatPane.setEditable(false);
p.add(m_descrStatPane, c);
c.gridy++;
c.gridx = 0;
c.gridwidth = 2;
m_statPane = new JEditorPane("text/html", "");
m_statPane.setEditable(false);
p.add(m_statPane, c);
c.gridy++;
c.weighty = 1;
JPanel foo = new JPanel();
foo.setBackground(Color.white);
p.add(foo, c);
return p;
}
Aggregations