terminotpad.MainFrame.java Source code

Java tutorial

Introduction

Here is the source code for terminotpad.MainFrame.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package terminotpad;

import java.awt.event.KeyEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.filechooser.FileFilter;
import org.fife.ui.autocomplete.AutoCompletion;
import org.fife.ui.autocomplete.BasicCompletion;
import org.fife.ui.autocomplete.CompletionProvider;
import org.fife.ui.autocomplete.DefaultCompletionProvider;
import org.fife.ui.autocomplete.ShorthandCompletion;
import org.fife.ui.rsyntaxtextarea.SyntaxConstants;
import org.json.simple.parser.ParseException;

/**
 *
 * @author bgc
 */
public class MainFrame extends JFrame implements DocumentListener {

    /**
     * Creates new form MainFrame
     */
    public MainFrame() {
        initComponents();
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
        rSyntax.setCodeFoldingEnabled(true);
        CompletionProvider provider = createCompletionProvider();
        AutoCompletion ac = new AutoCompletion(provider);
        ac.install(rSyntax);

    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings({ "unchecked", "Convert2Lambda" })
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPopup_complete = new javax.swing.JPopupMenu();
        jButton_stop = new javax.swing.JButton();
        jButton_rollback = new javax.swing.JButton();
        jButton_execute = new javax.swing.JButton();
        jButton_commit = new javax.swing.JButton();
        jTextPane_resultset = new javax.swing.JTextPane();
        jLabel_searchbar = new javax.swing.JLabel();
        jTextField_searchbar = new javax.swing.JTextField();
        jFileChooser2 = new javax.swing.JFileChooser();
        jScrollPane1 = new javax.swing.JScrollPane();
        rSyntax = new org.fife.ui.rsyntaxtextarea.RSyntaxTextArea();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenuFile = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItemQuit = new javax.swing.JMenuItem();
        jMenuEdit = new javax.swing.JMenu();
        jMenuItemOptions = new javax.swing.JMenuItem();
        jMenuLang = new javax.swing.JMenu();
        langSQL = new javax.swing.JMenuItem();
        langJAVA = new javax.swing.JMenuItem();
        langPHP = new javax.swing.JMenuItem();
        langHTML = new javax.swing.JMenuItem();
        langCSS = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("TermiNot'Pad - BETA");
        setMinimumSize(new java.awt.Dimension(710, 500));
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
        });

        jButton_stop.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/stop.png"))); // NOI18N
        jButton_stop.setText("Arrter");
        jButton_stop.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_stopActionPerformed(evt);
            }
        });

        jButton_rollback.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/cancel.png"))); // NOI18N
        jButton_rollback.setText("Rollback");
        jButton_rollback.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_rollbackActionPerformed(evt);
            }
        });

        jButton_execute.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/play.png"))); // NOI18N
        jButton_execute.setMnemonic(KeyEvent.VK_F1);
        jButton_execute.setText("Excuter");
        jButton_execute.setToolTipText("");
        jButton_execute.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_executeActionPerformed(evt);
            }
        });

        jButton_commit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/valid.png"))); // NOI18N
        jButton_commit.setText("Commit");
        jButton_commit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_commitActionPerformed(evt);
            }
        });

        jLabel_searchbar.setText("Rechercher");

        jTextField_searchbar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField_searchbarActionPerformed(evt);
            }
        });
        jTextField_searchbar.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                jTextField_searchbarPropertyChange(evt);
            }
        });
        jTextField_searchbar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jTextField_searchbarKeyPressed(evt);
            }
        });

        jFileChooser2.setControlButtonsAreShown(false);
        jFileChooser2.setCurrentDirectory(new java.io.File("F:\\Projets Java\\sql"));
        jFileChooser2.setName(""); // NOI18N
        jFileChooser2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jFileChooser2MouseClicked(evt);
            }
        });
        jFileChooser2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFileChooser2ActionPerformed(evt);
            }
        });

        rSyntax.setColumns(20);
        rSyntax.setRows(5);
        rSyntax.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                rSyntaxKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(rSyntax);

        jMenuFile.setText("Fichier");

        jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
                java.awt.event.InputEvent.CTRL_MASK));
        jMenuItem1.setText("Enregistrer");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItem1);

        jMenuItemQuit.setText("Quitter");
        jMenuItemQuit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemQuitActionPerformed(evt);
            }
        });
        jMenuFile.add(jMenuItemQuit);

        jMenuBar1.add(jMenuFile);

        jMenuEdit.setText("Edition");

        jMenuItemOptions.setText("Options");
        jMenuItemOptions.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItemOptionsActionPerformed(evt);
            }
        });
        jMenuEdit.add(jMenuItemOptions);

        jMenuBar1.add(jMenuEdit);

        jMenuLang.setText("Langage");

        langSQL.setText("SQL");
        langSQL.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                langSQLActionPerformed(evt);
            }
        });
        jMenuLang.add(langSQL);

        langJAVA.setText("JAVA");
        langJAVA.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                langJAVAActionPerformed(evt);
            }
        });
        jMenuLang.add(langJAVA);

        langPHP.setText("PHP");
        langPHP.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                langPHPActionPerformed(evt);
            }
        });
        jMenuLang.add(langPHP);

        langHTML.setText("HTML");
        langHTML.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                langHTMLActionPerformed(evt);
            }
        });
        jMenuLang.add(langHTML);

        langCSS.setText("CSS");
        langCSS.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                langCSSActionPerformed(evt);
            }
        });
        jMenuLang.add(langCSS);

        jMenuBar1.add(jMenuLang);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout
                        .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup().addComponent(jLabel_searchbar).addGap(18, 18, 18)
                                .addComponent(jTextField_searchbar, javax.swing.GroupLayout.PREFERRED_SIZE, 139,
                                        javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jFileChooser2, javax.swing.GroupLayout.PREFERRED_SIZE, 370,
                                javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED,
                                                javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jButton_execute).addGap(18, 18, 18).addComponent(jButton_stop)
                                        .addGap(18, 18, 18).addComponent(jButton_rollback).addGap(18, 18, 18)
                                        .addComponent(jButton_commit).addContainerGap())
                                .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jScrollPane1))))
                .addComponent(jTextPane_resultset));
        layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup().addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jButton_commit).addComponent(jButton_rollback)
                                        .addComponent(jButton_stop).addComponent(jButton_execute,
                                                javax.swing.GroupLayout.PREFERRED_SIZE, 35,
                                                javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(jLabel_searchbar).addComponent(jTextField_searchbar,
                                                javax.swing.GroupLayout.PREFERRED_SIZE,
                                                javax.swing.GroupLayout.DEFAULT_SIZE,
                                                javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jFileChooser2, javax.swing.GroupLayout.DEFAULT_SIZE, 356,
                                        Short.MAX_VALUE)
                                .addComponent(jScrollPane1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextPane_resultset, javax.swing.GroupLayout.PREFERRED_SIZE, 97,
                                javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap()));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_executeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_executeActionPerformed
        // TODO add your handling code here:
        jTextPane_resultset.setText("");

        String name = null;
        String request = rSyntax.getSelectedText();
        if (request == null) {
            request = "-- NO RESULT --";
        }
        String regex1 = "^select.*$";

        if (request.matches(regex1)) {
            System.out.println("C'est select : " + request);
            DbConnect c = new DbConnect();
            try {
                Connection cn = DbConnect.cConnect();
            } catch (IOException | ParseException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
            DbRequest rs = null;
            try {
                rs = new DbRequest();
            } catch (ParseException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
            ResultSet rsRequest = rs.selectRequest(request);
            try {
                while (rsRequest.next()) {
                    int userID = rsRequest.getInt(1);
                    name = rsRequest.getString(2);

                }
            } catch (SQLException ex) {

            }
        } else {
            System.out.println("C'est autre : " + request);
        }
        jTextPane_resultset.setText(name);
        jTextPane_resultset.setText(request);

    }//GEN-LAST:event_jButton_executeActionPerformed

    private void jButton_stopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_stopActionPerformed
        // TODO add your handling code here:
        jTextPane_resultset.setText("STOP");
    }//GEN-LAST:event_jButton_stopActionPerformed

    private void jTextField_searchbarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField_searchbarActionPerformed
        // TODO add your handling code here:

    }//GEN-LAST:event_jTextField_searchbarActionPerformed

    private void jTextField_searchbarPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_jTextField_searchbarPropertyChange
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField_searchbarPropertyChange

    @SuppressWarnings("ConvertToTryWithResources")
    private void jFileChooser2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFileChooser2ActionPerformed
        // TODO add your handling code here:
        File file = jFileChooser2.getSelectedFile();

        StringBuilder local = new StringBuilder();
        try {
            BufferedReader f = new BufferedReader(new FileReader(file));
            for (;;) {
                String lg = f.readLine();
                if (lg == null) {
                    break;
                }
                local.append(lg).append("\n");
            }
            f.close();
        } catch (IOException e) {
        }
        rSyntax.setText(local.toString());

        String temp = file.toString().replace("\\", "/");
        localFile.setFile(temp);

        System.out.println(localFile);
    }//GEN-LAST:event_jFileChooser2ActionPerformed

    private void jFileChooser2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jFileChooser2MouseClicked
        // TODO add your handling code here:

    }//GEN-LAST:event_jFileChooser2MouseClicked

    @SuppressWarnings("null")
    private void jButton_commitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_commitActionPerformed
        // TODO add your handling code here:
        try {
            DbConnect c = new DbConnect();
            DbRequest rs = null;
            rs.commit();
            jTextPane_resultset.setText("COMMIT OK");
        } catch (Exception e) {
            jTextPane_resultset.setText("COMMIT KO");
        }

    }//GEN-LAST:event_jButton_commitActionPerformed

    @SuppressWarnings("null")
    private void jButton_rollbackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_rollbackActionPerformed
        // TODO add your handling code here:
        try {
            DbConnect c = new DbConnect();
            DbRequest rs = null;
            rs.rollback();
            jTextPane_resultset.setText("ROLLBACK OK");
        } catch (Exception e) {
            jTextPane_resultset.setText("ROLLBACK KO");
        }
    }//GEN-LAST:event_jButton_rollbackActionPerformed

    private void jTextField_searchbarKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_searchbarKeyPressed
        // TODO add your handling code here: modifier ou surligner le contenu de la liste dessous
    }//GEN-LAST:event_jTextField_searchbarKeyPressed

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_formKeyPressed

    private void rSyntaxKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_rSyntaxKeyReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_rSyntaxKeyReleased

    private void jMenuItemQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemQuitActionPerformed
        // TODO add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jMenuItemQuitActionPerformed

    private void jMenuItemOptionsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItemOptionsActionPerformed
        // TODO add your handling code here:
        Options Opframe = new Options();
        Opframe.setVisible(true); // Rend la fentre visible
    }//GEN-LAST:event_jMenuItemOptionsActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        String content;
        String destFile;
        int ext = 0;
        content = rSyntax.getText();
        //    destFile = "src/doc/test.txt";
        while (ext == 0) {
            JFileChooser dlg = new JFileChooser();
            dlg.addChoosableFileFilter(new MessageFilter());
            dlg.setDialogType(javax.swing.JFileChooser.SAVE_DIALOG);
            dlg.setDialogTitle("Enregistrer sous ...");
            int ret = dlg.showOpenDialog(this);
            File fileReturn;
            // Traite le contenu du fichier
            if (ret == JFileChooser.APPROVE_OPTION) {
                fileReturn = dlg.getSelectedFile();
                destFile = fileReturn.toString();
                System.out.println(destFile);
                Fichier file = new Fichier(destFile, content);
                file.fileWrite();

                String reg = "[.][a-zA-Z0-9]{3}$";
                if (file.getExtend().matches(reg)) {
                    ext = 1;
                }
                localFile.setFile(file.getFile());
            }
        }
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void langSQLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_langSQLActionPerformed
        // TODO add your handling code here:
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_SQL);
    }//GEN-LAST:event_langSQLActionPerformed

    private void langHTMLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_langHTMLActionPerformed
        // TODO add your handling code here:
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_HTML);
    }//GEN-LAST:event_langHTMLActionPerformed

    private void langJAVAActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_langJAVAActionPerformed
        // TODO add your handling code here:
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
    }//GEN-LAST:event_langJAVAActionPerformed

    private void langPHPActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_langPHPActionPerformed
        // TODO add your handling code here:
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_PHP);
    }//GEN-LAST:event_langPHPActionPerformed

    private void langCSSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_langCSSActionPerformed
        // TODO add your handling code here:
        rSyntax.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_CSS);
    }//GEN-LAST:event_langCSSActionPerformed

    @Override
    public void insertUpdate(DocumentEvent e) {
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void removeUpdate(DocumentEvent e) {
        //   throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void changedUpdate(DocumentEvent e) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    class MessageFilter extends FileFilter // Filtre les message en .msg dans la fenetre de choix d'ouverture de fichier
    {

        @Override
        public boolean accept(File f) {
            return f.isDirectory() || f.getName().endsWith(".msg");
        }

        @Override
        public String getDescription() {
            return "Fichier message (*.msg)";
        }
    }

    private CompletionProvider createCompletionProvider() {

        // A DefaultCompletionProvider is the simplest concrete implementation
        // of CompletionProvider. This provider has no understanding of
        // language semantics. It simply checks the text entered up to the
        // caret position for a match against known completions. This is all
        // that is needed in the majority of cases.
        DefaultCompletionProvider provider = new DefaultCompletionProvider();

        // Add completions for all Java keywords. A BasicCompletion is just
        // a straightforward word completion.
        String lg = null;
        String file = "src/doc/sqlserver.txt";
        DbConnect c;
        Connection cn;
        DbRequest rs = null;
        ResultSet rsTables;

        // Rcuprer les tables de la bdd
        /*
         c = new DbConnect();
         try { 
         cn = DbConnect.cConnect();
         } catch (IOException ex) {
         Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
         } catch (ParseException ex) {
         Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
         }
         try {
         rs = new DbRequest();
         } catch (ParseException ex) {
         Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
         } catch (IOException ex) {
         Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
         }
         rsTables = rs.selectTables();
         try {
         while ( rsTables.next() )
         {
         provider.addCompletion(new BasicCompletion(provider, rsTables.getString("table_name")));
         }
         } catch (SQLException ex) {
         Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
         }
         */
        // Entrer les mots cls dans le dico
        try {
            try (BufferedReader f = new BufferedReader(new FileReader(file))) {
                for (;;) {
                    lg = f.readLine();
                    if (lg == null) {
                        break;
                    }
                    if (lg.length() > 0) {
                        provider.addCompletion(new BasicCompletion(provider, lg));

                    }
                }
            }
        } catch (IOException e) {
            provider.addCompletion(
                    new ShorthandCompletion(provider, lg, "System.err.println(", "System.err.println("));
        }
        return provider;
    }

    /**
     * @param args the command line arguments
     */
    @SuppressWarnings("Convert2Lambda")
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;

                }
            }
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
                | javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null,
                    ex);
        }
        //</editor-fold>

        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton_commit;
    private javax.swing.JButton jButton_execute;
    private javax.swing.JButton jButton_rollback;
    private javax.swing.JButton jButton_stop;
    private javax.swing.JFileChooser jFileChooser2;
    private javax.swing.JLabel jLabel_searchbar;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenu jMenuEdit;
    private javax.swing.JMenu jMenuFile;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItemOptions;
    private javax.swing.JMenuItem jMenuItemQuit;
    private javax.swing.JMenu jMenuLang;
    private javax.swing.JPopupMenu jPopup_complete;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField_searchbar;
    private javax.swing.JTextPane jTextPane_resultset;
    private javax.swing.JMenuItem langCSS;
    private javax.swing.JMenuItem langHTML;
    private javax.swing.JMenuItem langJAVA;
    private javax.swing.JMenuItem langPHP;
    private javax.swing.JMenuItem langSQL;
    private org.fife.ui.rsyntaxtextarea.RSyntaxTextArea rSyntax;
    // End of variables declaration//GEN-END:variables
    private Fichier localFile = new Fichier();

    void focus() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }
}