Example usage for javax.swing.text DefaultEditorKit EndOfLineStringProperty

List of usage examples for javax.swing.text DefaultEditorKit EndOfLineStringProperty

Introduction

In this page you can find the example usage for javax.swing.text DefaultEditorKit EndOfLineStringProperty.

Prototype

String EndOfLineStringProperty

To view the source code for javax.swing.text DefaultEditorKit EndOfLineStringProperty.

Click Source Link

Document

When reading a document if a CRLF is encountered a property with this name is added and the value will be "\r\n".

Usage

From source file:org.wandora.application.gui.topicpanels.ProcessingTopicPanel.java

@Override
public void init() {
    Wandora wandora = Wandora.getWandora();
    if (options == null) {
        if (USE_LOCAL_OPTIONS) {
            options = new Options(wandora.getOptions());
        } else {/* w  ww  . j  a v  a2 s  . co  m*/
            options = wandora.getOptions();
        }
    }
    tm = wandora.getTopicMap();

    initComponents();
    this.addComponentListener(this);
    try {
        // JavaSyntaxKit syntaxKit = new JavaSyntaxKit();
        // syntaxKit.install(processingEditor);
        DefaultSyntaxKit.initKit();
        processingEditor.setContentType("text/java");
    } catch (Exception e) {
        e.printStackTrace();
    }

    /*
    EditorKit ek=processingEditor.getEditorKit();
    if(ek instanceof DefaultSyntaxKit){
    DefaultSyntaxKit sk=(DefaultSyntaxKit)ek;
    sk.setProperty("Action.parenthesis", null); 
    sk.setProperty("Action.brackets", null);
    sk.setProperty("Action.quotes", null);
    sk.setProperty("Action.double-quotes", null);
    sk.setProperty("Action.close-curly", null);
    }*/
    readOptions();

    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK);
    processingEditor.getInputMap().put(key, "saveOperation");
    Action saveOperation = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveCurrentSketch();
        }
    };
    processingEditor.getActionMap().put("saveOperation", saveOperation);
    processingEditor.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");

    innerPanel.addComponentListener(new ComponentListener() {
        @Override
        public void componentResized(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentMoved(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentShown(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }

        @Override
        public void componentHidden(ComponentEvent e) {
            revalidate();
            Wandora.getWandora().validate();
        }
    });

    if (currentSketch != null) {
        processingEditor.setText(currentSketch);
    } else {
        processingEditor.setText(defaultMessage);
    }

    FileNameExtensionFilter sketchFilter = new FileNameExtensionFilter("Processing sketch files", "sketch");
    fc = new JFileChooser();
    fc.setFileFilter(sketchFilter);
    fc.setCurrentDirectory(new File(sketchPath));
}

From source file:org.wandora.application.gui.topicpanels.RTopicPanel.java

@Override
public void init() {
    Wandora wandora = Wandora.getWandora();
    tm = wandora.getTopicMap();//from ww  w .  ja  va 2s .c om

    if (options == null) {
        if (USE_LOCAL_OPTIONS) {
            options = new Options(wandora.getOptions());
        } else {
            options = wandora.getOptions();
        }
    }

    initComponents();
    this.addComponentListener(this);

    DefaultSyntaxKit.initKit();
    rEditor.setContentType("text/plain");

    KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK);
    rEditor.getInputMap().put(key, "saveOperation");
    Action saveOperation = new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            saveScript();
        }
    };
    rEditor.getActionMap().put("saveOperation", saveOperation);
    rEditor.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, "\n");

    rBridge = RBridge.getRBridge();
    rBridge.addRBridgeListener(this);

    fc = new JFileChooser();
    fc.setCurrentDirectory(new File(scriptPath));

    readOptions();
    if (currentScript != null) {
        rEditor.setText(currentScript);
    } else {
        rEditor.setText(defaultMessage);
    }
}