Search in sources :

Example 21 with JEditorPane

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());
    }
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 22 with JEditorPane

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);
    });
}
Also used : JEditorPane(javax.swing.JEditorPane)

Example 23 with JEditorPane

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));
}
Also used : JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane)

Example 24 with JEditorPane

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;
}
Also used : JScrollPane(javax.swing.JScrollPane) JTextArea(javax.swing.JTextArea) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JTextField(javax.swing.JTextField) JFrame(javax.swing.JFrame) JEditorPane(javax.swing.JEditorPane) JList(javax.swing.JList) JEditorPane(javax.swing.JEditorPane)

Example 25 with JEditorPane

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;
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridBagLayout(java.awt.GridBagLayout) JEditorPane(javax.swing.JEditorPane)

Aggregations

JEditorPane (javax.swing.JEditorPane)60 JScrollPane (javax.swing.JScrollPane)22 Dimension (java.awt.Dimension)12 JPanel (javax.swing.JPanel)12 IOException (java.io.IOException)11 JButton (javax.swing.JButton)11 JLabel (javax.swing.JLabel)11 JFrame (javax.swing.JFrame)10 GridBagLayout (java.awt.GridBagLayout)9 GridBagConstraints (java.awt.GridBagConstraints)8 JDialog (javax.swing.JDialog)7 HyperlinkEvent (javax.swing.event.HyperlinkEvent)6 BorderLayout (java.awt.BorderLayout)5 JTextField (javax.swing.JTextField)5 HyperlinkListener (javax.swing.event.HyperlinkListener)5 StyledEditorKit (javax.swing.text.StyledEditorKit)5 JCheckBox (javax.swing.JCheckBox)4 JSplitPane (javax.swing.JSplitPane)4 JTree (javax.swing.JTree)4 Component (java.awt.Component)3