Search in sources :

Example 1 with FileChooser

use of org.myrobotlab.swing.widget.FileChooser 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);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) BorderLayout(java.awt.BorderLayout) GridBagLayout(java.awt.GridBagLayout) FileChooser(org.myrobotlab.swing.widget.FileChooser) JLabel(javax.swing.JLabel) TextEditorPane(org.fife.ui.rsyntaxtextarea.TextEditorPane) Dimension(java.awt.Dimension) RTextScrollPane(org.fife.ui.rtextarea.RTextScrollPane)

Aggregations

BorderLayout (java.awt.BorderLayout)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 TextEditorPane (org.fife.ui.rsyntaxtextarea.TextEditorPane)1 RTextScrollPane (org.fife.ui.rtextarea.RTextScrollPane)1 FileChooser (org.myrobotlab.swing.widget.FileChooser)1