private void LoadQueriesBtnMouseClicked( java.awt.event.MouseEvent evt) { // GEN-FIRST:event_LoadQueriesBtnMouseClicked // Algorithm /* * Goto queries' directory and load all queryfile.query to Combobox * Change local directory to repository diretory * List all file there * Try to load all file and add to combobox * * */ String sQueryRepositoryPath = "/home/natuan/Documents/OntologyMysql/QueriesRepository/"; File dir = new File(sQueryRepositoryPath); String[] children = dir.list(); if (children == null) { // Either dir does not exist or is not a directory } else { System.out.println("list files"); for (int i = 0; i < children.length; i++) { // Get filename of file or directory String filename = children[i]; String sContent = ReadWholeFileToString(sQueryRepositoryPath + filename); queryList.add(sContent); QueriesCmb.addItem(filename); SparqlTxtArea.setText(sContent); // System.out.println(filename); } QueriesCmb.setSelectedIndex(children.length - 1); } } // GEN-LAST:event_LoadQueriesBtnMouseClicked
/** * 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") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jLabel4 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); ConnectKnowledgeBaseBtn = new javax.swing.JButton(); SparqlBtn = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); SparqlTxtArea = new javax.swing.JTextArea(); jLabel1 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); JessRuleArea = new javax.swing.JTextArea(); JessTestBtn = new javax.swing.JButton(); EvaluateJessRule = new javax.swing.JButton(); JessStringTF = new javax.swing.JTextField(); jTextField1 = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); jButton2 = new javax.swing.JButton(); jTextField2 = new javax.swing.JTextField(); jTextField4 = new javax.swing.JTextField(); jPasswordField1 = new javax.swing.JPasswordField(); jCheckBox1 = new javax.swing.JCheckBox(); jLabel5 = new javax.swing.JLabel(); DurationTF = new javax.swing.JTextField(); jLabel6 = new javax.swing.JLabel(); ProjectNameTF = new javax.swing.JTextField(); BriefInfoBtn = new javax.swing.JButton(); jScrollPane2 = new javax.swing.JScrollPane(); LoggingAreaTA = new javax.swing.JTextArea(); CountInstancesBtn = new javax.swing.JButton(); ClassNameTF = new javax.swing.JTextField(); QueriesCmb = new javax.swing.JComboBox(); LoadQueriesBtn = new javax.swing.JButton(); RunThisQueryBtn = new javax.swing.JButton(); RunAllQueriesBtn = new javax.swing.JButton(); ExitBtn = new javax.swing.JButton(); SPARQL2JessBtn = new javax.swing.JButton(); ClearQueriesBtn = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance( placecommframework.PlaceCommFrameworkApp.class) .getContext() .getResourceMap(PBVCPlugin.class); setTitle(resourceMap.getString("Form.title")); // NOI18N setIconImage(null); setName("Form"); // NOI18N jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N jLabel4.setName("jLabel4"); // NOI18N jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N jLabel2.setName("jLabel2"); // NOI18N ConnectKnowledgeBaseBtn.setText( resourceMap.getString("ConnectKnowledgeBaseBtn.text")); // NOI18N ConnectKnowledgeBaseBtn.setName("ConnectKnowledgeBaseBtn"); // NOI18N ConnectKnowledgeBaseBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { ConnectKnowledgeBaseBtnMouseClicked(evt); } }); SparqlBtn.setText(resourceMap.getString("SparqlBtn.text")); // NOI18N SparqlBtn.setName("SparqlBtn"); // NOI18N SparqlBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { SparqlBtnMouseClicked(evt); } }); jScrollPane1.setName("jScrollPane1"); // NOI18N SparqlTxtArea.setColumns(20); SparqlTxtArea.setRows(5); SparqlTxtArea.setText(resourceMap.getString("SparqlTxtArea.text")); // NOI18N SparqlTxtArea.setName("SparqlTxtArea"); // NOI18N jScrollPane1.setViewportView(SparqlTxtArea); jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N jLabel1.setName("jLabel1"); // NOI18N jScrollPane3.setName("jScrollPane3"); // NOI18N JessRuleArea.setColumns(20); JessRuleArea.setRows(5); JessRuleArea.setText(resourceMap.getString("JessRuleArea.text")); // NOI18N JessRuleArea.setName("JessRuleArea"); // NOI18N jScrollPane3.setViewportView(JessRuleArea); JessTestBtn.setText(resourceMap.getString("JessTestBtn.text")); // NOI18N JessTestBtn.setName("JessTestBtn"); // NOI18N JessTestBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { JessTestBtnMouseClicked(evt); } }); EvaluateJessRule.setText(resourceMap.getString("EvaluateJessRule.text")); // NOI18N EvaluateJessRule.setName("EvaluateJessRule"); // NOI18N EvaluateJessRule.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { EvaluateJessRuleMouseClicked(evt); } }); JessStringTF.setName("JessStringTF"); // NOI18N jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N jTextField1.setName("jTextField1"); // NOI18N jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N jLabel3.setName("jLabel3"); // NOI18N jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N jButton2.setName("jButton2"); // NOI18N jTextField2.setText(resourceMap.getString("jTextField2.text")); // NOI18N jTextField2.setName("jTextField2"); // NOI18N jTextField4.setText(resourceMap.getString("jTextField4.text")); // NOI18N jTextField4.setName("jTextField4"); // NOI18N jPasswordField1.setText(resourceMap.getString("jPasswordField1.text")); // NOI18N jPasswordField1.setName("jPasswordField1"); // NOI18N jCheckBox1.setText(resourceMap.getString("jCheckBox1.text")); // NOI18N jCheckBox1.setName("jCheckBox1"); // NOI18N jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N jLabel5.setName("jLabel5"); // NOI18N DurationTF.setText(resourceMap.getString("DurationTF.text")); // NOI18N DurationTF.setName("DurationTF"); // NOI18N jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N jLabel6.setName("jLabel6"); // NOI18N ProjectNameTF.setText(resourceMap.getString("ProjectNameTF.text")); // NOI18N ProjectNameTF.setName("ProjectNameTF"); // NOI18N BriefInfoBtn.setText(resourceMap.getString("BriefInfoBtn.text")); // NOI18N BriefInfoBtn.setName("BriefInfoBtn"); // NOI18N BriefInfoBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { BriefInfoBtnMouseClicked(evt); } }); jScrollPane2.setName("jScrollPane2"); // NOI18N LoggingAreaTA.setColumns(20); LoggingAreaTA.setRows(5); LoggingAreaTA.setName("LoggingAreaTA"); // NOI18N jScrollPane2.setViewportView(LoggingAreaTA); CountInstancesBtn.setText(resourceMap.getString("CountInstancesBtn.text")); // NOI18N CountInstancesBtn.setName("CountInstancesBtn"); // NOI18N CountInstancesBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { CountInstancesBtnMouseClicked(evt); } }); ClassNameTF.setText(resourceMap.getString("ClassNameTF.text")); // NOI18N ClassNameTF.setName("ClassNameTF"); // NOI18N QueriesCmb.setName("QueriesCmb"); // NOI18N QueriesCmb.addItemListener( new java.awt.event.ItemListener() { public void itemStateChanged(java.awt.event.ItemEvent evt) { QueriesCmbItemStateChanged(evt); } }); LoadQueriesBtn.setText(resourceMap.getString("LoadQueriesBtn.text")); // NOI18N LoadQueriesBtn.setName("LoadQueriesBtn"); // NOI18N LoadQueriesBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { LoadQueriesBtnMouseClicked(evt); } }); RunThisQueryBtn.setText(resourceMap.getString("RunThisQueryBtn.text")); // NOI18N RunThisQueryBtn.setName("RunThisQueryBtn"); // NOI18N RunThisQueryBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { RunThisQueryBtnMouseClicked(evt); } }); RunAllQueriesBtn.setText(resourceMap.getString("RunAllQueriesBtn.text")); // NOI18N RunAllQueriesBtn.setName("RunAllQueriesBtn"); // NOI18N RunAllQueriesBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { RunAllQueriesBtnMouseClicked(evt); } }); ExitBtn.setText(resourceMap.getString("ExitBtn.text")); // NOI18N ExitBtn.setName("ExitBtn"); // NOI18N ExitBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { ExitBtnMouseClicked(evt); } }); SPARQL2JessBtn.setText(resourceMap.getString("SPARQL2JessBtn.text")); // NOI18N SPARQL2JessBtn.setName("SPARQL2JessBtn"); // NOI18N ClearQueriesBtn.setText(resourceMap.getString("ClearQueriesBtn.text")); // NOI18N ClearQueriesBtn.setName("ClearQueriesBtn"); // NOI18N ClearQueriesBtn.addMouseListener( new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { ClearQueriesBtnMouseClicked(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(jButton2) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 334, Short.MAX_VALUE) .addComponent(ExitBtn)) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(jLabel3) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 427, Short.MAX_VALUE)) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(JessTestBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(EvaluateJessRule) .addGap(26, 26, 26) .addComponent( JessStringTF, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel5) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( DurationTF, javax.swing.GroupLayout.DEFAULT_SIZE, 171, Short.MAX_VALUE)) .addComponent( jScrollPane3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) .addComponent( jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 478, Short.MAX_VALUE) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel4) .addComponent(jLabel1) .addComponent(jLabel2) .addComponent(jLabel6)) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent( ProjectNameTF, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent( jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent( jPasswordField1, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE) .addComponent( jTextField2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE))) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(ConnectKnowledgeBaseBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(BriefInfoBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(CountInstancesBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( ClassNameTF, javax.swing.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(SPARQL2JessBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent(SparqlBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( ClearQueriesBtn, javax.swing.GroupLayout.DEFAULT_SIZE, 104, Short.MAX_VALUE)) .addGroup( javax.swing.GroupLayout.Alignment.LEADING, layout .createSequentialGroup() .addComponent(LoadQueriesBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( QueriesCmb, 0, 185, Short.MAX_VALUE))) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addGroup( layout .createSequentialGroup() .addComponent(RunThisQueryBtn) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent(RunAllQueriesBtn)) .addComponent( jCheckBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent( jTextField4, 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.BASELINE) .addComponent(jLabel4) .addComponent( jTextField2, 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.BASELINE) .addComponent(jLabel2) .addComponent( jPasswordField1, 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.BASELINE) .addComponent(jLabel6) .addComponent( ProjectNameTF, 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.BASELINE) .addComponent(ConnectKnowledgeBaseBtn) .addComponent(BriefInfoBtn) .addComponent(CountInstancesBtn) .addComponent( ClassNameTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 109, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent( QueriesCmb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(LoadQueriesBtn) .addComponent(RunThisQueryBtn) .addComponent(RunAllQueriesBtn)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(SparqlBtn) .addComponent(jCheckBox1) .addComponent(SPARQL2JessBtn) .addComponent(ClearQueriesBtn)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(JessTestBtn) .addComponent(EvaluateJessRule) .addComponent( JessStringTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5) .addComponent( DurationTF, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(4, 4, 4) .addComponent( jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3) .addComponent( jTextField1, 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.BASELINE) .addComponent(jButton2) .addComponent(ExitBtn)))); pack(); } // </editor-fold>//GEN-END:initComponents
private void QueriesCmbItemStateChanged( java.awt.event.ItemEvent evt) { // GEN-FIRST:event_QueriesCmbItemStateChanged // TODO add your handling code here: int iQueryNumber = QueriesCmb.getSelectedIndex(); SparqlTxtArea.setText(queryList.get(iQueryNumber).toString()); } // GEN-LAST:event_QueriesCmbItemStateChanged