diff --git a/build.xml b/build.xml index 7df2979..7b80fe7 100644 --- a/build.xml +++ b/build.xml @@ -7,8 +7,8 @@ - - Builds, tests, and runs the project POTOXML_JavaSE. + + Builds, tests, and runs the project GettextDB. - + @@ -619,7 +619,7 @@ is divided into following sections: - + @@ -716,7 +716,7 @@ is divided into following sections: - + @@ -1057,7 +1057,7 @@ is divided into following sections: - + @@ -1728,7 +1728,7 @@ is divided into following sections: - + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties index a48ac56..53b4fbb 100644 --- a/nbproject/genfiles.properties +++ b/nbproject/genfiles.properties @@ -1,8 +1,8 @@ -build.xml.data.CRC32=d935f596 -build.xml.script.CRC32=b59ecd6a +build.xml.data.CRC32=de7f6ef6 +build.xml.script.CRC32=1935e2d7 build.xml.stylesheet.CRC32=f85dc8f2@1.106.0.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=d935f596 -nbproject/build-impl.xml.script.CRC32=da07b80d +nbproject/build-impl.xml.data.CRC32=de7f6ef6 +nbproject/build-impl.xml.script.CRC32=93caa791 nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.106.0.48 diff --git a/nbproject/private/private.xml b/nbproject/private/private.xml index 25f13b2..6807a2b 100644 --- a/nbproject/private/private.xml +++ b/nbproject/private/private.xml @@ -2,8 +2,6 @@ - - file:/O:/projects/Workspace_Java/GettextDB/src/potoxml/NewJFrame.java - + diff --git a/nbproject/project.properties b/nbproject/project.properties index 43a75b3..2d8bc9b 100644 --- a/nbproject/project.properties +++ b/nbproject/project.properties @@ -3,7 +3,7 @@ annotation.processing.enabled.in.editor=false annotation.processing.processors.list= annotation.processing.run.all.processors=true annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=POTOXML_JavaSE +application.title=GettextDB application.vendor=ivanov.i build.classes.dir=${build.dir}/classes build.classes.excludes=**/*.java,**/*.form @@ -27,7 +27,7 @@ debug.test.modulepath=\ ${run.test.modulepath} # This directory is removed when the project is cleaned: dist.dir=dist -dist.jar=${dist.dir}/POTOXML_JavaSE.jar +dist.jar=${dist.dir}/GettextDB.jar dist.javadoc.dir=${dist.dir}/javadoc endorsed.classpath= excludes= @@ -68,7 +68,7 @@ javadoc.use=true javadoc.version=false javadoc.windowtitle= jlink.launcher=false -jlink.launcher.name=POTOXML_JavaSE +jlink.launcher.name=GettextDB main.class=potoxml.NewJFrame manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF diff --git a/nbproject/project.xml b/nbproject/project.xml index 003e6af..245184b 100644 --- a/nbproject/project.xml +++ b/nbproject/project.xml @@ -3,7 +3,7 @@ org.netbeans.modules.java.j2seproject - POTOXML_JavaSE + GettextDB diff --git a/settings.ini b/settings.ini index c0c664d..5b74044 100644 --- a/settings.ini +++ b/settings.ini @@ -2,9 +2,11 @@ db_url = jdbc\:postgresql\://10.1.7.74\:5432/pilot db_user = translate db_password = translate + [path0] -path=O:\\projects\\Workspace_PHP\\transit.istt.kz -check=[0-9|a-z|A-Z|_]+ -extensions=*.php -pattern=trt( -type=5 \ No newline at end of file +path = O\:\\projects\\Workspace_PHP\\transit.istt.kz +check = trt( +extensions = (.*\\.php$)||(.*\\.xml$)||(.*\\.js$) +pattern = [0-9|a-z|A-Z|_]+ +type = 5 + diff --git a/settings.txt b/settings.txt deleted file mode 100644 index cc3ad43..0000000 --- a/settings.txt +++ /dev/null @@ -1,2 +0,0 @@ -O:\projects\Workspace_PHP\transit.istt.kz -O:\temp\1.txt diff --git a/src/potoxml/NewJFrame.form b/src/potoxml/NewJFrame.form index 0dc969a..efd9cf6 100644 --- a/src/potoxml/NewJFrame.form +++ b/src/potoxml/NewJFrame.form @@ -31,8 +31,7 @@ - - + @@ -52,7 +51,6 @@ - @@ -131,7 +129,7 @@ - + @@ -149,7 +147,7 @@ - +
@@ -217,7 +215,7 @@
- +
@@ -229,9 +227,6 @@ - - - @@ -239,9 +234,6 @@ - - - @@ -249,17 +241,39 @@ - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -285,14 +299,6 @@ - - - - - - - - diff --git a/src/potoxml/NewJFrame.java b/src/potoxml/NewJFrame.java index 82cb6ea..fca93d0 100644 --- a/src/potoxml/NewJFrame.java +++ b/src/potoxml/NewJFrame.java @@ -13,13 +13,19 @@ import java.io.FileWriter; import java.io.FilenameFilter; import java.io.IOException; import java.io.StringReader; +import java.net.URISyntaxException; +import java.net.URLDecoder; +import java.security.CodeSource; import java.util.List; import java.util.Stack; import java.util.logging.Level; import java.util.logging.Logger; import java.sql.Connection; import java.sql.DriverManager; +import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Statement; +import javax.swing.JOptionPane; import javax.swing.table.DefaultTableModel; import org.ini4j.Ini; @@ -38,9 +44,23 @@ public class NewJFrame extends javax.swing.JFrame initComponents(); setTitle("GettextDB"); + jTable1.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); try { - File file = new File("settings.ini"); + String jarDir=""; + CodeSource codeSource = NewJFrame.class.getProtectionDomain().getCodeSource(); + File jarFile=null; + try { + jarFile = new File(codeSource.getLocation().toURI().getPath()); + } catch (URISyntaxException ex) { + Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex); + } + if(jarFile!=null){ + jarDir = jarFile.getParentFile().getPath()+"\\"; + } + textArea1.append("JAR file path: " + jarDir + "\n"); + + File file = new File(jarDir + "settings.ini"); if(file.exists()){ Ini ini = new Ini(file); jTFDBURL.setText(ini.get("main", "db_url")); @@ -55,7 +75,7 @@ public class NewJFrame extends javax.swing.JFrame String extensions = ini.get("path"+i, "extensions"); String pattern = ini.get("path"+i, "pattern"); String type = ini.get("path"+i, "type"); - model.addRow(new Object[]{path, extensions, pattern, check, type }); + model.addRow(new Object[]{path, extensions, check, pattern, type }); System.out.print(path); } } @@ -89,10 +109,10 @@ public class NewJFrame extends javax.swing.JFrame jLabel6 = new javax.swing.JLabel(); jTFDBPassword = new javax.swing.JTextField(); jButton5 = new javax.swing.JButton(); + jPanel1 = new javax.swing.JPanel(); jBSaveSettings = new javax.swing.JButton(); jButton1 = new javax.swing.JButton(); textArea1 = new java.awt.TextArea(); - jButton3 = new javax.swing.JButton(); jCheckBox1 = new javax.swing.JCheckBox(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -107,7 +127,7 @@ public class NewJFrame extends javax.swing.JFrame }, new String [] { - "Файл/Путь", "Расширения файлов", "Шаблон поиска", "Шаблон проверки", "ID типа слов" + "Файл/Путь", "Расширения файлов", "Название функции (", "Шаблон проверки", "ID типа слов" } ) { Class[] types = new Class [] { @@ -128,24 +148,23 @@ public class NewJFrame extends javax.swing.JFrame ); jPanel2Layout.setVerticalGroup( jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 179, Short.MAX_VALUE) ); jTabbedPane1.addTab("Настройки путей сканирования", jPanel2); jLabel4.setText("Строка соединения"); - jTFDBURL.setText("jdbc:postgresql://10.1.7.74:5432/pilot"); - jLabel5.setText("Пользователь"); - jTFDBUser.setText("translate"); - jLabel6.setText("Пароль"); - jTFDBPassword.setText("translate"); - jButton5.setText("Проверить соединение"); + jButton5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton5ActionPerformed(evt); + } + }); javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); jPanel3.setLayout(jPanel3Layout); @@ -186,11 +205,24 @@ public class NewJFrame extends javax.swing.JFrame .addComponent(jLabel6)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton5) - .addContainerGap(36, Short.MAX_VALUE)) + .addContainerGap(66, Short.MAX_VALUE)) ); jTabbedPane1.addTab("Настройки соединения с базой", jPanel3); + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 915, Short.MAX_VALUE) + ); + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 179, Short.MAX_VALUE) + ); + + jTabbedPane1.addTab("Настройки экспорта PO или XML файлов", jPanel1); + jBSaveSettings.setText("Сохранить настройки"); jBSaveSettings.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { @@ -242,13 +274,6 @@ public class NewJFrame extends javax.swing.JFrame } }); - jButton3.setText("Экспорт PO или XML файла"); - jButton3.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton3ActionPerformed(evt); - } - }); - jCheckBox1.setText("Экспортировать в базу при сканировании"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); @@ -260,8 +285,7 @@ public class NewJFrame extends javax.swing.JFrame .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(textArea1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() - .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 298, javax.swing.GroupLayout.PREFERRED_SIZE) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGap(0, 0, Short.MAX_VALUE) .addComponent(jCheckBox1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1)) @@ -277,7 +301,6 @@ public class NewJFrame extends javax.swing.JFrame .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) - .addComponent(jButton3) .addComponent(jCheckBox1)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); @@ -285,7 +308,7 @@ public class NewJFrame extends javax.swing.JFrame pack(); }// //GEN-END:initComponents - private void parse(String rootDir,String extensions,String pattern,String check,String type) + private void parse(Connection conn, String rootDir, String extensions, String check, String pattern, String type) { // Просматриваем каталоги FileFinder finder = new FileFinder(); @@ -297,8 +320,7 @@ public class NewJFrame extends javax.swing.JFrame //bufferedWriter.write("=0) { - from=s+pattern.length(); + from=s+check.length(); to=line.indexOf(")", from); //int e=-1; - //if(line.charAt(s+pattern.length()) == '"') { e=line.indexOf("\")", from); } - //if(line.charAt(s+pattern.length()) == '\'') { e = line.indexOf("')", from); } + //if(line.charAt(s+check.length()) == '"') { e=line.indexOf("\")", from); } + //if(line.charAt(s+check.length()) == '\'') { e = line.indexOf("')", from); } if(to>=0) { String text = line.substring(from, to); @@ -358,8 +380,18 @@ public class NewJFrame extends javax.swing.JFrame } if(text.length()>0){ - if(text.matches("[0-9|a-z|A-Z|_]+")){ + //if(text.matches("[0-9|a-z|A-Z|_]+")){ + if(text.matches(pattern)){ textArea1.append(text+"\n"); + + //Обновляю в базе + if(conn!=null){ + try (Statement stmt = conn.createStatement()) { + ResultSet rs = stmt.executeQuery("select main._update_translation_identifier('"+text+"',"+type+");"); + } catch (SQLException e) { + textArea1.append("Error write to DB\n"); + } + } }else{ textArea1.append("NO VALUD = "+text+"\n"); } @@ -389,22 +421,25 @@ public class NewJFrame extends javax.swing.JFrame private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton1ActionPerformed {//GEN-HEADEREND:event_jButton1ActionPerformed //Подключаюсь к базе данных - String url = jTFDBURL.getText(); //"jdbc:postgresql://10.1.7.74:5432/pilot"; - String user = jTFDBUser.getText(); //"translate"; - String password = jTFDBUser.getText(); //"translate"; Connection conn = null; - try { - Class.forName("org.postgresql.Driver"); - conn = DriverManager.getConnection(url, user, password); - System.out.println("Connected to the PostgreSQL server successfully."); - }catch(ClassNotFoundException | SQLException e){ - System.out.println(e.getMessage()); + if(jCheckBox1.isSelected()){ + String url = jTFDBURL.getText(); //"jdbc:postgresql://10.1.7.74:5432/pilot"; + String user = jTFDBUser.getText(); //"translate"; + String password = jTFDBUser.getText(); //"translate"; + try { + Class.forName("org.postgresql.Driver"); + conn = DriverManager.getConnection(url, user, password); + System.out.println("Connected to the PostgreSQL server successfully."); + }catch(ClassNotFoundException | SQLException e){ + System.out.println(e.getMessage()); + } } //Перебираю значения таблицы и пускаю на сканирование каждое поле DefaultTableModel model = (DefaultTableModel) jTable1.getModel(); for(int row=0;row